From 78870219a4f10bb0438d3b59d2efb674b8937fbf Mon Sep 17 00:00:00 2001 From: ZeroByteOrg Date: Fri, 5 Aug 2022 17:44:18 -0500 Subject: [PATCH 1/3] CX16 waitvsync uses Kernal API to retreive jiffies --- libsrc/cx16/waitvsync.s | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libsrc/cx16/waitvsync.s b/libsrc/cx16/waitvsync.s index dc0509223..9cd1824cf 100644 --- a/libsrc/cx16/waitvsync.s +++ b/libsrc/cx16/waitvsync.s @@ -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 From 9b3b652fa54093d9e937c22fd8deb0d082094bb8 Mon Sep 17 00:00:00 2001 From: ZeroByteOrg Date: Mon, 8 Aug 2022 15:17:28 -0500 Subject: [PATCH 2/3] Switched to using tmp1 instead of self-mod to store the jiffies value --- libsrc/cx16/waitvsync.s | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libsrc/cx16/waitvsync.s b/libsrc/cx16/waitvsync.s index 9cd1824cf..f8828eec2 100644 --- a/libsrc/cx16/waitvsync.s +++ b/libsrc/cx16/waitvsync.s @@ -10,15 +10,15 @@ ; .export _waitvsync + .importzp tmp1 .proc _waitvsync: near RDTIM = $FFDE ; Kernal API for reading the jiffy timer jsr RDTIM - sta lastjiffy + sta tmp1 keep_waiting: jsr RDTIM - cmp #$FF ; self-mod the value returned by RDTIM to save memory - lastjiffy=(*-1) + cmp tmp1 beq keep_waiting rts .endproc From 582e43931d0a362e4faacea1ccae5a724e3b4edf Mon Sep 17 00:00:00 2001 From: ZeroByteOrg Date: Mon, 8 Aug 2022 15:21:30 -0500 Subject: [PATCH 3/3] import RDTIM symbol instead of hard-wiring it here --- libsrc/cx16/waitvsync.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/cx16/waitvsync.s b/libsrc/cx16/waitvsync.s index f8828eec2..d75a7a735 100644 --- a/libsrc/cx16/waitvsync.s +++ b/libsrc/cx16/waitvsync.s @@ -11,9 +11,9 @@ .export _waitvsync .importzp tmp1 + .import RDTIM .proc _waitvsync: near - RDTIM = $FFDE ; Kernal API for reading the jiffy timer jsr RDTIM sta tmp1 keep_waiting: