From dc63912edddca123ebb67ed67933cb59fa71c1fb Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 20 Oct 2019 09:03:23 +0200 Subject: [PATCH] even more startup tweaks --- c64/kernal/init/cint_real.s | 21 ++++++++++++------- c64/kernal/init/e5a0.setup_vicii.s | 2 -- .../fce2.hw_entry_reset.s | 14 +++++++++---- c64/kernal/{interrupts => init}/fce2.interop | 0 c64/kernal/init/fda3.ioinit.s | 2 +- c64/kernal/{ => init}/ramtas_real.s | 0 .../interrupts/fe66.default_brk_handler.s | 5 +++++ c64/kernal/{ => iostack}/findfls.s | 2 +- 8 files changed, 30 insertions(+), 16 deletions(-) rename c64/kernal/{interrupts => init}/fce2.hw_entry_reset.s (73%) rename c64/kernal/{interrupts => init}/fce2.interop (100%) rename c64/kernal/{ => init}/ramtas_real.s (100%) rename c64/kernal/{ => iostack}/findfls.s (92%) diff --git a/c64/kernal/init/cint_real.s b/c64/kernal/init/cint_real.s index 82cbc77f..2c4722a4 100644 --- a/c64/kernal/init/cint_real.s +++ b/c64/kernal/init/cint_real.s @@ -56,18 +56,16 @@ cint_pal: !: sta TVSFLG - // Setup KEYLOG vector - XXX is it proper place? +cint_brk: // entry for BRK and STOP+RESTORE - XXX, where should it start? + + // Setup KEYLOG vector lda #scnkey_set_keytab sta KEYLOG+1 -cint_brk: // entry for BRK and STOP+RESTORE - XXX, where should it start? - - jsr setup_vicii - - // Initialise cursor blink flags (Compute's Mapping the 64 p215) + // Initialise cursor blink flags (Compute's Mapping the 64 p215) lda #$01 sta BLNCT @@ -93,15 +91,18 @@ cint_brk: // entry for BRK and STOP+RESTORE - XXX, where should it start? dex bpl !- sta BufferQuantity - -#endif // Set key repeat delay (Compute's Mapping the 64 p215) // Making some numbers up here: Repeat every ~1/10th sec // But require key to be held for ~1/3sec before // repeating (Compute's Mapping the 64 p58) + + // Not needed for default keyboard scanning code + ldx #22-2 // Fudge factor to match speed stx DELAY + +#endif // Set current colour for text (Compute's Mapping the 64 p215) ldx #$01 // default is light blue ($0E), but we use a different one @@ -115,5 +116,9 @@ cint_brk: // entry for BRK and STOP+RESTORE - XXX, where should it start? ldx #$00 stx MODE + // Setup video and I/O + jsr setup_vicii + // Fallthrough/jump to screen clear routine (Compute's Mapping the 64 p215) + jmp clear_screen diff --git a/c64/kernal/init/e5a0.setup_vicii.s b/c64/kernal/init/e5a0.setup_vicii.s index 3cc68a93..bd3d7d52 100644 --- a/c64/kernal/init/e5a0.setup_vicii.s +++ b/c64/kernal/init/e5a0.setup_vicii.s @@ -8,8 +8,6 @@ setup_vicii: - // XXX it should also set default devices - // Clear everything - turn off sprites (observed hanging around after // running programs and resetting), etc. diff --git a/c64/kernal/interrupts/fce2.hw_entry_reset.s b/c64/kernal/init/fce2.hw_entry_reset.s similarity index 73% rename from c64/kernal/interrupts/fce2.hw_entry_reset.s rename to c64/kernal/init/fce2.hw_entry_reset.s index f04dd653..e0a3793e 100644 --- a/c64/kernal/interrupts/fce2.hw_entry_reset.s +++ b/c64/kernal/init/fce2.hw_entry_reset.s @@ -5,12 +5,18 @@ hw_entry_reset: // The GPL program at https://github.com/Klaus2m5/6502_65C02_functional_tests/blob/master/6502_functional_test.a65 - // uses the following initial reset sequence, affirmed by c64 PRG p269 + // uses the similar initial reset sequence, affirmed by c64 PRG p269 - cld // for CPUs might clear D flag - but it is possible this is called manually - ldx #$FF + sei // disable the interrupts, as fast as possible - they are disabled in case of HW reset, + // but this routine can be also called manually + + ldx #$00 + sta VIC_SCROLX // turn the display off - we want as little screen artifacts as possible + + cld // required for all CPUs - due to possibility of manual call + + dex // $FF - to initialize stack pointer txs - sei // The following routine is based on reading the public KERNAL jumptable routine // list, and making unimaginative assumptions about what should be done on reset. diff --git a/c64/kernal/interrupts/fce2.interop b/c64/kernal/init/fce2.interop similarity index 100% rename from c64/kernal/interrupts/fce2.interop rename to c64/kernal/init/fce2.interop diff --git a/c64/kernal/init/fda3.ioinit.s b/c64/kernal/init/fda3.ioinit.s index 0203d315..28437fe5 100644 --- a/c64/kernal/init/fda3.ioinit.s +++ b/c64/kernal/init/fda3.ioinit.s @@ -13,7 +13,7 @@ IOINIT: // Set $00/$01 port mode and value // We want BASIC and KERNAL ROMs mapped, and datasette motor off // (https://www.c64-wiki.com/wiki/Zeropage) - // XXX - Work around VICE bug: Writing $00 before $01 results in rubbish in $01 + // Work around for VICE bug: Writing $00 before $01 results in rubbish in $01 // after. https://sourceforge.net/p/vice-emu/bugs/1057/ lda #$27 ldx #$2F diff --git a/c64/kernal/ramtas_real.s b/c64/kernal/init/ramtas_real.s similarity index 100% rename from c64/kernal/ramtas_real.s rename to c64/kernal/init/ramtas_real.s diff --git a/c64/kernal/interrupts/fe66.default_brk_handler.s b/c64/kernal/interrupts/fe66.default_brk_handler.s index 75d1b4f4..53d70783 100644 --- a/c64/kernal/interrupts/fe66.default_brk_handler.s +++ b/c64/kernal/interrupts/fe66.default_brk_handler.s @@ -5,6 +5,11 @@ default_brk_handler: sei // disable IRQs, to be sure they won't interfere + ldx #$00 + sta VIC_SCROLX // turn the display off - we want as little screen artifacts as possible + + cld // make sure this dangerous flag is disabled + jsr JRESTOR jsr JIOINIT jsr cint_brk diff --git a/c64/kernal/findfls.s b/c64/kernal/iostack/findfls.s similarity index 92% rename from c64/kernal/findfls.s rename to c64/kernal/iostack/findfls.s index f9cefadd..874fad51 100644 --- a/c64/kernal/findfls.s +++ b/c64/kernal/iostack/findfls.s @@ -1,5 +1,5 @@ -// Just a helper routines +// Just a helper routine // Find the LAT / SAT / FAT entry index where LAT corresponds to A, returns index in Y // Carry flag set means not found