PR#3 PREFIX /A2OSX.BUILD LOMEM $A00 INC 1 AUTO 6 .LIST OFF *-------------------------------------- HIS.Init >LDYAI 256 Get a buffer for History >SYSCALL GetMem0.YA bcs .9 txa >STA.G HIS.hBuf lda #0 >STA.G HIS.BufIndex >STA.G HIS.BufEnd .9 rts *-------------------------------------- HIS.Add >LDA.G HIS.hBuf beq .9 >SYSCALL GetMemPtr.A >STYA ZPPTR1 .10 >LDA.G HIS.BufEnd .11 sec add len+1 adc CmdBuflen 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 >STA.G HIS.BufEnd mark new end of history bra .11 retry.... .2 tax keep new HIS.BufEnd tay lda #0 sta (ZPPTR1),y set ending 0 >LDA.G HIS.BufEnd save old END pha txa get back new END >STA.G HIS.BufIndex set it as new IDX >STA.G HIS.BufEnd set new HIS.BufEnd pla get back old END clc adc ZPPTR1 sta ZPPTR1 bcc .3 inc ZPPTR1+1 .3 ldy #0 .4 lda (ZPCMDBuf),y beq .5 iny sta (ZPPTR1),y iny bra .4 .5 tya sta (ZPPTR1) .9 rts *-------------------------------------- HIS.GetPrev >LDA.G HIS.hBuf beq HISTORY.RTS tax >LDA.G HIS.BufEnd beq HISTORY.RTS empty history,nothing to do >LDA.G HIS.BufIndex beq HISTORY.RTS already oldest,nothing to do txa >SYSCALL GetMemPtr.A >STYA ZPPTR1 lda #0 .1 tax tay sec adc (ZPPTR1),y bcs History.RTS out of buffer ldy #HIS.BufIndex cmp (pData),y bne .1 reached current index .2 txa >STA.G HIS.BufIndex set new index bra HIS.SetBuf History.RTS rts *-------------------------------------- HIS.GetNext >LDA.G HIS.hBuf beq HISTORY.RTS tax >LDA.G HIS.BufEnd beq HISTORY.RTS empty history,nothing to do >CMP.G HIS.BufIndex beq HISTORY.RTS already oldest,nothing to do txa >SYSCALL GetMemPtr.A >STYA ZPPTR1 >LDA.G HIS.BufIndex tay sec adc (ZPPTR1),y add length+1 of current line in history >STA.G HIS.BufIndex >CMP.G HIS.BufEnd bne HIS.SetBuf jmp CmdLine.CLR end of history, just blank buffer *-------------------------------------- HIS.SetBuf jsr CmdLine.CLR >LDA.G HIS.BufIndex tay keep length of string clc adc ZPPTR1 sta ZPPTR1 bcc .1 inc ZPPTR1+1 .1 lda (ZPPTR1),y sta (ZPCMDBuf),y dey bpl .1 jmp CmdLine.SET *-------------------------------------- HIS.Quit >LDA.G HIS.hBuf beq .9 >SYSCALL FreeMem.A .9 rts *-------------------------------------- MAN SAVE /A2OSX.SRC/SBIN/SHELL.S.HIS LOAD /A2OSX.SRC/SBIN/SHELL.S ASM