2015-10-19 20:35:00 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2015-10-19 20:35:00 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2016-08-17 06:25:58 +00:00
|
|
|
|
HIS.Init >PUSHWI 256 Get a buffer for History
|
2015-10-19 20:35:00 +00:00
|
|
|
|
>PUSHBI S.MEM.F.INIT0
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL GetMem
|
2015-10-19 20:35:00 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
txa
|
|
|
|
|
ldy #hCmdHistory
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
ldy #CmdHistory.IDX
|
|
|
|
|
sta (pData),y
|
|
|
|
|
ldy #CmdHistory.END
|
|
|
|
|
sta (pData),y
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2016-08-17 06:25:58 +00:00
|
|
|
|
HIS.Add ldy #hCmdHistory
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .9
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL GetMemPtrA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
>STYA ZPPTR1
|
|
|
|
|
|
|
|
|
|
.10 ldy #CmdHistory.END
|
|
|
|
|
lda (pData),y
|
|
|
|
|
sec add len+1
|
|
|
|
|
adc (pData) CmdBuffer length
|
|
|
|
|
bcc .2 enough room
|
|
|
|
|
|
|
|
|
|
lda (ZPPTR1) get len of oldest string
|
|
|
|
|
sec
|
|
|
|
|
adc ZPPTR1
|
|
|
|
|
sta ZPPTR2
|
|
|
|
|
lda ZPPTR1+1
|
|
|
|
|
adc #0
|
|
|
|
|
sta ZPPTR2+1
|
|
|
|
|
|
|
|
|
|
ldy #$FF
|
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
lda (ZPPTR2),y move back until ending 0 found
|
|
|
|
|
sta (ZPPTR1),y
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
|
|
|
|
|
ldy #CmdHistory.END mark new end of history
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bra .10 retry....
|
|
|
|
|
|
|
|
|
|
.2 tax keep new CmdHistory.END
|
|
|
|
|
|
|
|
|
|
tay
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPPTR1),y set ending 0
|
|
|
|
|
|
|
|
|
|
ldy #CmdHistory.END save old END
|
|
|
|
|
lda (pData),y
|
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
txa get back new END
|
|
|
|
|
|
|
|
|
|
ldy #CmdHistory.IDX set it as new IDX
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
ldy #CmdHistory.END
|
|
|
|
|
sta (pData),y set new CmdHistory.END
|
|
|
|
|
|
|
|
|
|
pla get back old END
|
|
|
|
|
clc
|
|
|
|
|
adc ZPPTR1
|
|
|
|
|
sta ZPPTR1
|
|
|
|
|
bcc .3
|
|
|
|
|
inc ZPPTR1+1
|
|
|
|
|
|
|
|
|
|
.3 lda (pData)
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.4 lda (pData),y
|
|
|
|
|
sta (ZPPTR1),y
|
|
|
|
|
dey
|
|
|
|
|
bpl .4
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2016-09-26 06:18:51 +00:00
|
|
|
|
HIS.GetPrev ldy #hCmdHistory
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq HISTORY.RTS
|
|
|
|
|
|
|
|
|
|
tax
|
|
|
|
|
|
|
|
|
|
ldy #CmdHistory.END
|
|
|
|
|
lda (pData),y
|
|
|
|
|
beq HISTORY.RTS empty history,nothing to do
|
|
|
|
|
ldy #CmdHistory.IDX
|
|
|
|
|
lda (pData),y
|
|
|
|
|
beq HISTORY.RTS already oldest,nothing to do
|
|
|
|
|
|
|
|
|
|
txa
|
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL GetMemPtrA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
>STYA ZPPTR1
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
|
|
|
|
|
.1 tax
|
|
|
|
|
tay
|
|
|
|
|
sec
|
|
|
|
|
adc (ZPPTR1),y
|
2016-04-28 14:55:22 +00:00
|
|
|
|
bcs History.RTS out of buffer
|
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
ldy #CmdHistory.IDX
|
|
|
|
|
cmp (pData),y
|
|
|
|
|
bne .1 reached current index
|
|
|
|
|
|
|
|
|
|
.2 txa
|
|
|
|
|
ldy #CmdHistory.IDX set new index
|
|
|
|
|
sta (pData),y
|
2016-09-26 06:18:51 +00:00
|
|
|
|
bra HIS.SetBuf
|
2015-10-19 20:35:00 +00:00
|
|
|
|
History.RTS rts
|
|
|
|
|
*--------------------------------------
|
2016-09-26 06:18:51 +00:00
|
|
|
|
HIS.GetNext ldy #hCmdHistory
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq HISTORY.RTS
|
|
|
|
|
|
|
|
|
|
tax
|
|
|
|
|
|
|
|
|
|
ldy #CmdHistory.END
|
|
|
|
|
lda (pData),y
|
|
|
|
|
beq HISTORY.RTS empty history,nothing to do
|
|
|
|
|
ldy #CmdHistory.IDX
|
|
|
|
|
cmp (pData),y
|
|
|
|
|
beq HISTORY.RTS already oldest,nothing to do
|
|
|
|
|
|
|
|
|
|
txa
|
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL GetMemPtrA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
>STYA ZPPTR1
|
|
|
|
|
|
|
|
|
|
ldy #CmdHistory.IDX
|
|
|
|
|
lda (pData),y
|
|
|
|
|
phy
|
|
|
|
|
tay
|
|
|
|
|
sec
|
|
|
|
|
adc (ZPPTR1),y add length+1 of current line in history
|
|
|
|
|
ply
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
ldy #CmdHistory.END
|
|
|
|
|
cmp (pData),y
|
2016-09-26 06:18:51 +00:00
|
|
|
|
bne HIS.SetBuf
|
2015-10-19 20:35:00 +00:00
|
|
|
|
jmp CmdBuffer.CLR end of history, just blank buffer
|
|
|
|
|
*--------------------------------------
|
2016-09-26 06:18:51 +00:00
|
|
|
|
HIS.SetBuf jsr CmdBuffer.CLR
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
|
|
|
|
ldy #CmdHistory.IDX
|
|
|
|
|
lda (pData),y
|
|
|
|
|
tay keep length of string
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
adc ZPPTR1
|
|
|
|
|
sta ZPPTR1
|
|
|
|
|
bcc .1
|
|
|
|
|
inc ZPPTR1+1
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPPTR1),y
|
|
|
|
|
sta (pData),y
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
|
|
|
|
|
2017-04-03 06:01:52 +00:00
|
|
|
|
>LDYA pData
|
|
|
|
|
>SYSCALL PPrintfYA
|
|
|
|
|
rts
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
2016-08-17 06:25:58 +00:00
|
|
|
|
HIS.Quit ldy #hCmdHistory
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .9
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL FreeMemA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/SBIN/SHELL.S.HIS
|
|
|
|
|
LOAD /A2OSX.SRC/SBIN/SHELL.S
|
2015-10-19 20:35:00 +00:00
|
|
|
|
ASM
|