pokecrystal-board/engine/menus/main_menu.asm

224 lines
3.2 KiB
NASM
Raw Normal View History

2020-06-18 07:11:12 -07:00
; MainMenuItems indexes
const_def
const MAINMENU_NEW_GAME ; 0
const MAINMENU_CONTINUE ; 1
2020-06-18 07:11:12 -07:00
; MainMenu.Strings and MainMenu.Jumptable indexes
const_def
const MAINMENUITEM_CONTINUE ; 0
const MAINMENUITEM_NEW_GAME ; 1
const MAINMENUITEM_OPTION ; 2
const MAINMENUITEM_DEBUG_ROOM ; 3
2015-11-16 19:29:54 -08:00
2018-06-24 07:09:41 -07:00
MainMenu:
2020-06-18 07:11:12 -07:00
.loop
2015-11-16 19:29:54 -08:00
xor a
ldh [hMapAnims], a
call ClearTilemap
call LoadFrame
call LoadStandardFont
call ClearMenuAndWindowData
ld b, CGB_DIPLOMA
call GetCGBLayout
2015-11-16 19:29:54 -08:00
call SetPalettes
call MainMenu_GetWhichMenu
2015-12-18 17:07:09 -08:00
ld [wWhichIndexSet], a
call MainMenu_PrintCurrentTimeAndDay
ld hl, .MenuHeader
call LoadMenuHeader
call MainMenuJoypadLoop
call CloseWindow
2015-11-16 19:29:54 -08:00
jr c, .quit
call ClearTilemap
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
ld hl, .Jumptable
2015-11-16 19:29:54 -08:00
rst JumpTable
2020-06-18 07:11:12 -07:00
jr .loop
2015-11-16 19:29:54 -08:00
.quit
ret
2018-06-24 07:09:41 -07:00
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, 16, 7
dw .MenuData
2015-11-16 19:29:54 -08:00
db 1 ; default option
2018-06-24 07:09:41 -07:00
.MenuData:
db STATICMENU_CURSOR ; flags
2015-11-16 19:29:54 -08:00
db 0 ; items
dw MainMenuItems
2015-12-13 11:15:16 -08:00
dw PlaceMenuStrings
dw .Strings
2015-11-16 19:29:54 -08:00
2018-06-24 07:09:41 -07:00
.Strings:
2020-06-18 07:11:12 -07:00
; entries correspond to MAINMENUITEM_* constants
2015-11-16 19:29:54 -08:00
db "CONTINUE@"
db "NEW GAME@"
db "OPTION@"
if DEF(_DEBUG)
db "DEBUG ROOM@"
endc
2015-11-16 19:29:54 -08:00
.Jumptable:
2020-06-18 07:11:12 -07:00
; entries correspond to MAINMENUITEM_* constants
2015-12-26 18:59:03 -08:00
dw MainMenu_Continue
dw MainMenu_NewGame
2020-06-18 07:11:12 -07:00
dw MainMenu_Option
if DEF(_DEBUG)
dw MainMenu_DebugRoom
endc
2015-11-16 19:29:54 -08:00
MainMenuItems:
2020-06-18 07:11:12 -07:00
; entries correspond to MAINMENU_* constants
2015-11-16 19:29:54 -08:00
2020-06-18 07:11:12 -07:00
; MAINMENU_NEW_GAME
2015-11-16 19:29:54 -08:00
db 2
2020-06-18 07:11:12 -07:00
db MAINMENUITEM_NEW_GAME
db MAINMENUITEM_OPTION
db -1
2015-11-16 19:29:54 -08:00
2020-06-18 07:11:12 -07:00
; MAINMENU_CONTINUE
db 3 + DEF(_DEBUG)
2020-06-18 07:11:12 -07:00
db MAINMENUITEM_CONTINUE
db MAINMENUITEM_NEW_GAME
db MAINMENUITEM_OPTION
if DEF(_DEBUG)
db MAINMENUITEM_DEBUG_ROOM
endc
db -1
2015-11-16 19:29:54 -08:00
2018-06-24 07:09:41 -07:00
MainMenu_GetWhichMenu:
2015-11-17 20:29:14 -08:00
ld a, [wSaveFileExists]
2015-11-16 19:29:54 -08:00
and a
jr nz, .next
2020-06-18 07:11:12 -07:00
ld a, MAINMENU_NEW_GAME
2015-11-16 19:29:54 -08:00
ret
.next
2020-06-18 07:11:12 -07:00
ld a, MAINMENU_CONTINUE
2015-11-16 19:29:54 -08:00
ret
2018-06-24 07:09:41 -07:00
MainMenuJoypadLoop:
2015-11-16 19:29:54 -08:00
call SetUpMenu
.loop
call MainMenu_PrintCurrentTimeAndDay
ld a, [w2DMenuFlags1]
2015-11-16 19:29:54 -08:00
set 5, a
ld [w2DMenuFlags1], a
2016-03-01 19:31:21 -08:00
call GetScrollingMenuJoypad
2015-12-15 15:59:49 -08:00
ld a, [wMenuJoypad]
cp B_BUTTON
jr z, .b_button
cp A_BUTTON
jr z, .a_button
jr .loop
2015-11-16 19:29:54 -08:00
.a_button
2015-11-16 19:29:54 -08:00
call PlayClickSFX
and a
ret
.b_button
2015-11-16 19:29:54 -08:00
scf
ret
2018-06-24 07:09:41 -07:00
MainMenu_PrintCurrentTimeAndDay:
2015-11-17 20:29:14 -08:00
ld a, [wSaveFileExists]
2015-11-16 19:29:54 -08:00
and a
ret z
xor a
ldh [hBGMapMode], a
call .PlaceBox
2018-01-23 14:39:09 -08:00
ld hl, wOptions
2015-11-16 19:29:54 -08:00
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
call .PlaceTime
2015-11-16 19:29:54 -08:00
pop af
2018-01-23 14:39:09 -08:00
ld [wOptions], a
2015-11-16 19:29:54 -08:00
ld a, $1
ldh [hBGMapMode], a
2015-11-16 19:29:54 -08:00
ret
2018-06-24 07:09:41 -07:00
.PlaceBox:
2015-11-16 19:29:54 -08:00
hlcoord 0, 14
ld b, 2
ld c, 18
call Textbox1bpp
2015-11-16 19:29:54 -08:00
ret
2018-06-24 07:09:41 -07:00
.PlaceTime:
2015-11-17 20:29:14 -08:00
ld a, [wSaveFileExists]
2015-11-16 19:29:54 -08:00
and a
ret z
call GetWeekday
ld b, a
decoord 1, 15
2020-06-18 07:11:12 -07:00
call .PrintDayOfWeek
ld a, [wTimeOfDay]
maskbits NUM_DAYTIMES
2015-11-16 19:29:54 -08:00
decoord 4, 16
call .PrintTimeOfDay
2015-11-16 19:29:54 -08:00
ret
2020-06-18 07:11:12 -07:00
.PrintDayOfWeek:
2015-11-16 19:29:54 -08:00
push de
ld hl, .Days
ld a, b
call GetNthString
ld d, h
ld e, l
pop hl
call PlaceString
ld h, b
ld l, c
ld de, .Day
call PlaceString
ret
.Days:
2015-11-16 19:29:54 -08:00
db "SUN@"
db "MON@"
db "TUES@"
db "WEDNES@"
db "THURS@"
db "FRI@"
db "SATUR@"
.Day:
2015-11-16 19:29:54 -08:00
db "DAY@"
.PrintTimeOfDay:
push de
ld hl, .TimesOfDay
call GetNthString
ld d, h
ld e, l
pop hl
call PlaceString
ret
.TimesOfDay:
db "MORN@"
db "DAY@"
db "NITE@"
2023-07-31 03:27:53 -07:00
db "EVE@"
2018-06-24 07:09:41 -07:00
MainMenu_NewGame:
call NewGame
2015-11-16 19:29:54 -08:00
ret
2020-06-18 07:11:12 -07:00
MainMenu_Option:
call Option
2015-11-16 19:29:54 -08:00
ret
2018-06-24 07:09:41 -07:00
MainMenu_Continue:
call Continue
2015-11-16 19:29:54 -08:00
ret
if DEF(_DEBUG)
MainMenu_DebugRoom:
farcall _DebugRoom
ret
endc