pitch-dark/src/ui.options.a

287 lines
8.7 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_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
2018-03-27 21:17:47 +00:00
; action keys for options screen
2018-04-18 19:28:55 +00:00
kOptionsKeys
2018-03-27 21:17:47 +00:00
!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
!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-04-18 19:28:55 +00:00
_endOptionsKeys
2018-03-27 21:17:47 +00:00
2018-03-01 16:06:00 +00:00
;------------------------------------------------------------------------------
; OptionsDialog
2018-03-27 21:17:47 +00:00
; call WeeGUI to create and paint option screen, and run to completion
2018-03-01 16:06:00 +00:00
;
2018-04-02 19:43:11 +00:00
; in: WeeGUI initialized
2018-03-27 21:17:47 +00:00
; out: exits via MainScreen
; all registers and flags clobbered
2018-03-01 16:06:00 +00:00
;------------------------------------------------------------------------------
OptionsDialog
ldx #$FF
txs
jsr HardResetWeeGUI
2018-03-01 16:06:00 +00:00
jsr CreateDialog ; create decorated frame
!word kViewOptionsFrame
!word kStringOptionsFrame
2018-03-01 16:06:00 +00:00
jsr CreateButton ; create OK button
!word kViewOptionsOK
jsr CreateButton ; create Cancel button
!word kViewOptionsCancel
jsr CreateCheckbox ; create other UI controls
2018-04-01 22:26:54 +00:00
!word kViewForce40
2018-03-01 16:06:00 +00:00
jsr CreateCheckbox
2018-04-01 22:26:54 +00:00
!word kViewForceUpper
2018-03-26 18:57:06 +00:00
jsr CreateCheckbox
2018-04-01 22:26:54 +00:00
!word kViewScriptToFile
2018-03-26 18:57:06 +00:00
jsr CreateCheckbox
2018-04-01 22:26:54 +00:00
!word kViewAutoScript
2018-03-26 20:28:20 +00:00
jsr SetCheckboxByPref ; set initial state of checkboxes based on preferences
!byte ID_OPTIONS_FORCE40
2018-03-26 18:57:06 +00:00
!word kForce40
2018-03-26 20:28:20 +00:00
jsr SetCheckboxByPref
!byte ID_OPTIONS_FORCEUPPER
2018-03-26 18:57:06 +00:00
!word kForceUpper
2018-03-26 20:28:20 +00:00
jsr SetCheckboxByPref
!byte ID_OPTIONS_SCRIPTTOFILE
2018-03-26 18:57:06 +00:00
!word kScriptToFile
2018-03-26 20:28:20 +00:00
jsr SetCheckboxByPref
!byte ID_OPTIONS_AUTOSCRIPT
2018-03-26 18:57:06 +00:00
!word kAutoScript
2018-03-01 16:06:00 +00:00
ldx #WGDesktop ; paint background
jsr WeeGUI
2018-04-11 19:12:36 +00:00
jsr PaintTitleBar ; paint top title bar
2018-03-01 16:06:00 +00:00
ldx #WGViewPaintAll ; paint UI controls (window frame, buttons, checkboxes, radio buttons)
jsr WeeGUI
ldx #WGSelectView ; select frame (required for print routines that follow)
2018-03-01 16:06:00 +00:00
lda #ID_OPTIONS_FRAME
jsr WeeGUI
jsr PrintAt ; paint static text labels
!byte 6,3
!word kStringForce40Description
jsr PrintAt
!byte 6,8
!word kStringForceUpperDescription
jsr PrintAt
!byte 6,13
!word kStringScriptToFileDescription
jsr PrintAt
!byte 6,18
!word kStringAutoScriptDescription
2018-03-01 16:06:00 +00:00
jsr ClearPendingInput
2018-04-19 02:01:24 +00:00
- ldx #WGPendingViewAction
2018-04-11 19:12:36 +00:00
jsr WeeGUI ; handle mouse movement and clicks
2018-04-01 22:26:54 +00:00
lda $C000
2018-04-19 02:01:24 +00:00
bpl -
jsr ClearPendingInput
2018-04-11 19:12:36 +00:00
jsr HandleOptionsKey ; handle keypresses
2018-04-19 02:01:24 +00:00
bra -
2018-03-01 16:06:00 +00:00
2018-03-27 21:17:47 +00:00
;------------------------------------------------------------------------------
; internal functions
2018-03-01 16:06:00 +00:00
2018-04-19 18:46:06 +00:00
;------------------------------------------------------------------------------
; HandleOptions
;
; in: A = key pressed
; out: all registers and flags clobbered
;------------------------------------------------------------------------------
2018-03-01 16:06:00 +00:00
HandleOptionsKey
2018-06-20 22:58:05 +00:00
ldx #(_endOptionsKeys-kOptionsKeys)-2
2018-04-18 19:28:55 +00:00
- cmp kOptionsKeys,x
beq @found
2018-03-01 16:06:00 +00:00
dex
dex
bpl -
2018-03-16 18:17:45 +00:00
jmp SoftBell
@found lda kOptionsKeys+1,x
ldx #WGSelectView
jsr WeeGUI
2018-04-02 19:26:05 +00:00
jmp SimulateClick
2018-03-01 16:06:00 +00:00
callback_options_ok
2018-03-26 20:28:20 +00:00
jsr SetPrefByCheckbox
!byte ID_OPTIONS_FORCE40
!word kForce40
jsr SetPrefByCheckbox
!byte ID_OPTIONS_FORCEUPPER
!word kForceUpper
jsr SetPrefByCheckbox
!byte ID_OPTIONS_SCRIPTTOFILE
!word kScriptToFile
jsr SetPrefByCheckbox
!byte ID_OPTIONS_AUTOSCRIPT
!word kAutoScript
2018-03-27 20:31:01 +00:00
lda #1
2018-04-01 22:26:54 +00:00
sta gGlobalPrefsDirty ; must set, otherwise SaveGlobalPreferences does nothing
jsr SaveGlobalPreferences ; immediately write new preferences to disk
2018-03-26 20:28:20 +00:00
; execution falls through here
2018-03-01 16:06:00 +00:00
callback_options_cancel
jmp MainScreen
2018-03-27 21:17:47 +00:00
SetCheckboxByPref
+PARAMS_ON_STACK 3
ldy #1
lda (PARAM),y
sta @view
+LDPARAM 2
+STAY @key
2018-03-27 21:17:47 +00:00
jsr okvs_get
!word gGlobalPrefsStore
@key !word $FDFD ; SMC
bcs @exit
2018-03-27 21:17:47 +00:00
jsr okvs_as_boolean
beq @exit
2018-03-27 21:17:47 +00:00
ldx #WGSelectView
@view=*+1
2018-03-28 15:48:47 +00:00
lda #$FD ; SMC
2018-03-27 21:17:47 +00:00
jsr WeeGUI
ldx #WGSetState
lda #1
sta PARAM0
jsr WeeGUI
@exit rts
2018-03-27 21:17:47 +00:00
SetPrefByCheckbox
+PARAMS_ON_STACK 3
2018-04-19 02:01:24 +00:00
+LDPARAM 2
+STAY @key
2018-03-27 21:17:47 +00:00
ldy #1
lda (PARAM),y
ldx #WGSelectView
jsr WeeGUI
ldx #WGGetState
jsr WeeGUI
lda PARAM0
and #1
sta @valueb
2018-03-27 21:17:47 +00:00
jsr okvs_update
!word gGlobalPrefsStore
@key !word $FDFD ; SMC
!word @value
2018-03-27 21:17:47 +00:00
rts
@value !byte 1
@valueb !byte $FD ; SMC
2018-03-27 21:17:47 +00:00
2018-04-18 19:28:55 +00:00
;------------------------------------------------------------------------------
; WeeGUI view configuration records
kViewOptionsFrame
2018-03-01 16:06:00 +00:00
!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
kViewOptionsOK
2018-03-01 16:06:00 +00:00
!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
2018-04-01 22:26:54 +00:00
!word kStringOK ; caption
2018-03-01 16:06:00 +00:00
kViewOptionsCancel
2018-03-01 16:06:00 +00:00
!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
2018-04-01 22:26:54 +00:00
!word kStringCancel ; caption
2018-03-01 16:06:00 +00:00
2018-04-01 22:26:54 +00:00
kViewForce40
2018-03-01 16:06:00 +00:00
!byte ID_OPTIONS_FORCE40 ; view ID
2018-03-26 18:57:06 +00:00
!byte 14 ; left
!byte 4 ; top
2018-04-01 22:26:54 +00:00
!word kStringForce40 ; caption
2018-03-01 16:06:00 +00:00
2018-04-01 22:26:54 +00:00
kViewForceUpper
2018-03-01 16:06:00 +00:00
!byte ID_OPTIONS_FORCEUPPER ; view ID
2018-03-26 18:57:06 +00:00
!byte 14 ; left
!byte 9 ; top
2018-04-01 22:26:54 +00:00
!word kStringForceUpper ; caption
2018-03-01 16:06:00 +00:00
2018-04-01 22:26:54 +00:00
kViewScriptToFile
2018-03-26 18:57:06 +00:00
!byte ID_OPTIONS_SCRIPTTOFILE ; view ID
!byte 14 ; left
!byte 14 ; top
2018-04-01 22:26:54 +00:00
!word kStringScriptToFile ; caption
2018-03-01 16:06:00 +00:00
2018-04-01 22:26:54 +00:00
kViewAutoScript
2018-03-26 18:57:06 +00:00
!byte ID_OPTIONS_AUTOSCRIPT ; view ID
!byte 14 ; left
!byte 19 ; top
2018-04-01 22:26:54 +00:00
!word kStringAutoScript ; caption
2018-04-18 19:28:55 +00:00
kStringOptionsFrame
!text "Settings",0
kStringForce40
!text "Force "
!byte $34 ; '4' inverse
!text "0 column",0
kStringForce40Description
!text "Some games may be glitchy",0
kStringForceUpper
!text "Force "
!byte $75 ; 'u' inverse
!text "ppercase",0
kStringForceUpperDescription
!text "A MATTER OF PREFERENCE, I SUPPOSE",0
kStringScriptToFile
!text "SCRIPT to "
!byte $66 ; 'f' inverse
!text "ile",0
kStringScriptToFileDescription
!text "Save transcripts to a file instead of printer",0
2018-04-01 22:26:54 +00:00
kStringAutoScript
2018-03-26 18:57:06 +00:00
!text "Always "
!byte $13 ; 'S' inverse
!text "CRIPT",0
2018-04-01 22:26:54 +00:00
kStringAutoScriptDescription
2018-03-26 18:57:06 +00:00
!text "Turn on SCRIPT mode automatically",0