parse versions list and print current one in main screen

This commit is contained in:
4am 2018-03-27 22:40:09 -04:00
parent 1da0f45d13
commit e555e5b901
9 changed files with 138 additions and 39 deletions

View File

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

View File

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

11
src/parse.common.a Normal file
View File

@ -0,0 +1,11 @@
gKeyLen = $3F00
gKey = $3F01
gValLen = $3F10
gVal = $3F11
IncAndGetChar
iny
bne +
inc $FF
+ lda ($FE),y
rts

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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