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

View File

@ -115,6 +115,11 @@ OnInputChanged
; no input, reset params and UI ; no input, reset params and UI
lda #$FF lda #$FF
sta SelectedIndex ; reset selected index sta SelectedIndex ; reset selected index
ldx #40 ; reset visible line
lda #0
- sta UILine1-1,x
dex
bne -
ldy #MaxInputLength ; clear visible search bar ldy #MaxInputLength ; clear visible search bar
lda #" " lda #" "
- sta UILine2+1,y - sta UILine2+1,y
@ -136,16 +141,11 @@ OnInputChanged
jmp Draw40Chars jmp Draw40Chars
@findMatchingTitle @findMatchingTitle
ldx #0 ; reset match count jsr ResetTextRank
stx MatchCount ; TextRankCallback will increment this if
; there are any matches
stx BestMatchScore
dex
stx BestMatchIndex
jsr okvs_iter_values jsr okvs_iter_values ; iterate through all game titles
!word gGamesListStore !word gGamesListStore ; and rank them for the best match
!word TextRankCallback !word TextRankCallback ; to the current input buffer
lda MatchCount ; check match count lda MatchCount ; check match count
bne @yeschange bne @yeschange
@ -187,6 +187,27 @@ OnInputChanged
cpy #MaxInputLength+1 cpy #MaxInputLength+1
bcc - 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 lda #22 ; draw search bar
sta VTAB sta VTAB
sec ; on page 2, not currently visible sec ; on page 2, not currently visible
@ -196,23 +217,6 @@ OnInputChanged
+LDADDR UILine2 +LDADDR UILine2
jsr Draw40Chars jsr Draw40Chars
dec VTAB 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 bit $C055 ; show page 2
ldx #$20 ; copy back to page 1 ldx #$20 ; copy back to page 1