;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/" 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 $E3,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 !byte $8B,ID_SCROLLUP ; up arrow !byte $8A,ID_SCROLLDOWN ; down arrow .endkeys BELL = $FF3A ;------------------------------------------------------------------------------ ; 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 - rts .foundKey lda .keys+1,x bpl .activateView cmp #ID_SCROLLUP beq .handleScrollUp cmp #ID_SCROLLDOWN beq .handleScrollDown rts .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 } ;------------------------------------------------------------------------------ !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_clues rts callback_options rts !zone { callback_boxart jsr ResetPath lda #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 BELL } !zone { callback_play LaunchInterpreter jsr SaveGlobalPreferences jsr ResetPath lda #<.interpreterFilename ldy #>.interpreterFilename jsr AddToPath jsr LoadFile ; load interpreter at $2000 !word gPathname !word $2000 !word $2000 !word kProDOSFileBuffer bcs .nope ; change prefix to folder of file we want the interpreter to open jsr ResetPath lda #kGameRootDirectory jsr AddToPath lda gCurrentGame asl tax lda GAMES,x ldy GAMES+1,x jsr AddToPath jsr SetPrefix !word gPathname ; put .z3 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 jsr ExitWeeGUI jmp $2000 .nope sec rts .interpreterFilename !byte 15 !raw "ONBEYOND.SYSTEM" }