blob: 795e6f7f22328ffab2cd20cf260dea48f2aa6062 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
; in C:
;; void poll_keyboard(void) {
;; char c;
;;
;; if(!keypress()) return;
;;
;; /* have to latch start status because doing a keyclick clears CONSOL */
;; if(GTIA_READ.consol == 6) start_latch = 1;
;;
;; c = kgetc();
;; if(!c) return;
;;
;; /* maybe this shouldn't happen until user presses Enter in the edbox?
;; would let lurkers lurk and read scrollback... */
;; if(irc_away) {
;; txbuf_send_str("AWAY");
;; irc_away = 0;
;; }
;;
;; if(start_latch) { /* start pressed */
;; start_keystroke(c);
;; } else {
;; edbox_keystroke(c);
;; OS.cdtmv3 = hz / 2;
;; }
;; }
; compiles to ~128 bytes.
.include "atari.inc"
.export _poll_keyboard
.import _keypress, _kgetc, _start_latch, _start_keystroke
.import _edbox_keystroke, _hz, _txbuf_send_str, _irc_away
.rodata
away:
.byte "AWAY",0
.code
_poll_keyboard:
;; if(!keypress()) return;
jsr _keypress
beq @ret ; Z flag set = no keypress
;; if(GTIA_READ.consol == 6) start_latch = 1;
lda CONSOL
cmp #6
bne @nostart
sta _start_latch ; 6, not 1 (doesn't matter so long as it's non-zero)
@nostart:
; c = kgetc();
jsr _kgetc ; note that _kgetc can set _start_latch too
tax ; just to set Z flag based on return value in A
; if(!c) return;
beq @ret ; if _kgetc returned 0, we're done
; if(irc_away) {
ldx _irc_away
beq @noaway
; irc_away = 0;
ldx #0
stx _irc_away
; txbuf_send_str("AWAY");
pha ; _txbuf_send_str will clobber A so stash it
lda #<away
ldx #>away
jsr _txbuf_send_str
; }
pla
@noaway:
; if(start_latch) { /* start pressed */
ldx _start_latch
beq @nolatch
; start_keystroke(c);
ldx #0
jmp _start_keystroke
@nolatch:
; } else {
;;;; ldx #0 ; X already 0
; edbox_keystroke(c);
jsr _edbox_keystroke
; OS.cdtmv3 = hz / 2;
lda _hz
lsr
sta CDTMV3
; }
@ret:
rts
|