2018-02-07 14:05:24 +00:00
|
|
|
;license:MIT
|
|
|
|
;(c) 2018 by 4am
|
|
|
|
;
|
2018-03-27 20:55:31 +00:00
|
|
|
; User interface - click/activation callbacks and key handlers for main screen
|
2018-02-07 14:05:24 +00:00
|
|
|
;
|
|
|
|
; Public functions
|
|
|
|
; - HandleKey
|
|
|
|
;
|
2018-03-27 20:55:31 +00:00
|
|
|
; (all callbacks are defined in view configuration blocks
|
2018-02-07 14:05:24 +00:00
|
|
|
; and triggered through UI actions or called from HandleKey)
|
|
|
|
;
|
|
|
|
|
2018-03-27 20:55:31 +00:00
|
|
|
; IDs of actions that do not correspond to WeeGUI view IDs have high bit set
|
|
|
|
ID_SCROLLUP = $81
|
|
|
|
ID_SCROLLDOWN = $82
|
|
|
|
ID_X = $83
|
|
|
|
ID_Y = $84
|
|
|
|
ID_Z = $85
|
|
|
|
|
|
|
|
; action keys for main screen (should correspond to button titles)
|
2018-04-18 19:28:55 +00:00
|
|
|
kMainKeys
|
2018-02-24 20:25:41 +00:00
|
|
|
!byte $C7,ID_PLAY ; G
|
|
|
|
!byte $E7,ID_PLAY ; g
|
2018-02-07 21:02:14 +00:00
|
|
|
!byte $8D,ID_PLAY ; Return
|
2018-04-01 16:21:48 +00:00
|
|
|
!byte $C8,ID_HINTS ; H
|
|
|
|
!byte $E8,ID_HINTS ; h
|
2018-02-24 20:25:41 +00:00
|
|
|
!byte $C1,ID_BOXART ; A
|
|
|
|
!byte $E1,ID_BOXART ; a
|
2018-04-11 19:12:36 +00:00
|
|
|
!byte $D6,ID_VERSIONS ; V
|
|
|
|
!byte $F6,ID_VERSIONS ; v
|
2018-08-17 04:10:43 +00:00
|
|
|
!byte $C3,ID_CATALOG ; C
|
|
|
|
!byte $E3,ID_CATALOG ; c
|
2018-02-24 20:25:41 +00:00
|
|
|
!byte $D3,ID_OPTIONS ; S
|
2018-03-01 16:06:00 +00:00
|
|
|
!byte $F3,ID_OPTIONS ; s
|
2018-02-24 20:25:41 +00:00
|
|
|
!byte $D0,ID_PREVIOUS ; P
|
|
|
|
!byte $F0,ID_PREVIOUS ; p
|
2018-02-07 21:02:14 +00:00
|
|
|
!byte $88,ID_PREVIOUS ; left arrow
|
2018-02-07 14:05:24 +00:00
|
|
|
!byte $CE,ID_NEXT ; N
|
|
|
|
!byte $EE,ID_NEXT ; n
|
2018-02-07 21:02:14 +00:00
|
|
|
!byte $95,ID_NEXT ; right arrow
|
|
|
|
!byte $8B,ID_SCROLLUP ; up arrow
|
|
|
|
!byte $8A,ID_SCROLLDOWN ; down arrow
|
2018-03-22 20:06:31 +00:00
|
|
|
!byte $D8,ID_X ; X
|
|
|
|
!byte $F8,ID_X ; x
|
|
|
|
!byte $D9,ID_Y ; Y
|
|
|
|
!byte $F9,ID_Y ; y
|
|
|
|
!byte $DA,ID_Z ; Z
|
|
|
|
!byte $FA,ID_Z ; z
|
2018-06-20 22:58:05 +00:00
|
|
|
!byte $BF,ID_ABOUT ; ?
|
2018-04-18 19:28:55 +00:00
|
|
|
_endMainKeys
|
2018-02-07 14:05:24 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; HandleKey
|
2018-04-18 19:28:55 +00:00
|
|
|
; handle keypresses in main screen
|
2018-02-07 14:05:24 +00:00
|
|
|
;
|
|
|
|
; in: A contains key pressed
|
2018-02-09 01:38:26 +00:00
|
|
|
; out: all registers and flags clobbered
|
2018-02-07 14:05:24 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
HandleKey
|
2018-06-20 22:58:05 +00:00
|
|
|
ldx #(_endMainKeys-kMainKeys)-2
|
2018-04-18 19:28:55 +00:00
|
|
|
- cmp kMainKeys,x
|
2018-04-19 14:05:48 +00:00
|
|
|
beq @found
|
2018-02-07 14:05:24 +00:00
|
|
|
dex
|
|
|
|
dex
|
|
|
|
bpl -
|
2018-04-19 14:05:48 +00:00
|
|
|
@error jmp SoftBell ; unknown key, beep softly
|
|
|
|
@found lda kMainKeys+1,x ; get ID associated with this key
|
|
|
|
bpl @activateView ; ID < #$80 is a WeeGUI view, so activate it
|
2018-03-29 02:49:51 +00:00
|
|
|
cmp #ID_X ; X, Y, and Z keys are part of
|
2018-04-19 14:05:48 +00:00
|
|
|
beq @x ; an undocumented feature
|
2018-03-22 20:06:31 +00:00
|
|
|
cmp #ID_Y
|
2018-04-19 14:05:48 +00:00
|
|
|
beq @y
|
2018-03-22 20:06:31 +00:00
|
|
|
cmp #ID_Z
|
2018-04-19 14:05:48 +00:00
|
|
|
beq @z
|
2018-03-29 02:49:51 +00:00
|
|
|
cmp #ID_SCROLLDOWN ; arrow keys scroll the description box
|
2018-04-19 14:05:48 +00:00
|
|
|
beq @down
|
2018-02-07 21:02:14 +00:00
|
|
|
lda #$01
|
2018-04-18 02:28:22 +00:00
|
|
|
+HIDE_NEXT_2_BYTES
|
2018-04-19 14:05:48 +00:00
|
|
|
@down lda #$FF
|
2018-02-07 21:02:14 +00:00
|
|
|
pha
|
2018-02-07 14:05:24 +00:00
|
|
|
ldx #WGSelectView
|
2018-02-07 21:02:14 +00:00
|
|
|
lda #ID_DESCRIPTION
|
2018-02-07 14:05:24 +00:00
|
|
|
jsr WeeGUI
|
2018-02-07 21:02:14 +00:00
|
|
|
ldx #WGScrollYBy
|
|
|
|
pla
|
|
|
|
jsr WeeGUI
|
2018-04-19 14:05:48 +00:00
|
|
|
bra @click
|
|
|
|
@activateView
|
2018-04-01 16:21:48 +00:00
|
|
|
tax
|
2018-04-01 22:44:00 +00:00
|
|
|
ldy gViewInUse,x
|
2018-04-19 14:05:48 +00:00
|
|
|
beq @error
|
2018-04-10 17:32:49 +00:00
|
|
|
ldx #WGSelectView
|
|
|
|
jsr WeeGUI
|
2018-04-19 14:05:48 +00:00
|
|
|
@click jmp SimulateClick
|
2018-04-02 19:43:11 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; XYZZY handler
|
|
|
|
;------------------------------------------------------------------------------
|
2018-04-19 14:05:48 +00:00
|
|
|
@y lda @xyzzyCounter
|
2018-03-22 20:06:31 +00:00
|
|
|
cmp #1
|
2018-04-19 14:05:48 +00:00
|
|
|
beq @y1
|
2018-03-22 20:06:31 +00:00
|
|
|
cmp #4
|
2018-04-19 14:05:48 +00:00
|
|
|
bne @xyzzyReset
|
|
|
|
beq @xyzzyGo
|
|
|
|
@z lda @xyzzyCounter
|
2018-03-22 20:06:31 +00:00
|
|
|
cmp #2
|
2018-04-19 14:05:48 +00:00
|
|
|
beq @z1
|
2018-03-22 20:06:31 +00:00
|
|
|
cmp #3
|
2018-04-19 14:05:48 +00:00
|
|
|
beq @z2
|
|
|
|
bra @xyzzyReset
|
|
|
|
@x lda #1
|
2018-04-18 02:28:22 +00:00
|
|
|
+HIDE_NEXT_2_BYTES
|
2018-04-19 14:05:48 +00:00
|
|
|
@y1 lda #2
|
2018-04-18 02:28:22 +00:00
|
|
|
+HIDE_NEXT_2_BYTES
|
2018-04-19 14:05:48 +00:00
|
|
|
@z1 lda #3
|
2018-04-18 02:28:22 +00:00
|
|
|
+HIDE_NEXT_2_BYTES
|
2018-04-19 14:05:48 +00:00
|
|
|
@z2 lda #4
|
2018-04-18 02:28:22 +00:00
|
|
|
+HIDE_NEXT_2_BYTES
|
2018-04-19 14:05:48 +00:00
|
|
|
@xyzzyReset
|
2018-03-22 20:06:31 +00:00
|
|
|
lda #0
|
2018-04-19 14:05:48 +00:00
|
|
|
sta @xyzzyCounter
|
|
|
|
bra @error
|
|
|
|
@xyzzyCounter
|
2018-04-18 02:35:13 +00:00
|
|
|
!byte 0
|
2018-04-19 14:05:48 +00:00
|
|
|
@xyzzyGo
|
2018-03-22 20:06:31 +00:00
|
|
|
jsr SaveGlobalPreferences
|
|
|
|
jsr ResetPath
|
2018-03-29 02:49:51 +00:00
|
|
|
+LDADDR kArtworkRootDirectory
|
2018-03-22 20:06:31 +00:00
|
|
|
jsr AddToPath
|
2018-04-18 02:35:13 +00:00
|
|
|
|
|
|
|
jsr SetPrefix ; must set ProDOS prefix to directory where DHGR files actually are
|
|
|
|
!word gPathname ; (DHRSLIDE does not look in subdirectories)
|
2018-04-19 14:05:48 +00:00
|
|
|
bcs @error
|
2018-04-18 02:35:13 +00:00
|
|
|
|
2018-03-22 20:06:31 +00:00
|
|
|
jsr ResetPath
|
2018-04-18 02:35:13 +00:00
|
|
|
+LDADDR kDHRSLIDEFilename
|
2018-03-22 20:06:31 +00:00
|
|
|
jsr AddToPath
|
2018-04-18 02:35:13 +00:00
|
|
|
|
|
|
|
jsr LoadFile ; load DHRSLIDE program at $2000
|
2018-03-22 20:06:31 +00:00
|
|
|
!word gPathname
|
2018-03-23 17:44:34 +00:00
|
|
|
!word kSystemAddress
|
2018-03-22 20:06:31 +00:00
|
|
|
!word kProDOSFileBuffer
|
2018-04-18 02:35:13 +00:00
|
|
|
|
|
|
|
jsr ExitWeeGUI ; shut down WeeGUI
|
|
|
|
jmp kSystemAddress ; exit via DHRSLIDE
|
|
|
|
|
|
|
|
kDHRSLIDEFilename
|
2018-03-22 20:06:31 +00:00
|
|
|
!byte 15
|
|
|
|
!raw "DHRSLIDE.SYSTEM"
|
2018-02-07 21:02:14 +00:00
|
|
|
|
2018-04-02 19:43:11 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; button callbacks
|
|
|
|
;------------------------------------------------------------------------------
|
2018-03-28 18:09:39 +00:00
|
|
|
GetCurrentGameIndex
|
|
|
|
jsr okvs_get ; get shortname of current game
|
|
|
|
!word gGlobalPrefsStore
|
|
|
|
!word kLastPlayed
|
2018-03-29 02:49:51 +00:00
|
|
|
+STAY +
|
2018-03-28 18:09:39 +00:00
|
|
|
jsr okvs_get ; get numeric index
|
|
|
|
!word gGamesListStore
|
2018-03-29 02:49:51 +00:00
|
|
|
+ !word $FDFD ; SMC
|
2018-03-28 18:09:39 +00:00
|
|
|
rts ; X = index of current game
|
|
|
|
|
2018-02-07 14:05:24 +00:00
|
|
|
callback_previous
|
2018-03-28 18:09:39 +00:00
|
|
|
jsr GetCurrentGameIndex
|
|
|
|
dex
|
2018-02-07 14:05:24 +00:00
|
|
|
bpl +
|
2018-03-28 18:09:39 +00:00
|
|
|
jsr okvs_len
|
|
|
|
!word gGamesListStore
|
2018-03-26 17:17:35 +00:00
|
|
|
tax
|
2018-03-28 18:09:39 +00:00
|
|
|
dex
|
2018-04-19 14:05:48 +00:00
|
|
|
+ bra loadNewGameInfoAndRepaint
|
2018-03-29 02:49:51 +00:00
|
|
|
|
2018-03-28 18:09:39 +00:00
|
|
|
callback_next
|
|
|
|
jsr GetCurrentGameIndex
|
|
|
|
inx
|
2018-04-19 14:05:48 +00:00
|
|
|
stx @n
|
2018-03-28 18:09:39 +00:00
|
|
|
jsr okvs_len
|
|
|
|
!word gGamesListStore
|
2018-04-19 14:05:48 +00:00
|
|
|
ldx @n
|
|
|
|
@n=*+1
|
2018-03-28 18:09:39 +00:00
|
|
|
cmp #$FD ; SMC
|
2018-04-19 14:05:48 +00:00
|
|
|
bne loadNewGameInfoAndRepaint
|
2018-03-28 18:09:39 +00:00
|
|
|
ldx #0
|
2018-04-19 14:05:48 +00:00
|
|
|
|
|
|
|
loadNewGameInfoAndRepaint
|
2018-03-29 02:49:51 +00:00
|
|
|
stx +
|
2018-03-28 18:09:39 +00:00
|
|
|
jsr okvs_nth
|
|
|
|
!word gGamesListStore
|
2018-03-29 02:49:51 +00:00
|
|
|
+ !byte $FD ; SMC
|
|
|
|
+STAY +
|
2018-03-26 17:17:35 +00:00
|
|
|
jsr okvs_update
|
2018-03-28 02:40:09 +00:00
|
|
|
!word gGlobalPrefsStore
|
2018-03-26 17:17:35 +00:00
|
|
|
!word kLastPlayed
|
2018-03-29 02:49:51 +00:00
|
|
|
+ !word $FDFD ; SMC
|
2018-03-27 20:31:01 +00:00
|
|
|
lda #1
|
2018-04-01 22:26:54 +00:00
|
|
|
sta gGlobalPrefsDirty ; will trigger a file write later
|
|
|
|
sta gMainScreenPaintDirty ; will trigger a repaint later, in main run loop
|
|
|
|
jmp LoadGameInfo ; load new game info first
|