diff --git a/Makefile b/Makefile index 21728c942..6b22fb5cd 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,10 @@ dsk: asm index build/SEARCH01.IDX \ build/SEARCH10.IDX \ build/SEARCH11.IDX \ + res/CACHE00.IDX \ + res/CACHE01.IDX \ + res/CACHE10.IDX \ + res/CACHE11.IDX \ build/FX.IDX \ build/DFX.IDX \ build/GAMEHELP.IDX \ diff --git a/res/CACHE01.IDX b/res/CACHE01.IDX index aa4864c8c..135416a8d 100644 Binary files a/res/CACHE01.IDX and b/res/CACHE01.IDX differ diff --git a/res/CACHE11.IDX b/res/CACHE11.IDX index e1b521d3a..e2a3050b2 100644 Binary files a/res/CACHE11.IDX and b/res/CACHE11.IDX differ diff --git a/src/4cade.init.a b/src/4cade.init.a index 2202d04f3..5fb944231 100644 --- a/src/4cade.init.a +++ b/src/4cade.init.a @@ -400,12 +400,14 @@ CopyDevs beq + ; SEARCH00.IDX, SEARCH01.IDX, SEARCH10.IDX, SEARCH11.IDX, inx ; which correspond to X + stx gSearchHasJoystick ; . + stx gCacheHasJoystick ldx #$30 ; Once we construct the filename, we'll forever after lda MachineStatus ; load and reload the correct list of games that and #HAS_128K ; this machine can play. beq + inx + stx gSearchHas128K + stx gCacheHas128K lda #0 ; Read just the first 2 bytes of the search index sta sizelo ; to get the size, which is the number of games. diff --git a/src/constants.a b/src/constants.a index 3072749fe..bccc447c2 100644 --- a/src/constants.a +++ b/src/constants.a @@ -116,6 +116,9 @@ UI_ToPlay = $1FF7 gValLen = $1F80 gVal = $1F81 +gSearchIndex = $8200 +gSearchCache = $B000 + ; LC RAM 1 iLoadFileDirect = $FFEF WaitForVBL = $FFF2 @@ -153,7 +156,7 @@ PRELAUNCH_STANDARD_SIZE = 61 ; LoadStandardPrelaunch, eventually to be d iCurBlockLo = $D401 ; constant iCurBlockHi = $D403 ; constant launchpatch = $D662 ; glue.launch.a -iAddToPath = $FE8F ; Roger Rabbit, avoid, use Infiltrator 2 style instead +iAddToPath = $FE83 ; Roger Rabbit, avoid, use Infiltrator 2 style instead itraverse = $D964 ; Roger Rabbit, avoid, use Infiltrator 2 style instead ldrlo = $55 ; constant ldrhi = $56 ; constant diff --git a/src/prodos.path.a b/src/prodos.path.a index 4310b6303..5e8ee4d5d 100644 --- a/src/prodos.path.a +++ b/src/prodos.path.a @@ -205,3 +205,12 @@ gSearchHasJoystick gSearchHas128K !raw "_" !raw ".IDX" + +kSearchCacheFile + !byte 11 + !raw "CACHE" +gCacheHasJoystick + !raw "_" +gCacheHas128K + !raw "_" + !raw ".IDX" diff --git a/src/textrank.a b/src/textrank.a index 9e9921d86..5f2fedad6 100644 --- a/src/textrank.a +++ b/src/textrank.a @@ -6,6 +6,7 @@ ; Public functions ; - ReloadSearchIndex ; - ResetTextRank +; - FindTitleInCache ; - TextRankCallback (as okvs_iter_values callback) ; ; Public variables @@ -36,7 +37,52 @@ ReloadSearchIndex jsr LoadFile ; load appropriate search index into $8200 !word kRootDirectory !word kSearchIndexFile - !word $8200 + !word gSearchIndex + jsr LoadFile ; load appropriate search cache into $B000 + !word kRootDirectory + !word kSearchCacheFile + !word gSearchCache + rts + +FindTitleInCache + ldx InputLength + cpx #5 + bcs @nomatch + lda #$20 + sta InputBuffer, x + +LDADDR gSearchCache + +ST16 PTR + ldx #$FF +-- inx + ldy #0 +- lda (PTR), y + beq @nomatch + cmp InputBuffer, x + beq @matchchar + iny + iny + iny + bne - ; always branches +@matchchar + iny + lda (PTR), y + pha + iny + lda (PTR), y + bpl @foundindex + sta PTR+1 + pla + sta PTR + cpx InputLength + bcc -- +@nomatch + sec + rts +@foundindex + sta BestMatchIndex+1 + pla + sta BestMatchIndex + clc rts ;------------------------------------------------------------------------------ diff --git a/src/ui.search.mode.a b/src/ui.search.mode.a index 2b2811332..6c56292cd 100644 --- a/src/ui.search.mode.a +++ b/src/ui.search.mode.a @@ -199,8 +199,10 @@ FindMatchingTitle jsr SwitchToBank2 jsr EnableAcceleratorAndSwitchToBank1 - jsr ResetTextRank + jsr FindTitleInCache + bcc + ; sets BestMatchIndex on success + jsr ResetTextRank jsr okvs_iter_values ; iterate through all game display names !word gSearchStore ; and rank them for the best match !word TextRankCallback ; to the current input buffer