A2osX/BIN/SH.S.HIS.txt
2021-05-09 19:04:44 +02:00

165 lines
2.6 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
HIS.Init >LDYAI HISTORY.MAX Get a buffer for History
>SYSCALL StrVNew
bcs .9
>STA.G HIS.hBuf
>STZ.G HIS.Count
>STA.G HIS.Index
>STA.G HIS.LRU
.9 rts
*--------------------------------------
HIS.Add >LDA.G HIS.hBuf
beq .9
>LDA.G HIS.Count
cmp #HIS.MAX
bcc .2
>LDA.G HIS.LRU
tax
inc
cmp #HIS.MAX
bne .1
lda #0
.1 >STA.G HIS.LRU
bra .7
.2 tax
>INC.G HIS.Count
.7 >PUSHB.G HIS.hBuf
>PUSHBI 0
txa
>PUSHA
>PUSHW ZPCLBuf
>SYSCALL StrVSet
>STZ.G HIS.Index Reset Index
.9 rts
*--------------------------------------
HIS.Select >LDA.G HIS.Count
bne .10
clc
.99 rts
.10 >STZ.G HIS.Index
.1 jsr HIS.GetIndex
bcs .99
>PUSHW L.MSG.HIS
>PUSHB.G HIS.Index
>PUSHW ZPCLBuf
>PUSHBI 3
>SYSCALL PrintF
bcs .9
>INC.G HIS.Index
>CMP.G HIS.Count
bne .1
>PUSHW L.MSG.HISPROMPT
>PUSHBI 0
>SYSCALL PrintF
>STZ.G HIS.Index
>SYSCALL GetChar
bcs HIS.Select.RTS
cmp #'0'
bcc .7
cmp #'9'+1
bcs .7
and #$f
>STA.G HIS.Index
.7 >PUSHW L.MSG.HISROMPTCLR
>PUSHBI 0
>SYSCALL PrintF
jsr CL.PrintPrompt
bcs .9
>LDA.G HIS.Index
bne HIS.GetToCL1
jmp CL.Reset
.8 clc
.9
HIS.Select.RTS rts
*--------------------------------------
HIS.GetPrev >LDA.G HIS.hBuf
beq HIS.Select.RTS
>LDA.G HIS.Count
beq HIS.Select.RTS empty history,nothing to do
>LDA.G HIS.Index
bne .1
>LDA.G HIS.Count
.1 dec
bra HIS.GetToCL
*--------------------------------------
HIS.GetNext >LDA.G HIS.hBuf
beq HIS.Select.RTS
>LDA.G HIS.Count
beq HIS.Select.RTS empty history,nothing to do
>LDA.G HIS.Index
inc
>CMP.G HIS.Count
bne HIS.GetToCL
HIS.Reset >STZ.G HIS.Index
jmp CL.CLR
*--------------------------------------
HIS.GetToCL >STA.G HIS.Index
HIS.GetToCL1 jsr CL.CLR
jsr HIS.GetIndex
bcs .9
ldy #$ff
.1 iny
lda (ZPCLBuf),y
bne .1
tya
>STA.G CL.Ptr
>STA.G CL.Len
jmp CL.PrintCLBuf
.9 rts
*--------------------------------------
HIS.GetIndex >PUSHB.G HIS.hBuf
>PUSHBI 0
>PUSHB.G HIS.Index
>PUSHW ZPCLBuf
>SYSCALL StrVGet
rts
*--------------------------------------
MAN
SAVE usr/src/bin/sh.s.his
LOAD usr/src/bin/sh.s
ASM