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/GRUE.SYSTEM"
$(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "build/ONBEYOND.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/" "build/PITCH.DARK"
$(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "res/GAMES.CONF"
$(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "res/PITCH.DARK.CONF" $(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "res/PITCH.DARK.CONF"
$(CADIUS) CREATEFOLDER build/"$(DISK)" "/PITCH.DARK/LIB/" $(CADIUS) CREATEFOLDER build/"$(DISK)" "/PITCH.DARK/LIB/"
$(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/LIB/" "res/WEEGUI" $(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/LIB/" "res/WEEGUI"

View File

@ -1,6 +1,7 @@
GRUE.SYSTEM=Type(FF),AuxType(2000),Access(C3) GRUE.SYSTEM=Type(FF),AuxType(2000),Access(C3)
PITCH.DARK=Type(06),AuxType(6000),Access(C3) PITCH.DARK=Type(06),AuxType(6000),Access(C3)
PITCH.DARK.CONF=Type(04),AuxType(0000),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) ONBEYOND.SYSTEM=Type(FF),AuxType(2000),Access(C3)
ONBEYONDZ1=Type(06),AuxType(3000),Access(C3) ONBEYONDZ1=Type(06),AuxType(3000),Access(C3)
ONBEYONDZ2=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 ; Ordered key/value store
; ;
; Public functions ; Public functions
; - okvs_init(address) ; - okvs_init(address) reset (required)
; - okvs_len(address) ; - okvs_len(address) get number of keys
; - okvs_append(address, key, value, max_len) ; - okvs_append(address, key, value, max_len) add new key/value pair
; - okvs_update(address, key, value) ; - okvs_update(address, key, value) update key/value pair
; - okvs_get(address, key) ; - okvs_get(address, key) get value by key lookup
; - okvs_as_boolean(value) ; - 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 ; 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 ; Keys and values are length-prefixed strings (Pascal style), so max length
; of any single key or value is 255 bytes. ; 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 ; 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 ; 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 lda PTR ; update PTR to byte after copied key
clc clc
.keylen=*+1 .keylen=*+1
adc #$FD ; set at runtime adc #$FD ; SMC
sta PTR sta PTR
bcc + bcc +
inc PTR+1 inc PTR+1
@ -174,7 +175,7 @@ okvs_append
lda PTR lda PTR
clc clc
.valuelen=*+1 .valuelen=*+1
adc #$FD ; set at runtime adc #$FD ; SMC
sta SRC sta SRC
bcc + bcc +
inc PTR+1 inc PTR+1
@ -197,7 +198,9 @@ okvs_append
; 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 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 ; if C set, key was not found and all registers are clobbered
; all other flags clobbered ; all other flags clobbered
; $00/$01 clobbered ; $00/$01 clobbered
@ -211,6 +214,8 @@ okvs_get
beq .fail ; no keys, fail immediately beq .fail ; no keys, fail immediately
tax ; X = number of keys tax ; X = number of keys
inx inx
stx .maxKeys
ldx #0
jsr incptr ; PTR -> first record jsr incptr ; PTR -> first record
ldy #3 ldy #3
@ -240,7 +245,7 @@ okvs_get
bne .goToNextRecord bne .goToNextRecord
iny iny
.matchlen=*+1 .matchlen=*+1
cpy #$FD ; set at runtime cpy #$FD ; SMC
bne .matchKeyLoop bne .matchKeyLoop
lda PTR lda PTR
ldy PTR+1 ldy PTR+1
@ -257,11 +262,44 @@ okvs_get
rts rts
.goToNextRecord .goToNextRecord
jsr derefptr ; PTR -> next record jsr derefptr ; PTR -> next record
dex inx
.maxKeys=*+1
cpx #$FD ; SMC
bne .matchRecordLoop bne .matchRecordLoop
.fail sec .fail sec
rts 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 ; okvs_update
; ;
@ -292,8 +330,8 @@ okvs_update
bne - bne -
jsr okvs_get jsr okvs_get
.getparams=*-1 .getparams=*-1
!word $FDFD ; set at runtime !word $FDFD ; SMC
!word $FDFD ; set at runtime !word $FDFD ; SMC
bcs .exit bcs .exit
sta DEST sta DEST
sty DEST+1 sty DEST+1

View File

@ -54,7 +54,7 @@ ParseKeyValueText
+ sty $FF + sty $FF
jsr okvs_init ; reset key/value store jsr okvs_init ; reset key/value store
.initStore .initStore
!word $FDFD ; set at runtime !word $FDFD ; SMC
ldy #$00 ; index into ($FE) pointing to current character ldy #$00 ; index into ($FE) pointing to current character
.newKey .newKey
@ -95,16 +95,16 @@ ParseKeyValueText
lda #0 lda #0
!byte $2C !byte $2C
.useMaxLength .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 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 phy ; okvs functions clobber everything but we need Y
jsr okvs_append jsr okvs_append
.appendStore .appendStore
!word $FDFD ; set at runtime !word $FDFD ; SMC
!word gKeyLen !word gKeyLen
!word gValLen !word gValLen
.appendMaxLength .appendMaxLength
!byte $FD ; set at runtime !byte $FD ; SMC
ply ply
bra .newKey bra .newKey

View File

@ -13,9 +13,9 @@ kTextRootDirectory
!raw "TEXT/" !raw "TEXT/"
gVersionsStore gVersionsStore
!word $FDFD ; set at runtime in LoadGlobalPreferences !word $FDFD ; set in LoadGlobalPreferences
gOptionsStore gOptionsStore
!word $FDFD ; set at runtime in LoadGameInfo !word $FDFD ; set in LoadGameInfo
sectionPointers ; array of pointers to start of each section sectionPointers ; array of pointers to start of each section
addrEOF addrEOF
@ -35,18 +35,20 @@ addrInfo
; ;
; in: gCurrentGame between 0 and (kNumberOfGames-1) ; in: gCurrentGame between 0 and (kNumberOfGames-1)
; out: addrInfo, addrDescription, addrVersions, addrOptions populated ; 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 ; all registers and flags clobbered
; $00..$05 clobbered
; $0800..$1FFF clobbered
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
LoadGameInfo LoadGameInfo
jsr ResetPath jsr ResetPath
lda #<kTextRootDirectory lda #<kTextRootDirectory
ldy #>kTextRootDirectory ldy #>kTextRootDirectory
jsr AddToPath jsr AddToPath
lda gCurrentGame jsr okvs_get
asl !word gGlobalPrefsStore
tax !word kLastPlayed
lda GAMES,x
ldy GAMES+1,x
jsr AddToPath jsr AddToPath
jsr LoadFile 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 { !zone {
gGlobalPrefsStore
!word 0
gCurrentGame gCurrentGame
!byte 0 !byte 0
@ -70,30 +73,18 @@ LoadGlobalPreferences
lda SRC+1 lda SRC+1
sta gVersionsStore+1 sta gVersionsStore+1
jsr okvs_get ; set gCurrentGame jsr okvs_get ; get shortname of current game
!word gGlobalPrefsStore !word gGlobalPrefsStore
!word kLastPlayed !word kLastPlayed
sta DEST sta .gameNamePtr
sty DEST+1 sty .gameNamePtr+1
ldx #$FE
.findLastPlayed jsr okvs_get ; look up game in games list to get numeric index
inx !word gGamesListStore
inx .gameNamePtr
lda GAMES,x !word $FDFD ; SMC
sta SRC stx gCurrentGame
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
rts rts
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -149,7 +140,7 @@ SaveGlobalPreferences
sta .gameKey sta .gameKey
sty .gameKey+1 sty .gameKey+1
jsr addStringFromStore jsr addStringFromStore
.gameKey !word $FDFD ; set at runtime .gameKey !word $FDFD ; SMC
plx plx
inx inx
cpx #kNumberOfGames cpx #kNumberOfGames
@ -172,7 +163,7 @@ SaveGlobalPreferences
!word 0 ; auxtype=0000 !word 0 ; auxtype=0000
!word $2000 !word $2000
.prefslen .prefslen
!word $FDFD ; set at runtime !word $FDFD ; SMC
!word kProDOSFileBuffer !word kProDOSFileBuffer
stz gNeedToSavePrefs stz gNeedToSavePrefs
@ -201,9 +192,9 @@ addStringFromStore
jsr okvs_get jsr okvs_get
!word gGlobalPrefsStore !word gGlobalPrefsStore
.storeKey .storeKey
!word $FDFD ; set at runtime !word $FDFD ; SMC
.skipOverBooleanLogic .skipOverBooleanLogic
bra + ; set at runtime (opcode may become BIT) bra + ; SMC (opcode may become BIT)
sta PTR sta PTR
sty PTR+1 sty PTR+1
ldy #1 ldy #1
@ -231,7 +222,7 @@ addString
bne + bne +
inc $FF inc $FF
.len=*+1 .len=*+1
+ cpy #$FD ; set at runtime + cpy #$FD ; SMC
bne - bne -
rts rts

View File

@ -46,7 +46,7 @@ AddToPath
sta gPathname+1,x sta gPathname+1,x
inx inx
iny iny
.a cpy #$FD ; set at runtime .a cpy #$FD ; SMC
bcc - bcc -
stx gPathname stx gPathname
rts rts

View File

@ -20,6 +20,7 @@
!source "src/sound.a" !source "src/sound.a"
!source "src/launch.a" !source "src/launch.a"
!source "src/parse.common.a" !source "src/parse.common.a"
!source "src/parse.gamelist.a"
!source "src/parse.gameinfo.a" !source "src/parse.gameinfo.a"
!source "src/parse.prefs.a" !source "src/parse.prefs.a"
!source "src/ui.common.a" !source "src/ui.common.a"
@ -27,10 +28,6 @@
!source "src/ui.main.keys.a" !source "src/ui.main.keys.a"
!source "src/ui.options.a" !source "src/ui.options.a"
.weeguiFilename
!byte 10
!raw "LIB/WEEGUI"
Start Start
lda MACHID lda MACHID
and #$30 and #$30
@ -49,8 +46,9 @@ Start
jsr DisconnectRAM32 ; disconnect /RAM in S3,D2 jsr DisconnectRAM32 ; disconnect /RAM in S3,D2
jsr ClearInterpreterOptions ; clear options struct at $300 jsr ClearInterpreterOptions ; clear options struct at $300
jsr WGInit ; initialize WeeGUI jsr WGInit ; initialize WeeGUI
jsr LoadGlobalPreferences ; get current game jsr LoadGameList ; get master list of games
jsr LoadGameInfo ; load and parse game description text jsr LoadGlobalPreferences ; get current game and global options
jsr LoadGameInfo ; get current game description and game-specific options
ldx #WGEnableMouse ; enable mouse support ldx #WGEnableMouse ; enable mouse support
jsr WeeGUI jsr WeeGUI
MainScreen MainScreen
@ -78,5 +76,9 @@ ExitWeeGUI
ldx #WGExit ; clean up WeeGUI ldx #WGExit ; clean up WeeGUI
jmp WeeGUI jmp WeeGUI
gGlobalPrefsStore .weeguiFilename
!word *+2 ; address of storage space for prefs !byte 10
!raw "LIB/WEEGUI"
gGamesListStore
!word *+2 ; address first okvs store

View File

@ -47,7 +47,7 @@ CreateButton
lda ($00),y lda ($00),y
sta PARAM1 sta PARAM1
.type=*+1 .type=*+1
ldx #$FD ; set at runtime ldx #$FD ; SMC
jsr WeeGUI jsr WeeGUI
ldx #WGViewSetRawTitle ldx #WGViewSetRawTitle
lda #1 lda #1

View File

@ -165,21 +165,22 @@ paintInfoView
bpl - bpl -
lda #$00 lda #$00
sta $3F65 sta $3F65
lda gCurrentGame
asl jsr okvs_get ; get shortname of current game
tax
lda GAMES,x
sta .key1
lda GAMES+1,x
sta .key1+1
jsr okvs_get
!word gGlobalPrefsStore !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 sta .key2
sty .key2+1 sty .key2+1
jsr okvs_get
jsr okvs_get ; get long description of this version
!word gVersionsStore !word gVersionsStore
.key2 !word $FDFD ; set at runtime .key2 !word $FDFD ; SMC
sta SRC sta SRC
sty SRC+1 sty SRC+1
lda (SRC) lda (SRC)
@ -203,9 +204,9 @@ multiPrint
lda ($00) lda ($00)
beq .printDone beq .printDone
ldx #WGSetCursor ldx #WGSetCursor
.htab lda #$FD ; set at runtime .htab lda #$FD ; SMC
sta PARAM0 sta PARAM0
.vtab lda #$FD ; set at runtime .vtab lda #$FD ; SMC
sta PARAM1 sta PARAM1
jsr WeeGUI jsr WeeGUI
ldx #WGPrint ldx #WGPrint
@ -218,7 +219,7 @@ multiPrint
lda $00 lda $00
clc clc
.printLineLength .printLineLength
adc #$fd ; set at runtime adc #$fd ; SMC
sta $00 sta $00
bcc + bcc +
inc $01 inc $01

View File

@ -193,7 +193,7 @@ callback_next
jsr okvs_update jsr okvs_update
!word gGlobalPrefsStore !word gGlobalPrefsStore
!word kLastPlayed !word kLastPlayed
.gameptr !word $FDFD ; set at runtime .gameptr !word $FDFD ; SMC
.loadNewGameInfoAndRepaint .loadNewGameInfoAndRepaint
lda #1 lda #1
sta gNeedToSavePrefs sta gNeedToSavePrefs

View File

@ -222,7 +222,7 @@ SetCheckboxByPref
jsr okvs_get jsr okvs_get
!word gGlobalPrefsStore !word gGlobalPrefsStore
.key !word $FDFD ; set at runtime .key !word $FDFD ; SMC
bcs .exit bcs .exit
jsr okvs_as_boolean jsr okvs_as_boolean
@ -230,7 +230,7 @@ SetCheckboxByPref
ldx #WGSelectView ldx #WGSelectView
.id=*+1 .id=*+1
lda #$FD ; set at runtime lda #$FD ; SMC
jsr WeeGUI jsr WeeGUI
ldx #WGSetState ldx #WGSetState
lda #1 lda #1
@ -255,7 +255,7 @@ SetPrefByCheckbox
ldx #WGSelectView ldx #WGSelectView
.id=*+1 .id=*+1
lda #$FD ; set at runtime lda #$FD ; SMC
jsr WeeGUI jsr WeeGUI
ldx #WGGetState ldx #WGGetState
jsr WeeGUI jsr WeeGUI
@ -266,11 +266,11 @@ SetPrefByCheckbox
jsr okvs_update jsr okvs_update
!word gGlobalPrefsStore !word gGlobalPrefsStore
.key !word $FDFD ; set at runtime .key !word $FDFD ; SMC
!word .value !word .value
rts rts
.value !byte 1 .value !byte 1
!byte $FD ; set at runtime !byte $FD ; SMC
} }
.viewFrame .viewFrame