2015-10-19 20:35:00 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2017-07-06 15:30:40 +00:00
|
|
|
|
LOMEM $A00
|
2015-10-19 20:35:00 +00:00
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2017-07-06 15:30:40 +00:00
|
|
|
|
HIS.Init >LDYAI 256 Get a buffer for History
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMem0.YA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
txa
|
2017-08-01 19:41:01 +00:00
|
|
|
|
ldy #HIS.hBuf
|
2015-10-19 20:35:00 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
lda #0
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufIndex
|
2015-10-19 20:35:00 +00:00
|
|
|
|
sta (pData),y
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufEnd
|
2015-10-19 20:35:00 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-08-01 19:41:01 +00:00
|
|
|
|
HIS.Add ldy #HIS.hBuf
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .9
|
2017-08-22 06:37:03 +00:00
|
|
|
|
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2015-10-19 20:35:00 +00:00
|
|
|
|
>STYA ZPPTR1
|
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
.10 ldy #HIS.BufEnd
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
2017-08-22 06:37:03 +00:00
|
|
|
|
|
|
|
|
|
.11 sec add len+1
|
2015-10-19 20:35:00 +00:00
|
|
|
|
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
|
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufEnd mark new end of history
|
2015-10-19 20:35:00 +00:00
|
|
|
|
sta (pData),y
|
2017-08-22 06:37:03 +00:00
|
|
|
|
bra .11 retry....
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
.2 tax keep new HIS.BufEnd
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
|
|
|
|
tay
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPPTR1),y set ending 0
|
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufEnd save old END
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
txa get back new END
|
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufIndex set it as new IDX
|
2015-10-19 20:35:00 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufEnd
|
|
|
|
|
sta (pData),y set new HIS.BufEnd
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
2017-08-01 19:41:01 +00:00
|
|
|
|
HIS.GetPrev ldy #HIS.hBuf
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq HISTORY.RTS
|
|
|
|
|
|
|
|
|
|
tax
|
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufEnd
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq HISTORY.RTS empty history,nothing to do
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufIndex
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq HISTORY.RTS already oldest,nothing to do
|
|
|
|
|
|
|
|
|
|
txa
|
|
|
|
|
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
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
|
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufIndex
|
2015-10-19 20:35:00 +00:00
|
|
|
|
cmp (pData),y
|
|
|
|
|
bne .1 reached current index
|
|
|
|
|
|
|
|
|
|
.2 txa
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufIndex set new index
|
2015-10-19 20:35:00 +00:00
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
2017-08-01 19:41:01 +00:00
|
|
|
|
HIS.GetNext ldy #HIS.hBuf
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq HISTORY.RTS
|
|
|
|
|
|
|
|
|
|
tax
|
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufEnd
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq HISTORY.RTS empty history,nothing to do
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufIndex
|
2015-10-19 20:35:00 +00:00
|
|
|
|
cmp (pData),y
|
|
|
|
|
beq HISTORY.RTS already oldest,nothing to do
|
|
|
|
|
|
|
|
|
|
txa
|
|
|
|
|
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2015-10-19 20:35:00 +00:00
|
|
|
|
>STYA ZPPTR1
|
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufIndex
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
phy
|
|
|
|
|
tay
|
|
|
|
|
sec
|
|
|
|
|
adc (ZPPTR1),y add length+1 of current line in history
|
|
|
|
|
ply
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufEnd
|
2015-10-19 20:35:00 +00:00
|
|
|
|
cmp (pData),y
|
2016-09-26 06:18:51 +00:00
|
|
|
|
bne HIS.SetBuf
|
2017-08-22 06:37:03 +00:00
|
|
|
|
jmp CmdLine.CLR end of history, just blank buffer
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-22 06:37:03 +00:00
|
|
|
|
HIS.SetBuf jsr CmdLine.CLR
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
ldy #HIS.BufIndex
|
2015-10-19 20:35:00 +00:00
|
|
|
|
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-08-22 06:37:03 +00:00
|
|
|
|
jmp CmdLine.SET
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-01 19:41:01 +00:00
|
|
|
|
HIS.Quit ldy #HIS.hBuf
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .9
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL FreeMem.A
|
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
|