pitch-dark/src/ui.main.a

351 lines
9.9 KiB
Plaintext
Raw Normal View History

2018-02-07 14:05:24 +00:00
;license:MIT
;(c) 2018 by 4am
;
2018-03-27 20:55:31 +00:00
; User interface - views and paint routines for main screen
2018-02-07 14:05:24 +00:00
;
; Public functions
; - CreateViews
; - PaintAllViews
; - RepaintSomeViews
;
2018-03-27 21:17:47 +00:00
MAGICRTS = $FF58 ; used to set overflow bit
2018-02-07 14:05:24 +00:00
; View IDs (application-specific, acceptable range 0..15, no duplicates)
2018-03-27 21:17:47 +00:00
; ID_TITLE is defined in ui.common.a
2018-02-24 20:25:41 +00:00
ID_PREVIOUS = 1
ID_OPTIONS = 2
ID_NEXT = 3
ID_HR = 4
ID_PLAY = 5
ID_VERSIONS = 6
ID_BOXART = 7
ID_CLUES = 8
ID_INFO = 9
2018-02-07 14:05:24 +00:00
ID_DESCRIPTION = 13
!zone {
;------------------------------------------------------------------------------
; CreateViews
; call WeeGUI to create all application views
;
; in: WeeGUI loaded and initialized
2018-03-27 21:17:47 +00:00
; out: all registers and flags clobbered
2018-02-07 14:05:24 +00:00
;------------------------------------------------------------------------------
CreateViews
2018-03-01 16:06:00 +00:00
jsr CreateTitleView
2018-02-07 14:05:24 +00:00
2018-02-24 20:25:41 +00:00
ldx #WGCreateView ; create horizontal rule
lda #<.viewHR
sta PARAM0
lda #>.viewHR
sta PARAM1
jsr WeeGUI
2018-03-01 16:06:00 +00:00
jsr CreateButton ; create various buttons
2018-02-07 14:05:24 +00:00
!word .viewPrevious
2018-03-01 16:06:00 +00:00
jsr CreateButton
2018-02-07 14:05:24 +00:00
!word .viewNext
2018-03-01 16:06:00 +00:00
jsr CreateButton
2018-02-07 14:05:24 +00:00
!word .viewPlay
2018-03-01 16:06:00 +00:00
jsr CreateButton
2018-02-24 20:25:41 +00:00
!word .viewVersions
2018-03-01 16:06:00 +00:00
jsr CreateButton
2018-02-07 14:05:24 +00:00
!word .viewBoxArt
2018-03-01 16:06:00 +00:00
jsr CreateButton
2018-02-24 20:25:41 +00:00
!word .viewClues
2018-03-01 16:06:00 +00:00
jsr CreateButton
2018-02-07 14:05:24 +00:00
!word .viewOptions
ldx #WGCreateView ; create borderless frame for game title and info
lda #<.viewInfo
sta PARAM0
lda #>.viewInfo
sta PARAM1
jsr WeeGUI
ldx #WGViewSetAction
2018-03-27 21:27:13 +00:00
lda #<paintInfoView
2018-02-07 14:05:24 +00:00
sta PARAM0
2018-03-27 21:27:13 +00:00
lda #>paintInfoView
2018-02-07 14:05:24 +00:00
sta PARAM1
jsr WeeGUI
ldx #WGCreateView ; create scrollable frame for game description text
lda #<.viewDescription
sta PARAM0
lda #>.viewDescription
sta PARAM1
jsr WeeGUI
ldx #WGViewSetAction
2018-03-27 21:27:13 +00:00
lda #<paintDescriptionView
2018-02-07 14:05:24 +00:00
sta PARAM0
2018-03-27 21:27:13 +00:00
lda #>paintDescriptionView
2018-02-07 14:05:24 +00:00
sta PARAM1
jmp WeeGUI
;------------------------------------------------------------------------------
; PaintAllViews
; call WeeGUI to paint all UI elements
;
; in: WeeGUI loaded and initialized
; CreateViews has been called
2018-03-27 21:17:47 +00:00
; out: all registers and flags clobbered
; $00/$01 clobbered
2018-02-07 14:05:24 +00:00
;------------------------------------------------------------------------------
PaintAllViews
ldx #WGViewPaintAll ; repaint all views that can be painted automatically
jsr WeeGUI
2018-03-01 16:06:00 +00:00
jsr PaintTitleView
2018-03-27 21:27:13 +00:00
jsr paintHRView
jsr paintInfoView
jmp paintDescriptionView
2018-02-07 14:05:24 +00:00
;------------------------------------------------------------------------------
; RepaintSomeViews
; call WeeGUI to repaint UI elements after changing the current game
;
; in: WeeGUI loaded and initialized
; CreateViews has been called
; LoadGameInfo has been called to load new game description text
2018-03-27 21:17:47 +00:00
; out: all registers and flags clobbered
2018-02-07 14:05:24 +00:00
;------------------------------------------------------------------------------
RepaintSomeViews
2018-03-27 21:27:13 +00:00
jsr paintInfoView
jsr resetDescriptionViewScrolling
jmp paintDescriptionView
2018-02-07 14:05:24 +00:00
;------------------------------------------------------------------------------
2018-03-27 21:17:47 +00:00
; internal functions
2018-02-07 14:05:24 +00:00
2018-03-27 21:27:13 +00:00
paintHRView
2018-02-24 20:25:41 +00:00
ldx #WGSelectView
lda #ID_HR
jsr WeeGUI
2018-03-01 16:06:00 +00:00
lda #1
2018-02-24 20:25:41 +00:00
sta PARAM0
2018-03-01 16:06:00 +00:00
lda #5
2018-02-24 20:25:41 +00:00
sta PARAM1
2018-03-01 16:06:00 +00:00
lda #78
sta PARAM2
lda #0
sta PARAM3
ldy #83
ldx #WGFillRect
2018-02-24 20:25:41 +00:00
jmp WeeGUI
2018-02-07 14:05:24 +00:00
2018-03-27 21:27:13 +00:00
paintDescriptionView
2018-02-07 14:05:24 +00:00
ldx #WGSelectView
2018-02-08 02:41:07 +00:00
lda #ID_DESCRIPTION
2018-02-07 14:05:24 +00:00
jsr WeeGUI
lda addrDescription
ldy addrDescription+1
2018-02-08 21:28:49 +00:00
ldx #78
2018-03-27 21:27:13 +00:00
jsr multiPrint
lda .vtab+1
cmp #10
bcs +
lda #10
2018-03-01 16:06:00 +00:00
+ ldx #WGSetContentHeight
jmp WeeGUI
2018-03-27 21:27:13 +00:00
paintInfoView
ldx #WGSelectView
2018-02-08 21:28:49 +00:00
lda #ID_INFO
jsr WeeGUI
lda addrInfo
ldy addrInfo+1
2018-02-24 20:25:41 +00:00
ldx #65
phx
jsr multiPrint
plx
lda #$A0
- sta $3F00,x
dex
bpl -
lda #$00
sta $3F65
lda gCurrentGame
asl
tax
lda GAMES,x
sta .key1
lda GAMES+1,x
sta .key1+1
jsr okvs_get
!word gGlobalPrefsStore
.key1 !word $FDFD ; set at runtime
sta .key2
sty .key2+1
jsr okvs_get
!word gVersionsStore
.key2 !word $FDFD ; set at runtime
sta SRC
sty SRC+1
lda (SRC)
tay
- lda (SRC),y
sta $3F00,y
dey
bne -
stz $00
lda #$3F
sta $01
jmp .printLoop
2018-03-27 21:27:13 +00:00
multiPrint
2018-02-07 14:05:24 +00:00
sta $00
sty $01
2018-02-08 21:28:49 +00:00
stx .printLineLength+1
2018-02-08 02:41:07 +00:00
stz .htab+1
stz .vtab+1
2018-02-07 14:05:24 +00:00
.printLoop
lda ($00)
beq .printDone
2018-02-07 14:05:24 +00:00
ldx #WGSetCursor
.htab lda #$FD ; set at runtime
sta PARAM0
.vtab lda #$FD ; set at runtime
sta PARAM1
jsr WeeGUI
ldx #WGPrint
lda $00
sta PARAM0
lda $01
sta PARAM1
bit MAGICRTS ; set overflow bit
jsr WeeGUI
2018-02-08 21:28:49 +00:00
lda $00
clc
.printLineLength
adc #$fd ; set at runtime
sta $00
bcc +
2018-02-07 14:05:24 +00:00
inc $01
2018-02-08 21:28:49 +00:00
+ inc .vtab+1
2018-02-07 14:05:24 +00:00
bne .printLoop
.printDone
2018-02-07 14:05:24 +00:00
rts
2018-03-27 21:27:13 +00:00
resetDescriptionViewScrolling
ldx #WGSelectView
lda #ID_DESCRIPTION
jsr WeeGUI
ldx #WGScrollX
lda #0
jsr WeeGUI
ldx #WGScrollY
lda #0
jmp WeeGUI
2018-02-07 14:05:24 +00:00
.viewPrevious
!byte ID_PREVIOUS ; view ID
!byte 1 ; left
!byte 2 ; top
2018-02-24 20:25:41 +00:00
!byte 17 ; width
2018-02-07 14:05:24 +00:00
!word callback_previous ; callback
!word .stringPrevious ; caption
.stringPrevious
2018-02-24 20:25:41 +00:00
!text "< "
!byte $10 ; 'P' inverse
!text "revious game",0
2018-02-07 14:05:24 +00:00
.viewNext
!byte ID_NEXT ; view ID
2018-02-24 20:25:41 +00:00
!byte 66 ; left
2018-02-07 14:05:24 +00:00
!byte 2 ; top
!byte 13 ; width
!word callback_next ; callback
!word .stringNext ; caption
.stringNext
!byte $0E ; 'N' inverse
!text "ext game >",0
2018-02-24 20:25:41 +00:00
.viewOptions
!byte ID_OPTIONS ; view ID
!byte 34 ; left
!byte 2 ; top
!byte 12 ; width
!word callback_options ; callback
!word .stringOptions
.stringOptions
!byte $13 ; 'S' inverse
!text "ettings",0
.viewHR
!byte ID_HR ; view ID
!byte 0 ; style
!byte 1 ; left
!byte 4 ; top
!byte 78 ; visible width
!byte 1 ; visible height
!byte 78 ; width
!byte 1 ; height
2018-02-07 14:05:24 +00:00
.viewPlay
!byte ID_PLAY ; view ID
2018-02-24 20:25:41 +00:00
!byte 66 ; left
!byte 6 ; top
2018-02-07 14:05:24 +00:00
!byte 13 ; width
!word callback_play ; callback
!word .stringPlay ; caption
.stringPlay
2018-02-24 20:25:41 +00:00
!byte 144
!text "lay "
!byte $67 ; 'g' inverse
!text "ame",0
2018-02-07 14:05:24 +00:00
.viewBoxArt
!byte ID_BOXART ; view ID
!byte 66 ; left
2018-02-24 20:25:41 +00:00
!byte 8 ; top
!byte 13 ; width
2018-02-07 14:05:24 +00:00
!word callback_boxart ; callback
!word .stringBoxArt ; caption
.stringBoxArt
2018-02-24 20:25:41 +00:00
!byte $01 ; 'A' inverse
!text "rtwork",0
2018-02-07 14:05:24 +00:00
2018-02-24 20:25:41 +00:00
.viewClues
!byte ID_CLUES ; view ID
2018-02-07 14:05:24 +00:00
!byte 66 ; left
2018-02-24 20:25:41 +00:00
!byte 10 ; top
!byte 13 ; width
!word callback_clues ; callback
!word .stringClues ; caption
.stringClues
!byte $08 ; 'H' inverse
!text "ints",0
.viewVersions
!byte ID_VERSIONS ; view ID
!byte 66 ; left
!byte 12 ; top
!byte 13 ; width
!word callback_versions ; callback
!word .stringVersions ; caption
.stringVersions
!byte $12 ; 'R' inverse
!text "evisions",0
2018-02-07 14:05:24 +00:00
.viewInfo
!byte ID_INFO ; view ID
!byte 0 ; style
2018-02-24 20:25:41 +00:00
!byte 0 ; left
!byte 6 ; top
!byte 65 ; visible width
!byte 6 ; visible height
!byte 65 ; width
!byte 6 ; height
2018-02-07 14:05:24 +00:00
.viewDescription
!byte ID_DESCRIPTION ; view ID
!byte 2 ; style
!byte 1 ; left
!byte 15 ; top
!byte 77 ; visible width
!byte 8 ; visible height
!byte 77 ; width
!byte 39 ; height
2018-02-07 14:05:24 +00:00
}