use games.conf for master game list, remove hard-coded GAMES array

This commit is contained in:
4am 2018-03-28 14:09:39 -04:00
parent f5b5c9a374
commit fc962b6a59
6 changed files with 47 additions and 194 deletions

View File

@ -1,151 +0,0 @@
;license:MIT
;(c) 2018 by 4am
;
; Game directory and filenames
;
; Public constants
; - kNumberOfGames
; - GAMES
;
kNumberOfGames = 34
GAMES ; length of this array must = kNumberOfGames, there is no range checking
!word .adventure
!word .amfv
!word .ballyhoo
!word .beyondzork
!word .borderzone
!word .bureaucracy
!word .cutthroats
!word .deadline
!word .enchanter
!word .hgttg
!word .hollywoodhijinx
!word .infidel
!word .leathergoddesses
!word .lurkinghorror
!word .minizork
!word .moonmist
!word .nordandbert
!word .planetfall
!word .plunderedhearts
!word .seastalker
!word .sherlock
!word .sorcerer
!word .spellbreaker
!word .starcross
!word .stationfall
!word .suspect
!word .suspended
!word .trinity
!word .wishbringer
!word .witness
!word .zorki
!word .zorkii
!word .zorkiii
!word .ztuu
; length-prefixed names of each subdirectory in game directory, 1 per game
.adventure
!byte 9
!raw "ADVENTURE"
.amfv
!byte 4
!raw "AMFV"
.ballyhoo
!byte 8
!raw "BALLYHOO"
.beyondzork
!byte 11
!raw "BEYOND.ZORK"
.borderzone
!byte 11
!raw "BORDER.ZONE"
.bureaucracy
!byte 11
!raw "BUREAUCRACY"
.cutthroats
!byte 10
!raw "CUTTHROATS"
.deadline
!byte 8
!raw "DEADLINE"
.enchanter
!byte 9
!raw "ENCHANTER"
.hgttg
!byte 5
!raw "HGTTG"
.hollywoodhijinx
!byte 9
!raw "HOLLYWOOD"
.infidel
!byte 7
!raw "INFIDEL"
.leathergoddesses
!byte 4
!raw "LGOP"
.lurkinghorror
!byte 14
!raw "LURKING.HORROR"
.minizork
!byte 9
!raw "MINI.ZORK"
.moonmist
!byte 8
!raw "MOONMIST"
.nordandbert
!byte 13
!raw "NORD.AND.BERT"
.planetfall
!byte 10
!raw "PLANETFALL"
.plunderedhearts
!byte 9
!raw "PLUNDERED"
.seastalker
!byte 10
!raw "SEASTALKER"
.sherlock
!byte 8
!raw "SHERLOCK"
.sorcerer
!byte 8
!raw "SORCERER"
.spellbreaker
!byte 12
!raw "SPELLBREAKER"
.starcross
!byte 9
!raw "STARCROSS"
.stationfall
!byte 11
!raw "STATIONFALL"
.suspect
!byte 7
!raw "SUSPECT"
.suspended
!byte 9
!raw "SUSPENDED"
.trinity
!byte 7
!raw "TRINITY"
.wishbringer
!byte 11
!raw "WISHBRINGER"
.witness
!byte 7
!raw "WITNESS"
.zorki
!byte 6
!raw "ZORK.I"
.zorkii
!byte 7
!raw "ZORK.II"
.zorkiii
!byte 8
!raw "ZORK.III"
.ztuu
!byte 4
!raw "ZTUU"

View File

@ -88,6 +88,8 @@ okvs_init
; in: stack contains 2 bytes of parameters: ; in: stack contains 2 bytes of parameters:
; +1 [word] handle to storage space ; +1 [word] handle to storage space
; out: A contains number of keys in this store ; out: A contains number of keys in this store
; X clobbered
; Y preserved
; $00/$01 clobbered ; $00/$01 clobbered
; $02/$03 clobbered ; $02/$03 clobbered
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------

View File

@ -33,7 +33,7 @@ addrInfo
; LoadGameInfo ; LoadGameInfo
; load file with information about the current game ; load file with information about the current game
; ;
; in: gCurrentGame between 0 and (kNumberOfGames-1) ; in: current ProDOS prefix is the same as the PITCH.DARK binary
; out: addrInfo, addrDescription, addrVersions, addrOptions populated ; out: addrInfo, addrDescription, addrVersions, addrOptions populated
; gVersionsStore populated with keys/values in [versions] section ; gVersionsStore populated with keys/values in [versions] section
; gOptionsStore populated with keys/values in [options] section ; gOptionsStore populated with keys/values in [options] section

View File

@ -8,8 +8,6 @@
; - SaveGlobalPreferences ; - SaveGlobalPreferences
; ;
; Public variables ; Public variables
; - gCurrentGame byte 0..kNumberOfGames-1
; populated by LoadGlobalPreferences so other code can index into GAMES array for quick access to game shortnames
; - gNeedToSavePrefs byte 0=false, 1=true ; - gNeedToSavePrefs byte 0=false, 1=true
; set to 1 if prefs have changed. SaveGlobalPreferences won't write to disk if this is 0. ; set to 1 if prefs have changed. SaveGlobalPreferences won't write to disk if this is 0.
; ;
@ -25,9 +23,6 @@
gGlobalPrefsStore gGlobalPrefsStore
!word 0 !word 0
gCurrentGame
!byte 0
gNeedToSavePrefs gNeedToSavePrefs
!byte 0 !byte 0
@ -72,19 +67,6 @@ LoadGlobalPreferences
sta gVersionsStore sta gVersionsStore
lda SRC+1 lda SRC+1
sta gVersionsStore+1 sta gVersionsStore+1
jsr okvs_get ; get shortname of current game
!word gGlobalPrefsStore
!word kLastPlayed
sta .gameNamePtr
sty .gameNamePtr+1
jsr okvs_get ; look up game in games list to get numeric index
!word gGamesListStore
.gameNamePtr
!word $FDFD ; SMC
stx gCurrentGame
rts rts
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -129,21 +111,24 @@ SaveGlobalPreferences
ldy #>.fluff3 ldy #>.fluff3
jsr addString jsr addString
jsr okvs_len
!word gGamesListStore
sta .numberOfGames
ldx #0 ldx #0
.gameLoop .gameLoop
phx phx
txa stx .n
asl jsr okvs_nth
tax !word gGamesListStore
lda GAMES,x .n !byte $FD ; SMC
ldy GAMES+1,x
sta .gameKey sta .gameKey
sty .gameKey+1 sty .gameKey+1
jsr addStringFromStore jsr addStringFromStore
.gameKey !word $FDFD ; SMC .gameKey !word $FDFD ; SMC
plx plx
inx inx
cpx #kNumberOfGames .numberOfGames=*+1
cpx #$FD ; SMC
bne .gameLoop bne .gameLoop
lda #<.eof lda #<.eof

View File

@ -12,7 +12,6 @@
!source "src/constants.a" !source "src/constants.a"
!source "src/WeeGUI_MLI.s" !source "src/WeeGUI_MLI.s"
!source "src/games.a"
!source "src/okvs.a" !source "src/okvs.a"
!source "src/prodos.a" !source "src/prodos.a"
!source "src/ramdisk.a" !source "src/ramdisk.a"

View File

@ -170,31 +170,49 @@ HandleKey
} }
!zone { !zone {
GetCurrentGameIndex
jsr okvs_get ; get shortname of current game
!word gGlobalPrefsStore
!word kLastPlayed
sta .gameNamePtr
sty .gameNamePtr+1
jsr okvs_get ; get numeric index
!word gGamesListStore
.gameNamePtr
!word $FDFD ; SMC
rts ; X = index of current game
callback_previous callback_previous
lda gCurrentGame jsr GetCurrentGameIndex
dec dex
bpl + bpl +
lda #kNumberOfGames-1 jsr okvs_len
+ sta gCurrentGame !word gGamesListStore
bra .loadNewGameInfoAndRepaint
callback_next
lda gCurrentGame
inc
cmp #kNumberOfGames
bcc +
lda #0
+ sta gCurrentGame
asl
tax tax
lda GAMES,x dex
+ bra .loadNewGameInfoAndRepaint
callback_next
jsr GetCurrentGameIndex
inx
stx .n
jsr okvs_len
!word gGamesListStore
ldx .n
.n=*+1
cmp #$FD ; SMC
bne .loadNewGameInfoAndRepaint
ldx #0
.loadNewGameInfoAndRepaint
stx .nth
jsr okvs_nth
!word gGamesListStore
.nth !byte $FD ; SMC
sta .gameptr sta .gameptr
lda GAMES+1,x sty .gameptr+1
sta .gameptr+1
jsr okvs_update jsr okvs_update
!word gGlobalPrefsStore !word gGlobalPrefsStore
!word kLastPlayed !word kLastPlayed
.gameptr !word $FDFD ; SMC .gameptr !word $FDFD ; SMC
.loadNewGameInfoAndRepaint
lda #1 lda #1
sta gNeedToSavePrefs sta gNeedToSavePrefs
jsr LoadGameInfo jsr LoadGameInfo