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 AUTO 6
.LIST OFF .LIST OFF
*-------------------------------------- *--------------------------------------
TXT.OpenFileYA pha TXT.Exec jsr TXT.GetBuffer
>PUSHWI 0 Aux type jsr TXT.GetChar
>PUSHBI 4 S.FILEINFO.TYPE.TXT
>PUSHBI SYS.FOpen.R+SYS.FOpen.T
pla
>PUSHYA
>SYSCALL FOpen
bcs .9 bcs .9
ldy #hInputFile .11 cmp #' '
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
bne .10 bne .10
dey jsr TXT.GetNextChar
bcc .11
bcs .9
.10 tya .10 ldy #0
sta (pData)
cmp #$0D
beq .2 beq .2
.1 lda UsrBuf256,y .1 iny
sta (pData),y sta (pData),y
dey
cpy #CmdLine.MAX
beq .2
jsr TXT.GetNextChar
bcs .3
cmp #$0D
bne .1 bne .1
.2 ldy #bEcho .2 jsr TXT.GetNextChar Skip CR
.3 tya
sta (pData)
ldy #bEcho
lda (pData),y lda (pData),y
beq .8 beq .8
@ -55,15 +47,68 @@ TXT.ReadFile >PUSHWI UsrBuf256+1
.8 clc .8 clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
TXT.CloseFile ldy #hInputFile TXT.GetBuffer ldy #hBatchFile
lda (pData),y lda (pData),y
beq .9 >SYSCALL GetMemPtrA
>STYA ZPBufBase
>SYSCALL FCloseA ldy #BatchFileLen
lda (pData),y
clc
adc ZPBufBase
sta ZPBufEnd
.9 lda #0 iny
ldy #hInputFile 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 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 rts
*-------------------------------------- *--------------------------------------
MAN MAN

View File

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