Reimplemented OSWORD(A=$00). Forth works now too!

This commit is contained in:
Bobbi Webber-Manners 2021-07-20 23:47:30 -04:00
parent f5ac8f86c6
commit 4cb94bb3aa
2 changed files with 58 additions and 30 deletions

Binary file not shown.

View File

@ -1361,50 +1361,78 @@ SCNTAB DW $800,$880,$900,$980,$A00,$A80,$B00,$B80
OSWORD STX ZP1 ; ZP1 points to control block OSWORD STX ZP1 ; ZP1 points to control block
STY ZP1+1 STY ZP1+1
CMP #$00 ; OSWORD 0 read a line CMP #$00 ; OSWORD 0 read a line
BNE :S1 BNE :UNSUPP
LDA (ZP1) ; Addr of buf -> ZP2 LDA (ZP1) ; Addr of buf -> ZP2
STA ZP2 STA ZP2
LDY #$01 LDY #$01
LDA (ZP1),Y LDA (ZP1),Y
STA ZP2+1 STA ZP2+1
LDY #$00
:L1 JSR OSRDCH
STA (ZP2),Y
INY INY
CMP #$0D ; Carriage return LDA (ZP1),Y
BEQ :DONE STA :MAXLEN
CMP #27 ; Escape INY
BEQ :CANCEL LDA (ZP1),Y
CMP #$7F ; Delete STA :MINCH
BEQ :DELETE INY
JSR OSWRCH ; Echo LDA (ZP1),Y
BRA :L1 STA :MAXCH
:DONE JSR OSWRCH LDY #$00
LDA #$0A
JSR OSWRCH
CLC
RTS
:CANCEL SEC
RTS
:DELETE DEY
BEQ :L1 ; Nothing to delete
JSR OSWRCH ; Echo
DEY
BRA :L1 BRA :L1
:S1 PHA :BELL LDA #$07 ; BELL
LDA #<OSWORDM ; Unimplemented, print msg :R1 DEY
LDY #>OSWORDM :R2 INY
JSR $FFEE ; OSWRCH
:L1 JSR $FFE0 ; OSRDCH
BCS :EXIT
CMP #$7F ; Delete
BNE :S1 ; Nope
CPY #$00 ; Begin of line?
BEQ :L1
DEY
:S1 CMP #$15 ; Line delete ^U
BNE :S2 ; Nope
TYA ; Begin of line?
BEQ :L1
LDA #$7F ; Delete
:L2 JSR $FFEE ; OSWRCH
DEY
BNE :L2
BEQ :L1
:S2 STA (ZP2),Y
CMP #$0D ; CR
BEQ :S3
CPY :MAXLEN
BCS :BELL
CMP :MINCH
BCC :R1
CMP :MAXCH
BEQ :R2
BCC :R2
BCS :R1
:S3 JSR $FFE7 ; OSNEWL
:EXIT LDA ESCFLAG
ROL
RTS
:UNSUPP PHA
LDA #<:OSWORDM ; Unimplemented, print msg
LDY #>:OSWORDM
JSR PRSTR JSR PRSTR
PLA PLA
JSR PRHEX JSR PRHEX
LDA #<OSWORDM2 LDA #<:OSWRDM2
LDY #>OSWORDM2 LDY #>:OSWRDM2
JSR PRSTR JSR PRSTR
RTS RTS
OSWORDM STR 'OSWORD(' :MAXCH DB $00
:MINCH DB $00
:MAXLEN DB $00
:OSWORDM STR 'OSWORD('
DB $00 DB $00
OSWORDM2 STR ')' :OSWRDM2 STR ')'
DB $00 DB $00
OSBYTE PHX OSBYTE PHX