2020-04-22 20:41:59 +00:00
|
|
|
;license:MIT
|
2022-01-18 18:46:15 +00:00
|
|
|
;(c) 2020-2 by 4am
|
2020-04-22 20:41:59 +00:00
|
|
|
;
|
2020-09-26 02:59:55 +00:00
|
|
|
; main menu
|
2020-04-22 20:41:59 +00:00
|
|
|
;
|
|
|
|
; Public functions:
|
2020-09-24 02:24:49 +00:00
|
|
|
; - MainMenuEventLoop
|
2020-04-22 20:41:59 +00:00
|
|
|
;
|
|
|
|
|
2020-07-10 01:20:08 +00:00
|
|
|
; Codes returned by event handlers
|
|
|
|
kStayOnMainMenu = 0
|
2022-01-18 14:17:46 +00:00
|
|
|
kQuit = 1
|
2020-07-10 01:20:08 +00:00
|
|
|
|
|
|
|
kMainMenuKeys ; must keep in sync with kMainMenuKeyHandlersLo/Hi arrays
|
|
|
|
; except for last byte ($00) which doesn't need an associated handler
|
2020-09-26 02:59:55 +00:00
|
|
|
!byte $8D ; Return
|
|
|
|
!byte $C3 ; C
|
|
|
|
!byte $E3 ; c
|
|
|
|
!byte $D3 ; S
|
|
|
|
!byte $F3 ; s
|
2022-01-18 02:34:13 +00:00
|
|
|
!byte $93 ; Ctrl-S
|
2020-09-26 02:59:55 +00:00
|
|
|
!byte $C4 ; D
|
|
|
|
!byte $E4 ; d
|
|
|
|
!byte $D1 ; Q
|
|
|
|
!byte $F1 ; q
|
|
|
|
!byte $9B ; Esc
|
2020-07-10 01:20:08 +00:00
|
|
|
!byte $00
|
|
|
|
|
|
|
|
kMainMenuKeyHandlersLo
|
|
|
|
!byte <MainMenuEventReturn
|
|
|
|
!byte <MainMenuEventC
|
|
|
|
!byte <MainMenuEventC
|
|
|
|
!byte <MainMenuEventS
|
|
|
|
!byte <MainMenuEventS
|
2022-01-18 02:34:13 +00:00
|
|
|
!byte <MainMenuEventS
|
2020-09-26 02:59:55 +00:00
|
|
|
!byte <MainMenuEventD
|
|
|
|
!byte <MainMenuEventD
|
2020-07-10 01:20:08 +00:00
|
|
|
!byte <MainMenuEventQ
|
|
|
|
!byte <MainMenuEventQ
|
|
|
|
!byte <MainMenuEventQ
|
|
|
|
|
|
|
|
kMainMenuKeyHandlersHi
|
|
|
|
!byte >MainMenuEventReturn
|
|
|
|
!byte >MainMenuEventC
|
|
|
|
!byte >MainMenuEventC
|
|
|
|
!byte >MainMenuEventS
|
|
|
|
!byte >MainMenuEventS
|
2022-01-18 02:34:13 +00:00
|
|
|
!byte >MainMenuEventS
|
2020-09-26 02:59:55 +00:00
|
|
|
!byte >MainMenuEventD
|
|
|
|
!byte >MainMenuEventD
|
2020-07-10 01:20:08 +00:00
|
|
|
!byte >MainMenuEventQ
|
|
|
|
!byte >MainMenuEventQ
|
|
|
|
!byte >MainMenuEventQ
|
|
|
|
|
2020-09-24 02:24:49 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; MainMenuEventLoop
|
|
|
|
; display main menu
|
|
|
|
;
|
2020-04-22 20:41:59 +00:00
|
|
|
; in: C clear if screen is already cleared and title is already drawn
|
|
|
|
; (will happen if animated title screen runs to completion)
|
|
|
|
; C set if full screen clear & redraw is required
|
|
|
|
; (will happen if key is pressed during title screen, or
|
2022-01-18 14:17:46 +00:00
|
|
|
; if user returns to main menu from any other screen)
|
|
|
|
; out: Z = 0
|
2020-09-24 02:24:49 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
MainMenuEventLoop
|
2020-05-04 02:36:06 +00:00
|
|
|
bcc +
|
2020-07-10 01:20:08 +00:00
|
|
|
jsr DrawMainMenuTitle
|
|
|
|
+ jsr DrawMainMenuText
|
2020-05-05 01:46:19 +00:00
|
|
|
bit CLEARKBD
|
2022-01-18 03:29:27 +00:00
|
|
|
@musicloop
|
2020-09-26 02:59:55 +00:00
|
|
|
+LDADDR kMainMenuKeys
|
|
|
|
+ST16 $EE
|
2020-05-04 02:36:06 +00:00
|
|
|
+LDADDR MainMenuMusic
|
2020-09-26 02:59:55 +00:00
|
|
|
jsr PlaySound
|
2022-01-18 03:29:27 +00:00
|
|
|
bpl @musicloop ; music played to completion, no keypress, so start over
|
2020-05-04 02:36:06 +00:00
|
|
|
bit CLEARKBD
|
2020-10-02 01:35:55 +00:00
|
|
|
sta gLastKeyPressed
|
2020-07-10 01:20:08 +00:00
|
|
|
ldx #0
|
2022-01-18 03:29:27 +00:00
|
|
|
@keyloop
|
|
|
|
ldy kMainMenuKeys, x
|
2022-01-18 14:17:46 +00:00
|
|
|
beq @musicloop ; key has no associated handler, so ignore it
|
2020-07-10 01:20:08 +00:00
|
|
|
cpy gLastKeyPressed
|
2022-01-18 03:29:27 +00:00
|
|
|
beq @dispatch
|
2020-07-10 01:20:08 +00:00
|
|
|
inx
|
2022-01-18 14:17:46 +00:00
|
|
|
bne @keyloop ; always branches
|
2022-01-18 03:29:27 +00:00
|
|
|
@dispatch
|
|
|
|
lda kMainMenuKeyHandlersLo, x
|
2020-07-10 01:20:08 +00:00
|
|
|
sta @j+1
|
|
|
|
lda kMainMenuKeyHandlersHi, x
|
|
|
|
sta @j+2
|
|
|
|
@j jsr $FDFD ; SMC
|
|
|
|
beq MainMenuEventLoop
|
2020-05-04 02:36:06 +00:00
|
|
|
rts
|
2020-07-10 01:20:08 +00:00
|
|
|
|
|
|
|
MainMenuEventReturn
|
2022-01-18 14:17:46 +00:00
|
|
|
sec ; C=1 to trigger full redraw of 'select world' page
|
|
|
|
jsr SelectWorldEventLoop
|
|
|
|
jmp StayOnMainMenuWithFullRefresh
|
2020-07-10 01:20:08 +00:00
|
|
|
|
2020-09-26 02:59:55 +00:00
|
|
|
MainMenuEventD
|
|
|
|
jsr RunDemo
|
2022-01-18 14:17:46 +00:00
|
|
|
jmp StayOnMainMenuWithFullRefresh
|
2020-09-26 02:59:55 +00:00
|
|
|
|
2020-07-10 01:20:08 +00:00
|
|
|
MainMenuEventC
|
2020-05-04 16:56:05 +00:00
|
|
|
jsr AboutPage
|
2022-01-18 14:17:46 +00:00
|
|
|
StayOnMainMenuWithFullRefresh
|
|
|
|
ldx #kStayOnMainMenu ; Z=1 so caller will stay in main menu event loop
|
2020-07-10 01:20:08 +00:00
|
|
|
sec ; C=1 so caller will do a full screen refresh
|
|
|
|
rts
|
|
|
|
|
|
|
|
MainMenuEventS
|
2022-01-16 16:34:56 +00:00
|
|
|
jsr ToggleSoundPref
|
2020-07-10 01:20:08 +00:00
|
|
|
ldx #kStayOnMainMenu ; Z=1 so caller will stay in main menu event loop
|
|
|
|
clc ; C=0 so caller will only do a partial screen refresh
|
|
|
|
rts
|
|
|
|
|
|
|
|
MainMenuEventQ
|
2022-01-18 14:17:46 +00:00
|
|
|
ldx #kQuit ; Z=0 so caller will exit main menu event loop
|
2020-07-10 01:20:08 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
DrawMainMenuTitle
|
2020-04-22 20:41:59 +00:00
|
|
|
jsr Home
|
2020-04-28 02:45:54 +00:00
|
|
|
lda #1
|
|
|
|
sta GlobalLeftMargin
|
2020-04-22 20:41:59 +00:00
|
|
|
ldy #3
|
|
|
|
- ldx #1
|
2020-09-26 02:59:55 +00:00
|
|
|
lda sTitleLine1-2, y
|
2020-04-22 20:41:59 +00:00
|
|
|
jsr DrawLargeCharacter
|
|
|
|
inx
|
2020-09-26 02:59:55 +00:00
|
|
|
lda sTitleLine2-2, y
|
2020-04-22 20:41:59 +00:00
|
|
|
jsr DrawLargeCharacter
|
|
|
|
inx
|
2020-09-26 02:59:55 +00:00
|
|
|
lda sTitleLine3-2, y
|
2020-04-22 20:41:59 +00:00
|
|
|
jsr DrawLargeCharacter
|
|
|
|
iny
|
|
|
|
cpy #$0A
|
|
|
|
bne -
|
2020-05-04 02:34:12 +00:00
|
|
|
rts
|
2020-07-10 01:20:08 +00:00
|
|
|
|
|
|
|
DrawMainMenuText
|
2020-09-26 02:59:55 +00:00
|
|
|
+PRINT_AT sAsterisk, 2, 30
|
|
|
|
+PRINT_AT sVersion, 11, 26
|
|
|
|
+PRINT_AT sMainMenuPlay, 15, 10
|
|
|
|
+PRINT_AT sMainMenuSound, 16, 10
|
2020-05-05 01:46:19 +00:00
|
|
|
lda gSoundPref
|
|
|
|
beq @theSoundOfSilence
|
2020-09-26 02:59:55 +00:00
|
|
|
+LDADDR sMainMenuSoundOn
|
2020-05-05 01:46:19 +00:00
|
|
|
bne + ; always branches
|
|
|
|
@theSoundOfSilence
|
2020-09-26 02:59:55 +00:00
|
|
|
+LDADDR sMainMenuSoundOff
|
2020-05-05 01:46:19 +00:00
|
|
|
+ jsr DrawHeavySilkString
|
2020-09-26 02:59:55 +00:00
|
|
|
+PRINT_AT sMainMenuAbout, 17, 10
|
|
|
|
+PRINT_AT sMainMenuDemo, 18, 10
|
|
|
|
+PRINT_AT sMainMenuQuit, 19, 10
|
|
|
|
+PRINT_AT sMainMenuDisclaimer, 23, 0
|
2020-04-24 03:39:00 +00:00
|
|
|
rts
|