new settings dialog

This commit is contained in:
4am 2018-03-26 14:57:06 -04:00
parent a9cc254a74
commit 0af8117251
5 changed files with 172 additions and 105 deletions

Binary file not shown.

View File

@ -9,6 +9,7 @@
; - okvs_append(address, key, value, max_len) ; - okvs_append(address, key, value, max_len)
; - okvs_update(address, key, value) ; - okvs_update(address, key, value)
; - okvs_get(address, key) ; - okvs_get(address, key)
; - okvs_as_boolean(value)
; - [TODO] okvs_iter(address, callback) ; - [TODO] okvs_iter(address, callback)
; ;
; Used for global preferences, per-game options, and per-game version lists ; Used for global preferences, per-game options, and per-game version lists
@ -245,6 +246,9 @@ okvs_get
ldy PTR+1 ldy PTR+1
clc clc
adc .matchlen adc .matchlen
bcc +
iny
+ clc
adc #2 adc #2
sta PTR sta PTR
bcc + bcc +
@ -304,6 +308,28 @@ okvs_update
clc clc
.exit rts .exit rts
;------------------------------------------------------------------------------
; okvs_as_boolean
;
; in: A = address of value [lo]
; Y = address of value [hi]
; out: Z clear if value is a 1-byte string with value #$00 or the digit '0'
; Z set otherwise
; X preserved, A/Y clobbered
;------------------------------------------------------------------------------
okvs_as_boolean
sta PTR
sty PTR+1
lda (PTR)
cmp #1
bne +
ldy #1
lda (PTR),y
beq +
ora #$80
cmp #$B0
+ rts
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; internal functions ; internal functions

View File

@ -28,26 +28,17 @@ CreateCheckbox
!byte $2C ; hide next 2 bytes !byte $2C ; hide next 2 bytes
CreateButton CreateButton
ldx #WGCreateButton ldx #WGCreateButton
stx .type+1 stx .type
pla
sta $00 +PARAMS_ON_STACK 2
pla
sta $01
tax
lda #$02
clc
adc $00
bcc +
inx
+ phx
pha
ldy #$01 ldy #$01
lda ($00),y lda ($00),y
sta PARAM0 sta PARAM0
iny iny
lda ($00),y lda ($00),y
sta PARAM1 sta PARAM1
.type .type=*+1
ldx #$FD ; set at runtime ldx #$FD ; set at runtime
jsr WeeGUI jsr WeeGUI
ldx #WGViewSetRawTitle ldx #WGViewSetRawTitle

View File

@ -10,14 +10,12 @@
; View IDs (application-specific, acceptable range 0..15, no duplicates) ; View IDs (application-specific, acceptable range 0..15, no duplicates)
; ID_TITLE is defined in paintcommon.a ; ID_TITLE is defined in paintcommon.a
ID_OPTIONS_FRAME = 1 ID_OPTIONS_FRAME = 1
ID_OPTIONS_NAME = 2 ID_OPTIONS_FORCE40 = 2
ID_OPTIONS_YEAR = 3 ID_OPTIONS_FORCEUPPER = 3
ID_OPTIONS_GENRE = 4 ID_OPTIONS_SCRIPTTOFILE = 4
ID_OPTIONS_DIFFICULTY = 5 ID_OPTIONS_AUTOSCRIPT = 5
ID_OPTIONS_FORCE40 = 6 ID_OPTIONS_OK = 6
ID_OPTIONS_FORCEUPPER = 7 ID_OPTIONS_CANCEL = 7
ID_OPTIONS_OK = 8
ID_OPTIONS_CANCEL = 9
!zone { !zone {
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -53,21 +51,67 @@ OptionsDialog
!word .viewOK !word .viewOK
jsr CreateButton jsr CreateButton
!word .viewCancel !word .viewCancel
jsr CreateRadio
!word .viewName
ldx #WGSetState ; TODO: set the appropriate radio button based on preferences
lda #1
jsr WeeGUI
jsr CreateRadio
!word .viewYear
jsr CreateRadio
!word .viewGenre
jsr CreateRadio
!word .viewDifficulty
jsr CreateCheckbox jsr CreateCheckbox
!word .viewForce40 !word .viewForce40
jsr CreateCheckbox jsr CreateCheckbox
!word .viewForceUpper !word .viewForceUpper
jsr CreateCheckbox
!word .viewScriptToFile
jsr CreateCheckbox
!word .viewAutoScript
; set initial state of checkboxes based on preferences
jsr okvs_get
!word gPrefsStore
!word kForce40
jsr okvs_as_boolean
beq +
ldx #WGSelectView
lda #ID_OPTIONS_FORCE40
jsr WeeGUI
ldx #WGSetState
lda #1
sta PARAM0
jsr WeeGUI
+
jsr okvs_get
!word gPrefsStore
!word kForceUpper
jsr okvs_as_boolean
beq +
ldx #WGSelectView
lda #ID_OPTIONS_FORCEUPPER
jsr WeeGUI
ldx #WGSetState
lda #1
sta PARAM0
jsr WeeGUI
+
jsr okvs_get
!word gPrefsStore
!word kScriptToFile
jsr okvs_as_boolean
beq +
ldx #WGSelectView
lda #ID_OPTIONS_SCRIPTTOFILE
jsr WeeGUI
ldx #WGSetState
lda #1
sta PARAM0
jsr WeeGUI
+
jsr okvs_get
!word gPrefsStore
!word kAutoScript
jsr okvs_as_boolean
beq +
ldx #WGSelectView
lda #ID_OPTIONS_AUTOSCRIPT
jsr WeeGUI
ldx #WGSetState
lda #1
sta PARAM0
jsr WeeGUI
+
ldx #WGDesktop ; paint background ldx #WGDesktop ; paint background
jsr WeeGUI jsr WeeGUI
@ -82,28 +126,54 @@ OptionsDialog
jsr WeeGUI jsr WeeGUI
ldx #WGSetCursor ; paint static text labels ldx #WGSetCursor ; paint static text labels
lda #2 lda #4
sta PARAM0 sta PARAM0
lda #1 lda #3
sta PARAM1 sta PARAM1
jsr WeeGUI jsr WeeGUI
ldx #WGPrint ldx #WGPrint
lda #<.stringSortBy lda #<.stringForce40Description
sta PARAM0 sta PARAM0
lda #>.stringSortBy lda #>.stringForce40Description
sta PARAM1 sta PARAM1
jsr WeeGUI jsr WeeGUI
ldx #WGSetCursor ldx #WGSetCursor
lda #2 lda #4
sta PARAM0 sta PARAM0
lda #12 lda #8
sta PARAM1 sta PARAM1
jsr WeeGUI jsr WeeGUI
ldx #WGPrint ldx #WGPrint
lda #<.stringGameplay lda #<.stringForceUpperDescription
sta PARAM0 sta PARAM0
lda #>.stringGameplay lda #>.stringForceUpperDescription
sta PARAM1
jsr WeeGUI
ldx #WGSetCursor
lda #4
sta PARAM0
lda #13
sta PARAM1
jsr WeeGUI
ldx #WGPrint
lda #<.stringScriptToFileDescription
sta PARAM0
lda #>.stringScriptToFileDescription
sta PARAM1
jsr WeeGUI
ldx #WGSetCursor
lda #4
sta PARAM0
lda #18
sta PARAM1
jsr WeeGUI
ldx #WGPrint
lda #<.stringAutoScriptDescription
sta PARAM0
lda #>.stringAutoScriptDescription
sta PARAM1 sta PARAM1
jsr WeeGUI jsr WeeGUI
@ -124,17 +194,13 @@ OptionsDialog
!byte $C3,ID_OPTIONS_CANCEL ; C !byte $C3,ID_OPTIONS_CANCEL ; C
!byte $E3,ID_OPTIONS_CANCEL ; c !byte $E3,ID_OPTIONS_CANCEL ; c
!byte $9B,ID_OPTIONS_CANCEL ; Esc !byte $9B,ID_OPTIONS_CANCEL ; Esc
!byte $CE,ID_OPTIONS_NAME ; N
!byte $EE,ID_OPTIONS_NAME ; n
!byte $D9,ID_OPTIONS_YEAR ; Y
!byte $F9,ID_OPTIONS_YEAR ; y
!byte $C7,ID_OPTIONS_GENRE ; G
!byte $E7,ID_OPTIONS_GENRE ; g
!byte $C4,ID_OPTIONS_DIFFICULTY ; D
!byte $E4,ID_OPTIONS_DIFFICULTY ; d
!byte $B4,ID_OPTIONS_FORCE40 ; 4 !byte $B4,ID_OPTIONS_FORCE40 ; 4
!byte $D5,ID_OPTIONS_FORCEUPPER ; U !byte $D5,ID_OPTIONS_FORCEUPPER ; U
!byte $F5,ID_OPTIONS_FORCEUPPER ; u !byte $F5,ID_OPTIONS_FORCEUPPER ; u
!byte $C6,ID_OPTIONS_SCRIPTTOFILE ; F
!byte $E6,ID_OPTIONS_SCRIPTTOFILE ; f
!byte $D3,ID_OPTIONS_AUTOSCRIPT ; S
!byte $F3,ID_OPTIONS_AUTOSCRIPT ; s
.endkeys .endkeys
HandleOptionsKey HandleOptionsKey
@ -164,18 +230,18 @@ callback_options_cancel
.viewFrame .viewFrame
!byte ID_OPTIONS_FRAME ; view ID !byte ID_OPTIONS_FRAME ; view ID
!byte 2 ; style (decorated frame) !byte 2 ; style (decorated frame)
!byte 22 ; left !byte 12 ; left
!byte 3 ; top !byte 3 ; top
!byte 36 ; visible width !byte 56 ; visible width
!byte 18 ; visible height !byte 19 ; visible height
!byte 36 ; width !byte 56 ; width
!byte 18 ; height !byte 19 ; height
.stringFrame .stringFrame
!text "Settings",0 !text "Settings",0
.viewOK .viewOK
!byte ID_OPTIONS_OK ; view ID !byte ID_OPTIONS_OK ; view ID
!byte 46 ; left !byte 56 ; left
!byte 4 ; top !byte 4 ; top
!byte 10 ; width !byte 10 ; width
!word callback_options_ok ; callback !word callback_options_ok ; callback
@ -186,7 +252,7 @@ callback_options_cancel
.viewCancel .viewCancel
!byte ID_OPTIONS_CANCEL ; view ID !byte ID_OPTIONS_CANCEL ; view ID
!byte 46 ; left !byte 56 ; left
!byte 6 ; top !byte 6 ; top
!byte 10 ; width !byte 10 ; width
!word callback_options_cancel ; callback !word callback_options_cancel ; callback
@ -195,69 +261,51 @@ callback_options_cancel
!byte $03 ; 'C' inverse !byte $03 ; 'C' inverse
!text "ancel",0 !text "ancel",0
.viewName
!byte ID_OPTIONS_NAME ; view ID
!byte 26 ; left
!byte 6 ; top
!word .stringName
.stringName
!text " "
!byte $0E ; 'N' inverse
!text "ame",0
.viewYear
!byte ID_OPTIONS_YEAR ; view ID
!byte 26 ; left
!byte 8 ; top
!word .stringYear
.stringYear
!text " "
!byte $19 ; 'Y' inverse
!text "ear",0
.viewGenre
!byte ID_OPTIONS_GENRE ; view ID
!byte 26 ; left
!byte 10 ; top
!word .stringGenre
.stringGenre
!text " "
!byte $07 ; 'G' inverse
!text "enre",0
.viewDifficulty
!byte ID_OPTIONS_DIFFICULTY ; view ID
!byte 26 ; left
!byte 12 ; top
!word .stringDifficulty
.stringDifficulty
!text " "
!byte $04 ; 'D' inverse
!text "ifficulty",0
.viewForce40 .viewForce40
!byte ID_OPTIONS_FORCE40 ; view ID !byte ID_OPTIONS_FORCE40 ; view ID
!byte 26 ; left !byte 14 ; left
!byte 17 ; top !byte 4 ; top
!word .stringForce40 ; caption !word .stringForce40 ; caption
.stringForce40 .stringForce40
!text "Force " !text "Force "
!byte $34 ; '4' inverse !byte $34 ; '4' inverse
!text "0 column",0 !text "0 column",0
.stringForce40Description
!text "Some games may be glitchy",0
.viewForceUpper .viewForceUpper
!byte ID_OPTIONS_FORCEUPPER ; view ID !byte ID_OPTIONS_FORCEUPPER ; view ID
!byte 26 ; left !byte 14 ; left
!byte 19 ; top !byte 9 ; top
!word .stringForceUpper ; caption !word .stringForceUpper ; caption
.stringForceUpper .stringForceUpper
!text "Force " !text "Force "
!byte $75 ; 'u' inverse !byte $75 ; 'u' inverse
!text "ppercase",0 !text "ppercase",0
.stringForceUpperDescription
!text "A MATTER OF PREFERENCE",0
.stringSortBy .viewScriptToFile
!raw "Browse games by",0 !byte ID_OPTIONS_SCRIPTTOFILE ; view ID
!byte 14 ; left
!byte 14 ; top
!word .stringScriptToFile ; caption
.stringScriptToFile
!text "SCRIPT to "
!byte $66 ; 'f' inverse
!text "ile",0
.stringScriptToFileDescription
!text "Save transcripts to a file instead of printer",0
.stringGameplay .viewAutoScript
!raw "During gameplay:",0 !byte ID_OPTIONS_AUTOSCRIPT ; view ID
!byte 14 ; left
!byte 19 ; top
!word .stringAutoScript ; caption
.stringAutoScript
!text "Always "
!byte $13 ; 'S' inverse
!text "CRIPT",0
.stringAutoScriptDescription
!text "Turn on SCRIPT mode automatically",0
} }

View File

@ -13,8 +13,10 @@
; Public constants ; Public constants
; - kForce40 ; - kForce40
; - kForceUpper ; - kForceUpper
; - kSort ; - kScriptToFile
; - kAutoScript
; - kLastPlayed ; - kLastPlayed
;
!zone { !zone {
kDefaultGame = 30 ; Zork I kDefaultGame = 30 ; Zork I