shave some bytes

This commit is contained in:
4am 2021-10-27 20:08:03 -04:00
parent b0d96bad23
commit 6ffc9c7aac
9 changed files with 40 additions and 50 deletions

View File

@ -137,10 +137,10 @@ index: md asmfx asmprelaunch
# create gSearchStore indexes
#
[ -f build/DISPLAY.CONF ] || (bin/builddisplaynames.py < build/GAMES.CONF > build/DISPLAY.CONF)
[ -f build/SEARCH00.IDX ] || (grep "^00" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh > build/SEARCH00.IDX)
[ -f build/SEARCH01.IDX ] || (grep "^0" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh > build/SEARCH01.IDX)
[ -f build/SEARCH10.IDX ] || (grep "^.0" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh > build/SEARCH10.IDX)
[ -f build/SEARCH11.IDX ] || (cat build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh > build/SEARCH11.IDX)
[ -f build/SEARCH00.IDX ] || (grep "^00" < build/DISPLAY.CONF | bin/buildsearch.sh > build/SEARCH00.IDX)
[ -f build/SEARCH01.IDX ] || (grep "^0" < build/DISPLAY.CONF | bin/buildsearch.sh > build/SEARCH01.IDX)
[ -f build/SEARCH10.IDX ] || (grep "^.0" < build/DISPLAY.CONF | bin/buildsearch.sh > build/SEARCH10.IDX)
[ -f build/SEARCH11.IDX ] || (bin/buildsearch.sh < build/DISPLAY.CONF > build/SEARCH11.IDX)
#
# create a sorted list of game filenames, without metadata or display names
#

View File

@ -12,11 +12,12 @@ source=$(mktemp)
dhgr=$(echo "$key" | cut -c3) # 'has DHGR title screen' flag (0 or 1)
cheat=$(echo "$key" | cut -c4) # 'cheat category' (0..5)
key=$(echo "$key" | cut -d"," -f2)
echo "!byte ${#key}+${#value}+4" # OKVS record length
echo "!byte ${#key}+${#value}+5" # OKVS record length
echo "!byte ${#key}" # OKVS key length
echo "!text \"$key\"" # OKVS key
echo "!byte ${#value}+1" # OKVS value length
echo "!byte ${#value}" # OKVS value length
echo "!text \"$value\"" # OKVS value
echo "!byte 1"
echo "!byte $((dhgr*128))+$cheat"
done < "$records") > "$source"

View File

@ -386,11 +386,12 @@ CopyDevs
jsr stepptr
+LD16 PTR ; (PTR) points to free space after the OKVS data structure we just created
+ST16 gGamesListStore ; save pointer to free space for next store
jsr LoadFile ; load games list file into $8200
!word kRootDirectory
!word @kGameListConfFile
- !word $8200
lda #$EA
sta AddValueDuringAppend
jsr ParseGamesList ; parse games list into OKVS data structure in LC RAM bank
!word gGamesListStore
!word -

View File

@ -6,9 +6,9 @@
; YE OLDE GRAND UNIFIED MEMORY MAP
;
; LC RAM BANK 1
; D000..E2F8 - persistent data structures (gGlobalPrefsStore, gGamesListStore)
; D000..DFDE - persistent data structures (gGlobalPrefsStore, gGamesListStore)
; ...unused...
; EA2A..FFEE - main program code
; EA23..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)

View File

@ -210,6 +210,7 @@ okvs_append
tay
lda (SRC),y ; no max, use actual length instead
tax
AddValueDuringAppend
+ inx
tay
- lda (SRC),y

View File

@ -61,12 +61,8 @@ ParseGamesList
bvc @skipLine ; game requires 128K but we only have 64K, so ignore entire line
@parseDHGRTitle
jsr IncAndGetChar ; get third character ('1' if game has DHGR title)
and #$01
pha
@parseCheatsAvailable
jsr IncAndGetChar ; get fourth character (cheat category, int)
and #CHEAT_CATEGORY
pha
@swallowComma
jsr IncAndGetChar
@gatherKey
@ -86,19 +82,7 @@ ParseGamesList
jsr IncAndGetChar
cmp #$0A ; CR ends the value
bne @gatherValue
; beq @endValue
; sta gVal,x
; inx
; bpl @gatherValue
@endValue
pla ; pop cheat category
sta gVal,x ; store after game display name
pla ; pop has-DHGR-title flag
lsr
ror
ora gVal,x
sta gVal,x ; store in bit 7 of same byte as cheat category
inx
stx gValLen
tya
pha ; okvs functions clobber everything but we need Y

View File

@ -32,17 +32,17 @@ Help
jsr LoadIndexedFile
!word kGameHelpFile
!word $8000
!word $800
@indexRecordPtr
!word $FDFD ; SMC
clc
bcc .clearAndDisplayHelp ; always branches
@global jsr LoadFile ; load help text into $8000
@global jsr LoadFile ; load help text into $800
!word kRootDirectory
!word kHelpTextFile
!word $8000
!word $800
jsr LoadHelpOffscreen ; load fancy backdrop
ldx #7
@ -57,10 +57,10 @@ Help
; all other flags and registers clobbered
;------------------------------------------------------------------------------
Credits
jsr LoadFile ; load credits text into $8000
jsr LoadFile ; load credits text into $800
!word kRootDirectory
!word kCreditsFile
!word $8000
!word $800
.clearAndDisplayHelp
jsr ForceHGRMode
jsr ClearOffscreen
@ -68,7 +68,7 @@ Credits
.displayHelp
lda OffscreenPage
ror ; draw on offscreen page
+LDADDR $8000
+LDADDR $800
+ST16 PTR
;DrawPageInternal inlined here
;

View File

@ -83,18 +83,20 @@ LoadOffscreenFromAY
rts
LoadGameTitleOffscreen
; in: gGameToLaunch = index into gGamesListStore (word)
jsr GetGameToLaunch
; in: gGameToLaunch = index into gSearchStore (word)
+LD16 gGameToLaunch
+ST16 WINDEX
+LDADDR gSearchStore
jsr okvs_nth ; A/Y -> key (game filename) in gSearchStore
+ST16 @fname
bit MachineStatus ; if < 128K, don't bother checking for DHGR title
bvc @hgr
jsr okvs_get_current
; (PTR) -> game display name + bitfield of game info
jsr okvs_get_current_PTR_is_already_set
; (PTR) -> length-prefixed game info bitfield
; Y = 0
lda (PTR),y ; A = game display name length + 1
sta SAVE
tay
lda (PTR),y ; A = game info bitfield
iny ; Y = 1
lda (PTR), y ; A = game info bitfield
;;and #HAS_DHGR_TITLE
bmi @dhgr
@hgr

View File

@ -122,21 +122,22 @@ DrawUI
sta gPathname ; hack, used by first RedrawForDHGR which follows
; Draw40Chars which doesn't set gPathname
jsr GetGameToLaunch ; get current game, if any
jsr AnyGameSelected ; get index number of current game, if any
bcs @doneWithLine2 ; if no game, nothing more to do on UI line 2
+ST16 @fname
jsr okvs_get_current
iny ; Y = 1
+ST16 WINDEX
+LDADDR gSearchStore
jsr okvs_nth ; A/Y -> key of current game (in gSearchStore)
jsr okvs_get_current ; (PTR) -> display name of current game
; Y = 0
lda (PTR), y
tay
iny
sty SAVE
iny
lda (PTR), y ; A = game info bitfield
sta gGameToLaunchInfo
jsr okvs_get
!word gSearchStore
@fname !word $FDFD ; SMC
+ST16 PTR
ldy #0
lda (PTR), y
sta SAVE
inc SAVE
- iny
@printCursor
lda #$FD ; SMC
@ -197,7 +198,7 @@ DrawUI
ldy #0
@dotloop
iny
lda (PTR),y ; (PTR) still points to game display name + game info bitfield
lda (PTR),y ; (PTR) still points to game display name
ora #$20 ; force lower-case always
cmp InputBuffer,x
bne +