;license:MIT ;(c) 2018 by 4am ; ; User interface - views and paint routines for main screen ; ; Public functions ; - CreateViews ; - PaintAllViews ; - RepaintSomeViews ; MAGICRTS = $FF58 ; used to set overflow bit ; View IDs (application-specific, acceptable range 0..15, no duplicates) ; ID_TITLE is defined in ui.common.a 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 ID_DESCRIPTION = 13 !zone { ;------------------------------------------------------------------------------ ; CreateViews ; call WeeGUI to create all application views ; ; in: WeeGUI loaded and initialized ; out: all registers and flags clobbered ;------------------------------------------------------------------------------ CreateViews jsr CreateTitleView ldx #WGCreateView ; create horizontal rule +LDADDR .viewHR +STAY PARAM0 jsr WeeGUI jsr CreateButton ; create various buttons !word .viewPrevious jsr CreateButton !word .viewNext jsr CreateButton !word .viewPlay jsr CreateButton !word .viewVersions jsr CreateButton !word .viewBoxArt jsr CreateButton !word .viewClues jsr CreateButton !word .viewOptions ldx #WGCreateView ; create borderless frame for game title and info +LDADDR .viewInfo +STAY PARAM0 jsr WeeGUI ldx #WGViewSetAction +LDADDR paintInfoView +STAY PARAM0 jsr WeeGUI ldx #WGCreateView ; create scrollable frame for game description text +LDADDR .viewDescription +STAY PARAM0 jsr WeeGUI ldx #WGViewSetAction +LDADDR paintDescriptionView +STAY PARAM0 jmp WeeGUI ;------------------------------------------------------------------------------ ; PaintAllViews ; call WeeGUI to paint all UI elements ; ; in: WeeGUI loaded and initialized ; CreateViews has been called ; out: all registers and flags clobbered ; $00/$01 clobbered ;------------------------------------------------------------------------------ PaintAllViews ldx #WGViewPaintAll ; repaint all views that can be painted automatically jsr WeeGUI jsr PaintTitleView jsr paintHRView jsr paintInfoView jmp paintDescriptionView ;------------------------------------------------------------------------------ ; 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 ; out: all registers and flags clobbered ;------------------------------------------------------------------------------ RepaintSomeViews jsr paintInfoView jsr resetDescriptionViewScrolling jmp paintDescriptionView ;------------------------------------------------------------------------------ ; internal functions paintHRView ldx #WGSelectView lda #ID_HR jsr WeeGUI lda #1 sta PARAM0 lda #5 sta PARAM1 lda #78 sta PARAM2 lda #0 sta PARAM3 ldy #83 ldx #WGFillRect jmp WeeGUI paintDescriptionView ldx #WGSelectView lda #ID_DESCRIPTION jsr WeeGUI +LDAY addrDescription ldx #kDescriptionPaintWidth jsr multiPrint lda .vtab+1 cmp #10 bcs + lda #10 + ldx #WGSetContentHeight jmp WeeGUI paintInfoView ldx #WGSelectView lda #ID_INFO jsr WeeGUI +LDAY addrInfo ldx #kInfoPaintWidth jsr multiPrint jsr okvs_get ; get shortname of current game !word gGlobalPrefsStore !word kLastPlayed +STAY + ; A/Y contains address jsr okvs_get ; get selected version of this game !word gGlobalPrefsStore + !word $FDFD ; SMC +STAY + ; A/Y contains address jsr okvs_get ; get long description of this version !word gVersionsStore + !word $FDFD ; SMC ; A/Y contains address ldx #kInfoPaintWidth jsr CreateNullTerminatedString +LDADDR kNullTerminatedBuffer bra multiPrintWhereYouAre multiPrint stx .printLineLength+1 stz .htab+1 stz .vtab+1 multiPrintWhereYouAre +STAY $00 .printLoop lda ($00) beq .printDone ldx #WGSetCursor .htab lda #$FD ; SMC sta PARAM0 .vtab lda #$FD ; SMC sta PARAM1 jsr WeeGUI ldx #WGPrint lda $00 sta PARAM0 lda $01 sta PARAM1 bit MAGICRTS ; set overflow bit jsr WeeGUI lda $00 clc .printLineLength adc #$fd ; SMC sta $00 bcc + inc $01 + inc .vtab+1 bne .printLoop .printDone rts resetDescriptionViewScrolling ldx #WGSelectView lda #ID_DESCRIPTION jsr WeeGUI ldx #WGScrollX lda #0 jsr WeeGUI ldx #WGScrollY lda #0 jmp WeeGUI .viewPrevious !byte ID_PREVIOUS ; view ID !byte 1 ; left !byte 2 ; top !byte 17 ; width !word callback_previous ; callback !word .stringPrevious ; caption .stringPrevious !text "< " !byte $10 ; 'P' inverse !text "revious game",0 .viewNext !byte ID_NEXT ; view ID !byte 66 ; left !byte 2 ; top !byte 13 ; width !word callback_next ; callback !word .stringNext ; caption .stringNext !byte $0E ; 'N' inverse !text "ext game >",0 .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 .viewPlay !byte ID_PLAY ; view ID !byte 66 ; left !byte 6 ; top !byte 13 ; width !word callback_play ; callback !word .stringPlay ; caption .stringPlay !byte 144 !text "lay " !byte $67 ; 'g' inverse !text "ame",0 .viewBoxArt !byte ID_BOXART ; view ID !byte 66 ; left !byte 8 ; top !byte 13 ; width !word callback_boxart ; callback !word .stringBoxArt ; caption .stringBoxArt !byte $01 ; 'A' inverse !text "rtwork",0 .viewClues !byte ID_CLUES ; view ID !byte 66 ; left !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 .viewInfo !byte ID_INFO ; view ID !byte 0 ; style !byte 0 ; left !byte 6 ; top !byte 65 ; visible width !byte 6 ; visible height !byte 65 ; width !byte 6 ; height .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 }