2 ; 2013-12-24, 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
21 stx ptr3+1 ; save count as result
26 sta ptr2+1 ; Remember -count-1
31 jsr popax ; get fd and discard
36 bze L9 ; no more room in buf
38 ; If there are no more characters in BASIC's input buffer, then get a line from
39 ; the console into that buffer.
48 bnz L4 ; (zero-terminated buffer)
50 lda #$0A ; return newline char. at end of line
57 bnz L1 ; branch always
59 ; No error, return count.
68 ;--------------------------------------------------------------------------
69 ; initstdin: Reset the stdin console.
79 ;--------------------------------------------------------------------------