mirror of
https://github.com/a2-4am/4cade.git
synced 2025-08-07 03:26:10 +00:00
toggle both pages in search mode, update match highlighting even if screenshot doesn't change, support Esc to clear
This commit is contained in:
@@ -8,28 +8,28 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
; indices into InputDispatchTable
|
; indices into InputDispatchTable
|
||||||
kInputSearchKey= 0
|
kInputSearch = 0
|
||||||
kInputBackspace= 1
|
kInputClear = 1
|
||||||
kInputEnter = 2
|
kInputBack = 2
|
||||||
|
kInputLaunch = 3
|
||||||
|
|
||||||
InputDispatchTable
|
InputDispatchTable
|
||||||
!word OnSearchKey
|
!word OnSearch
|
||||||
!word OnBackspace
|
!word OnClear
|
||||||
!word OnEnter
|
!word OnBack
|
||||||
|
!word OnLaunch
|
||||||
|
|
||||||
SearchMode
|
SearchMode
|
||||||
jsr Home ; switches to text mode
|
jsr Home
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
|
sta OffscreenPage
|
||||||
sta InputLength
|
sta InputLength
|
||||||
|
|
||||||
jsr OnInputChanged
|
jsr OnInputChanged ; draw default UI on HGR page 1
|
||||||
|
|
||||||
bit $C054 ; show it
|
|
||||||
bit $C052
|
bit $C052
|
||||||
bit $C057
|
bit $C057
|
||||||
bit $C050
|
bit $C050
|
||||||
|
|
||||||
bit $C010
|
bit $C010
|
||||||
InputLoop
|
InputLoop
|
||||||
- lda $C000
|
- lda $C000
|
||||||
@@ -39,16 +39,20 @@ InputLoop
|
|||||||
|
|
||||||
cmp #$7F ; delete key
|
cmp #$7F ; delete key
|
||||||
bne +
|
bne +
|
||||||
- jsr ResetTextRank
|
- ldx #kInputBack
|
||||||
ldx #kInputBackspace
|
|
||||||
bne InputDispatch ; always branches
|
bne InputDispatch ; always branches
|
||||||
|
|
||||||
+ cmp #$08 ; left arrow = delete
|
+ cmp #$08 ; left arrow = delete
|
||||||
beq -
|
beq -
|
||||||
|
|
||||||
|
cmp #$1B ; Esc clears the input buffer
|
||||||
|
bne +
|
||||||
|
ldx #kInputClear
|
||||||
|
bne InputDispatch ; always branches
|
||||||
|
|
||||||
cmp #$0D ; ENTER launches the current game (if any)
|
cmp #$0D ; ENTER launches the current game (if any)
|
||||||
bne +
|
bne +
|
||||||
ldx #kInputEnter
|
ldx #kInputLaunch
|
||||||
bne InputDispatch ; always branches
|
bne InputDispatch ; always branches
|
||||||
+
|
+
|
||||||
cmp #$30 ; control keys and punctuation ignored
|
cmp #$30 ; control keys and punctuation ignored
|
||||||
@@ -72,7 +76,7 @@ InputLoop
|
|||||||
jmp InputLoop ; and start over
|
jmp InputLoop ; and start over
|
||||||
|
|
||||||
@goodkey
|
@goodkey
|
||||||
ldx #kInputSearchKey
|
ldx #kInputSearch
|
||||||
; execution falls through here
|
; execution falls through here
|
||||||
InputDispatch
|
InputDispatch
|
||||||
pha ; save key pressed
|
pha ; save key pressed
|
||||||
@@ -87,7 +91,16 @@ InputDispatch
|
|||||||
@j jsr $FDFD ; SMC
|
@j jsr $FDFD ; SMC
|
||||||
jmp InputLoop
|
jmp InputLoop
|
||||||
|
|
||||||
OnBackspace
|
OnClear
|
||||||
|
ldx InputLength
|
||||||
|
bne +
|
||||||
|
jsr SoftBell
|
||||||
|
rts
|
||||||
|
+ ldx #0
|
||||||
|
stx InputLength
|
||||||
|
jmp OnInputChanged
|
||||||
|
|
||||||
|
OnBack
|
||||||
ldx InputLength
|
ldx InputLength
|
||||||
bne +
|
bne +
|
||||||
jsr SoftBell
|
jsr SoftBell
|
||||||
@@ -95,11 +108,11 @@ OnBackspace
|
|||||||
+ dec InputLength
|
+ dec InputLength
|
||||||
jmp OnInputChanged
|
jmp OnInputChanged
|
||||||
|
|
||||||
OnEnter
|
OnLaunch
|
||||||
; TODO
|
; TODO
|
||||||
rts
|
rts
|
||||||
|
|
||||||
OnSearchKey
|
OnSearch
|
||||||
ldx InputLength
|
ldx InputLength
|
||||||
cpx #MaxInputLength
|
cpx #MaxInputLength
|
||||||
bne +
|
bne +
|
||||||
@@ -114,7 +127,7 @@ OnInputChanged
|
|||||||
bne @findMatchingTitle
|
bne @findMatchingTitle
|
||||||
; no input, reset params and UI
|
; no input, reset params and UI
|
||||||
lda #$FF
|
lda #$FF
|
||||||
sta SelectedIndex ; reset selected index
|
sta SelectedIndex ; no game selected
|
||||||
ldx #40 ; reset visible line
|
ldx #40 ; reset visible line
|
||||||
lda #0
|
lda #0
|
||||||
- sta UILine1-1,x
|
- sta UILine1-1,x
|
||||||
@@ -128,18 +141,19 @@ OnInputChanged
|
|||||||
lda #$7F
|
lda #$7F
|
||||||
sta UILine2+1
|
sta UILine2+1
|
||||||
|
|
||||||
|
lda OffscreenPage
|
||||||
|
beq +
|
||||||
|
lda #$40
|
||||||
|
+HIDE_NEXT_2_BYTES
|
||||||
|
+ lda #$20
|
||||||
|
sta @coveraddress+1
|
||||||
+LDADDR Cover
|
+LDADDR Cover
|
||||||
jsr SetPath
|
jsr SetPath
|
||||||
jsr LoadFile ; load default background at $2000
|
jsr LoadFileAt ; load default background
|
||||||
|
@coveraddress
|
||||||
lda #22 ; draw visible search bar
|
!word $FD00
|
||||||
sta VTAB
|
jsr _DrawSearchBarOffscreen
|
||||||
clc ; on page 1
|
jmp _ShowOtherPage
|
||||||
+LDADDR UILine1
|
|
||||||
jsr Draw40Chars
|
|
||||||
clc
|
|
||||||
+LDADDR UILine2
|
|
||||||
jmp Draw40Chars
|
|
||||||
|
|
||||||
@findMatchingTitle
|
@findMatchingTitle
|
||||||
jsr ResetTextRank
|
jsr ResetTextRank
|
||||||
@@ -148,28 +162,47 @@ OnInputChanged
|
|||||||
!word gGamesListStore ; and rank them for the best match
|
!word gGamesListStore ; and rank them for the best match
|
||||||
!word TextRankCallback ; to the current input buffer
|
!word TextRankCallback ; to the current input buffer
|
||||||
|
|
||||||
lda MatchCount ; check match count
|
lda MatchCount ; any matches at all?
|
||||||
bne @yeschange
|
bne +
|
||||||
jsr SoftBell ; no matches for this input buffer, beep
|
jsr SoftBell ; no matches for this input buffer, beep
|
||||||
dec InputLength ; and ignore the last key typed
|
dec InputLength ; and ignore the last key typed
|
||||||
@nochange
|
|
||||||
rts
|
rts
|
||||||
@yeschange
|
+
|
||||||
lda BestMatchIndex
|
lda BestMatchIndex ; check if the new best match is the same
|
||||||
cmp SelectedIndex ; we found a 'new' best match but it's the
|
cmp SelectedIndex ; as the current best match
|
||||||
beq @nochange ; same as the current match, so we're done
|
php ; (we'll use this later to skip reloading)
|
||||||
; TODO re-highlight here
|
|
||||||
|
|
||||||
sta SelectedIndex ; we have a new best match, so load the
|
sta SelectedIndex
|
||||||
sta @index ; new title screenshot and display the
|
sta @index
|
||||||
jsr okvs_nth ; new game title in the search bar
|
jsr okvs_nth
|
||||||
!word gGamesListStore
|
!word gGamesListStore
|
||||||
@index !byte $FD
|
@index !byte $FD
|
||||||
+STAY @key
|
+STAY @key
|
||||||
|
|
||||||
; load game title page at $4000 (page 2, not currently visible)
|
plp
|
||||||
+LOAD_FILE kHGRTitleDirectory, @key
|
bne +
|
||||||
|
lda OffscreenPage
|
||||||
|
eor #$01
|
||||||
|
sta OffscreenPage
|
||||||
|
jmp @skipload
|
||||||
|
+
|
||||||
|
lda OffscreenPage ; we have a new best match, so load the
|
||||||
|
beq + ; new title screenshot (offscreen)
|
||||||
|
lda #$40
|
||||||
|
+HIDE_NEXT_2_BYTES
|
||||||
|
+ lda #$20
|
||||||
|
sta @titleaddress+1
|
||||||
|
+LDADDR kHGRTitleDirectory
|
||||||
|
jsr SetPath
|
||||||
|
+LDADDR kPathSeparator
|
||||||
|
jsr AddToPath
|
||||||
|
+LDAY @key
|
||||||
|
jsr AddToPath
|
||||||
|
jsr LoadFileAt
|
||||||
|
@titleaddress
|
||||||
|
!word $FD00
|
||||||
|
|
||||||
|
@skipload
|
||||||
jsr okvs_get
|
jsr okvs_get
|
||||||
!word gGamesListStore
|
!word gGamesListStore
|
||||||
@key !word $FDFD
|
@key !word $FDFD
|
||||||
@@ -183,14 +216,14 @@ OnInputChanged
|
|||||||
bcc +
|
bcc +
|
||||||
lda #" "
|
lda #" "
|
||||||
+HIDE_NEXT_2_BYTES
|
+HIDE_NEXT_2_BYTES
|
||||||
+ lda (SRC),y
|
+ lda (SRC),y ; copy game title to search UI
|
||||||
sta UILine2,y
|
sta UILine2,y
|
||||||
cpy #MaxInputLength+1
|
cpy #MaxInputLength+1
|
||||||
bcc -
|
bcc -
|
||||||
|
|
||||||
ldx #40
|
ldx #40
|
||||||
lda #0
|
lda #0
|
||||||
- sta UILine1-1,x
|
- sta UILine1-1,x ; reset search bar
|
||||||
dex
|
dex
|
||||||
bne -
|
bne -
|
||||||
tay
|
tay
|
||||||
@@ -198,7 +231,7 @@ OnInputChanged
|
|||||||
+LOW_ASCII_TO_LOWER
|
+LOW_ASCII_TO_LOWER
|
||||||
cmp InputBuffer,x
|
cmp InputBuffer,x
|
||||||
bne +
|
bne +
|
||||||
lda #$0B ; dot to highlight matched character
|
lda #$0B ; add dots to highlight matched characters
|
||||||
sta UILine1,y
|
sta UILine1,y
|
||||||
inx
|
inx
|
||||||
cpx InputLength
|
cpx InputLength
|
||||||
@@ -208,32 +241,29 @@ OnInputChanged
|
|||||||
cpy #40
|
cpy #40
|
||||||
bne -
|
bne -
|
||||||
@doneHighlight
|
@doneHighlight
|
||||||
|
jsr _DrawSearchBarOffscreen; actually draw the search UI (offscreen)
|
||||||
|
jmp _ShowOtherPage ; now show everything at once
|
||||||
|
|
||||||
lda #22 ; draw search bar
|
_DrawSearchBarOffscreen
|
||||||
|
lda #22 ; draw visible search bar
|
||||||
sta VTAB
|
sta VTAB
|
||||||
sec ; on page 2, not currently visible
|
lda OffscreenPage
|
||||||
|
ror ; draw on offscreen page
|
||||||
+LDADDR UILine1
|
+LDADDR UILine1
|
||||||
jsr Draw40Chars
|
jsr Draw40Chars
|
||||||
sec
|
lda OffscreenPage
|
||||||
|
ror ; draw on offscreen page
|
||||||
+LDADDR UILine2
|
+LDADDR UILine2
|
||||||
jsr Draw40Chars
|
jmp Draw40Chars
|
||||||
dec VTAB
|
|
||||||
|
|
||||||
|
_ShowOtherPage
|
||||||
|
lda OffscreenPage
|
||||||
|
eor #$01
|
||||||
|
sta OffscreenPage
|
||||||
|
bne +
|
||||||
bit $C055 ; show page 2
|
bit $C055 ; show page 2
|
||||||
ldx #$20 ; copy back to page 1
|
rts
|
||||||
stx @b+2 ; TODO delete this and use LoadFileAt
|
+ bit $C054 ; show page 1
|
||||||
lda #$40 ; to load title screenshots on different
|
|
||||||
sta @a+2 ; pages
|
|
||||||
ldy #0
|
|
||||||
@a lda $4000,y
|
|
||||||
@b sta $2000,y
|
|
||||||
iny
|
|
||||||
bne @a
|
|
||||||
inc @a+2
|
|
||||||
inc @b+2
|
|
||||||
dex
|
|
||||||
bne @a
|
|
||||||
bit $C054 ; show page 1
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
@@ -252,3 +282,9 @@ UILine2
|
|||||||
!byte $7F
|
!byte $7F
|
||||||
!text " "
|
!text " "
|
||||||
!text "] 000 games"
|
!text "] 000 games"
|
||||||
|
|
||||||
|
OffscreenPage
|
||||||
|
!byte 1 ; 0 = currently showing HGR page 2
|
||||||
|
; (so offscreen is page 1 @ $2000)
|
||||||
|
; 1 = currently showing HGR page 1
|
||||||
|
; (so offscreen is page 2 @ $4000)
|
||||||
|
Reference in New Issue
Block a user