mirror of
https://github.com/a2-4am/pitch-dark.git
synced 2025-01-06 01:30:48 +00:00
292 lines
8.6 KiB
Plaintext
292 lines
8.6 KiB
Plaintext
;license:MIT
|
|
;(c) 2018 by 4am
|
|
;
|
|
; User interface - views and paint routines for options screen
|
|
;
|
|
; Public functions
|
|
; - OptionsDialog
|
|
;
|
|
|
|
!zone {
|
|
; View IDs (application-specific, acceptable range 0..15, no duplicates)
|
|
ID_OPTIONS_FRAME = 1
|
|
ID_OPTIONS_FORCE40 = 2
|
|
ID_OPTIONS_FORCEUPPER = 3
|
|
ID_OPTIONS_SCRIPTTOFILE = 4
|
|
ID_OPTIONS_AUTOSCRIPT = 5
|
|
ID_OPTIONS_OK = 6
|
|
ID_OPTIONS_CANCEL = 7
|
|
|
|
; 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
|
|
!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
|
|
|
|
;------------------------------------------------------------------------------
|
|
; OptionsDialog
|
|
; call WeeGUI to create and paint option screen, and run to completion
|
|
;
|
|
; in: WeeGUI initialized
|
|
; out: exits via MainScreen
|
|
; all registers and flags clobbered
|
|
;------------------------------------------------------------------------------
|
|
OptionsDialog
|
|
ldx #$FF
|
|
txs
|
|
ldx #WGResetAll ; reset WeeGUI, destroy all views
|
|
jsr WeeGUI
|
|
|
|
jsr CreateDialog ; create frame and OK/Cancel buttons
|
|
!word kViewOptionsFrame
|
|
!word kStringOptionsFrame
|
|
|
|
jsr CreateButton ; create OK button
|
|
!word kViewOptionsOK
|
|
|
|
jsr CreateButton ; create Cancel button
|
|
!word kViewOptionsCancel
|
|
|
|
jsr CreateCheckbox ; create other UI controls
|
|
!word kViewForce40
|
|
jsr CreateCheckbox
|
|
!word kViewForceUpper
|
|
jsr CreateCheckbox
|
|
!word kViewScriptToFile
|
|
jsr CreateCheckbox
|
|
!word kViewAutoScript
|
|
|
|
jsr SetCheckboxByPref ; set initial state of checkboxes based on preferences
|
|
!byte ID_OPTIONS_FORCE40
|
|
!word kForce40
|
|
jsr SetCheckboxByPref
|
|
!byte ID_OPTIONS_FORCEUPPER
|
|
!word kForceUpper
|
|
jsr SetCheckboxByPref
|
|
!byte ID_OPTIONS_SCRIPTTOFILE
|
|
!word kScriptToFile
|
|
jsr SetCheckboxByPref
|
|
!byte ID_OPTIONS_AUTOSCRIPT
|
|
!word kAutoScript
|
|
|
|
ldx #WGDesktop ; paint background
|
|
jsr WeeGUI
|
|
|
|
jsr PaintTitleBar ; paint top title bar
|
|
|
|
ldx #WGViewPaintAll ; paint UI controls (window frame, buttons, checkboxes, radio buttons)
|
|
jsr WeeGUI
|
|
|
|
ldx #WGSelectView ; select frame (required for print routines that follow)
|
|
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
|
|
|
|
bit $C010 ; clear keyboard strobe
|
|
ldx #WGClearPendingClick ; clear WeeGUI mouse strobe
|
|
jsr WeeGUI
|
|
.runLoop
|
|
ldx #WGPendingViewAction
|
|
jsr WeeGUI ; handle mouse movement and clicks
|
|
lda $C000
|
|
bpl .runLoop
|
|
bit $C010
|
|
jsr HandleOptionsKey ; handle keypresses
|
|
bra .runLoop
|
|
|
|
;------------------------------------------------------------------------------
|
|
; internal functions
|
|
|
|
HandleOptionsKey
|
|
ldx #.endkeys-.keys
|
|
- cmp .keys,x
|
|
beq .foundKey
|
|
dex
|
|
dex
|
|
bpl -
|
|
jmp SoftBell
|
|
.foundKey
|
|
lda .keys+1,x
|
|
ldx #WGSelectView
|
|
jsr WeeGUI
|
|
jmp SimulateClick
|
|
|
|
callback_options_ok
|
|
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
|
|
lda #1
|
|
sta gGlobalPrefsDirty ; must set, otherwise SaveGlobalPreferences does nothing
|
|
jsr SaveGlobalPreferences ; immediately write new preferences to disk
|
|
; execution falls through here
|
|
callback_options_cancel
|
|
jmp MainScreen
|
|
|
|
!zone {
|
|
SetCheckboxByPref
|
|
+PARAMS_ON_STACK 3
|
|
|
|
ldy #1
|
|
lda (PARAM),y
|
|
sta .id
|
|
+LDPARAM 2
|
|
+STAY .key
|
|
|
|
jsr okvs_get
|
|
!word gGlobalPrefsStore
|
|
.key !word $FDFD ; SMC
|
|
bcs .exit
|
|
|
|
jsr okvs_as_boolean
|
|
beq .exit
|
|
|
|
ldx #WGSelectView
|
|
.id=*+1
|
|
lda #$FD ; SMC
|
|
jsr WeeGUI
|
|
ldx #WGSetState
|
|
lda #1
|
|
sta PARAM0
|
|
jsr WeeGUI
|
|
.exit rts
|
|
}
|
|
|
|
!zone {
|
|
SetPrefByCheckbox
|
|
+PARAMS_ON_STACK 3
|
|
|
|
ldy #1
|
|
lda (PARAM),y
|
|
sta .id
|
|
+LDPARAM 2
|
|
+STAY .key
|
|
|
|
ldx #WGSelectView
|
|
.id=*+1
|
|
lda #$FD ; SMC
|
|
jsr WeeGUI
|
|
ldx #WGGetState
|
|
jsr WeeGUI
|
|
|
|
lda PARAM0
|
|
and #1
|
|
sta .value+1
|
|
|
|
jsr okvs_update
|
|
!word gGlobalPrefsStore
|
|
.key !word $FDFD ; SMC
|
|
!word .value
|
|
rts
|
|
.value !byte 1
|
|
!byte $FD ; SMC
|
|
}
|
|
|
|
kViewOptionsFrame
|
|
!byte ID_OPTIONS_FRAME ; view ID
|
|
!byte 2 ; style (decorated frame)
|
|
!byte 12 ; left
|
|
!byte 3 ; top
|
|
!byte 56 ; visible width
|
|
!byte 19 ; visible height
|
|
!byte 56 ; width
|
|
!byte 19 ; height
|
|
kStringOptionsFrame
|
|
!text "Settings",0
|
|
|
|
kViewOptionsOK
|
|
!byte ID_OPTIONS_OK ; view ID
|
|
!byte 56 ; left
|
|
!byte 4 ; top
|
|
!byte 10 ; width
|
|
!word callback_options_ok ; callback
|
|
!word kStringOK ; caption
|
|
|
|
kViewOptionsCancel
|
|
!byte ID_OPTIONS_CANCEL ; view ID
|
|
!byte 56 ; left
|
|
!byte 6 ; top
|
|
!byte 10 ; width
|
|
!word callback_options_cancel ; callback
|
|
!word kStringCancel ; caption
|
|
|
|
kViewForce40
|
|
!byte ID_OPTIONS_FORCE40 ; view ID
|
|
!byte 14 ; left
|
|
!byte 4 ; top
|
|
!word kStringForce40 ; caption
|
|
kStringForce40
|
|
!text "Force "
|
|
!byte $34 ; '4' inverse
|
|
!text "0 column",0
|
|
kStringForce40Description
|
|
!text "Some games may be glitchy",0
|
|
|
|
kViewForceUpper
|
|
!byte ID_OPTIONS_FORCEUPPER ; view ID
|
|
!byte 14 ; left
|
|
!byte 9 ; top
|
|
!word kStringForceUpper ; caption
|
|
kStringForceUpper
|
|
!text "Force "
|
|
!byte $75 ; 'u' inverse
|
|
!text "ppercase",0
|
|
kStringForceUpperDescription
|
|
!text "A MATTER OF PREFERENCE, I SUPPOSE",0
|
|
|
|
kViewScriptToFile
|
|
!byte ID_OPTIONS_SCRIPTTOFILE ; view ID
|
|
!byte 14 ; left
|
|
!byte 14 ; top
|
|
!word kStringScriptToFile ; caption
|
|
kStringScriptToFile
|
|
!text "SCRIPT to "
|
|
!byte $66 ; 'f' inverse
|
|
!text "ile",0
|
|
kStringScriptToFileDescription
|
|
!text "Save transcripts to a file instead of printer",0
|
|
|
|
kViewAutoScript
|
|
!byte ID_OPTIONS_AUTOSCRIPT ; view ID
|
|
!byte 14 ; left
|
|
!byte 19 ; top
|
|
!word kStringAutoScript ; caption
|
|
kStringAutoScript
|
|
!text "Always "
|
|
!byte $13 ; 'S' inverse
|
|
!text "CRIPT",0
|
|
kStringAutoScriptDescription
|
|
!text "Turn on SCRIPT mode automatically",0
|
|
}
|