mirror of
https://github.com/A2osX/A2osX.git
synced 2025-01-10 02:36:59 +00:00
347 lines
6.3 KiB
Plaintext
347 lines
6.3 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BOOT/SBIN/SHELL
|
||
*--------------------------------------
|
||
.INB INC/MACROS.I
|
||
.INB INC/PRODOS.I
|
||
.INB INC/A2OSX.I
|
||
.INB INC/A2OSX.API.I
|
||
.INB INC/LIBSTR.I
|
||
*--------------------------------------
|
||
ZPPTR1 .EQ ZPBIN
|
||
ZPPTR2 .EQ ZPBIN+2
|
||
ZPPTR3 .EQ ZPBIN+4
|
||
*--------------------------------------
|
||
CmdBuffer.MAX .EQ 127
|
||
*--------------------------------------
|
||
* File Header (16 Bytes)
|
||
*--------------------------------------
|
||
CS.START cld
|
||
jmp (.1,x)
|
||
.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 0
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
.1 .DA CS.INIT
|
||
.DA CS.RUN
|
||
.DA CS.DOEVENT
|
||
.DA CS.QUIT
|
||
*--------------------------------------
|
||
L.LIBSTR .DA LIBSTR
|
||
L.MSG.GREETINGS .DA MSG.GREETINGS
|
||
L.MSG.UNKNOWN .DA MSG.UNKNOWN
|
||
L.MSG.SYNERR .DA MSG.SYNERR
|
||
L.ENV.PATH .DA ENV.PATH
|
||
J.INTCMDS .DA EXEC.CMD.CD
|
||
.DA EXEC.CMD.SET
|
||
.DA EXEC.CMD.DATE
|
||
.DA EXEC.CMD.TIME
|
||
.DA EXEC.CMD.ECHO
|
||
.DA EXEC.CMD.TYPE
|
||
.DA EXEC.CMD.EXIT
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT >LDYA L.LIBSTR
|
||
>LOADLIBYA
|
||
bcs .9
|
||
sta hLIBSTR
|
||
|
||
ldy #S.PS.hARGS Batch mode ?
|
||
lda (pPs),y
|
||
beq CS.INIT.INTERACTIVE no,continue starting interactive
|
||
|
||
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.INIT.INTERACTIVE
|
||
jsr History.Init
|
||
bcs .9
|
||
|
||
ldy #S.PS.ID
|
||
lda (pPs),y
|
||
>PUSHA
|
||
ldy #S.PS.hOUTDEV
|
||
lda (pPs),y
|
||
>PUSHA
|
||
ldy #S.PS.hINDEV
|
||
lda (pPs),y
|
||
>PUSHA
|
||
>PUSHW L.MSG.GREETINGS
|
||
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
||
|
||
lda (pPs)
|
||
ora #S.PS.F.EVENT Now accept events
|
||
sta (pPs)
|
||
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN lda #0
|
||
sta (pData)
|
||
|
||
lda #"$"
|
||
jsr COUT
|
||
lda #" "
|
||
jsr COUT
|
||
|
||
.1 jsr A2osX.SLEEP
|
||
lda (pData)
|
||
bpl .1
|
||
|
||
.2 and #$7F
|
||
sta (pData)
|
||
beq CS.RUN Empty line
|
||
ldy #1
|
||
lda (pData),y
|
||
cmp #'#' Comment
|
||
beq CS.RUN
|
||
|
||
jsr History.Add
|
||
|
||
>LDYA pData
|
||
>SYSCALL SYS.NewPStrYA
|
||
bcs .99
|
||
|
||
ldy #hCmdLine
|
||
sta (pData),y
|
||
jsr EXEC.CMD
|
||
bcc .3
|
||
|
||
pha
|
||
lda #"["
|
||
jsr COUT
|
||
pla
|
||
jsr PRBYTE
|
||
lda #"]"
|
||
jsr COUT
|
||
jsr CROUT
|
||
|
||
.3 ldy #hCmdLine
|
||
lda (pData),y
|
||
>SYSCALL SYS.FreeMemA
|
||
ldy #hCmdLine
|
||
lda #0
|
||
sta (pData),y
|
||
|
||
ldy #bEXIT
|
||
lda (pData),y
|
||
bne .99
|
||
|
||
clc
|
||
rts
|
||
|
||
.99 sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.DOEVENT ldy #S.EVT.hDEV is Event from active IN device?
|
||
lda (pEvent),y
|
||
ldy #S.PS.hINDEV
|
||
cmp (pPs),y
|
||
|
||
bne .9
|
||
lda (pEvent)
|
||
and #S.EVT.F.KEY is it a KEY event?
|
||
beq .9
|
||
|
||
ldy #S.EVT.DATAHI is it an O or SAPPLE key ?
|
||
lda (pEvent),y
|
||
bne .9
|
||
|
||
ldy #S.EVT.DATALO
|
||
lda (pEvent),y
|
||
tax
|
||
|
||
cpx #$20
|
||
bcs .1
|
||
jsr CS.EVENT.CTRL.CHAR
|
||
bra .8
|
||
|
||
.1 cpx #$7f
|
||
bne .2
|
||
jsr CmdBuffer.DEL
|
||
bra .8
|
||
|
||
.2 lda (pData) CmdBuffer
|
||
|
||
cmp #CmdBuffer.MAX
|
||
beq .8
|
||
|
||
inc
|
||
sta (pData)
|
||
tay
|
||
txa
|
||
sta (pData),y
|
||
|
||
ora #$80
|
||
jsr COUT
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.EVENT.CTRL.CHAR
|
||
cmp #13 CR
|
||
bne .10
|
||
jsr CROUT
|
||
lda (pData) CmdBuffer
|
||
ora #$80
|
||
sta (pData)
|
||
clc
|
||
rts
|
||
|
||
.10 cmp #3
|
||
bne .1
|
||
jsr CmdBuffer.CLR
|
||
clc
|
||
rts
|
||
|
||
.1 cmp #8 BS (left arrow)
|
||
bne .2
|
||
jsr CmdBuffer.DEL
|
||
clc
|
||
rts
|
||
|
||
.2 cmp #10 LF (down arrow)
|
||
bne .3
|
||
|
||
jsr HISTORY.GETNEXT
|
||
clc
|
||
rts
|
||
|
||
.3 cmp #11 VT (up arrow)
|
||
bne .4
|
||
|
||
jsr HISTORY.GETPREV
|
||
clc
|
||
rts
|
||
|
||
.4 cmp #21 NAK (right arrow)
|
||
bne .8
|
||
|
||
clc
|
||
rts
|
||
|
||
.8 jsr PRBYTE
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT jsr History.Quit
|
||
lda hLIBSTR
|
||
>SYSCALL SYS.UnloadLibA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* PRIVATE
|
||
*--------------------------------------
|
||
CmdBuffer.PRINT ldy #0
|
||
.1 iny
|
||
lda (pData),y
|
||
ora #$80
|
||
jsr COUT
|
||
tya
|
||
cmp (pData)
|
||
bne .1
|
||
rts
|
||
*--------------------------------------
|
||
CmdBuffer.CLR jsr CmdBuffer.DEL
|
||
bne CmdBuffer.CLR
|
||
rts
|
||
*--------------------------------------
|
||
CmdBuffer.DEL lda (pData)
|
||
beq .9
|
||
lda #8
|
||
jsr COUT
|
||
lda (pData)
|
||
dec
|
||
sta (pData)
|
||
.9 rts
|
||
*--------------------------------------
|
||
PRBYTE pha
|
||
lsr
|
||
lsr
|
||
lsr
|
||
lsr
|
||
ora #$B0
|
||
cmp #$BA
|
||
bcc .1
|
||
adc #6
|
||
.1 jsr COUT
|
||
pla
|
||
and #$0F
|
||
ora #$B0
|
||
cmp #$BA
|
||
bcc COUT
|
||
adc #6
|
||
bra COUT
|
||
*--------------------------------------
|
||
CROUT lda #13
|
||
*--------------------------------------
|
||
COUT phx
|
||
phy
|
||
ldx #DEVMGR.COUT
|
||
jsr pDevJmp
|
||
ply
|
||
plx
|
||
rts
|
||
pDevJmp jmp (pDev)
|
||
*--------------------------------------
|
||
.INB SBIN/SHELL.S.CMD
|
||
.INB SBIN/SHELL.S.HIS
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
ENV.PATH >PSTRING "PATH"
|
||
CMDS >PSTRING "CD"
|
||
>PSTRING "SET"
|
||
>PSTRING "DATE"
|
||
>PSTRING "TIME"
|
||
>PSTRING "ECHO"
|
||
>PSTRING "TYPE"
|
||
>PSTRING "EXIT"
|
||
.HS 00
|
||
*--------------------------------------
|
||
LIBSTR >PSTRING "libstr.o"
|
||
MSG.GREETINGS >CSTRING "\nA2osX-Shell on Dev=(%h:%h),PS=%h\n\n"
|
||
MSG.UNKNOWN >CSTRING "Command Not Found\n"
|
||
MSG.SYNERR >CSTRING "Syntax Error Or Invalid Pathname\n"
|
||
hLIBSTR .BS 1
|
||
hNEWPATH .BS 1
|
||
hExecCmd .BS 1
|
||
hExecArgs .BS 1
|
||
hEnvPath .BS 1
|
||
hFullCmd .BS 1
|
||
hVarName .BS 1
|
||
hVarValue .BS 1
|
||
ExecCmdIdx .BS 1
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
CmdBuffer .BS CmdBuffer.MAX+1
|
||
bEXIT .BS 1
|
||
hCmdLine .BS 1
|
||
hCmdHistory .BS 1
|
||
CmdHistory.IDX .BS 1
|
||
CmdHistory.END .BS 1
|
||
DS.END
|
||
.ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE SBIN/SHELL.S
|
||
ASM
|