WIP search mode

This commit is contained in:
4am 2019-06-18 17:07:14 -04:00
parent 03de1b2a1a
commit 7be18b8ce1
2 changed files with 34 additions and 29 deletions

View File

@ -48,6 +48,7 @@ ResetTextRank
ldx #0
stx MatchCount
stx BestMatchScore
dex
stx BestMatchIndex
rts
@ -69,9 +70,9 @@ TextRankCallback
+STAY zpstring ; A/Y = address of this title
+LDADDR InputLength
+STAY zpword
; ldy #0 ; first we'll check for an exact match
; lda (zpstring),y ; check length of this title against the input buffer
; sta gamelength
ldy #0 ; first we'll check for an exact match
lda (zpstring),y ; check length of this title against the input buffer
sta gamelength
; cmp InputLength
; bne + ; not equal, so can't be an exact match
; tay ; check for exact match

View File

@ -115,6 +115,11 @@ OnInputChanged
; no input, reset params and UI
lda #$FF
sta SelectedIndex ; reset selected index
ldx #40 ; reset visible line
lda #0
- sta UILine1-1,x
dex
bne -
ldy #MaxInputLength ; clear visible search bar
lda #" "
- sta UILine2+1,y
@ -136,16 +141,11 @@ OnInputChanged
jmp Draw40Chars
@findMatchingTitle
ldx #0 ; reset match count
stx MatchCount ; TextRankCallback will increment this if
; there are any matches
stx BestMatchScore
dex
stx BestMatchIndex
jsr ResetTextRank
jsr okvs_iter_values
!word gGamesListStore
!word TextRankCallback
jsr okvs_iter_values ; iterate through all game titles
!word gGamesListStore ; and rank them for the best match
!word TextRankCallback ; to the current input buffer
lda MatchCount ; check match count
bne @yeschange
@ -187,6 +187,27 @@ OnInputChanged
cpy #MaxInputLength+1
bcc -
ldx #40
lda #0
- sta UILine1-1,x
dex
bne -
tay
- lda (SRC),y
+LOW_ASCII_TO_LOWER
cmp InputBuffer,x
bne +
lda #$0B ; dot to highlight matched character
sta UILine1,y
inx
cpx InputLength
beq @doneHighlight
+ inc HTAB
iny
cpy #40
bne -
@doneHighlight
lda #22 ; draw search bar
sta VTAB
sec ; on page 2, not currently visible
@ -196,23 +217,6 @@ OnInputChanged
+LDADDR UILine2
jsr Draw40Chars
dec VTAB
ldx #0 ; highlight matched characters
ldy #0
- lda (SRC),y
+LOW_ASCII_TO_LOWER
cmp InputBuffer,x
bne +
sec ; on page 2
jsr InvertChar
inx
cpx InputLength
beq @doneHighlight
+ inc HTAB
iny
cpy #MaxInputLength
bne -
@doneHighlight
bit $C055 ; show page 2
ldx #$20 ; copy back to page 1