Kernel 0.9.1 : Code reorganization & move to CSTR (SHELL, History, CL Editing)

This commit is contained in:
Rémy GIBERT 2017-09-26 17:55:25 +02:00
parent 6a46705d34
commit f1a0c7f011
5 changed files with 112 additions and 84 deletions

Binary file not shown.

Binary file not shown.

View File

@ -380,7 +380,11 @@ BS ldx CH
sta CH
dec CV
.3 lda #$20
.3 clc
rts
lda #$20
ora INVFLG
ldx CH
ldy CV

View File

@ -91,8 +91,6 @@ HIS.GetPrev >LDA.G HIS.hBuf
>SYSCALL GetMemPtr.A
>STYA ZPPTR1
>DEBUG
>LDA.G HIS.Count
beq HISTORY.RTS empty history,nothing to do
@ -104,9 +102,8 @@ HIS.GetPrev >LDA.G HIS.hBuf
.1 dec
>STA.G HIS.Index
jsr HIS.GetA
bra HIS.SetA
bra HIS.SetBuf
History.RTS rts
*--------------------------------------
HIS.GetNext >LDA.G HIS.hBuf
@ -115,8 +112,6 @@ HIS.GetNext >LDA.G HIS.hBuf
>SYSCALL GetMemPtr.A
>STYA ZPPTR1
>DEBUG
>LDA.G HIS.Count
beq HISTORY.RTS empty history,nothing to do
@ -125,18 +120,36 @@ HIS.GetNext >LDA.G HIS.hBuf
>CMP.G HIS.Count
bne .1
lda #0
>STA.G HIS.Index
jmp CmdLine.CLR
.1 >STA.G HIS.Index
jsr HIS.GetA
bne HIS.SetBuf
jmp CmdLine.CLR end of history, just blank buffer
.1 >STA.G HIS.Index
*--------------------------------------
HIS.GetA tax
beq .8
HIS.SetA jsr HIS.GetA
tya
clc
adc ZPPTR1
sta ZPPTR1
bcc .1
inc ZPPTR1+1
.1 jsr CmdLine.CLR
ldy #$ff
.2 iny
lda (ZPPTR1),y
sta (ZPCMDBuf),y
bne .2
jmp CmdLine.PRINT
*--------------------------------------
HIS.GetA ldy #0
tax
beq .80
ldy #0
lda (ZPPTR1),y
beq .9
@ -154,19 +167,11 @@ HIS.GetA tax
.9 sec Found ending 0....
rts
.8 clc
.8 iny
.80 clc
rts
*--------------------------------------
HIS.SetBuf jsr CmdLine.CLR
ldy #$ff
.1 lda (ZPPTR1),y
sta (ZPCMDBuf),y
bne .1
jmp CmdLine.PRINT
*--------------------------------------
HIS.Quit >LDA.G HIS.hBuf
beq .9
>SYSCALL FreeMem.A

View File

@ -42,9 +42,10 @@ CS.START cld
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length To Relocate
.DA DS.END-DS.START Data Segment to Allocate
.DA 0
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #64 SS
.DA #16 ZP
.DA 0
*--------------------------------------
* Relocation Table
@ -65,6 +66,11 @@ L.ENV.PWD .DA ENV.PWD
L.ENV.PS1 .DA ENV.PS1
L.FMT.DATE .DA FMT.DATE
L.FMT.TIME .DA FMT.TIME
L.MSG.HEXBYTE .DA MSG.HEXBYTE
J.ESC .DA CmdLine.BS left arrow
.DA HIS.GetNext
.DA HIS.GetPrev
.DA CmdLine.NAK right arow
L.INTCMDS .DA INTCMDS
J.INTCMDS .DA Cmd.Exec.CD
.DA Cmd.Exec.DATE
@ -310,7 +316,7 @@ CS.CHARIN tax Save Char
>STA.G bPause
clc
rts
*--------------------------------------
* interactive mode
.10 >LDA.G bEscMode
beq .13
@ -320,47 +326,61 @@ CS.CHARIN tax Save Char
lda #0
sta (pData),y Y=bEscMode
txa
ldx EscChars
ldx #EscChars.count-1
.17 cmp EscChars,x
beq .18
dex
bne .17
bra .8
bpl .17
clc
rts
.18 lda EscAscii,x
.18 txa
asl
tax
jmp (J.ESC,x)
*--------------------------------------
.13 cpx #$20
bcs .1
jsr CS.CHARIN.CTRL
bra .8
bcc CS.CHARIN.CTRL
.1 cpx #$7f
bne .2
jsr CmdLine.DEL
clc
rts
jmp CmdLine.DEL
.2 >LDA.G CmdBuflen
cmp #CmdLine.MAX
beq .8
pha
beq .8 Buffer full, discard...
inc
sta (pData),y
txa
ply
sta (ZPCMDBuf),y
iny
tay
lda #0
sta (ZPCMDBuf),y
>LDA.G bSecureRead
>LDA.G CmdBufPtr
tay
*.3 lda (ZPCMDBuf),y Move from Ptr To end of buffer forward...
* iny
* sta (ZPCMDBuf),y
* ora #0
* bne .3 ...until ending 0
txa
>LDA.G CmdBufPtr Insert char at Ptr
tay
sta (ZPCMDBuf),y
>INC.G CmdBufPtr
>CMP.G CmdBuflen
bne .4
.4 >LDA.G bSecureRead
bne .8
txa
@ -369,8 +389,17 @@ CS.CHARIN tax Save Char
.8 clc
rts
*--------------------------------------
CS.CHARIN.CTRL cpx #13 CR
CS.CHARIN.CTRL
* phx
* txa
* >PUSHA
* >LDYA L.MSG.HEXBYTE
* >SYSCALL PrintF.YA
* plx
cpx #13 CR
bne .10
txa
>SYSCALL PutChar.A
lda #10
@ -390,35 +419,9 @@ CS.CHARIN.CTRL cpx #13 CR
rts
.11 cpx #3 Ctrl-C
bne .1
jsr CmdLine.CLR
clc
rts
.1 cpx #8 BS (left arrow)
bne .2
jsr CmdLine.DEL
clc
rts
.2 cpx #10 LF (down arrow)
bne .3
jsr HIS.GetNext
clc
rts
.3 cpx #11 VT (up arrow)
bne .4
jsr HIS.GetPrev
clc
rts
.4 cpx #21 NAK (right arrow)
bne .8
jsr CmdLine.CLR
clc
rts
@ -470,11 +473,12 @@ CmdLine.CLR ldy #0
.1 lda (ZPCMDBuf),y
beq .9
lda #8
.2 lda #8
sta (pData),y
sta (ZPCMDBuf),y
iny
bne .1
lda (ZPCMDBuf),y
bne .2
jsr CmdLine.PRINT
@ -482,6 +486,17 @@ CmdLine.CLR ldy #0
.9 rts
*--------------------------------------
CmdLine.BS >LDA.G CmdBufPtr
beq .9
dec
sta (pData),y
lda #8
>SYSCALL PutChar.A
.9 rts
*--------------------------------------
CmdLine.NAK rts
*--------------------------------------
CmdLine.DEL >LDA.G CmdBuflen
beq .9
dec
@ -502,6 +517,7 @@ CmdLine.PRINT >LDYA ZPCMDBuf
CmdLine.RESET lda #0
sta (ZPCMDBuf)
>STA.G bCmdBufexec
>STA.G CmdBufPtr
>STA.G CmdBuflen
>STA.G bSecureRead Clear password mode
rts
@ -547,11 +563,13 @@ MSG.PRINTENV >CSTR "%s=%s\r\n"
MSG.CSHERR >CSTR "Pos %D:"
FMT.DATE >CSTR "%A, %B %d %Y"
FMT.TIME >CSTR "%H:%M:%S (%I:%M:%S%p)"
MSG.HEXBYTE >CSTR "[%h]"
*--------------------------------------
.INB /A2OSX.SRC/X.ERRORS.S
*--------------------------------------
EscChars >PSTR "DBAC"
EscAscii .HS 04080A0B15
EscChars.Count .EQ 4
EscChars .AS 'DBAC'
CSH.TSIZE .HS 0001020405 00,CHAR,INT,LONG,FLOAT....
CSH.ACCT .BS 1
CSH.ACC .BS 5
@ -562,6 +580,7 @@ CSH.ARG .BS 5
.OR 0
DS.START
hCmdBuf .BS 1
CmdBufPtr .BS 1
CmdBuflen .BS 1
bCmdBufexec .BS 1