split out DisplayArtwork function

This commit is contained in:
4am 2018-04-02 15:43:11 -04:00
parent 94b54cf04e
commit 77a14fecc4
8 changed files with 367 additions and 76 deletions

View File

@ -11,6 +11,13 @@
; - LaunchInterpreterWithHints
;
kGameRootDirectory ; length-prefixed pathname of game subdirectories
!byte 2
!raw "Z/"
kHintsRootDirectory ; length-prefixed pathname of hint files
!byte 5
!raw "PRIZM/"
kOnBeyondOptionsStruct = $0300
kOnBeyondColumns = $0300
kOnBeyondCase = $0301

View File

@ -35,6 +35,7 @@
!source "src/ui.main.a"
!source "src/ui.main.keys.a"
!source "src/ui.options.a"
!source "src/ui.artwork.a"
Start
lda MACHID

70
src/ui.artwork.a Normal file
View File

@ -0,0 +1,70 @@
;license:MIT
;(c) 2018 by 4am
;
; User interface - functions to load and display double hi-res artwork
;
; Public functions
; - DisplayArtwork
;
kArtworkRootDirectory ; length-prefixed pathname of DHGR graphic files
!byte 8
!raw "ARTWORK/"
!zone {
;------------------------------------------------------------------------------
; DisplayArtwork
; load and display double hi-res artwork, then wait for key or mouse click
;
; in: WeeGUI initialized
; out: all registers and flags clobbered
;------------------------------------------------------------------------------
DisplayArtwork
lda #0 ; set Z flag always
!cpu 65816
rep #2 ; clear Z flag on 65816 only
!cpu 65c02
beq + ; skip GS-specific code on non-GS machines (required, will crash on //c, grr)
lda $C029
and #$1F
sta $C029 ; set GS NEWVIDEO mode to turn off linearize
+
jsr ResetPath
+LDADDR kArtworkRootDirectory
jsr AddToPath
jsr okvs_get
!word gGlobalPrefsStore
!word kLastPlayed
jsr AddToPath ; gPathname = 'ARTWORK/<game shortname>'
+ jsr LoadDHRFile ; load artwork from file
!word gPathname
!word kProDOSFileBuffer
bcs .error
sta $C000 ; display double hi-res page 1
sta $C00D
sta $C05E
sta $C001
sta $C057
sta $C052
sta $C054
sta $C050
bit $C010 ; clear keyboard strobe
ldx #WGClearPendingClick ; clear WeeGUI mouse strobe
jsr WeeGUI
.artworkRunLoop
ldx #WGPendingClick
jsr WeeGUI
cpx #$FF
bne + ; X != #$FF -> user clicked mouse
lda $C000
bpl .artworkRunLoop
+ bit $C010 ; clear keyboard strobe
ldx #WGClearPendingClick ; clear WeeGUI mouse strobe
jsr WeeGUI
sta $C051 ; back to text
rts
.error
jmp SoftBell
}

View File

@ -27,7 +27,7 @@ kStringCancel
; CreateRadio/CreateCheckbox/CreateButton
; creates a WeeGUI UI control with the 'raw title' option set
;
; in: WeeGUI loaded and initialized
; in: WeeGUI initialized
; stack contains 2 bytes of parameters:
; +1 [word] pointer to WeeGUI view configuration block
; out: $00/$01 clobbered
@ -60,7 +60,7 @@ CreateButton
; CreateDialog
; creates a WeeGUI decorated frame view
;
; in: WeeGUI loaded and initialized
; in: WeeGUI initialized
; stack contains 8 bytes of parameters:
; +1 [word] address of WeeGUI view configuration block for frame
; +3 [word] address of null-terminated string for frame title
@ -85,7 +85,7 @@ CreateDialog
; PaintTitleBar
; paints the title bar on the top line
;
; in: WeeGUI loaded and initialized
; in: WeeGUI initialized
; out: all registers and flags clobbered
;------------------------------------------------------------------------------
!zone {
@ -115,7 +115,7 @@ kStringGlobalTitle
; PrintAt
; print a null-terminated string at a specified position
;
; in: WeeGUI loaded and initialized
; in: WeeGUI initialized
; stack contains 4 bytes of parameters:
; +1 [byte] X coordinate (relative to selected view)
; +2 [byte] Y coordinate (relative to selected view)
@ -141,7 +141,7 @@ PrintAt
; SimulateClick
; select, focus, activate, and unfocus a WeeGUI view
;
; in: WeeGUI loaded and initialized
; in: WeeGUI initialized
; A contains WeeGUI view ID
; out: X clobbered
;------------------------------------------------------------------------------

View File

@ -35,7 +35,7 @@ gViewInUse
; RepaintMainIfDirty will only repaint certain views that vary between games,
; and only if gMainScreenPaintDirty=1
;
; in: WeeGUI loaded and initialized
; in: WeeGUI initialized
; out: all registers and flags clobbered
;------------------------------------------------------------------------------
!zone {
@ -155,7 +155,7 @@ RepaintMainIfDirty
; create or destroy a WeeGUI Button view, based on per-game options
; and whether the button already exists
;
; in: WeeGUI loaded and initialized
; in: WeeGUI initialized
; gOptionsStore populated
; stack contains 5 bytes of parameters:
; +1 [byte] WeeGUI view ID

View File

@ -11,16 +11,6 @@
;
!zone {
kGameRootDirectory ; length-prefixed pathname of game subdirectories
!byte 2
!raw "Z/"
kHintsRootDirectory ; length-prefixed pathname of hint files
!byte 5
!raw "PRIZM/"
kArtworkRootDirectory ; length-prefixed pathname of DHGR box art
!byte 8
!raw "ARTWORK/"
; IDs of actions that do not correspond to WeeGUI view IDs have high bit set
ID_SCROLLUP = $81
ID_SCROLLDOWN = $82
@ -101,6 +91,10 @@ HandleKey
beq .notFound
.focusAndDoAction
jmp SimulateClick
;------------------------------------------------------------------------------
; XYZZY handler
;------------------------------------------------------------------------------
.y
lda .xyzzy
cmp #1
@ -159,6 +153,9 @@ HandleKey
!raw "DHRSLIDE.SYSTEM"
}
;------------------------------------------------------------------------------
; button callbacks
;------------------------------------------------------------------------------
!zone {
GetCurrentGameIndex
jsr okvs_get ; get shortname of current game
@ -210,64 +207,7 @@ callback_next
callback_versions
rts
!zone {
callback_boxart
jsr okvs_get
!word gOptionsStore
!word kHasArtwork
jsr okvs_as_boolean
beq .boxartError
lda #0 ; set Z flag always
!cpu 65816
rep #2 ; clear Z flag on 65816 only
!cpu 65c02
beq + ; skip GS-specific code on non-GS machines (required, will crash on //c, grr)
lda $C029
and #$1F
sta $C029 ; set GS NEWVIDEO mode to turn off linearize
+
jsr ResetPath
+LDADDR kArtworkRootDirectory
jsr AddToPath
jsr okvs_get
!word gGlobalPrefsStore
!word kLastPlayed
jsr AddToPath ; gPathname = 'ARTWORK/<game shortname>'
+ jsr LoadDHRFile ; load artwork from file
!word gPathname
!word kProDOSFileBuffer
bcs .boxartError
sta $C000 ; display double hi-res page 1
sta $C00D
sta $C05E
sta $C001
sta $C057
sta $C052
sta $C054
sta $C050
bit $C010 ; clear keyboard strobe
ldx #WGClearPendingClick ; clear WeeGUI mouse strobe
jsr WeeGUI
.boxArtRunLoop
ldx #WGPendingClick
jsr WeeGUI
cpx #$FF
bne + ; X != #$FF -> user clicked mouse
lda $C000
bpl .boxArtRunLoop
+ bit $C010 ; clear keyboard strobe
ldx #WGClearPendingClick ; clear WeeGUI mouse strobe
jsr WeeGUI
sta $C051 ; back to text
rts
.boxartError
jmp SoftBell
}
callback_boxart = DisplayArtwork
callback_options = OptionsDialog
callback_clues = LaunchInterpreterWithHints
callback_play = LaunchInterpreterWithGame

View File

@ -38,7 +38,7 @@ ID_OPTIONS_CANCEL = 7
; OptionsDialog
; call WeeGUI to create and paint option screen, and run to completion
;
; in: WeeGUI loaded and initialized
; in: WeeGUI initialized
; out: exits via MainScreen
; all registers and flags clobbered
;------------------------------------------------------------------------------

273
src/ui.resume.a Normal file
View File

@ -0,0 +1,273 @@
;license:MIT
;(c) 2018 by 4am
;
; User interface - views and paint routines for 'resume game' screen
;
; Public functions
; - ResumeGameDialog
;
!zone {
; View IDs (application-specific, acceptable range 0..15, no duplicates)
ID_RESUME_FRAME = 0
ID_RESUME_SLOT0 = 1
ID_RESUME_SLOT1 = 2
ID_RESUME_SLOT2 = 3
ID_RESUME_SLOT3 = 4
ID_RESUME_SLOT4 = 5
ID_RESUME_SLOT5 = 6
ID_RESUME_SLOT6 = 7
ID_RESUME_SLOT7 = 8
ID_RESUME_NEWGAME = 9
ID_RESUME_OK = 10
ID_RESUME_CANCEL = 11
gResumeViewInUse
!byte 1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0
; action keys for options screen
.keys
!byte $CF,ID_RESUME_OK ; O
!byte $EF,ID_RESUME_OK ; o
!byte $8D,ID_RESUME_OK ; Return
!byte $C3,ID_RESUME_CANCEL ; C
!byte $E3,ID_RESUME_CANCEL ; c
!byte $9B,ID_RESUME_CANCEL ; Esc
!byte $B0,ID_RESUME_SLOT0 ; 0
!byte $B1,ID_RESUME_SLOT1 ; 1
!byte $B2,ID_RESUME_SLOT2 ; 2
!byte $B3,ID_RESUME_SLOT3 ; 3
!byte $B4,ID_RESUME_SLOT4 ; 4
!byte $B5,ID_RESUME_SLOT5 ; 5
!byte $B6,ID_RESUME_SLOT6 ; 6
!byte $B7,ID_RESUME_SLOT7 ; 7
!byte $CE,ID_RESUME_NEWGAME ; N
!byte $EE,ID_RESUME_NEWGAME ; n
!byte $88,ID_RESUME_PREVIOUS; left arrow
!byte $95,ID_RESUME_NEXT ; right arrow
!byte $8B,ID_RESUME_PREVIOUS; up arrow
!byte $8A,ID_RESUME_NEXT ; down arrow
.endkeys
; IDs of actions that do not correspond to WeeGUI view IDs have high bit set
ID_RESUME_PREVIOUS = $81
ID_RESUME_NEXT = $82
;------------------------------------------------------------------------------
; ResumeDialog
; call WeeGUI to create and paint 'resume game' screen, and run to completion
;
; in: WeeGUI initialized
; out: exits via MainScreen or LaunchInterpreterWithGame
; all registers and flags clobbered
;------------------------------------------------------------------------------
ResumeDialog
ldx #$FF
txs
ldx #WGResetAll ; reset WeeGUI
jsr WeeGUI
ldx #WGCreateView ; create frame
+LDADDR kViewResumeFrame
+STAY PARAM0
jsr WeeGUI
ldx #WGViewSetTitle
+LDADDR kStringResumeFrame
+STAY PARAM0
jsr WeeGUI
jsr CreateButton ; create UI controls
!word kViewOK
jsr CreateButton
!word kViewCancel
jsr CreateCheckbox
!word kViewForce40
jsr CreateCheckbox
!word kViewForceUpper
jsr CreateCheckbox
!word kViewScriptToFile
jsr CreateCheckbox
!word kViewAutoScript
jsr SetCheckboxByPref ; set initial state of checkboxes based on preferences
!byte ID_RESUME_FORCE40
!word kForce40
jsr SetCheckboxByPref
!byte ID_RESUME_FORCEUPPER
!word kForceUpper
jsr SetCheckboxByPref
!byte ID_RESUME_SCRIPTTOFILE
!word kScriptToFile
jsr SetCheckboxByPref
!byte ID_RESUME_AUTOSCRIPT
!word kAutoScript
ldx #WGDesktop ; paint background
jsr WeeGUI
ldx #WGViewPaintAll ; paint UI controls (window frame, buttons, checkboxes, radio buttons)
jsr WeeGUI
jsr PaintTitleBar ; paint top title bar
ldx #WGSelectView
lda #ID_RESUME_FRAME
jsr WeeGUI
ldx #WGSetCursor ; paint static text labels
lda #6
sta PARAM0
lda #3
sta PARAM1
jsr WeeGUI
ldx #WGPrint
+LDADDR kStringForce40Description
+STAY PARAM0
jsr WeeGUI
ldx #WGSetCursor
lda #6
sta PARAM0
lda #8
sta PARAM1
jsr WeeGUI
ldx #WGPrint
+LDADDR kStringForceUpperDescription
+STAY PARAM0
jsr WeeGUI
ldx #WGSetCursor
lda #6
sta PARAM0
lda #13
sta PARAM1
jsr WeeGUI
ldx #WGPrint
+LDADDR kStringScriptToFileDescription
+STAY PARAM0
jsr WeeGUI
ldx #WGSetCursor
lda #6
sta PARAM0
lda #18
sta PARAM1
jsr WeeGUI
ldx #WGPrint
+LDADDR kStringAutoScriptDescription
+STAY PARAM0
jsr WeeGUI
.runLoop
ldx #WGPendingViewAction
jsr WeeGUI
lda $c000
bpl .runLoop
bit $c010
jsr HandleOptionsKey
bra .runLoop
;------------------------------------------------------------------------------
; internal functions
HandleOptionsKey
ldx #.endkeys-.keys
- cmp .keys,x
beq .foundKey
dex
dex
bpl -
jmp SoftBell
.foundKey
lda .keys+1,x
ldx #WGSelectView
jsr WeeGUI
ldx #WGViewFocus
jsr WeeGUI
ldx #WGViewFocusAction
jsr WeeGUI
ldx #WGViewUnfocus
jmp WeeGUI
callback_resume_ok
callback_resume_cancel
jmp MainScreen
kViewResumeFrame
!byte ID_RESUME_FRAME ; view ID
!byte 2 ; style (decorated frame)
!byte $FD ; left
!byte $FD ; top
!byte $FD ; visible width
!byte $FD ; visible height
!byte 56 ; width
!byte 19 ; height
kStringResumeFrame
!text "Resume Game",0
kViewOK
!byte ID_RESUME_OK ; view ID
!byte $FD ; left
!byte $FD ; top
!byte 10 ; width
!word callback_resume_ok ; callback
!word kStringOK ; caption
kViewCancel
!byte ID_RESUME_CANCEL ; view ID
!byte 56 ; left
!byte 6 ; top
!byte 10 ; width
!word callback_resume_cancel ; callback
!word kStringCancel ; caption
kViewForce40
!byte ID_RESUME_FORCE40 ; view ID
!byte 14 ; left
!byte 4 ; top
!word kStringForce40 ; caption
kStringForce40
!text "Force "
!byte $34 ; '4' inverse
!text "0 column",0
kStringForce40Description
!text "Some games may be glitchy",0
kViewForceUpper
!byte ID_RESUME_FORCEUPPER ; view ID
!byte 14 ; left
!byte 9 ; top
!word kStringForceUpper ; caption
kStringForceUpper
!text "Force "
!byte $75 ; 'u' inverse
!text "ppercase",0
kStringForceUpperDescription
!text "A MATTER OF PREFERENCE, I SUPPOSE",0
kViewScriptToFile
!byte ID_RESUME_SCRIPTTOFILE ; view ID
!byte 14 ; left
!byte 14 ; top
!word kStringScriptToFile ; caption
kStringScriptToFile
!text "SCRIPT to "
!byte $66 ; 'f' inverse
!text "ile",0
kStringScriptToFileDescription
!text "Save transcripts to a file instead of printer",0
kViewAutoScript
!byte ID_RESUME_AUTOSCRIPT ; view ID
!byte 14 ; left
!byte 19 ; top
!word kStringAutoScript ; caption
kStringAutoScript
!text "Always "
!byte $13 ; 'S' inverse
!text "CRIPT",0
kStringAutoScriptDescription
!text "Turn on SCRIPT mode automatically",0
}