1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-26 02:30:17 +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. */
;
; 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
.include "cx16.inc"
_waitvsync:
ldx RAM_BANK ; (TIMER is in RAM bank 0)
stz RAM_BANK
lda TIMER + 2
: cmp TIMER + 2
beq :- ; Wait for next jiffy
stx RAM_BANK
rts
.proc _waitvsync: near
RDTIM = $FFDE ; Kernal API for reading the jiffy timer
jsr RDTIM
sta lastjiffy
keep_waiting:
jsr RDTIM
cmp #$FF ; self-mod the value returned by RDTIM to save memory
lastjiffy=(*-1)
beq keep_waiting
rts
.endproc