2018-04-02 19:43:11 +00:00
|
|
|
;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
|
|
|
|
|
2018-04-17 03:48:30 +00:00
|
|
|
jsr LoadSavedGameInfo
|
|
|
|
|
2018-04-11 19:12:36 +00:00
|
|
|
; TODO call ZINFO and calculate proper height
|
|
|
|
ldy #3
|
|
|
|
sty kViewResumeFrame+3 ; frame top
|
|
|
|
iny
|
2018-04-17 03:48:30 +00:00
|
|
|
sty .resumeVTAB ; top of first radio button
|
2018-04-11 19:12:36 +00:00
|
|
|
sty kViewResumeOK+2 ; OK top
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
sty kViewResumeCancel+2 ; Cancel top
|
|
|
|
ldy #19
|
|
|
|
sty kViewResumeFrame+5 ; frame visible height
|
|
|
|
sty kViewResumeFrame+7 ; frame height
|
|
|
|
|
|
|
|
jsr CreateDialog
|
|
|
|
!word kViewResumeFrame
|
|
|
|
!word kStringResumeFrame
|
2018-04-02 19:43:11 +00:00
|
|
|
|
|
|
|
jsr CreateButton ; create UI controls
|
2018-04-11 19:12:36 +00:00
|
|
|
!word kViewResumeOK
|
2018-04-02 19:43:11 +00:00
|
|
|
jsr CreateButton
|
2018-04-11 19:12:36 +00:00
|
|
|
!word kViewResumeCancel
|
|
|
|
|
2018-04-17 03:48:30 +00:00
|
|
|
jsr okvs_iter
|
|
|
|
!word gSavedGamesStore
|
|
|
|
!word CreateResumeRadioCallback
|
|
|
|
|
2018-04-11 19:12:36 +00:00
|
|
|
jsr CreateRadio
|
2018-04-17 03:48:30 +00:00
|
|
|
!word kViewResumeNewGame
|
|
|
|
|
|
|
|
; TODO set proper radio button based on ZINFO
|
|
|
|
lda #ID_RESUME_NEWGAME
|
|
|
|
ldx #WGSelectView
|
|
|
|
jsr WeeGUI
|
|
|
|
lda #1
|
|
|
|
sta PARAM0
|
|
|
|
ldx #WGSetState
|
|
|
|
jsr WeeGUI
|
2018-04-02 19:43:11 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-04-17 03:48:30 +00:00
|
|
|
ldx #WGSelectView ; select frame (required for print routines that follow)
|
2018-04-02 19:43:11 +00:00
|
|
|
lda #ID_RESUME_FRAME
|
|
|
|
jsr WeeGUI
|
|
|
|
|
2018-04-17 03:48:30 +00:00
|
|
|
lda #1 ; WeeGUI radio buttons are limited to 15 characters, so we
|
|
|
|
sta .resumeVTAB ; print the longer labels separately
|
|
|
|
jsr okvs_iter_values
|
|
|
|
!word gSavedGamesStore
|
|
|
|
!word PrintResumeLabelCallback
|
|
|
|
|
2018-04-02 19:43:11 +00:00
|
|
|
.runLoop
|
|
|
|
ldx #WGPendingViewAction
|
|
|
|
jsr WeeGUI
|
|
|
|
lda $c000
|
|
|
|
bpl .runLoop
|
|
|
|
bit $c010
|
2018-04-11 19:12:36 +00:00
|
|
|
jsr HandleResumeKey
|
2018-04-02 19:43:11 +00:00
|
|
|
bra .runLoop
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; internal functions
|
|
|
|
|
2018-04-17 03:48:30 +00:00
|
|
|
CreateResumeRadioCallback
|
|
|
|
; X = index (0-based) into gSavedGamesStore, which is also the slot number
|
|
|
|
; A/Y points to caption (length-prefixed, 0 if slot is unused and should be skipped)
|
|
|
|
;
|
|
|
|
+STAY SAVE
|
|
|
|
lda (SAVE)
|
|
|
|
sta gResumeViewInUse+1,x ; mark whether this view is in use (hotkeys activate based on this array)
|
|
|
|
beq .createResumeRadioDone; 0-length key means this slot is unused, so we're done
|
|
|
|
txa
|
|
|
|
asl
|
|
|
|
tax
|
|
|
|
lda kViewResumeArray,x
|
|
|
|
ldy kViewResumeArray+1,x
|
|
|
|
+STAY +
|
|
|
|
+STAY SRC
|
|
|
|
ldy #2
|
|
|
|
lda .resumeVTAB
|
|
|
|
sta (SRC),y ; radio button top = frame top + 1 + (2 * X)
|
|
|
|
jsr CreateRadio ; create radio button for this version (will print label later)
|
|
|
|
+ !word $FDFD ; SMC
|
|
|
|
inc .resumeVTAB
|
|
|
|
inc .resumeVTAB
|
|
|
|
.createResumeRadioDone
|
|
|
|
rts
|
|
|
|
|
|
|
|
PrintResumeLabelCallback
|
|
|
|
+STAY SAVE
|
|
|
|
lda (SAVE)
|
|
|
|
beq .printVersionLabelDone
|
|
|
|
ldx #44
|
|
|
|
lda SAVE
|
|
|
|
jsr CreateNullTerminatedString
|
|
|
|
jsr PrintAt
|
|
|
|
!byte 13 ; htab (constant)
|
|
|
|
.resumeVTAB
|
|
|
|
!byte $FD ; SMC
|
|
|
|
!word kNullTerminatedBuffer
|
|
|
|
inc .resumeVTAB
|
|
|
|
inc .resumeVTAB
|
|
|
|
.printVersionLabelDone
|
|
|
|
rts
|
|
|
|
|
2018-04-11 19:12:36 +00:00
|
|
|
HandleResumeKey
|
2018-04-02 19:43:11 +00:00
|
|
|
ldx #.endkeys-.keys
|
|
|
|
- cmp .keys,x
|
|
|
|
beq .foundKey
|
|
|
|
dex
|
|
|
|
dex
|
|
|
|
bpl -
|
|
|
|
jmp SoftBell
|
|
|
|
.foundKey
|
|
|
|
lda .keys+1,x
|
|
|
|
ldx #WGSelectView
|
|
|
|
jsr WeeGUI
|
2018-04-11 19:12:36 +00:00
|
|
|
jmp SimulateClick
|
2018-04-02 19:43:11 +00:00
|
|
|
|
2018-04-11 19:12:36 +00:00
|
|
|
callback_resume_ok = LaunchInterpreterWithGame
|
|
|
|
callback_resume_cancel = MainScreen
|
2018-04-02 19:43:11 +00:00
|
|
|
|
|
|
|
kViewResumeFrame
|
|
|
|
!byte ID_RESUME_FRAME ; view ID
|
|
|
|
!byte 2 ; style (decorated frame)
|
2018-04-11 19:12:36 +00:00
|
|
|
!byte 5 ; left
|
2018-04-02 19:43:11 +00:00
|
|
|
!byte $FD ; top
|
2018-04-11 19:12:36 +00:00
|
|
|
!byte 70 ; visible width
|
2018-04-02 19:43:11 +00:00
|
|
|
!byte $FD ; visible height
|
2018-04-11 19:12:36 +00:00
|
|
|
!byte 70 ; width
|
|
|
|
!byte $FD ; height
|
2018-04-02 19:43:11 +00:00
|
|
|
kStringResumeFrame
|
|
|
|
!text "Resume Game",0
|
|
|
|
|
2018-04-11 19:12:36 +00:00
|
|
|
kViewResumeOK
|
2018-04-02 19:43:11 +00:00
|
|
|
!byte ID_RESUME_OK ; view ID
|
2018-04-11 19:12:36 +00:00
|
|
|
!byte 63 ; left
|
2018-04-02 19:43:11 +00:00
|
|
|
!byte $FD ; top
|
|
|
|
!byte 10 ; width
|
2018-04-11 19:12:36 +00:00
|
|
|
!word callback_resume_ok ; callback
|
2018-04-02 19:43:11 +00:00
|
|
|
!word kStringOK ; caption
|
|
|
|
|
2018-04-11 19:12:36 +00:00
|
|
|
kViewResumeCancel
|
|
|
|
!byte ID_RESUME_CANCEL ; view ID
|
|
|
|
!byte 63 ; left
|
|
|
|
!byte $FD ; top
|
2018-04-02 19:43:11 +00:00
|
|
|
!byte 10 ; width
|
|
|
|
!word callback_resume_cancel ; callback
|
|
|
|
!word kStringCancel ; caption
|
|
|
|
|
2018-04-17 03:48:30 +00:00
|
|
|
kViewResumeArray
|
|
|
|
!word kViewResumeSlot0
|
|
|
|
!word kViewResumeSlot1
|
|
|
|
!word kViewResumeSlot2
|
|
|
|
!word kViewResumeSlot3
|
|
|
|
!word kViewResumeSlot4
|
|
|
|
!word kViewResumeSlot5
|
|
|
|
!word kViewResumeSlot6
|
|
|
|
!word kViewResumeSlot7
|
|
|
|
|
2018-04-11 19:12:36 +00:00
|
|
|
kViewResumeSlot0
|
|
|
|
!byte ID_RESUME_SLOT0 ; view ID
|
|
|
|
!byte 8 ; left
|
2018-04-02 19:43:11 +00:00
|
|
|
!byte 4 ; top
|
2018-04-11 19:12:36 +00:00
|
|
|
!word kStringSlot0 ; caption
|
|
|
|
|
|
|
|
kViewResumeSlot1
|
|
|
|
!byte ID_RESUME_SLOT1 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 6 ; top
|
|
|
|
!word kStringSlot1 ; caption
|
|
|
|
|
|
|
|
kViewResumeSlot2
|
|
|
|
!byte ID_RESUME_SLOT2 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 8 ; top
|
|
|
|
!word kStringSlot2 ; caption
|
|
|
|
|
|
|
|
kViewResumeSlot3
|
|
|
|
!byte ID_RESUME_SLOT3 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 10 ; top
|
|
|
|
!word kStringSlot3 ; caption
|
|
|
|
|
|
|
|
kViewResumeSlot4
|
|
|
|
!byte ID_RESUME_SLOT4 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 12 ; top
|
|
|
|
!word kStringSlot4 ; caption
|
|
|
|
|
|
|
|
kViewResumeSlot5
|
|
|
|
!byte ID_RESUME_SLOT5 ; view ID
|
|
|
|
!byte 8 ; left
|
2018-04-02 19:43:11 +00:00
|
|
|
!byte 14 ; top
|
2018-04-11 19:12:36 +00:00
|
|
|
!word kStringSlot5 ; caption
|
|
|
|
|
|
|
|
kViewResumeSlot6
|
|
|
|
!byte ID_RESUME_SLOT6 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 16 ; top
|
|
|
|
!word kStringSlot6 ; caption
|
|
|
|
|
|
|
|
kViewResumeSlot7
|
|
|
|
!byte ID_RESUME_SLOT7 ; view ID
|
|
|
|
!byte 8 ; left
|
2018-04-17 03:48:30 +00:00
|
|
|
!byte 18 ; top
|
2018-04-11 19:12:36 +00:00
|
|
|
!word kStringSlot7 ; caption
|
|
|
|
|
2018-04-17 03:48:30 +00:00
|
|
|
kViewResumeNewGame
|
|
|
|
!byte ID_RESUME_NEWGAME ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 20 ; top
|
|
|
|
!word kStringNewGame ; caption
|
|
|
|
|
|
|
|
kStringSlot0
|
|
|
|
!text " Slot ",$30,":",0
|
|
|
|
|
|
|
|
kStringSlot1
|
|
|
|
!text " Slot ",$31,":",0
|
|
|
|
|
|
|
|
kStringSlot2
|
|
|
|
!text " Slot ",$32,":",0
|
|
|
|
|
|
|
|
kStringSlot3
|
|
|
|
!text " Slot ",$33,":",0
|
|
|
|
|
|
|
|
kStringSlot4
|
|
|
|
!text " Slot ",$34,":",0
|
|
|
|
|
|
|
|
kStringSlot5
|
|
|
|
!text " Slot ",$35,":",0
|
|
|
|
|
|
|
|
kStringSlot6
|
|
|
|
!text " Slot ",$36,":",0
|
|
|
|
|
2018-04-11 19:12:36 +00:00
|
|
|
kStringSlot7
|
2018-04-17 03:48:30 +00:00
|
|
|
!text " Slot ",$37,":",0
|
|
|
|
|
|
|
|
kStringNewGame
|
|
|
|
!text " Start ",110,"ew game",0
|
2018-04-02 19:43:11 +00:00
|
|
|
}
|