1
0
mirror of https://github.com/cc65/cc65.git synced 2025-02-06 12:31:12 +00:00

CX16 waitvsync uses Kernal API to retreive jiffies

This commit is contained in:
ZeroByteOrg 2022-08-05 17:44:18 -05:00
parent 4de40a20cb
commit 78870219a4

View File

@ -5,17 +5,20 @@
; /* Wait for the start of the next video field. */ ; /* Wait for the start of the next video field. */
; ;
; VERA's vertical sync causes IRQs which increment the jiffy timer. ; VERA's vertical sync causes IRQs which increment the jiffy timer.
;
; Updated by ZeroByteOrg to use Kernal API RDTIM to retreive the TIMER variable
; ;
.export _waitvsync .export _waitvsync
.include "cx16.inc" .proc _waitvsync: near
RDTIM = $FFDE ; Kernal API for reading the jiffy timer
_waitvsync: jsr RDTIM
ldx RAM_BANK ; (TIMER is in RAM bank 0) sta lastjiffy
stz RAM_BANK keep_waiting:
lda TIMER + 2 jsr RDTIM
: cmp TIMER + 2 cmp #$FF ; self-mod the value returned by RDTIM to save memory
beq :- ; Wait for next jiffy lastjiffy=(*-1)
stx RAM_BANK beq keep_waiting
rts rts
.endproc