precompute gSearchStore

This commit is contained in:
4am 2021-10-23 00:53:23 -04:00
parent 37c37b588b
commit 76242f8086
13 changed files with 408 additions and 357 deletions

View File

@ -36,7 +36,7 @@ dsk: asm
#
# precompute binary data structure for mega-attract mode configuration file
#
bin/buildokvs.sh res/ATTRACT.CONF build/ATTRACT.IDX >>build/log
bin/buildokvs.sh build/ATTRACT.IDX < res/ATTRACT.CONF >>build/log
#
# precompute binary data structure and substitute special characters
# in game help and other all-text pages
@ -55,6 +55,14 @@ dsk: asm
#
awk -F, '/,/ { print $$2 }' < build/GAMES.CONF | awk -F= '{ print $$1 }' | sort > build/GAMES.SORTED
#
# create search indexes
#
bin/builddisplaynames.py < res/GAMES.CONF > build/DISPLAY.CONF
grep "^00" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh build/SEARCH00.IDX
grep "^0" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh build/SEARCH01.IDX
grep "^.0" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh build/SEARCH10.IDX
cat build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh build/SEARCH11.IDX
#
# precompute indexed files for prelaunch
# note: prelaunch must be first in TOTAL.DATA due to a hack in LoadStandardPrelaunch
# note 2: these can not be padded because they are loaded at $0106 and padding would clobber the stack
@ -68,12 +76,12 @@ dsk: asm
# precompute indexed files for slideshows
#
(for f in res/SS/*; do \
bin/buildokvs.sh "$$f" "build/SS/$$(basename $$f)"; \
bin/buildokvs.sh "build/SS/$$(basename $$f)" < "$$f"; \
echo "$$(basename $$f)"; \
done) > build/SSDIR
bin/buildindexedfile.sh -p -a build/SSDIR build/SLIDESHOW.IDX build/TOTAL.DATA build/SS >>build/log
(for f in res/ATTRACT/*; do \
bin/buildokvs.sh "$$f" "build/ATTRACT/$$(basename $$f)"; \
bin/buildokvs.sh "build/ATTRACT/$$(basename $$f)" < "$$f"; \
echo "$$(basename $$f)"; \
done) > build/ATTRACTDIR
bin/buildindexedfile.sh -p -a build/ATTRACTDIR build/MINIATTRACT.IDX build/TOTAL.DATA build/ATTRACT >>build/log
@ -131,6 +139,10 @@ dsk: asm
build/CREDITS \
build/HELPTEXT \
build/ATTRACT.IDX \
build/SEARCH00.IDX \
build/SEARCH01.IDX \
build/SEARCH10.IDX \
build/SEARCH11.IDX \
build/FX.IDX \
build/DFX.IDX \
build/GAMEHELP.IDX \

14
bin/builddisplaynames.py Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env python3
# usage:
# builddisplaynames.py < res/GAMES.CONF > build/GAMES.CONF.WITH.NAMES
import sys
for line in sys.stdin:
if "," not in line: continue
if line.startswith("#"): continue
if "=" not in line:
prefix, key = line.split(",")
line = prefix + "," + key.strip() + "=" + key.replace(".", " ").title().replace(" Ii", " II")
print(line, end="")

View File

@ -4,7 +4,7 @@
# make temp file with just the key/value pairs (strip blank lines, comments, eof marker)
records=$(mktemp)
grep -v "^$" < "$1" | grep -v "^#" | grep -v "^\[" > "$records"
grep -v "^$" | grep -v "^#" | grep -v "^\[" > "$records"
# make temp assembly source file that represents the binary OKVS data structure
source=$(mktemp)
@ -19,7 +19,7 @@ source=$(mktemp)
done < "$records") > "$source"
# assemble temp source file to create binary OKVS data structure
acme -o "$2" "$source"
acme -o "$1" "$source"
# clean up
rm "$source"

7
res/ATTRACT/AO Normal file
View File

@ -0,0 +1,7 @@
#
# Attract mode for AO
# This file is automatically generated
#
[eof]

7
res/ATTRACT/CHIP.OUT Normal file
View File

@ -0,0 +1,7 @@
#
# Attract mode for CHIP.OUT
# This file is automatically generated
#
[eof]

7
res/ATTRACT/VV Normal file
View File

@ -0,0 +1,7 @@
#
# Attract mode for VV
# This file is automatically generated
#
[eof]

View File

@ -19,6 +19,10 @@ HGR3.IDX=Type(06),AuxType(4000),Access(C3)
HGR4.IDX=Type(06),AuxType(4000),Access(C3)
HGR5.IDX=Type(06),AuxType(4000),Access(C3)
HGR6.IDX=Type(06),AuxType(4000),Access(C3)
SEARCH00.IDX=Type(06),AuxType(8200),Access(C3)
SEARCH01.IDX=Type(06),AuxType(8200),Access(C3)
SEARCH10.IDX=Type(06),AuxType(8200),Access(C3)
SEARCH11.IDX=Type(06),AuxType(8200),Access(C3)
COVER=Type(06),AuxType(2000),Access(C3)
TITLE=Type(06),AuxType(2000),Access(C3)
HELP=Type(06),AuxType(2000),Access(C3)

View File

@ -413,6 +413,19 @@ CopyDevs
+READ_RAM1_WRITE_RAM1
}
ldx #$30
lda MachineStatus
and #HAS_JOYSTICK
beq +
inx
+ stx gSearchHasJoystick
ldx #$30
lda MachineStatus
and #HAS_128K
beq +
inx
+ stx gSearchHas128K
+LDADDR gGamesListStore
jsr okvs_len
+LD16 WCOUNT

View File

@ -7,7 +7,7 @@
;
; LC RAM BANK 1
; D000..E7D2 - persistent data structures (gGlobalPrefsStore, gGamesListStore)
; E92D..FFEE - main program code
; E9E8..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)
@ -149,7 +149,7 @@ CHEATS_ENABLED = %00001000
iCurBlockLo = $D401 ; constant
iCurBlockHi = $D403 ; constant
launchpatch = $D661 ; glue.launch.a
iAddToPath = $FEA5 ; Roger Rabbit, avoid, use Infiltrator 2 style instead
iAddToPath = $FE98 ; Roger Rabbit, avoid, use Infiltrator 2 style instead
itraverse = $D958 ; Roger Rabbit, avoid, use Infiltrator 2 style instead
ldrlo = $55 ; constant
ldrhi = $56 ; constant

View File

@ -118,109 +118,6 @@ okvs_len_imm
ora WCOUNT
rts
;------------------------------------------------------------------------------
; okvs_append
;
; in: stack contains 7 bytes of parameters:
; +1 [word] handle to storage space
; +3 [word] address of key
; +5 [word] address of value
; +7 [byte] maximum length of value (or 0 to fit)
; out: (new record count is not returned because no one cares)
; all registers clobbered
; $00/$01 clobbered
; $02/$03 clobbered
; $04/$05 has the address of the next available byte after the new record
; $08/$09 clobbered
;------------------------------------------------------------------------------
okvs_append
+PARAMS_ON_STACK 7
jsr GetStoreAddress
; PTR -> store
; Y = 0
lda (PTR),y ; A = number of keys in store
sta WINDEX
iny
lda (PTR), y
sta WINDEX+1
inc WINDEX
bne +
inc WINDEX+1
+
dey
lda WINDEX
sta (PTR),y ; increment number of keys
lda WINDEX+1
iny
sta (PTR),y
iny
lda (PTR),y ; get address of next free space
tax
iny
lda (PTR),y
sta PTR+1
sta SAVE+1
stx PTR
stx SAVE
; PTR -> new record
; SAVE -> new record
jsr incptr
; PTR -> space for new key
+LDPARAMPTR 3, SRC ; SRC -> new key to copy
ldy #0
lda (SRC),y
tay
tax
- lda (SRC),y ; copy new key
sta (PTR),y
dey
cpy #$FF
bne -
;;sec
txa
adc PTR ; update PTR to byte after copied key
sta PTR
bcc +
inc PTR+1
+ ; PTR -> space for new value
+LDPARAMPTR 5, SRC ; SRC -> new value to copy
iny ;;ldy #7
lda (PARAM),y ; get max length of value
tax
bne +
tay
lda (SRC),y ; no max, use actual length instead
tax
+ inx
tay
- lda (SRC),y
sta (PTR),y
dey
cpy #$FF
bne -
txa
clc
adc PTR
tax
lda PTR+1
adc #0
pha
+ jsr GetStoreAddress
; PTR -> store
pla
ldy #3
sta (PTR),y ; update next-free-space pointer in head
dey
txa
sta (PTR),y
sec
sbc SAVE
ldy #0
sta (SAVE),y ; set record length
rts
;------------------------------------------------------------------------------
; okvs_find / okvs_get
;

View File

@ -135,3 +135,106 @@ IncAndGetChar
beq IncAndGetChar
.parseKeyValueDone
rts
;------------------------------------------------------------------------------
; okvs_append
;
; in: stack contains 7 bytes of parameters:
; +1 [word] handle to storage space
; +3 [word] address of key
; +5 [word] address of value
; +7 [byte] maximum length of value (or 0 to fit)
; out: (new record count is not returned because no one cares)
; all registers clobbered
; $00/$01 clobbered
; $02/$03 clobbered
; $04/$05 has the address of the next available byte after the new record
; $08/$09 clobbered
;------------------------------------------------------------------------------
okvs_append
+PARAMS_ON_STACK 7
jsr GetStoreAddress
; PTR -> store
; Y = 0
lda (PTR),y ; A = number of keys in store
sta WINDEX
iny
lda (PTR), y
sta WINDEX+1
inc WINDEX
bne +
inc WINDEX+1
+
dey
lda WINDEX
sta (PTR),y ; increment number of keys
lda WINDEX+1
iny
sta (PTR),y
iny
lda (PTR),y ; get address of next free space
tax
iny
lda (PTR),y
sta PTR+1
sta SAVE+1
stx PTR
stx SAVE
; PTR -> new record
; SAVE -> new record
jsr incptr
; PTR -> space for new key
+LDPARAMPTR 3, SRC ; SRC -> new key to copy
ldy #0
lda (SRC),y
tay
tax
- lda (SRC),y ; copy new key
sta (PTR),y
dey
cpy #$FF
bne -
;;sec
txa
adc PTR ; update PTR to byte after copied key
sta PTR
bcc +
inc PTR+1
+ ; PTR -> space for new value
+LDPARAMPTR 5, SRC ; SRC -> new value to copy
iny ;;ldy #7
lda (PARAM),y ; get max length of value
tax
bne +
tay
lda (SRC),y ; no max, use actual length instead
tax
+ inx
tay
- lda (SRC),y
sta (PTR),y
dey
cpy #$FF
bne -
txa
clc
adc PTR
tax
lda PTR+1
adc #0
pha
+ jsr GetStoreAddress
; PTR -> store
pla
ldy #3
sta (PTR),y ; update next-free-space pointer in head
dey
txa
sta (PTR),y
sec
sbc SAVE
ldy #0
sta (SAVE),y ; set record length
rts

View File

@ -190,3 +190,12 @@ kDecrunchFile
kJoystickFile
!byte 8
!raw "JOYSTICK"
kSearchIndexFile
!byte 12
!raw "SEARCH"
gSearchHasJoystick
!raw "_"
gSearchHas128K
!raw "_"
!raw ".IDX"

View File

@ -36,32 +36,10 @@ InputBuffer
; out: gSearchStore populated
;------------------------------------------------------------------------------
BuildSearchStore
jsr SwitchToBank2
jsr EnableAcceleratorAndSwitchToBank1
+LDADDR gSearchStore
jsr okvs_init
jsr okvs_iter
!word gGamesListStore
!word @callback
jsr SwitchToBank2
jmp DisableAcceleratorAndSwitchToBank1
@callback
; callback called by okvs_iter on gGamesListStore
; in: A/Y contains address of filename
; $WINDEX contains 0-based index of the current record in gGamesListStore (word)
; out: all registers and flags clobbered
+ST16 @key
jsr GetGameDisplayName
+ST16 @value
@append
jsr okvs_append
!word gSearchStore
@key !word $FDFD ; SMC
@value !word $FDFD ; SMC
!byte 0
jsr LoadFile ; load appropriate search index into $8200
!word kRootDirectory
!word kSearchIndexFile
!word $8200
rts
;------------------------------------------------------------------------------