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 # https://bitbucket.org/magli143/exomizer/wiki/Home
EXOMIZER=exomizer mem -q -P23 -lnone EXOMIZER=exomizer mem -q -P23 -lnone
dsk: md asm compress dsk: md asm
cp res/blank.2mg build/"$(DISK)" >>build/log cp res/blank.2mg build/"$(DISK)" >>build/log
cp res/_FileInformation.txt build/ >>build/log cp res/_FileInformation.txt build/ >>build/log
$(CADIUS) ADDFILE build/"$(DISK)" "/$(VOLUME)/" "build/LAUNCHER.SYSTEM" >>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 gFXStore
gDFXStore gDFXStore
!word $6000 !word $6000
gSearchStore
!word $8000
gSlideshowStore gSlideshowStore
!word $0800 !word $0800
gGlobalPrefsStore gGlobalPrefsStore

View File

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

View File

@ -5,8 +5,9 @@
; ;
; Public functions ; Public functions
; - GetGameToLaunch ; - GetGameToLaunch
; - GetGameInfo ; - FindGame
; - GetGameInfoInActionSlideshow ; - FindGameInActionSlideshow
; - GetGameDisplayName
; - PlayGame ; - PlayGame
; - Launch ; - Launch
; ;
@ -22,32 +23,24 @@ gGameToLaunch=*+1
+LDADDR gGamesListStore +LDADDR gGamesListStore
jmp okvs_nth jmp okvs_nth
GetGameInfo FindGame
; in: A/Y points to game filename ; in: A/Y points to game filename
; out: C clear if game exists in gGamesListStore, and ; 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 ; X = game index, or #$FF if the game doesn't really exist but
; we want to return a successful result anyway (really, read the ; we want to return a successful result anyway
; hack notes, they're important) ; C set if game does not exist, and
; C set if game does not exist (this can happen because slideshows ; X clobbered (this can happen because slideshows list games
; list games that require a joystick, but the games list parser ; that require a joystick, but the games list parser filters out
; filters out joystick-only games if the machine doesn't have a ; joystick-only games if the machine doesn't have a joystick)
; joystick) ; A,Y always clobbered
ldx #$60
+HIDE_NEXT_2_BYTES
GetGameInfoInActionSlideshow
ldx #$EA
stx @maybeExit
+STAY @key +STAY @key
+STAY @slideshowKey jsr okvs_find
jsr okvs_get
!word gGamesListStore !word gGamesListStore
@key !word $FDFD ; SMC @key !word $FDFD ; SMC
bcc @exit bcc @exit
; Hack to allow self-running demos that don't correspond to a game ; Hack to allow self-running demos that don't correspond to a game
; filename. If the name ends in a '.', accept it unconditionally. ; filename. If the name ends in a '.', accept it unconditionally.
; The filename is its own display name. Launching this fake game ldx #$FF
; will of course fail, so don't do that.
+LDAY @key +LDAY @key
+STAY PARAM +STAY PARAM
ldy #0 ldy #0
@ -57,30 +50,78 @@ GetGameInfoInActionSlideshow
cmp #"." cmp #"."
beq @forceGoodResult beq @forceGoodResult
sec 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 rts
@forceGoodResult @forceGoodResult
+LDAY @key
ldx #$FF
clc clc
@exit rts @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 PlayGame
jsr GetGameToLaunch jsr GetGameToLaunch
; A/Y = address of game filename ; 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_append(address, key, value, max_len) add new key/value pair
; - okvs_update(address, key, value) update key/value pair ; - okvs_update(address, key, value) update key/value pair
; - okvs_get(address, key) get value by key lookup ; - 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_nth(address, n) get key by numeric index
; - okvs_next(address, n) get next key by numeric index ; - okvs_next(address, n) get next key by numeric index
; - okvs_iter(address, callback) iterate through keys ; - okvs_iter(address, callback) iterate through keys
@ -206,21 +207,26 @@ okvs_append
rts rts
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; okvs_get ; okvs_find / okvs_get
; ;
; in: stack contains 4 bytes of parameters: ; in: stack contains 4 bytes of parameters:
; +1 [word] handle to storage space ; +1 [word] handle to storage space
; +3 [word] address of key ; +3 [word] address of key
; out: if C clear, key was found ; out: if C clear, record was found
; A/Y = lo/hi address of value ; A/Y = lo/hi address of key (okvs_find) or value (okvs_get)
; X = numeric index of key ; X = numeric index of found record
; if C set, key was not found and all registers are clobbered ; if C set, keyrecord was not found and all registers are clobbered
; all other flags clobbered ; all other flags clobbered
; $00/$01 clobbered ; $00/$01 clobbered
; $02/$03 clobbered ; $02/$03 clobbered
; $04/$05 clobbered ; $04/$05 clobbered
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
okvs_find
lda #$60
+HIDE_NEXT_2_BYTES
okvs_get okvs_get
lda #$EA
sta @maybeGetValue
+PARAMS_ON_STACK 4 +PARAMS_ON_STACK 4
jsr GetStoreAddress jsr GetStoreAddress
; PTR -> store ; PTR -> store
@ -255,18 +261,14 @@ okvs_get
KEYLEN = *+1 KEYLEN = *+1
cpy #$D1 ; SMC cpy #$D1 ; SMC
bne @matchKeyLoop bne @matchKeyLoop
+LDAY DEST
clc
@maybeGetValue
brk ; SMC
jsr okvs_get_current
+LDAY PTR +LDAY PTR
clc clc
adc KEYLEN rts
bcc +
iny
clc
+ adc #2
sta PTR
bcc +
iny
clc
+ rts
@next jsr derefptr ; PTR -> next record @next jsr derefptr ; PTR -> next record
inx inx
@max = *+1 @max = *+1

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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