Kernel version 0.9 : SHELL, enhancement in Batch mode....

This commit is contained in:
Rémy GIBERT 2017-07-10 17:50:32 +02:00
parent 9989495ab7
commit 3cf8399ffb
5 changed files with 120 additions and 54 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5,47 +5,39 @@ INC 1
AUTO 6
.LIST OFF
*--------------------------------------
TXT.OpenFileYA pha
>PUSHWI 0 Aux type
>PUSHBI 4 S.FILEINFO.TYPE.TXT
>PUSHBI SYS.FOpen.R+SYS.FOpen.T
pla
>PUSHYA
>SYSCALL FOpen
TXT.Exec jsr TXT.GetBuffer
jsr TXT.GetChar
bcs .9
ldy #hInputFile
sta (pData),y
.9 rts
*--------------------------------------
TXT.ReadFile >PUSHWI UsrBuf256+1
>PUSHWI 127
ldy #hInputFile
lda (pData),y
>PUSHA
>SYSCALL FRead
bcs .9
tya
beq .10
lda UsrBuf256,y Y,A=Bytes read
cmp #$0D
.11 cmp #' '
bne .10
dey
jsr TXT.GetNextChar
bcc .11
bcs .9
.10 tya
sta (pData)
.10 ldy #0
cmp #$0D
beq .2
.1 lda UsrBuf256,y
.1 iny
sta (pData),y
dey
cpy #CmdLine.MAX
beq .2
jsr TXT.GetNextChar
bcs .3
cmp #$0D
bne .1
.2 ldy #bEcho
.2 jsr TXT.GetNextChar Skip CR
.3 tya
sta (pData)
ldy #bEcho
lda (pData),y
beq .8
@ -55,15 +47,68 @@ TXT.ReadFile >PUSHWI UsrBuf256+1
.8 clc
.9 rts
*--------------------------------------
TXT.CloseFile ldy #hInputFile
TXT.GetBuffer ldy #hBatchFile
lda (pData),y
beq .9
>SYSCALL GetMemPtrA
>STYA ZPBufBase
>SYSCALL FCloseA
ldy #BatchFileLen
lda (pData),y
clc
adc ZPBufBase
sta ZPBufEnd
.9 lda #0
ldy #hInputFile
iny
lda (pData),y
adc ZPBufBase+1
sta ZPBufEnd+1
TXT.SetBufPtr ldy #BatchFilePtr
lda (pData),y
clc
adc ZPBufBase
sta ZPBufPtr
iny
lda (pData),y
adc ZPBufBase+1
sta ZPBufPtr+1
rts
*--------------------------------------
TXT.PushPtr
*--------------------------------------
TXT.GetNextChar phy
ldy #BatchFilePtr
lda (pData),y
inc
sta (pData),y
bne .1
iny
lda (pData),y
inc
sta (pData),y
.1 ply
inc ZPBufPtr
bne TXT.GetChar
inc ZPBufPtr+1
TXT.GetChar lda ZPBufPtr
eor ZPBufEnd
bne .1
lda ZPBufPtr+1
eor ZPBufEnd+1
bne .1
lda #MLI.ERR.EOF
sec
rts
.1 lda (ZPBufPtr)
clc
rts
*--------------------------------------
MAN

View File

@ -15,6 +15,9 @@ AUTO 6
ZPPTR1 .EQ ZPBIN
ZPPTR2 .EQ ZPBIN+2
ZPPTR3 .EQ ZPBIN+4
ZPBufBase .EQ ZPBIN+8
ZPBufPtr .EQ ZPBIN+10
ZPBufEnd .EQ ZPBIN+12
*--------------------------------------
CmdLine.MAX .EQ 127
VarLen.MAX .EQ 15
@ -74,11 +77,27 @@ CS.INIT jsr SetPWD
beq CS.INIT.INTERACTIVE no arg, continue starting interactive
>PUSHWI 0 Aux type
>PUSHBI 4 S.FILEINFO.TYPE.TXT
>PUSHBI SYS.FOpen.R
lda #1
>SYSCALL GetArgA
jsr TXT.OpenFileYA
>PUSHYA
>SYSCALL LoadFile
bcs .9
phy
ldy #BatchFileLen+1
sta (pData),y
dey
pla
sta (pData),y
txa
ldy #hBatchFile
sta (pData),y
ldy #bExitOnEOF
lda #$FF
sta (pData),y
@ -114,7 +133,7 @@ CS.RUN ldy #bPause
jsr ERR.Print
bcs CS.RUN.EXIT.RTS
.11 ldy #hInputFile batch mode ?
.11 ldy #hBatchFile batch mode ?
lda (pData),y
beq .10
@ -200,15 +219,13 @@ CS.RUN.READ lda #0
plp
rts
*--------------------------------------
CS.RUN.BATCH jsr TXT.ReadFile
CS.RUN.BATCH jsr TXT.Exec
bcs .9
jsr CmdBuffer.Normalize
lda (pData)
beq CS.RUN.BATCH Empty line
* jsr HIS.Add
>LDYA pData
jsr Cmd.ExecYA
ldy #S.PS.RC
@ -216,8 +233,7 @@ CS.RUN.BATCH jsr TXT.ReadFile
clc
rts
.9 jsr TXT.CloseFile
ldy #bExitOnEOF
.9 ldy #bExitOnEOF
lda (pData),y
bne CS.RUN.EXIT
@ -228,14 +244,13 @@ CS.DOEVENT sec
rts
*--------------------------------------
CS.CHARIN tax
ldy #hInputFile Batch mode ?
ldy #hBatchFile Batch mode ?
lda (pData),y
beq .10
* Batch Mode
cpx #3 test Ctrl-c
bne .12
jsr TXT.CloseFile
ldy #bExitOnEOF
lda (pData),y
ldy #bExit
@ -367,10 +382,10 @@ CS.CHARIN.CTRL cpx #13 CR
*--------------------------------------
CS.QUIT jsr HIS.Quit
ldy #hInputFile
ldy #hBatchFile
lda (pData),y
beq .1
>SYSCALL FCloseA
>SYSCALL FreeMemA
.1
.8 clc
@ -391,10 +406,15 @@ PrintPrompt >LDYA L.ENV.PS1
>SYSCALL ExpandPStrYA
phx
>PUSHYA
pla
>SYSCALL FreeMemA
>LDYA L.MSG.PROMPT
>SYSCALL PPrintFYA
plx
php
pha
txa
>SYSCALL FreeMemA
pla
plp
.9 rts
*--------------------------------------
* Remove extra SPACE & comment
@ -507,7 +527,6 @@ hNEWPATH .BS 1
hCmdLine .BS 1
Cmd.Exec.Mode .BS 1
hFullPath .BS 1
hTextFile .BS 1
*--------------------------------------
.DUMMY
.OR 0
@ -523,7 +542,9 @@ bExitOnEOF .BS 1
hCmdHistory .BS 1
CmdHistory.IDX .BS 1
CmdHistory.END .BS 1
hInputFile .BS 1
hBatchFile .BS 1
BatchFilePtr .BS 2
BatchFileLen .BS 2
DS.END
.ED
*--------------------------------------