From a49fd87eab6cb615ef283267515a6c97d080027a Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 27 Jan 2016 01:09:14 -0500 Subject: merge timed_getch.s and jsleep.s, preparing to change timed_getch() API --- timed_getch.s | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'timed_getch.s') diff --git a/timed_getch.s b/timed_getch.s index ba3b0a9..1c5b418 100644 --- a/timed_getch.s +++ b/timed_getch.s @@ -1,16 +1,33 @@ - .export _timed_getch, _set_jiffy_timer, _agetc, _numgetc, _yngetc, _lcgetc + .export _timed_getch, _set_jiffy_timer, _agetc, _numgetc + .export _yngetc, _lcgetc, _jsleep .import _cgetc, _cblank, _cursor .include "atari.inc" +; keyboard and timer functions for taipan. + +; sleep for j jiffies. +; extern void __fastcall__ jsleep(unsigned int j); +_jsleep: + jsr _set_jiffy_timer +jiffy_wait: + lda CDTMV3 + ora CDTMV3+1 + bne jiffy_wait + rts + +; extern void __fastcall__ set_jiffy_timer(unsigned int jiffies); _set_jiffy_timer: ; called by jsleep() also. - sei ; disable IRQ while setting timer + sei ; disable IRQ while setting timer (probably overkill) sta CDTMV3 stx CDTMV3+1 cli rts +; like curses timeout() followed by getch(): sleep until either +; a key is pressed or the timer expires. +; extern int __fastcall__ timed_getch(unsigned int jiffies); _timed_getch: jsr _set_jiffy_timer wait4key: @@ -40,7 +57,7 @@ done: ; a control key is pressed, it turns it into the non-control version ; (e.g. ^A = lowercase a). Keys that can't be mapped to regular ASCII ; (such as clear, delete, escape) are replaced with a space. -; extern char lcgetc(); +; extern unsigned char agetc(void); _agetc: lda #1 ; show cursor jsr _cursor @@ -81,6 +98,7 @@ ok: ldx #0 rts +; extern unsigned char lcgetc(void); _lcgetc: jsr _agetc cmp #'A' @@ -90,6 +108,7 @@ _lcgetc: eor #$20 ; lowercase it bcc ok +; extern unsigned char numgetc(void); _numgetc: jsr _agetc cmp #$9b @@ -110,6 +129,7 @@ _numgetc: bcc ok bcs _numgetc +; extern unsigned char __fastcall__ yngetc(char dflt); _yngetc: sta FR0 ; stash default arg jsr _lcgetc -- cgit v1.2.3