pitch-dark/src/action.a

256 lines
6.7 KiB
Plaintext
Raw Normal View History

2018-02-07 14:05:24 +00:00
;license:MIT
;(c) 2018 by 4am
;
; User interface - click/activation callbacks
;
; Public functions
; - HandleKey
;
; (all callbacks are defined in view configuration blocks in paint.a
; and triggered through UI actions or called from HandleKey)
;
!zone {
kGameRootDirectory ; length-prefixed pathname of where game subdirectories are stored
2018-02-21 21:00:31 +00:00
!byte 2
!raw "Z/"
2018-03-16 18:17:45 +00:00
kHintsRootDirectory ; length-prefixed pathname of where game subdirectories are stored
!byte 5
!raw "PRIZM/"
kHintsSuffix
!byte 3
!raw ".Z5"
2018-02-21 21:00:31 +00:00
kArtworkRootDirectory ; length-prefixed pathname of DHGR box art
!byte 8
!raw "ARTWORK/"
; action keys for main screen (should correspond to button titles in paint.a)
2018-02-07 14:05:24 +00:00
.keys
2018-02-24 20:25:41 +00:00
!byte $C7,ID_PLAY ; G
!byte $E7,ID_PLAY ; g
!byte $8D,ID_PLAY ; Return
2018-02-24 20:25:41 +00:00
!byte $C8,ID_CLUES ; H
!byte $E8,ID_CLUES ; h
!byte $C1,ID_BOXART ; A
!byte $E1,ID_BOXART ; a
!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
; IDs of actions that do not correspond to WeeGUI view IDs have high bit set
ID_SCROLLUP = $81
ID_SCROLLDOWN = $82
!byte $8B,ID_SCROLLUP ; up arrow
!byte $8A,ID_SCROLLDOWN ; down arrow
2018-02-07 14:05:24 +00:00
.endkeys
;------------------------------------------------------------------------------
; HandleKey
; handle keypress to activate various UI elements
;
; in: A contains key pressed
; out: all registers and flags clobbered
2018-02-07 14:05:24 +00:00
;------------------------------------------------------------------------------
HandleKey
ldx #.endkeys-.keys
2018-02-07 14:05:24 +00:00
- cmp .keys,x
beq .foundKey
2018-02-07 14:05:24 +00:00
dex
dex
bpl -
2018-03-16 18:17:45 +00:00
jmp SoftBell
.foundKey
lda .keys+1,x
bpl .activateView
cmp #ID_SCROLLDOWN
beq .handleScrollDown
.handleScrollUp
lda #$01
!byte $2C ; hide next LDA
.handleScrollDown
lda #$FF
pha
.handleScroll
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 .focusAndDoAction
.activateView
ldx #WGSelectView
jsr WeeGUI
.focusAndDoAction
2018-02-07 14:05:24 +00:00
ldx #WGViewFocus
jsr WeeGUI
ldx #WGViewFocusAction
jsr WeeGUI
ldx #WGViewUnfocus
jmp WeeGUI
2018-02-21 21:00:31 +00:00
}
;------------------------------------------------------------------------------
2018-02-07 14:05:24 +00:00
2018-02-21 21:00:31 +00:00
!zone {
2018-02-07 14:05:24 +00:00
callback_previous
lda gCurrentGame
dec
bpl +
lda #kNumberOfGames-1
+ sta gCurrentGame
bra .loadNewGameInfoAndRepaint
callback_next
lda gCurrentGame
inc
cmp #kNumberOfGames
bcc +
lda #0
+ sta gCurrentGame
.loadNewGameInfoAndRepaint
jsr LoadGameInfo
jmp RepaintSomeViews
2018-02-21 21:00:31 +00:00
}
2018-02-24 20:25:41 +00:00
callback_versions
rts
2018-03-16 18:17:45 +00:00
2018-02-07 14:05:24 +00:00
callback_options
2018-03-01 16:06:00 +00:00
jmp OptionsDialog
2018-02-21 21:00:31 +00:00
!zone {
callback_boxart
jsr ResetPath
lda #<kArtworkRootDirectory
ldy #>kArtworkRootDirectory
jsr AddToPath
lda gCurrentGame
asl
tax
lda GAMES, x
ldy GAMES+1, x
jsr AddToPath
2018-02-24 20:25:41 +00:00
lda #0 ; set Z flag always
!cpu 65816
rep #2 ; clear Z flag on 65816 only
!cpu 65c02
beq + ; skip GS-specific code on non-GS machines (required, will crash on //c, grr)
lda $C029
and #$1F
sta $C029 ; set GS NEWVIDEO mode to turn off linearize
+ jsr LoadDHRFile ; load artwork from file
2018-02-21 21:00:31 +00:00
!word gPathname
!word kProDOSFileBuffer
bcs .nope
sta $C000 ; display double hi-res page 1
sta $C00D
sta $C05E
sta $C057
sta $C052
sta $C054
sta $C050
bit $c010
- lda $c000
bpl -
bit $c010
sta $C001 ; back to text
sta $C051
rts
.nope
2018-03-16 18:17:45 +00:00
jmp SoftBell
2018-02-21 21:00:31 +00:00
}
!zone {
2018-03-16 18:17:45 +00:00
callback_clues
jsr SaveGlobalPreferences
2018-03-16 18:17:45 +00:00
jsr LoadInterpreter
bcs .nope
; change prefix to folder of file we want the interpreter to open
jsr ResetPath
2018-03-16 18:17:45 +00:00
lda #<kHintsRootDirectory
ldy #>kHintsRootDirectory
jsr AddToPath
2018-03-16 18:17:45 +00:00
jsr SetPrefix
!word gPathname
2018-03-16 18:17:45 +00:00
; put just the filename at $2006
jsr ResetPath
lda gCurrentGame
asl
tax
lda GAMES,x
ldy GAMES+1,x
jsr AddToPath ; hints filename = game filename + hints suffix
lda #<kHintsSuffix
ldy #>kHintsSuffix
jsr AddToPath
lda #<gPathname
ldy #>gPathname
jsr SetStartupPath
; shutdown WeeGUI and transfer control to interpreter
jsr ExitWeeGUI
jmp $2000
.nope sec
rts
callback_play
LaunchInterpreter
jsr SaveGlobalPreferences
jsr LoadInterpreter
bcs .nope
; change prefix to folder of file we want the interpreter to open
jsr ResetPath
lda #<kGameRootDirectory
ldy #>kGameRootDirectory
jsr AddToPath
lda gCurrentGame
asl
tax
lda GAMES,x
ldy GAMES+1,x
jsr AddToPath
jsr SetPrefix
!word gPathname
2018-03-16 18:17:45 +00:00
; put just the filename at $2006
ldy #0
lda addrVersions
sta $00
lda addrVersions+1
sta $01
- lda ($00),y
cmp #$BD ; '='
beq .doneBuildingFilename
iny
and #$7F
sta $2006,y
bra -
.doneBuildingFilename
sty $2006
2018-03-16 18:17:45 +00:00
; shut down WeeGUI and transfer control to interpreter
jsr ExitWeeGUI
jmp $2000
2018-03-16 18:17:45 +00:00
LoadInterpreter
jsr ResetPath
lda #<.interpreterFilename
ldy #>.interpreterFilename
jsr AddToPath
jsr LoadFile ; load interpreter at $2000
!word gPathname
!word $2000
!word $2000
!word kProDOSFileBuffer
rts
.interpreterFilename
2018-02-20 21:37:28 +00:00
!byte 15
!raw "ONBEYOND.SYSTEM"
2018-02-07 14:05:24 +00:00
}