From 03424bb954a0ab7cdca71b4d25e5f6abde08df41 Mon Sep 17 00:00:00 2001 From: 4am Date: Wed, 28 Mar 2018 11:48:47 -0400 Subject: [PATCH] . --- Makefile | 1 + res/_FileInformation.txt | 1 + res/games.conf | 1 + src/okvs.a | 66 +++++++++++++++++++++++++++++++--------- src/parse.common.a | 8 ++--- src/parse.gameinfo.a | 16 +++++----- src/parse.gamelist.a | 42 +++++++++++++++++++++++++ src/parse.prefs.a | 45 +++++++++++---------------- src/path.a | 2 +- src/pitchdark.a | 18 ++++++----- src/ui.common.a | 2 +- src/ui.main.a | 29 +++++++++--------- src/ui.main.keys.a | 2 +- src/ui.options.a | 10 +++--- 14 files changed, 161 insertions(+), 82 deletions(-) create mode 100644 res/games.conf create mode 100644 src/parse.gamelist.a diff --git a/Makefile b/Makefile index 1f99d0a..1c95fd8 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,7 @@ dsk: md asm $(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "build/GRUE.SYSTEM" $(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "build/ONBEYOND.SYSTEM" $(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "build/PITCH.DARK" + $(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "res/GAMES.CONF" $(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "res/PITCH.DARK.CONF" $(CADIUS) CREATEFOLDER build/"$(DISK)" "/PITCH.DARK/LIB/" $(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/LIB/" "res/WEEGUI" diff --git a/res/_FileInformation.txt b/res/_FileInformation.txt index 4a5acbd..06d65c0 100644 --- a/res/_FileInformation.txt +++ b/res/_FileInformation.txt @@ -1,6 +1,7 @@ GRUE.SYSTEM=Type(FF),AuxType(2000),Access(C3) PITCH.DARK=Type(06),AuxType(6000),Access(C3) PITCH.DARK.CONF=Type(04),AuxType(0000),Access(C3) +GAMES.CONF=Type(04),AuxType(0000),Access(C3) ONBEYOND.SYSTEM=Type(FF),AuxType(2000),Access(C3) ONBEYONDZ1=Type(06),AuxType(3000),Access(C3) ONBEYONDZ2=Type(06),AuxType(3000),Access(C3) diff --git a/res/games.conf b/res/games.conf new file mode 100644 index 0000000..f54ef83 --- /dev/null +++ b/res/games.conf @@ -0,0 +1 @@ +# Pitch Dark games list # key=game directory, value=title ADVENTURE=ADVENTURE: the interactive original AMFV=A MIND FOREVER VOYAGING BALLYHOO=BALLYHOO BEYOND.ZORK=BEYOND ZORK: THE COCONUT OF QUENDOR BORDER.ZONE=BORDER ZONE: A GAME OF INTRIGUE BUREAUCRACY=BUREAUCRACY: a paranoid fantasy CUTTHROATS=CUTTHROATS DEADLINE=DEADLINE: an Interlogic mystery ENCHANTER=ENCHANTER HGTTG=THE HITCHHIKER'S GUIDE TO THE GALAXY HOLLYWOOD=HOLLYWOOD HIJINX: a zany treasure hunt INFIDEL=INFIDEL LGOP=LEATHER GOODESSES OF PHOBOS: a racy space-age spoof LURKING.HORROR=THE LURKING HORROR MINI.ZORK=MINI-ZORK I: THE GREAT UNDERGROUND EMPIRE MOONMIST=MOONMIST NORD.AND.BERT=NORD AND BERT COULDN'T MAKE HEAD OR TAIL OF IT PLANETFALL=PLANETFALL PLUNDERED=PLUNDERED HEARTS SEASTALKER=SEASTALKER: AND THE ULTRAMARINE BIOCEPTOR SHERLOCK=SHERLOCK: THE RIDDLE OF THE CROWN JEWELS SORCERER=SORCERER SPELLBREAKER=SPELLBREAKER STARCROSS=STARCROSS STATIONFALL=STATIONFALL SUSPECT=SUSPECT SUSPENDED=SUSPENDED TRINITY=TRINITY WISHBRINGER=WISHBRINGER: THE MAGICK STONE OF DREAMS WITNESS=THE WITNESS: an Interlogic mystery ZORK.I=ZORK I: THE GREAT UNDERGROUND EMPIRE ZORK.II=ZORK II: THE WIZARD OF FROBOZZ ZORK.III=ZORK III: THE DUNGEON MASTER ZTUU=ZORK: THE UNDISCOVERED UNDERGROUND [eof] \ No newline at end of file diff --git a/src/okvs.a b/src/okvs.a index 72054c8..e846ba2 100644 --- a/src/okvs.a +++ b/src/okvs.a @@ -4,12 +4,13 @@ ; Ordered key/value store ; ; Public functions -; - okvs_init(address) -; - okvs_len(address) -; - okvs_append(address, key, value, max_len) -; - okvs_update(address, key, value) -; - okvs_get(address, key) -; - okvs_as_boolean(value) +; - okvs_init(address) reset (required) +; - okvs_len(address) get number of keys +; - 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_nth(address, n) get key by numeric index +; - okvs_as_boolean(value) set Z flag based on value ; ; Used for global preferences, per-game options, and per-game version lists ; @@ -23,7 +24,7 @@ ; Keys and values are length-prefixed strings (Pascal style), so max length ; of any single key or value is 255 bytes. ; -; Keys are case-sensitive. +; Keys are case-sensitive. Lookups are an exact byte-for-byte comparison. ; ; append() has a max_len argument to reserve more space for the value, in case ; you want to update it later. max_len is the total space to reserve, not the @@ -147,7 +148,7 @@ okvs_append lda PTR ; update PTR to byte after copied key clc .keylen=*+1 - adc #$FD ; set at runtime + adc #$FD ; SMC sta PTR bcc + inc PTR+1 @@ -174,7 +175,7 @@ okvs_append lda PTR clc .valuelen=*+1 - adc #$FD ; set at runtime + adc #$FD ; SMC sta SRC bcc + inc PTR+1 @@ -197,7 +198,9 @@ okvs_append ; 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 and A/Y = lo/hi address of value +; 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 ; all other flags clobbered ; $00/$01 clobbered @@ -211,6 +214,8 @@ okvs_get beq .fail ; no keys, fail immediately tax ; X = number of keys inx + stx .maxKeys + ldx #0 jsr incptr ; PTR -> first record ldy #3 @@ -240,7 +245,7 @@ okvs_get bne .goToNextRecord iny .matchlen=*+1 - cpy #$FD ; set at runtime + cpy #$FD ; SMC bne .matchKeyLoop lda PTR ldy PTR+1 @@ -257,11 +262,44 @@ okvs_get rts .goToNextRecord jsr derefptr ; PTR -> next record - dex + inx +.maxKeys=*+1 + cpx #$FD ; SMC bne .matchRecordLoop .fail sec rts +;------------------------------------------------------------------------------ +; okvs_nth +; +; in: stack contains 3 bytes of parameters: +; +1 [word] handle to storage space +; +3 [byte] numeric index +; out: A/Y = lo/hi address of nth key +; all other registers and flags clobbered +; $00/$01 clobbered +; $02/$03 clobbered +; $04/$05 clobbered +;------------------------------------------------------------------------------ +okvs_nth + +PARAMS_ON_STACK 3 + jsr SetPTRFromStackParams + jsr incptr ; PTR -> first record + + ldy #3 + lda (PARAM),y + tax ; X = numeric index of key to get +- beq .done + jsr derefptr + dex + bra - +.done + jsr incptr + jsr incptr + lda PTR + ldy PTR+1 + rts + ;------------------------------------------------------------------------------ ; okvs_update ; @@ -292,8 +330,8 @@ okvs_update bne - jsr okvs_get .getparams=*-1 - !word $FDFD ; set at runtime - !word $FDFD ; set at runtime + !word $FDFD ; SMC + !word $FDFD ; SMC bcs .exit sta DEST sty DEST+1 diff --git a/src/parse.common.a b/src/parse.common.a index f68f6f3..9f3e126 100644 --- a/src/parse.common.a +++ b/src/parse.common.a @@ -54,7 +54,7 @@ ParseKeyValueText + sty $FF jsr okvs_init ; reset key/value store .initStore - !word $FDFD ; set at runtime + !word $FDFD ; SMC ldy #$00 ; index into ($FE) pointing to current character .newKey @@ -95,16 +95,16 @@ ParseKeyValueText lda #0 !byte $2C .useMaxLength - lda #$FD ; set at runtime + lda #$FD ; SMC sta .appendMaxLength ; all other values get upgraded to max_length so we can update them in place phy ; okvs functions clobber everything but we need Y jsr okvs_append .appendStore - !word $FDFD ; set at runtime + !word $FDFD ; SMC !word gKeyLen !word gValLen .appendMaxLength - !byte $FD ; set at runtime + !byte $FD ; SMC ply bra .newKey diff --git a/src/parse.gameinfo.a b/src/parse.gameinfo.a index 9f8d6e2..ca48325 100644 --- a/src/parse.gameinfo.a +++ b/src/parse.gameinfo.a @@ -13,9 +13,9 @@ kTextRootDirectory !raw "TEXT/" gVersionsStore - !word $FDFD ; set at runtime in LoadGlobalPreferences + !word $FDFD ; set in LoadGlobalPreferences gOptionsStore - !word $FDFD ; set at runtime in LoadGameInfo + !word $FDFD ; set in LoadGameInfo sectionPointers ; array of pointers to start of each section addrEOF @@ -35,18 +35,20 @@ addrInfo ; ; in: gCurrentGame between 0 and (kNumberOfGames-1) ; out: addrInfo, addrDescription, addrVersions, addrOptions populated +; gVersionsStore populated with keys/values in [versions] section +; gOptionsStore populated with keys/values in [options] section ; all registers and flags clobbered +; $00..$05 clobbered +; $0800..$1FFF clobbered ;------------------------------------------------------------------------------ LoadGameInfo jsr ResetPath lda #kTextRootDirectory jsr AddToPath - lda gCurrentGame - asl - tax - lda GAMES,x - ldy GAMES+1,x + jsr okvs_get + !word gGlobalPrefsStore + !word kLastPlayed jsr AddToPath jsr LoadFile diff --git a/src/parse.gamelist.a b/src/parse.gamelist.a new file mode 100644 index 0000000..71b2c1d --- /dev/null +++ b/src/parse.gamelist.a @@ -0,0 +1,42 @@ +;license:MIT +;(c) 2018 by 4am +; +; Parser for game list +; +; Public functions +; - LoadGameList +; + +;------------------------------------------------------------------------------ +; LoadGameList +; load file with master game list +; +; in: current ProDOS prefix is the same as the GAMES.CONF file +; out: gGamesListStore populated +; all registers and flags clobbered +;------------------------------------------------------------------------------ +!zone { +LoadGameList + jsr LoadFile ; load prefs file at $2000 + !word .gamesListFilename +.listAddress + !word $2000 + !word $2000 + !word kProDOSFileBuffer + + jsr ParseKeyValueText ; parse contents into games list store + !word gGamesListStore + !word .listAddress + !byte 0 + + lda SRC ; save pointer to free space for next store + sta gGlobalPrefsStore + lda SRC+1 + sta gGlobalPrefsStore+1 + + rts + +.gamesListFilename + !byte 10 + !raw "GAMES.CONF" +} diff --git a/src/parse.prefs.a b/src/parse.prefs.a index d2818bf..0d4cf36 100644 --- a/src/parse.prefs.a +++ b/src/parse.prefs.a @@ -22,6 +22,9 @@ ; !zone { +gGlobalPrefsStore + !word 0 + gCurrentGame !byte 0 @@ -70,30 +73,18 @@ LoadGlobalPreferences lda SRC+1 sta gVersionsStore+1 - jsr okvs_get ; set gCurrentGame + jsr okvs_get ; get shortname of current game !word gGlobalPrefsStore !word kLastPlayed - sta DEST - sty DEST+1 - ldx #$FE -.findLastPlayed - inx - inx - lda GAMES,x - sta SRC - lda GAMES+1,x - sta SRC+1 - lda (SRC) - tay - dey -- lda (SRC),y - cmp (DEST),y - bne .findLastPlayed - dey - bpl - - txa - lsr - sta gCurrentGame + 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 ;------------------------------------------------------------------------------ @@ -149,7 +140,7 @@ SaveGlobalPreferences sta .gameKey sty .gameKey+1 jsr addStringFromStore -.gameKey !word $FDFD ; set at runtime +.gameKey !word $FDFD ; SMC plx inx cpx #kNumberOfGames @@ -172,7 +163,7 @@ SaveGlobalPreferences !word 0 ; auxtype=0000 !word $2000 .prefslen - !word $FDFD ; set at runtime + !word $FDFD ; SMC !word kProDOSFileBuffer stz gNeedToSavePrefs @@ -201,9 +192,9 @@ addStringFromStore jsr okvs_get !word gGlobalPrefsStore .storeKey - !word $FDFD ; set at runtime + !word $FDFD ; SMC .skipOverBooleanLogic - bra + ; set at runtime (opcode may become BIT) + bra + ; SMC (opcode may become BIT) sta PTR sty PTR+1 ldy #1 @@ -231,7 +222,7 @@ addString bne + inc $FF .len=*+1 -+ cpy #$FD ; set at runtime ++ cpy #$FD ; SMC bne - rts diff --git a/src/path.a b/src/path.a index 84ca4bb..ec63034 100644 --- a/src/path.a +++ b/src/path.a @@ -46,7 +46,7 @@ AddToPath sta gPathname+1,x inx iny -.a cpy #$FD ; set at runtime +.a cpy #$FD ; SMC bcc - stx gPathname rts diff --git a/src/pitchdark.a b/src/pitchdark.a index 8e49574..968386c 100644 --- a/src/pitchdark.a +++ b/src/pitchdark.a @@ -20,6 +20,7 @@ !source "src/sound.a" !source "src/launch.a" !source "src/parse.common.a" + !source "src/parse.gamelist.a" !source "src/parse.gameinfo.a" !source "src/parse.prefs.a" !source "src/ui.common.a" @@ -27,10 +28,6 @@ !source "src/ui.main.keys.a" !source "src/ui.options.a" -.weeguiFilename - !byte 10 - !raw "LIB/WEEGUI" - Start lda MACHID and #$30 @@ -49,8 +46,9 @@ Start jsr DisconnectRAM32 ; disconnect /RAM in S3,D2 jsr ClearInterpreterOptions ; clear options struct at $300 jsr WGInit ; initialize WeeGUI - jsr LoadGlobalPreferences ; get current game - jsr LoadGameInfo ; load and parse game description text + jsr LoadGameList ; get master list of games + jsr LoadGlobalPreferences ; get current game and global options + jsr LoadGameInfo ; get current game description and game-specific options ldx #WGEnableMouse ; enable mouse support jsr WeeGUI MainScreen @@ -78,5 +76,9 @@ ExitWeeGUI ldx #WGExit ; clean up WeeGUI jmp WeeGUI -gGlobalPrefsStore - !word *+2 ; address of storage space for prefs +.weeguiFilename + !byte 10 + !raw "LIB/WEEGUI" + +gGamesListStore + !word *+2 ; address first okvs store diff --git a/src/ui.common.a b/src/ui.common.a index 98c44db..5e80d13 100644 --- a/src/ui.common.a +++ b/src/ui.common.a @@ -47,7 +47,7 @@ CreateButton lda ($00),y sta PARAM1 .type=*+1 - ldx #$FD ; set at runtime + ldx #$FD ; SMC jsr WeeGUI ldx #WGViewSetRawTitle lda #1 diff --git a/src/ui.main.a b/src/ui.main.a index 513b38c..de6b93b 100644 --- a/src/ui.main.a +++ b/src/ui.main.a @@ -165,21 +165,22 @@ paintInfoView bpl - lda #$00 sta $3F65 - lda gCurrentGame - asl - tax - lda GAMES,x - sta .key1 - lda GAMES+1,x - sta .key1+1 - jsr okvs_get + + jsr okvs_get ; get shortname of current game !word gGlobalPrefsStore -.key1 !word $FDFD ; set at runtime + !word kLastPlayed + sta .key1 + sty .key1+1 + + jsr okvs_get ; get selected version of this game + !word gGlobalPrefsStore +.key1 !word $FDFD ; SMC sta .key2 sty .key2+1 - jsr okvs_get + + jsr okvs_get ; get long description of this version !word gVersionsStore -.key2 !word $FDFD ; set at runtime +.key2 !word $FDFD ; SMC sta SRC sty SRC+1 lda (SRC) @@ -203,9 +204,9 @@ multiPrint lda ($00) beq .printDone ldx #WGSetCursor -.htab lda #$FD ; set at runtime +.htab lda #$FD ; SMC sta PARAM0 -.vtab lda #$FD ; set at runtime +.vtab lda #$FD ; SMC sta PARAM1 jsr WeeGUI ldx #WGPrint @@ -218,7 +219,7 @@ multiPrint lda $00 clc .printLineLength - adc #$fd ; set at runtime + adc #$fd ; SMC sta $00 bcc + inc $01 diff --git a/src/ui.main.keys.a b/src/ui.main.keys.a index 6fb7d7a..0b06da2 100644 --- a/src/ui.main.keys.a +++ b/src/ui.main.keys.a @@ -193,7 +193,7 @@ callback_next jsr okvs_update !word gGlobalPrefsStore !word kLastPlayed -.gameptr !word $FDFD ; set at runtime +.gameptr !word $FDFD ; SMC .loadNewGameInfoAndRepaint lda #1 sta gNeedToSavePrefs diff --git a/src/ui.options.a b/src/ui.options.a index 5a23461..6c14e31 100644 --- a/src/ui.options.a +++ b/src/ui.options.a @@ -222,7 +222,7 @@ SetCheckboxByPref jsr okvs_get !word gGlobalPrefsStore -.key !word $FDFD ; set at runtime +.key !word $FDFD ; SMC bcs .exit jsr okvs_as_boolean @@ -230,7 +230,7 @@ SetCheckboxByPref ldx #WGSelectView .id=*+1 - lda #$FD ; set at runtime + lda #$FD ; SMC jsr WeeGUI ldx #WGSetState lda #1 @@ -255,7 +255,7 @@ SetPrefByCheckbox ldx #WGSelectView .id=*+1 - lda #$FD ; set at runtime + lda #$FD ; SMC jsr WeeGUI ldx #WGGetState jsr WeeGUI @@ -266,11 +266,11 @@ SetPrefByCheckbox jsr okvs_update !word gGlobalPrefsStore -.key !word $FDFD ; set at runtime +.key !word $FDFD ; SMC !word .value rts .value !byte 1 - !byte $FD ; set at runtime + !byte $FD ; SMC } .viewFrame