pitch-dark/src/paintoptions.a

312 lines
8.6 KiB
Plaintext
Raw Normal View History

2018-03-01 16:06:00 +00:00
;license:MIT
;(c) 2018 by 4am
;
; User interface - views and paint routines for options screen
;
; Public functions
; - OptionsDialog
;
; View IDs (application-specific, acceptable range 0..15, no duplicates)
; ID_TITLE is defined in paintcommon.a
ID_OPTIONS_FRAME = 1
2018-03-26 18:57:06 +00:00
ID_OPTIONS_FORCE40 = 2
ID_OPTIONS_FORCEUPPER = 3
ID_OPTIONS_SCRIPTTOFILE = 4
ID_OPTIONS_AUTOSCRIPT = 5
ID_OPTIONS_OK = 6
ID_OPTIONS_CANCEL = 7
2018-03-01 16:06:00 +00:00
!zone {
;------------------------------------------------------------------------------
; OptionsDialog
; call WeeGUI to create and paint all option screen views
;
; in: WeeGUI loaded and initialized
; out: all registers clobbered
; all flags clobbered
;------------------------------------------------------------------------------
OptionsDialog
ldx #$FF
txs
2018-03-03 16:41:09 +00:00
ldx #WGReset ; reset WeeGUI
jsr WeeGUI
2018-03-01 16:06:00 +00:00
jsr CreateTitleView ; create title bar (defined in paintcommon.a)
ldx #WGCreateView ; create frame
lda #<.viewFrame
sta PARAM0
lda #>.viewFrame
sta PARAM1
jsr WeeGUI
ldx #WGViewSetTitle
lda #<.stringFrame
sta PARAM0
lda #>.stringFrame
sta PARAM1
jsr WeeGUI
jsr CreateButton ; create UI controls
!word .viewOK
jsr CreateButton
!word .viewCancel
jsr CreateCheckbox
!word .viewForce40
jsr CreateCheckbox
!word .viewForceUpper
2018-03-26 18:57:06 +00:00
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
+
2018-03-01 16:06:00 +00:00
ldx #WGDesktop ; paint background
jsr WeeGUI
ldx #WGViewPaintAll ; paint UI controls (window frame, buttons, checkboxes, radio buttons)
jsr WeeGUI
jsr PaintTitleView ; paint top title bar
ldx #WGSelectView
lda #ID_OPTIONS_FRAME
jsr WeeGUI
ldx #WGSetCursor ; paint static text labels
2018-03-26 18:57:06 +00:00
lda #4
2018-03-01 16:06:00 +00:00
sta PARAM0
2018-03-26 18:57:06 +00:00
lda #3
2018-03-01 16:06:00 +00:00
sta PARAM1
jsr WeeGUI
ldx #WGPrint
2018-03-26 18:57:06 +00:00
lda #<.stringForce40Description
2018-03-01 16:06:00 +00:00
sta PARAM0
2018-03-26 18:57:06 +00:00
lda #>.stringForce40Description
2018-03-01 16:06:00 +00:00
sta PARAM1
jsr WeeGUI
ldx #WGSetCursor
2018-03-26 18:57:06 +00:00
lda #4
2018-03-01 16:06:00 +00:00
sta PARAM0
2018-03-26 18:57:06 +00:00
lda #8
2018-03-01 16:06:00 +00:00
sta PARAM1
jsr WeeGUI
ldx #WGPrint
2018-03-26 18:57:06 +00:00
lda #<.stringForceUpperDescription
2018-03-01 16:06:00 +00:00
sta PARAM0
2018-03-26 18:57:06 +00:00
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
2018-03-01 16:06:00 +00:00
sta PARAM1
jsr WeeGUI
.runLoop
ldx #WGPendingViewAction
jsr WeeGUI
lda $c000
bpl .runLoop
bit $c010
jsr HandleOptionsKey
bra .runLoop
; action keys for options screen
.keys
!byte $CF,ID_OPTIONS_OK ; O
!byte $EF,ID_OPTIONS_OK ; o
!byte $8D,ID_OPTIONS_OK ; Return
!byte $C3,ID_OPTIONS_CANCEL ; C
!byte $E3,ID_OPTIONS_CANCEL ; c
!byte $9B,ID_OPTIONS_CANCEL ; Esc
!byte $B4,ID_OPTIONS_FORCE40 ; 4
!byte $D5,ID_OPTIONS_FORCEUPPER ; U
!byte $F5,ID_OPTIONS_FORCEUPPER ; u
2018-03-26 18:57:06 +00:00
!byte $C6,ID_OPTIONS_SCRIPTTOFILE ; F
!byte $E6,ID_OPTIONS_SCRIPTTOFILE ; f
!byte $D3,ID_OPTIONS_AUTOSCRIPT ; S
!byte $F3,ID_OPTIONS_AUTOSCRIPT ; s
2018-03-01 16:06:00 +00:00
.endkeys
HandleOptionsKey
ldx #.endkeys-.keys
- cmp .keys,x
beq .foundKey
dex
dex
bpl -
2018-03-16 18:17:45 +00:00
jmp SoftBell
2018-03-01 16:06:00 +00:00
.foundKey
lda .keys+1,x
ldx #WGSelectView
jsr WeeGUI
ldx #WGViewFocus
jsr WeeGUI
ldx #WGViewFocusAction
jsr WeeGUI
ldx #WGViewUnfocus
jmp WeeGUI
callback_options_ok
; TODO set preferences
callback_options_cancel
jmp MainScreen
.viewFrame
!byte ID_OPTIONS_FRAME ; view ID
!byte 2 ; style (decorated frame)
2018-03-26 18:57:06 +00:00
!byte 12 ; left
2018-03-01 16:06:00 +00:00
!byte 3 ; top
2018-03-26 18:57:06 +00:00
!byte 56 ; visible width
!byte 19 ; visible height
!byte 56 ; width
!byte 19 ; height
2018-03-01 16:06:00 +00:00
.stringFrame
!text "Settings",0
.viewOK
!byte ID_OPTIONS_OK ; view ID
2018-03-26 18:57:06 +00:00
!byte 56 ; left
2018-03-01 16:06:00 +00:00
!byte 4 ; top
!byte 10 ; width
!word callback_options_ok ; callback
!word .stringOK ; caption
.stringOK
!byte $0F ; 'P' inverse
!byte 139,0
.viewCancel
!byte ID_OPTIONS_CANCEL ; view ID
2018-03-26 18:57:06 +00:00
!byte 56 ; left
2018-03-01 16:06:00 +00:00
!byte 6 ; top
!byte 10 ; width
!word callback_options_cancel ; callback
!word .stringCancel ; caption
.stringCancel
!byte $03 ; 'C' inverse
!text "ancel",0
.viewForce40
!byte ID_OPTIONS_FORCE40 ; view ID
2018-03-26 18:57:06 +00:00
!byte 14 ; left
!byte 4 ; top
2018-03-01 16:06:00 +00:00
!word .stringForce40 ; caption
.stringForce40
!text "Force "
!byte $34 ; '4' inverse
!text "0 column",0
2018-03-26 18:57:06 +00:00
.stringForce40Description
!text "Some games may be glitchy",0
2018-03-01 16:06:00 +00:00
.viewForceUpper
!byte ID_OPTIONS_FORCEUPPER ; view ID
2018-03-26 18:57:06 +00:00
!byte 14 ; left
!byte 9 ; top
2018-03-01 16:06:00 +00:00
!word .stringForceUpper ; caption
.stringForceUpper
!text "Force "
!byte $75 ; 'u' inverse
!text "ppercase",0
2018-03-26 18:57:06 +00:00
.stringForceUpperDescription
!text "A MATTER OF PREFERENCE",0
2018-03-01 16:06:00 +00:00
2018-03-26 18:57:06 +00:00
.viewScriptToFile
!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
2018-03-01 16:06:00 +00:00
2018-03-26 18:57:06 +00:00
.viewAutoScript
!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
2018-03-01 16:06:00 +00:00
}