; 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, _txbuf_send_str, _irc_away _hz = $f0 ; must agree with timers.h! .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 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