diff options
author | B. Watson <yalhcru@gmail.com> | 2016-01-27 01:09:14 -0500 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2016-01-27 01:09:14 -0500 |
commit | a49fd87eab6cb615ef283267515a6c97d080027a (patch) | |
tree | 762cfa222e74e0b3517c20916629ec269b64f860 | |
parent | ee56543e38c10c2391012d9222f78f44552cd77c (diff) | |
download | taipan-a49fd87eab6cb615ef283267515a6c97d080027a.tar.gz |
merge timed_getch.s and jsleep.s, preparing to change timed_getch() API
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | jsleep.s | 11 | ||||
-rw-r--r-- | timed_getch.s | 26 |
3 files changed, 24 insertions, 15 deletions
@@ -89,7 +89,7 @@ XEX=taipan.xex # All the C and asm sources for taimain.xex: TAIMAIN_HDRS=sounds.h TAIMAIN_C_SRC=taipan.c -TAIMAIN_ASM_SRC=rand.s draw_lorcha.s timed_getch.s jsleep.s portstat.s clrtobot.s ultostr.s soundasm.s +TAIMAIN_ASM_SRC=rand.s draw_lorcha.s timed_getch.s portstat.s clrtobot.s ultostr.s soundasm.s # Comment these lines out to build without big number support. # This will stop being possible at some point. diff --git a/jsleep.s b/jsleep.s deleted file mode 100644 index e052ddd..0000000 --- a/jsleep.s +++ /dev/null @@ -1,11 +0,0 @@ - - .export _jsleep - .import _set_jiffy_timer - -_jsleep: - jsr _set_jiffy_timer -wait: - lda 540 - ora 541 - bne wait - rts 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 |