kthacker | 62e146c | 2006-04-17 15:11:35 +0000 | [diff] [blame] | 1 | ; unsigned char kbhit (void); |
| 2 | ; Return true if there's a key waiting, return false if not |
| 3 | ; TESTED |
| 4 | |
| 5 | .globl _kbhit |
| 6 | .area _CODE |
| 7 | _kbhit:: |
| 8 | call 0xBB09 ; KM READ KEY |
| 9 | ld (key),a |
PulkoMandy | 3783e42 | 2023-05-02 17:40:17 +0200 | [diff] [blame] | 10 | ld a,#1 |
kthacker | 62e146c | 2006-04-17 15:11:35 +0000 | [diff] [blame] | 11 | ret c |
PulkoMandy | 3783e42 | 2023-05-02 17:40:17 +0200 | [diff] [blame] | 12 | ld a,#0 |
kthacker | 62e146c | 2006-04-17 15:11:35 +0000 | [diff] [blame] | 13 | ret |
| 14 | |
| 15 | ; char cgetc (void); |
| 16 | ; Return a character from the keyboard. If there is no character available, |
| 17 | ; the functions waits until the user does press a key. If cursor is set to |
| 18 | ; 1 (see below), a blinking cursor is displayed while waiting. |
| 19 | ; TESTED |
| 20 | |
| 21 | .globl _cgetc |
| 22 | |
| 23 | _cgetc:: |
| 24 | ld a,(key) |
kthacker | 62e146c | 2006-04-17 15:11:35 +0000 | [diff] [blame] | 25 | ret |
| 26 | |
| 27 | ;; call 0xBB09 |
| 28 | ;; jr nc,_cgetc |
| 29 | ;; ld l,a |
| 30 | ;; ret |
| 31 | |
| 32 | key: .db 0 |