Skip to content

Commit

Permalink
Expands INPUT to allow 255 bytes of buffer.
Browse files Browse the repository at this point in the history
Adds a test to catch errors on long records, and always return the full
buffer on long records.
  • Loading branch information
dmsc committed Oct 14, 2024
1 parent 85651fa commit 570a981
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/interp/a800/input.asm
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@ line_buf = LBUFF
lda #<line_buf
sta ICBAL, x
.assert (<line_buf) = $80, error, "invalid optimization"
;lda #$80
sta ICBLL, x
lda #0
asl ; Use ASL instead of LDA #0, one byte less
sta ICBLH, x
lda #$FF
sta ICBLL, x
jsr CIOV
lda ICBLL, x

sty IOERROR
tax
beq no_eol ; No characters read
; Error 136: end of file, keep last character
cpy #$88
beq no_eol
; TODO: do we need to handle other errors?
; tya
; bmi no_eol

; Error 136: end of file
; Error 137: out of buffer space
; Also, in case of any other error, keep last character
tya
bmi no_eol

; Remove EOL at end of buffer
dex
Expand Down
26 changes: 26 additions & 0 deletions testsuite/tests/diskio.bas
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,29 @@ bget #2, adr(A$) + 1, 32
close #2
? ERR()
? A$

' Write a big string
open #1, 8, 0, "D:XXX"
? #1, "Big 1: ";
FOR I=0 TO 19
? #1, "<STRING ";I; ">";
NEXT
? #1,
? #1, "Big 2: ";
FOR I=0 TO 25
? #1, "<STRING ";I+20; ">";
NEXT
? #1,
close #1

? "BIG INPUT"
open #2, 4, 0, "D:XXX"
input #2, A$
? ERR()
? A$, LEN(A$)
input #2, A$
? ERR()
? A$, LEN(A$)
close #2
? ERR()

6 changes: 6 additions & 0 deletions testsuite/tests/diskio.chk
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ BGET 32
1
hola
chaoZZZ
BIG INPUT
1
Big 1: <STRING 0><STRING 1><STRING 2><STRING 3><STRING 4><STRING 5><STRING 6><STRING 7><STRING 8><STRING 9><STRING 10><STRING 11><STRING 12><STRING 13><STRING 14><STRING 15><STRING 16><STRING 17><STRING 18><STRING 19> 217
137
Big 2: <STRING 20><STRING 21><STRING 22><STRING 23><STRING 24><STRING 25><STRING 26><STRING 27><STRING 28><STRING 29><STRING 30><STRING 31><STRING 32><STRING 33><STRING 34><STRING 35><STRING 36><STRING 37><STRING 38><STRING 39><STRING 40><STRING 41><STRIN 255
1

0 comments on commit 570a981

Please sign in to comment.