set IRQ frequency depending on video system
This commit is contained in:
1 parent
c16b4cb4bc
commit
79c09d9793
7 files changed
+78
-51
No files matched your search
@@ -27,8 +27,7 @@ The following ROM features are currently missing:
|
||||
* tape support
|
||||
* RS-232 support
|
||||
* breaking Kernal routines with RUN/STOP key
|
||||
* BRK handling
|
||||
* PAL/NTSC is detected, but for now only startup banner uses the result
|
||||
* BRK handling; NMI/IRQ handling is incomplete
|
||||
|
||||
Features currently being worked on:
|
||||
|
||||
@@ -73,7 +72,7 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on
|
||||
| Address | Name | Status | Remarks |
|
||||
| --------- | :------- | :------: | :------------------------------------------------: |
|
||||
| `$FF81` | `CINT` | DONE | |
|
||||
| `$FF84` | `IOINIT` | DONE | |
|
||||
| `$FF84` | `IOINIT` | PARTIAL | CIA initialization incomplete |
|
||||
| `$FF87` | `RAMTAS` | DONE | |
|
||||
| `$FF8A` | `RESTOR` | DONE | |
|
||||
| `$FF8D` | `VECTOR` | DONE | |
|
||||
|
||||
+1
-25
@@ -14,31 +14,7 @@ cint:
|
||||
cint_brk: ; entry for BRK and STOP+RESTORE - XXX, where should it start?
|
||||
|
||||
jsr setup_vicii
|
||||
|
||||
;; 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
|
||||
|
||||
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:
|
||||
lda #$00
|
||||
beq +
|
||||
cint_pal:
|
||||
lda #$01
|
||||
*
|
||||
sta PALNTSC
|
||||
jsr setup_pal_ntsc
|
||||
|
||||
;; Initialise cursor blink flags (Compute's Mapping the 64 p215)
|
||||
lda #$00
|
||||
|
||||
+40
-21
@@ -34,35 +34,54 @@ ioinit:
|
||||
cpy #$80 ; $20 * amount of chips to silence, $80 to silence 4 chips
|
||||
bne -
|
||||
|
||||
;; Enable CIA1 IRQ and ~50Hz timer
|
||||
;; (https://csdb.dk/forums/?roomid=11&topicid=69037)
|
||||
lda #$7f
|
||||
sta $DC0D ; First disable all
|
||||
;; 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
|
||||
jsr setup_pal_ntsc
|
||||
|
||||
;; (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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ default_nmi_handler:
|
||||
|
||||
;; 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)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
;;
|
||||
;; 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
|
||||
;;
|
||||
|
||||
setup_pal_ntsc:
|
||||
|
||||
lda VIC_RASTER
|
||||
setup_pal_ntsc_w1:
|
||||
cmp VIC_RASTER
|
||||
beq setup_pal_ntsc_w1
|
||||
bmi setup_pal_ntsc
|
||||
|
||||
;; 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 setup_pal
|
||||
|
||||
setup_ntsc:
|
||||
lda #$00
|
||||
beq +
|
||||
|
||||
setup_pal:
|
||||
lda #$01
|
||||
*
|
||||
sta PALNTSC
|
||||
rts
|
||||
Reference in new issue
Block a user