From e9140607bc569b9affe3796719bdd5baa7d5aedd Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 29 Oct 2019 17:03:13 +0100 Subject: [PATCH] further IO stack refactoring --- Makefile | 16 +++++--- c64/,,config_generic.s | 11 ++--- c64/,,config_mega65.s | 13 +++--- c64/,,config_testing.s | 13 +++--- c64/,,config_ultimate64.s | 12 +++--- .../{stubs => ,stubs}/e566.home_cursor.s | 0 c64/kernal/{stubs => ,stubs}/e566.interop | 0 .../{stubs => ,stubs}/e6b6.advance_cursor.s | 0 c64/kernal/{stubs => ,stubs}/e6b6.interop | 0 c64/kernal/{stubs => ,stubs}/e701.interop | 0 .../{stubs => ,stubs}/e701.previous_line.s | 0 .../{stubs => ,stubs}/e716.chrout_screen.s | 0 c64/kernal/{stubs => ,stubs}/e716.interop | 0 c64/kernal/{stubs => ,stubs}/e8ea.interop | 0 .../{stubs => ,stubs}/e8ea.scroll_line.s | 0 .../e96c.insert_line_at_top.s | 0 c64/kernal/{stubs => ,stubs}/e96c.interop | 0 .../{stubs => ,stubs}/e9ff.clear_line.s | 0 c64/kernal/{stubs => ,stubs}/e9ff.interop | 0 c64/kernal/{stubs => ,stubs}/f646.iec_close.s | 0 c64/kernal/{stubs => ,stubs}/f646.interop | 0 c64/kernal/{stubs => ,stubs}/fd90.interop | 0 c64/kernal/{stubs => ,stubs}/fd90.unknown.s | 0 c64/kernal/f333.clrchn.jmp.s | 6 --- c64/kernal/{ => iec}/ciout.s | 8 ++++ c64/kernal/iec/clrchn_iec.s | 30 ++++++++++++++ .../{clrchn_real.s => iostack/f333.clrchn.s} | 26 +++++------- c64/kernal/{ => iostack}/f333.interop | 0 .../udtim.s => keyboard/udtim_keyboard.s} | 37 ++--------------- c64/kernal/{ => memory}/fd15.interop | 0 c64/kernal/{ => memory}/fd15.restor.s | 0 c64/kernal/{ => memory}/fe25.interop | 0 c64/kernal/{ => memory}/fe25.memtop.s | 0 c64/kernal/{ => memory}/membot.s | 0 c64/kernal/{ => memory}/under_rom_routines.s | 0 c64/kernal/{ => memory}/vector_real.s | 0 c64/kernal/{ => rom_revision}/ff80.interop | 0 .../{ => rom_revision}/ff80.kernal_revision.s | 0 c64/kernal/{ => time}/rdtim.s | 0 c64/kernal/{ => time}/settim.s | 0 c64/kernal/time/udtim.s | 41 +++++++++++++++++++ 41 files changed, 131 insertions(+), 82 deletions(-) rename c64/kernal/{stubs => ,stubs}/e566.home_cursor.s (100%) rename c64/kernal/{stubs => ,stubs}/e566.interop (100%) rename c64/kernal/{stubs => ,stubs}/e6b6.advance_cursor.s (100%) rename c64/kernal/{stubs => ,stubs}/e6b6.interop (100%) rename c64/kernal/{stubs => ,stubs}/e701.interop (100%) rename c64/kernal/{stubs => ,stubs}/e701.previous_line.s (100%) rename c64/kernal/{stubs => ,stubs}/e716.chrout_screen.s (100%) rename c64/kernal/{stubs => ,stubs}/e716.interop (100%) rename c64/kernal/{stubs => ,stubs}/e8ea.interop (100%) rename c64/kernal/{stubs => ,stubs}/e8ea.scroll_line.s (100%) rename c64/kernal/{stubs => ,stubs}/e96c.insert_line_at_top.s (100%) rename c64/kernal/{stubs => ,stubs}/e96c.interop (100%) rename c64/kernal/{stubs => ,stubs}/e9ff.clear_line.s (100%) rename c64/kernal/{stubs => ,stubs}/e9ff.interop (100%) rename c64/kernal/{stubs => ,stubs}/f646.iec_close.s (100%) rename c64/kernal/{stubs => ,stubs}/f646.interop (100%) rename c64/kernal/{stubs => ,stubs}/fd90.interop (100%) rename c64/kernal/{stubs => ,stubs}/fd90.unknown.s (100%) delete mode 100644 c64/kernal/f333.clrchn.jmp.s rename c64/kernal/{ => iec}/ciout.s (91%) create mode 100644 c64/kernal/iec/clrchn_iec.s rename c64/kernal/{clrchn_real.s => iostack/f333.clrchn.s} (59%) rename c64/kernal/{ => iostack}/f333.interop (100%) rename c64/kernal/{interrupts/udtim.s => keyboard/udtim_keyboard.s} (61%) rename c64/kernal/{ => memory}/fd15.interop (100%) rename c64/kernal/{ => memory}/fd15.restor.s (100%) rename c64/kernal/{ => memory}/fe25.interop (100%) rename c64/kernal/{ => memory}/fe25.memtop.s (100%) rename c64/kernal/{ => memory}/membot.s (100%) rename c64/kernal/{ => memory}/under_rom_routines.s (100%) rename c64/kernal/{ => memory}/vector_real.s (100%) rename c64/kernal/{ => rom_revision}/ff80.interop (100%) rename c64/kernal/{ => rom_revision}/ff80.kernal_revision.s (100%) rename c64/kernal/{ => time}/rdtim.s (100%) rename c64/kernal/{ => time}/settim.s (100%) create mode 100644 c64/kernal/time/udtim.s diff --git a/Makefile b/Makefile index 931d9c24..5e0b8662 100644 --- a/Makefile +++ b/Makefile @@ -11,16 +11,20 @@ SRCDIR_BASIC = $(SRCDIR_COMMON) \ SRCDIR_KERNAL = $(SRCDIR_COMMON) \ c64/kernal \ + c64/kernal/,stubs \ c64/kernal/assets \ - c64/kernal/jumptable \ c64/kernal/iec \ c64/kernal/init \ c64/kernal/interrupts \ c64/kernal/iostack \ + c64/kernal/jumptable \ c64/kernal/keyboard \ + c64/kernal/memory \ c64/kernal/print \ + c64/kernal/rom_revision \ c64/kernal/screen \ - c64/kernal/stubs + c64/kernal/time + SRC_TOOLS = $(wildcard src/tools/*.c,src/tools/*.cc) @@ -65,14 +69,16 @@ GIT_COMMIT:= $(shell git log -1 --pretty='%h' | tr '[:lower:]' '[:upper:]') .PHONY: all clean updatebin -all: $(STD_TARGET_LIST) $(EXT_TARGET_LIST) +all: + $(MAKE) -j64 --output-sync=target $(STD_TARGET_LIST) $(EXT_TARGET_LIST) clean: @rm -rf build -updatebin: $(STD_TARGET_LIST) $(TOOL_RELEASE) +updatebin: + $(MAKE) -j64 --output-sync=target $(STD_TARGET_LIST) $(TOOL_RELEASE) $(TOOL_RELEASE) -i ./build -o ./bin basic_generic.rom kernal_generic.rom basic_testing.rom kernal_testing.rom basic_mega65.rom kernal_mega65.rom basic_ultimate64.rom kernal_ultimate64.rom - cp build/chargen.rom bin/chargen.rom + cp build/chargen.rom bin/chargen.rom # Rules - tools diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index 62588e3f..e5920bef 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -40,9 +40,10 @@ // I/O devices -#define CONFIG_IEC // please keep enabled for now -// #define CONFIG_TAPE // please keep disabled for now -// #define CONFIG_RS_232 // please keep disabled for now +#define CONFIG_IEC // please keep enabled for now +// #define CONFIG_TAPE_NORMAL // please keep disabled for now +// #define CONFIG_TAPE_TURBO // please keep disabled for now +// #define CONFIG_RS232_USERPORT // please keep disabled for now // Multiple SID support @@ -62,8 +63,8 @@ // #define CONFIG_LEGACY_SCNKEY #define CONFIG_KEYBOARD_C128 #define CONFIG_KEYBOARD_C128_CAPS_LOCK -// #define CONFIG_KEYBOARD_C65 // untested -// #define CONFIG_KEYBOARD_C65_CAPS_LOCK // untested +// #define CONFIG_KEYBOARD_C65 // untested +// #define CONFIG_KEYBOARD_C65_CAPS_LOCK // untested // #define CONFIG_KEY_REPEAT_DEFAULT // #define CONFIG_KEY_REPEAT_ALWAYS #define CONFIG_KEY_FAST_SCAN diff --git a/c64/,,config_mega65.s b/c64/,,config_mega65.s index 57c09be7..441f6b48 100644 --- a/c64/,,config_mega65.s +++ b/c64/,,config_mega65.s @@ -42,9 +42,10 @@ // I/O devices -#define CONFIG_IEC // please keep enabled for now -// #define CONFIG_TAPE // please keep disabled for now -// #define CONFIG_RS_232 // please keep disabled for now +#define CONFIG_IEC // please keep enabled for now +// #define CONFIG_TAPE_NORMAL // please keep disabled for now +// #define CONFIG_TAPE_TURBO // please keep disabled for now +// #define CONFIG_RS232_USERPORT // please keep disabled for now // Multiple SID support @@ -53,7 +54,7 @@ .const CONFIG_SID_2ND_ADDRESS = $D440 // #define CONFIG_SID_3RD -.const CONFIG_SID_3RD_ADDRESS = $D420 +.const CONFIG_SID_3RD_ADDRESS = $D480 // #define CONFIG_SID_D4XX // #define CONFIG_SID_D5XX @@ -64,8 +65,8 @@ // #define CONFIG_LEGACY_SCNKEY // #define CONFIG_KEYBOARD_C128 // #define CONFIG_KEYBOARD_C128_CAPS_LOCK -#define CONFIG_KEYBOARD_C65 // untested -#define CONFIG_KEYBOARD_C65_CAPS_LOCK // untested +#define CONFIG_KEYBOARD_C65 // untested +#define CONFIG_KEYBOARD_C65_CAPS_LOCK // untested // #define CONFIG_KEY_REPEAT_DEFAULT // #define CONFIG_KEY_REPEAT_ALWAYS #define CONFIG_KEY_FAST_SCAN diff --git a/c64/,,config_testing.s b/c64/,,config_testing.s index 8393da38..50130b12 100644 --- a/c64/,,config_testing.s +++ b/c64/,,config_testing.s @@ -41,9 +41,10 @@ // I/O devices -#define CONFIG_IEC // please keep enabled for now -// #define CONFIG_TAPE // please keep disabled for now -// #define CONFIG_RS_232 // please keep disabled for now +#define CONFIG_IEC // please keep enabled for now +// #define CONFIG_TAPE_NORMAL // please keep disabled for now +// #define CONFIG_TAPE_TURBO // please keep disabled for now +// #define CONFIG_RS232_USERPORT // please keep disabled for now // Multiple SID support @@ -51,7 +52,7 @@ #define CONFIG_SID_2ND .const CONFIG_SID_2ND_ADDRESS = $D420 -// #define CONFIG_SID_3RD +#define CONFIG_SID_3RD .const CONFIG_SID_3RD_ADDRESS = $D440 // #define CONFIG_SID_D4XX @@ -63,8 +64,8 @@ #define CONFIG_LEGACY_SCNKEY // #define CONFIG_KEYBOARD_C128 // #define CONFIG_KEYBOARD_C128_CAPS_LOCK -// #define CONFIG_KEYBOARD_C65 // untested -// #define CONFIG_KEYBOARD_C65_CAPS_LOCK // untested +// #define CONFIG_KEYBOARD_C65 // untested +// #define CONFIG_KEYBOARD_C65_CAPS_LOCK // untested // #define CONFIG_KEY_REPEAT_DEFAULT // #define CONFIG_KEY_REPEAT_ALWAYS #define CONFIG_KEY_FAST_SCAN diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index d36e6723..5d9d4a07 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -40,9 +40,10 @@ // I/O devices -#define CONFIG_IEC // please keep enabled for now -// #define CONFIG_TAPE // please keep disabled for now -// #define CONFIG_RS_232 // please keep disabled for now +#define CONFIG_IEC // please keep enabled for now +// #define CONFIG_TAPE_NORMAL // please keep disabled for now +// #define CONFIG_TAPE_TURBO // please keep disabled for now +// #define CONFIG_RS232_USERPORT // please keep disabled for now // Multiple SID support @@ -62,8 +63,8 @@ // #define CONFIG_LEGACY_SCNKEY // #define CONFIG_KEYBOARD_C128 // #define CONFIG_KEYBOARD_C128_CAPS_LOCK -// #define CONFIG_KEYBOARD_C65 // untested -// #define CONFIG_KEYBOARD_C65_CAPS_LOCK // untested +// #define CONFIG_KEYBOARD_C65 // untested +// #define CONFIG_KEYBOARD_C65_CAPS_LOCK // untested // #define CONFIG_KEY_REPEAT_DEFAULT // #define CONFIG_KEY_REPEAT_ALWAYS #define CONFIG_KEY_FAST_SCAN @@ -92,6 +93,7 @@ .const CONFIG_KEYCMD_F13 = @"" .const CONFIG_KEYCMD_F14 = @"" + // Eye candy #define CONFIG_COLORS_BRAND diff --git a/c64/kernal/stubs/e566.home_cursor.s b/c64/kernal/,stubs/e566.home_cursor.s similarity index 100% rename from c64/kernal/stubs/e566.home_cursor.s rename to c64/kernal/,stubs/e566.home_cursor.s diff --git a/c64/kernal/stubs/e566.interop b/c64/kernal/,stubs/e566.interop similarity index 100% rename from c64/kernal/stubs/e566.interop rename to c64/kernal/,stubs/e566.interop diff --git a/c64/kernal/stubs/e6b6.advance_cursor.s b/c64/kernal/,stubs/e6b6.advance_cursor.s similarity index 100% rename from c64/kernal/stubs/e6b6.advance_cursor.s rename to c64/kernal/,stubs/e6b6.advance_cursor.s diff --git a/c64/kernal/stubs/e6b6.interop b/c64/kernal/,stubs/e6b6.interop similarity index 100% rename from c64/kernal/stubs/e6b6.interop rename to c64/kernal/,stubs/e6b6.interop diff --git a/c64/kernal/stubs/e701.interop b/c64/kernal/,stubs/e701.interop similarity index 100% rename from c64/kernal/stubs/e701.interop rename to c64/kernal/,stubs/e701.interop diff --git a/c64/kernal/stubs/e701.previous_line.s b/c64/kernal/,stubs/e701.previous_line.s similarity index 100% rename from c64/kernal/stubs/e701.previous_line.s rename to c64/kernal/,stubs/e701.previous_line.s diff --git a/c64/kernal/stubs/e716.chrout_screen.s b/c64/kernal/,stubs/e716.chrout_screen.s similarity index 100% rename from c64/kernal/stubs/e716.chrout_screen.s rename to c64/kernal/,stubs/e716.chrout_screen.s diff --git a/c64/kernal/stubs/e716.interop b/c64/kernal/,stubs/e716.interop similarity index 100% rename from c64/kernal/stubs/e716.interop rename to c64/kernal/,stubs/e716.interop diff --git a/c64/kernal/stubs/e8ea.interop b/c64/kernal/,stubs/e8ea.interop similarity index 100% rename from c64/kernal/stubs/e8ea.interop rename to c64/kernal/,stubs/e8ea.interop diff --git a/c64/kernal/stubs/e8ea.scroll_line.s b/c64/kernal/,stubs/e8ea.scroll_line.s similarity index 100% rename from c64/kernal/stubs/e8ea.scroll_line.s rename to c64/kernal/,stubs/e8ea.scroll_line.s diff --git a/c64/kernal/stubs/e96c.insert_line_at_top.s b/c64/kernal/,stubs/e96c.insert_line_at_top.s similarity index 100% rename from c64/kernal/stubs/e96c.insert_line_at_top.s rename to c64/kernal/,stubs/e96c.insert_line_at_top.s diff --git a/c64/kernal/stubs/e96c.interop b/c64/kernal/,stubs/e96c.interop similarity index 100% rename from c64/kernal/stubs/e96c.interop rename to c64/kernal/,stubs/e96c.interop diff --git a/c64/kernal/stubs/e9ff.clear_line.s b/c64/kernal/,stubs/e9ff.clear_line.s similarity index 100% rename from c64/kernal/stubs/e9ff.clear_line.s rename to c64/kernal/,stubs/e9ff.clear_line.s diff --git a/c64/kernal/stubs/e9ff.interop b/c64/kernal/,stubs/e9ff.interop similarity index 100% rename from c64/kernal/stubs/e9ff.interop rename to c64/kernal/,stubs/e9ff.interop diff --git a/c64/kernal/stubs/f646.iec_close.s b/c64/kernal/,stubs/f646.iec_close.s similarity index 100% rename from c64/kernal/stubs/f646.iec_close.s rename to c64/kernal/,stubs/f646.iec_close.s diff --git a/c64/kernal/stubs/f646.interop b/c64/kernal/,stubs/f646.interop similarity index 100% rename from c64/kernal/stubs/f646.interop rename to c64/kernal/,stubs/f646.interop diff --git a/c64/kernal/stubs/fd90.interop b/c64/kernal/,stubs/fd90.interop similarity index 100% rename from c64/kernal/stubs/fd90.interop rename to c64/kernal/,stubs/fd90.interop diff --git a/c64/kernal/stubs/fd90.unknown.s b/c64/kernal/,stubs/fd90.unknown.s similarity index 100% rename from c64/kernal/stubs/fd90.unknown.s rename to c64/kernal/,stubs/fd90.unknown.s diff --git a/c64/kernal/f333.clrchn.jmp.s b/c64/kernal/f333.clrchn.jmp.s deleted file mode 100644 index 7c56fe28..00000000 --- a/c64/kernal/f333.clrchn.jmp.s +++ /dev/null @@ -1,6 +0,0 @@ - -// 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/ciout.s b/c64/kernal/iec/ciout.s similarity index 91% rename from c64/kernal/ciout.s rename to c64/kernal/iec/ciout.s index 3d84170c..9250c55c 100644 --- a/c64/kernal/ciout.s +++ b/c64/kernal/iec/ciout.s @@ -11,6 +11,8 @@ CIOUT: +#if CONFIG_IEC + pha lda C3PO bne ciout_send_byte @@ -35,3 +37,9 @@ ciout_send_byte: inc C3PO // iec_tx_byte sets it to 0, but we still have something to send jmp ciout_store_in_buffer +#else + + sec // indicate failure + rts + +#endif diff --git a/c64/kernal/iec/clrchn_iec.s b/c64/kernal/iec/clrchn_iec.s new file mode 100644 index 00000000..84993a0c --- /dev/null +++ b/c64/kernal/iec/clrchn_iec.s @@ -0,0 +1,30 @@ + +// +// IEC part of the CLRCHN routine +// + + +#if CONFIG_IEC + + +clrchn_iec: + + // Check input device + lda DFLTN + jsr iec_check_devnum_oc + bcs !+ + + // It was IEC device - send UNTALK first + jsr UNTLK +!: + // Check output device + lda DFLTO + jsr iec_check_devnum_oc + + // If it was IEC device - send UNLSN first + bcc_far UNLSN + + rts + + +#endif // CONFIG_IEC diff --git a/c64/kernal/clrchn_real.s b/c64/kernal/iostack/f333.clrchn.s similarity index 59% rename from c64/kernal/clrchn_real.s rename to c64/kernal/iostack/f333.clrchn.s index 845e2cb6..ab94909f 100644 --- a/c64/kernal/clrchn_real.s +++ b/c64/kernal/iostack/f333.clrchn.s @@ -9,26 +9,22 @@ // -clrchn_real: +CLRCHN: + +#if CONFIG_IEC + jsr clrchn_iec +#else + nop // just to prevent double label +#endif + + // FALLTROUGH - // Handle IEC input device - lda DFLTN - jsr iec_check_devnum_oc - bcs !+ - // Previous device was IEC one - send UNTALK first - jsr UNTLK -!: - // Restore output device to default - lda DFLTO - jsr iec_check_devnum_oc - bcs !+ - // Handle IEC output device - jsr UNLSN -!: clrchn_reset: // entry needed by setup_vicii + // Set input device number to keyboard lda #$00 sta DFLTN + // Set output device number to screen lda #$03 sta DFLTO diff --git a/c64/kernal/f333.interop b/c64/kernal/iostack/f333.interop similarity index 100% rename from c64/kernal/f333.interop rename to c64/kernal/iostack/f333.interop diff --git a/c64/kernal/interrupts/udtim.s b/c64/kernal/keyboard/udtim_keyboard.s similarity index 61% rename from c64/kernal/interrupts/udtim.s rename to c64/kernal/keyboard/udtim_keyboard.s index 369b907f..d35f86f6 100644 --- a/c64/kernal/interrupts/udtim.s +++ b/c64/kernal/keyboard/udtim_keyboard.s @@ -1,29 +1,12 @@ // -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmer's Reference Guide - page 303 -// - [CM64] Compute's Mapping the Commodore 64 - pages 27, 232 -// -// CPU registers that has to be preserved (see [RG64]): .Y +// Keyboard part of the UDTIM routine, has to preserve .Y // -UDTIM: - // Update jiffy clock. The whole day is $4F1A00 jiffies (24 hours * 60 minutes * 60 seconds * 60 jiffies), - // after this time we have to reset the clock. +udtim_keyboard: - inc TIME+0 - bne udtim_update_stkey // done with clock - inc TIME+1 - bne udtim_clock_rollover - inc TIME+2 - - // FALLTROUGH - -udtim_update_stkey: // entry to be used when interrupts are disabled - - // According to [CM64], page 27, another action we have to perform is to copy + // According to [CM64], page 27, the action we have to perform is to copy // the last row of keyboard to RAM, so that various routines can detect the STOP // key press. But something as simple as this would have created warm restart // with M+N+SPACE+RESTORE due to ghosting - so the original ROM has to provide @@ -65,17 +48,3 @@ udtim_update_stkey: // entry to be used when interrupts are disabled // unable to, for example, read the space bar status. rts - -udtim_clock_rollover: - - // At this point TIME+0 contains 0 - lda TIME+1 - cmp #$1A - bne udtim_update_stkey // done with clock - lda TIME+2 - cmp #$4F - bne udtim_update_stkey // done with clock - lda #$00 - sta TIME+2 - sta TIME+1 - beq udtim_update_stkey // done with clock - will always jump diff --git a/c64/kernal/fd15.interop b/c64/kernal/memory/fd15.interop similarity index 100% rename from c64/kernal/fd15.interop rename to c64/kernal/memory/fd15.interop diff --git a/c64/kernal/fd15.restor.s b/c64/kernal/memory/fd15.restor.s similarity index 100% rename from c64/kernal/fd15.restor.s rename to c64/kernal/memory/fd15.restor.s diff --git a/c64/kernal/fe25.interop b/c64/kernal/memory/fe25.interop similarity index 100% rename from c64/kernal/fe25.interop rename to c64/kernal/memory/fe25.interop diff --git a/c64/kernal/fe25.memtop.s b/c64/kernal/memory/fe25.memtop.s similarity index 100% rename from c64/kernal/fe25.memtop.s rename to c64/kernal/memory/fe25.memtop.s diff --git a/c64/kernal/membot.s b/c64/kernal/memory/membot.s similarity index 100% rename from c64/kernal/membot.s rename to c64/kernal/memory/membot.s diff --git a/c64/kernal/under_rom_routines.s b/c64/kernal/memory/under_rom_routines.s similarity index 100% rename from c64/kernal/under_rom_routines.s rename to c64/kernal/memory/under_rom_routines.s diff --git a/c64/kernal/vector_real.s b/c64/kernal/memory/vector_real.s similarity index 100% rename from c64/kernal/vector_real.s rename to c64/kernal/memory/vector_real.s diff --git a/c64/kernal/ff80.interop b/c64/kernal/rom_revision/ff80.interop similarity index 100% rename from c64/kernal/ff80.interop rename to c64/kernal/rom_revision/ff80.interop diff --git a/c64/kernal/ff80.kernal_revision.s b/c64/kernal/rom_revision/ff80.kernal_revision.s similarity index 100% rename from c64/kernal/ff80.kernal_revision.s rename to c64/kernal/rom_revision/ff80.kernal_revision.s diff --git a/c64/kernal/rdtim.s b/c64/kernal/time/rdtim.s similarity index 100% rename from c64/kernal/rdtim.s rename to c64/kernal/time/rdtim.s diff --git a/c64/kernal/settim.s b/c64/kernal/time/settim.s similarity index 100% rename from c64/kernal/settim.s rename to c64/kernal/time/settim.s diff --git a/c64/kernal/time/udtim.s b/c64/kernal/time/udtim.s new file mode 100644 index 00000000..65dc6aaf --- /dev/null +++ b/c64/kernal/time/udtim.s @@ -0,0 +1,41 @@ + +// +// Official Kernal routine, described in: +// +// - [RG64] C64 Programmer's Reference Guide - page 303 +// - [CM64] Compute's Mapping the Commodore 64 - pages 27, 232 +// +// CPU registers that has to be preserved (see [RG64]): .Y +// + +UDTIM: + + // Update jiffy clock. The whole day is $4F1A00 jiffies + // (24 hours * 60 minutes * 60 seconds * 60 jiffies), + // after this time we have to reset the clock. + + inc TIME+0 + bne udtim_time_done // done with clock + inc TIME+1 + bne udtim_clock_rollover + inc TIME+2 + + // FALLTROUGH + +udtim_time_done: + + jmp udtim_keyboard + +udtim_clock_rollover: + + // At this point TIME+0 contains 0 + lda TIME+1 + cmp #$1A + bne udtim_time_done // done with clock + lda TIME+2 + cmp #$4F + bne udtim_time_done // done with clock + lda #$00 + sta TIME+2 + sta TIME+1 + beq udtim_time_done // done with clock - will always jump