aboutsummaryrefslogtreecommitdiff
path: root/timed_getch.s
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-27 01:09:14 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-27 01:09:14 -0500
commita49fd87eab6cb615ef283267515a6c97d080027a (patch)
tree762cfa222e74e0b3517c20916629ec269b64f860 /timed_getch.s
parentee56543e38c10c2391012d9222f78f44552cd77c (diff)
downloadtaipan-a49fd87eab6cb615ef283267515a6c97d080027a.tar.gz
merge timed_getch.s and jsleep.s, preparing to change timed_getch() API
Diffstat (limited to 'timed_getch.s')
-rw-r--r--timed_getch.s26
1 files changed, 23 insertions, 3 deletions
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