pitch-dark/src/ui.main.keys.a

200 lines
6.0 KiB
Plaintext
Raw Normal View History

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
!byte $8D,ID_PLAY ; Return
!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
2020-04-27 15:28:15 +00:00
!byte $CA,ID_CATALOG ; J
!byte $EA,ID_CATALOG ; j
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
!byte $88,ID_PREVIOUS ; left arrow
2018-02-07 14:05:24 +00:00
!byte $CE,ID_NEXT ; N
!byte $EE,ID_NEXT ; n
!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
; 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
beq @found
2018-02-07 14:05:24 +00:00
dex
dex
bpl -
@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
beq @x ; an undocumented feature
2018-03-22 20:06:31 +00:00
cmp #ID_Y
beq @y
2018-03-22 20:06:31 +00:00
cmp #ID_Z
beq @z
2018-03-29 02:49:51 +00:00
cmp #ID_SCROLLDOWN ; arrow keys scroll the description box
beq @down
lda #$01
2018-04-18 02:28:22 +00:00
+HIDE_NEXT_2_BYTES
@down lda #$FF
pha
2018-02-07 14:05:24 +00:00
ldx #WGSelectView
lda #ID_DESCRIPTION
2018-02-07 14:05:24 +00:00
jsr WeeGUI
ldx #WGScrollYBy
pla
jsr WeeGUI
bra @click
@activateView
tax
2018-04-01 22:44:00 +00:00
ldy gViewInUse,x
beq @error
ldx #WGSelectView
jsr WeeGUI
@click jmp SimulateClick
2018-04-02 19:43:11 +00:00
;------------------------------------------------------------------------------
; XYZZY handler
;------------------------------------------------------------------------------
@y lda @xyzzyCounter
2018-03-22 20:06:31 +00:00
cmp #1
beq @y1
2018-03-22 20:06:31 +00:00
cmp #4
bne @xyzzyReset
beq @xyzzyGo
@z lda @xyzzyCounter
2018-03-22 20:06:31 +00:00
cmp #2
beq @z1
2018-03-22 20:06:31 +00:00
cmp #3
beq @z2
bra @xyzzyReset
@x lda #1
2018-04-18 02:28:22 +00:00
+HIDE_NEXT_2_BYTES
@y1 lda #2
2018-04-18 02:28:22 +00:00
+HIDE_NEXT_2_BYTES
@z1 lda #3
2018-04-18 02:28:22 +00:00
+HIDE_NEXT_2_BYTES
@z2 lda #4
2018-04-18 02:28:22 +00:00
+HIDE_NEXT_2_BYTES
@xyzzyReset
2018-03-22 20:06:31 +00:00
lda #0
sta @xyzzyCounter
bra @error
@xyzzyCounter
2018-04-18 02:35:13 +00:00
!byte 0
@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)
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-04-02 19:43:11 +00:00
;------------------------------------------------------------------------------
; button callbacks
;------------------------------------------------------------------------------
GetCurrentGameIndex
jsr okvs_get ; get shortname of current game
!word gGlobalPrefsStore
!word kLastPlayed
2018-03-29 02:49:51 +00:00
+STAY +
jsr okvs_get ; get numeric index
!word gGamesListStore
2018-03-29 02:49:51 +00:00
+ !word $FDFD ; SMC
rts ; X = index of current game
2018-02-07 14:05:24 +00:00
callback_previous
jsr GetCurrentGameIndex
dex
2018-02-07 14:05:24 +00:00
bpl +
jsr okvs_len
!word gGamesListStore
2018-03-26 17:17:35 +00:00
tax
dex
+ bra loadNewGameInfoAndRepaint
2018-03-29 02:49:51 +00:00
callback_next
jsr GetCurrentGameIndex
inx
stx @n
jsr okvs_len
!word gGamesListStore
ldx @n
@n=*+1
cmp #$FD ; SMC
bne loadNewGameInfoAndRepaint
ldx #0
loadNewGameInfoAndRepaint
2018-03-29 02:49:51 +00:00
stx +
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
!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