329 lines
8.3 KiB
Plaintext
329 lines
8.3 KiB
Plaintext
;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
|
|
!byte 2
|
|
!raw "Z/"
|
|
kHintsRootDirectory ; length-prefixed pathname of where game subdirectories are stored
|
|
!byte 5
|
|
!raw "PRIZM/"
|
|
kHintsSuffix
|
|
!byte 3
|
|
!raw ".Z5"
|
|
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)
|
|
.keys
|
|
!byte $C7,ID_PLAY ; G
|
|
!byte $E7,ID_PLAY ; g
|
|
!byte $8D,ID_PLAY ; Return
|
|
!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
|
|
!byte $F3,ID_OPTIONS ; s
|
|
!byte $D0,ID_PREVIOUS ; P
|
|
!byte $F0,ID_PREVIOUS ; p
|
|
!byte $88,ID_PREVIOUS ; left arrow
|
|
!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
|
|
ID_X = $83
|
|
ID_Y = $84
|
|
ID_Z = $85
|
|
!byte $8B,ID_SCROLLUP ; up arrow
|
|
!byte $8A,ID_SCROLLDOWN ; down arrow
|
|
!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
|
|
.endkeys
|
|
|
|
;------------------------------------------------------------------------------
|
|
; HandleKey
|
|
; handle keypress to activate various UI elements
|
|
;
|
|
; in: A contains key pressed
|
|
; out: all registers and flags clobbered
|
|
;------------------------------------------------------------------------------
|
|
HandleKey
|
|
ldx #.endkeys-.keys
|
|
- cmp .keys,x
|
|
beq .foundKey
|
|
dex
|
|
dex
|
|
bpl -
|
|
jmp SoftBell
|
|
.foundKey
|
|
lda .keys+1,x
|
|
bpl .activateView
|
|
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
|
|
ldx #WGSelectView
|
|
lda #ID_DESCRIPTION
|
|
jsr WeeGUI
|
|
ldx #WGScrollYBy
|
|
pla
|
|
jsr WeeGUI
|
|
bra .focusAndDoAction
|
|
.activateView
|
|
ldx #WGSelectView
|
|
jsr WeeGUI
|
|
.focusAndDoAction
|
|
ldx #WGViewFocus
|
|
jsr WeeGUI
|
|
ldx #WGViewFocusAction
|
|
jsr WeeGUI
|
|
ldx #WGViewUnfocus
|
|
jmp WeeGUI
|
|
.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
|
|
jsr ResetPath
|
|
lda #<.dhrslideFilename
|
|
ldy #>.dhrslideFilename
|
|
jsr AddToPath
|
|
jsr LoadFile
|
|
!word gPathname
|
|
!word $2000
|
|
!word $2000
|
|
!word kProDOSFileBuffer
|
|
jsr ExitWeeGUI
|
|
jmp $2000
|
|
.dhrslideFilename
|
|
!byte 15
|
|
!raw "DHRSLIDE.SYSTEM"
|
|
|
|
}
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
!zone {
|
|
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
|
|
}
|
|
|
|
callback_versions
|
|
rts
|
|
|
|
callback_options
|
|
jmp OptionsDialog
|
|
|
|
!zone {
|
|
callback_boxart
|
|
jsr ResetPath
|
|
lda #<kArtworkRootDirectory
|
|
ldy #>kArtworkRootDirectory
|
|
jsr AddToPath
|
|
lda gCurrentGame
|
|
asl
|
|
tax
|
|
lda GAMES, x
|
|
ldy GAMES+1, x
|
|
jsr AddToPath
|
|
|
|
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
|
|
!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
|
|
jmp SoftBell
|
|
}
|
|
|
|
!zone {
|
|
callback_clues
|
|
jsr SaveGlobalPreferences
|
|
jsr LoadInterpreter
|
|
bcs .nope
|
|
; change prefix to folder of file we want the interpreter to open
|
|
jsr ResetPath
|
|
lda #<kHintsRootDirectory
|
|
ldy #>kHintsRootDirectory
|
|
jsr AddToPath
|
|
jsr SetPrefix
|
|
!word gPathname
|
|
; 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
|
|
; 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
|
|
; shut down WeeGUI and transfer control to interpreter
|
|
jsr ExitWeeGUI
|
|
jmp $2000
|
|
|
|
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
|
|
!byte 15
|
|
!raw "ONBEYOND.SYSTEM"
|
|
}
|