mirror of
https://github.com/a2-4am/million-perfect-letters.git
synced 2024-06-02 22:41:33 +00:00
161 lines
5.0 KiB
Plaintext
161 lines
5.0 KiB
Plaintext
;license:MIT
|
|
;(c) 2020 by 4am
|
|
;
|
|
; main menu
|
|
;
|
|
; Public functions:
|
|
; - MainMenuEventLoop
|
|
;
|
|
|
|
; Codes returned by event handlers
|
|
kStayOnMainMenu = 0
|
|
kRequestedQuit = 1
|
|
kStartPlaying = 2
|
|
|
|
kMainMenuKeys ; must keep in sync with kMainMenuKeyHandlersLo/Hi arrays
|
|
; except for last byte ($00) which doesn't need an associated handler
|
|
!byte $8D ; Return
|
|
!byte $C3 ; C
|
|
!byte $E3 ; c
|
|
!byte $D3 ; S
|
|
!byte $F3 ; s
|
|
!byte $93 ; Ctrl-S
|
|
!byte $C4 ; D
|
|
!byte $E4 ; d
|
|
!byte $D1 ; Q
|
|
!byte $F1 ; q
|
|
!byte $9B ; Esc
|
|
!byte $00
|
|
|
|
kMainMenuKeyHandlersLo
|
|
!byte <MainMenuEventReturn
|
|
!byte <MainMenuEventC
|
|
!byte <MainMenuEventC
|
|
!byte <MainMenuEventS
|
|
!byte <MainMenuEventS
|
|
!byte <MainMenuEventS
|
|
!byte <MainMenuEventD
|
|
!byte <MainMenuEventD
|
|
!byte <MainMenuEventQ
|
|
!byte <MainMenuEventQ
|
|
!byte <MainMenuEventQ
|
|
|
|
kMainMenuKeyHandlersHi
|
|
!byte >MainMenuEventReturn
|
|
!byte >MainMenuEventC
|
|
!byte >MainMenuEventC
|
|
!byte >MainMenuEventS
|
|
!byte >MainMenuEventS
|
|
!byte >MainMenuEventS
|
|
!byte >MainMenuEventD
|
|
!byte >MainMenuEventD
|
|
!byte >MainMenuEventQ
|
|
!byte >MainMenuEventQ
|
|
!byte >MainMenuEventQ
|
|
|
|
;------------------------------------------------------------------------------
|
|
; MainMenuEventLoop
|
|
; display main menu
|
|
;
|
|
; 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
|
|
; if user returns to main menu from play or any other screen)
|
|
; out: C clear if user selected a world to play, and
|
|
; A = world ID
|
|
; C set if user selected quit
|
|
;------------------------------------------------------------------------------
|
|
MainMenuEventLoop
|
|
bcc +
|
|
jsr DrawMainMenuTitle
|
|
+ jsr DrawMainMenuText
|
|
bit CLEARKBD
|
|
-
|
|
+LDADDR kMainMenuKeys
|
|
+ST16 $EE
|
|
+LDADDR MainMenuMusic
|
|
jsr PlaySound
|
|
bpl - ; music played to completion, no keypress, so start over
|
|
bit CLEARKBD
|
|
sta gLastKeyPressed
|
|
ldx #0
|
|
- ldy kMainMenuKeys, x
|
|
cpy gLastKeyPressed
|
|
beq +
|
|
inx
|
|
bne -
|
|
+ lda kMainMenuKeyHandlersLo, x
|
|
sta @j+1
|
|
lda kMainMenuKeyHandlersHi, x
|
|
sta @j+2
|
|
@j jsr $FDFD ; SMC
|
|
beq MainMenuEventLoop
|
|
rts
|
|
|
|
MainMenuEventReturn
|
|
jsr SelectWorld
|
|
bcs + ; in next event handler
|
|
ldx #kStartPlaying ; Z=0 so caller will exit main menu event loop
|
|
; C=0 so grand-caller will start playing
|
|
; A=world ID (from SelectWorld)
|
|
rts
|
|
|
|
MainMenuEventD
|
|
jsr RunDemo
|
|
bne + ; always branches
|
|
|
|
MainMenuEventC
|
|
jsr AboutPage
|
|
+ ldx #kStayOnMainMenu ; Z=1 so caller will stay in main menu event loop
|
|
sec ; C=1 so caller will do a full screen refresh
|
|
rts
|
|
|
|
MainMenuEventS
|
|
jsr ToggleSoundPref
|
|
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
|
|
ldx #kRequestedQuit ; Z=0 so caller will exit main menu event loop
|
|
sec ; C=1 so grand-caller will call MLI quit
|
|
rts
|
|
|
|
DrawMainMenuTitle
|
|
jsr Home
|
|
lda #1
|
|
sta GlobalLeftMargin
|
|
ldy #3
|
|
- ldx #1
|
|
lda sTitleLine1-2, y
|
|
jsr DrawLargeCharacter
|
|
inx
|
|
lda sTitleLine2-2, y
|
|
jsr DrawLargeCharacter
|
|
inx
|
|
lda sTitleLine3-2, y
|
|
jsr DrawLargeCharacter
|
|
iny
|
|
cpy #$0A
|
|
bne -
|
|
rts
|
|
|
|
DrawMainMenuText
|
|
+PRINT_AT sAsterisk, 2, 30
|
|
+PRINT_AT sVersion, 11, 26
|
|
+PRINT_AT sMainMenuPlay, 15, 10
|
|
+PRINT_AT sMainMenuSound, 16, 10
|
|
lda gSoundPref
|
|
beq @theSoundOfSilence
|
|
+LDADDR sMainMenuSoundOn
|
|
bne + ; always branches
|
|
@theSoundOfSilence
|
|
+LDADDR sMainMenuSoundOff
|
|
+ jsr DrawHeavySilkString
|
|
+PRINT_AT sMainMenuAbout, 17, 10
|
|
+PRINT_AT sMainMenuDemo, 18, 10
|
|
+PRINT_AT sMainMenuQuit, 19, 10
|
|
+PRINT_AT sMainMenuDisclaimer, 23, 0
|
|
rts
|