pitch-dark/src/ui.common.a

132 lines
3.0 KiB
Plaintext

;license:MIT
;(c) 2018 by 4am
;
; User interface - common views and paint routines across screens
;
; Public functions
; - CreateRadio
; - CreateCheckbox
; - CreateButton
; - PaintTitleBar
;
;------------------------------------------------------------------------------
; CreateRadio/CreateCheckbox/CreateButton
; creates a WeeGUI UI control with the 'raw title' option set
;
; in: 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
ldy #$01
lda (PARAM),y
sta PARAM0
iny
lda (PARAM),y
sta PARAM1
.type=*+1
ldx #$FD ; SMC
jsr WeeGUI
ldx #WGViewSetRawTitle
lda #1
sta PARAM0
jmp WeeGUI
}
!zone {
CreateConditionalButton
+PARAMS_ON_STACK 5
ldy #1
lda (PARAM),y
sta .viewID
ldy #3
lda (PARAM),y
pha
dey
lda (PARAM),y
ply
+STAY .viewConfigurationRecord
ldy #5
lda (PARAM),y
pha
dey
lda (PARAM),y
ply
+STAY .optionsStoreKey
jsr okvs_get
!word gOptionsStore
.optionsStoreKey
!word $FDFD ; SMC
.viewID=*+1
ldx #$FD ; SMC (X = WeeGUI view ID)
jsr okvs_as_boolean
beq .no
lda gViewInUse,x
bne .done
lda #1
sta gViewInUse,x
jsr CreateButton
.viewConfigurationRecord
!word $FDFD ; SMC
bra .done
.no lda gViewInUse,x
beq .done
lda #0
sta gViewInUse,x
txa ; A = WeeGUI view ID
ldx #WGSelectView
jsr WeeGUI
ldx #WGDeleteView
jsr WeeGUI
.done rts
}
;------------------------------------------------------------------------------
; PaintTitleBar
; paints the title bar
;
; in: none
; out: all registers and flags clobbered
;------------------------------------------------------------------------------
!zone {
PaintTitleBar
ldy #79
- sty PARAM0
stz PARAM1
ldx #WGSetGlobalCursor
jsr WeeGUI
ldx #WGPlot
lda .stringTitle,y
jsr WeeGUI
dey
bpl -
ldx #WGSyncGlobalCursor
jmp WeeGUI
.stringTitle
!raw " "
!byte 16
!raw "itch "
!byte 4
!raw "ark ",0
}