From e555e5b901076cae2a6ae34a9998c9a70c9de7d2 Mon Sep 17 00:00:00 2001 From: 4am Date: Tue, 27 Mar 2018 22:40:09 -0400 Subject: [PATCH] parse versions list and print current one in main screen --- src/launch.a | 10 ++--- src/okvs.a | 1 + src/parse.common.a | 11 +++++ src/{gameinfo.a => parse.gameinfo.a} | 60 +++++++++++++++++++++++++--- src/{prefs.a => parse.prefs.a} | 39 +++++++++--------- src/pitchdark.a | 7 ++-- src/ui.main.a | 39 +++++++++++++++++- src/ui.main.keys.a | 6 +-- src/ui.options.a | 4 +- 9 files changed, 138 insertions(+), 39 deletions(-) create mode 100644 src/parse.common.a rename src/{gameinfo.a => parse.gameinfo.a} (65%) rename src/{prefs.a => parse.prefs.a} (93%) diff --git a/src/launch.a b/src/launch.a index 9a15819..4adb127 100644 --- a/src/launch.a +++ b/src/launch.a @@ -21,7 +21,7 @@ ClearInterpreterOptions SetInterpreterOptions jsr okvs_get - !word gPrefsStore + !word gGlobalPrefsStore !word kForce40 jsr okvs_as_boolean beq + @@ -32,7 +32,7 @@ SetInterpreterOptionsExceptForce40 lda #$D9 sta $0300 ; 40/80 columns jsr okvs_get - !word gPrefsStore + !word gGlobalPrefsStore !word kForceUpper jsr okvs_as_boolean beq + @@ -45,7 +45,7 @@ SetInterpreterOptionsExceptForce40 sta $0302 ; auto-restore jsr okvs_get - !word gPrefsStore + !word gGlobalPrefsStore !word kScriptToFile jsr okvs_as_boolean beq + @@ -55,7 +55,7 @@ SetInterpreterOptionsExceptForce40 sta $0303 ; script-to-file jsr okvs_get - !word gPrefsStore + !word gGlobalPrefsStore !word kAutoScript jsr okvs_as_boolean beq + @@ -91,7 +91,7 @@ LaunchInterpreter jsr AddToPath jsr okvs_get - !word gPrefsStore + !word gGlobalPrefsStore !word kLastPlayed jsr AddToPath diff --git a/src/okvs.a b/src/okvs.a index 6dbd55f..72054c8 100644 --- a/src/okvs.a +++ b/src/okvs.a @@ -107,6 +107,7 @@ okvs_len ; out: all registers clobbered ; $00/$01 clobbered ; $02/$03 clobbered +; $04/$05 has the address of the next available byte after the new record ;------------------------------------------------------------------------------ okvs_append +PARAMS_ON_STACK 7 diff --git a/src/parse.common.a b/src/parse.common.a new file mode 100644 index 0000000..702d2cc --- /dev/null +++ b/src/parse.common.a @@ -0,0 +1,11 @@ +gKeyLen = $3F00 +gKey = $3F01 +gValLen = $3F10 +gVal = $3F11 + +IncAndGetChar + iny + bne + + inc $FF ++ lda ($FE),y + rts diff --git a/src/gameinfo.a b/src/parse.gameinfo.a similarity index 65% rename from src/gameinfo.a rename to src/parse.gameinfo.a index 5806fc2..312c7ef 100644 --- a/src/gameinfo.a +++ b/src/parse.gameinfo.a @@ -12,6 +12,9 @@ kTextRootDirectory !byte 5 !raw "TEXT/" +gVersionsStore + !word $FDFD ; set at runtime in LoadGlobalPreferences + sectionPointers ; array of pointers to start of each section addrEOF !word 0 @@ -100,10 +103,57 @@ LoadGameInfo dex bpl .convertSectionNoInc -IncAndGetChar - iny - bne + - inc $FF -+ lda ($FE),y + jmp LoadVersions + ;jmp LoadGamePreferences +} + +!zone { +LoadVersions + jsr okvs_init + !word gVersionsStore + + lda addrVersions+1 + sta $FF + lda addrVersions + sec + sbc #$01 + sta $FE + bcs + + dec $FF ++ ldy #$00 ; index into ($FE) pointing to current character +.newKey ldx #$00 ; X = index into current key +.gatherKey + stx gKeyLen + jsr IncAndGetChar + and #$7F + cmp #$3D ; '=' ends the key + beq .endKey + cmp #$5B ; '[' ends the parsing + beq .doneParsing + sta gKey,x + inx + bra .gatherKey +.endKey stx gKeyLen + ldx #$00 ; X = index into the current value +.gatherValue + stx gValLen + jsr IncAndGetChar + cmp #$00 ; null ends the value + beq .endValue + and #$7F + sta gVal,x + inx + bra .gatherValue +.endValue + stx gValLen + phy ; okvs functions clobber everything but we need Y + jsr okvs_append + !word gVersionsStore + !word gKeyLen + !word gValLen + !byte 0 + ply + bra .newKey +.doneParsing rts } diff --git a/src/prefs.a b/src/parse.prefs.a similarity index 93% rename from src/prefs.a rename to src/parse.prefs.a index a05eb2a..bc33882 100644 --- a/src/prefs.a +++ b/src/parse.prefs.a @@ -54,7 +54,7 @@ LoadGlobalPreferences stz gNeedToSavePrefs jsr okvs_init - !word gPrefsStore + !word gGlobalPrefsStore jsr LoadFile ; load prefs file at $2000 !word .globalPrefsFilename @@ -69,7 +69,7 @@ LoadGlobalPreferences ldy #$00 ; index into ($FE) pointing to current character .newKey ldx #$00 ; X = index into current key .gatherKey - stx .keylen + stx gKeyLen jsr IncAndGetChar cmp #$23 ; '#' is starts a comment (until CR) beq .skipComment @@ -77,38 +77,38 @@ LoadGlobalPreferences beq .endKey cmp #$0D ; found CR before '=', ignore key and start over beq .newKey - sta .key,x + sta gKey,x inx bra .gatherKey -.endKey stx .keylen +.endKey stx gKeyLen txa ; to set Z flag beq .doneParsing ; empty key ends the parsing ldx #$00 ; X = index into the current value .gatherValue - stx .vallen + stx gValLen jsr IncAndGetChar cmp #$0D ; CR ends the value beq .endValue - sta .val,x + sta gVal,x inx bra .gatherValue .endValue - stx .vallen - lda .vallen + stx gValLen + lda gValLen cmp #1 bne .use16 - lda .val + lda gVal and #1 - sta .val ; single-character values get converted to #$00 or #$01 in prefs store + sta gVal ; single-character values get converted to #$00 or #$01 in prefs store lda #0 !byte $2C .use16 lda #16 sta .okvslen ; all other values get upgraded to 16 bytes so we can update them in place phy ; okvs functions clobber everything but we need Y jsr okvs_append - !word gPrefsStore - !word .keylen - !word .vallen + !word gGlobalPrefsStore + !word gKeyLen + !word gValLen .okvslen !byte $FD ; set at runtime ply bra .newKey @@ -120,8 +120,12 @@ LoadGlobalPreferences bra .newKey .doneParsing + lda SRC + sta gVersionsStore + lda SRC+1 + sta gVersionsStore+1 jsr okvs_get - !word gPrefsStore + !word gGlobalPrefsStore !word kLastPlayed sta DEST sty DEST+1 @@ -146,11 +150,6 @@ LoadGlobalPreferences sta gCurrentGame rts -.keylen !byte 0 -.key !fill 15 -.vallen !byte 0 -.val !fill 15 - ;------------------------------------------------------------------------------ ; SaveGlobalPreferences ; @@ -254,7 +253,7 @@ addStringFromStore ldy #>.equals jsr addString jsr okvs_get - !word gPrefsStore + !word gGlobalPrefsStore .storeKey !word $FDFD ; set at runtime .skipOverBooleanLogic diff --git a/src/pitchdark.a b/src/pitchdark.a index 99416e2..8e49574 100644 --- a/src/pitchdark.a +++ b/src/pitchdark.a @@ -17,10 +17,11 @@ !source "src/prodos.a" !source "src/ramdisk.a" !source "src/path.a" - !source "src/gameinfo.a" - !source "src/prefs.a" !source "src/sound.a" !source "src/launch.a" + !source "src/parse.common.a" + !source "src/parse.gameinfo.a" + !source "src/parse.prefs.a" !source "src/ui.common.a" !source "src/ui.main.a" !source "src/ui.main.keys.a" @@ -77,5 +78,5 @@ ExitWeeGUI ldx #WGExit ; clean up WeeGUI jmp WeeGUI -gPrefsStore +gGlobalPrefsStore !word *+2 ; address of storage space for prefs diff --git a/src/ui.main.a b/src/ui.main.a index 47fec9d..b0febdd 100644 --- a/src/ui.main.a +++ b/src/ui.main.a @@ -156,7 +156,44 @@ paintInfoView lda addrInfo ldy addrInfo+1 ldx #65 - ; execution falls through here + phx + jsr multiPrint + plx + lda #$A0 +- sta $3F00,x + dex + bpl - + lda #$00 + sta $3F65 + lda gCurrentGame + asl + tax + lda GAMES,x + sta .key1 + lda GAMES+1,x + sta .key1+1 + jsr okvs_get + !word gGlobalPrefsStore +.key1 !word $FDFD ; set at runtime + sta .key2 + sty .key2+1 + jsr okvs_get + !word gVersionsStore +.key2 !word $FDFD ; set at runtime + sta SRC + sty SRC+1 + lda (SRC) + tay +- lda (SRC),y + ora #$80 + sta $3F00,y + dey + bne - + stz $00 + lda #$3F + sta $01 + jmp .printLoop + multiPrint sta $00 sty $01 diff --git a/src/ui.main.keys.a b/src/ui.main.keys.a index 26adb12..6fb7d7a 100644 --- a/src/ui.main.keys.a +++ b/src/ui.main.keys.a @@ -191,7 +191,7 @@ callback_next lda GAMES+1,x sta .gameptr+1 jsr okvs_update - !word gPrefsStore + !word gGlobalPrefsStore !word kLastPlayed .gameptr !word $FDFD ; set at runtime .loadNewGameInfoAndRepaint @@ -214,7 +214,7 @@ callback_boxart ldy #>kArtworkRootDirectory jsr AddToPath jsr okvs_get - !word gPrefsStore + !word gGlobalPrefsStore !word kLastPlayed jsr AddToPath @@ -268,7 +268,7 @@ callback_clues ; put just the filename at $2006 jsr okvs_get - !word gPrefsStore + !word gGlobalPrefsStore !word kLastPlayed jsr SetStartupPath ; shutdown WeeGUI and transfer control to interpreter diff --git a/src/ui.options.a b/src/ui.options.a index 935a833..5a23461 100644 --- a/src/ui.options.a +++ b/src/ui.options.a @@ -221,7 +221,7 @@ SetCheckboxByPref sta .key+1 jsr okvs_get - !word gPrefsStore + !word gGlobalPrefsStore .key !word $FDFD ; set at runtime bcs .exit @@ -265,7 +265,7 @@ SetPrefByCheckbox sta .value+1 jsr okvs_update - !word gPrefsStore + !word gGlobalPrefsStore .key !word $FDFD ; set at runtime !word .value rts