diff --git a/c64/kernal/cint.s b/c64/kernal/cint.s index 1fa22258..a99aa08d 100644 --- a/c64/kernal/cint.s +++ b/c64/kernal/cint.s @@ -11,14 +11,55 @@ cint: + ;; According to [CM64], this routine checks for PAL/NTSC. It's definitely not done + ;; within the 'BRK' part, this can be easily checked - POKE something + ;; to address 678 on a real C64, press STOP+RESTORE, the value won't change + + ;; 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 + + lda #$C8 ; preparation, as the VIC might be uninitialized + sta VIC_SCROLX + +cint_w0: + lda VIC_RASTER +cint_w1: + cmp VIC_RASTER + beq cint_w1 + bmi cint_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 cint_pal + +cint_ntsc: + + ;; 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 + + sty CIA1_TIMALO + stx CIA1_TIMAHI + + lda #$00 + beq + + +cint_pal: + + lda #$01 +* + sta PALNTSC + 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 diff --git a/c64/kernal/fda3.ioinit.s b/c64/kernal/fda3.ioinit.s index 3f1a3ba9..7572e3cf 100644 --- a/c64/kernal/fda3.ioinit.s +++ b/c64/kernal/fda3.ioinit.s @@ -34,32 +34,7 @@ ioinit: 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 @@ -81,17 +56,6 @@ ioinit_pal: 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 diff --git a/c64/kernal/reset_entry.s b/c64/kernal/reset_entry.s index 8a6ccabc..e41cd7f3 100644 --- a/c64/kernal/reset_entry.s +++ b/c64/kernal/reset_entry.s @@ -13,14 +13,8 @@ reset_entry: ; The following routine is based on reading the public KERNAL jumptable routine ; list, and making unimaginative assumptions about what should be done on reset. - - ; 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 + ; Also, https://codebase64.org/doku.php?id=base:assembling_your_own_cart_rom_image was used + ; as it shows example startup sequence, to be followe by cartridge creators ; C64 PRG p269 jsr cartridge_check @@ -28,10 +22,12 @@ reset_entry: 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 + ; Setting up the screen and testing ram is obviously required + ; also affirmed by p269 of c64 prg + jsr RAMTAS ; called RANTAM on Codebase64 wiki + ; Resetting IO vectors is obviously required, if we want interrupts to run ; also affirmed by c64 prg p269 jsr RESTOR