1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-11 11:30:13 +00:00

Merge pull request #67 from greg-king5/echo

CBM stdin Console RETURN-key Echo
This commit is contained in:
Oliver Schmidt 2013-12-26 06:54:42 -08:00
commit e267addb5b

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 16.11.2002 ; 2002-11-16, Ullrich von Bassewitz
; 2013-12-23, Greg King
; ;
; int read (int fd, void* buf, unsigned count); ; int read (int fd, void* buf, unsigned count);
; ;
@ -7,7 +8,7 @@
.export _read .export _read
.constructor initstdin .constructor initstdin
.import SETLFS, OPEN, CHKIN, BASIN, CLRCH, READST .import SETLFS, OPEN, CHKIN, BASIN, CLRCH, BSOUT, READST
.import rwcommon .import rwcommon
.import popax .import popax
.importzp ptr1, ptr2, ptr3, tmp1, tmp2, tmp3 .importzp ptr1, ptr2, ptr3, tmp1, tmp2, tmp3
@ -51,14 +52,20 @@
adc #LFN_OFFS ; Carry is already clear adc #LFN_OFFS ; Carry is already clear
tax tax
lda fdtab-LFN_OFFS,x; Get flags for this handle lda fdtab-LFN_OFFS,x; Get flags for this handle
tay
and #LFN_READ ; File open for writing? and #LFN_READ ; File open for writing?
beq invalidfd beq invalidfd
; Check the EOF flag. If it is set, don't read anything ; Check the EOF flag. If it is set, don't read anything
lda fdtab-LFN_OFFS,x; Get flags for this handle tya ; Get flags again
bmi eof bmi eof
; Remember the device number.
ldy unittab-LFN_OFFS,x
sty unit
; Valid lfn. Make it the input file ; Valid lfn. Make it the input file
jsr CHKIN jsr CHKIN
@ -69,8 +76,13 @@
@L0: jsr BASIN @L0: jsr BASIN
sta tmp1 ; Save the input byte sta tmp1 ; Save the input byte
ldx unit
bne @L0_1 ; Not keyboard/screen-editor
cmp #$0D ; Is it a Carriage Return?
bne @L0_1
jsr BSOUT ; Yes, echo it (because editor didn't)
jsr READST ; Read the IEEE status @L0_1: jsr READST ; Read the IEEE status
sta tmp3 ; Save it sta tmp3 ; Save it
and #%10111111 ; Check anything but the EOI bit and #%10111111 ; Check anything but the EOI bit
bne devnotpresent ; Assume device not present bne devnotpresent ; Assume device not present
@ -138,4 +150,10 @@ invalidfd:
.endproc .endproc
;--------------------------------------------------------------------------
.bss
unit: .res 1