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 SetInterpreterOptions
jsr okvs_get jsr okvs_get
!word gPrefsStore !word gGlobalPrefsStore
!word kForce40 !word kForce40
jsr okvs_as_boolean jsr okvs_as_boolean
beq + beq +
@@ -32,7 +32,7 @@ SetInterpreterOptionsExceptForce40
lda #$D9 lda #$D9
sta $0300 ; 40/80 columns sta $0300 ; 40/80 columns
jsr okvs_get jsr okvs_get
!word gPrefsStore !word gGlobalPrefsStore
!word kForceUpper !word kForceUpper
jsr okvs_as_boolean jsr okvs_as_boolean
beq + beq +
@@ -45,7 +45,7 @@ SetInterpreterOptionsExceptForce40
sta $0302 ; auto-restore sta $0302 ; auto-restore
jsr okvs_get jsr okvs_get
!word gPrefsStore !word gGlobalPrefsStore
!word kScriptToFile !word kScriptToFile
jsr okvs_as_boolean jsr okvs_as_boolean
beq + beq +
@@ -55,7 +55,7 @@ SetInterpreterOptionsExceptForce40
sta $0303 ; script-to-file sta $0303 ; script-to-file
jsr okvs_get jsr okvs_get
!word gPrefsStore !word gGlobalPrefsStore
!word kAutoScript !word kAutoScript
jsr okvs_as_boolean jsr okvs_as_boolean
beq + beq +
@@ -91,7 +91,7 @@ LaunchInterpreter
jsr AddToPath jsr AddToPath
jsr okvs_get jsr okvs_get
!word gPrefsStore !word gGlobalPrefsStore
!word kLastPlayed !word kLastPlayed
jsr AddToPath jsr AddToPath

View File

@@ -107,6 +107,7 @@ okvs_len
; out: all registers clobbered ; out: all registers clobbered
; $00/$01 clobbered ; $00/$01 clobbered
; $02/$03 clobbered ; $02/$03 clobbered
; $04/$05 has the address of the next available byte after the new record
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
okvs_append okvs_append
+PARAMS_ON_STACK 7 +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 !byte 5
!raw "TEXT/" !raw "TEXT/"
gVersionsStore
!word $FDFD ; set at runtime in LoadGlobalPreferences
sectionPointers ; array of pointers to start of each section sectionPointers ; array of pointers to start of each section
addrEOF addrEOF
!word 0 !word 0
@@ -100,10 +103,57 @@ LoadGameInfo
dex dex
bpl .convertSectionNoInc bpl .convertSectionNoInc
IncAndGetChar jmp LoadVersions
iny ;jmp LoadGamePreferences
bne + }
inc $FF
+ lda ($FE),y !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 rts
} }

View File

@@ -54,7 +54,7 @@ LoadGlobalPreferences
stz gNeedToSavePrefs stz gNeedToSavePrefs
jsr okvs_init jsr okvs_init
!word gPrefsStore !word gGlobalPrefsStore
jsr LoadFile ; load prefs file at $2000 jsr LoadFile ; load prefs file at $2000
!word .globalPrefsFilename !word .globalPrefsFilename
@@ -69,7 +69,7 @@ LoadGlobalPreferences
ldy #$00 ; index into ($FE) pointing to current character ldy #$00 ; index into ($FE) pointing to current character
.newKey ldx #$00 ; X = index into current key .newKey ldx #$00 ; X = index into current key
.gatherKey .gatherKey
stx .keylen stx gKeyLen
jsr IncAndGetChar jsr IncAndGetChar
cmp #$23 ; '#' is starts a comment (until CR) cmp #$23 ; '#' is starts a comment (until CR)
beq .skipComment beq .skipComment
@@ -77,38 +77,38 @@ LoadGlobalPreferences
beq .endKey beq .endKey
cmp #$0D ; found CR before '=', ignore key and start over cmp #$0D ; found CR before '=', ignore key and start over
beq .newKey beq .newKey
sta .key,x sta gKey,x
inx inx
bra .gatherKey bra .gatherKey
.endKey stx .keylen .endKey stx gKeyLen
txa ; to set Z flag txa ; to set Z flag
beq .doneParsing ; empty key ends the parsing beq .doneParsing ; empty key ends the parsing
ldx #$00 ; X = index into the current value ldx #$00 ; X = index into the current value
.gatherValue .gatherValue
stx .vallen stx gValLen
jsr IncAndGetChar jsr IncAndGetChar
cmp #$0D ; CR ends the value cmp #$0D ; CR ends the value
beq .endValue beq .endValue
sta .val,x sta gVal,x
inx inx
bra .gatherValue bra .gatherValue
.endValue .endValue
stx .vallen stx gValLen
lda .vallen lda gValLen
cmp #1 cmp #1
bne .use16 bne .use16
lda .val lda gVal
and #1 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 lda #0
!byte $2C !byte $2C
.use16 lda #16 .use16 lda #16
sta .okvslen ; all other values get upgraded to 16 bytes so we can update them in place 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 phy ; okvs functions clobber everything but we need Y
jsr okvs_append jsr okvs_append
!word gPrefsStore !word gGlobalPrefsStore
!word .keylen !word gKeyLen
!word .vallen !word gValLen
.okvslen !byte $FD ; set at runtime .okvslen !byte $FD ; set at runtime
ply ply
bra .newKey bra .newKey
@@ -120,8 +120,12 @@ LoadGlobalPreferences
bra .newKey bra .newKey
.doneParsing .doneParsing
lda SRC
sta gVersionsStore
lda SRC+1
sta gVersionsStore+1
jsr okvs_get jsr okvs_get
!word gPrefsStore !word gGlobalPrefsStore
!word kLastPlayed !word kLastPlayed
sta DEST sta DEST
sty DEST+1 sty DEST+1
@@ -146,11 +150,6 @@ LoadGlobalPreferences
sta gCurrentGame sta gCurrentGame
rts rts
.keylen !byte 0
.key !fill 15
.vallen !byte 0
.val !fill 15
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; SaveGlobalPreferences ; SaveGlobalPreferences
; ;
@@ -254,7 +253,7 @@ addStringFromStore
ldy #>.equals ldy #>.equals
jsr addString jsr addString
jsr okvs_get jsr okvs_get
!word gPrefsStore !word gGlobalPrefsStore
.storeKey .storeKey
!word $FDFD ; set at runtime !word $FDFD ; set at runtime
.skipOverBooleanLogic .skipOverBooleanLogic

View File

@@ -17,10 +17,11 @@
!source "src/prodos.a" !source "src/prodos.a"
!source "src/ramdisk.a" !source "src/ramdisk.a"
!source "src/path.a" !source "src/path.a"
!source "src/gameinfo.a"
!source "src/prefs.a"
!source "src/sound.a" !source "src/sound.a"
!source "src/launch.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.common.a"
!source "src/ui.main.a" !source "src/ui.main.a"
!source "src/ui.main.keys.a" !source "src/ui.main.keys.a"
@@ -77,5 +78,5 @@ ExitWeeGUI
ldx #WGExit ; clean up WeeGUI ldx #WGExit ; clean up WeeGUI
jmp WeeGUI jmp WeeGUI
gPrefsStore gGlobalPrefsStore
!word *+2 ; address of storage space for prefs !word *+2 ; address of storage space for prefs

View File

@@ -156,7 +156,44 @@ paintInfoView
lda addrInfo lda addrInfo
ldy addrInfo+1 ldy addrInfo+1
ldx #65 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 multiPrint
sta $00 sta $00
sty $01 sty $01

View File

@@ -191,7 +191,7 @@ callback_next
lda GAMES+1,x lda GAMES+1,x
sta .gameptr+1 sta .gameptr+1
jsr okvs_update jsr okvs_update
!word gPrefsStore !word gGlobalPrefsStore
!word kLastPlayed !word kLastPlayed
.gameptr !word $FDFD ; set at runtime .gameptr !word $FDFD ; set at runtime
.loadNewGameInfoAndRepaint .loadNewGameInfoAndRepaint
@@ -214,7 +214,7 @@ callback_boxart
ldy #>kArtworkRootDirectory ldy #>kArtworkRootDirectory
jsr AddToPath jsr AddToPath
jsr okvs_get jsr okvs_get
!word gPrefsStore !word gGlobalPrefsStore
!word kLastPlayed !word kLastPlayed
jsr AddToPath jsr AddToPath
@@ -268,7 +268,7 @@ callback_clues
; put just the filename at $2006 ; put just the filename at $2006
jsr okvs_get jsr okvs_get
!word gPrefsStore !word gGlobalPrefsStore
!word kLastPlayed !word kLastPlayed
jsr SetStartupPath jsr SetStartupPath
; shutdown WeeGUI and transfer control to interpreter ; shutdown WeeGUI and transfer control to interpreter

View File

@@ -221,7 +221,7 @@ SetCheckboxByPref
sta .key+1 sta .key+1
jsr okvs_get jsr okvs_get
!word gPrefsStore !word gGlobalPrefsStore
.key !word $FDFD ; set at runtime .key !word $FDFD ; set at runtime
bcs .exit bcs .exit
@@ -265,7 +265,7 @@ SetPrefByCheckbox
sta .value+1 sta .value+1
jsr okvs_update jsr okvs_update
!word gPrefsStore !word gGlobalPrefsStore
.key !word $FDFD ; set at runtime .key !word $FDFD ; set at runtime
!word .value !word .value
rts rts