2018-04-11 19:12:36 +00:00
|
|
|
;license:MIT
|
|
|
|
;(c) 2018 by 4am
|
|
|
|
;
|
|
|
|
; User interface - views and paint routines for versions screen
|
|
|
|
;
|
|
|
|
; Public functions
|
|
|
|
; - VersionsDialog
|
|
|
|
;
|
|
|
|
|
|
|
|
; View IDs (application-specific, acceptable range 0..15, no duplicates)
|
|
|
|
ID_VERSIONS_FRAME = 0
|
|
|
|
ID_VERSIONS_1 = 1 ; WARNING lots of logic in this screen assumes that the radio
|
|
|
|
ID_VERSIONS_2 = 2 ; buttons for each version are sequentially numbered starting at 1
|
|
|
|
ID_VERSIONS_3 = 3 ; and it would be very difficult to untangle if that suddenly
|
|
|
|
ID_VERSIONS_4 = 4 ; stopped being true
|
|
|
|
ID_VERSIONS_5 = 5
|
|
|
|
ID_VERSIONS_6 = 6
|
|
|
|
ID_VERSIONS_7 = 7
|
|
|
|
ID_VERSIONS_8 = 8
|
|
|
|
ID_VERSIONS_9 = 9
|
|
|
|
ID_VERSIONS_OK = 10
|
|
|
|
ID_VERSIONS_CANCEL = 11
|
|
|
|
|
2018-04-11 23:02:44 +00:00
|
|
|
; action keys for versions screen
|
2018-04-18 19:28:55 +00:00
|
|
|
kVersionsKeys
|
2018-04-11 19:12:36 +00:00
|
|
|
!byte $CF,ID_VERSIONS_OK ; O
|
|
|
|
!byte $EF,ID_VERSIONS_OK ; o
|
|
|
|
!byte $8D,ID_VERSIONS_OK ; Return
|
|
|
|
!byte $C3,ID_VERSIONS_CANCEL; C
|
|
|
|
!byte $E3,ID_VERSIONS_CANCEL; c
|
|
|
|
!byte $9B,ID_VERSIONS_CANCEL; Esc
|
|
|
|
!byte $B1,ID_VERSIONS_1 ; 1
|
|
|
|
!byte $B2,ID_VERSIONS_2 ; 2
|
|
|
|
!byte $B3,ID_VERSIONS_3 ; 3
|
|
|
|
!byte $B4,ID_VERSIONS_4 ; 4
|
|
|
|
!byte $B5,ID_VERSIONS_5 ; 5
|
|
|
|
!byte $B6,ID_VERSIONS_6 ; 6
|
|
|
|
!byte $B7,ID_VERSIONS_7 ; 7
|
|
|
|
!byte $B8,ID_VERSIONS_8 ; 8
|
|
|
|
!byte $B9,ID_VERSIONS_9 ; 9
|
2018-04-19 18:41:39 +00:00
|
|
|
!byte $88,ID_RADIO_PREVIOUS ; left arrow
|
|
|
|
!byte $95,ID_RADIO_NEXT ; right arrow
|
|
|
|
!byte $8B,ID_RADIO_PREVIOUS ; up arrow
|
|
|
|
!byte $8A,ID_RADIO_NEXT ; down arrow
|
2018-04-18 19:28:55 +00:00
|
|
|
_endVersionsKeys
|
2018-04-11 19:12:36 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; VersionsDialog
|
|
|
|
; call WeeGUI to create and paint 'select version' dialog, and run to completion
|
|
|
|
;
|
|
|
|
; in: WeeGUI initialized
|
|
|
|
; out: exits via MainScreen
|
|
|
|
; all registers and flags clobbered
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
VersionsDialog
|
|
|
|
ldx #$FF
|
|
|
|
txs
|
2018-04-17 19:43:00 +00:00
|
|
|
jsr HardResetWeeGUI
|
2018-04-11 19:12:36 +00:00
|
|
|
|
|
|
|
jsr okvs_len
|
|
|
|
!word gVersionsStore
|
2018-04-17 20:08:32 +00:00
|
|
|
sta iNumVersions
|
2018-04-11 19:12:36 +00:00
|
|
|
|
2018-04-11 22:55:28 +00:00
|
|
|
asl
|
|
|
|
inc
|
|
|
|
sta kViewVersionsFrame+5 ; frame visible height = 1 + (2 * numVersions)
|
|
|
|
sta kViewVersionsFrame+7 ; frame height
|
|
|
|
lda #12
|
|
|
|
sec
|
2018-04-17 20:08:32 +00:00
|
|
|
sbc iNumVersions
|
2018-04-11 22:55:28 +00:00
|
|
|
sta kViewVersionsFrame+3 ; frame top = 12 - numVersions
|
|
|
|
inc
|
|
|
|
sta kViewVersionsOK+2 ; OK top = frame top + 1
|
|
|
|
inc
|
|
|
|
inc
|
|
|
|
sta kViewVersionsCancel+2 ; Cancel top = OK top + 2
|
2018-04-11 19:12:36 +00:00
|
|
|
|
2018-04-19 18:41:39 +00:00
|
|
|
jsr CreateDialog ; create decorated frame
|
2018-04-11 19:12:36 +00:00
|
|
|
!word kViewVersionsFrame
|
|
|
|
!word kStringVersionsFrame
|
|
|
|
|
|
|
|
jsr CreateButton ; create UI controls
|
|
|
|
!word kViewVersionsOK
|
|
|
|
jsr CreateButton
|
|
|
|
!word kViewVersionsCancel
|
|
|
|
|
2018-04-11 22:55:28 +00:00
|
|
|
ldx #0 ; X = index of radio button (0-based)
|
2018-04-11 19:12:36 +00:00
|
|
|
.createRadioLoop
|
|
|
|
phx
|
|
|
|
txa
|
|
|
|
asl
|
|
|
|
tax
|
2018-04-11 23:02:44 +00:00
|
|
|
lda kViewVersionsArray,x
|
|
|
|
ldy kViewVersionsArray+1,x
|
2018-04-11 19:12:36 +00:00
|
|
|
+STAY +
|
2018-04-11 22:55:28 +00:00
|
|
|
+STAY SRC
|
|
|
|
txa
|
|
|
|
inc
|
|
|
|
clc
|
|
|
|
adc kViewVersionsFrame+3
|
|
|
|
ldy #2
|
|
|
|
sta (SRC),y ; radio button top = frame top + 1 + (2 * X)
|
2018-04-11 19:12:36 +00:00
|
|
|
jsr CreateRadio ; create radio button for this version (will print label later)
|
|
|
|
+ !word $FDFD ; SMC
|
|
|
|
plx
|
|
|
|
inx
|
2018-04-17 20:08:32 +00:00
|
|
|
iNumVersions=*+1
|
2018-04-11 19:12:36 +00:00
|
|
|
cpx #$FD ; SMC
|
|
|
|
bne .createRadioLoop
|
|
|
|
|
2018-04-11 23:02:44 +00:00
|
|
|
jsr okvs_get ; get current version and check appropriate radio button
|
2018-04-11 19:12:36 +00:00
|
|
|
!word gGlobalPrefsStore
|
|
|
|
!word kLastPlayed
|
|
|
|
+STAY +
|
|
|
|
jsr okvs_get
|
|
|
|
!word gGlobalPrefsStore
|
|
|
|
+ !word $FDFD ; SMC
|
|
|
|
+STAY +
|
|
|
|
jsr okvs_get
|
|
|
|
!word gVersionsStore
|
|
|
|
+ !word $FDFD ; SMC
|
|
|
|
; X = 0-based index of current version in the list of versions for this game
|
|
|
|
inx ; X = 1-based index of current version, which is the WeeGUI view ID
|
|
|
|
txa
|
|
|
|
ldx #WGSelectView
|
|
|
|
jsr WeeGUI
|
|
|
|
lda #1
|
|
|
|
sta PARAM0
|
|
|
|
ldx #WGSetState
|
|
|
|
jsr WeeGUI
|
|
|
|
|
|
|
|
ldx #WGDesktop ; paint background
|
|
|
|
jsr WeeGUI
|
|
|
|
|
|
|
|
jsr PaintTitleBar ; paint top title bar
|
|
|
|
|
|
|
|
ldx #WGViewPaintAll ; paint UI controls (window frame, buttons, checkboxes, radio buttons)
|
|
|
|
jsr WeeGUI
|
|
|
|
|
|
|
|
ldx #WGSelectView ; select frame (required for print routines that follow)
|
|
|
|
lda #ID_VERSIONS_FRAME
|
|
|
|
jsr WeeGUI
|
|
|
|
|
2018-04-15 16:29:24 +00:00
|
|
|
lda #1 ; WeeGUI radio buttons are limited to 15 characters, so we have just the
|
2018-04-17 20:08:32 +00:00
|
|
|
sta iVersionsVTAB ; hotkeys (1-9) 'in' the radio button then print the labels separately
|
2018-04-13 02:54:51 +00:00
|
|
|
jsr okvs_iter_values
|
2018-04-11 19:12:36 +00:00
|
|
|
!word gVersionsStore
|
2018-04-13 02:54:51 +00:00
|
|
|
!word PrintVersionLabelCallback
|
2018-04-11 19:12:36 +00:00
|
|
|
|
2018-04-17 20:16:45 +00:00
|
|
|
jsr ClearPendingInput
|
2018-04-19 02:01:24 +00:00
|
|
|
- ldx #WGPendingViewAction
|
2018-04-11 19:12:36 +00:00
|
|
|
jsr WeeGUI ; handle mouse movement and clicks
|
|
|
|
lda $C000
|
2018-04-19 02:01:24 +00:00
|
|
|
bpl -
|
2018-04-17 20:16:45 +00:00
|
|
|
jsr ClearPendingInput
|
2018-04-11 19:12:36 +00:00
|
|
|
jsr HandleVersionsKey ; handle keypresses
|
2018-04-19 02:01:24 +00:00
|
|
|
bra -
|
2018-04-11 19:12:36 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; internal functions
|
|
|
|
|
2018-04-19 18:46:06 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; HandleVersionsKey
|
|
|
|
;
|
|
|
|
; in: A = key pressed
|
|
|
|
; out: all registers and flags clobbered
|
|
|
|
;------------------------------------------------------------------------------
|
2018-04-11 19:12:36 +00:00
|
|
|
HandleVersionsKey
|
2018-06-20 22:58:05 +00:00
|
|
|
ldx #(_endVersionsKeys-kVersionsKeys)-2
|
2018-04-18 19:28:55 +00:00
|
|
|
- cmp kVersionsKeys,x
|
2018-04-19 14:05:48 +00:00
|
|
|
beq @found
|
2018-04-11 19:12:36 +00:00
|
|
|
dex
|
|
|
|
dex
|
|
|
|
bpl -
|
2018-04-19 14:05:48 +00:00
|
|
|
@error jmp SoftBell
|
|
|
|
@found lda kVersionsKeys+1,x ; get action ID associated with this key
|
|
|
|
bmi @updown
|
2018-04-19 02:01:24 +00:00
|
|
|
tax ; action ID < #$80 is a WeeGUI view, so activate it
|
2018-04-19 18:41:39 +00:00
|
|
|
ldy gViewInUse,x
|
2018-04-19 14:05:48 +00:00
|
|
|
beq @error
|
2018-04-19 02:01:24 +00:00
|
|
|
ldx #WGSelectView
|
|
|
|
jsr WeeGUI
|
|
|
|
jmp SimulateClick
|
2018-04-19 18:41:39 +00:00
|
|
|
@updown ldx #ID_VERSIONS_1
|
|
|
|
ldy iNumVersions
|
|
|
|
jmp HandleUpDownRadio
|
2018-04-11 19:12:36 +00:00
|
|
|
|
2018-04-18 19:28:55 +00:00
|
|
|
PrintVersionLabelCallback
|
|
|
|
; called via okvs_iter_values
|
|
|
|
; X = index (0-based) into gVersionsStore
|
|
|
|
; A/Y points to okvs record value, which we use to create a printable label
|
|
|
|
ldx #50
|
|
|
|
jsr CreateNullTerminatedString
|
|
|
|
jsr PrintAt
|
|
|
|
!byte 7 ; htab (constant)
|
|
|
|
iVersionsVTAB
|
|
|
|
!byte $FD ; SMC
|
|
|
|
!word kNullTerminatedBuffer
|
|
|
|
inc iVersionsVTAB
|
|
|
|
inc iVersionsVTAB
|
|
|
|
rts
|
|
|
|
|
|
|
|
VersionsOKCallback
|
2018-04-19 18:41:39 +00:00
|
|
|
ldx #ID_VERSIONS_1
|
|
|
|
ldy iNumVersions
|
|
|
|
jsr GetCheckedRadioButton ; figure out which radio button is checked
|
2018-04-11 19:12:36 +00:00
|
|
|
dec
|
2018-04-19 14:05:48 +00:00
|
|
|
sta @n
|
2018-04-11 19:12:36 +00:00
|
|
|
jsr okvs_nth
|
|
|
|
!word gVersionsStore
|
2018-04-19 14:05:48 +00:00
|
|
|
@n !byte $FD ; SMC
|
|
|
|
+STAY @value
|
2018-04-11 19:12:36 +00:00
|
|
|
jsr okvs_get
|
|
|
|
!word gGlobalPrefsStore
|
|
|
|
!word kLastPlayed
|
2018-04-19 14:05:48 +00:00
|
|
|
+STAY @key
|
2018-04-11 19:12:36 +00:00
|
|
|
jsr okvs_update
|
|
|
|
!word gGlobalPrefsStore
|
2018-04-19 14:05:48 +00:00
|
|
|
@key !word $FDFD ; SMC
|
|
|
|
@value !word $FDFD ; SMC
|
2018-04-11 19:12:36 +00:00
|
|
|
|
|
|
|
lda #1
|
|
|
|
sta gGlobalPrefsDirty ; must set, otherwise SaveGlobalPreferences does nothing
|
|
|
|
jsr SaveGlobalPreferences ; immediately write new preferences to disk
|
2018-04-18 19:28:55 +00:00
|
|
|
jsr CheckForSavedGames ; recheck whether the newly selected version has saved games (affects painting in main screen)
|
|
|
|
jmp MainScreen ; exit via main screen
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; WeeGUI view configuration records
|
2018-04-11 19:12:36 +00:00
|
|
|
|
|
|
|
kViewVersionsFrame
|
2018-04-11 23:02:44 +00:00
|
|
|
!byte ID_VERSIONS_FRAME ; view ID
|
2018-04-11 19:12:36 +00:00
|
|
|
!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
|
|
|
|
|
|
|
|
kViewVersionsOK
|
|
|
|
!byte ID_VERSIONS_OK ; view ID
|
|
|
|
!byte 63 ; left
|
|
|
|
!byte $FD ; top
|
|
|
|
!byte 10 ; width
|
2018-04-18 19:28:55 +00:00
|
|
|
!word VersionsOKCallback ; callback
|
2018-04-11 19:12:36 +00:00
|
|
|
!word kStringOK ; caption
|
|
|
|
|
|
|
|
kViewVersionsCancel
|
|
|
|
!byte ID_VERSIONS_CANCEL ; view ID
|
|
|
|
!byte 63 ; left
|
|
|
|
!byte $FD ; top
|
|
|
|
!byte 10 ; width
|
2018-04-18 19:28:55 +00:00
|
|
|
!word MainScreen ; callback
|
2018-04-11 19:12:36 +00:00
|
|
|
!word kStringCancel ; caption
|
|
|
|
|
2018-04-11 23:02:44 +00:00
|
|
|
kViewVersionsArray
|
2018-04-11 19:12:36 +00:00
|
|
|
!word kViewVersions1
|
|
|
|
!word kViewVersions2
|
|
|
|
!word kViewVersions3
|
|
|
|
!word kViewVersions4
|
|
|
|
!word kViewVersions5
|
|
|
|
!word kViewVersions6
|
|
|
|
!word kViewVersions7
|
|
|
|
!word kViewVersions8
|
|
|
|
!word kViewVersions9
|
|
|
|
|
|
|
|
kViewVersions1
|
|
|
|
!byte ID_VERSIONS_1 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 4 ; top
|
|
|
|
!word kString1 ; caption
|
|
|
|
|
|
|
|
kViewVersions2
|
|
|
|
!byte ID_VERSIONS_2 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 6 ; top
|
|
|
|
!word kString2 ; caption
|
|
|
|
|
|
|
|
kViewVersions3
|
|
|
|
!byte ID_VERSIONS_3 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 8 ; top
|
|
|
|
!word kString3 ; caption
|
|
|
|
|
|
|
|
kViewVersions4
|
|
|
|
!byte ID_VERSIONS_4 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 10 ; top
|
|
|
|
!word kString4 ; caption
|
|
|
|
|
|
|
|
kViewVersions5
|
|
|
|
!byte ID_VERSIONS_5 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 12 ; top
|
|
|
|
!word kString5 ; caption
|
|
|
|
|
|
|
|
kViewVersions6
|
|
|
|
!byte ID_VERSIONS_6 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 14 ; top
|
|
|
|
!word kString6 ; caption
|
|
|
|
|
|
|
|
kViewVersions7
|
|
|
|
!byte ID_VERSIONS_7 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 16 ; top
|
|
|
|
!word kString7 ; caption
|
|
|
|
|
|
|
|
kViewVersions8
|
|
|
|
!byte ID_VERSIONS_8 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 18 ; top
|
|
|
|
!word kString8 ; caption
|
|
|
|
|
|
|
|
kViewVersions9
|
|
|
|
!byte ID_VERSIONS_9 ; view ID
|
|
|
|
!byte 8 ; left
|
|
|
|
!byte 20 ; top
|
|
|
|
!word kString9 ; caption
|
|
|
|
|
2018-04-18 19:28:55 +00:00
|
|
|
kStringVersionsFrame
|
|
|
|
!text "Select Version",0
|
2018-04-17 03:48:30 +00:00
|
|
|
kString1
|
|
|
|
!text " ",$31,0
|
|
|
|
kString2
|
|
|
|
!text " ",$32,0
|
|
|
|
kString3
|
|
|
|
!text " ",$33,0
|
|
|
|
kString4
|
|
|
|
!text " ",$34,0
|
|
|
|
kString5
|
|
|
|
!text " ",$35,0
|
|
|
|
kString6
|
|
|
|
!text " ",$36,0
|
|
|
|
kString7
|
|
|
|
!text " ",$37,0
|
|
|
|
kString8
|
|
|
|
!text " ",$38,0
|
2018-04-11 19:12:36 +00:00
|
|
|
kString9
|
2018-04-17 03:48:30 +00:00
|
|
|
!text " ",$39,0
|