Snake on Commodore 64

Commodore 64 was a popular computer during the eighties. It's is still possible to get hold of one; Either by buying a vintage computer from an auction site or you could get a reproduction made with modern technology. If you do not want the real-thing, you could use an emulator

We will make the game snake or nibbles on the c64. Snake is a well-known game that have been available in many platforms, lately also on playstation 3. This tutorial will be on Linux, but don't worry, we will show how you can easily use Linux from either Windows or Mac OSX.

Step 1

Download vmware player;

http://www.vmware.com/products/player/

Step 2

You going to need a virtual applicance that will run from vmware player.

We use this one;

http://www.quotrader.org/vm/ubuntu1004/

If you do not want to follow step 1 to Step 7 it's possible to get a pre-installed version from us (post@retrotard.com)

Step 3

Start-up the downloaded vmware image, you will be prompted from a password, which (if you downloaded some of the above images) is "password"

Step 4

Next we need to install a c64 emulator. Start up a terminal, then type:

sudo apt-get install vice

This will install a c64 emulator. In addition for this emulator, vice, we also need to install some rom files. Start firefox browser inside your Linux, and go to

http://www.zimmers.net/anonftp/pub/cbm/crossplatform/emulators/VICE/old/index.html

Download: vice-0.14.2-roms.tar.gz

Locate the downloaded files, usually by typing the following in the terminal:

cd /home/user/Downloads

Extract the files by typing:

tar -xvfz vice-0.14.2-roms.tar.gz

Next copy the rom files so the emulator can find them

sudo cp * /usr/lib/vice/C64/.

type:

x64

to start the emulator

Step 5

Let's play around with the emulator, type

poke 53281,0

inside the emulator

Try to change 0 to a number between 0 and 15. poke means, place a value in memory, and by placing 0 at position 54281 in memory we change the color of the screen.

Step 6

We could go ahead an write snake in the built in basic on the c64, but that wouldn't be very satisfying. We could also find an assembler, but that would be a bit to detailed. The cool thing would be to build it on your host computer (linux) and send it to the c64 emulator. Luckily for us, there is a C compiler that produces c64 binaries that are compatible with the emulator.

go to :

ftp://ftp.musoftware.de/pub/uz/cc65/

download:

cc65-sources-2.13.2.tar.bz2

and

cc65-c64-2.13.2-1.zip

Locate the downloaded files, and extract them with:

tar -xvf cc65-sources-2.13.2.tar.bz2

and

unzip cc65-c64-2.13.2-1.zip

Step 7

Locate the extracted directory cc65-2.13.2

cd cc65-2.13.2

Then type:

sudo make -f make/gcc.mak

Then

sudo make -f make/gcc.mak install

Now your development environment should be all set up. If you want to skip this part, you could get the vmware file from here

Step 8

Open gedit to type in the program

gedit snake.c &

type in (or copy and paste) the following code into gedit:

Save the file, and type:

cc65 -O -t c64 snake.c

Then

ca65 snake.s

and finally:

ld65 -t c64 -o snake snake.o lib/c64.lib

Where c64 lib is found in the directoy of the zip file

Step 9

Now let's try out the game:

x64 snake

which should make something like this:

Conclusion

The game is played by setting the joystick in port no.2

For an interactive video guide, contact us post@retrotard.com