From 011948651a4b9d15f647be0cdf521a3c02b1de9b Mon Sep 17 00:00:00 2001 From: 4am Date: Sat, 6 Nov 2021 19:12:40 -0400 Subject: [PATCH] search cache --- Makefile | 4 ++++ res/CACHE01.IDX | Bin 2385 -> 2478 bytes res/CACHE11.IDX | Bin 3495 -> 3583 bytes src/4cade.init.a | 2 ++ src/constants.a | 5 ++++- src/prodos.path.a | 9 ++++++++ src/textrank.a | 48 ++++++++++++++++++++++++++++++++++++++++++- src/ui.search.mode.a | 4 +++- 8 files changed, 69 insertions(+), 3 deletions(-) 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 aa4864c8c0ff512eb672837694499d4673ebedaa..135416a8dc309feb74873474dd49417865fe8407 100644 GIT binary patch delta 939 zcmZ8fO=whS6g@ZdW|C+Un?H@2sAK&_K?N5^85I{5r0xoJ<>GtadvRWznfLO3CXOIM z#f3kgJ1{f^{h>YAB`QXP9b$Y=mMl-A?_+dUZ|H~T@ za*H7*BeNCu0{A@$dU&-BB8$N+cij+Ek<7xJ1*;SNT`0bZcu-AdozT;&*n@H_{23}7 zPpzCYQ#lLacB|b>6mq?g%dlfP$}5!9tGtcjRBH9A&D_K7MX(lwYglAG#5%|gu)b2I zb+EUqU=;@QsBYj{9<~U#XP2G`%yX==F{s7-zx7Y3yne?;W7ew45eX|M|g7>VoX_wnf@N7?@&IY+~WvNFg^+K zvw|Fjc^s9I8X;N5IfdW{Mq}7uv9B@p7V;H}ui?JoyJ;kd^sTY{ zIyPmTBsWb~HMaM}?sW3LNiKr-I$m^@n%oQ$Eo6Vj!wl&SLl4tMh7LS=dg3q-Lbebo2uQv4A)m^;8R7m|H1u7>$OLXHLGRz ZJ@{1My^(rKjO6MQSKL(@@OP(+@D2>;0^0xp delta 852 zcmX|9OKePG7(L&-s44!GxxfWHp8MqSV*jH zgpi^HWr4)w|0hw=Ah8fZL^MIXA|+n&igNwiFd7?NfU?5XgZ5Hzv0 z7NQY7jf_$d*QMSFvmRC*x*CwZBY9CM?dqTn%WMwxeqsa_ho$ydz^M zZ!a4ihSfIm9ESKZEfa=7`FS zzVY>h4}&gd%pVw?KAX`$b5klE&5-1^bOoP=Q}*& z=0r&JmXSS895zAuZ+nA(rd{`QmM$?UoNk^qS)O)g-N`OabwTkEVF4bf8^gk#*79= ahy(vddGY_A2^#fGlmZwPIDkE!dcq&^*zg+w diff --git a/res/CACHE11.IDX b/res/CACHE11.IDX index e1b521d3a93aeb4765000b794473ca855ab78275..e2a3050b2055963cb8c512e2f064fa4ce1ea7830 100644 GIT binary patch delta 1484 zcmY*ZS!`5g6h2=|r-cL+2(+|Rh8D13q(VViiY-P&mb4M0mS~0l-q~*FF4MbAJA*J* zt;)XKK4E-lVw8jjVn~p=OJaE-J|IRGO+b`YP4LYnF@)%u0aTv;^PTgZ?aRIA(}uqr z_OG1q4zgXx26~PS?*DAf`HF&u__ks~L2_p?HBwa06xB;b&4k_$<7P3FfO)%UReAPg z&za+8vlw_A6n!5`tCt;SYd1u@C+$US2U6XhvdPnT!q^9E562Eb$X?uqHUeXWaV3db z(jsIv5=EzwI)k5zN>Y;UN0rS;yJMA8o40z_L+q|AQKcy)@A6``l$b`z>7-1hbUoRl z?q8LyHAg&(t|D>5eR5n=;iM-op!j@JTBz@FQcrsW3n;gM^5>Y;LefP~T}XN}**6%k zByr1=+DK_5Z4nuZiKM4VSx)H{q&`LZ(_}6s=a0L@c9Po3=%7po-WsR?Pk+I$# zSJm9!?W-F}dx`W{{7es-J!EYnNA?F^W$I=UuaUfk6wTN2zA@xGT{O^3xh)*)C1co? zt5!Dd_ETxnRLW>%x!l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uLbS{&7D;&8(Wki&^K=yZh^cNDB zD0h|74g-6rM#h53nIw0TtJg>@kJO8dej@!k87m|ENAiAVeuKn1f3WcZbou)m zQ`qLe-`F~TS7g<}se}6`D;l8g=9>}_gZ}l#xfLa{a*@j$r|yC%@naS;v!UG$Yc_wD z(;-H=)&l83q|Afb41GK@7Qk$Vvyl6XAx=d~3o=WPT?91=<6f9a*eN(ExbN}NcBGfE zuoZd|Zabr;5FbR+Cs8I@)B9f2+WQ06t$^5xbRS4eM9K=-t5~`kawpU^FgxLW<$v4M zyzx>btw;J1?sXy44XvBeW{9hiya`Gl(l?{rHmH9@`Ny!Q2lhsITT$4K(k;GW7XbKf_0dz(2Po;HXT7AzYXxcp8%|L>^|IQ5v!YO@^&7(INIgGZ_^j+G43A zmh(_JCc5HUOvrK0fTqX)WJDhJ2pl(d_r_ic91xVsK(1urW*J%#V{x`N>p5id(94Wo zfOsC}i;QeYF05m*<1!gV&V!em8c~5U3U`#t`ysy!WgqUO&4F6ZaKhN9mVpoKL+|6D|)A; 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