don't store game display names that we can calculate from filename

This commit is contained in:
4am 2020-03-18 12:08:39 -04:00
parent 44e721d99d
commit d484e98073
16 changed files with 173 additions and 94 deletions

View File

@ -25,7 +25,7 @@ CADIUS=cadius
# https://bitbucket.org/magli143/exomizer/wiki/Home
EXOMIZER=exomizer mem -q -P23 -lnone
dsk: md asm compress
dsk: md asm
cp res/blank.2mg build/"$(DISK)" >>build/log
cp res/_FileInformation.txt build/ >>build/log
$(CADIUS) ADDFILE build/"$(DISK)" "/$(VOLUME)/" "build/LAUNCHER.SYSTEM" >>build/log

File diff suppressed because one or more lines are too long

View File

@ -121,6 +121,8 @@ gAttractModeStore
gFXStore
gDFXStore
!word $6000
gSearchStore
!word $8000
gSlideshowStore
!word $0800
gGlobalPrefsStore

View File

@ -6,10 +6,10 @@
; YE OLDE GRAND UNIFIED MEMORY MAP
;
; LC RAM BANK 1
; D000..E8DF - persistent data structures (per-game cheat categories,
; D000..E694 - persistent data structures (per-game cheat categories,
; gGlobalPrefsStore, gGamesListStore)
; ...unused...
; EB2C..FFF9 - main program code
; EAB9..FFF9 - main program code
; FFFA..FFFF - NMI, reset, IRQ vectors
;
; LC RAM BANK 2
@ -123,7 +123,7 @@ EnableAccelerator = DisableAccelerator+3
MOCKINGBOARD_SLOT = %00001111
HAS_SPEECH = %10000000
; AND masks for game info bitfield (after game title in gGamesList)
; AND masks for game info bitfield (after game display name in gGamesListStore)
HAS_DHGR_TITLE = %10000000 ; this one is hard-coded via BMI instead of AND/BNE
CHEAT_CATEGORY = %00001111
@ -136,5 +136,5 @@ SUPPORTS_SHR = %00110000
CHEATS_ENABLED = %00001000
; VBL functions
WaitForVBL = $FCB2
UnwaitForVBL = $FCC7
WaitForVBL = $FCB0
UnwaitForVBL = $FCC5

View File

@ -5,8 +5,9 @@
;
; Public functions
; - GetGameToLaunch
; - GetGameInfo
; - GetGameInfoInActionSlideshow
; - FindGame
; - FindGameInActionSlideshow
; - GetGameDisplayName
; - PlayGame
; - Launch
;
@ -22,32 +23,24 @@ gGameToLaunch=*+1
+LDADDR gGamesListStore
jmp okvs_nth
GetGameInfo
FindGame
; in: A/Y points to game filename
; out: C clear if game exists in gGamesListStore, and
; A/Y points to game display name (but see hack notes below)
; X = game index, or #$FF if the game doesn't really exist but
; we want to return a successful result anyway (really, read the
; hack notes, they're important)
; C set if game does not exist (this can happen because slideshows
; list games that require a joystick, but the games list parser
; filters out joystick-only games if the machine doesn't have a
; joystick)
ldx #$60
+HIDE_NEXT_2_BYTES
GetGameInfoInActionSlideshow
ldx #$EA
stx @maybeExit
; we want to return a successful result anyway
; C set if game does not exist, and
; X clobbered (this can happen because slideshows list games
; that require a joystick, but the games list parser filters out
; joystick-only games if the machine doesn't have a joystick)
; A,Y always clobbered
+STAY @key
+STAY @slideshowKey
jsr okvs_get
jsr okvs_find
!word gGamesListStore
@key !word $FDFD ; SMC
bcc @exit
; Hack to allow self-running demos that don't correspond to a game
; filename. If the name ends in a '.', accept it unconditionally.
; The filename is its own display name. Launching this fake game
; will of course fail, so don't do that.
ldx #$FF
+LDAY @key
+STAY PARAM
ldy #0
@ -57,30 +50,78 @@ GetGameInfoInActionSlideshow
cmp #"."
beq @forceGoodResult
sec
@maybeExit
!byte $00 ; SMC
; if the key is still not found, AND the caller said to try this, then try
; getting the value of the current record from gSlideshowStore
; (some games have multiple action screenshots, in which case the filename of
; the action screenshot is not the game name, but the value is)
jsr okvs_get
!word gSlideshowStore
@slideshowKey
!word $FDFD ; SMC
+STAY @key3
jsr okvs_get
!word gGamesListStore
@key3 !word $FDFD ; SMC
; note that the game might still not be found (C will be set by okvs_get),
; which can happen if the game can't be played due to memory or joystick
; requirements
rts
@forceGoodResult
+LDAY @key
ldx #$FF
clc
@exit rts
FindGameInActionSlideshow
; in: A/Y points to game filename
; out: C clear if game exists, and
; X = game index, and
; A/Y points to game display name + game info bitfield
; C set if game can't be found by any means
+STAY @sskey
jsr FindGame
bcc +
; 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
jsr FindGame
bcs @exit
+
jsr GetGameDisplayName
clc
@exit rts
GetGameDisplayName
; 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
+STAY SAVE
jsr okvs_get_current ; get value for this key
; (PTR) -> truncated game display name + info bitfield
ldy #0
lda (PTR), y ; A = length of truncated game display name + info bitfield
cmp #1 ; 1 means there's no title, just info bitfield (1 byte)
beq +
+LDAY PTR
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
ldy #1
- lda (SAVE), y
@or ora #$20 ; SMC (opcode)
sta gValLen, y
lda #$09 ; OR opcode
sta @or
@next iny
@len=*+1
cpy #$FD ; SMC
bne -
pla
sta gValLen, y
+LDADDR gValLen
rts
PlayGame
jsr GetGameToLaunch
; A/Y = address of game filename

View File

@ -9,6 +9,7 @@
; - okvs_append(address, key, value, max_len) add new key/value pair
; - okvs_update(address, key, value) update key/value pair
; - okvs_get(address, key) get value by key lookup
; - okvs_find(address, key) get key by key lookup
; - okvs_nth(address, n) get key by numeric index
; - okvs_next(address, n) get next key by numeric index
; - okvs_iter(address, callback) iterate through keys
@ -206,21 +207,26 @@ okvs_append
rts
;------------------------------------------------------------------------------
; okvs_get
; okvs_find / okvs_get
;
; in: stack contains 4 bytes of parameters:
; +1 [word] handle to storage space
; +3 [word] address of key
; out: if C clear, key was found
; A/Y = lo/hi address of value
; X = numeric index of key
; if C set, key was not found and all registers are clobbered
; out: if C clear, record was found
; A/Y = lo/hi address of key (okvs_find) or value (okvs_get)
; X = numeric index of found record
; if C set, keyrecord was not found and all registers are clobbered
; all other flags clobbered
; $00/$01 clobbered
; $02/$03 clobbered
; $04/$05 clobbered
;------------------------------------------------------------------------------
okvs_find
lda #$60
+HIDE_NEXT_2_BYTES
okvs_get
lda #$EA
sta @maybeGetValue
+PARAMS_ON_STACK 4
jsr GetStoreAddress
; PTR -> store
@ -255,18 +261,14 @@ okvs_get
KEYLEN = *+1
cpy #$D1 ; SMC
bne @matchKeyLoop
+LDAY DEST
clc
@maybeGetValue
brk ; SMC
jsr okvs_get_current
+LDAY PTR
clc
adc KEYLEN
bcc +
iny
clc
+ adc #2
sta PTR
bcc +
iny
clc
+ rts
rts
@next jsr derefptr ; PTR -> next record
inx
@max = *+1

View File

@ -38,6 +38,7 @@ ParseGamesList
cmp #$0D ; CR
bne @skipLine
@newkey ldx #$00 ; X = index into current key
stx gValLen ; initialize value length (in case this line has no value)
@emptyline
jsr IncAndGetChar ; get first filter character ('1' if game requires joystick)
cmp #$0D ; ignore blank line
@ -70,6 +71,8 @@ ParseGamesList
jsr IncAndGetChar
@gatherKey
jsr IncAndGetChar
cmp #$0D ; CR -> finalize key, no value
beq @endKey
cmp #$3D ; '=' ends the key
beq @endKey
sta gKey,x
@ -77,6 +80,8 @@ ParseGamesList
bpl @gatherKey
@endKey stx gKeyLen
ldx #$00 ; now X = index into the current value
cmp #$0D
beq @endValue
@gatherValue
jsr IncAndGetChar
cmp #$0D ; CR ends the value
@ -86,8 +91,8 @@ ParseGamesList
bpl @gatherValue
@endValue
pla ; pop cheat category
sta gVal,x ; store after game title
pla ; pop DHGR title
sta gVal,x ; store after game display name
pla ; pop has-DHGR-title flag
lsr
ror
ora gVal,x
@ -103,7 +108,6 @@ ParseGamesList
!byte 0
pla ; pop saved Y
tay
clc
bcc @newkey ; always branches
jmp @newkey
@exit rts

View File

@ -4,16 +4,17 @@
; text rank - an implementation of the Quicksilver search rank algorithm
;
; Public functions
; - BuildSearchStore
; - ResetTextRank
; - TextRankCallback (as okvs_iter_values callback)
;
; Public variables
; - InputLength ; [byte] number of characters typed in search mode
; - InputBuffer ; [25 bytes] characters typed in search mode
; - SelectedIndex ; [byte] index in gGamesListStore of currently selected game in search mode
; - SelectedIndex ; [byte] index in gSearchStore of currently selected game in search mode
; - MatchCount ; [byte] number of games that match InputBuffer
; - BestMatchScore ; [byte] raw ranking score (0-100) of current best match (updated during TextRankCallback)
; - BestMatchIndex ; [byte] index in gGamesListStore of current best match (updated during TextRankCallback)
; - BestMatchIndex ; [byte] index in gSearchStore of current best match (updated during TextRankCallback)
MaxInputLength = 26
InputLength
@ -21,6 +22,33 @@ InputLength
InputBuffer
!text " "
BuildSearchStore
jsr SwitchToBank2
jsr EnableAcceleratorAndSwitchToBank1
+LDADDR gSearchStore
jsr okvs_init
jsr okvs_iter
!word gGamesListStore
!word @callback
rts
@callback
; callback called by okvs_iter on gGamesListStore
; in: A/Y contains address of filename
; X contains 0-based index of the current record in gGamesListStore
; out: all registers and flags clobbered
+STAY @key
jsr GetGameDisplayName
+STAY @value
@append
jsr okvs_append
!word gSearchStore
@key !word $FDFD ; SMC
@value !word $FDFD ; SMC
!byte 0
rts
;------------------------------------------------------------------------------
; ResetTextRank
; reset the Match variables to allow re-scanning (e.g. because of backspace)
@ -38,20 +66,20 @@ ResetTextRank
;------------------------------------------------------------------------------
; TextRankCallback
; callback called by okvs_iter_values on gGamesListStore
; to calculate a ranking score for a single game title
; callback called by okvs_iter_values on gSearchStore
; to calculate a ranking score for a single game display name
; against the current InputBuffer
; in: A/Y contains address of game title
; X contains 0-based index of the current record in gGamesListStore
; in: A/Y contains address of game display name
; X contains 0-based index of the current record in gSearchStore
; out: all registers and flags clobbered
; MatchCount possibly incremented (if this title was a match at all)
; BestMatchScore and BestMatchIndex possibly updated (if this title
; MatchCount possibly incremented (if this game was a match at all)
; BestMatchScore and BestMatchIndex possibly updated (if this game
; was the best match so far)
;------------------------------------------------------------------------------
TextRankCallback
stx tmpx ; X = OKVS index of this title
+STAY zpstring ; A/Y = address of this title
stx tmpx ; X = OKVS index of this game
+STAY zpstring ; A/Y = address of this game display name
+LDADDR InputLength
+STAY zpword
ldy #0

View File

@ -181,7 +181,7 @@ DHGRTitleCallback
+STAY +
jsr GetGameInfo
jsr FindGame
; if game is not found (C will be set here), it means it can't be played on
; this machine due to memory or joystick requirements, so we don't display
; it in slideshows
@ -213,12 +213,12 @@ DHGRActionCallback
+STAY +
jsr GetGameInfoInActionSlideshow
jsr FindGameInActionSlideshow
; if game name is not found (C will be set here), it means the game
; can't be played due to memory or joystick requirements, so we hide
; it from slideshows
bcs DHGRRTS
+STAY SAVE ; (SAVE) -> game title
+STAY SAVE ; (SAVE) -> game display name + game info bitfield
stx gGameToLaunch
jsr LoadAuxFile ; load compressed DHGR screenshot at aux $3FF8
@ -238,7 +238,7 @@ DrawGameTitleInActionSlideshowHGR
sta VTAB
lda #0 ; solid horizontal bar character
jsr @resetline
lda (SAVE),y ; (SAVE) -> game title, Y = 0, so A = title length + 1
lda (SAVE),y ; (SAVE) -> game display name, Y = 0, so A = display length + 1
clc
adc #$02
sta gPathname
@ -248,7 +248,7 @@ DrawGameTitleInActionSlideshowHGR
inc VTAB
lda #" "
jsr @resetline
lda (SAVE),y ; A = title length + 1
lda (SAVE),y ; A = display length + 1
tay
dey
- lda (SAVE),y

View File

@ -95,7 +95,7 @@ GRActionCallback
+STAY +
jsr GetGameInfoInActionSlideshow
jsr FindGameInActionSlideshow
; if game name is not found (C will be set here), it means the game
; can't be played due to memory or joystick requirements, so we hide
; it from slideshows

View File

@ -112,7 +112,7 @@ HGRTitleCallback
+STAY +
jsr GetGameInfo
jsr FindGame
; if game is not found (C will be set here), it means it can't be played on
; this machine due to memory or joystick requirements, so we don't display
; it in slideshows
@ -144,14 +144,14 @@ HGRActionCallback
+STAY +
jsr GetGameInfoInActionSlideshow
jsr FindGameInActionSlideshow
; if game name is not found (C will be set here), it means the game
; can't be played due to memory or joystick requirements, so we hide
; it from slideshows
bcs HGRRTS
; found the game
+STAY SAVE ; (SAVE) -> game title
+STAY SAVE ; (SAVE) -> game display name + game info bitfield
stx gGameToLaunch
jsr LoadFile ; load compressed HGR screenshot at $3FF8

View File

@ -137,7 +137,7 @@ RunAttractModule
; language card or auxiliary memory.
+LDAY @key
jsr GetGameInfo
jsr FindGame
bcs ATTRTS ; if game doesn't exist, skip the demo
cpx #$FF
beq +

View File

@ -88,7 +88,7 @@ SHRArtworkCallback
+STAY @sfname
jsr GetGameInfo
jsr FindGame
; if game is not found (C will be set here), it means it can't be played on
; this machine due to memory or joystick requirements, so we don't display
; it in slideshows

View File

@ -89,9 +89,9 @@ LoadGameTitleOffscreen
bit MachineStatus ; if < 128K, don't bother checking for DHGR title
bvc @hgr
jsr okvs_get_current
; (PTR) -> game title + bitfield of game info
; (PTR) -> game display name + bitfield of game info
; Y = 0
lda (PTR),y ; A = game title length + 1
lda (PTR),y ; A = game display name length + 1
sta SAVE
tay
lda (PTR),y ; A = game info bitfield

View File

@ -109,10 +109,11 @@ DrawUI
beq @doneWithLine2
jsr GetGameToLaunch
jsr okvs_get_current
; (PTR) -> game title + bitfield of game info
; Y = 0
lda (PTR),y ; A = game title length + 1
jsr GetGameDisplayName
; A/Y -> game display name + bitfield of game info
+STAY PTR
ldy #0
lda (PTR),y ; A = game display name length + 1
sta SAVE
tay
lda (PTR),y ; A = game info bitfield
@ -178,7 +179,7 @@ DrawUI
ldy #0
@dotloop
iny
lda (PTR),y ; (PTR) still points to game title
lda (PTR),y ; (PTR) still points to game display name + game info bitfield
ora #$20 ; force lower-case always
cmp InputBuffer,x
bne +

View File

@ -100,6 +100,7 @@ SearchMode
ldx #$FF
txs
stx gGameToLaunch ; $FF = no game selected
jsr BuildSearchStore
jsr Home ; clear screen (switches to text mode)
jsr OnInputChanged ; draw UI offscreen
jsr HGRMode ; show HGR screen
@ -187,8 +188,8 @@ FindMatchingTitle
jsr ResetTextRank
jsr okvs_iter_values ; iterate through all game titles
!word gGamesListStore ; and rank them for the best match
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
lda MatchCount ; any matches at all?