diff --git a/Makefile b/Makefile index 9d3e59cc7..2d44e5df1 100644 --- a/Makefile +++ b/Makefile @@ -159,7 +159,9 @@ index: md asmfx asmprelaunch # precompute indexed files for slideshows # [ -f build/SLIDESHOW.IDX ] || ((for f in res/SS/*; do \ - bin/buildokvs.sh < "$$f" > "build/SS/$$(basename $$f)"; \ + [ $$(echo "$$(basename $$f)" | cut -c-3) = "ACT" ] && \ + bin/buildaction.sh build/DISPLAY.CONF < "$$f" > "build/SS/$$(basename $$f)" || \ + bin/buildokvs.sh < "$$f" > "build/SS/$$(basename $$f)"; \ echo "$$(basename $$f)"; \ done) | bin/buildindexedfile.sh -p -a build/TOTAL.DATA build/SS > build/SLIDESHOW.IDX) [ -f build/MINIATTRACT.IDX ] || ((for f in res/ATTRACT/*; do \ diff --git a/bin/buildaction.sh b/bin/buildaction.sh new file mode 100755 index 000000000..5938cd2c6 --- /dev/null +++ b/bin/buildaction.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# make temp file with just the key/value pairs (strip blank lines, comments, eof marker) +records=$(mktemp) +awk '!/^$|^#|^\[/' > "$records" + +# make temp assembly source file that represents the binary OKVS data structure +source=$(mktemp) +(echo "*=0" # dummy program counter for assembler + echo "!le16 $(wc -l <"$records"), 0" # OKVS header + while IFS="=" read -r key value; do + [ -n "$value" ] && filename="$value" || filename="$key" + displayname=$(awk -F= '/,'"$filename"'=/ { print $2 }' "$1") + echo "!byte ${#key}+${#value}+${#displayname}+4" # OKVS record length + echo "!byte ${#key}" # OKVS key length + echo "!text \"$key\"" # OKVS key + echo "!byte ${#value}" # OKVS value length + echo "!text \"$value\"" # OKVS value + echo "!byte ${#displayname}" + echo "!text \"$displayname\"" + done < "$records") > "$source" + +# assemble temp source file into binary OKVS data structure, then output that +out=$(mktemp) +acme -o "$out" "$source" +cat "$out" + +# clean up +rm "$out" +rm "$source" +rm "$records" diff --git a/src/constants.a b/src/constants.a index bdf56613d..3bbcbedf3 100644 --- a/src/constants.a +++ b/src/constants.a @@ -6,8 +6,9 @@ ; YE OLDE GRAND UNIFIED MEMORY MAP ; ; LC RAM BANK 1 -; D000..E7FE - persistent data structures (gGlobalPrefsStore, gGamesListStore) -; E9EE..FFEE - main program code +; D000..E2F8 - persistent data structures (gGlobalPrefsStore, gGamesListStore) +; ...unused... +; EA2A..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) diff --git a/src/glue.launch.a b/src/glue.launch.a index aa981e57a..5ebf09ce5 100644 --- a/src/glue.launch.a +++ b/src/glue.launch.a @@ -94,91 +94,32 @@ GlueLaunchRTS ; check if an arbitrary game exists, for some definition of 'exists', while ; in the middle of a slideshow ; -; /!\ This function assumes that gSlideshowStore exists and is populated, -; which is generally only true during the callback function of a slideshow -; -; in: A/Y points to game filename +; in: A/Y points to a key in gSlideshowStore ; out: C clear if game exists, and ; $WINDEX = game index, and -; A/Y points to game display name + game info bitfield +; A/Y points to game display name ; C set if game can't be found by any means ;------------------------------------------------------------------------------ FindGameInActionSlideshow - +ST16 @sskey + +ST16 @slideshowKey jsr FindGame - bcc GetGameDisplayName + bcc @GetGameDisplayName ; if the game was not found, try getting the value of the current record from ; gSlideshowStore (some games have multiple action screenshots, in which case ; the key is only the screenshot filename, and the value is the actual game ; filename) jsr okvs_get !word gSlideshowStore -@sskey !word $FDFD ; SMC +@slideshowKey + !word $FDFD ; SMC jsr FindGame bcs GlueLaunchRTS - ; /!\ execution falls through here to GetGameDisplayName -;------------------------------------------------------------------------------ -; GetGameDisplayName -; lookup or construct the display name for a specific game -; -; in: A/Y contains address of a key in gGamesListStore -; out: A/Y contains address of game display name + game info bitfield -; (this might be just the corresponding value in gGamesListStore, -; or it might be a temporary buffer in main memory that we constructed -; out of thin air) -; gValLen possibly clobbered (up to gValLen+MaxInputLength) -; X preserved -; C clear -;------------------------------------------------------------------------------ -GetGameDisplayName - +ST16 SAVE - jsr okvs_get_current ; get value for this key - ; (PTR) -> truncated game display name + info bitfield - ; Y = 0 - lda (PTR), y ; A = length of truncated game display name + info bitfield - lsr ;;cmp #1 ; 1 means there's no title, just info bitfield (1 byte) - beq + +@GetGameDisplayName + +LD16 @slideshowKey + jsr okvs_get_current + jsr okvs_get_current_PTR_is_already_set +LD16 PTR - clc - rts -+ ; game display name is truncated, we must expand it - iny ; Y = 1 - lda (PTR), y ; A = game info bitfield - pha ; save on stack - dey - lda (SAVE), y ; A = length of key - tay - iny - sty @len - sty gValLen - lda #$24 ; BIT opcode - sta @or ; first character remains capitalized - ldy #1 -- lda (SAVE), y - cmp #$49 ; 'I' - bne + - cmp gValLen-1,y - beq ++ ; preserve 'II' casing -+ cmp #$2E - bne @or - lda #$20 ; convert '.' to ' ' -@or ora #$20 ; SMC (opcode) -++ sta gValLen, y - cmp #$20 - bne + - lda #$24 ; first character after ' ' remains capitalized - +HIDE_NEXT_2_BYTES -+ lda #$09 ; OR opcode - sta @or -@next iny -@len=*+1 - cpy #$FD ; SMC - bne - - pla - sta gValLen, y - +LDADDR gValLen - clc rts ;------------------------------------------------------------------------------ diff --git a/src/okvs.a b/src/okvs.a index 4ad11413e..7be09e064 100644 --- a/src/okvs.a +++ b/src/okvs.a @@ -395,6 +395,7 @@ okvs_iter_values okvs_get_current ; out: Y = 0 +ST16 PTR +okvs_get_current_PTR_is_already_set jsr stepptr bne incptr diff --git a/src/parse.games.a b/src/parse.games.a index 16becb1ff..970565bff 100644 --- a/src/parse.games.a +++ b/src/parse.games.a @@ -85,10 +85,11 @@ ParseGamesList @gatherValue jsr IncAndGetChar cmp #$0A ; CR ends the value - beq @endValue - sta gVal,x - inx - bpl @gatherValue + bne @gatherValue +; beq @endValue +; sta gVal,x +; inx +; bpl @gatherValue @endValue pla ; pop cheat category sta gVal,x ; store after game display name diff --git a/src/ui.attract.dhgr.a b/src/ui.attract.dhgr.a index eaf29425d..470a05f1d 100644 --- a/src/ui.attract.dhgr.a +++ b/src/ui.attract.dhgr.a @@ -215,7 +215,7 @@ DHGRActionCallback ; can't be played due to memory or joystick requirements, so we hide ; it from slideshows bcs DHGRRTS - +ST16 SAVE ; (SAVE) -> game display name + game info bitfield + +ST16 SAVE ; (SAVE) -> game display name +LD16 WINDEX ; save game index in case user hits RETURN +ST16 gGameToLaunch ; while it's visible (we'll launch it) @@ -245,18 +245,17 @@ DrawGameTitleInActionSlideshow sta VTAB lda #0 ; solid horizontal bar character jsr @resetline - lda (SAVE),y ; (SAVE) -> game display name, Y = 0, so A = display length + 1 + lda (SAVE),y ; (SAVE) -> game display name, Y = 0, so A = display length clc - adc #$02 + adc #$03 sta gPathname lda #7 ; top-right rounded corner character jsr @drawline lda #" " jsr @resetline - lda (SAVE),y ; A = display length + 1 + lda (SAVE),y ; A = display length tay - dey - lda (SAVE),y sta gPathname+1,y dey diff --git a/src/ui.attract.hgr.a b/src/ui.attract.hgr.a index c727849d3..c8803adb1 100644 --- a/src/ui.attract.hgr.a +++ b/src/ui.attract.hgr.a @@ -147,7 +147,7 @@ HGRActionCallback bcs HGRRTS ; found the game - +ST16 SAVE ; (SAVE) -> game display name + game info bitfield + +ST16 SAVE ; (SAVE) -> game display name +LD16 WINDEX ; save game index in case user hits RETURN +ST16 gGameToLaunch ; while it's visible (we'll launch it) diff --git a/src/ui.overlay.a b/src/ui.overlay.a index 1604df7ec..536bd9d33 100644 --- a/src/ui.overlay.a +++ b/src/ui.overlay.a @@ -124,16 +124,19 @@ DrawUI jsr GetGameToLaunch ; get current game, if any bcs @doneWithLine2 ; if no game, nothing more to do on UI line 2 - jsr GetGameDisplayName - ; A/Y -> game display name + bitfield of game info + +ST16 @fname + jsr okvs_get_current + iny ; Y = 1 + 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 ; A = game display name length + 1 + lda (PTR), y sta SAVE - tay - lda (PTR),y ; A = game info bitfield - sta gGameToLaunchInfo - ldy #0 + inc SAVE - iny @printCursor lda #$FD ; SMC