pitch-dark/src/ui.common.a

159 lines
4.4 KiB
Plaintext
Raw Normal View History

2018-03-01 16:06:00 +00:00
;license:MIT
;(c) 2018 by 4am
;
; User interface - common views and paint routines across screens
;
; Public functions
; - CreateRadio
; - CreateCheckbox
; - CreateButton
; - PaintTitleBar
; - PrintAt
2018-04-02 19:26:05 +00:00
; - SimulateClick
2018-03-01 16:06:00 +00:00
;
; Public constants
; - kStringOK
; - kStringCancel
;
kStringOK
!byte $0F ; 'O' inverse
!byte 139,0
kStringCancel
!byte $03 ; 'C' inverse
!text "ancel",0
2018-03-01 16:06:00 +00:00
2018-03-27 21:17:47 +00:00
;------------------------------------------------------------------------------
; CreateRadio/CreateCheckbox/CreateButton
; creates a WeeGUI UI control with the 'raw title' option set
;
; in: WeeGUI loaded and initialized
; stack contains 2 bytes of parameters:
2018-03-27 21:17:47 +00:00
; +1 [word] pointer to WeeGUI view configuration block
; out: $00/$01 clobbered
; all registers clobbered
;------------------------------------------------------------------------------
!zone {
2018-03-01 16:06:00 +00:00
CreateRadio
ldx #WGCreateRadio
!byte $2C ; hide next 2 bytes
CreateCheckbox
ldx #WGCreateCheckbox
!byte $2C ; hide next 2 bytes
CreateButton
ldx #WGCreateButton
2018-03-26 18:57:06 +00:00
stx .type
+PARAMS_ON_STACK 2
+LDPARAM 1
+STAY PARAM0
2018-03-26 18:57:06 +00:00
.type=*+1
2018-03-28 15:48:47 +00:00
ldx #$FD ; SMC
2018-03-01 16:06:00 +00:00
jsr WeeGUI
ldx #WGViewSetRawTitle
lda #1
sta PARAM0
jmp WeeGUI
}
;------------------------------------------------------------------------------
; CreateDialog
; creates a WeeGUI decorated frame view
;
; in: WeeGUI loaded and 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
}
2018-03-27 21:17:47 +00:00
;------------------------------------------------------------------------------
; PaintTitleBar
; paints the title bar on the top line
2018-03-27 21:17:47 +00:00
;
; in: WeeGUI loaded and initialized
; out: all registers and flags clobbered
2018-03-27 21:17:47 +00:00
;------------------------------------------------------------------------------
!zone {
PaintTitleBar
ldy #79
- sty PARAM0
stz PARAM1
ldx #WGSetGlobalCursor
2018-03-01 16:06:00 +00:00
jsr WeeGUI
ldx #WGPlot
2018-04-02 19:26:05 +00:00
lda kStringGlobalTitle,y
2018-03-01 16:06:00 +00:00
jsr WeeGUI
dey
bpl -
ldx #WGSyncGlobalCursor
jmp WeeGUI
2018-03-01 16:06:00 +00:00
2018-04-02 19:26:05 +00:00
kStringGlobalTitle
!raw " "
2018-04-02 19:26:05 +00:00
!byte 16 ; inverse P
!raw "itch "
2018-04-02 19:26:05 +00:00
!byte 4 ; inverse D
!raw "ark ",0
2018-03-26 20:28:20 +00:00
}
;------------------------------------------------------------------------------
; PrintAt
; print a null-terminated string at a specified position
;
; in: WeeGUI loaded and 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
}
2018-04-02 19:26:05 +00:00
;------------------------------------------------------------------------------
; SimulateClick
; select, focus, activate, and unfocus a WeeGUI view
;
; in: WeeGUI loaded and 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
}