2018-08-17 02:45:59 +00:00
|
|
|
|
|
|
|
;-------------------------------------------------------
|
|
|
|
; Usage: TIMER_SETUP lines
|
|
|
|
; where lines is the number of scanlines to skip (> 2).
|
|
|
|
; The timer will be set so that it expires before this number
|
|
|
|
; of scanlines. A WSYNC will be done first.
|
|
|
|
|
|
|
|
MAC TIMER_SETUP
|
|
|
|
.lines SET {1}
|
2018-08-26 13:19:09 +00:00
|
|
|
.cycles SET ((.lines * 76) - 13)
|
|
|
|
; special case for when we have two timer events in a line
|
|
|
|
; and our 2nd event straddles the WSYNC boundary
|
|
|
|
if (.cycles % 64) < 12
|
|
|
|
lda #(.cycles / 64) - 1
|
|
|
|
sta WSYNC
|
|
|
|
else
|
|
|
|
lda #(.cycles / 64)
|
|
|
|
sta WSYNC
|
|
|
|
endif
|
2018-08-17 02:45:59 +00:00
|
|
|
sta TIM64T
|
|
|
|
ENDM
|
|
|
|
|
|
|
|
;-------------------------------------------------------
|
|
|
|
; Use with TIMER_SETUP to wait for timer to complete.
|
2018-08-26 13:19:09 +00:00
|
|
|
; Performs a WSYNC afterwards.
|
2018-08-17 02:45:59 +00:00
|
|
|
|
|
|
|
MAC TIMER_WAIT
|
|
|
|
.waittimer
|
|
|
|
lda INTIM
|
|
|
|
bne .waittimer
|
2018-08-26 13:19:09 +00:00
|
|
|
sta WSYNC
|
2018-08-17 02:45:59 +00:00
|
|
|
ENDM
|