This commit is contained in:
4am 2018-03-28 11:48:47 -04:00
parent d7e285bb8a
commit 03424bb954
14 changed files with 161 additions and 82 deletions

View File

@ -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"

View File

@ -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)

1
res/games.conf Normal file
View File

@ -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: <YOUR NAME> 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]

View File

@ -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

View File

@ -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

View File

@ -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
ldy #>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

42
src/parse.gamelist.a Normal file
View File

@ -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"
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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