pitch-dark/src/ui.main.a

346 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-02-24 20:25:41 +00:00
ID_PREVIOUS = 1
ID_OPTIONS = 2
ID_NEXT = 3
ID_PLAY = 4
ID_BOXART = 5
ID_HINTS = 6
ID_VERSIONS = 7
ID_INFO = 8
ID_DESCRIPTION = 9
gViewInUse
!byte 0,1,1,1,1,0,0,0,1,1,0,0,0,0,0
2018-02-07 14:05:24 +00:00
!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 CreateButton ; create various buttons
2018-02-07 14:05:24 +00:00
!word .viewPrevious
2018-03-01 16:06:00 +00:00
jsr CreateButton
!word .viewOptions
jsr CreateButton
2018-02-07 14:05:24 +00:00
!word .viewNext
lda gHasSavedGames
beq .wantPlayButton
2018-03-01 16:06:00 +00:00
jsr CreateButton
!word .viewResume
bra .donePlayOrResume
.wantPlayButton
2018-03-01 16:06:00 +00:00
jsr CreateButton
!word .viewPlay
.donePlayOrResume
jsr CreateConditionalButton
!byte ID_BOXART
2018-02-07 14:05:24 +00:00
!word .viewBoxArt
!word kHasArtwork
jsr CreateConditionalButton
!byte ID_HINTS
!word .viewHints
!word kHasHints
jsr CreateConditionalButton
!byte ID_VERSIONS
!word .viewVersions
!word kHasVersions
2018-02-07 14:05:24 +00:00
ldx #WGCreateView ; create borderless frame for game title and info
2018-03-29 02:49:51 +00:00
+LDADDR .viewInfo
+STAY PARAM0
2018-02-07 14:05:24 +00:00
jsr WeeGUI
ldx #WGViewSetAction
2018-03-29 02:49:51 +00:00
+LDADDR paintInfoView
+STAY PARAM0
2018-02-07 14:05:24 +00:00
jsr WeeGUI
ldx #WGCreateView ; create scrollable frame for game description text
2018-03-29 02:49:51 +00:00
+LDADDR .viewDescription
+STAY PARAM0
2018-02-07 14:05:24 +00:00
jsr WeeGUI
ldx #WGViewSetAction
2018-03-29 02:49:51 +00:00
+LDADDR paintDescriptionView
+STAY PARAM0
2018-02-07 14:05:24 +00:00
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
jsr PaintTitleBar
jsr paintHR
2018-03-27 21:27:13 +00:00
jsr paintInfoView
jmp paintDescriptionView
2018-02-07 14:05:24 +00:00
;------------------------------------------------------------------------------
; RepaintIfDirty
2018-02-07 14:05:24 +00:00
; 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
;------------------------------------------------------------------------------
RepaintIfDirty
lda gMainScreenPaintDirty
beq +
jsr CreateViews
ldx #WGViewPaintAll
jsr WeeGUI
2018-03-27 21:27:13 +00:00
jsr paintInfoView
jsr resetDescriptionViewScrolling
jsr paintDescriptionView
stz gMainScreenPaintDirty
+ rts
gMainScreenPaintDirty
!byte 0
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
paintHR
lda #4
2018-02-24 20:25:41 +00:00
sta PARAM1
ldy #78
lda #83
- sty PARAM0
ldx #WGSetGlobalCursor
jsr WeeGUI
ldx #WGPlot
jsr WeeGUI
dey
bne -
ldx #WGSyncGlobalCursor
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
2018-03-29 02:49:51 +00:00
+LDAY addrDescription
ldx #kDescriptionPaintWidth
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
2018-03-29 02:49:51 +00:00
+LDAY addrInfo
ldx #kInfoPaintWidth
jsr multiPrint
2018-03-28 15:48:47 +00:00
jsr okvs_get ; get shortname of current game
!word gGlobalPrefsStore
!word kLastPlayed
2018-03-31 14:22:09 +00:00
+STAY + ; A/Y contains address
2018-03-28 15:48:47 +00:00
jsr okvs_get ; get selected version of this game
!word gGlobalPrefsStore
2018-03-29 02:49:51 +00:00
+ !word $FDFD ; SMC
2018-03-31 14:22:09 +00:00
+STAY + ; A/Y contains address
2018-03-28 15:48:47 +00:00
jsr okvs_get ; get long description of this version
!word gVersionsStore
2018-03-29 02:49:51 +00:00
+ !word $FDFD ; SMC
2018-03-31 14:22:09 +00:00
; A/Y contains address
ldx #kInfoPaintWidth
jsr CreateNullTerminatedString
+LDADDR kNullTerminatedBuffer
bra multiPrintWhereYouAre
2018-03-27 21:27:13 +00:00
multiPrint
2018-02-08 02:41:07 +00:00
stz .htab+1
stz .vtab+1
2018-03-31 14:22:09 +00:00
multiPrintWhereYouAre
2018-03-31 14:28:36 +00:00
stx .printLineLength+1
2018-03-31 14:22:09 +00:00
+STAY $00
2018-02-07 14:05:24 +00:00
.printLoop
lda ($00)
beq .printDone
2018-02-07 14:05:24 +00:00
ldx #WGSetCursor
2018-03-28 15:48:47 +00:00
.htab lda #$FD ; SMC
2018-02-07 14:05:24 +00:00
sta PARAM0
2018-03-28 15:48:47 +00:00
.vtab lda #$FD ; SMC
2018-02-07 14:05:24 +00:00
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
2018-03-28 15:48:47 +00:00
adc #$fd ; SMC
2018-02-08 21:28:49 +00:00
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
!byte 13 ; 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",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
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
.viewResume
!byte ID_PLAY ; view ID
!byte 66 ; left
!byte 6 ; top
!byte 13 ; width
!word callback_resume ; callback
!word .stringResume ; caption
.stringResume
!byte 146
!text "esume "
!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
.viewHints
!byte ID_HINTS ; 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 .stringHints ; caption
.stringHints
2018-02-24 20:25:41 +00:00
!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
}