diff --git a/Makefile b/Makefile index 57f70e255..2464803cb 100644 --- a/Makefile +++ b/Makefile @@ -53,14 +53,6 @@ dsk: index asmproboot asmlauncher build/PREFS.CONF \ build/CREDITS \ build/HELPTEXT \ - build/SEARCH00.IDX \ - build/SEARCH01.IDX \ - build/SEARCH10.IDX \ - build/SEARCH11.IDX \ - res/CACHE00.IDX \ - res/CACHE01.IDX \ - res/CACHE10.IDX \ - res/CACHE11.IDX \ build/HGR0.IDX \ build/HGR1.IDX \ build/HGR2.IDX \ @@ -116,13 +108,14 @@ index: md asmfx asmprelaunch compress [ -f build/GAMEHELP/"$$(basename $$f)" ] || (bin/converthelp.sh "$$f" build/GAMEHELP/"$$(basename $$f)"); \ done # -# create search indexes: (game-requires-joystick) X (game-requires-128K) +# create search indexes for each variation of (game-requires-joystick) X (game-requires-128K) +# in the form of OKVS data structures, plus game counts in the form of source files # [ -f build/GAMES.CONF ] || (awk '!/^$$|^#/' < res/GAMES.CONF > build/GAMES.CONF) - [ -f build/SEARCH00.IDX ] || (grep "^00" < build/GAMES.CONF | bin/buildsearch.sh > build/SEARCH00.IDX) - [ -f build/SEARCH01.IDX ] || (grep "^0" < build/GAMES.CONF | bin/buildsearch.sh > build/SEARCH01.IDX) - [ -f build/SEARCH10.IDX ] || (grep "^.0" < build/GAMES.CONF | bin/buildsearch.sh > build/SEARCH10.IDX) - [ -f build/SEARCH11.IDX ] || (bin/buildsearch.sh < build/GAMES.CONF > build/SEARCH11.IDX) + [ -f build/SEARCH00.IDX ] || (grep "^00" < build/GAMES.CONF | bin/buildsearch.sh src/index/count00.a > build/SEARCH00.IDX) + [ -f build/SEARCH01.IDX ] || (grep "^0" < build/GAMES.CONF | bin/buildsearch.sh src/index/count01.a > build/SEARCH01.IDX) + [ -f build/SEARCH10.IDX ] || (grep "^.0" < build/GAMES.CONF | bin/buildsearch.sh src/index/count10.a > build/SEARCH10.IDX) + [ -f build/SEARCH11.IDX ] || (bin/buildsearch.sh src/index/count11.a < build/GAMES.CONF > build/SEARCH11.IDX) # # create a sorted list of game filenames, without metadata or display names # @@ -183,6 +176,14 @@ index: md asmfx asmprelaunch compress # add IDX files to the combined index file and generate # the index records that callers use to reference them # + bin/addfile.sh build/SEARCH00.IDX build/TOTAL.IDX > src/index/search00.idx.a + bin/addfile.sh res/CACHE00.IDX build/TOTAL.IDX > src/index/cache00.idx.a + bin/addfile.sh build/SEARCH01.IDX build/TOTAL.IDX > src/index/search01.idx.a + bin/addfile.sh res/CACHE01.IDX build/TOTAL.IDX > src/index/cache01.idx.a + bin/addfile.sh build/SEARCH10.IDX build/TOTAL.IDX > src/index/search10.idx.a + bin/addfile.sh res/CACHE10.IDX build/TOTAL.IDX > src/index/cache10.idx.a + bin/addfile.sh build/SEARCH11.IDX build/TOTAL.IDX > src/index/search11.idx.a + bin/addfile.sh res/CACHE11.IDX build/TOTAL.IDX > src/index/cache11.idx.a bin/addfile.sh build/PRELAUNCH.IDX build/TOTAL.IDX > src/index/prelaunch.idx.a bin/addfile.sh build/ATTRACT.IDX build/TOTAL.IDX > src/index/attract.idx.a bin/addfile.sh build/FX.IDX build/TOTAL.IDX > src/index/fx.idx.a diff --git a/bin/buildsearch.sh b/bin/buildsearch.sh index 75daec3b2..e898962a7 100755 --- a/bin/buildsearch.sh +++ b/bin/buildsearch.sh @@ -4,6 +4,14 @@ records=$(mktemp) awk '!/^$|^#|^\[/' > "$records" +# generate source file with game count +(echo ";" + echo "; Game count" + echo ";" + echo "; This file is automatically generated" + echo ";" + echo "!word $(wc -l < "$records")") > "$1" + # make temp assembly source file that represents the binary OKVS data structure source=$(mktemp) (echo "*=0" # dummy program counter for assembler diff --git a/src/4cade.init.a b/src/4cade.init.a index 5fb944231..6329a575c 100644 --- a/src/4cade.init.a +++ b/src/4cade.init.a @@ -394,42 +394,40 @@ CopyDevs ora MachineStatus sta MachineStatus ; set bit 3 of MachineStatus - ldx #$30 ; Look at other bits of MachineStatus to build - lda MachineStatus ; the filename of the search index to use. - and #HAS_JOYSTICK ; There are 4 files on disk, named - 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 + rol + rol + rol + rol + and #%00000110 + tax ; X in (0,2,4,6) + ldy kGameCounts, x + sty GameCount ; store total game count based on based on (has-joystick) X (has-128K) + sty SAVE + ldy kGameCounts+1, x + sty GameCount+1 + sty SAVE+1 + lsr + tax ; X in (0,1,2,3) + lda kSearchIndexLo, x + sta @searchIndexSrc+1 ; set up search index record based on (has-joystick) X (has-128K) + lda kSearchIndexHi, x + sta @searchIndexSrc+2 + lda kSearchCacheLo, x + sta @searchCacheSrc+1 ; set up search cache record based on (has-joystick) X (has-128K) + lda kSearchCacheHi, x + sta @searchCacheSrc+2 + ldy #5 +@searchIndexSrc + lda $FDFD, y ; SMC + sta kSearchIndexRecord, y +@searchCacheSrc + lda $FDFD, y + sta kSearchCacheRecord, y + dey + bpl @searchIndexSrc - lda #0 ; Read just the first 2 bytes of the search index - sta sizelo ; to get the size, which is the number of games. - lda #2 ; (we will load the entire search index later.) - sta sizehi - jsr SwitchToBank2 - lda #$24 ; patch out code that calculates file size during load - sta LoadFileInternal_SizePatch - jsr SwitchToBank1 - jsr ReloadSearchIndex ; this will really only load the first 2 bytes - jsr SwitchToBank2 - lda #$85 ; restore code that calculates file size during load - sta LoadFileInternal_SizePatch - jsr SwitchToBank1 - +LDADDR gSearchStore - jsr okvs_len ; this works because it only looks at the first two bytes - +LD16 WCOUNT - +ST16 GameCount - +ST16 SAVE - - ; calculate and update visible game count (3-digit decimal number as ASCII string) - dey ; Y = 0 + ; convert GameCount (word) to VisibleGameCount (3-digit decimal number as ASCII string) + iny ; Y = 0 @outer lda #0 pha @@ -464,3 +462,45 @@ CopyDevs !byte 100 !byte 10 !byte 1 + +kSearchIndexLo + !byte kSearchIndexRecord00 + !byte >kSearchIndexRecord01 + !byte >kSearchIndexRecord10 + !byte >kSearchIndexRecord11 +kSearchCacheLo + !byte kSearchCacheRecord00 + !byte >kSearchCacheRecord01 + !byte >kSearchCacheRecord10 + !byte >kSearchCacheRecord11 +kSearchIndexRecord00 + !source "src/index/search00.idx.a" +kSearchIndexRecord01 + !source "src/index/search01.idx.a" +kSearchIndexRecord10 + !source "src/index/search10.idx.a" +kSearchIndexRecord11 + !source "src/index/search11.idx.a" +kSearchCacheRecord00 + !source "src/index/cache00.idx.a" +kSearchCacheRecord01 + !source "src/index/cache01.idx.a" +kSearchCacheRecord10 + !source "src/index/cache10.idx.a" +kSearchCacheRecord11 + !source "src/index/cache11.idx.a" +kGameCounts + !source "src/index/count00.a" + !source "src/index/count01.a" + !source "src/index/count10.a" + !source "src/index/count11.a" diff --git a/src/constants.a b/src/constants.a index e71e77c40..32b18e782 100644 --- a/src/constants.a +++ b/src/constants.a @@ -11,7 +11,7 @@ ; ...unused... ; E000..E3FF - HGR font data ; ...unused... -; E984..FFEE - main program code +; E8FF..FFEE - main program code ; FFEF..FFF9 - API functions and global constants available for main program ; code, prelaunchers, transition effects, &c. ; (LoadFileDirect, Wait/UnwaitForVBL, MockingboardStuff, MachineStatus) @@ -60,15 +60,14 @@ ; 2000..5FFF - hi-res screens cleared ; A000.. - prelaunch index file ; -; MAIN MEMORY DURING CREDITS +; MAIN MEMORY DURING CREDITS (preserves search index and cache) ; 0800.. - credits text ; -; MAIN MEMORY DURING GLOBAL HELP +; MAIN MEMORY DURING GLOBAL HELP (preserves search index and cache) ; 0800.. - help text ; -; MAIN MEMORY DURING PER-GAME HELP +; MAIN MEMORY DURING PER-GAME HELP (clobbers search cache) ; 0800.. - help text -; 6000..9FFF - search index ; A000.. - game help index file ; ;------------------------------------------------------------------------------ @@ -202,7 +201,7 @@ PRELAUNCH_STANDARD_SIZE = 61 ; LoadStandardPrelaunch, eventually to be d iCurBlockLo = $D401 ; constant iCurBlockHi = $D403 ; constant launchpatch = $D662 ; glue.launch.a -iAddToPath = $FEC7 ; Roger Rabbit, avoid, use Infiltrator 2 style instead +iAddToPath = $FED4 ; 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/index/artwork.idx.a b/src/index/artwork.idx.a index 92e2bcfa5..e2d13d3a3 100644 --- a/src/index/artwork.idx.a +++ b/src/index/artwork.idx.a @@ -4,5 +4,5 @@ ; This file is automatically generated ; !byte 0 - !be24 33099 + !be24 82246 !le16 4186 diff --git a/src/index/attract.idx.a b/src/index/attract.idx.a index 6ba3afffd..0fc0e57ab 100644 --- a/src/index/attract.idx.a +++ b/src/index/attract.idx.a @@ -4,5 +4,5 @@ ; This file is automatically generated ; !byte 0 - !be24 6132 + !be24 55279 !le16 5157 diff --git a/src/index/cache00.idx.a b/src/index/cache00.idx.a new file mode 100644 index 000000000..bf1390500 --- /dev/null +++ b/src/index/cache00.idx.a @@ -0,0 +1,8 @@ +; +; Index record for res/CACHE00.IDX +; +; This file is automatically generated +; + !byte 0 + !be24 6152 + !le16 3580 diff --git a/src/index/cache01.idx.a b/src/index/cache01.idx.a new file mode 100644 index 000000000..a71a07dcd --- /dev/null +++ b/src/index/cache01.idx.a @@ -0,0 +1,8 @@ +; +; Index record for res/CACHE01.IDX +; +; This file is automatically generated +; + !byte 0 + !be24 16468 + !le16 3940 diff --git a/src/index/cache10.idx.a b/src/index/cache10.idx.a new file mode 100644 index 000000000..163199876 --- /dev/null +++ b/src/index/cache10.idx.a @@ -0,0 +1,8 @@ +; +; Index record for res/CACHE10.IDX +; +; This file is automatically generated +; + !byte 0 + !be24 29225 + !le16 4615 diff --git a/src/index/cache11.idx.a b/src/index/cache11.idx.a new file mode 100644 index 000000000..e6de56b07 --- /dev/null +++ b/src/index/cache11.idx.a @@ -0,0 +1,8 @@ +; +; Index record for res/CACHE11.IDX +; +; This file is automatically generated +; + !byte 0 + !be24 43585 + !le16 5562 diff --git a/src/index/count00.a b/src/index/count00.a new file mode 100644 index 000000000..5fd29d231 --- /dev/null +++ b/src/index/count00.a @@ -0,0 +1,6 @@ +; +; Game count +; +; This file is automatically generated +; +!word 264 diff --git a/src/index/count01.a b/src/index/count01.a new file mode 100644 index 000000000..7a18e0b91 --- /dev/null +++ b/src/index/count01.a @@ -0,0 +1,6 @@ +; +; Game count +; +; This file is automatically generated +; +!word 288 diff --git a/src/index/count10.a b/src/index/count10.a new file mode 100644 index 000000000..b2d6c5a4f --- /dev/null +++ b/src/index/count10.a @@ -0,0 +1,6 @@ +; +; Game count +; +; This file is automatically generated +; +!word 372 diff --git a/src/index/count11.a b/src/index/count11.a new file mode 100644 index 000000000..31efeb794 --- /dev/null +++ b/src/index/count11.a @@ -0,0 +1,6 @@ +; +; Game count +; +; This file is automatically generated +; +!word 411 diff --git a/src/index/dfx.idx.a b/src/index/dfx.idx.a index c985e82fd..52cbd9dcb 100644 --- a/src/index/dfx.idx.a +++ b/src/index/dfx.idx.a @@ -4,5 +4,5 @@ ; This file is automatically generated ; !byte 0 - !be24 13435 + !be24 62582 !le16 1242 diff --git a/src/index/dhgr.idx.a b/src/index/dhgr.idx.a index 59f045526..8074f87bd 100644 --- a/src/index/dhgr.idx.a +++ b/src/index/dhgr.idx.a @@ -4,5 +4,5 @@ ; This file is automatically generated ; !byte 0 - !be24 31757 + !be24 80904 !le16 1249 diff --git a/src/index/fx.idx.a b/src/index/fx.idx.a index 0e113c95f..9b1a2d086 100644 --- a/src/index/fx.idx.a +++ b/src/index/fx.idx.a @@ -4,5 +4,5 @@ ; This file is automatically generated ; !byte 0 - !be24 11289 + !be24 60436 !le16 2146 diff --git a/src/index/gamehelp.idx.a b/src/index/gamehelp.idx.a index 85d3c4dd7..46df7ea0f 100644 --- a/src/index/gamehelp.idx.a +++ b/src/index/gamehelp.idx.a @@ -4,5 +4,5 @@ ; This file is automatically generated ; !byte 0 - !be24 14677 + !be24 63824 !le16 6132 diff --git a/src/index/gr.idx.a b/src/index/gr.idx.a index 7515ac511..da70276c8 100644 --- a/src/index/gr.idx.a +++ b/src/index/gr.idx.a @@ -4,5 +4,5 @@ ; This file is automatically generated ; !byte 0 - !be24 33006 + !be24 82153 !le16 93 diff --git a/src/index/miniattract.idx.a b/src/index/miniattract.idx.a index 2b2f979c1..d713e11cf 100644 --- a/src/index/miniattract.idx.a +++ b/src/index/miniattract.idx.a @@ -4,5 +4,5 @@ ; This file is automatically generated ; !byte 0 - !be24 25625 + !be24 74772 !le16 6132 diff --git a/src/index/prelaunch.idx.a b/src/index/prelaunch.idx.a index f3993d401..6dc0d0fd4 100644 --- a/src/index/prelaunch.idx.a +++ b/src/index/prelaunch.idx.a @@ -4,5 +4,5 @@ ; This file is automatically generated ; !byte 0 - !be24 0 + !be24 49147 !le16 6132 diff --git a/src/index/search00.idx.a b/src/index/search00.idx.a new file mode 100644 index 000000000..ff7027ff5 --- /dev/null +++ b/src/index/search00.idx.a @@ -0,0 +1,8 @@ +; +; Index record for build/SEARCH00.IDX +; +; This file is automatically generated +; + !byte 0 + !be24 0 + !le16 6152 diff --git a/src/index/search01.idx.a b/src/index/search01.idx.a new file mode 100644 index 000000000..591055dfb --- /dev/null +++ b/src/index/search01.idx.a @@ -0,0 +1,8 @@ +; +; Index record for build/SEARCH01.IDX +; +; This file is automatically generated +; + !byte 0 + !be24 9732 + !le16 6736 diff --git a/src/index/search10.idx.a b/src/index/search10.idx.a new file mode 100644 index 000000000..dbe0d8eb8 --- /dev/null +++ b/src/index/search10.idx.a @@ -0,0 +1,8 @@ +; +; Index record for build/SEARCH10.IDX +; +; This file is automatically generated +; + !byte 0 + !be24 20408 + !le16 8817 diff --git a/src/index/search11.idx.a b/src/index/search11.idx.a new file mode 100644 index 000000000..311a4a6ae --- /dev/null +++ b/src/index/search11.idx.a @@ -0,0 +1,8 @@ +; +; Index record for build/SEARCH11.IDX +; +; This file is automatically generated +; + !byte 0 + !be24 33840 + !le16 9745 diff --git a/src/index/slideshow.idx.a b/src/index/slideshow.idx.a index 49de3c7e4..d38602a1d 100644 --- a/src/index/slideshow.idx.a +++ b/src/index/slideshow.idx.a @@ -4,5 +4,5 @@ ; This file is automatically generated ; !byte 0 - !be24 20809 + !be24 69956 !le16 4816 diff --git a/src/prodos.path.a b/src/prodos.path.a index 36e07093e..321982112 100644 --- a/src/prodos.path.a +++ b/src/prodos.path.a @@ -53,6 +53,46 @@ AddToPath @done rts +kSearchIndexRecord + !byte 0 + !be24 0 ; SMC in 4cade.init + !le16 0 ; SMC in 4cade.init + +kSearchCacheRecord + !byte 0 + !be24 0 ; SMC in 4cade.init + !le16 0 ; SMC in 4cade.init + +kPrelaunchIndexRecord + !source "src/index/prelaunch.idx.a" + +kAttractModeIndexRecord + !source "src/index/attract.idx.a" + +kMiniAttractIndexRecord + !source "src/index/miniattract.idx.a" + +kAttractModeSlideshowIndexRecord + !source "src/index/slideshow.idx.a" + +kFXIndexRecord + !source "src/index/fx.idx.a" + +kDFXIndexRecord + !source "src/index/dfx.idx.a" + +kGameHelpIndexRecord + !source "src/index/gamehelp.idx.a" + +kSHRArtworkIndexRecord + !source "src/index/artwork.idx.a" + +kDHGRActionIndexRecord + !source "src/index/dhgr.idx.a" + +kGRActionIndexRecord + !source "src/index/gr.idx.a" + kTotalDataFile !byte 10 !raw "TOTAL.DATA" @@ -80,12 +120,6 @@ gHGRActionIndexNumber !raw "_" !raw ".IDX" -kDHGRActionIndexRecord - !source "src/index/dhgr.idx.a" - -kGRActionIndexRecord - !source "src/index/gr.idx.a" - kDemoDirectory !byte 5 !raw "DEMO/" @@ -99,34 +133,10 @@ kFXDirectory !byte 3 !raw "FX/" -kPrelaunchIndexRecord - !source "src/index/prelaunch.idx.a" - kGlobalPrefsFilename !byte 10 !raw "PREFS.CONF" -kAttractModeIndexRecord - !source "src/index/attract.idx.a" - -kMiniAttractIndexRecord - !source "src/index/miniattract.idx.a" - -kAttractModeSlideshowIndexRecord - !source "src/index/slideshow.idx.a" - -kFXIndexRecord - !source "src/index/fx.idx.a" - -kDFXIndexRecord - !source "src/index/dfx.idx.a" - -kGameHelpIndexRecord - !source "src/index/gamehelp.idx.a" - -kSHRArtworkIndexRecord - !source "src/index/artwork.idx.a" - kCreditsFile !byte 7 !raw "CREDITS" @@ -166,21 +176,3 @@ kDecrunchFile kJoystickFile !byte 8 !raw "JOYSTICK" - -kSearchIndexFile - !byte 12 - !raw "SEARCH" -gSearchHasJoystick - !raw "_" -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 5f2fedad6..94df80595 100644 --- a/src/textrank.a +++ b/src/textrank.a @@ -34,14 +34,14 @@ InputBuffer ; out: gSearchStore populated ;------------------------------------------------------------------------------ ReloadSearchIndex - jsr LoadFile ; load appropriate search index into $8200 - !word kRootDirectory - !word kSearchIndexFile + jsr LoadIndexedFile ; load appropriate search index into $8200 + !word kTotalIndexFile !word gSearchIndex - jsr LoadFile ; load appropriate search cache into $B000 - !word kRootDirectory - !word kSearchCacheFile + !word kSearchIndexRecord + jsr LoadIndexedFile ; load appropriate search cache into $B000 + !word kTotalIndexFile !word gSearchCache + !word kSearchCacheRecord rts FindTitleInCache