pitch-dark/src/ui.common.a
2018-03-28 22:49:51 -04:00

102 lines
2.8 KiB
Plaintext

;license:MIT
;(c) 2018 by 4am
;
; User interface - common views and paint routines across screens
;
; Public functions
; - CreateRadio
; - CreateCheckbox
; - CreateButton
; - CreateTitleView
; - PaintTitleView
;
; ROM routines
INVERSE = $FE80
NORMAL = $FE84
; View IDs (application-specific, acceptable range 0..15, no duplicates)
ID_TITLE = 0
!zone {
;------------------------------------------------------------------------------
; 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
;------------------------------------------------------------------------------
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 ($00),y
sta PARAM0
iny
lda ($00),y
sta PARAM1
.type=*+1
ldx #$FD ; SMC
jsr WeeGUI
ldx #WGViewSetRawTitle
lda #1
sta PARAM0
jmp WeeGUI
;------------------------------------------------------------------------------
; CreateTitleView
; creates the standard title bar on top row of screen
;
; in: none
; out: A,X clobbered
; title view selected
;------------------------------------------------------------------------------
CreateTitleView
ldx #WGCreateView ; create title bar on top line
+LDADDR viewTitle
+STAY PARAM0
jmp WeeGUI
;------------------------------------------------------------------------------
; PaintTitleView
; paints the title bar
;
; in: none
; out: all registers clobbered
; title view selected
;------------------------------------------------------------------------------
PaintTitleView
ldx #WGSelectView
lda #ID_TITLE
jsr WeeGUI
jsr INVERSE
ldx #WGPrint
+LDADDR .stringTitle
+STAY PARAM0
jsr WeeGUI
jmp NORMAL
viewTitle
!byte ID_TITLE ; view ID
!byte 0 ; style
!byte 0 ; left
!byte 0 ; top
!byte 80 ; visible width
!byte 1 ; visible height
!byte 80 ; width
!byte 1 ; height
.stringTitle
!raw " Pitch Dark ",0
}