A2osX/SBIN/SHELL.S.HIS.txt

186 lines
3.1 KiB
Plaintext
Raw Normal View History

NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
2015-10-19 20:35:00 +00:00
.LIST OFF
*--------------------------------------
HIS.Init >LDYAI History.MAX Get a buffer for History
2018-07-13 14:38:24 +00:00
>SYSCALL GetMem0
2015-10-19 20:35:00 +00:00
bcs .9
txa
>STA.G HIS.hBuf
2015-10-19 20:35:00 +00:00
lda #0
>STA.G HIS.Count
>STA.G HIS.Index
2015-10-19 20:35:00 +00:00
.9 rts
*--------------------------------------
HIS.Add >LDA.G HIS.hBuf
2015-10-19 20:35:00 +00:00
beq .9
2018-07-13 14:38:24 +00:00
>SYSCALL GetMemPtr
2015-10-19 20:35:00 +00:00
>STYA ZPPTR1
.10 lda #$ff
jsr HIS.GetA Y=ending 0
phy
tya
sec add len+1
>ADC.G CmdBuflen CmdBuffer length
pla
2015-10-19 20:35:00 +00:00
bcc .2 enough room
ldy #$ff we must remove oldest
.12 iny
lda (ZPPTR1),y get len of oldest string
bne .12
tya
* sec
2015-10-19 20:35:00 +00:00
adc ZPPTR1
sta ZPPTR2
lda ZPPTR1+1
adc #0
sta ZPPTR2+1
ldy #$FF
.1 iny
lda (ZPPTR2),y move back until String ending 0 found
2015-10-19 20:35:00 +00:00
sta (ZPPTR1),y
bne .1
iny
lda (ZPPTR2),y move back until Array ending 0 found
sta (ZPPTR1),y
bne .1
2015-10-19 20:35:00 +00:00
>DEC.G HIS.Count
bra .10 retry....
2015-10-19 20:35:00 +00:00
.2 clc A = ending O offset
2015-10-19 20:35:00 +00:00
adc ZPPTR1
sta ZPPTR1
bcc .3
inc ZPPTR1+1
.3 ldy #$ff
2015-10-19 20:35:00 +00:00
.4 iny
lda (ZPCMDBuf),y
2015-10-19 20:35:00 +00:00
sta (ZPPTR1),y
bne .4
iny
sta (ZPPTR1),y set new array ending 0
* lda #0
>STA.G HIS.Index Reset Index
>INC.G HIS.Count
2015-10-19 20:35:00 +00:00
.9 rts
*--------------------------------------
HIS.GetPrev >LDA.G HIS.hBuf
2015-10-19 20:35:00 +00:00
beq HISTORY.RTS
2018-07-13 14:38:24 +00:00
>SYSCALL GetMemPtr
2015-10-19 20:35:00 +00:00
>STYA ZPPTR1
>LDA.G HIS.Count
beq HISTORY.RTS empty history,nothing to do
>LDA.G HIS.Index
bne .1
2015-10-19 20:35:00 +00:00
>LDA.G HIS.Count
2016-04-28 14:55:22 +00:00
.1 dec
>STA.G HIS.Index
2015-10-19 20:35:00 +00:00
bra HIS.SetA
2015-10-19 20:35:00 +00:00
History.RTS rts
*--------------------------------------
HIS.GetNext >LDA.G HIS.hBuf
2015-10-19 20:35:00 +00:00
beq HISTORY.RTS
2018-07-13 14:38:24 +00:00
>SYSCALL GetMemPtr
2015-10-19 20:35:00 +00:00
>STYA ZPPTR1
>LDA.G HIS.Count
beq HISTORY.RTS empty history,nothing to do
>LDA.G HIS.Index
inc
>CMP.G HIS.Count
bne .1
lda #0
>STA.G HIS.Index
jmp CL.CLR
.1 >STA.G HIS.Index
*--------------------------------------
HIS.SetA jsr HIS.GetA
tya
clc
adc ZPPTR1
sta ZPPTR1
bcc .1
inc ZPPTR1+1
.1 jsr CL.CLR
ldy #$ff
.2 iny
lda (ZPPTR1),y
sta (ZPCMDBuf),y
bne .2
2015-10-19 20:35:00 +00:00
tya
>STA.G CmdBufPtr
>STA.G CmdBuflen
jmp CL.PRINT
2015-10-19 20:35:00 +00:00
*--------------------------------------
HIS.GetA ldy #0
tax
beq .80
lda (ZPPTR1),y
beq .9
.1 iny
lda (ZPPTR1),y
bne .1
dex
beq .8
iny
lda (ZPPTR1),y
bne .1
.9 sec Found ending 0....
rts
.8 iny
.80 clc
rts
*--------------------------------------
HIS.Quit >LDA.G HIS.hBuf
2015-10-19 20:35:00 +00:00
beq .9
2018-07-13 14:38:24 +00:00
>SYSCALL FreeMem
2015-10-19 20:35:00 +00:00
.9 rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SBIN/SHELL.S.HIS
LOAD /A2OSX.SRC/SBIN/SHELL.S
2015-10-19 20:35:00 +00:00
ASM