diff --git a/.gitignore b/.gitignore index 7e0e151c..1d25926a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,18 @@ -c64/basic/OUT.BIN -c64/basic/combined.s -c64/kernal/OUT.BIN -c64/kernal/combined.s -chargen -newbasic -newc65 -newkern -newrom -ophis.bin -padding -src/collect_data -src/compress_text -src/pngprepare -src/preprocess -temp.map + +# Compilation related files + temp.s +temp.map + +ophis.bin +build/* + +# Input to the similarity tool - copyrighted material, we can't check it in! + +/basic +/kernal + +# Various IDE project files, temporary files, etc. + +*project +.*swp diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 00000000..2bb826fe --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,2 @@ + +Although the project itself is LGPL3, I (FeralChild64) allow to redistribute my contributions to this project under any OSI (Open Source Initiative) approved open source license. diff --git a/Makefile b/Makefile index 92d15cae..7e68ac85 100644 --- a/Makefile +++ b/Makefile @@ -1,61 +1,157 @@ -all: Ophis src/collect_data src/preprocess + +# Source files + +SRC_COMMON = $(wildcard c64/aliases/*.s) +SRC_BASIC_COMMON = $(SRC_COMMON) $(wildcard c64/basic/*.s) +SRC_KERNAL_COMMON = $(SRC_COMMON) $(wildcard c64/kernal/*.s c64/kernal/jumptable/*.s c64/kernal/iec/*.s) + +SRC_BASIC_generic = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,target_generic/*.s) +SRC_BASIC_mega65 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,target_mega65/*.s) +SRC_BASIC_ultimate64 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,target_ultimate64/*.s) + +SRC_KERNAL_generic = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,target_generic/*.s) +SRC_KERNAL_mega65 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,target_mega65/*.s) +SRC_KERNAL_ultimate64 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,target_ultimate64/*.s) + +# List of tools + +TOOL_COLLECT_DATA = build/tools/collect_data +TOOL_COMPRESS_TEXT = build/tools/compress_text +TOOL_PNGPREPARE = build/tools/pngprepare +TOOL_PREPROCESS = build/tools/preprocess +TOOL_SIMILARITY = build/tools/similarity + +TOOLS_LIST = $(TOOL_COLLECT_DATA) $(TOOL_COMPRESS_TEXT) $(TOOL_PNGPREPARE) $(TOOL_PREPROCESS) $(TOOL_SIMILARITY) + +# Rules - main + +.PHONY: all clean updatebin + +all: build/chargen build/newkern_generic build/newbasic_generic build/newc65 build/newkern_ultimate64 build/newbasic_ultimate64 Ophis: git submodule init git submodule update -src/pngprepare: src/pngprepare.c Makefile - $(CC) $(COPT) -I/usr/local/include -L/usr/local/lib -o src/pngprepare src/pngprepare.c -lpng +clean: + @rm -rf build + @rm -f temp.s + @rm -f temp.map + @rm -f ophis.bin -chargen: src/pngprepare assets/8x8font.png - src/pngprepare charrom assets/8x8font.png chargen +updatebin: build/chargen build/newbasic_generic build/newkern_generic build/newbasic_mega65 build/newkern_mega65 build/newbasic_ultimate64 build/newkern_ultimate64 + cp build/chargen bin/chargen.rom + cp build/newbasic_generic bin/basic_generic.rom + cp build/newkern_generic bin/kernal_generic.rom + cp build/newbasic_mega65 bin/basic_mega65.rom + cp build/newkern_mega65 bin/kernal_mega65.rom + cp build/newbasic_ultimate64 bin/basic_ultimate64.rom + cp build/newkern_ultimate64 bin/kernal_ultimate64.rom -src/collect_data: src/collect_data.c Makefile - gcc -Wall -o src/collect_data src/collect_data.c +# Rules - tools -src/preprocess: src/preprocess.c Makefile - gcc -g -Wall -o src/preprocess src/preprocess.c +$(TOOL_COLLECT_DATA): src/collect_data.c Makefile + @mkdir -p build/tools + gcc -Wall -o $(TOOL_COLLECT_DATA) src/collect_data.c -src/similarity: src/similarity.c Makefile - gcc -g -Wall -o src/similarity src/similarity.c +$(TOOL_COMPRESS_TEXT): src/compress_text.c Makefile + @mkdir -p build/tools + gcc -g -Wall -o $(TOOL_COMPRESS_TEXT) src/compress_text.c -lm -src/compress_text: src/compress_text.c Makefile - gcc -g -Wall -o src/compress_text src/compress_text.c -lm +$(TOOL_PNGPREPARE): src/pngprepare.c Makefile + @mkdir -p build/tools + $(CC) $(COPT) -I/usr/local/include -L/usr/local/lib -o $(TOOL_PNGPREPARE) src/pngprepare.c -lpng -newrom: c64/kernal/OUT.BIN c64/basic/OUT.BIN - cat c64/basic/OUT.BIN c64/kernal/OUT.BIN >newrom +$(TOOL_PREPROCESS): src/preprocess.c Makefile + @mkdir -p build/tools + gcc -g -Wall -o $(TOOL_PREPROCESS) src/preprocess.c -newkern: newrom Makefile - dd if=newrom bs=8192 count=1 skip=2 of=newkern +$(TOOL_SIMILARITY): src/similarity.c Makefile + @mkdir -p build/tools + gcc -g -Wall -o $(TOOL_SIMILARITY) src/similarity.c -newbasic: newrom Makefile - dd if=newrom bs=8192 count=1 skip=0 of=newbasic +# Rules - CHARGEN -newc65: newkern newbasic chargen Makefile - dd if=/dev/zero bs=4096 count=10 of=newc65 - cat newbasic chargen chargen newkern >>newc65 - dd if=/dev/zero bs=65536 count=1 of=padding - cat padding >>newc65 +build/chargen: $(TOOL_PNGPREPARE) assets/8x8font.png + $(TOOL_PNGPREPARE) charrom assets/8x8font.png build/chargen + +# Dependencies + +build/basic_generic/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_generic) build/basic/packed_messages.s +build/kernal_generic/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_generic) +build/newrom_generic: build/basic_generic/OUT.BIN build/kernal_generic/OUT.BIN +build/newkern_generic: build/newrom_generic Makefile +build/newbasic_generic: build/newrom_generic Makefile + +build/basic_mega65/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_mega65) build/basic/packed_messages.s +build/kernal_mega65/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_mega65) +build/newrom_mega65: build/basic_mega65/OUT.BIN build/kernal_mega65/OUT.BIN +build/newkern_mega65: build/newrom_mega65 Makefile +build/newbasic_mega65: build/newrom_mega65 Makefile + +build/basic_ultimate64/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_ultimate64) build/basic/packed_messages.s +build/kernal_ultimate64/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_ultimate64) +build/newrom_ultimate64: build/basic_ultimate64/OUT.BIN build/kernal_ultimate64/OUT.BIN +build/newkern_ultimate64: build/newrom_ultimate64 Makefile +build/newbasic_ultimate64: build/newrom_ultimate64 Makefile -c64/basic/packed_messages.s: Makefile src/compress_text - src/compress_text > c64/basic/packed_messages.s +# Rules - BASIC and KERNAL -c64/kernal/OUT.BIN: src/preprocess c64/kernal/*.s - src/preprocess -d c64/kernal -l e4d3 -h ffff +build/basic/packed_messages.s: $(TOOL_COMPRESS_TEXT) + @mkdir -p build/basic + $(TOOL_COMPRESS_TEXT) > build/basic/packed_messages.s -c64/basic/OUT.BIN: src/preprocess c64/basic/*.s c64/basic/packed_messages.s - src/preprocess -d c64/basic -l a000 -h e4d2 +.PRECIOUS: build/basic_%/OUT.BIN +build/basic_%/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_$*) build/basic/packed_messages.s + @mkdir -p build/basic_$* + @rm -f build/basic_$*/* + @for SRC in $(SRC_BASIC_$*); do \ + ln -s ../../$$SRC build/basic_$*/$$(basename $$SRC); \ + done + @ln -s ../../build/basic/packed_messages.s build/basic_$*/packed_messages.s + $(TOOL_PREPROCESS) -d build/basic_$* -l a000 -h e4d2 -testremote: newkern newbasic - x64 -kernal newkern -basic newbasic -remotemonitor +.PRECIOUS: build/kernal_%/OUT.BIN +build/kernal_%/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_$*) + @mkdir -p build/kernal_$* + @rm -f build/kernal_$*/* + @for SRC in $(SRC_KERNAL_$*); do \ + ln -s ../../$$SRC build/kernal_$*/$$(basename $$SRC); \ + done + $(TOOL_PREPROCESS) -d build/kernal_$* -l e4d3 -h ffff -test: newkern newbasic - x64 -kernal newkern -basic newbasic -8 empty.d64 +.PRECIOUS: build/newrom_% +build/newrom_%: build/basic_%/OUT.BIN build/kernal_%/OUT.BIN + cat build/basic_$*/OUT.BIN build/kernal_$*/OUT.BIN > build/newrom_$* -testm65: newc65 - m65 -b ../mega65-core/bin/mega65r1.bit -k ../mega65-core/bin/KICKUP.M65 -R newc65 -4 +.PRECIOUS: build/newkern_% +build/newkern_%: build/newrom_% Makefile + dd if=build/newrom_$* bs=8192 count=1 skip=2 of=build/newkern_$* -testsimilarity: newkern newbasic src/similarity - src/similarity kernal newrom - src/similarity basic newrom +.PRECIOUS: build/newbasic_% +build/newbasic_%: build/newrom_% Makefile + dd if=build/newrom_$* bs=8192 count=1 skip=0 of=build/newbasic_$* + +# Rules - platform 'Mega 65' specific + +build/newc65: build/newkern_mega65 build/newbasic_mega65 build/chargen Makefile + dd if=/dev/zero bs=4096 count=10 of=build/newc65 + cat build/newbasic_mega65 build/chargen build/chargen build/newkern_mega65 >> build/newc65 + dd if=/dev/zero bs=65536 count=1 of=build/basic/padding + cat build/basic/padding >> build/newc65 + +# Rules - tests + +test: build/newkern_generic build/newbasic_generic + x64 -kernal build/newkern_generic -basic build/newbasic_generic -8 empty.d64 + +testremote: build/newkern_generic build/newbasic_generic + x64 -kernal build/newkern-generic -basic build/newbasic-generic -remotemonitor + +testm65: build/newc65 + m65 -b ../mega65-core/bin/mega65r1.bit -k ../mega65-core/bin/KICKUP.M65 -R build/newc65 -4 + +testsimilarity: build/newrom_generic $(TOOL_SIMILARITY) + $(TOOL_SIMILARITY) kernal build/newrom_generic + $(TOOL_SIMILARITY) basic build/newrom_generic diff --git a/STATUS.md b/STATUS.md new file mode 100644 index 00000000..286da229 --- /dev/null +++ b/STATUS.md @@ -0,0 +1,117 @@ +# New features + + +Here are the features of the Open ROMs not found in the original ROMs from the 80s: + +* improved keyboard scanning, supports multi-key roll-over and rejection of spurious joystick input +* joystick (port 1) can be used to move text cursor +* uses RAM under ROM and I/O: 61436 bytes free +* extended `LOAD` command + * start/end addresses are displayed, in the Final cartridge style + * command with just the file name tries to use the last device if it's number seems sane; otherwise uses 8 + * secondary address over 255 is considered a start address +* DOS wedge (direct mode only) - `@`, `@`, `@$`, `@$`, `@` + +NOTE: extra features and their syntax can change in the future! + +# Features missing + + +The following ROM features are currently missing: + +* most BASIC commands +* BASIC variables +* BASIC expression parsing +* floating point routines +* tape support +* RS-232 support +* warm start (RUN/STOP + RESTORE) - NMI is not implemented at all +* breaking Kernal routines with RUN/STOP key + +Features currently being worked on: + +* IEC support needs more testing ang bugfixing; alternative drive ROMs (JiffyDOS, DolphinDOS, etc) usually don't work with current implementation, `@$` leaves the drive led on, most likely other problems can be found + +# API status + + +Status of the various APIs and variables from the original ROMs + + +## Page 0 + + +TODO + + +## Pages 2 & 3 + + +TODO + + +## BASIC + + +TODO + + +## Kernal + + +Note: only the jump table addresses are currently supported, real routine addresses are different! + + +### Official Kernal routines + +NOTE: Even the 'DONE' routines won't support features described as missing in one of the previous chapters! + +
+ +| Address | Name | Status | Remarks | +| --------- | :------- | :------: | :------------------------------------------------: | +| `$FF81` | `CINT` | PARTIAL | at least PAL/NTSC detection is missing | +| `$FF84` | `IOINIT` | PARTIAL | at least SID volume handling is missing | +| `$FF87` | `RAMTAS` | DONE | | +| `$FF8A` | `RESTOR` | PARTIAL | CBINV, NMINV, and USRCMD missing | +| `$FF8D` | `VECTOR` | DONE | | +| `$FF90` | `SETMSG` | DONE | | +| `$FF93` | `SECOND` | DONE | | +| `$FF96` | `TKSA` | DONE | | +| `$FF99` | `MEMTOP` | DONE | | +| `$FF9C` | `MEMBOT` | DONE | | +| `$FF9F` | `SCNKEY` | DONE | could be better integrated with ROM (aliases) | +| `$FFA2` | `SETTMO` | NOT DONE | | +| `$FFA5` | `ACPTR` | DONE | | +| `$FFA8` | `CIOUT` | DONE | | +| `$FFAB` | `UNTLK` | DONE | | +| `$FFAE` | `UNLSN` | DONE | | +| `$FFB1` | `LISTEN` | DONE | | +| `$FFB4` | `TALK` | DONE | | +| `$FFB7` | `READST` | DONE | | +| `$FFBA` | `SETFLS` | DONE | | +| `$FFBD` | `SETNAM` | DONE | | +| `$FFC0` | `OPEN` | DONE | | +| `$FFC3` | `CLOSE` | PARTIAL | most likely incompleete, @$ doesn't end properly | +| `$FFC6` | `CHKIN` | DONE | | +| `$FFC9` | `CHKOUT` | PARTIAL | | +| `$FFCC` | `CLRCHN` | DONE | | +| `$FFCF` | `CHRIN` | PARTIAL | | +| `$FFD2` | `CHROUT` | PARTIAL | | +| `$FFD5` | `LOAD` | PARTIAL | no VERIFY support yet | +| `$FFD8` | `SAVE` | NOT DONE | | +| `$FFDB` | `SETTIM` | NOT DONE | | +| `$FFDE` | `RDTIM` | NOT DONE | | +| `$FFE1` | `STOP` | PARTIAL | no connection with UDTIM | +| `$FFE4` | `GETIN` | PARTIAL | only some devices supported | +| `$FFE7` | `CLALL` | DONE | | +| `$FFEA` | `UDTIM` | NOT DONE | | +| `$FFED` | `SCREEN` | DONE | | +| `$FFF0` | `PLOT` | NOT DONE | | +| `$FFF3` | `IOBASE` | DONE | | + +
+ +### Unofficial Kernal locations + +TODO diff --git a/bin/REEADME.txt b/bin/REEADME.txt new file mode 100644 index 00000000..d3a254bc --- /dev/null +++ b/bin/REEADME.txt @@ -0,0 +1,14 @@ + +Follow these rules, or bad things will happen! + + +- Don't mix ROMs for different platforms - use generic BASIC with generic KERNAL, Mega65 BASIC with Mega65 KERNAL, etc. + +- Don't mix these ROMs with any other ROMs; the only exception is CHARGEN, this one is fully interchangeable. + +- Don't mix ROMs from different builds/versions (again, CHARGEN is an exception). + +- The generic ROM set should be compatible with any C64-compatible machine; platform-specific ROMs might not work on other platforms. + + +Have fun! diff --git a/bin/basic b/bin/basic_generic.rom similarity index 51% rename from bin/basic rename to bin/basic_generic.rom index 2de26fca..29d891b1 100644 Binary files a/bin/basic and b/bin/basic_generic.rom differ diff --git a/bin/basic_mega65.rom b/bin/basic_mega65.rom new file mode 100644 index 00000000..a72bf16d Binary files /dev/null and b/bin/basic_mega65.rom differ diff --git a/bin/basic_ultimate64.rom b/bin/basic_ultimate64.rom new file mode 100644 index 00000000..6ed9ce5b Binary files /dev/null and b/bin/basic_ultimate64.rom differ diff --git a/bin/chargen.rom b/bin/chargen.rom new file mode 100644 index 00000000..11cbd8c2 Binary files /dev/null and b/bin/chargen.rom differ diff --git a/bin/kernal b/bin/kernal deleted file mode 100644 index 16a9a00b..00000000 Binary files a/bin/kernal and /dev/null differ diff --git a/bin/kernal_generic.rom b/bin/kernal_generic.rom new file mode 100644 index 00000000..35157ebb Binary files /dev/null and b/bin/kernal_generic.rom differ diff --git a/bin/kernal_mega65.rom b/bin/kernal_mega65.rom new file mode 100644 index 00000000..35157ebb Binary files /dev/null and b/bin/kernal_mega65.rom differ diff --git a/bin/kernal_ultimate64.rom b/bin/kernal_ultimate64.rom new file mode 100644 index 00000000..35157ebb Binary files /dev/null and b/bin/kernal_ultimate64.rom differ diff --git a/c64/aliases/,aliases_error_codes.s b/c64/aliases/,aliases_error_codes.s new file mode 100644 index 00000000..e27f5373 --- /dev/null +++ b/c64/aliases/,aliases_error_codes.s @@ -0,0 +1,63 @@ + + ;; Kernal error codes - returned in the A register + ;; Described in 'Commodore 64 Programmer's Reference Guide', page 306 + + .alias K_ERR_ROUTINE_TERMINATED $00 + .alias K_ERR_TOO_MANY_OPEN_FILES $01 + .alias K_ERR_FILE_ALREADY_OPEN $02 + .alias K_ERR_FILE_NOT_OPEN $03 + .alias K_ERR_FILE_NOT_FOUND $04 + .alias K_ERR_DEVICE_NOT_FOUND $05 + .alias K_ERR_FILE_NOT_INPUT $06 + .alias K_ERR_FILE_NOT_OUTPUT $07 + .alias K_ERR_FILE_NAME_MISSING $08 + .alias K_ERR_ILLEGAL_DEVICE_NUMBER $09 + .alias K_ERR_TOP_MEM_RS232 $F0 + + ;; Kernal status codes for READST routine (IOSTATUS) + ;; Described in 'Commodore 64 Programmer's Reference Guide', page 292 + + ;; For IEC devices + .alias K_STS_TIMEOUT_WRITE $01 + .alias K_STS_TIMEOUT_READ $02 + .alias K_STS_EOI $40 + .alias K_STS_DEVICE_NOT_FOUND $80 + ;; For tape deck + .alias K_STS_SHORT_BLOCK $04 + .alias K_STS_LONG_BLOCK $08 + .alias K_STS_READ_ERROR $10 + .alias K_STS_CHECKSUM_ERROR $20 + .alias K_STS_END_OF_FILE $40 + .alias K_STS_END_OF_TAPE $80 + + ;; BASIC error codes, taken from http://sta.c64.org/cbm64baserr.html + .alias B_ERR_TOO_MANY_FILES $01 + .alias B_ERR_FILE_OPEN $02 + .alias B_ERR_FILE_NOT_OPEN $03 + .alias B_ERR_FILE_NOT_FOUND $04 + .alias B_ERR_DEVICE_NOT_PRESENT $05 + .alias B_ERR_NOT_INPUT_FILE $06 + .alias B_ERR_NOT_OUTPUT_FILE $07 + .alias B_ERR_MISSING_FILENAME $08 + .alias B_ERR_ILLEGAL_DEVICE_NUMBER $09 + .alias B_ERR_NEXT_WITHOUT_FOR $0A + .alias B_ERR_SYNTAX $0B + .alias B_ERR_RETURN_WITHOUT_GOSUB $0C + .alias B_ERR_OUT_OF_DATA $0D + .alias B_ERR_ILLEGAL_QUANTITY $0E + .alias B_ERR_OVERFLOW $0F + .alias B_ERR_OUT_OF_MEMORY $10 + .alias B_ERR_UNDEFD_STATEMENT $11 + .alias B_ERR_BAD_SUBSCRIPT $12 + .alias B_ERR_REDIMD_ARRAY $13 + .alias B_ERR_DIVISION_BY_ZERO $14 + .alias B_ERR_ILLEGAL_DIRECT $15 + .alias B_ERR_TYPE_MISMATCH $16 + .alias B_ERR_STRING_TOO_LONG $17 + .alias B_ERR_FILE_DATA $18 + .alias B_ERR_FORMULA_TOO_COMPLEX $19 + .alias B_ERR_CANT_CONTINUE $1A + .alias B_ERR_UNDEFD_FUNCTION $1B + .alias B_ERR_VERIFY $1C + .alias B_ERR_LOAD $1D + .alias B_ERR_BREAK $1E diff --git a/c64/aliases/,aliases_hardware.s b/c64/aliases/,aliases_hardware.s new file mode 100644 index 00000000..ee6ceddb --- /dev/null +++ b/c64/aliases/,aliases_hardware.s @@ -0,0 +1,154 @@ + +;; +;; Names of hardware registers - slightly modified names from C64 Programmer's Reference Guide +;; + + ;; CPU memory registers + + .alias CPU_D6510 $0000 + .alias CPU_R6510 $0001 + + ;; VIC-II registers + + .alias VIC_SP0X $D000 + .alias VIC_SP0Y $D001 + .alias VIC_SP1X $D002 + .alias VIC_SP1Y $D003 + .alias VIC_SP2X $D004 + .alias VIC_SP2Y $D005 + .alias VIC_SP3X $D006 + .alias VIC_SP3Y $D007 + .alias VIC_SP4X $D008 + .alias VIC_SP4Y $D009 + .alias VIC_SP5X $D00A + .alias VIC_SP5Y $D00B + .alias VIC_SP6X $D00C + .alias VIC_SP6Y $D00D + .alias VIC_SP7X $D00E + .alias VIC_SP7Y $D00F + + .alias VIC_MSIGX $D010 + .alias VIC_SCROLLY $D011 + .alias VIC_RASTER $D012 + .alias VIC_LPENX $D013 + .alias VIC_LPENY $D014 + .alias VIC_SPENA $D015 + .alias VIC_SCROLX $D016 + .alias VIC_YXPAND $D017 + .alias VIC_YMCSB $D018 + .alias VIC_IRQ $D019 + .alias VIC_IRQMSK $D01A + .alias VIC_SPBGPR $D01B + .alias VIC_SPMC $D01C + .alias VIC_XXPAND $D01D + .alias VIC_SPSPCL $D01E + .alias VIC_SPBGCL $D01F + + .alias VIC_EXTCOL $D020 + .alias VIC_BGCOL0 $D021 + .alias VIC_BGCOL1 $D022 + .alias VIC_BGCOL2 $D023 + .alias VIC_BGCOL3 $D024 + .alias VIC_SPMC0 $D025 + .alias VIC_SPMC1 $D026 + .alias VIC_SP0COL $D027 + .alias VIC_SP1COL $D028 + .alias VIC_SP2COL $D029 + .alias VIC_SP3COL $D02A + .alias VIC_SP4COL $D02B + .alias VIC_SP5COL $D02C + .alias VIC_SP6COL $D02D + .alias VIC_SP7COL $D02E + + ;; SID #1 registers + + .alias SID1_FRELO1 $D400 + .alias SID1_FREHI1 $D401 + .alias SID1_PWLO1 $D402 + .alias SID1_PWHI1 $D403 + .alias SID1_VCREG1 $D404 + .alias SID1_ATDCY1 $D405 + .alias SID1_SUREL1 $D406 + + .alias SID1_FRELO2 $D407 + .alias SID1_FREHI2 $D408 + .alias SID1_PWLO2 $D409 + .alias SID1_PWHI2 $D40A + .alias SID1_VCREG2 $D40B + .alias SID1_ATDCY2 $D40C + .alias SID1_SUREL2 $D40D + + .alias SID1_FRELO3 $D40E + .alias SID1_FREHI3 $D40F + .alias SID1_PWLO3 $D410 + .alias SID1_PWHI3 $D411 + .alias SID1_VCREG3 $D412 + .alias SID1_ATDCY3 $D413 + .alias SID1_SUREL3 $D414 + + .alias SID1_CUTLO $D415 + .alias SID1_CUTHI $D416 + .alias SID1_RESON $D417 + .alias SID1_SIGVOL $D418 + .alias SID1_POTX $D419 + .alias SID1_POTY $D41A + .alias SID1_RANDOM $D41B + .alias SID1_ENV3 $D41C + + ;; SID #2, #3, #4 registers + + .alias SID2_SIGVOL $D438 + .alias SID3_SIGVOL $D458 + .alias SID4_SIGVOL $D478 + + ;; CIA #1 registers + + .alias CIA1_PRA $DC00 + .alias CIA1_PRB $DC01 + .alias CIA1_DDRA $DC02 + .alias CIA1_DDRB $DC03 + + .alias CIA1_TIMALO $DC04 + .alias CIA1_TIMAHI $DC05 + .alias CIA1_TIMBLO $DC06 + .alias CIA1_TIMBHI $DC07 + + .alias CIA1_TODTEN $DC08 + .alias CIA1_TODSEC $DC09 + .alias CIA1_TODMIN $DC0A + .alias CIA1_TODHRS $DC0B + + .alias CIA1_SDR $DC0C + .alias CIA1_ICR $DC0D + .alias CIA1_CRA $DC0E + .alias CIA1_CRB $DC0F + + ;; CIA #2 registers + + .alias CIA2_PRA $DD00 ; VIC bank switching and IEC port + .alias CIA2_PRB $DD01 + .alias CIA2_DDRA $DD02 + .alias CIA2_DDRB $DD03 + + .alias CIA2_TIMALO $DD04 + .alias CIA2_TIMAHI $DD05 + .alias CIA2_TIMBLO $DD06 + .alias CIA2_TIMBHI $DD07 + + .alias CIA2_TODTEN $DD08 + .alias CIA2_TODSEC $DD09 + .alias CIA2_TODMIN $DD0A + .alias CIA2_TODHRS $DD0B + + .alias CIA2_SDR $DD0C + .alias CIA2_ICR $DD0D + .alias CIA2_CRA $DD0E + .alias CIA2_CRB $DD0F + + ;; CIA #2 helper bits - IEC bus + + .alias BIT_CIA2_PRA_ATN_OUT $08 ; 1 - low (pulled), 0 - high (released) + .alias BIT_CIA2_PRA_CLK_OUT $10 ; 1 - low (pulled), 0 - high (released) + .alias BIT_CIA2_PRA_DAT_OUT $20 ; 1 - low (pulled), 0 - high (released) + .alias BIT_CIA2_PRA_CLK_IN $40 ; 0 - low (pulled), 1 - high (released) + .alias BIT_CIA2_PRA_DAT_IN $80 ; 0 - low (pulled), 1 - high (released) diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s new file mode 100644 index 00000000..311fbf87 --- /dev/null +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -0,0 +1,99 @@ +;; +;; Names of ZP and low memory locations +;; (https://www.c64-wiki.com/wiki/Zeropage) +;; + + ;; $00-$01 - 6502 CPU registers are here + + ;; + ;; Page 0 - BASIC area ($02-$8F) + ;; + + .alias TXTTAB $2B + + ;; + ;; Page 0 - Kernal area ($90-$FF) + ;; + + .alias IOSTATUS $90 + .alias STKEY $91 ; Keys down clears bits. STOP - bit 7, C= - bit 6, SPACE - bit 4, CTRL - bit 2 + + .alias VERCK $93 ; 0 = LOAD, 1 = VERIVY + + .alias C3PO $94 ; flag - is BSOUR content valid + .alias BSOUR $95 ; serial bus buffered output byte + + .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables + .alias DFLTN $99 + .alias DFLTO $9A + + .alias MSGFLG $9D ; bit 6 = error messages, bit 7 = control message + + .alias TIME $A0 ; $A0-$A2, jiffy clock + + .alias IEC_TMP1 $A3 ; temporary variable for tape and IEC + .alias IEC_TMP2 $A4 ; temporary variable for tape and IEC + + ;; 2-byte location below seems to be a good place for temporary storage, + ;; it seems used for timing during tape reads only - see: + ;; - 'C64 Programmer's Reference Guide', page 314 + ;; - 'Compute's Mapping the Commodore 64', page 32 + .alias CMP0 $B0 ; $B0-$B1 + + .alias FNLEN $B7 ; current file name length + + .alias FNADDR $BB ; $BB-$BC, current file name pointer + + .alias STAL $C1 ; $C1-$C2 LOAD/SAVE start address + + ;; + ;; Other low memory addresses + ;; + + .alias BUF $200 ; $200-$250 (81 bytes), BASIC line editor input buffer + + ;; Kernal tables for opened files, 10 entries each + .alias LAT $259 ; logical file numbers + .alias FAT $263 ; device numbers + .alias SAT $26D ; secondary addresses + + .alias MEMSTR $281 + .alias MEMSIZ $283 ; NOTE: Mapping the 64 erroniously has the hex as $282, while the DEC is correct + + .alias HIBASE $288 ; high byte of start of screen + + .alias RSSTAT $297 ; RS-232 status + + .alias PALNTSC $2A6 ; 0 = NTSC, 1 = PAL + + + ;; Registers for SYS call + .alias SAREG $30C + .alias SXREG $30D + .alias SYREG $30E + .alias SPREG $30F + + .alias USRPOK $310 ; JMP instruction + .alias USRADD $311 ; $311 - $312 + + ;; Kernal vectors - interrupts + .alias CINV $314 + .alias CBINV $316 + .alias NMINV $318 + + ;; Kernal vectors - routines + .alias IOPEN $31A + .alias ICLOSE $31C + .alias ICHKIN $31E + .alias ICKOUT $320 + .alias ICLRCH $322 + .alias IBASIN $324 + .alias IBSOUT $326 + .alias ISTOP $328 + .alias IGETIN $32A + .alias ICLALL $32C + .alias USRCMD $32E + .alias ILOAD $330 + .alias ISAVE $331 + + .alias TBUFFR $33C ; $33C-$3FB, tape buffer diff --git a/c64/aliases/,aliases_rom_basic.s b/c64/aliases/,aliases_rom_basic.s new file mode 100644 index 00000000..e69de29b diff --git a/c64/aliases/,aliases_rom_kernal.s b/c64/aliases/,aliases_rom_kernal.s new file mode 100644 index 00000000..91c601d9 --- /dev/null +++ b/c64/aliases/,aliases_rom_kernal.s @@ -0,0 +1,41 @@ + + ;; Kernal jump table + .alias JCINT $FF81 + .alias JIOINIT $FF84 + .alias JRAMTAS $FF87 + .alias JRESTOR $FF8A + .alias JVECTOR $FF8D + .alias JSETMSG $FF90 + .alias JSECOND $FF93 + .alias JTKSA $FF96 + .alias JMEMTOP $FF99 + .alias JMEMBOT $FF9C + .alias JSCNKEY $FF9F + .alias JSETTMO $FFA2 + .alias JACPTR $FFA5 + .alias JCIOUT $FFA8 + .alias JUNTLK $FFAB + .alias JUNLSN $FFAE + .alias JLISTEN $FFB1 + .alias JTALK $FFB4 + .alias JREADST $FFB7 + .alias JSETFLS $FFBA + .alias JSETNAM $FFBD + .alias JOPEN $FFC0 + .alias JCLOSE $FFC3 + .alias JCHKIN $FFC6 + .alias JCKOUT $FFC9 + .alias JCLRCHN $FFCC + .alias JCHRIN $FFCF + .alias JCHROUT $FFD2 + .alias JLOAD $FFD5 + .alias JSAVE $FFD8 + .alias JSETTIM $FFDB + .alias JRDTIM $FFDE + .alias JSTOP $FFE1 + .alias JGETIN $FFE4 + .alias JCLALL $FFE7 + .alias JUDTIM $FFEA + .alias JSCREEN $FFED + .alias JPLOT $FFF0 + .alias JIOBASE $FFF3 diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index 712e7c35..e54dd5a9 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -52,22 +52,13 @@ .alias memmove_dst $6b .alias memmove_size $6d - .alias TXTTAB $2B - .alias IOSTATUS $90 - ; Keys down clears bits. STOP=bit 7, C= bit 6, SPACE bit 4, CTRL bit 2 - .alias BUCKYSTATUS $91 - .alias load_or_verify_flag $93 .alias current_file_num $98 - .alias input_device_number $99 - ; bit 6 = error messages, bit 7 = control messages - .alias kernal_message_control_flags $9d - .alias jiffy_clock_24bits $a0 .alias cassette_buffer_bytes_used $A6 .alias load_or_scroll_temp_pointer $AC ;; We also use the following for temp colour pointer when scrolling .alias load_save_verify_end_address $AE + .alias cassette_buffer_ptr $B2 - .alias current_filename_length $B7 .alias current_logical_filenum $B8 .alias current_secondary_address $B9 .alias current_device_number $BA @@ -100,15 +91,12 @@ .alias rs232_rx_buffer_ptr $F7 .alias rs232_tx_buffer_ptr $F9 - .alias basic_input_buffer $0200 - + .alias basic_input_buffer BUF + ; "Compute's Mapping the 64" book .alias keyboard_buffer $0277 - .alias MEMSTR $0281 - .alias MEMSIZ $0283 ; NOTE: Mapping the 64 erroniously has the hex as $282, while the DEC is correct .alias text_colour $0286 ; p55 .alias colour_under_cursor $0287 ; p56 - .alias HIBASE $0288 ; p56 (high byte of start of screen) .alias key_buffer_size $0289 ; p57 ;; 0 = cursor keys, insert, delete and space repeat, but nothing else @@ -124,14 +112,6 @@ .alias keyboard_decoding_ptr $028F .alias enable_case_switch $0291 .alias screen_scroll_disable $0292 - .alias pal_or_ntsc $02A6 - - ;; Registers for SYS call - .alias sys_reg_a $30c - .alias sys_reg_x $30d - .alias sys_reg_y $30e - .alias sys_reg_p $30f - .alias sys_jmp $310 ;; BASIC uses some extra bytes for memory access under ROMs located at $2A7 onwards ;; IRQs are disabled when doing such accesses, and a default NMI handler only increments @@ -144,4 +124,3 @@ .alias poke_under_roms tiny_nmi_handler+poke_under_roms_routine-tiny_nmi_handler_routine .alias memmap_allram tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine .alias memmap_normal tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine - diff --git a/c64/basic/,target_generic/,hooks_generic.s b/c64/basic/,target_generic/,hooks_generic.s new file mode 100644 index 00000000..186b29d0 --- /dev/null +++ b/c64/basic/,target_generic/,hooks_generic.s @@ -0,0 +1,9 @@ + +;; Target-specific hooks + + +.macro TARGET_HOOK_BANNER + + .byte $05, " OPEN ROMS, ", $00 + +.macend diff --git a/c64/basic/,target_mega65/,hooks_mega65.s b/c64/basic/,target_mega65/,hooks_mega65.s new file mode 100644 index 00000000..97c859e5 --- /dev/null +++ b/c64/basic/,target_mega65/,hooks_mega65.s @@ -0,0 +1,41 @@ + +;; Target-specific hooks + + +.macro TARGET_HOOK_BANNER + + ;; New banner from Retrofan + .byte $9a, $12, $20, $20, $7f, $a9, $20, $20, $1f, $20, $9a, $20, $20, $20 + .byte $20, $1f, $20, $9a, $a9, $20, $20, $20, $92, $a1, $1f, $12, $20, $9a, $a9, $20 + .byte $20, $20, $7f, $1f, $20, $20, $9a, $a3, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20 + .byte $20, $20, $20, $05, $92, $4d, $45, $47, $41, $9a, $12, $20, $20, $20, $20, $20 + .byte $20, $1f, $20, $9a, $20, $20, $92, $a2, $bb, $1f, $12, $20, $9a, $20, $20, $92 + .byte $ac, $a2, $a2, $1f, $12, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20 + .byte $20, $1e, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $42 + .byte $41, $53, $49, $43, $9a, $12, $20, $20, $92, $7f, $a9, $12, $20, $20, $1f, $20 + .byte $9a, $20, $20, $a2, $92, $be, $1f, $12, $20, $9a, $20, $20, $92, $bc, $12, $20 + .byte $20, $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $20, $9e, $a3, $a3, $a3 + .byte $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $2d, $2d, $2d, $2d, $2d, $2d, $9a + .byte $12, $20, $20, $1f, $20, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $20, $20 + .byte $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20, $9a + .byte $20, $20, $1f, $20, $20, $96, $a3, $a3, $a3, $a3, $1f + .byte $92, $0D, $0D, $05, $00 + + ;; Original Deft-supplied banner + ;; .byte $9A,$12,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$20,$05,$12,$A0,$A0 + ;; .byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9B,$92,$20,$05,$12,$A0,$A0 + ;; .byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9A,$92,$20,$05,$20,$20,$20 + ;; .byte $4D,$20,$45,$20,$47,$20,$41,$0D,$99,$12,$A3,$A3,$A3,$A3,$A3,$A3 + ;; .byte $A3,$DF,$92,$7F,$12,$CD,$CD,$DF,$92,$7F,$12,$DF,$05,$92,$20,$20 + ;; .byte $99,$7F,$12,$DF,$05,$92,$20,$20,$99,$7F,$12,$DF,$92,$7F,$12,$DF + ;; .byte $05,$92,$20,$20,$99,$42,$20,$41,$20,$53,$20,$49,$20,$43,$0D,$9E + ;; .byte $12,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$7F,$12,$DF,$92 + ;; .byte $7F,$12,$DF,$92,$7F,$12,$CD,$05,$92,$20,$20,$9B,$7F,$12,$CD,$92 + ;; .byte $7F,$12,$DF,$92,$7F,$12,$CD,$92,$7F,$12,$DF,$9A,$92,$20,$05,$20 + ;; .byte $9A,$2D,$2D,$2D,$2D,$2D,$2D,$2D,$0D,$96,$12,$A3,$A3,$A3,$A3,$A3 + ;; .byte $A3,$A3,$A3,$A3,$DF,$9A,$92,$7F,$12,$DF,$92,$7F,$9B,$20,$9A,$7F + ;; .byte $12,$A0,$A0,$9B,$92,$20,$9A,$7F,$12,$A0,$A0,$9B,$92,$20,$9A,$7F + ;; .byte $12,$DF,$92,$7F,$9B,$20,$9A,$20,$9B,"0.2.0.0",$0D + ;; .byte $0D,$05,$92,$00 + +.macend diff --git a/c64/basic/,target_ultimate64/,hooks_ultimate64.s b/c64/basic/,target_ultimate64/,hooks_ultimate64.s new file mode 100644 index 00000000..519d07e9 --- /dev/null +++ b/c64/basic/,target_ultimate64/,hooks_ultimate64.s @@ -0,0 +1,9 @@ + +;; Target-specific hooks + + +.macro TARGET_HOOK_BANNER + + .byte $05, " OPEN ROMS FOR ULTIMATE 64", $0D, $0D, " ", $00 + +.macend diff --git a/c64/basic/ab1e.print_string.s b/c64/basic/ab1e.print_string.s index 9ca8a586..83f8d366 100644 --- a/c64/basic/ab1e.print_string.s +++ b/c64/basic/ab1e.print_string.s @@ -20,7 +20,7 @@ print_string_loop: lda (temp_string_ptr),y beq print_string_end - jsr $FFD2 ; KERNAL CHROUT + jsr via_IBSOUT txa tay diff --git a/c64/basic/basic_cold_start.s b/c64/basic/basic_cold_start.s index 187c828e..325bd1ed 100644 --- a/c64/basic/basic_cold_start.s +++ b/c64/basic/basic_cold_start.s @@ -15,41 +15,7 @@ basic_cold_start: ; Used 217 bytes startup_banner: - ;; New banner from Retrofan - .byte $9a, $12, $20, $20, $7f, $a9, $20, $20, $1f, $20, $9a, $20, $20, $20 - .byte $20, $1f, $20, $9a, $a9, $20, $20, $20, $92, $a1, $1f, $12, $20, $9a, $a9, $20 - .byte $20, $20, $7f, $1f, $20, $20, $9a, $a3, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20 - .byte $20, $20, $20, $05, $92, $4d, $45, $47, $41, $9a, $12, $20, $20, $20, $20, $20 - .byte $20, $1f, $20, $9a, $20, $20, $92, $a2, $bb, $1f, $12, $20, $9a, $20, $20, $92 - .byte $ac, $a2, $a2, $1f, $12, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20 - .byte $20, $1e, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $42 - .byte $41, $53, $49, $43, $9a, $12, $20, $20, $92, $7f, $a9, $12, $20, $20, $1f, $20 - .byte $9a, $20, $20, $a2, $92, $be, $1f, $12, $20, $9a, $20, $20, $92, $bc, $12, $20 - .byte $20, $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $20, $9e, $a3, $a3, $a3 - .byte $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $2d, $2d, $2d, $2d, $2d, $2d, $9a - .byte $12, $20, $20, $1f, $20, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $20, $20 - .byte $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20, $9a - .byte $20, $20, $1f, $20, $20, $96, $a3, $a3, $a3, $a3, $1f - .byte $92, $0D, $0D, $05 - - .byte $00 - - ;; Original Deft-supplied banner - ;; .byte $9A,$12,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$20,$05,$12,$A0,$A0 - ;; .byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9B,$92,$20,$05,$12,$A0,$A0 - ;; .byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9A,$92,$20,$05,$20,$20,$20 - ;; .byte $4D,$20,$45,$20,$47,$20,$41,$0D,$99,$12,$A3,$A3,$A3,$A3,$A3,$A3 - ;; .byte $A3,$DF,$92,$7F,$12,$CD,$CD,$DF,$92,$7F,$12,$DF,$05,$92,$20,$20 - ;; .byte $99,$7F,$12,$DF,$05,$92,$20,$20,$99,$7F,$12,$DF,$92,$7F,$12,$DF - ;; .byte $05,$92,$20,$20,$99,$42,$20,$41,$20,$53,$20,$49,$20,$43,$0D,$9E - ;; .byte $12,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$7F,$12,$DF,$92 - ;; .byte $7F,$12,$DF,$92,$7F,$12,$CD,$05,$92,$20,$20,$9B,$7F,$12,$CD,$92 - ;; .byte $7F,$12,$DF,$92,$7F,$12,$CD,$92,$7F,$12,$DF,$9A,$92,$20,$05,$20 - ;; .byte $9A,$2D,$2D,$2D,$2D,$2D,$2D,$2D,$0D,$96,$12,$A3,$A3,$A3,$A3,$A3 - ;; .byte $A3,$A3,$A3,$A3,$DF,$9A,$92,$7F,$12,$DF,$92,$7F,$9B,$20,$9A,$7F - ;; .byte $12,$A0,$A0,$9B,$92,$20,$9A,$7F,$12,$A0,$A0,$9B,$92,$20,$9A,$7F - ;; .byte $12,$DF,$92,$7F,$9B,$20,$9A,$20,$9B,"0.2.0.0",$0D - ;; .byte $0D,$05,$92,$00 + `TARGET_HOOK_BANNER ;; Work out free bytes, and display jsr basic_do_new @@ -63,7 +29,7 @@ startup_banner: jsr print_integer lda #$20 - jsr $ffd2 + jsr via_IBSOUT ;; Print the rest of the start up message ldx #34 diff --git a/c64/basic/basic_do_error.s b/c64/basic/basic_do_error.s index 584bfe19..92d7e46d 100644 --- a/c64/basic/basic_do_error.s +++ b/c64/basic/basic_do_error.s @@ -7,9 +7,9 @@ basic_do_error: ;; Print ? at start lda #$0d - jsr $ffd2 + jsr via_IBSOUT lda #$3f - jsr $ffd2 + jsr via_IBSOUT ;; Print main part of error message pla @@ -18,7 +18,7 @@ basic_do_error: ;; Print ERROR at end lda #$20 - jsr $ffd2 + jsr via_IBSOUT ldx #33 jsr print_packed_message @@ -27,9 +27,9 @@ basic_do_error: ;; XXX print line number if not in direct mode lda #$0d - jsr $ffd2 + jsr via_IBSOUT lda #$0d - jsr $ffd2 + jsr via_IBSOUT ;; Reset stack, and go back to main loop ldx #$fe diff --git a/c64/basic/basic_execute_line.s b/c64/basic/basic_execute_line.s index a7689e51..5ea0aafb 100644 --- a/c64/basic/basic_execute_line.s +++ b/c64/basic/basic_execute_line.s @@ -29,7 +29,7 @@ no_space_to_skip: basic_execute_statement: ;; Check for RUN/STOP - lda BUCKYSTATUS + lda STKEY bpl basic_do_break ;; Skip over any white space and : @@ -80,9 +80,9 @@ basic_execute_statement: ;; Now consume the character jsr basic_consume_character - rts + rts -not_a_token: +not_a_token: ;; Space, which we can also just ignore cmp #$20 beq basic_skip_char @@ -93,11 +93,28 @@ not_a_token: cmp #$3a beq basic_skip_char +;; START wedge support + + ;; Are we in direct mode? + ;; DOS Wedge is a hacky solution (inelegant, but convenient), + ;; BASIC programmers should implement communication with drives + ;; the standard way, handling channels properly. Besides, + ;; current implementation does not support characters under ROM + ldx basic_current_line_number+1 + cpx #$ff + bne + + ;; We are in direct mode, allow wedge to handle '@' sign + ;; XXX Maybe it should be allowed only as the first command? + cmp #$40 + bne + + jsr basic_consume_character + jmp wedge_dos +* +;; END wedge support + ;; If all else fails, it's a syntax error jmp do_SYNTAX_error - jmp basic_main_loop - basic_skip_char: jsr basic_consume_character jmp basic_execute_statement diff --git a/c64/basic/basic_main_loop.s b/c64/basic/basic_main_loop.s index 233bd60c..2d7afdd6 100644 --- a/c64/basic/basic_main_loop.s +++ b/c64/basic/basic_main_loop.s @@ -52,7 +52,7 @@ rsl_l1: lda $0200,x * ;; Do printing of the new line lda #$0d - jsr $ffd2 + jsr via_IBSOUT ;; Ignore empty lines lda tokenise_work1 diff --git a/c64/basic/cmd_break.s b/c64/basic/cmd_break.s index 38c7bd3d..31194132 100644 --- a/c64/basic/cmd_break.s +++ b/c64/basic/cmd_break.s @@ -17,7 +17,7 @@ basic_do_break: * lda #$0d - jsr $ffd2 + jsr via_IBSOUT cmd_end: jmp basic_main_loop diff --git a/c64/basic/cmd_list.s b/c64/basic/cmd_list.s index ba02f675..a1be1724 100644 --- a/c64/basic/cmd_list.s +++ b/c64/basic/cmd_list.s @@ -22,10 +22,16 @@ list_loop: jmp basic_main_loop list_more_lines: - lda BUCKYSTATUS + lda STKEY bmi + jmp basic_do_break * + jsr list_single_line + ;; Now link to the next line + jsr basic_find_next_line + jmp list_loop + +list_single_line: ; entry point needed by DOS wedge ;; Print line number ldy #3 jsr peek_under_roms @@ -36,7 +42,7 @@ list_more_lines: pla jsr print_integer lda #$20 - jsr $ffd2 + jsr via_IBSOUT ;; Iterate through printing out the line ;; contents @@ -105,19 +111,16 @@ list_not_rem: bne list_print_loop list_is_literal: - jsr $ffd2 + jsr via_IBSOUT iny bne list_print_loop list_end_of_line: ;; Clear reverse flag lda #$92 - jsr $ffd2 + jsr via_IBSOUT ;; Print end of line lda #$0d - jsr $ffd2 + jsr via_IBSOUT + rts - ;; Now link to the next line - jsr basic_find_next_line - jmp list_loop - diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index 000743fd..dc900c54 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -11,9 +11,18 @@ cmd_load: ;; middle of a program. For safety, we do. jsr basic_do_clr + ;; Setup Kernal to print control messages or not + lda #$80 ; display control messages and omit error messages + ldx basic_current_line_number+1 + cpx #$FF + beq + + lda #$00 ; direct mode - don't display anything +* + jsr JSETMSG + ;; Set filename and length lda #$00 - sta current_filename_length + sta FNLEN ;; Without tape support, LOAD must have a filename ;; (This also skips any leading spaces) @@ -34,7 +43,7 @@ cmd_load: ;; Now search for end of line or closing quote ;; so that we know the length of the filename -getting_filename: +getting_filename: jsr basic_fetch_and_consume_character cmp #$22 beq got_filename @@ -44,19 +53,52 @@ getting_filename: jmp got_filename * - inc current_filename_length + inc FNLEN jmp getting_filename -got_filename: +got_filename: - ;; Try to load an IEC file - lda #0 ; use supplied load address, not the one from the file + ;; Now fetch the file number, start from the default one + jsr select_device + stx current_device_number + jsr injest_comma + bcs got_devicenumber + + jsr basic_parse_line_number + lda basic_line_number+1 + bne do_ILLEGAL_QUANTITY_error + lda basic_line_number+0 + sta current_device_number + +got_devicenumber: + + ;; Now fetch the secondary address + lda #$00 sta current_secondary_address - lda #$00 ; LOAD not verify - ldx #<$0801 ; LOAD address = $0801 + jsr injest_comma + bcs got_secondaryaddress + jsr basic_parse_line_number + lda basic_line_number+1 + bne + + lda basic_line_number+0 + sta current_secondary_address + jmp got_secondaryaddress +* + ;; Second parameter is above 255, this can't be a secondary address + ;; Use it as load address instead + ;; XXX temporary syntax, it would be better to use something + ;; XXX like 'LOAD"FILE",8 TO 49152' + ldx basic_line_number+0 + ldy basic_line_number+1 + bne got_loadaddress + +got_secondaryaddress: + ldx #<$0801 ldy #>$0801 - jsr $ffd5 +got_loadaddress: + lda #$00 ; LOAD not verify + jsr via_ILOAD bcc + ;; A = KERNAL error code, which also almost match diff --git a/c64/basic/cmd_new.s b/c64/basic/cmd_new.s index ce355946..9d5f9d94 100644 --- a/c64/basic/cmd_new.s +++ b/c64/basic/cmd_new.s @@ -41,7 +41,7 @@ basic_do_new: ;; (same story), expression value cache? sec ; Read, not write value - jsr $ff99 ; KERNAL MEMTOP routine + jsr JMEMTOP cpx #$80 beq + lda #>$f7ff diff --git a/c64/basic/cmd_sys.s b/c64/basic/cmd_sys.s index 86830bd0..2328a0a4 100644 --- a/c64/basic/cmd_sys.s +++ b/c64/basic/cmd_sys.s @@ -10,22 +10,22 @@ cmd_sys: jsr basic_parse_line_number ;; setup call - lda #$4c ;JMP - sta sys_jmp + lda #$4C ;JMP + sta USRPOK lda basic_line_number+0 - sta sys_jmp+1 + sta USRADD+0 lda basic_line_number+1 - sta sys_jmp+2 + sta USRADD+1 ;; Setup the register values - lda sys_reg_p + lda SPREG pha - ldy sys_reg_y - ldx sys_reg_x - lda sys_reg_a + ldy SYREG + ldx SXREG + lda SAREG plp ;; Call the routine. - jsr sys_jmp + jsr USRPOK jmp basic_execute_statement diff --git a/c64/basic/injest_comma.s b/c64/basic/injest_comma.s new file mode 100644 index 00000000..43be5113 --- /dev/null +++ b/c64/basic/injest_comma.s @@ -0,0 +1,20 @@ + +;; Consummes a comma in a BASIC code, C set for no coma found + +injest_comma: + + jsr basic_fetch_and_consume_character + cmp #$2C ; comma character + beq injest_comma_found + cmp #$20 + beq injest_comma ; space, can always be skipped + + ;; not found + jsr basic_unconsume_character + sec + rts + +injest_comma_found: + clc + rts + diff --git a/c64/basic/packed_messages.s b/c64/basic/packed_messages.s deleted file mode 100644 index 2747aeda..00000000 --- a/c64/basic/packed_messages.s +++ /dev/null @@ -1,126 +0,0 @@ -packed_message_chars: - .byte $45 ; 'E' = $1 (nybl) - .byte $54 ; 'T' = $2 (nybl) - .byte $4F ; 'O' = $3 (nybl) - .byte $4E ; 'N' = $4 (nybl) - .byte $49 ; 'I' = $5 (nybl) - .byte $52 ; 'R' = $6 (nybl) - .byte $41 ; 'A' = $7 (nybl) - .byte $4C ; 'L' = $8 (nybl) - .byte $53 ; 'S' = $9 (nybl) - .byte $44 ; 'D' = $a (nybl) - .byte $46 ; 'F' = $b (nybl) - .byte $55 ; 'U' = $c (nybl) - .byte $50 ; 'P' = $d (nybl) - .byte $4D ; 'M' = $e (nybl) - .byte $43 ; 'C' = $F1 / $xF $43 - .byte $47 ; 'G' = $F2 / $xF $47 - .byte $59 ; 'Y' = $F3 / $xF $59 - .byte $56 ; 'V' = $F4 / $xF $56 - .byte $42 ; 'B' = $F5 / $xF $42 - .byte $48 ; 'H' = $F6 / $xF $48 - .byte $58 ; 'X' = $F7 / $xF $58 - .byte $57 ; 'W' = $F8 / $xF $57 - .byte $24 ; '$' = $F9 / $xF $24 - .byte $27 ; ''' = $Fa / $xF $27 - .byte $0D ; ' ' = $Fb / $xF $0D - .byte $51 ; 'Q' = $Fc / $xF $51 - .byte $2E ; '.' = $Fd / $xF $2E - .byte $23 ; '#' = $FE/F + $23 - .byte $4B ; 'K' = $FE/F + $4B - .byte $28 ; '(' = $FE/F + $28 - .byte $5A ; 'Z' = $FE/F + $5A - .byte $2B ; '+' = $FE/F + $2B - .byte $2D ; '-' = $FE/F + $2D - .byte $2A ; '*' = $FE/F + $2A - .byte $2F ; '/' = $FE/F + $2F - .byte $5E ; '^' = $FE/F + $5E - .byte $3E ; '>' = $FE/F + $3E - .byte $3D ; '=' = $FE/F + $3D - .byte $3C ; '<' = $FE/F + $3C -packed_message_tokens: - .byte $00,$01,$02,$ff,$03,$04,$ff,$03 - .byte $05,$04,$ff,$03,$05,$06,$ff,$07 - .byte $05,$08,$ff,$05,$09,$03,$ff,$05 - .byte $0a,$03,$ff,$0b,$0c,$ff,$0d,$07 - .byte $0e,$ff,$0f,$10,$11,$ff,$12,$ff - .byte $13,$10,$14,$ff,$15,$16,$17,$ff - .byte $0d,$18,$ff,$19,$ff,$15,$16,$1a - .byte $ff,$1b,$1c,$ff,$1d,$1e,$ff,$1f - .byte $20,$ff,$21,$22,$23,$ff,$0d,$24 - .byte $ff,$25,$26,$ff,$27,$00,$28,$ff - .byte $03,$17,$ff,$29,$00,$2a,$ff,$2b - .byte $2c,$ff,$1b,$2d,$ff,$2e,$ff,$2f - .byte $ff,$30,$ff,$31,$ff,$32,$ff,$33 - .byte $ff,$34,$ff,$35,$36,$ff,$1a,$37 - .byte $ff - .byte $05 - .byte $38 - .byte $ff -packed_message_words: - .byte $23,$30,$e7,$4f,$59,$00,$b5,$81 - .byte $90,$b5,$81,$00,$3d,$14,$00,$43 - .byte $20,$b3,$c4,$a0,$a1,$f4,$5f,$43 - .byte $10,$d6,$19,$14,$20,$54,$dc,$20 - .byte $3c,$2d,$c2,$00,$e5,$99,$54,$f2 - .byte $00,$b5,$81,$47,$e1,$00,$58,$81 - .byte $f2,$78,$00,$4c,$ef,$42,$16,$00 - .byte $41,$f7,$20,$f8,$52,$f6,$3c,$20 - .byte $b3,$60,$9f,$59,$42,$7f,$58,$00 - .byte $61,$2c,$64,$00,$f2,$39,$cf,$42 - .byte $00,$3c,$20,$3b,$00,$a7,$27,$00 - .byte $fc,$c7,$42,$52,$f3,$00,$3f,$56 - .byte $16,$b8,$3f,$57,$00,$e1,$e3,$6f - .byte $59,$00,$c4,$a1,$bf,$27,$a0,$92 - .byte $72,$1e,$14,$20,$f5,$7a,$00,$9c - .byte $f5,$9f,$43,$65,$d2,$00,$61,$a5 - .byte $ef,$27,$a0,$76,$67,$f3,$00,$a5 - .byte $f4,$59,$53,$40,$f5,$f3,$00,$ff - .byte $5a,$16,$30,$a5,$61,$f1,$20,$2f - .byte $59,$d1,$00,$e5,$9e,$72,$f1,$f6 - .byte $00,$92,$65,$4f,$47,$00,$83,$4f - .byte $47,$00,$b3,$6e,$c8,$70,$f1,$3e - .byte $d8,$1f,$58,$00,$f1,$74,$fa,$20 - .byte $f1,$34,$25,$4c,$10,$bc,$4f,$43 - .byte $25,$34,$00,$f4,$16,$5b,$f3,$00 - .byte $83,$7a,$00,$61,$7a,$f3,$fd,$fb - .byte $00,$83,$7a,$54,$f2,$00,$f4,$16 - .byte $5b,$f3,$54,$f2,$00,$97,$f4,$54 - .byte $f2,$00,$16,$63,$60,$f5,$f3,$21 - .byte $90,$b6,$11,$fd,$fb,$fb,$00,$f1 - .byte $36,$6c,$d2,$00,$5e,$d8,$1e,$14 - .byte $21 - .byte $a0 -packed_keywords: - .byte $14,$a0,$b3,$60,$41,$f7,$20,$a7 - .byte $27,$00,$54,$dc,$2f,$23,$00,$54 - .byte $dc,$20,$a5,$e0,$61,$7a,$00,$81 - .byte $20,$f2,$32,$30,$6c,$40,$5b,$00 - .byte $61,$92,$36,$10,$f2,$39,$cf,$42 - .byte $00,$61,$2c,$64,$00,$61,$e0,$92 - .byte $3d,$00,$34,$00,$f8,$75,$20,$83 - .byte $7a,$00,$97,$f4,$10,$f4,$16,$5b - .byte $f3,$00,$a1,$b0,$d3,$ff,$4b,$10 - .byte $d6,$54,$2f,$23,$00,$d6,$54,$20 - .byte $f1,$34,$20,$85,$92,$00,$f1,$86 - .byte $00,$f1,$ea,$00,$9f,$59,$90,$3d - .byte $14,$00,$f1,$83,$91,$00,$f2,$12 - .byte $00,$41,$f8,$00,$27,$f5,$fe,$28 - .byte $23,$00,$b4,$00,$9d,$f1,$fe,$28 - .byte $2f,$48,$14,$00,$43,$20,$92,$1d - .byte $00,$fe,$2b,$fe,$2d,$fe,$2a,$fe - .byte $2f,$fe,$5e,$74,$a0,$36,$00,$fe - .byte $3e,$fe,$3d,$fe,$3c,$9f,$47,$40 - .byte $54,$20,$7f,$42,$90,$c9,$60,$b6 - .byte $10,$d3,$90,$9f,$51,$60,$64,$a0 - .byte $83,$f2,$00,$1f,$58,$d0,$f1,$39 - .byte $00,$95,$40,$27,$40,$72,$40,$d1 - .byte $1f,$4b,$00,$81,$40,$92,$6f,$24 - .byte $00,$f4,$78,$00,$79,$f1,$00,$f1 - .byte $f6,$6f,$24,$00,$81,$b2,$f9,$00 - .byte $65,$f2,$f6,$2f,$24,$00,$e5,$af - .byte $24 - .byte $00 - .byte $f2 - .byte $30 - .alias packed_keyword_table_len $DC diff --git a/c64/basic/print_integer.s b/c64/basic/print_integer.s index 739f8b8b..7e897243 100644 --- a/c64/basic/print_integer.s +++ b/c64/basic/print_integer.s @@ -58,7 +58,7 @@ hi_loop: pha ldx #4 clc -hi_add_loop: +hi_add_loop: lda $0100,x adc number_table_hi,y sta $0100,x @@ -115,7 +115,7 @@ found_start_of_number: ;; Print digits * lda $0100,y ora #$30 - jsr $ffd2 + jsr via_IBSOUT iny cpy #5 bne - diff --git a/c64/basic/print_packed_message.s b/c64/basic/print_packed_message.s index 58481e82..7aac0876 100644 --- a/c64/basic/print_packed_message.s +++ b/c64/basic/print_packed_message.s @@ -38,7 +38,7 @@ found_message_in_token_stream: beq + jsr print_packed_word lda #$20 - jsr $ffd2 + jsr via_IBSOUT pla tay iny @@ -47,7 +47,7 @@ found_message_in_token_stream: pla ;; Rub out space at the end lda #$14 - jsr $ffd2 + jsr via_IBSOUT rts print_packed_word: @@ -138,13 +138,13 @@ next_packed_word_char: lsr tax - ;; Save Y so it doesn't get clobbered by $FFD2 + ;; Save Y so it doesn't get clobbered by CHROUT tya pha ;; X=1-14 = first 14 chars, so subtract one lda packed_message_chars-1,x - jsr $FFD2 + jsr via_IBSOUT ;; See if there is a char in the low nybl to print pla @@ -171,7 +171,7 @@ has_nybl: ;; X=1-14 = first 14 chars, so subtract one lda packed_message_chars-1,x - jsr $FFD2 + jsr via_IBSOUT * pla tay @@ -207,7 +207,7 @@ unpack_literal_char: tya pha lda (temp_string_ptr),y - jsr $ffd2 + jsr via_IBSOUT pla tay rts diff --git a/c64/basic/printf.s b/c64/basic/printf.s index c1edc71c..85fa0cf8 100644 --- a/c64/basic/printf.s +++ b/c64/basic/printf.s @@ -112,7 +112,7 @@ not_hexword: not_pointer: ;; Print character - jsr $ffd2 + jsr via_IBSOUT printf_nextchar: jsr printf_advance @@ -148,11 +148,11 @@ printf_printhexbyte: cmp #$3A bcc + adc #6 -* jsr $ffd2 +* jsr via_IBSOUT pla and #$0f ora #$30 cmp #$3A bcc + adc #6 -* jmp $ffd2 +* jmp via_IBSOUT diff --git a/c64/basic/select_device.s b/c64/basic/select_device.s new file mode 100644 index 00000000..f5939033 --- /dev/null +++ b/c64/basic/select_device.s @@ -0,0 +1,19 @@ + +select_device: + + ;; Take last device number, make sure it's a drive - 8 or above. Above 30, + ;; although illegal for IEC we also consider a drive, as they exists + ;; drivers assigning these numbers to CBM-DOS capable devices - like some + ;; IEEE-488 carts. + ;; + ;; If current device is not a drive, set device to 8 (first drive number) + ;; Device number is left in X, for SETFLS Kernal routine + + ;; Note: if tape support is introduced here, make sure DOS wedge won't get broken + + ldx current_device_number + cpx #$08 + bcs + + ldx #$08 +* + rts diff --git a/c64/basic/via_vector.s b/c64/basic/via_vector.s new file mode 100644 index 00000000..3cfc7480 --- /dev/null +++ b/c64/basic/via_vector.s @@ -0,0 +1,42 @@ + +;; +;; Helper routines for jumping via vectors, to be used with JSR +;; +;; Note: they are not in the order of low memory vectors, to avoid +;; similarity with the original ROMs + +via_ISAVE: + jmp (ISAVE) + +via_ILOAD: + jmp (ILOAD) + +via_ICLOSE: + jmp (ICLOSE) + +via_IOPEN: + jmp (IOPEN) + +via_ICHKIN: + jmp (ICHKIN) + +via_IBASIN: + jmp (IBASIN) + +via_IGETIN: + jmp (IGETIN) + +via_ICKOUT: + jmp (ICKOUT) + +via_IBSOUT: + jmp (IBSOUT) + +via_ICLRCH: + jmp (ICLRCH) + +via_ICLALL: + jmp (ICLALL) + +via_ISTOP: + jmp (ISTOP) diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s new file mode 100644 index 00000000..e147e9fe --- /dev/null +++ b/c64/basic/wedge_dos.s @@ -0,0 +1,230 @@ + +;; START wedge support + +wedge_dos: + + ;; Close all the channels, so that wedge has full control + jsr via_ICLALL + + ;; Set file parameters, channel 15 is a typical one for commands + jsr select_device ; sets X register + lda #$0F + ldy #$0F + jsr JSETFLS + + ;; Now we have to check what the user wants us to do + + ;; Check if user asked for a status + ldy #$00 + lda (basic_current_statement_ptr), y + beq wedge_dos_status + + ;; Check if asked for a directory + cmp #$24 + beq wedge_dos_directory +* + ;; Check if asked to change drive number, or if it is a regular command + cmp #$30 + bcc wedge_dos_command ; char code before 0 + cmp #$3A + bcs wedge_dos_command ; char code after 9 + iny + lda (basic_current_statement_ptr), y + beq wedge_dos_change_drive ; end of buffer + cmp #$20 + beq wedge_dos_change_drive + jmp - + +wedge_dos_command: + + ;; Provide command name + jsr wedge_dos_setnam + + jsr JSETNAM + jsr via_IOPEN + bcs wedge_dos_basic_error + + ;; Retrieve status, print it if not OK + jsr via_ICLALL + jsr wedge_dos_status_get + lda BUF+0 + cmp #$30 ; '0' + bne wedge_dos_status_print + lda BUF+1 + cmp #$30 ; '0' + bne wedge_dos_status_print + + ;; Clean-up and exit + jmp wedge_dos_clean_exit + +wedge_dos_change_drive: + + ;; Reuse the line number parser for device number retrieval + jsr basic_parse_line_number + lda basic_line_number+1 + beq + + jmp do_ILLEGAL_QUANTITY_error +* + lda basic_line_number+0 + cmp #$08 + bpl + + bcs + + jmp do_ILLEGAL_DEVICE_NUMBER_error +* + sta current_device_number + jmp basic_end_of_line + +wedge_dos_status_get: + + ;; Here the flow is mostly the same as in the example from + ;; https://codebase64.org/doku.php?id=base:reading_the_error_channel_of_a_disk_drive + + ;; Set remaining file parameters, open the channel + lda #$00 ; empty file name + jsr JSETNAM + jsr via_IOPEN + bcs wedge_dos_basic_error + + ;; Set channel for input + ldx #$0F + jsr via_ICHKIN + bcs wedge_dos_basic_error + + ldy #$00 +* + cpy #$50 ; buffer overflow protection + beq + + jsr JREADST ; retrieve errors + ;; XXX error in case of status != EOF + ;; Print out everything retrieved from the drive + bne + + jsr via_IBASIN + bcs wedge_dos_basic_error + sta BUF, y + iny + jmp - +* + rts + +wedge_dos_status: + jsr wedge_dos_status_get + ;; FALLTROUGH + +wedge_dos_status_print: + + ;; Print buffered status + ldx #$00 +* + dey + bmi + + lda BUF, x + jsr via_IBSOUT + inx + bne - +* + ;; Clean-up and exit + jmp wedge_dos_clean_exit + +wedge_dos_directory: + + ;; First change the secondary address to the one suitable for + ;; directory loading + ;; XXX + lda #$00 ; logical device number + ldx current_device_number + ldy #$60 + jsr JSETFLS + + ;; Provide file name + jsr wedge_dos_setnam + + ;; Open the file + jsr via_IOPEN + bcs wedge_dos_basic_error + + ;; Set channel for file reading + ldx #$00 + jsr via_ICHKIN + bcs wedge_dos_basic_error + + ;; Ignore start address (2 first bytes) - XXX check for errors + jsr via_IBASIN + bcs wedge_dos_basic_error + jsr via_IBASIN + bcs wedge_dos_basic_error + +wedge_dos_directory_line: + + ;; Load a single line, reuse BASIC input buffer + ldy #$FF +* + iny + jsr via_IBASIN + bcs wedge_dos_basic_error + sta BUF, y + cpy #$50 + beq + ; line too long, terminate loading file + jsr JREADST + bne + ; end of file + cpy #$04 ; 2 bytes (pointer to next line) + 2 bytes (line number) + bcc - + lda BUF, y + bne - + ;; End of line, but not end of file + beq wedge_dos_directory_display +* + lda #K_STS_END_OF_FILE + sta IOSTATUS ; make sure end of file is marked + ;; FALLTROUGH + +wedge_dos_directory_display: + + cpy #$05 ; protection against malformed directory + bcc wedge_dos_clean_exit + + lda #$00 ; extra protection agains buffer overflow + sta BUF, y + + ;; Display line + ldx #BUF + stx basic_current_line_ptr+1 + ldx #basic_current_line_ptr + jsr list_single_line + + ;; Read & display next line or quit + lda IOSTATUS + beq wedge_dos_directory_line + ;; FALLTROUGH + +wedge_dos_clean_exit: + jsr via_ICLALL + ;; Print new line + lda #$0D + jsr via_IBSOUT + jmp basic_end_of_line + +wedge_dos_basic_error: + pha + jsr via_ICLALL + pla + tax + dex + jmp do_basic_error + +wedge_dos_setnam: + ;; Now determine the length of the 'file' name + ldy #$FF +* + iny + lda (basic_current_statement_ptr), y + bne - + + ;; Set the name to open + tya + ldx basic_current_statement_ptr+0 + ldy basic_current_statement_ptr+1 + jmp JSETNAM + +;; END wedge support diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 4dc694f1..b769b149 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -3,27 +3,18 @@ ; (And only those for now that we feel the need to implement initially) ; (https://www.c64-wiki.com/wiki/Zeropage) - .alias TXTTAB $2B - .alias IOSTATUS $90 - ; Keys down clears bits. STOP=bit 7, C= bit 6, SPACE bit 4, CTRL bit 2 - .alias BUCKYSTATUS $91 .alias kernal_load_or_verify_flag $93 .alias current_file_num $98 - .alias input_device_number $99 - ; bit 6 = error messages, bit 7 = control messages - .alias kernal_message_control_flags $9d - .alias jiffy_clock_24bits $a0 + .alias input_device_number DFLTN .alias cassette_buffer_bytes_used $A6 .alias load_or_scroll_temp_pointer $AC ;; We also use the following for temp colour pointer when scrolling .alias load_save_verify_end_address $AE .alias cassette_buffer_ptr $B2 - .alias current_filename_length $B7 .alias current_logical_filenum $B8 .alias current_secondary_address $B9 .alias current_device_number $BA .alias current_filename_ptr $BB - .alias load_save_start_ptr $C1 .alias load_save_end_ptr $C3 .alias last_key_matrix_position $C5 .alias keys_in_key_buffer $C6 @@ -50,15 +41,11 @@ .alias keyboard_decoding_table_ptr $F5 .alias rs232_rx_buffer_ptr $F7 .alias rs232_tx_buffer_ptr $F9 - - + ; "Compute's Mapping the 64" book .alias keyboard_buffer $0277 - .alias MEMSTR $0281 - .alias MEMSIZ $0283 ; NOTE: Mapping the 64 erroniously has the hex as $282, while the DEC is correct .alias text_colour $0286 ; p55 .alias colour_under_cursor $0287 ; p56 - .alias HIBASE $0288 ; p56 (high byte of start of screen) .alias key_buffer_size $0289 ; p57 ;; 0 = cursor keys, insert, delete and space repeat, but nothing else @@ -74,7 +61,6 @@ .alias keyboard_decoding_ptr $028F .alias enable_case_switch $0291 .alias screen_scroll_disable $0292 - .alias pal_or_ntsc $02A6 ;; Under-ROM routines ;; (BASIC also includes them. XXX - We should de-duplicate them in a safe manner) @@ -84,5 +70,4 @@ .alias poke_under_roms tiny_nmi_handler+poke_under_roms_routine-tiny_nmi_handler_routine .alias memmap_allram tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine .alias memmap_normal tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine - - + diff --git a/c64/kernal/,target_generic/,hooks_generic.s b/c64/kernal/,target_generic/,hooks_generic.s new file mode 100644 index 00000000..a2c8c1a6 --- /dev/null +++ b/c64/kernal/,target_generic/,hooks_generic.s @@ -0,0 +1,6 @@ + +;; Target-specific hooks + + +.macro TARGET_HOOK_LOAD +.macend diff --git a/c64/kernal/,target_mega65/,hooks_mega65.s b/c64/kernal/,target_mega65/,hooks_mega65.s new file mode 100644 index 00000000..a2c8c1a6 --- /dev/null +++ b/c64/kernal/,target_mega65/,hooks_mega65.s @@ -0,0 +1,6 @@ + +;; Target-specific hooks + + +.macro TARGET_HOOK_LOAD +.macend diff --git a/c64/kernal/,target_ultimate64/,aliases_ultimate64.s b/c64/kernal/,target_ultimate64/,aliases_ultimate64.s new file mode 100644 index 00000000..a4aabfaf --- /dev/null +++ b/c64/kernal/,target_ultimate64/,aliases_ultimate64.s @@ -0,0 +1,57 @@ + +;; Registers according to Ultimate 64 Command Interface description, +;; https://1541u-documentation.readthedocs.io/en/latest/command%20interface.html +;; and ultimate_dos_v1.0.pdf and command_interface_v1.0.pdf by Gideon Zweijtzer + + ;; Command interface registers + .alias U64_CONTROL $DF1C ; write + .alias U64_STATUS $DF1C ; read + .alias U64_COMMAND_DATA $DF1D ; write + .alias U64_IDENTIFICATION $DF1D ; read + .alias U64_RESPONSE_DATA $DF1E ; read only + .alias U64_STATUS_DATA $DF1F ; read only + + ;; Constant for U64_IDENTIFICATION register + .alias U64_MAGIC_ID $C9 + + ;; Constants for U64_CONTROL register + .alias U64_CTRL_BIT_PUSH_CMD $01 + .alias U64_CTRL_BIT_DATA_ACC $02 + .alias U64_CTRL_BIT_ABORT $04 + .alias U64_CTRL_BIT_CLR_ERR $08 + + ;; Constants for U64_STATUS register + .alias U64_STAT_BIT_CMD_BUSY $01 + .alias U64_STAT_BIT_DATA_ACC $02 + .alias U64_STAT_BIT_ABORT_P $04 + .alias U64_STAT_BIT_ERROR $08 + .alias U64_STAT_MASK_STATE $30 ; two bits! + .alias U64_STAT_BIT_STAT_AV $40 + .alias U64_STAT_BIT_DATA_AV $80 + + ;; Interface targets + .alias U64_TARGET_DOS1 $01 + .alias U64_TARGET_DOS2 $02 + + ;; DOS command codes + .alias U64_DOS_CMD_IDENTIFY $01 + .alias U64_DOS_CMD_OPEN_FILE $02 + .alias U64_DOS_CMD_CLOSE_FILE $03 + .alias U64_DOS_CMD_READ_DATA $04 + .alias U64_DOS_CMD_WRITE_DATA $05 + .alias U64_DOS_CMD_FILE_SEEK $06 + .alias U64_DOS_CMD_FILE_INFO $07 + .alias U64_DOS_CMD_CHANGE_DIR $11 + .alias U64_DOS_CMD_GET_PATH $12 + .alias U64_DOS_CMD_OPEN_DIR $13 + .alias U64_DOS_CMD_READ_DIR $14 + .alias U64_DOS_CMD_COPY_UI_PATH $15 + .alias U64_DOS_CMD_LOAD_REU $21 + .alias U64_DOS_CMD_SAVE_REU $22 + .alias U64_DOS_CMD_ECHO $F0 + + ;; DOS file opening constants + .alias U64_FA_READ $01 + .alias U64_FA_WRITE $02 + .alias U64_FA_CREATE_NEW $03 + .alias U64_FA_CREATE_ALWAYS $04 diff --git a/c64/kernal/,target_ultimate64/,hooks_ultimate64.s b/c64/kernal/,target_ultimate64/,hooks_ultimate64.s new file mode 100644 index 00000000..03f6eeb8 --- /dev/null +++ b/c64/kernal/,target_ultimate64/,hooks_ultimate64.s @@ -0,0 +1,9 @@ + +;; Target-specific hooks + + +.macro TARGET_HOOK_LOAD + ;; XXX disabled for now - the current file opening API is not + ;; really suitable for easy usage from Kernal + ;; jsr u64_load +.macend diff --git a/c64/kernal/,target_ultimate64/u64_load.s.disabled b/c64/kernal/,target_ultimate64/u64_load.s.disabled new file mode 100644 index 00000000..07ddc298 --- /dev/null +++ b/c64/kernal/,target_ultimate64/u64_load.s.disabled @@ -0,0 +1,130 @@ + +;; +;; LOAD routine hook for fast loading via UltiDOS +;; + + +u64_load: + + ;; First check whether the command interface is enabled + lda U64_IDENTIFICATION + cmp #U64_MAGIC_ID + beq + + +u64_load_skip: + rts +* + ;; XXX find out which device number softIEC is mapped to + lda current_device_number + cmp #$20 ; for now use device number 32 + bne u64_load_skip + + ;; Takeover the flow completely + pla + pla + + ;; Display SEARCHING FOR + filename + jsr lvs_display_searching_for + + ;; Whatever the interface was doing - ask to abort it + jsr u64_load_abort + + ;; Send a command to open the file + lda #U64_DOS_CMD_OPEN_FILE + jsr u64_load_send_cmd + lda #U64_FA_READ + jsr u64_load_send_cmd + jsr u64_load_send_filename + jsr u64_load_finalize_cmd + + ;; Check status + jsr u64_load_check_status + bcs lvs_file_not_found_error + + ;; Load first two bytes to determine start address + + ;; XXX + + jsr printf + .byte "DBG: NOT IMPLEMENTED",$0D,0 + + jmp lvs_wrap_around_error + rts + +u64_load_abort: + lda #U64_CTRL_BIT_ABORT + sta U64_CONTROL +* + lda U64_STATUS + bne - + rts + +u64_load_send_cmd: + + ldx #U64_TARGET_DOS2 + stx U64_COMMAND_DATA ; target + sta U64_COMMAND_DATA ; command code + rts + +u64_load_send_filename: + ldy #0 +u64_load_send_filename_loop: + cpy FNLEN + bne+ + rts +* + ldx #200usec, then it is EOI and we have to assert the - ;; DATA line for 60 usec to tell the TALKER that we have - ;; acknowledged the EOI. - ldx #20 -iec_rx_clk_wait: - ;; Loop takes 11 usec, so ~20 iterations for 200usec timeout - lda $dd00 - rol - bpl not_eoi - dex - cpx #$21 - bne not_rx_timeout - ;; Time out waiting for CLK to assert again. - ;; = error - sec - rts -not_rx_timeout: - cpx #$00 - bpl iec_rx_clk_wait - - ;; Remember EOI condition - lda IOSTATUS - ora #$40 - sta IOSTATUS - - ;; EOI timeout: So pulse DATA line for 60 usec - jsr iec_assert_data - jsr iec_wait60us - jsr iec_release_clk_and_data - - ;; And still wait for CLK to be asserted - ;; XXX - This will cause periodic EOI pulses if the sender takes too long. - ;; That is probably ok. - ldx #$7f - jmp iec_rx_clk_wait - -not_eoi: - ;; CLK is now low. Latch input bits in on rising edge - ;; of CLK, eight times for eight bits. - ldx #7 - - ;; Get empty byte to load into. - lda #$00 - pha - -iec_rx_bit_loop: - - ;; Wait for CLK to release - ;; jsr iec_wait_for_clock_release - ;; (we do this implicitly below, with a tighter routine, - ;; so that we don't have timing problems, as the requirements - ;; are quite tight. Basically we need to read the clock and data - ;; bit from the same byte read. - - ;; DATA now has the next bit, but inverted (well, except that it turns out not to be). - ;; DATA is in bit7, which is a bit annoying. - ;; But we can clock it out with a ROL instruction - ;; so that it is in C. We can then ROR it into the - ;; partial data byte. - ;; We use ROR so that we shift in from the top, so that - ;; the first bit we shift in ends up in bit 0 after all - ;; 8 bits have been read. - ;; ODD: For some reason we don't need to invert the - ;; received bits. This is weird, because we invert them - ;; on the way out, and everything in the protocol seems - ;; to indicate that we sould do so. But experimentation - ;; has confirmed the bits don't need inversion on reception. - - ;; Move data bit into C flag, and loop until bit 6 clears - ;; i.e., the clock has been released. -* LDA $DD00 - ROL - bpl - - - ;; Pull it into the data byte - pla - ROR - pha - - ;; Wait for CLK to re-assert - jsr iec_wait_for_clock_assert - - ;; More bits? - dex - bpl iec_rx_bit_loop - - ;; Then we must within 1000usec acknowledge the frame by - ;; asserting DATA. At this point, CLK is asserted by the - ;; talker and DATA by us, i.e., we are ready to receive - ;; the next byte. (p11). - jsr iec_assert_data - - ;; Retreive the received byte - PLA - - ;; Return no-error - CLC - RTS - diff --git a/c64/kernal/iec_turnaround_to_listen.s b/c64/kernal/iec_turnaround_to_listen.s deleted file mode 100644 index b65565b7..00000000 --- a/c64/kernal/iec_turnaround_to_listen.s +++ /dev/null @@ -1,39 +0,0 @@ - ;; According to http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - ;; pages 7--8. - -iec_turnaround_to_listen: - - ;; Assert data and release clock - lda $dd00 - and #$ef ; release clock (bit 4) - ora #$20 ; assert data (bit 5) - sta $dd00 - - ;; Wait for clock line to be asserted by the drive -* lda $dd00 - and #$40 - bne - - - ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - ;; page 8 tells us we should not do anything here after waiting for - ;; the clock line to assert. - - ldx #$ff - * lda $dd00 - and #$40 - bne + - dex - bne - - - ;; jsr printf - ;; .byte "TURNAROUND FAILED - FILE NOT FOUND?",$0d,$00 - - ;; ;; Timeout = file not found error - ;; ;; (https://www.pagetable.com/?p=1023) - lda #4 - sec - rts -* - ;; ATN turn around successful - clc - rts diff --git a/c64/kernal/iec_tx_byte.s b/c64/kernal/iec_tx_byte.s deleted file mode 100644 index 03f35c6d..00000000 --- a/c64/kernal/iec_tx_byte.s +++ /dev/null @@ -1,87 +0,0 @@ -iec_tx_byte: - - pha - - jsr iec_assert_clk_release_data - - ;; Give devices time to respond - jsr wait1ms - - ;; Did a device respond? (DATA will be pulled if so) - lda $DD00 - bpl + - - ;; No devices present, so we can immediately return with device not found - pla - jmp kernalerror_DEVICE_NOT_FOUND -* - - ;; Release CLK and wait for DATA to release. - jsr iec_release_clk_and_data - - ;; Wait for DATA to be released - ;; Listener is allowed to hold DATA for as long as they want. - ;; i.e., this is the part of the protocol where the listener indicates - ;; that they are busy doing something, like processing the previous - ;; character. - jsr iec_wait_for_data_release - - ;; We then wait for 60 usec (less than 200usec so we don't - ;; signal EOI), before asserting CLK again. - jsr iec_wait60us - - ;; Do the actual transmission of 8 bits of data - ldx #7 - - pla - -iec_tx_byte_nextbit: - ;; Is next bit 0 or 1? - lsr - pha - bcs + - - ;; Setup 0 - jsr iec_assert_clk_and_data - jmp iec_tx_byte_l1 -* - ;; Setup 1 - jsr iec_assert_clk_release_data -iec_tx_byte_l1: - ;; Clock bit out - jsr iec_wait20us - - jsr iec_release_clk - - jsr iec_wait20us - - ;; More bits to send? - pla - dex - bpl iec_tx_byte_nextbit - - ;; Done sending bits. Assert CLK and wait for acknowledgement - jsr iec_assert_clk_release_data - - ;; Acknowledgement must happen within 1ms, else it - ;; is DEVICE NOT PRESENT - ;; Acknowledgement consists of the DATA line being pulled - ;; by the listener. - ;; We can't easily count rasters here, so we just - ;; try a set number of times - ldx #$ff -* lda $DD00 - ;; BPL here is checking that bit 7 of $DD00 clears, - ;; i.e, that the DATA line is asserted. - bpl + - dex - bne - - - ;; Timeout - DEVICE NOT PRESENT - jmp kernalerror_DEVICE_NOT_FOUND -* - ;; All done. - ;; End state is TALKER is asserting CLK, and listener is asserting DATA - ;; until they are ready for the next byte. - clc - rts diff --git a/c64/kernal/iec_wait20us.s b/c64/kernal/iec_wait20us.s deleted file mode 100644 index 86456409..00000000 --- a/c64/kernal/iec_wait20us.s +++ /dev/null @@ -1,7 +0,0 @@ - -iec_wait20us: - ;; Wait 20usec - ;; JSR + RTS already costs 12, so need only 8 more - ldy $dd00 - ldy $dd00 - rts diff --git a/c64/kernal/iec_wait60us.s b/c64/kernal/iec_wait60us.s deleted file mode 100644 index d1eed334..00000000 --- a/c64/kernal/iec_wait60us.s +++ /dev/null @@ -1,9 +0,0 @@ -iec_wait60us: - - ;; Waste ~60 clock cycles (including JSR + RTS) - ldy #$06 -* lda $dd00 - dey - bpl - - - rts diff --git a/c64/kernal/iec_wait_for_clock_assert.s b/c64/kernal/iec_wait_for_clock_assert.s deleted file mode 100644 index aa661af9..00000000 --- a/c64/kernal/iec_wait_for_clock_assert.s +++ /dev/null @@ -1,5 +0,0 @@ -iec_wait_for_clock_assert: - LDA $DD00 - and #$40 - bne iec_wait_for_clock_assert - rts diff --git a/c64/kernal/iec_wait_for_clock_release.s b/c64/kernal/iec_wait_for_clock_release.s deleted file mode 100644 index cb5d8c72..00000000 --- a/c64/kernal/iec_wait_for_clock_release.s +++ /dev/null @@ -1,5 +0,0 @@ -iec_wait_for_clock_release: - LDA $DD00 - and #$40 - beq iec_wait_for_clock_release - rts diff --git a/c64/kernal/iec_wait_for_data_release.s b/c64/kernal/iec_wait_for_data_release.s deleted file mode 100644 index 36232975..00000000 --- a/c64/kernal/iec_wait_for_data_release.s +++ /dev/null @@ -1,5 +0,0 @@ -iec_wait_for_data_release: - LDA $DD00 - and #$40 - beq iec_wait_for_data_release - rts diff --git a/c64/kernal/irq_handler.s b/c64/kernal/irq_handler.s index 1b8b4730..82bbaac7 100644 --- a/c64/kernal/irq_handler.s +++ b/c64/kernal/irq_handler.s @@ -6,7 +6,7 @@ irq_handler: ;; $EA61 - Check keyboard, but don't update timer? https://github.com/cc65/cc65/issues/324 ;; $EA81 - https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb ;; Also the $0314 vector is widely used (e.g., https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb) - + ;; Save registers ;; Sequence according to Compute's Mapping the 64 p73 pha @@ -17,7 +17,7 @@ irq_handler: ;; Call interrupt routine ;; (but only if initialised) - lda $0314 - ora $0315 + lda CINV + ora CINV+1 beq default_irq_handler - jmp ($0314) + jmp (CINV) diff --git a/c64/kernal/ff81.s b/c64/kernal/jumptable/ff81.jcint.s similarity index 100% rename from c64/kernal/ff81.s rename to c64/kernal/jumptable/ff81.jcint.s diff --git a/c64/kernal/ff84.s b/c64/kernal/jumptable/ff84.jioinit.s similarity index 100% rename from c64/kernal/ff84.s rename to c64/kernal/jumptable/ff84.jioinit.s diff --git a/c64/kernal/ff87.s b/c64/kernal/jumptable/ff87.jramtas.s similarity index 100% rename from c64/kernal/ff87.s rename to c64/kernal/jumptable/ff87.jramtas.s diff --git a/c64/kernal/ff8a.s b/c64/kernal/jumptable/ff8a.jrestor.s similarity index 100% rename from c64/kernal/ff8a.s rename to c64/kernal/jumptable/ff8a.jrestor.s diff --git a/c64/kernal/ff8d.s b/c64/kernal/jumptable/ff8d.jvector.s similarity index 100% rename from c64/kernal/ff8d.s rename to c64/kernal/jumptable/ff8d.jvector.s diff --git a/c64/kernal/ff90.s b/c64/kernal/jumptable/ff90.jsetmsg.s similarity index 100% rename from c64/kernal/ff90.s rename to c64/kernal/jumptable/ff90.jsetmsg.s diff --git a/c64/kernal/ff93.s b/c64/kernal/jumptable/ff93.jsecond.s similarity index 100% rename from c64/kernal/ff93.s rename to c64/kernal/jumptable/ff93.jsecond.s diff --git a/c64/kernal/ff96.s b/c64/kernal/jumptable/ff96.jtksa.s similarity index 100% rename from c64/kernal/ff96.s rename to c64/kernal/jumptable/ff96.jtksa.s diff --git a/c64/kernal/ff99.s b/c64/kernal/jumptable/ff99.jmemtop.s similarity index 100% rename from c64/kernal/ff99.s rename to c64/kernal/jumptable/ff99.jmemtop.s diff --git a/c64/kernal/ff9c.s b/c64/kernal/jumptable/ff9c.jmembot.s similarity index 100% rename from c64/kernal/ff9c.s rename to c64/kernal/jumptable/ff9c.jmembot.s diff --git a/c64/kernal/ff9f.s b/c64/kernal/jumptable/ff9f.jscnkey.s similarity index 100% rename from c64/kernal/ff9f.s rename to c64/kernal/jumptable/ff9f.jscnkey.s diff --git a/c64/kernal/ffa2.s b/c64/kernal/jumptable/ffa2.jsettmo.s similarity index 100% rename from c64/kernal/ffa2.s rename to c64/kernal/jumptable/ffa2.jsettmo.s diff --git a/c64/kernal/ffa5.s b/c64/kernal/jumptable/ffa5.jacptr.s similarity index 100% rename from c64/kernal/ffa5.s rename to c64/kernal/jumptable/ffa5.jacptr.s diff --git a/c64/kernal/ffa8.s b/c64/kernal/jumptable/ffa8.jciout.s similarity index 100% rename from c64/kernal/ffa8.s rename to c64/kernal/jumptable/ffa8.jciout.s diff --git a/c64/kernal/ffab.s b/c64/kernal/jumptable/ffab.juntlk.s similarity index 100% rename from c64/kernal/ffab.s rename to c64/kernal/jumptable/ffab.juntlk.s diff --git a/c64/kernal/ffae.s b/c64/kernal/jumptable/ffae.junlsn.s similarity index 100% rename from c64/kernal/ffae.s rename to c64/kernal/jumptable/ffae.junlsn.s diff --git a/c64/kernal/ffb1.s b/c64/kernal/jumptable/ffb1.jlisten.s similarity index 100% rename from c64/kernal/ffb1.s rename to c64/kernal/jumptable/ffb1.jlisten.s diff --git a/c64/kernal/ffb4.s b/c64/kernal/jumptable/ffb4.jtalk.s similarity index 100% rename from c64/kernal/ffb4.s rename to c64/kernal/jumptable/ffb4.jtalk.s diff --git a/c64/kernal/ffb7.s b/c64/kernal/jumptable/ffb7.jreadst.s similarity index 100% rename from c64/kernal/ffb7.s rename to c64/kernal/jumptable/ffb7.jreadst.s diff --git a/c64/kernal/ffba.s b/c64/kernal/jumptable/ffba.jsetfls.s similarity index 87% rename from c64/kernal/ffba.s rename to c64/kernal/jumptable/ffba.jsetfls.s index 4e68df53..6ad1fe44 100644 --- a/c64/kernal/ffba.s +++ b/c64/kernal/jumptable/ffba.jsetfls.s @@ -1,3 +1,3 @@ ; Set logical, first and second addresses ; C64 Programmer's Reference Guide Page 273 - jmp setlfs + jmp setfls diff --git a/c64/kernal/ffbd.s b/c64/kernal/jumptable/ffbd.jsetnam.s similarity index 100% rename from c64/kernal/ffbd.s rename to c64/kernal/jumptable/ffbd.jsetnam.s diff --git a/c64/kernal/ffc0.s b/c64/kernal/jumptable/ffc0.jopen.s similarity index 100% rename from c64/kernal/ffc0.s rename to c64/kernal/jumptable/ffc0.jopen.s diff --git a/c64/kernal/ffc3.s b/c64/kernal/jumptable/ffc3.jclose.s similarity index 100% rename from c64/kernal/ffc3.s rename to c64/kernal/jumptable/ffc3.jclose.s diff --git a/c64/kernal/ffc6.s b/c64/kernal/jumptable/ffc6.jchkin.s similarity index 100% rename from c64/kernal/ffc6.s rename to c64/kernal/jumptable/ffc6.jchkin.s diff --git a/c64/kernal/ffc9.s b/c64/kernal/jumptable/ffc9.jckout.s similarity index 85% rename from c64/kernal/ffc9.s rename to c64/kernal/jumptable/ffc9.jckout.s index 1b76a8dc..ccfe9a2f 100644 --- a/c64/kernal/ffc9.s +++ b/c64/kernal/jumptable/ffc9.jckout.s @@ -1,3 +1,3 @@ ; Open channel for output ; C64 Programmer's Reference Guide Page 272 - jmp chkout + jmp ckout diff --git a/c64/kernal/ffcc.s b/c64/kernal/jumptable/ffcc.jclrchn.s similarity index 100% rename from c64/kernal/ffcc.s rename to c64/kernal/jumptable/ffcc.jclrchn.s diff --git a/c64/kernal/ffcf.s b/c64/kernal/jumptable/ffcf.jchrin.s similarity index 100% rename from c64/kernal/ffcf.s rename to c64/kernal/jumptable/ffcf.jchrin.s diff --git a/c64/kernal/ffd2.s b/c64/kernal/jumptable/ffd2.jchrout.s similarity index 100% rename from c64/kernal/ffd2.s rename to c64/kernal/jumptable/ffd2.jchrout.s diff --git a/c64/kernal/ffd5.s b/c64/kernal/jumptable/ffd5.jload.s similarity index 100% rename from c64/kernal/ffd5.s rename to c64/kernal/jumptable/ffd5.jload.s diff --git a/c64/kernal/ffd8.s b/c64/kernal/jumptable/ffd8.jsave.s similarity index 100% rename from c64/kernal/ffd8.s rename to c64/kernal/jumptable/ffd8.jsave.s diff --git a/c64/kernal/ffdb.s b/c64/kernal/jumptable/ffdb.jsettim.s similarity index 100% rename from c64/kernal/ffdb.s rename to c64/kernal/jumptable/ffdb.jsettim.s diff --git a/c64/kernal/ffde.s b/c64/kernal/jumptable/ffde.jrdtim.s similarity index 100% rename from c64/kernal/ffde.s rename to c64/kernal/jumptable/ffde.jrdtim.s diff --git a/c64/kernal/ffe1.s b/c64/kernal/jumptable/ffe1.jstop.s similarity index 100% rename from c64/kernal/ffe1.s rename to c64/kernal/jumptable/ffe1.jstop.s diff --git a/c64/kernal/ffe4.s b/c64/kernal/jumptable/ffe4.jgetin.s similarity index 100% rename from c64/kernal/ffe4.s rename to c64/kernal/jumptable/ffe4.jgetin.s diff --git a/c64/kernal/ffe7.s b/c64/kernal/jumptable/ffe7.jclall.s similarity index 81% rename from c64/kernal/ffe7.s rename to c64/kernal/jumptable/ffe7.jclall.s index d333af55..03e1725f 100644 --- a/c64/kernal/ffe7.s +++ b/c64/kernal/jumptable/ffe7.jclall.s @@ -1,3 +1,3 @@ ; $FFE7 - Close all files vector ; (http://codebase64.org/doku.php?id=base:kernalreference) - jmp close_all_files + jmp clall diff --git a/c64/kernal/ffea.s b/c64/kernal/jumptable/ffea.judtim.s similarity index 100% rename from c64/kernal/ffea.s rename to c64/kernal/jumptable/ffea.judtim.s diff --git a/c64/kernal/ffed.s b/c64/kernal/jumptable/ffed.jscreen.s similarity index 83% rename from c64/kernal/ffed.s rename to c64/kernal/jumptable/ffed.jscreen.s index a9e258cf..55d44e37 100644 --- a/c64/kernal/ffed.s +++ b/c64/kernal/jumptable/ffed.jscreen.s @@ -1,4 +1,4 @@ ; $FFED - Return screen size (X=columns, Y=rows) ; (http://codebase64.org/doku.php?id=base:kernalreference) - jmp get_screen_size + jmp screen diff --git a/c64/kernal/fff0.s b/c64/kernal/jumptable/fff0.jplot.s similarity index 100% rename from c64/kernal/fff0.s rename to c64/kernal/jumptable/fff0.jplot.s diff --git a/c64/kernal/jumptable/fff3.jiobase.s b/c64/kernal/jumptable/fff3.jiobase.s new file mode 100644 index 00000000..1c459c5d --- /dev/null +++ b/c64/kernal/jumptable/fff3.jiobase.s @@ -0,0 +1,19 @@ + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 284 +;; - [CM64] Compute's Mapping the Commodore 64 - page 214 +;; - http://codebase64.org/doku.php?id=base:kernalreference (original source) +;; +;; CPU registers that has to be preserved (see [RG64]): .A +;; + + +;; As there is nothing between here and $FFFA, we can just hard code this in place. + +iobase: + ldy #$DC + ldx #$00 + rts + diff --git a/c64/kernal/listen.s b/c64/kernal/listen.s index 4fc90f42..dd240070 100644 --- a/c64/kernal/listen.s +++ b/c64/kernal/listen.s @@ -1,3 +1,30 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 285 +;; - [CM64] Compute's Mapping the Commodore 64 - page 223 +;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc +;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + + listen: - rts + + ;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer + jsr iec_tx_flush + + ;; Check whether device number is correct + jsr iec_check_devnum + bcc + + jmp kernalerror_DEVICE_NOT_FOUND +* + ;; Encode and execute the command + ora #$20 + + jmp common_talk_listen + + + diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 4a2ca7c8..e845b546 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -1,7 +1,15 @@ - ; Function defined on pp272-273 of C64 Programmers Reference Guide - ;; IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - ;; Definition of function from Compute's Mapping the 64 p231 +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 286 +;; - [CM64] Compute's Mapping the Commodore 64 - page 231 +;; - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + + ;; Expects that SETLFS and SETNAM are called before hand. ;; $YYXX = load address. ;; (ignored if SETLFS channel = 1, i.e., like ,8,1) @@ -9,212 +17,127 @@ ;; On exit, $YYXX is the highest address into which data ;; will have been placed. - ;; Searching through Compute's Mapping the 64, we find the following - ;; things are used: - ;; $93 = kernal_load_or_verify_flag - ;; $AC = current pointer for loading/verifying - ;; $C1 = similar to the above. + ;; XXX honor MSGFLG bit 6 + ;; XXX add VERIFY support + load: ;; Are we loading or verifying? - sta kernal_load_or_verify_flag + sta VERCK ;; Store start address of LOAD - stx load_save_start_ptr+0 - sty load_save_start_ptr+1 + stx STAL+0 + sty STAL+1 + + ;; Reset status + jsr kernalstatus_reset ;; We need our helpers to get to filenames under ROMs or IO area jsr install_ram_routines - - ;; Disable IRQs, since timing matters! - SEI - ;; Display SEARCHING FOR - jsr printf - .byte "SEARCHING FOR ",0 + ;; Allow platform-specific routine to takeover the flow + `TARGET_HOOK_LOAD - ldy #$00 -print_filename_loop: - cpy current_filename_length - beq + - ldx #$033C - STA cassette_buffer_ptr+1 + sta cassette_buffer_ptr+1 ; set screen address to $0400 ; https://www.c64-wiki.com/wiki/Screen_RAM ; Since we are setting $D018, we also make sure we are using the ; ROM character set (C64 Programmer's Reference Guide p322) - LDA #$14 - STA $D018 + lda #$14 + sta VIC_YMCSB ; Make sure we have the correct VIC-II memory bank for the screen to really be at $0400 ; and not $4400, $8400 or $C400 ; https://www.c64-wiki.com/wiki/VIC_bank#Selecting_VIC_banks - LDA $DD02 - ORA #$03 - STA $DD02 - LDA $DD00 - ORA #$03 - STA $DD00 + lda CIA2_DDRA + ora #$03 + sta CIA2_DDRA + lda CIA2_PRA + ora #$03 + sta CIA2_PRA ;; Set screen address pointer ("Compute's Mapping the 64" p238) ;; This is obvious boiler plate containing no creative input, but to avoid ;; unnecessarily similarity to the C64 KERNAL, we use X instead of A to do this, ;; and several following - LDX #>$0400 - STX HIBASE + ldx #>$0400 + stx HIBASE ;; Work out RAM size and put in MEMSTR and MEMSIZ ;; "Compute's Mapping the 64", p54 diff --git a/c64/kernal/rdtim.s b/c64/kernal/rdtim.s index 89e78575..a9e40a16 100644 --- a/c64/kernal/rdtim.s +++ b/c64/kernal/rdtim.s @@ -1,3 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 291 +;; - [CM64] Compute's Mapping the Commodore 64 - page 232 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + rdtim: rts diff --git a/c64/kernal/readst.s b/c64/kernal/readst.s index 28139f1b..b3fbaa53 100644 --- a/c64/kernal/readst.s +++ b/c64/kernal/readst.s @@ -1,3 +1,30 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 292 +;; - [CM64] Compute's Mapping the Commodore 64 - page 239 +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + readst: + + ;; Check the current device number + + lda current_device_number + cmp #$02 + bne + + + ;; This is RS-232 device - according to 'Compute's Mapping the Commodore 64' page 239 + ;; it reads status from RSSTAT + lda RSSTAT + rts +* + ;; According to 'Compute's Mapping the Commodore 64' page 239, it usually retrieves + ;; status from IOSTATUS + + ;; XXX is it always the case if device is not RS-232 ? + + lda IOSTATUS rts diff --git a/c64/kernal/restor.s b/c64/kernal/restor.s deleted file mode 100644 index 0844288b..00000000 --- a/c64/kernal/restor.s +++ /dev/null @@ -1,3 +0,0 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide -restor: - rts diff --git a/c64/kernal/save.s b/c64/kernal/save.s index e8730e78..e98d030f 100644 --- a/c64/kernal/save.s +++ b/c64/kernal/save.s @@ -1,3 +1,13 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 293/294 +;; - [CM64] Compute's Mapping the Commodore 64 - page 231/232 +;; - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + save: rts diff --git a/c64/kernal/scan_keyboard.s b/c64/kernal/scan_keyboard.s index 61851c3f..8b9de00f 100644 --- a/c64/kernal/scan_keyboard.s +++ b/c64/kernal/scan_keyboard.s @@ -1,9 +1,19 @@ - ;; Scan the keyboard.. - ;; Here we don't use the horrible buggy original routine, - ;; not just because of copyright. Instead, we use the - ;; nice one with joystick interference removal and - ;; key roll-over support from - ;; http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 295 +;; - [CM64] Compute's Mapping the Commodore 64 - page 220 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + +;; Scan the keyboard.. +;; Here we don't use the horrible buggy original routine, +;; not just because of copyright. Instead, we use the +;; nice one with joystick interference removal and +;; key roll-over support from +;; http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way ;; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;; Keyboard IO Routine @@ -324,7 +334,7 @@ next_row: ;; so that RUN/STOP etc can be checked easily ;; (Compute's Mapping the 64, p27) lda ScanResult+0 - sta BUCKYSTATUS + sta STKEY ;; Store de-bounce data for bucky keys ;; (Compute's Mapping the 64, p58-59) diff --git a/c64/kernal/screen.s b/c64/kernal/screen.s new file mode 100644 index 00000000..b2e793fc --- /dev/null +++ b/c64/kernal/screen.s @@ -0,0 +1,19 @@ + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 295 +;; - [CM64] Compute's Mapping the Commodore 64 - page 215 +;; +;; CPU registers that has to be preserved (see [RG64]): .A +;; + +screen: + + ;; There are only 2 sane ways to implement this routine, + ;; I hope this one is different than what Commodore picked :) + + ldy #25 ; 25 columns + ldx #40 ; 40 rows + + rts diff --git a/c64/kernal/second.s b/c64/kernal/second.s index 65eb7f88..d130cfc5 100644 --- a/c64/kernal/second.s +++ b/c64/kernal/second.s @@ -1,3 +1,25 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 296 +;; - [CM64] Compute's Mapping the Commodore 64 - page 223/224 +;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + + second: - rts + + ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), + ;; allowed channels are 0-15; report error if out of range + cmp #$10 + bcc + + jmp kernalerror_DEVICE_NOT_FOUND ; XXX find a better error message for wrong channel (create new one?) +* + ora #$60 + + jmp common_open_close_unlsn_second + + diff --git a/c64/kernal/setfls.s b/c64/kernal/setfls.s new file mode 100644 index 00000000..ce6892a8 --- /dev/null +++ b/c64/kernal/setfls.s @@ -0,0 +1,20 @@ + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 297 +;; - [CM64] Compute's Mapping the Commodore 64 - page 238 +;; +;; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y +;; + +setfls: + + ;; There are 6 sane ways to implement this routine, + ;; I hope this one won't cause similarity to CBM code + + sta current_logical_filenum + sty current_secondary_address + stx current_device_number + + rts diff --git a/c64/kernal/setlfs.s b/c64/kernal/setlfs.s deleted file mode 100644 index 742ef38f..00000000 --- a/c64/kernal/setlfs.s +++ /dev/null @@ -1,3 +0,0 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide -setlfs: - rts diff --git a/c64/kernal/setmsg.s b/c64/kernal/setmsg.s index eb79d7f5..fc20350e 100644 --- a/c64/kernal/setmsg.s +++ b/c64/kernal/setmsg.s @@ -1,3 +1,13 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 298 +;; - [CM64] Compute's Mapping the Commodore 64 - page 239 +;; +;; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y +;; + setmsg: + sta MSGFLG rts diff --git a/c64/kernal/setnam.s b/c64/kernal/setnam.s index 8c2d0b86..0cbead31 100644 --- a/c64/kernal/setnam.s +++ b/c64/kernal/setnam.s @@ -1,3 +1,20 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 298/299 +;; - [CM64] Compute's Mapping the Commodore 64 - page 238 +;; +;; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y +;; + setnam: + + ;; There are 6 sane ways to implement this routine, + ;; I hope this one won't cause similarity to CBM code + + sta FNLEN + sty FNADDR + 1 + stx FNADDR + 0 + rts diff --git a/c64/kernal/settim.s b/c64/kernal/settim.s index bfc95254..804538c1 100644 --- a/c64/kernal/settim.s +++ b/c64/kernal/settim.s @@ -1,3 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 299/300 +;; - [CM64] Compute's Mapping the Commodore 64 - page 232 +;; +;; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y +;; + settim: rts diff --git a/c64/kernal/settmo.s b/c64/kernal/settmo.s index ffd76b69..273fbf43 100644 --- a/c64/kernal/settmo.s +++ b/c64/kernal/settmo.s @@ -1,3 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 300 +;; - [CM64] Compute's Mapping the Commodore 64 - page 239 +;; +;; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y +;; + settmo: rts diff --git a/c64/kernal/stop.s b/c64/kernal/stop.s index 2f8e82e2..980bd9bf 100644 --- a/c64/kernal/stop.s +++ b/c64/kernal/stop.s @@ -1,17 +1,26 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 301 +;; - [CM64] Compute's Mapping the Commodore 64 - page 232 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; + stop: - ;; Bit 7 of BUCKYSTATUS contains the state of the STOP key + ;; Bit 7 of STKEY contains the state of the STOP key ;; (Compute's Mapping the 64, p27) ;; BASIC checks carry flag to indicate STOP or not - lda BUCKYSTATUS + lda STKEY and #$80 beq stop_pressed - ;; By trial and error, we know that Z + C = BREAK + ;; By trial and error, we know that Z + C = BREAK ;; and that neither should be set otherwise lda #$ff - clc + clc rts stop_pressed: diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index 48a341d6..16440aa8 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -1,3 +1,32 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 301/302 +;; - [CM64] Compute's Mapping the Commodore 64 - page 223 +;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc +;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + + talk: - rts + + ;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer + jsr iec_tx_flush + + ;; Check whether device number is correct + jsr iec_check_devnum + bcc + + jmp kernalerror_DEVICE_NOT_FOUND +* + ;; Encode and execute the command + ora #$40 + +common_talk_listen: ; common part of TALK and LISTEN + + sta IEC_TMP2 + jmp iec_tx_command + + diff --git a/c64/kernal/tksa.s b/c64/kernal/tksa.s index 4b599d45..be048d62 100644 --- a/c64/kernal/tksa.s +++ b/c64/kernal/tksa.s @@ -1,3 +1,26 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 302 +;; - [CM64] Compute's Mapping the Commodore 64 - page 224 +;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + + tksa: - rts + + ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), + ;; allowed channels are 0-15; report error if out of range + cmp #$10 + bcc + + jmp kernalerror_DEVICE_NOT_FOUND ; XXX find a better error message for wrong channel (create new one?) +* + ora #$F0 + + jmp common_untlk_tksa + + + diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index 31a35a40..0298c215 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -1,3 +1,25 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 303 +;; - [CM64] Compute's Mapping the Commodore 64 - page 224 +;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc +;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + + unlsn: - rts + + ;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer + jsr iec_tx_flush + + ;; Buffer empty, send the command + lda #$3F + + jmp common_open_close_unlsn_second + + + diff --git a/c64/kernal/untlk.s b/c64/kernal/untlk.s index 30a018a4..e8054e0d 100644 --- a/c64/kernal/untlk.s +++ b/c64/kernal/untlk.s @@ -1,3 +1,33 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 304 +;; - [CM64] Compute's Mapping the Commodore 64 - page 224 +;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc +;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + + untlk: + + ;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer + jsr iec_tx_flush + + ;; Buffer empty, send the command + lda #$5F + +common_untlk_tksa: ; common part of UNTLK and TKSA + + sta IEC_TMP2 + jsr iec_tx_command + bcs + ; branch if error + ;; XXX - for TKSA, is it really the right place to do a turnaround? I've got some doubts + ;; (it forces us to send the TKSA command 'manually' sometimes), but + ;; Luigi Di Fraia (https://luigidifraia.wordpress.com/2017/06/27/codebase64-on-the-kernal-behaviour/) + ;; claims TKSA Kernal routine actually does the turnaround + jmp iec_turnaround_to_listen +* rts diff --git a/c64/kernal/update_jiffy_clock.s b/c64/kernal/update_jiffy_clock.s index 4d5a6dbb..7e05883a 100644 --- a/c64/kernal/update_jiffy_clock.s +++ b/c64/kernal/update_jiffy_clock.s @@ -1,2 +1,12 @@ + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 303 +;; - [CM64] Compute's Mapping the Commodore 64 - page 232 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; + update_jiffy_clock: rts diff --git a/c64/kernal/vector.s b/c64/kernal/vector.s index 8b296793..5fb49426 100644 --- a/c64/kernal/vector.s +++ b/c64/kernal/vector.s @@ -1,3 +1,88 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 293 (RESTOR), 304 (VECTOR) +;; - [CM64] Compute's Mapping the Commodore 64 - page 237 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + +restor: + + clc ;; clear carry - for writing to system table + ldx #vector_defaults + + ;; FALLTHROUGH + vector: + +.scope + + ;; Temporary storage location + .alias _caller_arr_ptr CMP0 + + ;; According to 'Compute's Mapping the Commodore 64' page 237, + ;; the CBM implementation does not disable IRQs - yet, the + ;; 'C64 Programmers Reference Guide' does not contain such + ;; warning and does not mention any preparations needed, so... + ;; better safe than sorry, disable the IRQ for the duration + ;; of vector manipulation + php + cli + + ;; Prepare the user data pointer + stx _caller_arr_ptr + 0 + sty _caller_arr_ptr + 1 + + ;; Select routine variant - store or restore vectors + ldy #$1F + bcc vector_restore + + ;; FALLTHROUGH + +vector_store: +* + lda CINV, y + sta (_caller_arr_ptr), y + dey + bpl - + + ;; Restore status register (IRQ) before return + plp rts + +vector_restore: +* + lda (_caller_arr_ptr), y + sta CINV, y + dey + bpl - + + ;; Restore status register (IRQ) before return + plp + rts + +.scend + + ;; XXX below we have quite a lot of data... should we decouple them? + +vector_defaults: + .word default_irq_handler ;; CINV + .word $0000 ;; CBINV XXX implement this + .word $0000 ;; NMINV XXX implement this + + .word open ;; IOPEN + .word close ;; ICLOSE + .word chkin ;; ICHKIN + .word ckout ;; ICKOUT + .word clrchn ;; ICLRCH + .word chrin ;; IBASIN + .word chrout ;; IBSOUT + .word stop ;; ISTOP + .word getin ;; IGETIN + .word clall ;; ICLALL + .word $0000 ;; USRCMD XXX implement this + .word load ;; ILOAD + .word save ;; ISAVE diff --git a/c64/kernal/wait1ms.s b/c64/kernal/wait1ms.s deleted file mode 100644 index c2a24d44..00000000 --- a/c64/kernal/wait1ms.s +++ /dev/null @@ -1,14 +0,0 @@ - ;; 16 rasters = 16 x 63 cycles = ~1ms - ;; (Probably 2 will be bad lines, so we will over-estimate the delay a bit) - -wait1ms: - ldx #16 - lda $d012 -* - cmp $d012 - beq - - lda $d012 - dex - bne - - rts - diff --git a/strings/000000A9 b/strings/000000A9 new file mode 100644 index 00000000..88f49cb5 --- /dev/null +++ b/strings/000000A9 @@ -0,0 +1 @@ +A string of empty bytes followed by half an instruction. Not copyrightable diff --git a/strings/00003C b/strings/00003C new file mode 100644 index 00000000..0ae5a8af --- /dev/null +++ b/strings/00003C @@ -0,0 +1,3 @@ +$3C byte after some leading $00s + +Not creative. Not copyrightable. diff --git a/strings/0000A9 b/strings/0000A9 new file mode 100644 index 00000000..88f49cb5 --- /dev/null +++ b/strings/0000A9 @@ -0,0 +1 @@ +A string of empty bytes followed by half an instruction. Not copyrightable diff --git a/strings/0002A2 b/strings/0002A2 new file mode 100644 index 00000000..ef2431f1 --- /dev/null +++ b/strings/0002A2 @@ -0,0 +1,3 @@ +address $0200 + LDX# (argument does not match) + +Not even a full instruction - not copyrightable. diff --git a/strings/002090FF b/strings/002090FF new file mode 100644 index 00000000..4cb0adc7 --- /dev/null +++ b/strings/002090FF @@ -0,0 +1,3 @@ +$00 + JSR $FF90 (SETMSG) + +Instruction (jump to an official, docummented location) and some part. Not copyrightable. diff --git a/strings/006020 b/strings/006020 new file mode 100644 index 00000000..f5f52edc --- /dev/null +++ b/strings/006020 @@ -0,0 +1,3 @@ +$00 + RTS (or instruction part) + JSR xxxx + +Single byte instruction with two halfs, or half of the instruction + half of other. Not copyrightable. diff --git a/strings/00990001 b/strings/00990001 new file mode 100644 index 00000000..08241cc8 --- /dev/null +++ b/strings/00990001 @@ -0,0 +1,3 @@ +$00 + STA $0100, Y + +Single instruction and some part. Not copyrightable. diff --git a/strings/00990002 b/strings/00990002 new file mode 100644 index 00000000..8f8f4711 --- /dev/null +++ b/strings/00990002 @@ -0,0 +1,3 @@ +$00 + STA $0200, Y + +Single instruction and some part. Not copyrightable. diff --git a/strings/00DD60AD00DD09 b/strings/00DD60AD00DD09 new file mode 100644 index 00000000..64861d09 --- /dev/null +++ b/strings/00DD60AD00DD09 @@ -0,0 +1,5 @@ +address $DD00 (from previous instruction) + RTS (end of the routine, new one starting) + LDA $DD00 + ORA # (argument does not match) + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/0220DA b/strings/0220DA new file mode 100644 index 00000000..ab518d6c --- /dev/null +++ b/strings/0220DA @@ -0,0 +1,3 @@ +fragment + JSR + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/026020 b/strings/026020 new file mode 100644 index 00000000..e0fe475c --- /dev/null +++ b/strings/026020 @@ -0,0 +1,3 @@ +byte $02 + RTS + JSR (address does not match) + +One instruction + some fragments. Not copyrightable. diff --git a/strings/02B96302 b/strings/02B96302 new file mode 100644 index 00000000..cb17a83e --- /dev/null +++ b/strings/02B96302 @@ -0,0 +1,4 @@ +$02 + LDA $0263, X (FAT table access) + +Single instruction (indexed access to a documented table) + some part. Not copyrightable. + diff --git a/strings/02B96D02 b/strings/02B96D02 new file mode 100644 index 00000000..8ceebc31 --- /dev/null +++ b/strings/02B96D02 @@ -0,0 +1,3 @@ +$02 + LDA $026D, X (SAT table access) + +Single instruction (indexed access to a documented table) + some part. Not copyrightable. diff --git a/strings/032060 b/strings/032060 new file mode 100644 index 00000000..ab518d6c --- /dev/null +++ b/strings/032060 @@ -0,0 +1,3 @@ +fragment + JSR + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C09 b/strings/034C09 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C09 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C33 b/strings/034C33 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C33 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C37 b/strings/034C37 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C37 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C48 b/strings/034C48 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C48 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C73 b/strings/034C73 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C73 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C83 b/strings/034C83 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C83 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C9E b/strings/034C9E new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C9E @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034CFB b/strings/034CFB new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034CFB @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034CFC b/strings/034CFC new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034CFC @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/036C1C036C b/strings/036C1C036C new file mode 100644 index 00000000..ebb399e0 --- /dev/null +++ b/strings/036C1C036C @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($031C) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C1E036C b/strings/036C1E036C new file mode 100644 index 00000000..e6f9e218 --- /dev/null +++ b/strings/036C1E036C @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($031E) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C20036C b/strings/036C20036C new file mode 100644 index 00000000..ab5ed572 --- /dev/null +++ b/strings/036C20036C @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($0320) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C22036C b/strings/036C22036C new file mode 100644 index 00000000..f05b4581 --- /dev/null +++ b/strings/036C22036C @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($0322) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C24036C b/strings/036C24036C new file mode 100644 index 00000000..4b11242c --- /dev/null +++ b/strings/036C24036C @@ -0,0 +1,3 @@ +03 (most likely adddress higher byte) + JMP ($0324) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C2603 b/strings/036C2603 new file mode 100644 index 00000000..3271b1af --- /dev/null +++ b/strings/036C2603 @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($0326) (via public, documented vector) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C2A036C b/strings/036C2A036C new file mode 100644 index 00000000..552a4b08 --- /dev/null +++ b/strings/036C2A036C @@ -0,0 +1,4 @@ +$03 (most likely adddress higher byte) + JMP ($032A) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. + diff --git a/strings/036C2C03 b/strings/036C2C03 new file mode 100644 index 00000000..3bf23438 --- /dev/null +++ b/strings/036C2C03 @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($032C) (via public, documented vector) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/090185 b/strings/090185 new file mode 100644 index 00000000..46ebeb00 --- /dev/null +++ b/strings/090185 @@ -0,0 +1,3 @@ +ORA #$01 (or part of another instruction) + STA (address does not match) + +At most one instruction and a half - not copyrightable. diff --git a/strings/093020 b/strings/093020 new file mode 100644 index 00000000..e020853f --- /dev/null +++ b/strings/093020 @@ -0,0 +1,4 @@ +ORA #$30 + JSR without address +alternatively a value (part of the instruction) followed by a conditional jump + +Instruction and a half. Not copyrightable. diff --git a/strings/098085 b/strings/098085 new file mode 100644 index 00000000..00d602b9 --- /dev/null +++ b/strings/098085 @@ -0,0 +1,3 @@ +ORA #$80 (or part of another instruction) + STA (address does not match) + +At most one instruction and a half - not copyrightable. diff --git a/strings/0A90034C b/strings/0A90034C new file mode 100644 index 00000000..e9598dd7 --- /dev/null +++ b/strings/0A90034C @@ -0,0 +1,4 @@ +$0A + BCC addr + JMP (address does not match) + +Some part + BCC / JMP combo (typical construction on a 6502, where there is no conditional far jump), even the address does not match. Not copyrightable. + diff --git a/strings/0D4C4F4144494E b/strings/0D4C4F4144494E new file mode 100644 index 00000000..5eae602c --- /dev/null +++ b/strings/0D4C4F4144494E @@ -0,0 +1,5 @@ + / last 'jsr printf' instruction byte (pure coincidence) + "LOADIN" PETSCII string + +Not copyrightable. + + diff --git a/strings/0D534541524348494E47 b/strings/0D534541524348494E47 new file mode 100644 index 00000000..240ea5a8 --- /dev/null +++ b/strings/0D534541524348494E47 @@ -0,0 +1,3 @@ + / last 'jsr printf' instruction byte (pure coincidence) + "SEARCHING" PETSCII string + +Not copyrightable. diff --git a/strings/0D564552494659494E b/strings/0D564552494659494E new file mode 100644 index 00000000..38121d93 --- /dev/null +++ b/strings/0D564552494659494E @@ -0,0 +1,3 @@ + / last 'jsr printf' instruction byte (pure coincidence) + "VERIFYIN" PETSCII string + +Not copyrightable. diff --git a/strings/108D00DD b/strings/108D00DD new file mode 100644 index 00000000..b0d7830a --- /dev/null +++ b/strings/108D00DD @@ -0,0 +1,3 @@ +part of previous instruction + STA $DD00 + +Instruction (storing register in a well-known I/O register) preceeded by a half of another one - not copyrightable. diff --git a/strings/18607820 b/strings/18607820 new file mode 100644 index 00000000..2a01aa66 --- /dev/null +++ b/strings/18607820 @@ -0,0 +1,3 @@ +CLC + RTS (end of subroutine, another one starts) + SEI + JSR (address does not match) + +Nothing creative here. First 2 instruction, which is are a common way to end a subroutine and indicate a success. Afterwards a start of new subroutine, which starts with disabling interrupts. Not copyrightable. diff --git a/strings/1860A59D10 b/strings/1860A59D10 new file mode 100644 index 00000000..e7a89a08 --- /dev/null +++ b/strings/1860A59D10 @@ -0,0 +1,3 @@ +CLC + RTS + LDA $9D + BPL + +Nothing creative here. First 2 instruction, which is are a common way to end a subroutine and indicate a success. Afterwards a start of new subroutine, which starts by checking a documented zeropage variable. Not copyrightable. diff --git a/strings/2046524F4D20 b/strings/2046524F4D20 new file mode 100644 index 00000000..d2c609c4 --- /dev/null +++ b/strings/2046524F4D20 @@ -0,0 +1,3 @@ + + FROM + - PETSCII string + +Not copyrightable. diff --git a/strings/204F5045 b/strings/204F5045 new file mode 100644 index 00000000..bd9f84dd --- /dev/null +++ b/strings/204F5045 @@ -0,0 +1,3 @@ + + OPE - PETSCII string + +Syllable starting a word is definitely not copyrightable. diff --git a/strings/208EA6A9 b/strings/208EA6A9 new file mode 100644 index 00000000..809ed04c --- /dev/null +++ b/strings/208EA6A9 @@ -0,0 +1,3 @@ +JSR $A68E + LDA # (value does not match) + +Instruction and a half. Not copyrightable. diff --git a/strings/20BDFF20 b/strings/20BDFF20 new file mode 100644 index 00000000..77b74280 --- /dev/null +++ b/strings/20BDFF20 @@ -0,0 +1,3 @@ +JSR $FFBD (SETNAM) + JSR (address does not match) + +Instruction (jump to official, documented location) + one byte of another one. Not copyrightable. diff --git a/strings/29DF8D00DD b/strings/29DF8D00DD new file mode 100644 index 00000000..b159a7ac --- /dev/null +++ b/strings/29DF8D00DD @@ -0,0 +1,3 @@ +AND #$DF + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. Here we just have a trivial bit manipulation - not creeative, not copyrightable. diff --git a/strings/29DF8D00DD60AD00DD b/strings/29DF8D00DD60AD00DD new file mode 100644 index 00000000..8701bf28 --- /dev/null +++ b/strings/29DF8D00DD60AD00DD @@ -0,0 +1,5 @@ +AND #$DF + STA $DD00 + RTS + LDA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/29EF8D b/strings/29EF8D new file mode 100644 index 00000000..8e99ad35 --- /dev/null +++ b/strings/29EF8D @@ -0,0 +1,3 @@ +AND #$EF + STA without address + +Clear a bit + a half of other instruction - not copyrightable. diff --git a/strings/29EF8D00DD60 b/strings/29EF8D00DD60 new file mode 100644 index 00000000..3a45bb8d --- /dev/null +++ b/strings/29EF8D00DD60 @@ -0,0 +1,5 @@ +AND #$EF + STA $DD00 + RTS + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/29EF8D00DD60AD00DD09 b/strings/29EF8D00DD60AD00DD09 new file mode 100644 index 00000000..6fb7f246 --- /dev/null +++ b/strings/29EF8D00DD60AD00DD09 @@ -0,0 +1,5 @@ +AND #$EF + STA $DD00 + RTS + LDA $DD00 + ORA# + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/29F78D00DD b/strings/29F78D00DD new file mode 100644 index 00000000..58a79f31 --- /dev/null +++ b/strings/29F78D00DD @@ -0,0 +1,3 @@ +AND #$F7 + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. Here we just have a trivial bit manipulation - not creeative, not copyrightable. diff --git a/strings/29F78D00DD60 b/strings/29F78D00DD60 new file mode 100644 index 00000000..bada463b --- /dev/null +++ b/strings/29F78D00DD60 @@ -0,0 +1,5 @@ +(beginning of the routine not matching) + AND #$F7 + STA $DD00 + RTS + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/386020 b/strings/386020 new file mode 100644 index 00000000..3693f9aa --- /dev/null +++ b/strings/386020 @@ -0,0 +1,3 @@ +SEC + RTS (end of subroutine, new one starts from the next byte) + JSR (address not matching) + +One subroutine ends with carry clear, second starts with JSR, but to a different address - accidental similarity, code most likely performs something different in both cases. diff --git a/strings/3ED0034C37 b/strings/3ED0034C37 new file mode 100644 index 00000000..3850ac4b --- /dev/null +++ b/strings/3ED0034C37 @@ -0,0 +1,3 @@ +$3E + BNE addr + JMP $xx37 + +Some part + BNE / JMP combo (typical construction on a 6502, where there is no conditional far jump), even the address does not fully match. Not copyrightable. diff --git a/strings/4CBDFFA9 b/strings/4CBDFFA9 new file mode 100644 index 00000000..4caa0103 --- /dev/null +++ b/strings/4CBDFFA9 @@ -0,0 +1,3 @@ +JMP $FFBD (SETNAM) + LDA #$ (value does not match) + +Instruction (jump to an official, documented location) + opcode of another one. Not copyrightable. diff --git a/strings/4F5045 b/strings/4F5045 new file mode 100644 index 00000000..b7ca79b9 --- /dev/null +++ b/strings/4F5045 @@ -0,0 +1,3 @@ +ORE - PETSCII string + +Not copyrightable. diff --git a/strings/524F4D b/strings/524F4D new file mode 100644 index 00000000..b4fe5d3c --- /dev/null +++ b/strings/524F4D @@ -0,0 +1,3 @@ +ROM - PETSCII string + +Not copyrightable. diff --git a/strings/564552 b/strings/564552 new file mode 100644 index 00000000..fd01de08 --- /dev/null +++ b/strings/564552 @@ -0,0 +1,3 @@ +VER - PETSCII string + +Not copyrightable. diff --git a/strings/5645524946 b/strings/5645524946 new file mode 100644 index 00000000..c9039b3d --- /dev/null +++ b/strings/5645524946 @@ -0,0 +1,3 @@ +VERIF - PETSCII string, part of 'VERIFY' + +Not copyrightable. diff --git a/strings/5902D0F8 b/strings/5902D0F8 new file mode 100644 index 00000000..8b870d15 --- /dev/null +++ b/strings/5902D0F8 @@ -0,0 +1,3 @@ +$0259 (LAT table address) + BNE $F8 (few bytes back) + +Instruction + some parts (revealing that this is some manipulation on documented Kernal table). Not copyrightable. diff --git a/strings/6020A0E5A900 b/strings/6020A0E5A900 new file mode 100644 index 00000000..e69de29b diff --git a/strings/6031EA b/strings/6031EA new file mode 100644 index 00000000..e3398d10 --- /dev/null +++ b/strings/6031EA @@ -0,0 +1,3 @@ +RTS (ending a subroutine, new one starts) + conditional jump + +Nothing creative here - not copyrightable. diff --git a/strings/60A59D10 b/strings/60A59D10 new file mode 100644 index 00000000..bcc0416b --- /dev/null +++ b/strings/60A59D10 @@ -0,0 +1,3 @@ +RTS (belonging to previopus subroutine) + LDA $9D (MSGFLG) + BPL + +The only similarity here is, that the subroutine starts by checking a documented variable. Not copyrightable. diff --git a/strings/60A59D10FB b/strings/60A59D10FB new file mode 100644 index 00000000..3dc7afb7 --- /dev/null +++ b/strings/60A59D10FB @@ -0,0 +1,3 @@ +RTS + LDA $9D (MSGFLG) + BPL $FB + +Check documented variable value, utilize nearest RTS (a very common optimization, mentionedd for example here just few days ago: https://gitlab.com/mkslack/Area6510/commit/9bdc624574c76661db302cdbf85559fb0e9e309a) to quit subroutine if the highest bit is not 1 (the easiest way to distinguish 2 documented values of the MSGFLG: $00 and $80). Nothing creative here - not copyrightable. diff --git a/strings/60AD00DD09 b/strings/60AD00DD09 new file mode 100644 index 00000000..47b2fff5 --- /dev/null +++ b/strings/60AD00DD09 @@ -0,0 +1,4 @@ +fragment (or, most likely, RTS belonging to previous routine) + LDA $DD00 + ORA without matching argument + +$DD00 is a register for VIC bank switching and IEC access, using it typically requires bit manipulation. +Nothing creative here - not copyrightable. diff --git a/strings/60AD00DD0910 b/strings/60AD00DD0910 new file mode 100644 index 00000000..465ca2c5 --- /dev/null +++ b/strings/60AD00DD0910 @@ -0,0 +1,5 @@ +RTS (end of the routine, new one starting) + LDA $DD00 + ORA #$10 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/60AD00DD09108D00DD b/strings/60AD00DD09108D00DD new file mode 100644 index 00000000..d2e3ec90 --- /dev/null +++ b/strings/60AD00DD09108D00DD @@ -0,0 +1,5 @@ +RTS (end of the routine, new one starting) + LDA $DD00 + ORA #$10 + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/630285 b/strings/630285 new file mode 100644 index 00000000..1eeb6590 --- /dev/null +++ b/strings/630285 @@ -0,0 +1,3 @@ +address $0263 + STA (address does not match) + +Not even a full instruction. Not copyrightable. diff --git a/strings/686020 b/strings/686020 new file mode 100644 index 00000000..a2a6d383 --- /dev/null +++ b/strings/686020 @@ -0,0 +1,3 @@ +PLA + RTS (end of subroutine, another one starting) + JSR (address does not match) + +End of a routine preserving .A register + part of instruction belonging to another subroutine. Not copyrightable. diff --git a/strings/6C1A036C b/strings/6C1A036C new file mode 100644 index 00000000..b2044ce0 --- /dev/null +++ b/strings/6C1A036C @@ -0,0 +1,3 @@ +JMP ($031A) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/7AA47B b/strings/7AA47B new file mode 100644 index 00000000..ea849b8b --- /dev/null +++ b/strings/7AA47B @@ -0,0 +1,3 @@ +Access to $7A (but instruction opcode does not match) + LDY $7B ($7A-$7B is a documented vector) + +Instruction and a half, clearly a zeropage vector access - not copyrightable. diff --git a/strings/7AD0034C b/strings/7AD0034C new file mode 100644 index 00000000..48d269ae --- /dev/null +++ b/strings/7AD0034C @@ -0,0 +1,3 @@ +$7A + BNE with matching address + JMP + +Single instruction + some matching parts of two others. Not copyrightable. diff --git a/strings/9914038810 b/strings/9914038810 new file mode 100644 index 00000000..83b907e4 --- /dev/null +++ b/strings/9914038810 @@ -0,0 +1,3 @@ +STA $0314, Y + DEY + BPL addr + +Part of memory copy routine to set/initialize vector table in RAM (a documented one). There is a limited amount of sane ways to implement this code - ours is clearly different from the original, or there would be more similarities. Such a small fragment of rather common routine is definitely not copyrightable. diff --git a/strings/A000B17AD0 b/strings/A000B17AD0 new file mode 100644 index 00000000..bece149c --- /dev/null +++ b/strings/A000B17AD0 @@ -0,0 +1,3 @@ +LDY #$00 + LDA ($7A), Y + BNE (offset does not match) + +Small part of a loop processing data pointed by TEXTPTR - not creative, not copyrightable. diff --git a/strings/A59AC903 b/strings/A59AC903 new file mode 100644 index 00000000..09302357 --- /dev/null +++ b/strings/A59AC903 @@ -0,0 +1,3 @@ +LDA $9A (DFLTO) + CMP #$03 + +Check whether the default output device is screen - not even fully matching the original ROM (different branch instruction used) - might be one onstruction on other architecture. Not copyrightable. diff --git a/strings/A5BAC902D0 b/strings/A5BAC902D0 new file mode 100644 index 00000000..95880faa --- /dev/null +++ b/strings/A5BAC902D0 @@ -0,0 +1,3 @@ +LDA $BA + CMP #$02 + BNE (offset does not match) + +Check whether the current device number is 2 (RS-232). Not creative - not copyrightablee. diff --git a/strings/A67AA47B b/strings/A67AA47B new file mode 100644 index 00000000..4c546a62 --- /dev/null +++ b/strings/A67AA47B @@ -0,0 +1,5 @@ +LDX $7A + LDY $7B + +Loading TXTPTR value to X/Y registers, would be 1 instruction on any 16-bit CPU. Not creative - not copyrightable. + + diff --git a/strings/A90020BDFF b/strings/A90020BDFF new file mode 100644 index 00000000..3d2e939f --- /dev/null +++ b/strings/A90020BDFF @@ -0,0 +1,4 @@ +LDA #$00 + JSR $FFBD (SETNAM routine) + +Code to set the file name as empty ($FFBD is a standard, documented address). Trivial - not copyrightable. + diff --git a/strings/A90020BDFF20 b/strings/A90020BDFF20 new file mode 100644 index 00000000..52da1afa --- /dev/null +++ b/strings/A90020BDFF20 @@ -0,0 +1,3 @@ +LDA #$00 + JSR $FFBD (SETNAM routine) + JSR (address differs) + +Code to set the file name as empty ($FFBD is a standard, documented address), followed by jump to subroutine (but placed elsewere). Trivial - not copyrightable. diff --git a/strings/A9009900 b/strings/A9009900 new file mode 100644 index 00000000..3801d04d --- /dev/null +++ b/strings/A9009900 @@ -0,0 +1,3 @@ +LDA #$00 + STA xx00, Y + +Instruction and a half (probably a loop zeroing something - but something different in both cases). Not copyrightable. diff --git a/strings/AA208E b/strings/AA208E new file mode 100644 index 00000000..46ef467b --- /dev/null +++ b/strings/AA208E @@ -0,0 +1,3 @@ +TAX (or instruction fragment) + JSR + lower byte of jump address + +At most instruction and a half - not copyrightable. diff --git a/strings/B190034C b/strings/B190034C new file mode 100644 index 00000000..b4bf4caa --- /dev/null +++ b/strings/B190034C @@ -0,0 +1,3 @@ +LDA ($0390), Y + JMP (address does not match) + +Instruction and a half - not copyrightable. diff --git a/strings/B1B0034C b/strings/B1B0034C new file mode 100644 index 00000000..4df42d32 --- /dev/null +++ b/strings/B1B0034C @@ -0,0 +1,3 @@ +LDA ($03B0), Y + JMP (address does not match) + +Instruction and a half - not copyrightable. diff --git a/strings/BAA90085 b/strings/BAA90085 new file mode 100644 index 00000000..007ab7ac --- /dev/null +++ b/strings/BAA90085 @@ -0,0 +1,3 @@ +$BA + LDA #$00 + STA (address does not match) + +One full instruction (loading acumulator with 0) and some parts - not copyrightable. diff --git a/strings/BAFF20 b/strings/BAFF20 new file mode 100644 index 00000000..95fcfa02 --- /dev/null +++ b/strings/BAFF20 @@ -0,0 +1,3 @@ +address $FFBA (jump table position of SETLFS) + JSR without address + +Not even a full instruction - not copyrightable. diff --git a/strings/C8B17AF0 b/strings/C8B17AF0 new file mode 100644 index 00000000..f39a32bf --- /dev/null +++ b/strings/C8B17AF0 @@ -0,0 +1,3 @@ +INY + LDA ($7A),Y + BEQ (offset does not match) + +Small part of a loop processing data pointed by TEXTPTR - not creative, not copyrightable. diff --git a/strings/C8C4B7 b/strings/C8C4B7 new file mode 100644 index 00000000..c18389c8 --- /dev/null +++ b/strings/C8C4B7 @@ -0,0 +1,3 @@ +INY + CPY $B7 (FNLEN documented variable) + +Tiny part of the loop processing file name or IEC command. Not creative - not copyrightable. diff --git a/strings/D0034C37 b/strings/D0034C37 new file mode 100644 index 00000000..6fe14834 --- /dev/null +++ b/strings/D0034C37 @@ -0,0 +1,3 @@ +BNE $03 + JMP xx37 + +Instruction and a half - part of a common workaround for conditional jumps not reaching far. Not copyrightable. diff --git a/strings/DD09108D00DD b/strings/DD09108D00DD new file mode 100644 index 00000000..f263c197 --- /dev/null +++ b/strings/DD09108D00DD @@ -0,0 +1,5 @@ +$DD + ORA #$10 + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29DF8D00DD60AD00DD b/strings/DD29DF8D00DD60AD00DD new file mode 100644 index 00000000..9979799f --- /dev/null +++ b/strings/DD29DF8D00DD60AD00DD @@ -0,0 +1,5 @@ +$DD + AND #$DF + STA $DD00 + RTS (end of the routine, new one starting) + LDA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29DF8D00DD60AD00DD09208D00DD b/strings/DD29DF8D00DD60AD00DD09208D00DD new file mode 100644 index 00000000..fc3ddb19 --- /dev/null +++ b/strings/DD29DF8D00DD60AD00DD09208D00DD @@ -0,0 +1,5 @@ +$DD + AND #$DF + STA $DD00 + RTS (end of the routine, new one starting) + LDA $DD00 + ORA #$20 + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29EF8D00DD b/strings/DD29EF8D00DD new file mode 100644 index 00000000..6fcdcaaa --- /dev/null +++ b/strings/DD29EF8D00DD @@ -0,0 +1,5 @@ +$DD + AND #$EF + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29EF8D00DD60 b/strings/DD29EF8D00DD60 new file mode 100644 index 00000000..4ad51171 --- /dev/null +++ b/strings/DD29EF8D00DD60 @@ -0,0 +1,5 @@ +$DD + AND #$EF + STA $DD00 + RTS + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29EF8D00DD60AD00DD09 b/strings/DD29EF8D00DD60AD00DD09 new file mode 100644 index 00000000..903213d1 --- /dev/null +++ b/strings/DD29EF8D00DD60AD00DD09 @@ -0,0 +1,5 @@ +$DD + AND #$EF + STA $DD00 + RTS + LDA #$DD00 + ORA # (argument does not match) + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29F78D00DD60 b/strings/DD29F78D00DD60 new file mode 100644 index 00000000..20b06c7a --- /dev/null +++ b/strings/DD29F78D00DD60 @@ -0,0 +1,5 @@ +$DD + AND #$F7 + STA $DD00 + RTS + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD60AD00DD09208D00DD b/strings/DD60AD00DD09208D00DD new file mode 100644 index 00000000..f885c7da --- /dev/null +++ b/strings/DD60AD00DD09208D00DD @@ -0,0 +1,5 @@ +$DD + RTS (end of the routine, new one starting) + LDA $DD00 + ORA #$20 + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DF8D00DD b/strings/DF8D00DD new file mode 100644 index 00000000..a3426d59 --- /dev/null +++ b/strings/DF8D00DD @@ -0,0 +1,3 @@ +$EF + STA $DD00 + +Instruction (storing acumulator in a documented I/O register) and some part. Not copyrightable. diff --git a/strings/DF8D00DD60AD00DD b/strings/DF8D00DD60AD00DD new file mode 100644 index 00000000..63207a43 --- /dev/null +++ b/strings/DF8D00DD60AD00DD @@ -0,0 +1,5 @@ +$DF + STA $DD00 + RTS + LDA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/E5C91DD0 b/strings/E5C91DD0 new file mode 100644 index 00000000..18aee6b1 --- /dev/null +++ b/strings/E5C91DD0 @@ -0,0 +1,3 @@ +$E5 + CMP #$1D + BNE (offset does not match) + +Instruction + some parts. Not copyrightable. diff --git a/strings/EF8D00DD60AD00DD09 b/strings/EF8D00DD60AD00DD09 new file mode 100644 index 00000000..d8780b0e --- /dev/null +++ b/strings/EF8D00DD60AD00DD09 @@ -0,0 +1,5 @@ +$EF + STA $DD00 + RTS + LDA $DD00 + ORA # (value does not match) + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/F6A90085 b/strings/F6A90085 new file mode 100644 index 00000000..815dc515 --- /dev/null +++ b/strings/F6A90085 @@ -0,0 +1,3 @@ +$F6 + LDA #$00 + STA ... + +A part + instruction to clear the accumulator + opcode of another instruction. Not copyrightable. diff --git a/strings/F7206F b/strings/F7206F new file mode 100644 index 00000000..ab518d6c --- /dev/null +++ b/strings/F7206F @@ -0,0 +1,3 @@ +fragment + JSR + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/F78D00DD60 b/strings/F78D00DD60 new file mode 100644 index 00000000..f7b83ec1 --- /dev/null +++ b/strings/F78D00DD60 @@ -0,0 +1,5 @@ +$F7 + STA $DD00 + RTS + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions.