Getting C code written for 2560 on Arduino board

Hello all,

I have an arduino Mega 2560 board.

I have an Asteroids program I want to upload to the board that is written for the 2560 chip, but is written in c.

I have tried copying the c program and dumping it in Arduino IDE with no success.

Can anyone assist?

This will be connected to a AVR scope clock to play asteroids on a CRT.

Thanks for any assistance or leads on this one.

asteroids.c (26.6 KB)

Which version of the IDE did you try?

The code you posted looks like an Arduino sketch with setup() and loop() function, but contains no main() function, so I think it must be written for some version of the Arduino-IDE.

Delta_G:
What exactly do you mean? Does it not compile? Or does it not run the way you want? What doe it actually do and how does that compare to what you want? No success can mean a lot of things.

It could also mean: he failed with doing copy-and-paste, perhaps from the Windows Wordpad editor to the Arduino-IDE?

Thanks for the responses guys.

The IDE Im using is 1.6.7

Sorry to be vague with the 'no success'

It gives a whole bunch of errors I have attached the text of the errors.

I know the program works as many others have used it as is, and it is written for the 2560, perhaps it is the IDE Jurs?

I am using a Mac if that changes things? Using Text Edit to cut and paste from

asteroids errors.pdf (58.9 KB)

Maybe. Recently released versions IDE 1.6.6 and 1.6.7 are VERY buggy. Better avoid them.

Perhaps you try to find out the date when the file you try to compile was released, then look up the Arduino release notes which was the current version of the Arduino-IDE at that time, then install and use that version of the IDE.

Sorry, uploaded now...

I also have the compiled hex available, is there any way to drop this directly on the chip?

I found a program called hex uploader for mac, anyone used this before?

Looks like it could be Arduino 0020, I am downloading it now and I'll see if that does the trick, thanks Jurs.

I don't know anything about MAC.

With a Windows PC you could use XLoader to upload a HEX file easily.

With MAC you could set the Arduino-IDE preferences to verbose output during upload (with any sketch you want) and watch the upload messages in the status window.

Watch out for the call of the "avrdude" upload command which uploads the temporary hex file.

If you are able to create a similar upload command for your existing hex file (with all the cryptic parameters in the command line), then you can use the "avrdude" tool for upload, which is part of the Arduino IDE.

Delta,

That cleared up a lot, there are still some errors left.

I have attached them.

This is using the Arduino 0020 IDE

Asteroids errors 0020.pdf (22.2 KB)

Interesting, I think I know what may be the reason.

The site I got the asteroids program from used a STK600-ATMEGA2560 board to link with he Dutchtronics Scope Clock terminal. Just seen also their baud rate is 250,000 not 115,200 (I don't actually know what that means but is that an issue too?).

http://www.dutchtronix.com/TerminalH3-1-Enhanced.htm#Demo

Does this mean Im fighting a loosing battle trying to get this to be Arduino compatible?

Might be easier to focus on getting the compiled HEX onto the 2560?

I might have to install windows on my computer to try XLoader to get the Hex on there.

Thanks Delta, I'll have a read through and see what I can come up with.

The baud rate on the scope clock terminal can be changed so that fixes the baud rate issue.

Cheers.

The link you posted has clear instructions on how to upload the program, Why not follow that.

The programming tool avrdude, part of the free WinAVR suite of programming tools, is used to upload firmware from your computer to the clock board.

I recognized in the code you posted some modifications I made to the original asteroids.c from wherever Jan at Dutchtronixs got it.

I did not implement Asteroids on an Arduino, instead I implemented it on a PC, using the Code::Blocks IDE. I wrote a set of companion routines (e.g. VGClearScreen(), etc.) that send the vectors and commands to the Scope Clock board via the serial port at 115,200 baud. It should not be difficult to modify the VG*() functions to run on the Arduino, all they do is send some characters to the serial port. It is much easier to do that on the Arduino than on the PC (in an efficient way, especially if a USB-TTL serial adapter is involved).

I've attached the code (too big to post in line). See the VectorGen folder for the PC game and vector driver, VectorGenDemo3.c, which #includes the asteroids.c game. It works fine, but not as much fun as the original stand-up console version, partly because the ship never explodes. Have fun.

Edit: In looking through this stuff again, I realized that the original source code for the much simpler VG*() UART routines is still in the code, but commented out. Look in the folder "Asteroids" at asteroids.c

Asteroids.zip (148 KB)

Thanks Jremington,

Do you think I should try to copy and paste the Asteroids.c you have posted here into the Arduino IDE to compile, will that work? Which IDE version would be best for that?

This is my first delve into Arduino and programming so I'm at a loss but hoping to learn.

As I think the modifications you are talking about might be because he implemented it on a STK-600 development board.

Either way will using the .hex file uploaded directly to the 2560 on the arduino board work?

Thanks for your help with this. I'm borrowing a windows computer tonight to give it a go using XLoader

The asteroids folder in the zip file I posted contains code that could, with some effort, run under the Arduino IDE. The key will be to get the VG*() and UART functions working. For a first Arduino project, this may be rather challenging.

If you want to run the game using a PC connected to the ScopeClock, download the Code::Blocks IDE, click open the "Asteroids.cbp" file and generate an executable.

Great thanks JR,

I mostly build amplifiers etc with valve tech.

The idea is to use a 1930's clear 903 CRT, valve driven to display the clock and have asteroids function, so sooner or later I would like it running on the Mega 2560 board so it can be neatly installed inside a self contained cabinet

RCA Type 906 3-Inch CRT (clear construction which would look ace exposed).

For now I might build up the clock and test it using a PC, then read up on arduino to get it going on that.

I will still try uploading the hex compiled for the 2560 onto the mega 2560 board and see what happens.

Is there a chance that .hex file will work straight out of the box if uploaded directly to the chip using Xloader or is it a futile exercise trying?

Does the fact that the chip is installed in a mega 2560 arduino board and not an stk-600 development board as dutchtronics have a factor?

Seems the guys at dutchtronics got it working on the 2560 with that .hex file

That tube is a beauty!

The Arduino IDE can upload a premade .hex file, but off the top of my head I can't tell you how to do it. Worth a try!

Ok I'll give it a go and report back.

Yes I have two of the 906 tubes, been waiting for the right project to use one, I think this is it.

Cheers.