It does boot the C64 as well.
With as little as 2K RAM but that results in 0 basic bytes free.
But not the PET yet.
It does boot the C64 as well.
With as little as 2K RAM but that results in 0 basic bytes free.
But not the PET yet.
So in order to run c64 v2 I need Basic and kernal roms, and I need to convert them into the "source format". I guess I need to change the addresses in the cpu.c as well (I am using the original code without the display stuff..). Are there any other changes needed?
pito:
So in order to run c64 v2 I need Basic and kernal roms, and I need to convert them into the "source format". I guess I need to change the addresses in the cpu.c as well (I am using the original code without the display stuff..). Are there any other changes needed?
This change is needed in cpu.c to boot the C64:
uint8_t read6502(uint16_t address) {
if ((address >= 0xA000)&&(address < 0xC000)) return BIOS[(address - 0xA000)];
if (address >= 0xE000) return BIOS[(address - 0xC000)];
if ((address >= 0xD000)&&(address < 0xD800)) return(0);
if (address < RAM_SIZE) return(RAM[address]);
}
void write6502(uint16_t address, uint8_t value) {
if (address < RAM_SIZE) {
RAM[address] = value;
if ((address>1023)&&(address<2024)) {
writeVIDEO(address-1024,value);
}
}
}
For the BIOS I used this file: 64c.251913-01.bin that has both the BASIC and KERNAL ROM's in a single file.
The writeVIDEO puts a char on the TFT if it gets written into screenmemory at $400.
Do we still need the
prog_uchar BIOStop[256] PROGMEM = {....
stuff there?
pito:
Do we still need theprog_uchar BIOStop[256] PROGMEM = {....stuff there?
You can remove the BIOStop array.
Ok, I converted the rom and changed to (I am not using the video version yet):
uint8_t read6502(uint16_t address) {
uint8_t tempval = 0;
if (address == 0xF004) { //EhBASIC simulated ASIC input
tempval = getkey();
clearkey();
return(tempval);
}
if ((address >= 0xA000)&&(address < 0xC000)) return BIOS[(address - 0xA000)];
if (address >= 0xE000) return BIOS[(address - 0xC000)];
if ((address >= 0xD000)&&(address < 0xD800)) return(0);
if (address < RAM_SIZE) return(RAM[address]);
}
void write6502(uint16_t address, uint8_t value) {
if (address < RAM_SIZE) RAM[address] = value;
if (address == 0xF001) { //EhBASIC simulated ASIC output
serout(value);
}
}
pito:
Ok, I converted the rom and changed to (I am not using the video version yet):uint8_t read6502(uint16_t address) {
uint8_t tempval = 0;
if (address == 0xF004) { //EhBASIC simulated ASIC input
tempval = getkey();
clearkey();
return(tempval);
}
if ((address >= 0xA000)&&(address < 0xC000)) return BIOS[(address - 0xA000)];
if (address >= 0xE000) return BIOS[(address - 0xC000)];
if ((address >= 0xD000)&&(address < 0xD800)) return(0);
if (address < RAM_SIZE) return(RAM[address]);
}
void write6502(uint16_t address, uint8_t value) {
if (address < RAM_SIZE) RAM[address] = value;
if (address == 0xF001) { //EhBASIC simulated ASIC output
serout(value);
}
}
Yes, that is right.
janost:
...
But you're right about it being cool.
Wish I could find a keyboard that matches the size
I'm thinking an old cellphone slide keyboard, or maybe a Blackberry...
One of the "for parts" eBay things...


No luck yet. I've tried with 65536 ramsize, and 30000 ramsize. I have got 128kB ram so no problem.
The ehBasic boots and works fine with 49k ramsize.
I did only the changes above..
Maybe the i/o addresses differ..
mrburnette:
janost:
...
But you're right about it being cool.
Wish I could find a keyboard that matches the sizeI'm thinking an old cellphone slide keyboard, or maybe a Blackberry...
One of the "for parts" eBay things...
I have the top one in my museum ![]()
pito:
No luck yet. I've tried with 65536 ramsize, and 30000 ramsize. I have got 128kB ram so no problem.
The ehBasic boots and works fine with 49k ramsize.
I did only the changes above..
Maybe the i/o addresses differ..
But you will basically end up with a 1000byte screen that you cant see at RAM[1024]
Can you explain, plz?
Does it mean the C64 has no i/o similar to enhBasic but I have to use the output from videoram?
pito:
Can you explain, plz?
The PET/VIC-20/C64/C128 is a fullscreen editor and not a terminal OS.
All output gets written to videomemory.
And all input is read from videomemory on the line your are standing on with the cursor when you press enter.
It is possible to redirect the output because that is written through a vector at $FFD2
Not sure about the input but it may be possible,
It's been long since I hacked any of those but by modifying the KERNAL you may get it to work like EHBASIC.
Not sure how good it will work though.
Ok, thanks, so I need to think about a new i/o code..
I was the Atari520 user at that time, so no idea how the C64 works ![]()
It was Amiga for me ![]()
I used this when I first began with the VIC-20 EMU
It write out the videomemory to serial so you can at least see if it boots.
for (byte y=0;y<23;y++) {
for (byte x=0;x<22;x++) {
for (byte z=0;z<100;z++) {
exec6502();
}
petscii=videomem[eeaddress++];
if (petscii<32) {
petscii=petscii+64;
}
USART_write(petscii);
}
USART_write(10);
USART_write(13);
}
Ok, it seems it boots:
void loop () {
// exec6502(100); //if timing is enabled, this value is in 6502 clock ticks. otherwise, simply instruction count.
// if (Serial.available()) {
// curkey = Serial.read() & 0x7F;
// }
//}
int address = 0;
for (int y=0;y<25;y++) {
for (int x=0;x<40;x++) {
exec6502(100);
unsigned char petscii=VRAM[address++];
if (petscii<32) {
petscii=petscii+64;
}
Serial.write(petscii);
}
Serial.println();
}
}

Ok, that's great.
Now to the input,
Since interrupts are not running, to get characters in as they was typed on the non existent keyboard, you need to "poke" those into the keyboard buffer.
This code:
void loop() {
exec6502();
RAM[198]=1;
RAM[631]=65;
}
Results in the attached picture ![]()
So basically you remove the 0xF004 and getval from the read6502 function.
The you add an "If serial.available" in the loop function and poke the available character into the keyboard buffer.
void loop () {
int v_address = 0;
Serial.write(27); // Move to Home
Serial.write("[H");
for (int y=0;y<25;y++) {
for (int x=0;x<40;x++) {
exec6502(100);
if (Serial.available()) {
curkey = Serial.read() & 0x7F;
RAM[198]=1;
RAM[631]=curkey;
}
unsigned char petscii=VRAM[v_address++];
if (petscii<32) petscii=petscii+64;
Serial.write(petscii);
}
Serial.write(13);
Serial.write(10);
}
}

pito:
void loop () {
int v_address = 0;
Serial.write(27); // Move to Home
Serial.write("[H");
for (int y=0;y<25;y++) {
for (int x=0;x<40;x++) {
exec6502(100);
if (Serial.available()) {
curkey = Serial.read() & 0x7F;
RAM[198]=1;
RAM[631]=curkey;
}
unsigned char petscii=VRAM[v_address++];
if (petscii<32) petscii=petscii+64;
Serial.write(petscii);
}
Serial.write(13);
Serial.write(10);
}
}
Cool
You're able to run it. ![]()