Commodore 64: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
No edit summary
Line 27: Line 27:
sudo make install
sudo make install
</syntaxhighlight>
</syntaxhighlight>
=Creating a Program=
==Install Tools==
First clone the tools
<syntaxhighlight lang="bash">
git clone https://github.com/cc65/cc65
</syntaxhighlight>
==Build the Tools==
No suprises
<syntaxhighlight lang="bash">
cd cc65
make
export PATH:`pwd`/bin:$PATH
</syntaxhighlight>
==Build 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
<syntaxhighlight lang="c">
#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;
}
</syntaxhighlight>
=Running the Emulator=
=Running the Emulator=
For me I was after the commodore 64 so
For me I was after the commodore 64 so

Revision as of 01:33, 23 September 2020

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

Build 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;	
}

Running the Emulator

For me I was after the commodore 64 so

x64sc