Upload files to "/"
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
*.o
|
||||
*.bin
|
||||
rom.txt
|
||||
@@ -0,0 +1,14 @@
|
||||
all:
|
||||
ca65 -g basic/basic.s
|
||||
ca65 -g kernal/kernal.s
|
||||
ld65 -C rom.cfg -o rom.bin basic/basic.o kernal/kernal.o -Ln rom.txt -m map.txt
|
||||
# if it's the unchanged 901226-01 image, use old checksum algorithm
|
||||
$$SHELL -c "if [ $$(crc32 basic.bin) == cfdebff8 ]; then \
|
||||
python checksum.py --old basic.bin 0xa0 0x1f52; \
|
||||
else \
|
||||
python checksum.py --new basic.bin 0xa0 0x1f52; \
|
||||
fi"
|
||||
python checksum.py --new kernal.bin 0xe0 0x4ac
|
||||
|
||||
clean:
|
||||
rm -f basic/basic.o kernal/kernal.o basic.bin kernal.bin rom.bin
|
||||
@@ -1,3 +1,45 @@
|
||||
# ATX64-ROMs
|
||||
# Commodore 64 BASIC and KERNAL Source
|
||||
|
||||
Kernal and Basic ROMs for my ATX64 project
|
||||
This repository contains the Commodore 64 BASIC and KERNAL source in a format that is easy to edit and can be built using modern tools on modern systems. It is derived from the [original sources](https://www.github.com/mist64/cbmsrc), with all original symbols and comments intact.
|
||||
|
||||
## Building
|
||||
|
||||
* Requires
|
||||
* [cc65](https://github.com/cc65/cc65).
|
||||
* make, Python, crc32
|
||||
* Use `make` to build.
|
||||
* The resulting files are
|
||||
* `basic.bin` (`$A000`-`$BFFF`): identical with basic.901226-01.bin
|
||||
* `kernal.bin` (`$E000`-`$FFFF`): identical with kernal.901227-03.bin
|
||||
|
||||
## Modifying
|
||||
|
||||
The major parts of KERNAL reside in their own segments that will always be linked to their original addresses, so if you want to remove tape or RS232 support, for example, the other sections will still remain where they should be in the image.
|
||||
|
||||
## Checksums
|
||||
|
||||
Commodore built all ROMs so that the 8 bit checksum matches the upper 8 bits of the location in the address space, e.g. BASIC is located at `$A000`, so its checksum has to be `$A0`. There is one "checksum adjust byte" at a dedicated location in every ROM that is updated after the build to cause the correct checksum. In BASIC, this is at `$BF52` (`CKSMA0`) and in KERNAL, it's at `$E4AC`.
|
||||
|
||||
The algorithm looks like this:
|
||||
|
||||
10 A=0:C=0
|
||||
20 FOR I=16384 TO 24575
|
||||
30 B=PEEK(I)
|
||||
40 A=A+B+C:C=0
|
||||
50 IF A>255 THEN A=A-256:C=1
|
||||
60 NEXT
|
||||
70 PRINTA
|
||||
|
||||
Starting in 1983 though, they started using a slightly different algorithm (that adds the final carry) with _most_ ROMs:
|
||||
|
||||
65 A=A+C
|
||||
|
||||
The only version of C64 BASIC is from 1982 and uses the old checksum. The -03 version of the KERNAL is from 1983 and uses the new checksum.
|
||||
|
||||
Any ROMs after 1983 (so also all ROMs we create today) should be checksummed using the new algorithm. The Makefile will use the old algorithm on BASIC if it's unchanged from the 901226-01 version, otherwise it will use the new algorithm. The KERNAL checksum will always use the new algorithm.
|
||||
|
||||
## Credits
|
||||
|
||||
This version is maintained by Michael Steil <mist64@mac.com>, [www.pagetable.com](https://www.pagetable.com/)
|
||||
|
||||
Forked by insanity213, blasted in some wozmon, savagely ripped out tape and rs232 support. There may still be some little pieces of tape and rs232 in there, need to clean up some more. Passed diag cart test, ccgms seems to run with the swiftlink driver and run a few demos. Initial version 0.2. 0.3 in progress, hope to shuffle some more stuff around to make the free blocks as large as possible.
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
ca65 -g basic/basic.s
|
||||
ca65 -g kernal/kernal.s
|
||||
ld65 -C rom.cfg -o rom.bin basic/basic.o kernal/kernal.o -Ln rom.txt -m map.txt
|
||||
python checksum.py --new basic.bin 0xa0 0x1f52
|
||||
python checksum.py --new kernal.bin 0xe0 0x4ac
|
||||
copy kernal.bin ..\
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
||||
def calc_checksum(data, old):
|
||||
a = 0
|
||||
c = 0
|
||||
for b in data:
|
||||
a = a + b + c
|
||||
c = 0
|
||||
if a > 255:
|
||||
a = a - 256
|
||||
c = 1
|
||||
if not old:
|
||||
a += c
|
||||
return a
|
||||
|
||||
def usage():
|
||||
print("Usage: python checksum.py {--old|--new} <file.bin> [<checksum> <offset>]")
|
||||
exit(1)
|
||||
|
||||
# main
|
||||
|
||||
if len(sys.argv) != 3 and len(sys.argv) != 5:
|
||||
usage()
|
||||
|
||||
if sys.argv[1] == "--old":
|
||||
old = True
|
||||
elif sys.argv[1] == "--new":
|
||||
old = False
|
||||
else:
|
||||
usage()
|
||||
|
||||
filename = sys.argv[2]
|
||||
|
||||
data = bytearray(open(filename, 'rb').read())
|
||||
|
||||
checksum = calc_checksum(data, old)
|
||||
|
||||
if len(sys.argv) != 5:
|
||||
print(filename + ": " + hex(checksum))
|
||||
exit(0)
|
||||
|
||||
desired_checksum = int(sys.argv[3], 16)
|
||||
offset = int(sys.argv[4], 16)
|
||||
|
||||
if checksum < desired_checksum:
|
||||
data[offset] = desired_checksum - checksum
|
||||
else:
|
||||
data[offset] = 0xff - (checksum - desired_checksum)
|
||||
|
||||
file = open(filename, "wb")
|
||||
file.write(data)
|
||||
@@ -0,0 +1,7 @@
|
||||
del kernal.bin
|
||||
del basic.bin
|
||||
del map.txt
|
||||
del rom.txt
|
||||
del rom.bin
|
||||
del basic\basic.o
|
||||
del kernal\kernal.o
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,85 @@
|
||||
Modules list:
|
||||
-------------
|
||||
basic.o:
|
||||
ZPBASIC Offs=000000 Size=000090 Align=00001 Fill=0000
|
||||
STRTMP Offs=000000 Size=000002 Align=00001 Fill=0000
|
||||
BVECTORS Offs=000000 Size=000013 Align=00001 Fill=0000
|
||||
LOBASIC Offs=000000 Size=002000 Align=00001 Fill=0000
|
||||
HIBASIC Offs=000000 Size=0004A7 Align=00001 Fill=0000
|
||||
kernal.o:
|
||||
ZPKERNAL Offs=000000 Size=000070 Align=00001 Fill=0000
|
||||
STACK Offs=000000 Size=000001 Align=00001 Fill=0000
|
||||
KVAR Offs=000000 Size=0000A7 Align=00001 Fill=0000
|
||||
KVECTORS Offs=000000 Size=000020 Align=00001 Fill=0000
|
||||
EDITOR Offs=000000 Size=000809 Align=00001 Fill=0000
|
||||
SERIAL Offs=000000 Size=0001AF Align=00001 Fill=0000
|
||||
MESSAGES Offs=000000 Size=000053 Align=00001 Fill=0000
|
||||
NBASIN Offs=000000 Size=000046 Align=00001 Fill=0000
|
||||
NGETIN Offs=000000 Size=000011 Align=00001 Fill=0000
|
||||
NBSOUT Offs=000000 Size=00002E Align=00001 Fill=0000
|
||||
OPENC Offs=000000 Size=000079 Align=00001 Fill=0000
|
||||
CLOSE Offs=000000 Size=000076 Align=00001 Fill=0000
|
||||
OPEN Offs=000000 Size=0000C9 Align=00001 Fill=0000
|
||||
LOAD Offs=000000 Size=0000EE Align=00001 Fill=0000
|
||||
SAVE Offs=000000 Size=000076 Align=00001 Fill=0000
|
||||
CUNLSN Offs=000000 Size=000005 Align=00001 Fill=0000
|
||||
TIME Offs=000000 Size=000052 Align=00001 Fill=0000
|
||||
ERROR Offs=000000 Size=00003F Align=00001 Fill=0000
|
||||
INIT Offs=000000 Size=000161 Align=00001 Fill=0000
|
||||
NMI Offs=000000 Size=00006E Align=00001 Fill=0000
|
||||
IRQFILE Offs=000000 Size=00003D Align=00001 Fill=0000
|
||||
KPATCH Offs=000000 Size=000035 Align=00001 Fill=0000
|
||||
JMPTBL Offs=000000 Size=00007A Align=00001 Fill=0000
|
||||
VECTORS Offs=000000 Size=000006 Align=00001 Fill=0000
|
||||
WOZMON Offs=000000 Size=000100 Align=00001 Fill=0000
|
||||
|
||||
|
||||
Segment list:
|
||||
-------------
|
||||
Name Start End Size Align
|
||||
----------------------------------------------------
|
||||
ZPBASIC 000000 00008F 000090 00001
|
||||
ZPKERNAL 000090 0000FF 000070 00001
|
||||
STRTMP 0000FF 000100 000002 00001
|
||||
STACK 000100 000100 000001 00001
|
||||
KVAR 000200 0002A6 0000A7 00001
|
||||
BVECTORS 000300 000312 000013 00001
|
||||
KVECTORS 000314 000333 000020 00001
|
||||
LOBASIC 00A000 00BFFF 002000 00001
|
||||
HIBASIC 00E000 00E4A6 0004A7 00001
|
||||
KPATCH 00E4B7 00E4EB 000035 00001
|
||||
EDITOR 00E500 00ED08 000809 00001
|
||||
SERIAL 00ED09 00EEB7 0001AF 00001
|
||||
WOZMON 00EEB8 00EFB7 000100 00001
|
||||
NGETIN 00F13E 00F14E 000011 00001
|
||||
NBASIN 00F157 00F19C 000046 00001
|
||||
NBSOUT 00F1CA 00F1F7 00002E 00001
|
||||
OPENC 00F20E 00F286 000079 00001
|
||||
CLOSE 00F2B9 00F32E 000076 00001
|
||||
OPEN 00F34A 00F412 0000C9 00001
|
||||
LOAD 00F49E 00F58B 0000EE 00001
|
||||
SAVE 00F5DD 00F652 000076 00001
|
||||
CUNLSN 00F654 00F658 000005 00001
|
||||
TIME 00F69B 00F6EC 000052 00001
|
||||
ERROR 00F6ED 00F72B 00003F 00001
|
||||
INIT 00FCE2 00FE42 000161 00001
|
||||
NMI 00FE43 00FEB0 00006E 00001
|
||||
MESSAGES 00FEB1 00FF03 000053 00001
|
||||
IRQFILE 00FF43 00FF7F 00003D 00001
|
||||
JMPTBL 00FF80 00FFF9 00007A 00001
|
||||
VECTORS 00FFFA 00FFFF 000006 00001
|
||||
|
||||
|
||||
Exports list by name:
|
||||
---------------------
|
||||
|
||||
|
||||
|
||||
Exports list by value:
|
||||
----------------------
|
||||
|
||||
|
||||
|
||||
Imports list:
|
||||
-------------
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
MEMORY {
|
||||
# BASIC
|
||||
ZPBASIC: start = $0000, size = $0090;
|
||||
STRTMP: start = $00FF, size = $0002;
|
||||
BVECTORS: start = $0300, size = $0013;
|
||||
|
||||
# KERNAL
|
||||
ZPKERNAL: start = $0090, size = $0070;
|
||||
STACK: start = $0100, size = $0100;
|
||||
KVAR: start = $0200, size = $0100;
|
||||
KVECTORS: start = $0314, size = $0100;
|
||||
|
||||
# ROM A000-BFFF
|
||||
LOBASIC: start = $A000, size = $2000, fill=yes, fillval=$AA, file="basic.bin";
|
||||
|
||||
# ROM E000-FFFF
|
||||
HIBASIC: start = $E000, size = $04B7, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
KPATCH: start = $E4B7, size = $0049, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
|
||||
EDITOR: start = $E500, size = $0809, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
SERIAL: start = $ED09, size = $01AF, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
WOZMON: start = $EEB8, size = $0286, fill=yes, fillval=$12, file="kernal.bin";
|
||||
NGETIN: start = $F13E, size = $0019, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
NBASIN: start = $F157, size = $0073, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
NBSOUT: start = $F1CA, size = $0044, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
OPENC: start = $F20E, size = $00AB, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
CLOSE: start = $F2B9, size = $0091, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
OPEN: start = $F34A, size = $0154, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
LOAD: start = $F49E, size = $013F, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
SAVE: start = $F5DD, size = $0077, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
CUNLSN: start = $F654, size = $0047, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
TIME: start = $F69B, size = $0052, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
ERROR: start = $F6ED, size = $003F, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
CRAP: start = $F72C, size = $05B6, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
INIT: start = $FCE2, size = $0161, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
NMI: start = $FE43, size = $006E, fill=yes, fillval=$C2, file="kernal.bin";
|
||||
MESSAGES:start = $FEB1, size = $0092, fill=yes, fillval=$F2, file="kernal.bin";
|
||||
IRQFILE: start = $FF43, size = $003D, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
JMPTBL: start = $FF80, size = $007A, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
VECTORS: start = $FFFA, size = $0006, fill=yes, fillval=$D2, file="kernal.bin";
|
||||
|
||||
}
|
||||
|
||||
SEGMENTS {
|
||||
ZPBASIC: load = ZPBASIC, type = zp;
|
||||
STRTMP: load = STRTMP, type = zp;
|
||||
BVECTORS: load = BVECTORS, type = bss;
|
||||
|
||||
ZPKERNAL: load = ZPKERNAL, type = zp;
|
||||
STACK: load = STACK, type = bss;
|
||||
KVAR: load = KVAR, type = bss;
|
||||
KVECTORS: load = KVECTORS, type = bss;
|
||||
|
||||
LOBASIC: load = LOBASIC, type = ro;
|
||||
|
||||
HIBASIC: load = HIBASIC, type = ro;
|
||||
KPATCH: load = KPATCH, type = ro;
|
||||
EDITOR: load = EDITOR, type = ro;
|
||||
SERIAL: load = SERIAL, type = ro;
|
||||
CRAP: load = CRAP, type = ro;
|
||||
MESSAGES: load = MESSAGES, type = ro;
|
||||
NGETIN: load = NGETIN, type = ro;
|
||||
NBASIN: load = NBASIN, type = ro;
|
||||
NBSOUT: load = NBSOUT, type = ro;
|
||||
OPENC: load = OPENC, type = ro;
|
||||
CLOSE: load = CLOSE, type = ro;
|
||||
OPEN: load = OPEN, type = ro;
|
||||
LOAD: load = LOAD, type = ro;
|
||||
SAVE: load = SAVE, type = ro;
|
||||
CUNLSN: load = CUNLSN, type = ro;
|
||||
TIME: load = TIME, type = ro;
|
||||
ERROR: load = ERROR, type = ro;
|
||||
WOZMON: load = WOZMON, type = ro;
|
||||
INIT: load = INIT, type = ro;
|
||||
NMI: load = NMI, type = ro;
|
||||
IRQFILE: load = IRQFILE, type = ro;
|
||||
JMPTBL: load = JMPTBL, type = ro;
|
||||
VECTORS: load = VECTORS, type = ro;
|
||||
}
|
||||
Reference in New Issue
Block a user