Files
pitch-dark/src/ui.resume.a
2018-04-11 15:12:36 -04:00

265 lines
7.6 KiB
Plaintext

;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
; TODO call ZINFO and calculate proper height
ldy #3
sty kViewResumeFrame+3 ; frame top
iny
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
jsr CreateButton ; create UI controls
!word kViewResumeOK
jsr CreateButton
!word kViewResumeCancel
jsr CreateRadio
!word kViewResumeSlot0
jsr CreateRadio
!word kViewResumeSlot1
jsr CreateRadio
!word kViewResumeSlot2
jsr CreateRadio
!word kViewResumeSlot3
jsr CreateRadio
!word kViewResumeSlot4
jsr CreateRadio
!word kViewResumeSlot5
jsr CreateRadio
!word kViewResumeSlot6
jsr CreateRadio
!word kViewResumeSlot7
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
.runLoop
ldx #WGPendingViewAction
jsr WeeGUI
lda $c000
bpl .runLoop
bit $c010
jsr HandleResumeKey
bra .runLoop
;------------------------------------------------------------------------------
; internal functions
HandleResumeKey
ldx #.endkeys-.keys
- cmp .keys,x
beq .foundKey
dex
dex
bpl -
jmp SoftBell
.foundKey
lda .keys+1,x
ldx #WGSelectView
jsr WeeGUI
jmp SimulateClick
callback_resume_ok = LaunchInterpreterWithGame
callback_resume_cancel = MainScreen
kViewResumeFrame
!byte ID_RESUME_FRAME ; view ID
!byte 2 ; style (decorated frame)
!byte 5 ; left
!byte $FD ; top
!byte 70 ; visible width
!byte $FD ; visible height
!byte 70 ; width
!byte $FD ; height
kStringResumeFrame
!text "Resume Game",0
kViewResumeOK
!byte ID_RESUME_OK ; view ID
!byte 63 ; left
!byte $FD ; top
!byte 10 ; width
!word callback_resume_ok ; callback
!word kStringOK ; caption
kViewResumeCancel
!byte ID_RESUME_CANCEL ; view ID
!byte 63 ; left
!byte $FD ; top
!byte 10 ; width
!word callback_resume_cancel ; callback
!word kStringCancel ; caption
kViewResumeSlot0
!byte ID_RESUME_SLOT0 ; view ID
!byte 8 ; left
!byte 4 ; top
!word kStringSlot0 ; caption
kStringSlot0
!text " Slot "
!byte $30 ; '0' inverse
!text ":",0
kViewResumeSlot1
!byte ID_RESUME_SLOT1 ; view ID
!byte 8 ; left
!byte 6 ; top
!word kStringSlot1 ; caption
kStringSlot1
!text " Slot "
!byte $31 ; '1' inverse
!text ":",0
kViewResumeSlot2
!byte ID_RESUME_SLOT2 ; view ID
!byte 8 ; left
!byte 8 ; top
!word kStringSlot2 ; caption
kStringSlot2
!text " Slot "
!byte $32 ; '2' inverse
!text ":",0
kViewResumeSlot3
!byte ID_RESUME_SLOT3 ; view ID
!byte 8 ; left
!byte 10 ; top
!word kStringSlot3 ; caption
kStringSlot3
!text " Slot "
!byte $33 ; '3' inverse
!text ":",0
kViewResumeSlot4
!byte ID_RESUME_SLOT4 ; view ID
!byte 8 ; left
!byte 12 ; top
!word kStringSlot4 ; caption
kStringSlot4
!text " Slot "
!byte $34 ; '4' inverse
!text ":",0
kViewResumeSlot5
!byte ID_RESUME_SLOT5 ; view ID
!byte 8 ; left
!byte 14 ; top
!word kStringSlot5 ; caption
kStringSlot5
!text " Slot "
!byte $35 ; '5' inverse
!text ":",0
kViewResumeSlot6
!byte ID_RESUME_SLOT6 ; view ID
!byte 8 ; left
!byte 16 ; top
!word kStringSlot6 ; caption
kStringSlot6
!text " Slot "
!byte $36 ; '6' inverse
!text ":",0
kViewResumeSlot7
!byte ID_RESUME_SLOT7 ; view ID
!byte 8 ; left
!byte 18 ; top
!word kStringSlot7 ; caption
kStringSlot7
!text " Slot "
!byte $37 ; '7' inverse
!text ":",0
}