2 ; 2014-08-22, Greg King
4 ; int read (int fd, void* buf, unsigned count);
6 ; This function is a hack! It lets us get text from the stdin console.
10 .constructor initstdin
13 .importzp ptr1, ptr2, ptr3
14 .forceimport disable_caps
22 stx ptr3+1 ; save count as result
27 sta ptr2+1 ; Remember -count-1
32 jsr popax ; get fd and discard
37 bze L9 ; no more room in buf
39 ; If there are no more characters in BASIC's input buffer, then get a line from
40 ; the console into that buffer.
49 bnz L4 ; (zero-terminated buffer)
51 lda #$0A ; return newline char. at end of line
58 bnz L1 ; branch always
60 ; No error, return count.
69 ;--------------------------------------------------------------------------
70 ; initstdin: Reset the stdin console.
80 ;--------------------------------------------------------------------------