mirror of
https://github.com/a2-4am/4live.git
synced 2025-01-02 13:30:48 +00:00
Merge pull request #21 from peterferrie/master
add memory-search option
This commit is contained in:
commit
ed27b90a7f
188
src/4live.a
188
src/4live.a
@ -1,6 +1,6 @@
|
|||||||
;
|
;
|
||||||
; 4LIVE
|
; 4LIVE
|
||||||
; Copyright (c) 2016-7 by 4am && qkumba
|
; Copyright (c) 2016-8 by 4am && qkumba
|
||||||
; 100% open source, see LICENSE file
|
; 100% open source, see LICENSE file
|
||||||
;
|
;
|
||||||
!cpu 6502
|
!cpu 6502
|
||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
;user-defined
|
;user-defined
|
||||||
HOTKEY = $80 ; CTRL-@
|
HOTKEY = $80 ; CTRL-@
|
||||||
|
FINDKEY = $86 ; CTRL-F
|
||||||
HIGHLIGHTKEY = $82 ; CTRL-B
|
HIGHLIGHTKEY = $82 ; CTRL-B
|
||||||
CLEARKEY = $83 ; CTRL-C
|
CLEARKEY = $83 ; CTRL-C
|
||||||
PREVPAGEKEY = $92 ; CTRL-R
|
PREVPAGEKEY = $92 ; CTRL-R
|
||||||
@ -17,6 +18,7 @@
|
|||||||
|
|
||||||
VERBOSE = $0 ; set to 1 to show memory usage during build
|
VERBOSE = $0 ; set to 1 to show memory usage during build
|
||||||
;
|
;
|
||||||
|
!addr PROMPT = $33
|
||||||
!addr KSWL = $38
|
!addr KSWL = $38
|
||||||
!addr KSWH = $39
|
!addr KSWH = $39
|
||||||
!addr FCBFOP = $40
|
!addr FCBFOP = $40
|
||||||
@ -30,9 +32,12 @@
|
|||||||
!addr LCBANK2 = $C083
|
!addr LCBANK2 = $C083
|
||||||
!addr ROMIN1 = $C089
|
!addr ROMIN1 = $C089
|
||||||
!addr LCBANK1 = $C08B
|
!addr LCBANK1 = $C08B
|
||||||
|
!addr SCRN2P2 = $F87B ;SCRN2 +2
|
||||||
|
!addr PRNTYX = $F940
|
||||||
!addr APLDETECT = $FBB3 ;#06 if IIe or later
|
!addr APLDETECT = $FBB3 ;#06 if IIe or later
|
||||||
!addr KEYIN = $FD1B
|
!addr KEYIN = $FD1B
|
||||||
!addr RDCHAR = $FD35
|
!addr RDCHAR = $FD35
|
||||||
|
!addr CROUT = $FD8E
|
||||||
!addr COUT = $FDED
|
!addr COUT = $FDED
|
||||||
|
|
||||||
;private arbitrary addresses, shared with DOS to avoid conflict
|
;private arbitrary addresses, shared with DOS to avoid conflict
|
||||||
@ -58,6 +63,8 @@
|
|||||||
SPACE = $A0
|
SPACE = $A0
|
||||||
DELETE = $FF
|
DELETE = $FF
|
||||||
|
|
||||||
|
WILDCARD = $97
|
||||||
|
|
||||||
IOBSLOT = 1
|
IOBSLOT = 1
|
||||||
IOBDRIVE = 2
|
IOBDRIVE = 2
|
||||||
NAMELEN = 30
|
NAMELEN = 30
|
||||||
@ -72,8 +79,8 @@
|
|||||||
POSRDWRRANGE = 4
|
POSRDWRRANGE = 4
|
||||||
WIDTH = 40
|
WIDTH = 40
|
||||||
HEIGHT = 24
|
HEIGHT = 24
|
||||||
LDRBASE = $2E9
|
LDRBASE = $2DB
|
||||||
INSTALLBUFFER = $232 ; yes, the overlay overwrites the loader...
|
INSTALLBUFFER = $21E ; yes, the overlay overwrites the loader...
|
||||||
; see also "warning!" below
|
; see also "warning!" below
|
||||||
SWAPBUFFER = $900 ; (LoadSaveEnd - LoadSaveStart) size
|
SWAPBUFFER = $900 ; (LoadSaveEnd - LoadSaveStart) size
|
||||||
; needed by Diversi-DOS, must be page-aligned
|
; needed by Diversi-DOS, must be page-aligned
|
||||||
@ -108,12 +115,8 @@ LdrStart
|
|||||||
sta FileDrive
|
sta FileDrive
|
||||||
dey ;ldy #IOBSLOT
|
dey ;ldy #IOBSLOT
|
||||||
lda (OPSRC1L), y
|
lda (OPSRC1L), y
|
||||||
lsr
|
jsr SCRN2P2
|
||||||
lsr
|
|
||||||
lsr
|
|
||||||
lsr
|
|
||||||
sta FileSlot
|
sta FileSlot
|
||||||
dey ;ldy #00
|
|
||||||
|
|
||||||
;open self and read first overlay
|
;open self and read first overlay
|
||||||
|
|
||||||
@ -231,6 +234,18 @@ BankInRAM1
|
|||||||
bit LCBANK1
|
bit LCBANK1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
PrintAddr
|
||||||
|
bit ROMIN1
|
||||||
|
jsr PRNTYX
|
||||||
|
|
||||||
|
PrintCR
|
||||||
|
lda #RETURN
|
||||||
|
|
||||||
|
PrintChar
|
||||||
|
bit ROMIN1
|
||||||
|
jsr COUT
|
||||||
|
bne BankInRAM1
|
||||||
|
|
||||||
;read file content into memory
|
;read file content into memory
|
||||||
;with swapping of the memory contents in Diversi-DOS,
|
;with swapping of the memory contents in Diversi-DOS,
|
||||||
;in order to preserve the original memory region
|
;in order to preserve the original memory region
|
||||||
@ -444,11 +459,19 @@ GetKey
|
|||||||
|
|
||||||
cmp #HOTKEY
|
cmp #HOTKEY
|
||||||
|
|
||||||
|
;yes -> let's do that
|
||||||
|
|
||||||
|
beq +
|
||||||
|
|
||||||
|
;memory search?
|
||||||
|
|
||||||
|
cmp #FINDKEY
|
||||||
|
|
||||||
;no -> return to DOS
|
;no -> return to DOS
|
||||||
|
|
||||||
bne ReuseRts
|
bne ReuseRts
|
||||||
|
|
||||||
jsr BankInRAM1
|
+ jsr BankInRAM1
|
||||||
jsr RunFromBankedRAM
|
jsr RunFromBankedRAM
|
||||||
lda ROMIN1
|
lda ROMIN1
|
||||||
|
|
||||||
@ -475,6 +498,9 @@ InstallEnd
|
|||||||
BankedCopyStart
|
BankedCopyStart
|
||||||
!pseudopc $D000 {
|
!pseudopc $D000 {
|
||||||
RunFromBankedRAM
|
RunFromBankedRAM
|
||||||
|
cmp #FINDKEY
|
||||||
|
beq FindChars
|
||||||
|
|
||||||
;preserve X across calls
|
;preserve X across calls
|
||||||
;it's important for DOS
|
;it's important for DOS
|
||||||
|
|
||||||
@ -507,6 +533,148 @@ RunFromBankedRAM
|
|||||||
tax
|
tax
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
FindChars
|
||||||
|
sty CharCount + 1
|
||||||
|
ldx #0
|
||||||
|
ldy #0
|
||||||
|
|
||||||
|
ConvertChars
|
||||||
|
cmp #$10
|
||||||
|
bcs NextChar
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
sta OPSRC1L
|
||||||
|
jsr Char2Nib
|
||||||
|
ora OPSRC1L
|
||||||
|
sta SECTORBUFFER, y
|
||||||
|
iny
|
||||||
|
|
||||||
|
NextChar
|
||||||
|
jsr Char2Nib
|
||||||
|
|
||||||
|
CharCount
|
||||||
|
cpx #0 ;self-modified
|
||||||
|
bcc ConvertChars
|
||||||
|
jsr PrintCR
|
||||||
|
dex
|
||||||
|
beq CancelLine
|
||||||
|
jsr SearchMemory
|
||||||
|
|
||||||
|
CancelLine
|
||||||
|
ldx #0
|
||||||
|
lda PROMPT
|
||||||
|
tay ;in case Y was zero
|
||||||
|
jmp PrintChar
|
||||||
|
|
||||||
|
SearchMemory
|
||||||
|
lda DOSBASE
|
||||||
|
sta .endvalue+1
|
||||||
|
lda #8
|
||||||
|
sta search+2
|
||||||
|
sty match_size1+1
|
||||||
|
sty match_size2+1
|
||||||
|
|
||||||
|
; fetch last byte to improve search speed
|
||||||
|
|
||||||
|
dey
|
||||||
|
|
||||||
|
match_buffer1
|
||||||
|
lda SECTORBUFFER,y
|
||||||
|
sta check_byte1+1
|
||||||
|
sta check_byte2+1
|
||||||
|
|
||||||
|
; set low part of initial search position
|
||||||
|
|
||||||
|
sty cont_search+1
|
||||||
|
|
||||||
|
lda #<cont_search-branch_cont-2
|
||||||
|
sta branch_cont+1
|
||||||
|
|
||||||
|
; search...
|
||||||
|
|
||||||
|
cont_search
|
||||||
|
ldy #$d1 ; modified at runtime
|
||||||
|
|
||||||
|
search
|
||||||
|
lda $d100,y ; modified at runtime
|
||||||
|
iny
|
||||||
|
beq check_end
|
||||||
|
|
||||||
|
check_byte1
|
||||||
|
cmp #$d1 ; modified at runtime
|
||||||
|
bne search
|
||||||
|
|
||||||
|
; point to first byte
|
||||||
|
|
||||||
|
sty cont_search+1
|
||||||
|
|
||||||
|
check_match
|
||||||
|
tya
|
||||||
|
|
||||||
|
match_size1
|
||||||
|
sbc #$d1 ; modified at runtime
|
||||||
|
sta match_buffer2+1
|
||||||
|
lda search+2
|
||||||
|
sbc #$00
|
||||||
|
sta match_buffer2+2
|
||||||
|
ldy #$00
|
||||||
|
|
||||||
|
match_all
|
||||||
|
lda SECTORBUFFER,y
|
||||||
|
cmp #WILDCARD
|
||||||
|
beq found_wild
|
||||||
|
|
||||||
|
match_buffer2
|
||||||
|
cmp $d1d1,y ; modified at runtime
|
||||||
|
|
||||||
|
branch_cont
|
||||||
|
bne cont_search
|
||||||
|
|
||||||
|
found_wild
|
||||||
|
iny
|
||||||
|
|
||||||
|
match_size2
|
||||||
|
cpy #$d1 ; modified at runtime
|
||||||
|
bne match_all
|
||||||
|
|
||||||
|
; point to start of match
|
||||||
|
|
||||||
|
ldx match_buffer2+1
|
||||||
|
ldy match_buffer2+2
|
||||||
|
jsr PrintAddr
|
||||||
|
tya
|
||||||
|
bne branch_cont
|
||||||
|
|
||||||
|
; cold path
|
||||||
|
|
||||||
|
check_end
|
||||||
|
inc search+2
|
||||||
|
ldx search+2
|
||||||
|
.endvalue
|
||||||
|
cpx #$D1
|
||||||
|
bne check_byte1
|
||||||
|
ldx #<all_done_set-branch_cont-2
|
||||||
|
stx branch_cont+1
|
||||||
|
|
||||||
|
check_byte2
|
||||||
|
cmp #$d1 ; modified at runtime
|
||||||
|
beq check_match
|
||||||
|
|
||||||
|
all_done_set
|
||||||
|
;fall through
|
||||||
|
|
||||||
|
Char2Nib
|
||||||
|
lda $0200, x
|
||||||
|
inx
|
||||||
|
sec
|
||||||
|
sbc #$B0
|
||||||
|
cmp #$0A
|
||||||
|
bcc +
|
||||||
|
sbc #7
|
||||||
|
+ rts
|
||||||
|
|
||||||
ScrollEditBufferIn
|
ScrollEditBufferIn
|
||||||
ldy #(<(ScrollParmsDown - ScrollParms) - 1)
|
ldy #(<(ScrollParmsDown - ScrollParms) - 1)
|
||||||
jsr SetScrollLine
|
jsr SetScrollLine
|
||||||
@ -1526,7 +1694,7 @@ SecondLine
|
|||||||
!fill WIDTH * 7, SPACE
|
!fill WIDTH * 7, SPACE
|
||||||
!text " 4LIVE by 4am && qkumba "
|
!text " 4LIVE by 4am && qkumba "
|
||||||
!fill WIDTH, SPACE
|
!fill WIDTH, SPACE
|
||||||
!text " Revision 04 / Serial number 170123 "
|
!text " Revision 05 / Serial number 180410 "
|
||||||
!fill WIDTH * 2, SPACE
|
!fill WIDTH * 2, SPACE
|
||||||
!text " https://github.com/a2-4am/4live "
|
!text " https://github.com/a2-4am/4live "
|
||||||
!fill WIDTH * 9, SPACE
|
!fill WIDTH * 9, SPACE
|
||||||
|
Loading…
Reference in New Issue
Block a user