Commodore 64

From bibbleWiki
Jump to navigation Jump to search

Introduction

This page is to provide steps to install a commodore 64 emulator and tools on Ubuntu. At the time this was on Ubuntu 20.04 LTS with kernel 5.4.0-47-generic

Downloads

  • I downloaded vice emu [1]

apt install

I needed to install the following but of course it will be different for all.

sudo apt install flex
sudo apt install bison
sudo apt install xa65 
sudo apt install libpng-dev
sudo apt-get install libsdl2-dev
sudo apt-get install texinfo

The lack of textinfo caused

/bin/bash: no: command not found
make[2]: *** [Makefile:1119: vice.txt] Error 127
make[1]: *** [Makefile:734: all-recursive] Error 1
make: *** [Makefile:508: all-recursive] Error 1

Configure, Build And Install

And to build

 ./configure
./make -j 16
sudo make install

Creating a Program

Install Tools

First clone the tools

git clone https://github.com/cc65/cc65

Build the Tools

No suprises

cd cc65
make
export PATH:`pwd`/bin:$PATH

Get The Source

I chose to build my Balloon Sprite because I can. I remember typing this in religiously but of course now cut and paste is a lot simpler and it is now in "C". I was in BASIC back in the day

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <peekpoke.h>

const char sprite[] = {
	0,127,0,1,255,192,3,255,224,3,231,224,
	7,217,240,7,223,240,7,217,240,3,231,224,
	3,255,224,3,255,224,2,255,160,1,127,64,
	1,62,64,0,156,128,0,156,128,0,73,0,0,73,0,
	0,62,0,0,62,0,0,62,0,0,28,0
};

int v = 0xD000;	// START OF DISPLAY CHIP

// Need wait function to slow down x loop
void rasterWait(void) {
	unsigned char raster;
	do {
		raster = PEEK(v + 18);
	} while (raster < 250 || raster > 252);
}

int main (void)
{
	unsigned char n;
	unsigned char x;
	unsigned char t;
    printf ("%c", 147);
	POKE(v + 21, 28); 			// ENABLE SPRITE 2, 3, 4
	POKE(2042, 13);				// SPRITE 2 DATA FROM 13TH BLK
	POKE(2043, 13);				// SPRITE 3 DATA FROM 13TH BLK
	POKE(2044, 13);				// SPRITE 4 DATA FROM 13TH BLK

	for (n = 0 ; n < sizeof(sprite) ; n++) {
		POKE(832 + n, sprite[n]);
	}
	POKE(v + 23, 12); // Expand sprite 2, 4 x direction
	POKE(v + 29, 12); // Expand sprite 2, 4 y direction
	
	do {
		for (x = 1 ; x <= 190; x++) {
			POKE(v + 4, x); 		// UPDATE X COORDINATES
			POKE(v + 6, x);
			POKE(v + 8, x);
			POKE(v + 5, x); 		// UPDATE Y COORDINATES
			POKE(v + 7, 190 - x);
			POKE(v + 9, 100);
			rasterWait();
		}
	} while (1);
    return EXIT_SUCCESS;	
}

Build Source

Make sure the bin directory is in your path.

cl65 -O -t c64  sprite.c

Make a Drive and copy Program

Hmmmm copy program. Sounds like it is really from the past. Not app, not exe, not binary - program

c1541 -format diskname,id d64 my_diskimage.d64 -attach my_diskimage.d64 -write sprite

Running the Emulator

For me I was after the commodore 64 so

x64sc

In the emulator I had to map my drive created previously. Then in the emulator I type

LOAD "0:SPRITE",8

C64 balloon.png

Install VICE emulator

This does not work off the bat as there seems to be some licensing issue so I obviously do not support this

apt install vice

We need to copy additional files /usr/share/vice/C64

$ wget http://www.zimmers.net/anonftp/pub/cbm/crossplatform/emulators/VICE/vice-3.x.tar.gz
$ tar -zxvf vice-3.x.tar.gz

$ cd vice-3.3/data/C64
$ sudo cp chargen kernal basic /usr/share/vice/C64

$ cd vice-3.3/data/DRIVES
$ sudo cp d1541II d1571cr dos* /usr/share/vice/DRIVES/