mirror of
https://github.com/a2-4am/pitch-dark.git
synced 2024-09-27 04:54:48 +00:00
159 lines
4.3 KiB
Plaintext
159 lines
4.3 KiB
Plaintext
;license:MIT
|
|
;(c) 2018 by 4am
|
|
;
|
|
; User interface - common views and paint routines across screens
|
|
;
|
|
; Public functions
|
|
; - CreateRadio
|
|
; - CreateCheckbox
|
|
; - CreateButton
|
|
; - PaintTitleBar
|
|
; - PrintAt
|
|
; - SimulateClick
|
|
;
|
|
; Public constants
|
|
; - kStringOK
|
|
; - kStringCancel
|
|
;
|
|
|
|
kStringOK
|
|
!byte $0F ; 'O' inverse
|
|
!byte 139,0
|
|
kStringCancel
|
|
!byte $03 ; 'C' inverse
|
|
!text "ancel",0
|
|
|
|
;------------------------------------------------------------------------------
|
|
; CreateRadio/CreateCheckbox/CreateButton
|
|
; creates a WeeGUI UI control with the 'raw title' option set
|
|
;
|
|
; in: WeeGUI initialized
|
|
; stack contains 2 bytes of parameters:
|
|
; +1 [word] pointer to WeeGUI view configuration block
|
|
; out: $00/$01 clobbered
|
|
; all registers clobbered
|
|
;------------------------------------------------------------------------------
|
|
!zone {
|
|
CreateRadio
|
|
ldx #WGCreateRadio
|
|
!byte $2C ; hide next 2 bytes
|
|
CreateCheckbox
|
|
ldx #WGCreateCheckbox
|
|
!byte $2C ; hide next 2 bytes
|
|
CreateButton
|
|
ldx #WGCreateButton
|
|
stx .type
|
|
|
|
+PARAMS_ON_STACK 2
|
|
+LDPARAM 1
|
|
+STAY PARAM0
|
|
.type=*+1
|
|
ldx #$FD ; SMC
|
|
jsr WeeGUI
|
|
ldx #WGViewSetRawTitle
|
|
lda #1
|
|
sta PARAM0
|
|
jmp WeeGUI
|
|
}
|
|
|
|
;------------------------------------------------------------------------------
|
|
; CreateDialog
|
|
; creates a WeeGUI decorated frame view
|
|
;
|
|
; in: WeeGUI initialized
|
|
; stack contains 8 bytes of parameters:
|
|
; +1 [word] address of WeeGUI view configuration block for frame
|
|
; +3 [word] address of null-terminated string for frame title
|
|
; out: $00/$01 clobbered
|
|
; all registers clobbered
|
|
;------------------------------------------------------------------------------
|
|
!zone {
|
|
CreateDialog
|
|
+PARAMS_ON_STACK 4
|
|
+LDPARAM 1
|
|
+STAY PARAM0
|
|
ldx #WGCreateView ; create frame
|
|
jsr WeeGUI
|
|
|
|
+LDPARAM 3
|
|
+STAY PARAM0
|
|
ldx #WGViewSetTitle ; set frame title
|
|
jmp WeeGUI
|
|
}
|
|
|
|
;------------------------------------------------------------------------------
|
|
; PaintTitleBar
|
|
; paints the title bar on the top line
|
|
;
|
|
; in: WeeGUI initialized
|
|
; out: all registers and flags clobbered
|
|
;------------------------------------------------------------------------------
|
|
!zone {
|
|
PaintTitleBar
|
|
ldy #79
|
|
- sty PARAM0
|
|
stz PARAM1
|
|
ldx #WGSetGlobalCursor
|
|
jsr WeeGUI
|
|
ldx #WGPlot
|
|
lda kStringGlobalTitle,y
|
|
jsr WeeGUI
|
|
dey
|
|
bpl -
|
|
ldx #WGSyncGlobalCursor
|
|
jmp WeeGUI
|
|
|
|
kStringGlobalTitle
|
|
!raw " "
|
|
!byte 16 ; inverse P
|
|
!raw "itch "
|
|
!byte 4 ; inverse D
|
|
!raw "ark ",0
|
|
}
|
|
|
|
;------------------------------------------------------------------------------
|
|
; PrintAt
|
|
; print a null-terminated string at a specified position
|
|
;
|
|
; in: WeeGUI initialized
|
|
; stack contains 4 bytes of parameters:
|
|
; +1 [byte] X coordinate (relative to selected view)
|
|
; +2 [byte] Y coordinate (relative to selected view)
|
|
; +3 [word] address of null-terminated string
|
|
; out: WeeGUI local cursor positioned after string
|
|
; $00/$01 clobbered
|
|
; all registers and flags clobbered
|
|
;------------------------------------------------------------------------------
|
|
!zone {
|
|
PrintAt
|
|
+PARAMS_ON_STACK 4
|
|
+LDPARAM 1
|
|
+STAY PARAM0
|
|
ldx #WGSetCursor
|
|
jsr WeeGUI
|
|
+LDPARAM 3
|
|
+STAY PARAM0
|
|
ldx #WGPrint
|
|
jmp WeeGUI
|
|
}
|
|
|
|
;------------------------------------------------------------------------------
|
|
; SimulateClick
|
|
; select, focus, activate, and unfocus a WeeGUI view
|
|
;
|
|
; in: WeeGUI initialized
|
|
; A contains WeeGUI view ID
|
|
; out: X clobbered
|
|
;------------------------------------------------------------------------------
|
|
!zone {
|
|
SimulateClick
|
|
ldx #WGSelectView
|
|
jsr WeeGUI
|
|
ldx #WGViewFocus
|
|
jsr WeeGUI
|
|
ldx #WGViewFocusAction
|
|
jsr WeeGUI
|
|
ldx #WGViewUnfocus
|
|
jmp WeeGUI
|
|
}
|