diff --git a/Makefile b/Makefile index 7e68ac85..a6a214d8 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ 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_KERNAL_COMMON = $(SRC_COMMON) $(wildcard c64/kernal/*.s c64/kernal/jumptable/*.s c64/kernal/iec/*.s c64/kernal/interrupts/*.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) @@ -23,6 +23,10 @@ TOOL_SIMILARITY = build/tools/similarity TOOLS_LIST = $(TOOL_COLLECT_DATA) $(TOOL_COMPRESS_TEXT) $(TOOL_PNGPREPARE) $(TOOL_PREPROCESS) $(TOOL_SIMILARITY) +# GIT commit + +GIT_COMMIT:= $(shell git log -1 --pretty='%h' | tr '[:lower:]' '[:upper:]') + # Rules - main .PHONY: all clean updatebin @@ -147,7 +151,7 @@ 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 + 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 diff --git a/STATUS.md b/STATUS.md index 286da229..83831a1f 100644 --- a/STATUS.md +++ b/STATUS.md @@ -6,6 +6,7 @@ Here are the features of the Open ROMs not found in the original ROMs from the 8 * 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 +* cold/warm start silences 4 SID chips - assumes addresses $D400, $D420, $D440, $D460 * 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 @@ -25,12 +26,12 @@ The following ROM features are currently missing: * 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 +* BRK handling; NMI/IRQ handling is incomplete 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 +* IEC support needs more work; alternative drive ROMs (JiffyDOS, DolphinDOS, etc) usually don't work with current implementation, SAVE / VERIFY are not implemented, etc. # API status @@ -70,10 +71,10 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | Address | Name | Status | Remarks | | --------- | :------- | :------: | :------------------------------------------------: | -| `$FF81` | `CINT` | PARTIAL | at least PAL/NTSC detection is missing | -| `$FF84` | `IOINIT` | PARTIAL | at least SID volume handling is missing | +| `$FF81` | `CINT` | DONE | | +| `$FF84` | `IOINIT` | PARTIAL | CIA initialization incomplete | | `$FF87` | `RAMTAS` | DONE | | -| `$FF8A` | `RESTOR` | PARTIAL | CBINV, NMINV, and USRCMD missing | +| `$FF8A` | `RESTOR` | DONE | | | `$FF8D` | `VECTOR` | DONE | | | `$FF90` | `SETMSG` | DONE | | | `$FF93` | `SECOND` | DONE | | @@ -81,7 +82,7 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | `$FF99` | `MEMTOP` | DONE | | | `$FF9C` | `MEMBOT` | DONE | | | `$FF9F` | `SCNKEY` | DONE | could be better integrated with ROM (aliases) | -| `$FFA2` | `SETTMO` | NOT DONE | | +| `$FFA2` | `SETTMO` | DONE | | | `$FFA5` | `ACPTR` | DONE | | | `$FFA8` | `CIOUT` | DONE | | | `$FFAB` | `UNTLK` | DONE | | @@ -92,20 +93,20 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | `$FFBA` | `SETFLS` | DONE | | | `$FFBD` | `SETNAM` | DONE | | | `$FFC0` | `OPEN` | DONE | | -| `$FFC3` | `CLOSE` | PARTIAL | most likely incompleete, @$ doesn't end properly | +| `$FFC3` | `CLOSE` | DONE | | | `$FFC6` | `CHKIN` | DONE | | | `$FFC9` | `CHKOUT` | PARTIAL | | | `$FFCC` | `CLRCHN` | DONE | | | `$FFCF` | `CHRIN` | PARTIAL | | | `$FFD2` | `CHROUT` | PARTIAL | | -| `$FFD5` | `LOAD` | PARTIAL | no VERIFY support yet | +| `$FFD5` | `LOAD` | PARTIAL | no VERIFY support yet, no STOP key support | | `$FFD8` | `SAVE` | NOT DONE | | | `$FFDB` | `SETTIM` | NOT DONE | | | `$FFDE` | `RDTIM` | NOT DONE | | -| `$FFE1` | `STOP` | PARTIAL | no connection with UDTIM | +| `$FFE1` | `STOP` | DONE | | | `$FFE4` | `GETIN` | PARTIAL | only some devices supported | | `$FFE7` | `CLALL` | DONE | | -| `$FFEA` | `UDTIM` | NOT DONE | | +| `$FFEA` | `UDTIM` | NOT DONE | checking for STOP key present in SCNKEY instead | | `$FFED` | `SCREEN` | DONE | | | `$FFF0` | `PLOT` | NOT DONE | | | `$FFF3` | `IOBASE` | DONE | | diff --git a/bin/basic_generic.rom b/bin/basic_generic.rom index 29d891b1..82c768bf 100644 Binary files a/bin/basic_generic.rom and b/bin/basic_generic.rom differ diff --git a/bin/basic_mega65.rom b/bin/basic_mega65.rom index a72bf16d..911bacab 100644 Binary files a/bin/basic_mega65.rom and b/bin/basic_mega65.rom differ diff --git a/bin/basic_ultimate64.rom b/bin/basic_ultimate64.rom index 6ed9ce5b..e54c732f 100644 Binary files a/bin/basic_ultimate64.rom and b/bin/basic_ultimate64.rom differ diff --git a/bin/kernal_generic.rom b/bin/kernal_generic.rom index 35157ebb..140ad023 100644 Binary files a/bin/kernal_generic.rom and b/bin/kernal_generic.rom differ diff --git a/bin/kernal_mega65.rom b/bin/kernal_mega65.rom index 35157ebb..140ad023 100644 Binary files a/bin/kernal_mega65.rom and b/bin/kernal_mega65.rom differ diff --git a/bin/kernal_ultimate64.rom b/bin/kernal_ultimate64.rom index 35157ebb..140ad023 100644 Binary files a/bin/kernal_ultimate64.rom and b/bin/kernal_ultimate64.rom differ diff --git a/c64/aliases/,aliases_hardware.s b/c64/aliases/,aliases_hardware.s index ee6ceddb..cc57faa3 100644 --- a/c64/aliases/,aliases_hardware.s +++ b/c64/aliases/,aliases_hardware.s @@ -5,8 +5,8 @@ ;; CPU memory registers - .alias CPU_D6510 $0000 - .alias CPU_R6510 $0001 + .alias CPU_D6510 $00 + .alias CPU_R6510 $01 ;; VIC-II registers @@ -28,7 +28,7 @@ .alias VIC_SP7Y $D00F .alias VIC_MSIGX $D010 - .alias VIC_SCROLLY $D011 + .alias VIC_SCROLY $D011 .alias VIC_RASTER $D012 .alias VIC_LPENX $D013 .alias VIC_LPENY $D014 @@ -60,46 +60,40 @@ .alias VIC_SP6COL $D02D .alias VIC_SP7COL $D02E - ;; SID #1 registers + ;; SID 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 SID_FRELO1 $D400 + .alias SID_FREHI1 $D401 + .alias SID_PWLO1 $D402 + .alias SID_PWHI1 $D403 + .alias SID_VCREG1 $D404 + .alias SID_ATDCY1 $D405 + .alias SID_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 SID_FRELO2 $D407 + .alias SID_FREHI2 $D408 + .alias SID_PWLO2 $D409 + .alias SID_PWHI2 $D40A + .alias SID_VCREG2 $D40B + .alias SID_ATDCY2 $D40C + .alias SID_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 SID_FRELO3 $D40E + .alias SID_FREHI3 $D40F + .alias SID_PWLO3 $D410 + .alias SID_PWHI3 $D411 + .alias SID_VCREG3 $D412 + .alias SID_ATDCY3 $D413 + .alias SID_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 + .alias SID_CUTLO $D415 + .alias SID_CUTHI $D416 + .alias SID_RESON $D417 + .alias SID_SIGVOL $D418 + .alias SID_POTX $D419 + .alias SID_POTY $D41A + .alias SID_RANDOM $D41B + .alias SID_ENV3 $D41C ;; CIA #1 registers diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s index 311fbf87..6108e28e 100644 --- a/c64/aliases/,aliases_ram_lowmem.s +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -45,6 +45,7 @@ .alias FNADDR $BB ; $BB-$BC, current file name pointer .alias STAL $C1 ; $C1-$C2 LOAD/SAVE start address + .alias MEMUS $C3 ; $C3-$C4 temporary address for tape LOAD/SAVE ;; ;; Other low memory addresses @@ -60,6 +61,8 @@ .alias MEMSTR $281 .alias MEMSIZ $283 ; NOTE: Mapping the 64 erroniously has the hex as $282, while the DEC is correct + .alias TIMOUT $285 ; IEEE-488 timeout + .alias HIBASE $288 ; high byte of start of screen .alias RSSTAT $297 ; RS-232 status diff --git a/c64/aliases/,aliases_rom_basic.s b/c64/aliases/,aliases_rom_basic.s index e69de29b..ff6c46dc 100644 --- a/c64/aliases/,aliases_rom_basic.s +++ b/c64/aliases/,aliases_rom_basic.s @@ -0,0 +1,5 @@ + + ;; BASIC startup vector + + .alias IBASIC_COLD_START $A000 + .alias IBASIC_WARM_START $A002 diff --git a/c64/aliases/,aliases_rom_cart.s b/c64/aliases/,aliases_rom_cart.s new file mode 100644 index 00000000..c2e25c1e --- /dev/null +++ b/c64/aliases/,aliases_rom_cart.s @@ -0,0 +1,5 @@ + + ;; Cartridge ROM locations + .alias ICART_COLD_START $8000 ; $8000-$8001, cartridge cold start vector + .alias ICART_WARM_START $8002 ; $8002-$8003, cartridge warm start vector (RESTORE key) + .alias CART_SIG $8004 ; 5 bytes, signature for cartridge detection diff --git a/c64/basic/,target_generic/,hooks_generic.s b/c64/basic/,target_generic/,hooks_generic.s index 186b29d0..92860379 100644 --- a/c64/basic/,target_generic/,hooks_generic.s +++ b/c64/basic/,target_generic/,hooks_generic.s @@ -4,6 +4,6 @@ .macro TARGET_HOOK_BANNER - .byte $05, " OPEN ROMS, ", $00 + .byte " OPEN ROMS, ", $00 .macend diff --git a/c64/basic/,target_ultimate64/,hooks_ultimate64.s b/c64/basic/,target_ultimate64/,hooks_ultimate64.s index 519d07e9..9ae05e35 100644 --- a/c64/basic/,target_ultimate64/,hooks_ultimate64.s +++ b/c64/basic/,target_ultimate64/,hooks_ultimate64.s @@ -4,6 +4,6 @@ .macro TARGET_HOOK_BANNER - .byte $05, " OPEN ROMS FOR ULTIMATE 64", $0D, $0D, " ", $00 + .byte " 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 83f8d366..0ea252a3 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 via_IBSOUT + jsr JCHROUT txa tay diff --git a/c64/basic/basic_cold_start.s b/c64/basic/basic_cold_start.s index 325bd1ed..b57145c8 100644 --- a/c64/basic/basic_cold_start.s +++ b/c64/basic/basic_cold_start.s @@ -17,6 +17,14 @@ startup_banner: `TARGET_HOOK_BANNER + ;; Print PAL/NTSC + ldx #30 ; NTSC + lda PALNTSC + beq + + ldx #31 ; PAL +* + jsr print_packed_message + ;; Work out free bytes, and display jsr basic_do_new lda basic_top_of_memory_ptr+0 @@ -26,10 +34,10 @@ startup_banner: lda basic_top_of_memory_ptr+1 sbc basic_end_of_text_ptr+1 - jsr print_integer + jsr print_integer lda #$20 - jsr via_IBSOUT + jsr JCHROUT ;; Print the rest of the start up message ldx #34 @@ -37,8 +45,8 @@ startup_banner: ;; jump into warm start loop jmp basic_warm_start - - + + startup_message: ;; Clear the screen .byte $93 diff --git a/c64/basic/basic_do_error.s b/c64/basic/basic_do_error.s index 92d7e46d..731f99c2 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 via_IBSOUT + jsr JCHROUT lda #$3f - jsr via_IBSOUT + jsr JCHROUT ;; Print main part of error message pla @@ -18,7 +18,7 @@ basic_do_error: ;; Print ERROR at end lda #$20 - jsr via_IBSOUT + jsr JCHROUT 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 via_IBSOUT + jsr JCHROUT lda #$0d - jsr via_IBSOUT + jsr JCHROUT ;; Reset stack, and go back to main loop ldx #$fe diff --git a/c64/basic/basic_main_loop.s b/c64/basic/basic_main_loop.s index 2d7afdd6..69e12c9d 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 via_IBSOUT + jsr JCHROUT ;; Ignore empty lines lda tokenise_work1 diff --git a/c64/basic/cmd_break.s b/c64/basic/cmd_break.s index 31194132..36128422 100644 --- a/c64/basic/cmd_break.s +++ b/c64/basic/cmd_break.s @@ -17,7 +17,7 @@ basic_do_break: * lda #$0d - jsr via_IBSOUT + jsr JCHROUT cmd_end: jmp basic_main_loop diff --git a/c64/basic/cmd_list.s b/c64/basic/cmd_list.s index a1be1724..72e9edd9 100644 --- a/c64/basic/cmd_list.s +++ b/c64/basic/cmd_list.s @@ -42,7 +42,7 @@ list_single_line: ; entry point needed by DOS wedge pla jsr print_integer lda #$20 - jsr via_IBSOUT + jsr JCHROUT ;; Iterate through printing out the line ;; contents @@ -111,16 +111,16 @@ list_not_rem: bne list_print_loop list_is_literal: - jsr via_IBSOUT + jsr JCHROUT iny bne list_print_loop list_end_of_line: ;; Clear reverse flag lda #$92 - jsr via_IBSOUT + jsr JCHROUT ;; Print end of line lda #$0d - jsr via_IBSOUT + jsr JCHROUT rts diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index dc900c54..ac286c6e 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -191,6 +191,7 @@ end_of_line_search: pla sta basic_current_line_ptr+0 - - jmp basic_relink_loop + +via_ILOAD: + jmp (ILOAD) diff --git a/c64/basic/print_integer.s b/c64/basic/print_integer.s index 7e897243..f5d93fa7 100644 --- a/c64/basic/print_integer.s +++ b/c64/basic/print_integer.s @@ -115,7 +115,7 @@ found_start_of_number: ;; Print digits * lda $0100,y ora #$30 - jsr via_IBSOUT + jsr JCHROUT iny cpy #5 bne - diff --git a/c64/basic/print_packed_message.s b/c64/basic/print_packed_message.s index 7aac0876..006bf70e 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 via_IBSOUT + jsr JCHROUT pla tay iny @@ -47,7 +47,7 @@ found_message_in_token_stream: pla ;; Rub out space at the end lda #$14 - jsr via_IBSOUT + jsr JCHROUT rts print_packed_word: @@ -144,7 +144,7 @@ next_packed_word_char: ;; X=1-14 = first 14 chars, so subtract one lda packed_message_chars-1,x - jsr via_IBSOUT + jsr JCHROUT ;; 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 via_IBSOUT + jsr JCHROUT * pla tay @@ -207,7 +207,7 @@ unpack_literal_char: tya pha lda (temp_string_ptr),y - jsr via_IBSOUT + jsr JCHROUT pla tay rts diff --git a/c64/basic/printf.s b/c64/basic/printf.s index 85fa0cf8..ceb4337b 100644 --- a/c64/basic/printf.s +++ b/c64/basic/printf.s @@ -112,7 +112,7 @@ not_hexword: not_pointer: ;; Print character - jsr via_IBSOUT + jsr JCHROUT printf_nextchar: jsr printf_advance @@ -148,11 +148,11 @@ printf_printhexbyte: cmp #$3A bcc + adc #6 -* jsr via_IBSOUT +* jsr JCHROUT pla and #$0f ora #$30 cmp #$3A bcc + adc #6 -* jmp via_IBSOUT +* jmp JCHROUT diff --git a/c64/basic/via_vector.s b/c64/basic/via_vector.s deleted file mode 100644 index 3cfc7480..00000000 --- a/c64/basic/via_vector.s +++ /dev/null @@ -1,42 +0,0 @@ - -;; -;; 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 index e147e9fe..ccfffe4d 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -4,7 +4,7 @@ wedge_dos: ;; Close all the channels, so that wedge has full control - jsr via_ICLALL + jsr JCLALL ;; Set file parameters, channel 15 is a typical one for commands jsr select_device ; sets X register @@ -41,11 +41,11 @@ wedge_dos_command: jsr wedge_dos_setnam jsr JSETNAM - jsr via_IOPEN + jsr JOPEN bcs wedge_dos_basic_error ;; Retrieve status, print it if not OK - jsr via_ICLALL + jsr JCLALL jsr wedge_dos_status_get lda BUF+0 cmp #$30 ; '0' @@ -82,12 +82,12 @@ wedge_dos_status_get: ;; Set remaining file parameters, open the channel lda #$00 ; empty file name jsr JSETNAM - jsr via_IOPEN + jsr JOPEN bcs wedge_dos_basic_error ;; Set channel for input ldx #$0F - jsr via_ICHKIN + jsr JCHKIN bcs wedge_dos_basic_error ldy #$00 @@ -98,7 +98,7 @@ wedge_dos_status_get: ;; XXX error in case of status != EOF ;; Print out everything retrieved from the drive bne + - jsr via_IBASIN + jsr JCHRIN bcs wedge_dos_basic_error sta BUF, y iny @@ -118,7 +118,7 @@ wedge_dos_status_print: dey bmi + lda BUF, x - jsr via_IBSOUT + jsr JCHROUT inx bne - * @@ -139,18 +139,18 @@ wedge_dos_directory: jsr wedge_dos_setnam ;; Open the file - jsr via_IOPEN + jsr JOPEN bcs wedge_dos_basic_error ;; Set channel for file reading ldx #$00 - jsr via_ICHKIN + jsr JCHKIN bcs wedge_dos_basic_error ;; Ignore start address (2 first bytes) - XXX check for errors - jsr via_IBASIN + jsr JCHRIN bcs wedge_dos_basic_error - jsr via_IBASIN + jsr JCHRIN bcs wedge_dos_basic_error wedge_dos_directory_line: @@ -159,7 +159,7 @@ wedge_dos_directory_line: ldy #$FF * iny - jsr via_IBASIN + jsr JCHRIN bcs wedge_dos_basic_error sta BUF, y cpy #$50 @@ -199,15 +199,15 @@ wedge_dos_directory_display: ;; FALLTROUGH wedge_dos_clean_exit: - jsr via_ICLALL + jsr JCLALL ;; Print new line lda #$0D - jsr via_IBSOUT + jsr JCHROUT jmp basic_end_of_line wedge_dos_basic_error: pha - jsr via_ICLALL + jsr JCLALL pla tax dex diff --git a/c64/kernal/cartridge_check.s b/c64/kernal/cartridge_check.s index de748d4e..26106ae8 100644 --- a/c64/kernal/cartridge_check.s +++ b/c64/kernal/cartridge_check.s @@ -3,13 +3,13 @@ cartridge_check: ldx #$04 cartridge_check_l1: - lda $8002,x + lda CART_SIG,x cmp cartridge_signature,x bne no_cartridge dex bpl cartridge_check_l1 - jmp ($8000) -cartridge_signature: - .byte $C3,$C2,$CD,$38,$30 + sec + rts no_cartridge: + clc rts diff --git a/c64/kernal/cartridge_signature.s b/c64/kernal/cartridge_signature.s new file mode 100644 index 00000000..2b0c5f90 --- /dev/null +++ b/c64/kernal/cartridge_signature.s @@ -0,0 +1,3 @@ + +cartridge_signature: + .byte $C3,$C2,$CD,$38,$30 diff --git a/c64/kernal/chkinout.s b/c64/kernal/chkinout_real.s similarity index 98% rename from c64/kernal/chkinout.s rename to c64/kernal/chkinout_real.s index 1075665c..85d7d622 100644 --- a/c64/kernal/chkinout.s +++ b/c64/kernal/chkinout_real.s @@ -11,7 +11,7 @@ ;; CHKIN implementation -chkin: +chkin_real: ;; Store Y for preservation tya @@ -88,11 +88,9 @@ chkinout_file_not_output: tay jmp kernalerror_FILE_NOT_OUTPUT -chkinout_common: - ;; CKOUT implementation -ckout: +ckout_real: ;; Store Y for preservation tya diff --git a/c64/kernal/chrin.s b/c64/kernal/chrin_real.s similarity index 99% rename from c64/kernal/chrin.s rename to c64/kernal/chrin_real.s index 8a84f5d6..b69db61d 100644 --- a/c64/kernal/chrin.s +++ b/c64/kernal/chrin_real.s @@ -14,7 +14,7 @@ ;; If from keyboard, then it gets a whole line of input, and returns the first char. ;; Repeated calls after that read out the successive bytes of the line of input. -chrin: +chrin_real: ;; Determine the device number lda DFLTN diff --git a/c64/kernal/chrout.s b/c64/kernal/chrout_real.s similarity index 99% rename from c64/kernal/chrout.s rename to c64/kernal/chrout_real.s index 6f340a0f..128a7426 100644 --- a/c64/kernal/chrout.s +++ b/c64/kernal/chrout_real.s @@ -9,7 +9,7 @@ ;; -chrout: +chrout_real: sta last_printed_character_ascii diff --git a/c64/kernal/cint.s b/c64/kernal/cint.s index 973def0d..1fa22258 100644 --- a/c64/kernal/cint.s +++ b/c64/kernal/cint.s @@ -10,8 +10,15 @@ cint: + +cint_brk: ; entry for BRK and STOP+RESTORE - XXX, where should it start? + jsr setup_vicii - + + ;; According to [CM64], this routine also checks for PAL/NTSC - this must be a mistake, + ;; it's too late (IOINIT already needs this information), besides - POKE something + ;; to address 678 on a real C64, press STOP+RESTORE - the value won't change + ;; Initialise cursor blink flags (Compute's Mapping the 64 p215) lda #$00 sta cursor_blink_disable @@ -34,8 +41,8 @@ cint: stx key_first_repeat_delay ;; Set current colour for text (Compute's Mapping the 64 p215) - ldx #$0e ; light blue by default - stx $0286 + ldx #$01 ; default is light blue ($0E), but we use a different one + stx text_colour ;; Set maximum keyboard buffer size (Compute's Mapping the 64 p215) ldx #10 @@ -45,9 +52,6 @@ cint: ;; Set default I/O devices (see SCINIT description at http://sta.c64.org/cbm64krnfunc.html) jsr clrchn_reset - + ;; Fallthrough/jump to screen clear routine (Compute's Mapping the 64 p215) jmp clear_screen - - rts - diff --git a/c64/kernal/clall.s b/c64/kernal/clall_real.s similarity index 94% rename from c64/kernal/clall.s rename to c64/kernal/clall_real.s index ba595c20..33649858 100644 --- a/c64/kernal/clall.s +++ b/c64/kernal/clall_real.s @@ -9,7 +9,7 @@ ;; -clall: +clall_real: ;; Store .Y register tya @@ -23,7 +23,7 @@ clall: beq + dey lda LAT, y - jsr close ; XXX jump through ICLOSE? + jsr JCLOSE jmp - * ;; Restore .Y register diff --git a/c64/kernal/close_load.s b/c64/kernal/close_load.s new file mode 100644 index 00000000..f594590f --- /dev/null +++ b/c64/kernal/close_load.s @@ -0,0 +1,23 @@ + + +;; Common ppart of CLOSE and LOAD routines + +close_load: + + tax + + ;; Command drive to stop talking and to close the file + jsr untlk + + txa + jsr listen + + lda #$E0 ; CLOSE command + sta IEC_TMP2 + jsr iec_tx_command + jsr iec_tx_command_finalize + + ;; Tell drive to unlisten + jsr unlsn + + rts diff --git a/c64/kernal/clrchn.s b/c64/kernal/clrchn_real.s similarity index 98% rename from c64/kernal/clrchn.s rename to c64/kernal/clrchn_real.s index 3cc53078..2abee15e 100644 --- a/c64/kernal/clrchn.s +++ b/c64/kernal/clrchn_real.s @@ -9,7 +9,7 @@ ;; -clrchn: +clrchn_real: ;; Handle IEC input device lda DFLTN diff --git a/c64/kernal/e544.clear_screen.s b/c64/kernal/e544.clear_screen.s index 6b1d41fc..431c571e 100644 --- a/c64/kernal/e544.clear_screen.s +++ b/c64/kernal/e544.clear_screen.s @@ -1,21 +1,20 @@ ;; Clear screen and initialise line link table ;; (Compute's Mapping the 64 p215-216) -clear_screen: - +clear_screen: + ;; Clear line link table ;; (Compute's Mapping the 64 p215) lda #$00 ldy #24 -clearscreen_l1: +clearscreen_l1: sta screen_line_link_table,y dey bpl clearscreen_l1 ;; Y now = #$FF - ;; Clear screen RAM. ;; We should do this at HIBASE, which annoyingly ;; is no ZP, so we need to make a vector diff --git a/c64/kernal/e5a0.setup_vicii.s b/c64/kernal/e5a0.setup_vicii.s index 671bfadf..d2483a45 100644 --- a/c64/kernal/e5a0.setup_vicii.s +++ b/c64/kernal/e5a0.setup_vicii.s @@ -1,19 +1,20 @@ -setup_vicii: +setup_vicii: + ;; Set up default IO values (Compute's Mapping the 64 p215) - lda #$1b ; Enable text mode - sta $d011 - lda #$c8 ; 40 column etc - sta $d016 + lda #$1B ; Enable text mode + sta VIC_SCROLY + lda #$C8 ; 40 column etc + sta VIC_SCROLX ;; Compute's Mapping the 64, p156 ;; We use a different colour scheme of white text on all blue lda #$06 - sta $D020 - sta $D021 + sta VIC_EXTCOL + sta VIC_BGCOL0 - ;; Turn off sprites - ;; (observed hanging around after running programs and resetting) + ;; Turn off sprites (observed hanging around after running programs and resetting) lda #$00 - sta $D015 - + sta VIC_SPENA + + ;;FALLTROUGH diff --git a/c64/kernal/getin.s b/c64/kernal/f13e.getin.s similarity index 100% rename from c64/kernal/getin.s rename to c64/kernal/f13e.getin.s diff --git a/c64/kernal/f13e.interop b/c64/kernal/f13e.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f13e.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/f157.chrin.jmp.s b/c64/kernal/f157.chrin.jmp.s new file mode 100644 index 00000000..c063c752 --- /dev/null +++ b/c64/kernal/f157.chrin.jmp.s @@ -0,0 +1,6 @@ + +;; Our implementation is longer than the original one, +;; placing it here would cause a collision with CHROUT + +chrin: + jmp chrin_real diff --git a/c64/kernal/f157.interop b/c64/kernal/f157.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f157.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/f1ca.chrout.jmp.s b/c64/kernal/f1ca.chrout.jmp.s new file mode 100644 index 00000000..02e434ea --- /dev/null +++ b/c64/kernal/f1ca.chrout.jmp.s @@ -0,0 +1,6 @@ + +;; Our implementation is longer than the original one, +;; placing it here would cause a collision with CHKIN + +chrout: + jmp chrout_real diff --git a/c64/kernal/f1ca.interop b/c64/kernal/f1ca.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f1ca.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/f20e.chkin.jmp.s b/c64/kernal/f20e.chkin.jmp.s new file mode 100644 index 00000000..bed06f58 --- /dev/null +++ b/c64/kernal/f20e.chkin.jmp.s @@ -0,0 +1,6 @@ + +;; In our implementation CHKIN and CKOUT are closely tied, +;; placing it here would cause a collision + +chkin: + jmp chkin_real diff --git a/c64/kernal/f20e.interop b/c64/kernal/f20e.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f20e.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/f250.ckout.jmp.s b/c64/kernal/f250.ckout.jmp.s new file mode 100644 index 00000000..671d44bd --- /dev/null +++ b/c64/kernal/f250.ckout.jmp.s @@ -0,0 +1,6 @@ + +;; In our implementation CHKIN and CKOUT are closely tied, +;; placing it here would cause a collision + +ckout: + jmp ckout_real diff --git a/c64/kernal/f250.interop b/c64/kernal/f250.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f250.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/close.s b/c64/kernal/f291.close.s similarity index 90% rename from c64/kernal/close.s rename to c64/kernal/f291.close.s index fc8e0a8c..693362ce 100644 --- a/c64/kernal/close.s +++ b/c64/kernal/f291.close.s @@ -26,14 +26,19 @@ close: ;; IEC device jsr iec_tx_flush ; make sure no byte is awaiting -* lda SAT, y ; get secondary address + cmp #$60 + bne + + ;; workaround for using CLOSE on reading executable - XXX is this a proper way? + jsr close_load + jmp close_remove_from_table +* ora $E0 ; CLOSE command sta IEC_TMP2 jsr iec_tx_command bcs close_remove_from_table jsr iec_tx_command_finalize - + close_remove_from_table: ;; Remove channel from the table iny diff --git a/c64/kernal/f291.interop b/c64/kernal/f291.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f291.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/f32f.clall.jmp.s b/c64/kernal/f32f.clall.jmp.s new file mode 100644 index 00000000..56567151 --- /dev/null +++ b/c64/kernal/f32f.clall.jmp.s @@ -0,0 +1,6 @@ + +;; Our implementation is longer than the original one, +;; placing it here would cause a collision with CLRCHN + +clall: + jmp clall_real diff --git a/c64/kernal/f32f.interop b/c64/kernal/f32f.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f32f.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/f333.clrchn.jmp.s b/c64/kernal/f333.clrchn.jmp.s new file mode 100644 index 00000000..ac23dc8e --- /dev/null +++ b/c64/kernal/f333.clrchn.jmp.s @@ -0,0 +1,6 @@ + +;; Our implementation is longer than the original one, +;; placing it here would cause a collision with OPEN + +clrchn: + jmp clrchn_real diff --git a/c64/kernal/f333.interop b/c64/kernal/f333.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f333.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/f34a.interop b/c64/kernal/f34a.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f34a.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/open.s b/c64/kernal/f34a.open.s similarity index 100% rename from c64/kernal/open.s rename to c64/kernal/f34a.open.s diff --git a/c64/kernal/f4a5.interop b/c64/kernal/f4a5.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f4a5.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/load.s b/c64/kernal/f4a5.load.s similarity index 94% rename from c64/kernal/load.s rename to c64/kernal/f4a5.load.s index e845b546..ece03816 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/f4a5.load.s @@ -125,19 +125,8 @@ load_loop: ;; Close file on drive - ;; Command drive to stop talking and to close the file - jsr untlk - lda current_device_number - jsr listen - - lda #$E0 - sta IEC_TMP2 - jsr iec_tx_command - jsr iec_tx_command_finalize - - ;; Tell drive to unlisten - jsr unlsn + jsr close_load ;; Return last address jmp lvs_return_last_address diff --git a/c64/kernal/f5ed.interop b/c64/kernal/f5ed.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f5ed.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/save.s b/c64/kernal/f5ed.save.s similarity index 100% rename from c64/kernal/save.s rename to c64/kernal/f5ed.save.s diff --git a/c64/kernal/f6ed.interop b/c64/kernal/f6ed.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/f6ed.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/stop.s b/c64/kernal/f6ed.stop.s similarity index 95% rename from c64/kernal/stop.s rename to c64/kernal/f6ed.stop.s index 980bd9bf..fd0ce804 100644 --- a/c64/kernal/stop.s +++ b/c64/kernal/f6ed.stop.s @@ -14,8 +14,7 @@ stop: ;; BASIC checks carry flag to indicate STOP or not lda STKEY - and #$80 - beq stop_pressed + bpl stop_pressed ;; By trial and error, we know that Z + C = BREAK ;; and that neither should be set otherwise diff --git a/c64/kernal/fda3.ioinit.s b/c64/kernal/fda3.ioinit.s index fd579b03..3f1a3ba9 100644 --- a/c64/kernal/fda3.ioinit.s +++ b/c64/kernal/fda3.ioinit.s @@ -15,40 +15,99 @@ ioinit: ; (https://www.c64-wiki.com/wiki/Zeropage) ;; XXX - Work around VICE bug: Writing $00 before $01 results in rubbish in $01 ;; after. https://sourceforge.net/p/vice-emu/bugs/1057/ - LDA #$27 - LDX #$2F - STA $01 - STX $00 + lda #$27 + ldx #$2F + sta CPU_R6510 + stx CPU_D6510 - ;; Enable CIA1 IRQ and ~50Hz timer - ;; (https://csdb.dk/forums/?roomid=11&topicid=69037) - lda #$7f - sta $DC0D ; First disable all + ;; Silence the SID chips + + ldy #$00 +* + lda SID_SIGVOL, Y + and #$F0 + sta SID_SIGVOL, Y + tya + clc + adc #$20 + tay + cpy #$80 ; $20 * amount of chips to silence, $80 to silence 4 chips + bne - + + ;; Detect video system (PAL/NTSC), use Graham's method, as it's short and reliable + ;; see here: https://codebase64.org/doku.php?id=base:detect_pal_ntsc + +ioinit_w0: + lda VIC_RASTER +ioinit_w1: + cmp VIC_RASTER + beq ioinit_w1 + bmi ioinit_w0 + + ;; Result in A, if no interrupt happened during the test: + ;; #$37 -> 312 rasterlines, PAL, VIC 6569 + ;; #$06 -> 263 rasterlines, NTSC, VIC 6567R8 + ;; #$05 -> 262 rasterlines, NTSC, VIC 6567R56A + + cmp #$07 + bcs ioinit_pal + +ioinit_ntsc: + lda #$00 + beq + + +ioinit_pal: + lda #$01 +* + sta PALNTSC + + ;; XXX: calibrate TOD for both CIA's, see here: https://codebase64.org/doku.php?id=base:efficient_tod_initialisation + + ;; Enable CIA1 IRQ and ~50Hz timer (https://csdb.dk/forums/?roomid=11&topicid=69037) + lda #$7F + sta CIA1_ICR ; disable all ;; Set timer interval to ~1/60th of a second - ;; (This value was calculated by running a custom IRQ haandler on a C64 + + ;; (This value was calculated by running a custom IRQ handler on a C64 ;; with original KERNAL, and writing the values of $DC04/5 to the screen ;; in the IRQ handler to see roughly what value the timers must be set to) - lda #<16380 - sta $dc04 - lda #>16380 - sta $dc05 + ;; ldy #<16380 + ;; ldx #>16380 + + ;; PAL C64 (https://codebase64.org/doku.php?id=base:cpu_clocking), + ;; is clocked at 0.985248 MHz, so that 1/60s is 16421 CPU cycles + + ldy #<16421 + ldx #>16421 + + lda PALNTSC + bne + + + ;; NTSC C64 (https://codebase64.org/doku.php?id=base:cpu_clocking), + ;; is clocked at 1.022727 MHz, so that 1/60s is 17045 CPU cycles + + ldy #<17045 + ldx #>17045 + + ;; Store the IRQ timing constant to CIA chip +* + sty CIA1_TIMALO + stx CIA1_TIMAHI ;; Enable timer interrupt lda #$81 - sta $dc0d + sta CIA1_ICR - ;; Enable timer A to run continuously - ;; (http://codebase64.org/doku.php?id=base:timerinterrupts) + ;; Enable timer A to run continuously (http://codebase64.org/doku.php?id=base:timerinterrupts) lda #$11 - sta $dc0e - lda $dc0d + sta CIA1_CRA + lda CIA1_ICR ;; Set DDR on CIA2 for IEC bus, VIC-II banking - lda #$3b - sta $dd02 - - ;; Set IEC bus oto its initial idle state - jsr iec_set_idle - - rts + lda #$3B + sta CIA2_DDRA + + ;; Set IEC bus to its initial idle state + jmp iec_set_idle + diff --git a/c64/kernal/ff80.interop b/c64/kernal/ff80.interop new file mode 100644 index 00000000..e586be7d --- /dev/null +++ b/c64/kernal/ff80.interop @@ -0,0 +1 @@ +Byte telling Kernal version; we can probably put just about anything here, but we want to be distinct from everyone else! diff --git a/c64/kernal/ff80.kernal_revision.s b/c64/kernal/ff80.kernal_revision.s new file mode 100644 index 00000000..7cadcbec --- /dev/null +++ b/c64/kernal/ff80.kernal_revision.s @@ -0,0 +1,31 @@ + +;; +;; This byte identifies Kernal revision. Sources: +;; - [CM64] Compute's Mapping the Commodore 64 (page 242/243) +;; - [MM] Marko Mäkelä article, http://www.zimmers.net/anonftp/pub/cbm/firmware/computers/c64/revisions.txt +;; - [VICE] Checked with ROMs included in VICE emulator +;; +;; IDEA: put here a value, that is different from any version currently known, as +;; a warning that this is not a Commodore Kernal. Currently known numbers for C64 are: +;; +;; - $00 - [CM64] then current number [MM] 901227-02 [VICE] C64 Revision 2 +;; - $03 - [CM64] (not mentionned) [MM] 901227-02, 901227-03 [VICE] C64 Revision 3 +;; - $43 - [CM64] (not mentionned) [MM] 251104-04 [VICE] SX-64 +;; - $64 - [CM64] PET64 ROM [MM] (not mentionned) [VICE] PET64 +;; - $AA - [CM64] first version of ROM [MM] 901227-01 [VICE] C64 Revision 1 +;; +;; Values from unofficial ROMs: +;; - $03 - SuperCPU ROM 1.40, 2.04, also unofficial 0.7 ROM from [VICE] +;; +;; Values from other Commodore machines: +;; C128: +;; - $01 - see https://www.pagetable.com/?p=1058 +;; - $02 - unreleased updated ROM, see https://www.pagetable.com/?p=1058 +;; +;; XXX check more unofficial C64 ROMs (JiffyDOS, DolphinDOS, etc.) and other machines +;; VIC-20, PET, CBM II, 264 series, C65 prototypes, other sources for C128 ROMs +;; + + +kernal_revision: + .byte $FF diff --git a/c64/kernal/iec/iec_wait20us.s b/c64/kernal/iec/iec_wait20us.s index 3ea1349f..819830cc 100644 --- a/c64/kernal/iec/iec_wait20us.s +++ b/c64/kernal/iec/iec_wait20us.s @@ -6,7 +6,7 @@ iec_wait20us: ;; PAL: ;; - CPU frequency 0.985248 MHz, we need to waste at least 20 cycles ;; NTSC: - ;; - CPU frequency 1.022727 MHZ, we need to waste at least 21 cycles + ;; - CPU frequency 1.022727 MHz, we need to waste at least 21 cycles ;; Waste cycles by reading some unimportant memory location ;; in order not to clutter VICE debug logs diff --git a/c64/kernal/iec/iec_wait60us.s b/c64/kernal/iec/iec_wait60us.s index 0f6cd957..90501a5e 100644 --- a/c64/kernal/iec/iec_wait60us.s +++ b/c64/kernal/iec/iec_wait60us.s @@ -6,7 +6,7 @@ iec_wait60us: ;; PAL: ;; - CPU frequency 0.985248 MHz, we need to waste at least 60 cycles ;; NTSC: - ;; - CPU frequency 1.022727 MHZ, we need to waste at least 62 cycles + ;; - CPU frequency 1.022727 MHz, we need to waste at least 62 cycles ;; Waste cycles in a loop diff --git a/c64/kernal/ea31.default_irq_handler.s b/c64/kernal/interrupts/ea31.default_irq_handler.s similarity index 74% rename from c64/kernal/ea31.default_irq_handler.s rename to c64/kernal/interrupts/ea31.default_irq_handler.s index e37991f1..944fe430 100644 --- a/c64/kernal/ea31.default_irq_handler.s +++ b/c64/kernal/interrupts/ea31.default_irq_handler.s @@ -1,7 +1,9 @@ + default_irq_handler: jsr blink_cursor - jsr scan_keyboard + jsr JSCNKEY + jsr JUDTIM ; update jiffy clock ;; Acknowledge CIA interrupt and return jmp clear_cia1_interrupt_flag_and_return_from_interrupt diff --git a/c64/kernal/interrupts/ea31.interop b/c64/kernal/interrupts/ea31.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/interrupts/ea31.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/ea7e.s b/c64/kernal/interrupts/ea7e.ack_cia1_return_from_interrupt.s similarity index 100% rename from c64/kernal/ea7e.s rename to c64/kernal/interrupts/ea7e.ack_cia1_return_from_interrupt.s diff --git a/c64/kernal/ea81.s b/c64/kernal/interrupts/ea81.return_from_interrupt.s similarity index 100% rename from c64/kernal/ea81.s rename to c64/kernal/interrupts/ea81.return_from_interrupt.s diff --git a/c64/kernal/interrupts/fe47.default_nmi_handler.s b/c64/kernal/interrupts/fe47.default_nmi_handler.s new file mode 100644 index 00000000..8814ac2c --- /dev/null +++ b/c64/kernal/interrupts/fe47.default_nmi_handler.s @@ -0,0 +1,30 @@ + +default_nmi_handler: + + ;; Implemented according to Compute's Mapping the Commodore 64, page 74 + ;; and to https://www.c64-wiki.com/wiki/Interrupt + + ;; Save registers, sequence according to Compute's Mapping the Commodore 64, page 73 + pha + txa + pha + tya + pha + + ;; XXX: RS-232 support is not implemented + + ;; XXX confirm NMIs from CIA, or no other NMI will arrive! + + jsr cartridge_check + bcc + + jmp (ICART_WARM_START) +* + + ;; According to C64 Wiki, if STOP key is pressed, the routine assumes warm start request + + jsr JSTOP + bcs + + jmp return_from_interrupt ; no STOP pressed +* + jmp (CBINV) ; STOP + RESTORE + diff --git a/c64/kernal/interrupts/fe47.interop b/c64/kernal/interrupts/fe47.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/interrupts/fe47.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/interrupts/fe66.default_brk_handler.s b/c64/kernal/interrupts/fe66.default_brk_handler.s new file mode 100644 index 00000000..6b1f4c73 --- /dev/null +++ b/c64/kernal/interrupts/fe66.default_brk_handler.s @@ -0,0 +1,15 @@ + +default_brk_handler: + + ;; Implemented according to Compute's Mapping the Commodore 64, pages 73-74 + + sei ; disable IRQs, to be sure they won't interfere + + jsr JRESTOR + jsr JIOINIT + jsr CINT_BRK + + cli + + jmp (IBASIC_WARM_START) + diff --git a/c64/kernal/interrupts/fe66.interop b/c64/kernal/interrupts/fe66.interop new file mode 100644 index 00000000..09ebb21a --- /dev/null +++ b/c64/kernal/interrupts/fe66.interop @@ -0,0 +1,8 @@ +All the Kernal routines, for which there are vectors in $0314-$0333, have to be available at their original addresses. + +Reason: some autostart software (https://codebase64.org/doku.php?id=base:autostarting_disk_files) override these vectors, so that some point +to new locations (custom IRQ routine, custom STOP routine, etc.), while others points the original Kernal routines. Different techniques modify +different vectors (while resetting others to original C64 locations), some don't change the vectors at all, but might still put the original +C64 Kernal addresses there (for example, if the file overrides keyboard input buffer and screeen memory). + +For various cartridges (like IDE64) this just means disabling their extensions; for us that would mean improperly functionning Kernal. diff --git a/c64/kernal/irq_handler.s b/c64/kernal/interrupts/irq_handler.s similarity index 53% rename from c64/kernal/irq_handler.s rename to c64/kernal/interrupts/irq_handler.s index 82bbaac7..99733333 100644 --- a/c64/kernal/irq_handler.s +++ b/c64/kernal/interrupts/irq_handler.s @@ -1,3 +1,4 @@ + irq_handler: ;; The IRQ is a commonly messed with thing on the C64, ;; so we need to handle entry points that are commonly @@ -7,17 +8,32 @@ irq_handler: ;; $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 + ;; Save registers, sequence according to Compute's Mapping the Commodore 64, page 73 pha txa pha tya pha - ;; Call interrupt routine - ;; (but only if initialised) + ;; Check if caused by BRK + + ;; XXX disabled for now - resets Duotris game, unknown why + ; tsx + ; lda $0104, x ; get the pre-interrupt processor state + ; and #$10 + ; bne irq_handler_brk + + ;; Not caused by BRK - call interrupt routine (only if initialised) lda CINV ora CINV+1 - beq default_irq_handler + beq + jmp (CINV) +* + ;; Vector not initialized - call default interrupt routine + jmp default_irq_handler + +irq_handler_brk: + + ;; Interrupt caused by BRK + jmp (CBINV) + diff --git a/c64/kernal/interrupts/nmi_handler.s b/c64/kernal/interrupts/nmi_handler.s new file mode 100644 index 00000000..c5336f8b --- /dev/null +++ b/c64/kernal/interrupts/nmi_handler.s @@ -0,0 +1,18 @@ + +nmi_handler: + + sei ;; don't allow IRQ to interfere, see https://www.c64-wiki.com/wiki/Interrupt + + ;; Call interrupt routine (only if initialised) + pha + lda NMINV + ora NMINV+1 + beq + + pla + jmp (NMINV) +* + ;; Vector not initialized - call default interrupt routine + pla + jmp default_nmi_handler + + diff --git a/c64/kernal/jumptable/ff9f.jscnkey.s b/c64/kernal/jumptable/ff9f.jscnkey.s index 6da0b26f..2f445ce4 100644 --- a/c64/kernal/jumptable/ff9f.jscnkey.s +++ b/c64/kernal/jumptable/ff9f.jscnkey.s @@ -1,3 +1,3 @@ ; Scan keyboard ; C64 Programmer's Reference Guide Page 273 - jmp scan_keyboard + jmp SCNKEY diff --git a/c64/kernal/jumptable/ffc0.jopen.s b/c64/kernal/jumptable/ffc0.jopen.s index 58339e6b..7aafbb7e 100644 --- a/c64/kernal/jumptable/ffc0.jopen.s +++ b/c64/kernal/jumptable/ffc0.jopen.s @@ -1,3 +1,4 @@ ; open a logical file ; C64 Programmer's Reference Guide Page 272 - jmp open +; According to Compute's Mapping the Commodore 64 (pages 74/75), this jump is indirect + jmp (IOPEN) diff --git a/c64/kernal/jumptable/ffc3.jclose.s b/c64/kernal/jumptable/ffc3.jclose.s index c4b44418..b59159d3 100644 --- a/c64/kernal/jumptable/ffc3.jclose.s +++ b/c64/kernal/jumptable/ffc3.jclose.s @@ -1,3 +1,4 @@ ; close a specified logical file ; C64 Programmer's Reference Guide Page 272 - jmp close +; According to Compute's Mapping the Commodore 64 (pages 74/75), this jump is indirect + jmp (ICLOSE) diff --git a/c64/kernal/jumptable/ffc6.jchkin.s b/c64/kernal/jumptable/ffc6.jchkin.s index 842faeb9..da8948c7 100644 --- a/c64/kernal/jumptable/ffc6.jchkin.s +++ b/c64/kernal/jumptable/ffc6.jchkin.s @@ -1,3 +1,4 @@ ; Open channel for input ; C64 Programmer's Reference Guide Page 272 - jmp chkin +; According to Compute's Mapping the Commodore 64 (pages 74/75), this jump is indirect + jmp (ICHKIN) diff --git a/c64/kernal/jumptable/ffc9.jckout.s b/c64/kernal/jumptable/ffc9.jckout.s index ccfe9a2f..f394d46d 100644 --- a/c64/kernal/jumptable/ffc9.jckout.s +++ b/c64/kernal/jumptable/ffc9.jckout.s @@ -1,3 +1,4 @@ ; Open channel for output ; C64 Programmer's Reference Guide Page 272 - jmp ckout +; According to Compute's Mapping the Commodore 64 (pages 74/75), this jump is indirect + jmp (ICKOUT) diff --git a/c64/kernal/jumptable/ffcc.jclrchn.s b/c64/kernal/jumptable/ffcc.jclrchn.s index 174f0557..9fb7697c 100644 --- a/c64/kernal/jumptable/ffcc.jclrchn.s +++ b/c64/kernal/jumptable/ffcc.jclrchn.s @@ -1,3 +1,4 @@ ; close input and output channels ; C64 Programmer's Reference Guide Page 272 - jmp clrchn +; According to Compute's Mapping the Commodore 64 (pages 74/75), this jump is indirect + jmp (ICLRCH) diff --git a/c64/kernal/jumptable/ffcf.jchrin.s b/c64/kernal/jumptable/ffcf.jchrin.s index d2952a23..465ac6b8 100644 --- a/c64/kernal/jumptable/ffcf.jchrin.s +++ b/c64/kernal/jumptable/ffcf.jchrin.s @@ -1,3 +1,4 @@ ; Input character from channel ; C64 Programmer's Reference Guide Page 272 - jmp chrin +; According to Compute's Mapping the Commodore 64 (pages 74/75), this jump is indirect + jmp (IBASIN) diff --git a/c64/kernal/jumptable/ffd2.jchrout.s b/c64/kernal/jumptable/ffd2.jchrout.s index 816a6ece..318b26cf 100644 --- a/c64/kernal/jumptable/ffd2.jchrout.s +++ b/c64/kernal/jumptable/ffd2.jchrout.s @@ -1,3 +1,4 @@ ; Output character to channel ; C64 Programmer's Reference Guide Page 272 - jmp chrout +; According to Compute's Mapping the Commodore 64 (pages 74/75), this jump is indirect + jmp (IBSOUT) diff --git a/c64/kernal/jumptable/ffe1.jstop.s b/c64/kernal/jumptable/ffe1.jstop.s index c9c13712..e5b6c4ec 100644 --- a/c64/kernal/jumptable/ffe1.jstop.s +++ b/c64/kernal/jumptable/ffe1.jstop.s @@ -1,3 +1,4 @@ ; Scan stop key ; C64 Programmer's Reference Guide Page 273 - jmp stop +; According to Compute's Mapping the Commodore 64 (pages 74/75), this jump is indirect + jmp (ISTOP) diff --git a/c64/kernal/jumptable/ffe4.jgetin.s b/c64/kernal/jumptable/ffe4.jgetin.s index c1b21dbe..c9f67cf4 100644 --- a/c64/kernal/jumptable/ffe4.jgetin.s +++ b/c64/kernal/jumptable/ffe4.jgetin.s @@ -1,3 +1,4 @@ ; Get character from keyboard queue (keyboard buffer) ; C64 Programmer's Reference Guide Page 272 - jmp getin +; According to Compute's Mapping the Commodore 64 (pages 74/75), this jump is indirect + jmp (IGETIN) diff --git a/c64/kernal/jumptable/ffe7.jclall.s b/c64/kernal/jumptable/ffe7.jclall.s index 03e1725f..f5050a8a 100644 --- a/c64/kernal/jumptable/ffe7.jclall.s +++ b/c64/kernal/jumptable/ffe7.jclall.s @@ -1,3 +1,4 @@ ; $FFE7 - Close all files vector ; (http://codebase64.org/doku.php?id=base:kernalreference) - jmp clall +; According to Compute's Mapping the Commodore 64 (pages 74/75), this jump is indirect + jmp (ICLALL) diff --git a/c64/kernal/jumptable/ffea.judtim.s b/c64/kernal/jumptable/ffea.judtim.s index d637dff8..5cb58e73 100644 --- a/c64/kernal/jumptable/ffea.judtim.s +++ b/c64/kernal/jumptable/ffea.judtim.s @@ -1,4 +1,4 @@ ; $FFEA - Update jiffy clock vector ; (http://codebase64.org/doku.php?id=base:kernalreference) - jmp update_jiffy_clock + jmp UDTIM diff --git a/c64/kernal/nmi_handler.s b/c64/kernal/nmi_handler.s deleted file mode 100644 index b9531976..00000000 --- a/c64/kernal/nmi_handler.s +++ /dev/null @@ -1,3 +0,0 @@ -nmi_handler: - inc $D020 - rti diff --git a/c64/kernal/reset_entry.s b/c64/kernal/reset_entry.s index 0febf335..8a6ccabc 100644 --- a/c64/kernal/reset_entry.s +++ b/c64/kernal/reset_entry.s @@ -11,24 +11,36 @@ reset_entry: txs sei - ; C64 PRG p269 - jsr cartridge_check - ; The following routine is based on reading the public KERNAL jumptable routine ; list, and making unimaginative assumptions about what should be done on reset. - ; Initialising IO is obviously required. also indicated by c64 prg p269. - jsr ioinit + + ; According to example here: https://codebase64.org/doku.php?id=base:assembling_your_own_cart_rom_image + ; the cartridge does not call RAMTAS - despite it's obviously required. So, call RAMTAS + ; before the cartridge check/takeover + ; Setting up the screen and testing ram is obviously required ; also affirmed by p269 of c64 prg - jsr ramtas + jsr RAMTAS + + ; C64 PRG p269 + jsr cartridge_check + bcc + + jmp (ICART_COLD_START) +* + ; Initialising IO is obviously required. Also indicated by c64 prg p269. + ; Has to be after ther RAMTAS, as it clears memory, including the PAL/NTSC flag, + ; which is set by IOINIT + jsr IOINIT + ; Resetting IO vectors is obviously required, if we want interrupts to run ; also affirmed by c64 prg p269 - jsr restor + jsr RESTOR + ;; "Compute's Mapping the 64" p236 - jsr cint + jsr CINT ; What do we do when finished? A C64 jumps into the BASIC ROM cli ; Allow interrupts to happen ; c64 prg p269 - jmp ($a000) + jmp (IBASIC_COLD_START) diff --git a/c64/kernal/scan_keyboard.s b/c64/kernal/scnkey.s similarity index 98% rename from c64/kernal/scan_keyboard.s rename to c64/kernal/scnkey.s index 8b9de00f..d5a6bb1b 100644 --- a/c64/kernal/scan_keyboard.s +++ b/c64/kernal/scnkey.s @@ -69,7 +69,7 @@ ;// Operational Variables .alias MaxKeyRollover 3 -scan_keyboard: +scnkey: lda #$00 sta BufferQuantity @@ -204,12 +204,16 @@ ReturnNoKeys: NoActivityDetected: + ;; Cancel STKEY status + lda #$FF + sta STKEY ; XXX this variable should be set by UDTIM + ;; So cancel all bucky keys lda key_bucky_state sta key_last_bucky_state lda #$00 sta key_bucky_state - + jmp ReturnNoKeys ;; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -334,7 +338,7 @@ next_row: ;; so that RUN/STOP etc can be checked easily ;; (Compute's Mapping the 64, p27) lda ScanResult+0 - sta STKEY + sta STKEY ; XXX this variable should be set by UDTIM ;; Store de-bounce data for bucky keys ;; (Compute's Mapping the 64, p58-59) @@ -538,5 +542,3 @@ KeyCanRepeat: KeyRepeatWait: pla jmp ConsiderNextKey - - diff --git a/c64/kernal/settmo.s b/c64/kernal/settmo.s index 273fbf43..23cda2b0 100644 --- a/c64/kernal/settmo.s +++ b/c64/kernal/settmo.s @@ -9,4 +9,5 @@ ;; settmo: + sta TIMOUT rts diff --git a/c64/kernal/update_jiffy_clock.s b/c64/kernal/udtim.s similarity index 92% rename from c64/kernal/update_jiffy_clock.s rename to c64/kernal/udtim.s index 7e05883a..b502112f 100644 --- a/c64/kernal/update_jiffy_clock.s +++ b/c64/kernal/udtim.s @@ -8,5 +8,5 @@ ;; CPU registers that has to be preserved (see [RG64]): .Y ;; -update_jiffy_clock: +udtim: rts diff --git a/c64/kernal/vector.s b/c64/kernal/vector.s index 5fb49426..c5ed62ba 100644 --- a/c64/kernal/vector.s +++ b/c64/kernal/vector.s @@ -20,8 +20,10 @@ vector: .scope - ;; Temporary storage location - .alias _caller_arr_ptr CMP0 + ;; Temporary storage location - checked on real C64 that this is the + ;; address originally used; after calling VECTOR and checking zero page + ;; area afterwards, the address could be found there + .alias _caller_arr_ptr MEMUS ;; According to 'Compute's Mapping the Commodore 64' page 237, ;; the CBM implementation does not disable IRQs - yet, the @@ -32,9 +34,10 @@ vector: php cli - ;; Prepare the user data pointer - stx _caller_arr_ptr + 0 + ;; Prepare the user data pointer - strange order to reduce risk + ;; of potential similarity to the original routine sty _caller_arr_ptr + 1 + stx _caller_arr_ptr + 0 ;; Select routine variant - store or restore vectors ldy #$1F @@ -65,24 +68,3 @@ vector_restore: 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/vector_defaults.s b/c64/kernal/vector_defaults.s new file mode 100644 index 00000000..fc35e4ac --- /dev/null +++ b/c64/kernal/vector_defaults.s @@ -0,0 +1,26 @@ + +;; +;; Default values for Kernal vectors - described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 293 (RESTOR), 304 (VECTOR) +;; - [CM64] Compute's Mapping the Commodore 64 - page 237 +;; + +vector_defaults: + .word default_irq_handler ;; CINV + .word default_brk_handler ;; CBINV + .word default_nmi_handler ;; NMINV + + .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 default_brk_handler ;; USRCMD + .word load ;; ILOAD + .word save ;; ISAVE diff --git a/src/compress_text.c b/src/compress_text.c index fd156b19..57c02f19 100644 --- a/src/compress_text.c +++ b/src/compress_text.c @@ -159,15 +159,20 @@ char *error_list[]={ "LOAD", // https://www.discogs.com/Gimmik-Load-Error/release/482462 // Non-error messages "READY.\r", // #29 // https://www.ibm.com/support/knowledgecenter/zosbasics/com.ibm.zos.zconcepts/zconc_whatistsonative.htm https://github.com/stefanhaustein/expressionparser - "LOADING", // #30 // https://community.tibco.com/wiki/how-show-loading-prompt-when-reloading-external-data - "VERIFYING", // https://discussions.apple.com/thread/8087203 - "SAVING", + "NTSC, ", // #30 + "PAL, ", // #31 + "", // unused for now "ERROR", // #33 // Simply the word error that is attached to the other parts of messages https://fjkraan.home.xs4all.nl/comp/apple2faq/app2asoftfaq.html - "BYTES FREE.\r\r", // #34 // https://github.com/stefanhaustein/expressionparser + "BYTES FREE\r\r", // #34 // https://github.com/stefanhaustein/expressionparser "MEMORY CORRUPT", // #35 "NOT IMPLEMENTED", // #36 NULL}; +// XXX: create separate list for Kernal +// "LOADING", // #30 // https://community.tibco.com/wiki/how-show-loading-prompt-when-reloading-external-data +// "VERIFYING", // https://discussions.apple.com/thread/8087203 +// "SAVING", + // Token $FF is end of message, so we can have only 255 unique words #define MAX_WORDS 255 char *words[MAX_WORDS]; diff --git a/strings/018DA602 b/strings/018DA602 new file mode 100644 index 00000000..5404e18b --- /dev/null +++ b/strings/018DA602 @@ -0,0 +1,3 @@ +$01 + STA $02A6 (PAL/NTSC flag) + +Instruction and a part (storing data into a decumented variable). Not copyrightable. diff --git a/strings/02A9018D b/strings/02A9018D new file mode 100644 index 00000000..a7822c3a --- /dev/null +++ b/strings/02A9018D @@ -0,0 +1,3 @@ +$02 + LDA #$01 + STA (address does not match) + +Instruction + some parts. Not copyrightable. diff --git a/strings/02A97F8D b/strings/02A97F8D new file mode 100644 index 00000000..dbf4cde4 --- /dev/null +++ b/strings/02A97F8D @@ -0,0 +1,3 @@ +$02 + LDA #$7F + STA (address does not match) + +Instruction + some parts. Not copyrightable. diff --git a/strings/034C09F4 b/strings/034C09F4 new file mode 100644 index 00000000..7a3dbddb --- /dev/null +++ b/strings/034C09F4 @@ -0,0 +1,3 @@ +$03 + JMP $F409 + +Instruction + some part. Not copyrightable. diff --git a/strings/036C0080 b/strings/036C0080 new file mode 100644 index 00000000..87cb7116 --- /dev/null +++ b/strings/036C0080 @@ -0,0 +1,3 @@ +$03 + JMP ($8000) (jump via cartridge vector) + +Instruction (jump via a documented vector) + some part. Not copyrightable. diff --git a/strings/036C028020 b/strings/036C028020 new file mode 100644 index 00000000..2a086842 --- /dev/null +++ b/strings/036C028020 @@ -0,0 +1,3 @@ +$03 + JMP ($8002) (cartridge vector) + JSR (address does not match, part of other branch) + +Instruction and some parts. Not copyrightable. diff --git a/strings/036C1403 b/strings/036C1403 new file mode 100644 index 00000000..d5c29c2b --- /dev/null +++ b/strings/036C1403 @@ -0,0 +1,3 @@ +$03 + JMP ($0314) (jump via CINV) + +Instruction (jump via documented vector) + some part. Not copyrightable. diff --git a/strings/036C1C036C b/strings/036C1C036C deleted file mode 100644 index ebb399e0..00000000 --- a/strings/036C1C036C +++ /dev/null @@ -1,3 +0,0 @@ -$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 deleted file mode 100644 index e6f9e218..00000000 --- a/strings/036C1E036C +++ /dev/null @@ -1,3 +0,0 @@ -$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 deleted file mode 100644 index ab5ed572..00000000 --- a/strings/036C20036C +++ /dev/null @@ -1,3 +0,0 @@ -$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 deleted file mode 100644 index f05b4581..00000000 --- a/strings/036C22036C +++ /dev/null @@ -1,3 +0,0 @@ -$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 deleted file mode 100644 index 4b11242c..00000000 --- a/strings/036C24036C +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 3271b1af..00000000 --- a/strings/036C2603 +++ /dev/null @@ -1,3 +0,0 @@ -$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 deleted file mode 100644 index 552a4b08..00000000 --- a/strings/036C2A036C +++ /dev/null @@ -1,4 +0,0 @@ -$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 deleted file mode 100644 index 3bf23438..00000000 --- a/strings/036C2C03 +++ /dev/null @@ -1,3 +0,0 @@ -$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/08A90020 b/strings/08A90020 new file mode 100644 index 00000000..8f1e0328 --- /dev/null +++ b/strings/08A90020 @@ -0,0 +1,3 @@ +PHP + LDA #$00 + JSR (address does not match) + +Two very simple instructions (one without argument, second zeroing a register) + a part. Not creative - not copyrightable. diff --git a/strings/20E1FFB0 b/strings/20E1FFB0 new file mode 100644 index 00000000..4489ec2c --- /dev/null +++ b/strings/20E1FFB0 @@ -0,0 +1,3 @@ +JSR $FFE1 (STOP routine jumptable address) + BCS (offset does not match) + +Instruction (call of documented subroutine) and a half - not copyrightable. diff --git a/strings/6031EA66FE47FE4AF391F20EF250F233F357F1CAF1EDF63EF12FF366FEA5F4EDF5 b/strings/6031EA66FE47FE4AF391F20EF250F233F357F1CAF1EDF63EF12FF366FEA5F4EDF5 new file mode 100644 index 00000000..b12c656e --- /dev/null +++ b/strings/6031EA66FE47FE4AF391F20EF250F233F357F1CAF1EDF63EF12FF366FEA5F4EDF5 @@ -0,0 +1,7 @@ +RTS (from previous routine) + a list of vectors to be copied starting from $0314 + +Values of the vectors are already present in many autostart software - as it often overrides them, +sometimes changing one to trigger autostart (one of the possible techniques). We have to use the same +vector values to be compatible (in fact, it even complicates our implementation) - see *.interop files +for more details. + diff --git a/strings/608D850260 b/strings/608D850260 new file mode 100644 index 00000000..bdc30ddc --- /dev/null +++ b/strings/608D850260 @@ -0,0 +1,5 @@ +RTS (from previous routine) + STA $0285 (TIMOUT variable) + RTS + +SETTMO routine (+ RTS from previous one). There really is just one sane way to +implement a subroutine storing accumulator in a fixed memory location. +Not creative - not copyrightable. diff --git a/strings/60A5BAC902D0 b/strings/60A5BAC902D0 new file mode 100644 index 00000000..fc3f35f3 --- /dev/null +++ b/strings/60A5BAC902D0 @@ -0,0 +1,4 @@ +RTS (from previous routine) + LDA $BA (current device number) + CMP $02 + BNE (offset does not match) + +Routine starts by checking whether the device is RS-232 - nothing creative, not copyrightable. + diff --git a/strings/60AA20 b/strings/60AA20 new file mode 100644 index 00000000..0b4517ad --- /dev/null +++ b/strings/60AA20 @@ -0,0 +1,3 @@ +RTS (from previous routine) + TAX + JSR (address does not match) + +Routine starting from TAX + some subroutine jump. Not copyrightable. diff --git a/strings/C3C2CD3830 b/strings/60C3C2CD3830 similarity index 88% rename from strings/C3C2CD3830 rename to strings/60C3C2CD3830 index 395bb154..1190bf40 100644 --- a/strings/C3C2CD3830 +++ b/strings/60C3C2CD3830 @@ -1,6 +1,6 @@ -CBM80 cartridge signature +RTS + CBM80 PETSCII string -This is the string used to compare with the signature block of +CBM80 is the string used to compare with the signature block of a cartridge. It is required for interoperability with C64 cartridges, and the requirement for this string is explicit, and is well documented, including the string itself, in many places, such as: diff --git a/strings/6C1A036C b/strings/6C1A036C deleted file mode 100644 index b2044ce0..00000000 --- a/strings/6C1A036C +++ /dev/null @@ -1,3 +0,0 @@ -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/6C1A036C1C036C1E036C20036C22036C24036C26034C b/strings/6C1A036C1C036C1E036C20036C22036C24036C26034C new file mode 100644 index 00000000..fcfe7208 --- /dev/null +++ b/strings/6C1A036C1C036C1E036C20036C22036C24036C26034C @@ -0,0 +1 @@ +This is a part of Kernal jumptable - series of jumps, sometimes to the well known addreses (or through documented vectors). No business logic, part of the Kernal API itself - not copyrightable. diff --git a/strings/6C28036C2A036C2C034C b/strings/6C28036C2A036C2C034C new file mode 100644 index 00000000..fcfe7208 --- /dev/null +++ b/strings/6C28036C2A036C2C034C @@ -0,0 +1 @@ +This is a part of Kernal jumptable - series of jumps, sometimes to the well known addreses (or through documented vectors). No business logic, part of the Kernal API itself - not copyrightable. diff --git a/strings/ADA602F0 b/strings/ADA602F0 new file mode 100644 index 00000000..17bb093a --- /dev/null +++ b/strings/ADA602F0 @@ -0,0 +1,3 @@ +LDA $02A6 (PALNTSC) + BEQ (offset does not match) + +Instruction (read of a documented routine) + a half - not copyrightable. diff --git a/strings/B8D0034C b/strings/B8D0034C new file mode 100644 index 00000000..1e2f4b72 --- /dev/null +++ b/strings/B8D0034C @@ -0,0 +1,3 @@ +$B8 + BNE (offset match) + JMP (address does not match) + +Instruction + some parts. Not copyrightable. diff --git a/strings/C39914038810 b/strings/C39914038810 new file mode 100644 index 00000000..21d8b91f --- /dev/null +++ b/strings/C39914038810 @@ -0,0 +1,3 @@ +$C3 + STA $0314, Y + DEY + BPL (offset does not match) + +Part of the loop processing a documented array, but only two instructions fully match. Nothing creative - not copyrightable. diff --git a/strings/DD09208D00DD b/strings/DD09208D00DD new file mode 100644 index 00000000..56c3d79f --- /dev/null +++ b/strings/DD09208D00DD @@ -0,0 +1,5 @@ +$DD + 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/DD29DF8D00DD b/strings/DD29DF8D00DD new file mode 100644 index 00000000..697075eb --- /dev/null +++ b/strings/DD29DF8D00DD @@ -0,0 +1,5 @@ +$DD + AND #$DF + 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/DD29DF8D00DD60 b/strings/DD29DF8D00DD60 new file mode 100644 index 00000000..dd4fcd9c --- /dev/null +++ b/strings/DD29DF8D00DD60 @@ -0,0 +1,5 @@ +$DD + AND #$DF + 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/F64C54F6 b/strings/F64C54F6 new file mode 100644 index 00000000..8602c5f4 --- /dev/null +++ b/strings/F64C54F6 @@ -0,0 +1,3 @@ +$F6 + JMP $F654 + +Instruction and a part - not copyrightable.