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