pitch-dark/src/action.a

285 lines
7.2 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/"
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
2018-03-22 20:06:31 +00:00
ID_X = $83
ID_Y = $84
ID_Z = $85
!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-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
2018-03-22 20:06:31 +00:00
cmp #ID_X
beq .x
cmp #ID_Y
beq .y
cmp #ID_Z
beq .z
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-03-22 20:06:31 +00:00
.y
lda .xyzzy
cmp #1
beq .y1
cmp #4
bne .xyzzyReset
beq .xyzzyGo
.z
lda .xyzzy
cmp #2
beq .z1
cmp #3
beq .z2
bra .xyzzyReset
.x
lda #1
!byte $2C
.y1
lda #2
!byte $2C
.z1
lda #3
!byte $2C
.z2
lda #4
!byte $2C
.xyzzyReset
lda #0
.xyzzyStoreAndExit
sta .xyzzy
jmp SoftBell
.xyzzy
!byte $00
.xyzzyGo
ldx #WGClearScreen
jsr WeeGUI
jsr SaveGlobalPreferences
jsr ResetPath
lda #<kArtworkRootDirectory
ldy #>kArtworkRootDirectory
jsr AddToPath
jsr SetPrefix
!word gPathname
2018-03-23 17:44:34 +00:00
bcs .xyzzyError
2018-03-22 20:06:31 +00:00
jsr ResetPath
lda #<.dhrslideFilename
ldy #>.dhrslideFilename
jsr AddToPath
jsr LoadFile
!word gPathname
2018-03-23 17:44:34 +00:00
!word kSystemAddress
2018-03-22 20:06:31 +00:00
!word $2000
!word kProDOSFileBuffer
2018-03-23 17:44:34 +00:00
bcs .xyzzyError
2018-03-22 20:06:31 +00:00
jsr ExitWeeGUI
2018-03-23 17:44:34 +00:00
jmp kSystemAddress
.xyzzyError
jmp MainScreen
2018-03-22 20:06:31 +00:00
.dhrslideFilename
!byte 15
!raw "DHRSLIDE.SYSTEM"
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
2018-03-26 17:17:35 +00:00
asl
tax
lda GAMES,x
sta .gameptr
lda GAMES+1,x
sta .gameptr+1
jsr okvs_update
!word gPrefsStore
!word kLastPlayed
.gameptr !word $FDFD ; set at runtime
2018-02-07 14:05:24 +00:00
.loadNewGameInfoAndRepaint
2018-03-27 20:31:01 +00:00
lda #1
sta gNeedToSavePrefs
2018-02-07 14:05:24 +00:00
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
2018-03-26 17:17:35 +00:00
jsr okvs_get
!word gPrefsStore
!word kLastPlayed
2018-02-21 21:00:31 +00:00
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
2018-03-23 17:44:34 +00:00
bcs .boxartError
2018-02-21 21:00:31 +00:00
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
2018-03-23 17:44:34 +00:00
.boxartError
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
2018-03-23 17:44:34 +00:00
bcs .cluesError
2018-03-16 18:17:45 +00:00
; 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-23 17:44:34 +00:00
bcs .cluesError
2018-03-26 17:17:35 +00:00
2018-03-16 18:17:45 +00:00
; put just the filename at $2006
2018-03-26 17:17:35 +00:00
jsr okvs_get
!word gPrefsStore
!word kLastPlayed
2018-03-16 18:17:45 +00:00
jsr SetStartupPath
; shutdown WeeGUI and transfer control to interpreter
jsr ExitWeeGUI
jsr SetInterpreterOptionsExceptForce40
2018-03-23 17:44:34 +00:00
jmp kSystemAddress
.cluesError
jmp SoftBell
}
2018-03-16 18:17:45 +00:00
callback_play
2018-03-27 00:05:34 +00:00
jmp LaunchInterpreter