Revert various stdio changes to make it match the version in the ORCA/C 2.1.1 B3 ORCALib binary on Opus ][.

The reverted changes relate mainly to adding a second character position in the putback buffer, but the library with those changes crashes on basic stdio operations like printing a string.

For now, this patch reverts stdio to a working, tested version. If the reverted changes are valuable, they can be fixed and then reintroduced later.
This commit is contained in:
Stephen Heumann 2018-02-26 20:03:14 -06:00
parent 89acbf2ced
commit e3c0c962d4
2 changed files with 34 additions and 38 deletions

View File

@ -71,7 +71,7 @@ FILE_end gequ FILE_base+4 end of the file buffer
FILE_size gequ FILE_end+4 size of the file buffer
FILE_cnt gequ FILE_size+4 # chars that can be read/writen to buffer
FILE_pbk gequ FILE_cnt+4 put back character
FILE_flag gequ FILE_pbk+4 buffer flags
FILE_flag gequ FILE_pbk+2 buffer flags
FILE_file gequ FILE_flag+2 GS/OS file ID
sizeofFILE gequ FILE_file+2 size of the record

View File

@ -431,16 +431,14 @@ lb0 lda #EOF
lb1 ldy #FILE_pbk if there is a char in the putback buffer
lda [stream],Y
bmi lb2
and #$00FF return it
and #$0080
bne lb2
lda [stream],Y return it
and #$00FF
sta c
ldy #FILE_pbk+2 pop the putback buffer
lda [stream],Y
tax
lda #$FFFF
sta [stream],Y
ldy #FILE_pbk
txa
lda [stream],Y pop the putback buffer
xba
ora #$FF00
sta [stream],Y
brl gc9
@ -623,6 +621,7 @@ rdRefNum ds 2
rdDataBuffer ds 4
rdRequestCount ds 4
rdTransferCount ds 4
dc i'1' cache priority
end
****************************************************************
@ -927,8 +926,6 @@ ar6a sta [fileBuff],Y
ldy #FILE_pbk nothing in the putback buffer
lda #$FFFF
sta [fileBuff],Y
ldy #FILE_pbk+2
sta [fileBuff],Y
ldy #FILE_file set the file ID
lda opRefNum
sta [fileBuff],Y
@ -1134,7 +1131,7 @@ ar1 ph4 #BUFSIZ get space for the file buffer
bne ar3
lda #ENOMEM memory error
sta >errno
brl rt1
bra rt1
ar3 move4 stream,fileBuff set the file buffer address
lda buffStart set the start of the buffer
@ -1185,8 +1182,6 @@ ar6a sta [fileBuff],Y
ldy #FILE_pbk nothing in the putback buffer
lda #$FFFF
sta [fileBuff],Y
ldy #FILE_pbk+2
sta [fileBuff],Y
ldy #FILE_file set the file ID
lda opRefNum
sta [fileBuff],Y
@ -1799,8 +1794,6 @@ lb6 ldy #FILE_flag clear the EOF , READ, WRITE flags
ldy #FILE_pbk nothing in the putback buffer
lda #$FFFF
sta [stream],Y
ldy #FILE_pbk+2
sta [stream],Y
stz err
rts plb
@ -1914,15 +1907,12 @@ lb1 move4 gmPosition,pos set the position
lda pos+2
sbc [stream],Y
sta pos+2
ldy #FILE_pbk dec pos by 1 for each char in the
lda [stream],Y putback buffer then
bmi lb2
dec4 pos
ldy #FILE_pbk+2
lda [stream],Y
bmi lb2
dec4 pos
lb2 ldy #FILE_file set the file's mark
ldy #FILE_pbk if there is a char in the putback
lda [stream],Y buffer then
and #$0080
bne rts
dec4 pos dec pos by 1
ldy #FILE_file set the file's mark
lda [stream],Y
sta spRefNum
move4 pos,spPosition
@ -2022,11 +2012,12 @@ lb5 div4 wrTransferCount,element_size,count
lb6 plb
creturn 4:count return
wr dc i'4' parameter block for OSWrite
wr dc i'5' parameter block for OSRead
wrRefNum ds 2
wrDataBuffer ds 4
wrRequestCount ds 4
wrTransferCount ds 4
dc i'1'
end
****************************************************************
@ -2057,13 +2048,15 @@ getchar start
; get the char from the keyboard
;
lda >stdin+4+FILE_pbk if there is a char in the putback
bmi lb1 buffer then
and #$00FF save it in X
and #$0080 buffer then
bne lb1
lda >stdin+4+FILE_pbk save it in x
and #$00FF
tax
lda >stdin+4+FILE_pbk+2 pop the buffer
lda >stdin+4+FILE_pbk pop the buffer
xba
ora #$FF00
sta >stdin+4+FILE_pbk
lda #$FFFF
sta >stdin+4+FILE_pbk+2
txa restore the char
bra lb2
@ -2984,18 +2977,21 @@ char equ 1 characater to return
lda c error if EOF is pushed
cmp #EOF
beq rts
ldy #FILE_pbk+2 error if the buffer is full
ldy #FILE_pbk+1 error if the buffer is full
short M
lda [stream],Y
bpl rts
ldy #FILE_pbk push the old character (if any)
dey push the old character (if any)
lda [stream],Y
ldy #FILE_pbk+2
iny
sta [stream],Y
ldy #FILE_pbk put back the character
lda c
and #$00FF
dey
lda c put back the character
sta [stream],Y
sta char
stz char+1
bpl rts
dec char+1
rts long M
creturn 2:char
end