; set up system tick timer
xor a
out0 (TIME_TCR), a
- ld hl, #(CPU_CLOCK_KHZ * (1000/20) / TICKSPERSEC) ; timer ticks at PHI/20
+ ld hl, #((CPU_CLOCK_KHZ * (1000/Z180_TIMER_SCALE) / TICKSPERSEC) - 1)
out0 (TIME_RLDR0L), l
out0 (TIME_RLDR0H), h
ld a, #0x11 ; enable downcounting and interrupts for timer 0 only
; (18.432MHz) but this made the machine unstable.
USE_FANCY_MONITOR .equ 1 ; disabling this saves around 0.5KB
CPU_CLOCK_KHZ .equ 16000 ; 16MHz is the stock crystal
+Z180_TIMER_SCALE .equ 10 ; CPU clocks per timer tick
TICKSPERSEC .equ 40 ; timer interrupt rate (Hz)
PROGBASE .equ 0x0000