aboutsummaryrefslogtreecommitdiff
path: root/timed_getch.s
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-27 16:42:06 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-27 16:42:06 -0500
commita895e5bd48e88a330a0c2e162e7da8161d4b0521 (patch)
tree8ec6543bab2b4fba2b59695901b4f732c07994e6 /timed_getch.s
parenta49fd87eab6cb615ef283267515a6c97d080027a (diff)
downloadtaipan-a895e5bd48e88a330a0c2e162e7da8161d4b0521.tar.gz
timed_getch now uses hardcoded 300 jiffies, all prompts are 5 sec
Diffstat (limited to 'timed_getch.s')
-rw-r--r--timed_getch.s22
1 files changed, 12 insertions, 10 deletions
diff --git a/timed_getch.s b/timed_getch.s
index 1c5b418..9a0f9a1 100644
--- a/timed_getch.s
+++ b/timed_getch.s
@@ -25,31 +25,33 @@ _set_jiffy_timer: ; called by jsleep() also.
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);
+; like curses timeout(5000) followed by getch(): sleep until either
+; a key is pressed or the timer expires. returns 0 if no key pressed.
+; extern char __fastcall__ timed_getch(void);
_timed_getch:
+ lda #$2c ; $012c jiffies = 5 sec (NTSC) or 6 sec (PAL)
+ ldx #$01
jsr _set_jiffy_timer
-wait4key:
+@wait4key:
lda CDTMV3 ; has timer counted down to 0?
ora CDTMV3+1
- beq done ; yes, return(-1)
+ beq @done ; yes, return(0)
lda CH ; no, check for a keypress
; ...but don't let the capslock or inverse keys count
; as a keypress, here.
cmp #$ff ; no key pressed
- beq wait4key
+ beq @wait4key
and #$3f ; mask shift/control bits
cmp #$3c ; caps-lock
- beq wait4key
+ beq @wait4key
cmp #$27 ; inverse (atari) key
- beq wait4key
+ beq @wait4key
jmp _agetc ; user hit a key, read it.
-done:
- lda #$ff ; return -1
+@done:
+ ;lda #$00 ; return(0), A is already 0 here
tax
rts