shithub: pokecrystal

Download patch

ref: ed3bcf6fa2a267f311ae9f497907f46118ef7fc5
parent: 50e182e83180dc6bfd012ddc26e7dc07052a89a5
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Thu Jun 18 06:11:12 EDT 2020

Harmonize engine/menus with pokegold

--- a/engine/menus/delete_save.asm
+++ b/engine/menus/delete_save.asm
@@ -13,7 +13,7 @@
 	call VerticalMenu
 	ret c
 	ld a, [wMenuCursorY]
-	cp $1
+	cp 1
 	ret z
 	farcall EmptyAllSRAMBanks
 	ret
--- a/engine/menus/intro_menu.asm
+++ b/engine/menus/intro_menu.asm
@@ -1,4 +1,4 @@
-_MainMenu:
+Intro_MainMenu:
 	ld de, MUSIC_NONE
 	call PlayMusic
 	call DelayFrame
@@ -54,8 +54,8 @@
 	farcall DoMysteryGift
 	ret
 
-OptionsMenu:
-	farcall _OptionsMenu
+Option:
+	farcall _Option
 	ret
 
 NewGame:
@@ -66,7 +66,8 @@
 	call AreYouABoyOrAreYouAGirl
 	call OakSpeech
 	call InitializeWorld
-	ld a, 1
+
+	ld a, LANDMARK_NEW_BARK_TOWN
 	ld [wPrevLandmark], a
 
 	ld a, SPAWN_HOME
@@ -77,7 +78,7 @@
 	jp FinishContinueFunction
 
 AreYouABoyOrAreYouAGirl:
-	farcall Mobile_AlwaysReturnNotCarry ; some mobile stuff
+	farcall Mobile_AlwaysReturnNotCarry ; mobile
 	jr c, .ok
 	farcall InitGender
 	ret
@@ -780,7 +781,7 @@
 .Kris:
 	db "KRIS@@@@@@@"
 
-Unreferenced_Function60e9:
+Unreferenced_GSShowPlayerNamingChoices:
 	call LoadMenuHeader
 	call VerticalMenu
 	ld a, [wMenuCursorY]
@@ -910,7 +911,7 @@
 
 Intro_PlacePlayerSprite:
 	farcall GetPlayerIcon
-	ld c, $c
+	ld c, 12
 	ld hl, vTiles0
 	call Request2bpp
 
@@ -939,7 +940,7 @@
 .male
 	ld a, b
 
-	ld [hli], a
+	ld [hli], a ; attributes
 	dec c
 	jr nz, .loop
 	ret
@@ -952,7 +953,7 @@
 	db 10 * 8 + 4,  9 * 8, 2
 	db 10 * 8 + 4, 10 * 8, 3
 
-CrystalIntroSequence:
+IntroSequence:
 	callfar Copyright_GameFreakPresents
 	jr c, StartTitleScreen
 	farcall CrystalIntro
@@ -1008,10 +1009,10 @@
 	jp hl
 
 .dw
-	dw _MainMenu
+	dw Intro_MainMenu
 	dw DeleteSaveData
-	dw CrystalIntroSequence
-	dw CrystalIntroSequence
+	dw IntroSequence
+	dw IntroSequence
 	dw ResetClock
 
 .TitleScreen:
@@ -1258,12 +1259,12 @@
 	ret nz
 	ld bc, wSpriteAnim10
 	ld hl, SPRITEANIMSTRUCT_FRAME
-	add hl, bc ; over-the-top compicated way to load wc3ae into hl
+	add hl, bc
 	ld l, [hl]
 	ld h, 0
 	add hl, hl
 	add hl, hl
-	ld de, .Data63ca
+	ld de, .Data_63ca
 	add hl, de
 	; If bit 2 of [wTitleScreenTimer] is set, get the second dw; else, get the first dw
 	ld a, [wTitleScreenTimer]
@@ -1283,7 +1284,7 @@
 	call InitSpriteAnimStruct
 	ret
 
-.Data63ca:
+.Data_63ca:
 ; frame 0 y, x; frame 1 y, x
 	db 11 * 8 + 4, 10 * 8,  0 * 8,      0 * 8
 	db 11 * 8 + 4, 13 * 8, 11 * 8 + 4, 11 * 8
@@ -1333,4 +1334,4 @@
 	ld a, $90
 	ldh [hWY], a
 	call WaitBGMap
-	jp CrystalIntroSequence
+	jp IntroSequence
--- a/engine/menus/main_menu.asm
+++ b/engine/menus/main_menu.asm
@@ -1,7 +1,29 @@
+	; MainMenuItems indexes
+	const_def
+	const MAINMENU_NEW_GAME               ; 0
+	const MAINMENU_CONTINUE               ; 1
+	const MAINMENU_MOBILE_MYSTERY         ; 2
+	const MAINMENU_MOBILE                 ; 3
+	const MAINMENU_MOBILE_STUDIUM         ; 4
+	const MAINMENU_MYSTERY_MOBILE_STUDIUM ; 5
+	const MAINMENU_MYSTERY                ; 6
+	const MAINMENU_MYSTERY_STUDIUM        ; 7
+	const MAINMENU_STUDIUM                ; 8
+
+	; MainMenu.Strings and MainMenu.Jumptable indexes
+	const_def
+	const MAINMENUITEM_CONTINUE       ; 0
+	const MAINMENUITEM_NEW_GAME       ; 1
+	const MAINMENUITEM_OPTION         ; 2
+	const MAINMENUITEM_MYSTERY_GIFT   ; 3
+	const MAINMENUITEM_MOBILE         ; 4
+	const MAINMENUITEM_MOBILE_STUDIUM ; 5
+
 MobileMenuGFX:
 INCBIN "gfx/mobile/mobile_menu.2bpp"
 
 MainMenu:
+.loop
 	xor a
 	ld [wDisableTextAcceleration], a
 	call ClearTilemapEtc
@@ -22,7 +44,7 @@
 	ld a, [wMenuSelection]
 	ld hl, .Jumptable
 	rst JumpTable
-	jr MainMenu
+	jr .loop
 
 .quit
 	ret
@@ -41,6 +63,7 @@
 	dw .Strings
 
 .Strings:
+; entries correspond to MAINMENUITEM_* constants
 	db "CONTINUE@"
 	db "NEW GAME@"
 	db "OPTION@"
@@ -49,94 +72,89 @@
 	db "MOBILE STUDIUM@"
 
 .Jumptable:
+; entries correspond to MAINMENUITEM_* constants
 	dw MainMenu_Continue
 	dw MainMenu_NewGame
-	dw MainMenu_Options
+	dw MainMenu_Option
 	dw MainMenu_MysteryGift
 	dw MainMenu_Mobile
 	dw MainMenu_MobileStudium
 
-CONTINUE       EQU 0
-NEW_GAME       EQU 1
-OPTION         EQU 2
-MYSTERY_GIFT   EQU 3
-MOBILE         EQU 4
-MOBILE_STUDIUM EQU 5
-
 MainMenuItems:
+; entries correspond to MAINMENU_* constants
 
-NewGameMenu:
+	; MAINMENU_NEW_GAME
 	db 2
-	db NEW_GAME
-	db OPTION
+	db MAINMENUITEM_NEW_GAME
+	db MAINMENUITEM_OPTION
 	db -1
 
-ContinueMenu:
+	; MAINMENU_CONTINUE
 	db 3
-	db CONTINUE
-	db NEW_GAME
-	db OPTION
+	db MAINMENUITEM_CONTINUE
+	db MAINMENUITEM_NEW_GAME
+	db MAINMENUITEM_OPTION
 	db -1
 
-MobileMysteryMenu:
+	; MAINMENU_MOBILE_MYSTERY
 	db 5
-	db CONTINUE
-	db NEW_GAME
-	db OPTION
-	db MYSTERY_GIFT
-	db MOBILE
+	db MAINMENUITEM_CONTINUE
+	db MAINMENUITEM_NEW_GAME
+	db MAINMENUITEM_OPTION
+	db MAINMENUITEM_MYSTERY_GIFT
+	db MAINMENUITEM_MOBILE
 	db -1
 
-MobileMenu:
+	; MAINMENU_MOBILE
 	db 4
-	db CONTINUE
-	db NEW_GAME
-	db OPTION
-	db MOBILE
+	db MAINMENUITEM_CONTINUE
+	db MAINMENUITEM_NEW_GAME
+	db MAINMENUITEM_OPTION
+	db MAINMENUITEM_MOBILE
 	db -1
 
-MobileStudiumMenu:
+	; MAINMENU_MOBILE_STUDIUM
 	db 5
-	db CONTINUE
-	db NEW_GAME
-	db OPTION
-	db MOBILE
-	db MOBILE_STUDIUM
+	db MAINMENUITEM_CONTINUE
+	db MAINMENUITEM_NEW_GAME
+	db MAINMENUITEM_OPTION
+	db MAINMENUITEM_MOBILE
+	db MAINMENUITEM_MOBILE_STUDIUM
 	db -1
 
-MysteryMobileStudiumMenu:
+	; MAINMENU_MYSTERY_MOBILE_STUDIUM
 	db 6
-	db CONTINUE
-	db NEW_GAME
-	db OPTION
-	db MYSTERY_GIFT
-	db MOBILE
-	db MOBILE_STUDIUM
+	db MAINMENUITEM_CONTINUE
+	db MAINMENUITEM_NEW_GAME
+	db MAINMENUITEM_OPTION
+	db MAINMENUITEM_MYSTERY_GIFT
+	db MAINMENUITEM_MOBILE
+	db MAINMENUITEM_MOBILE_STUDIUM
 	db -1
 
-MysteryMenu:
+	; MAINMENU_MYSTERY
 	db 4
-	db CONTINUE
-	db NEW_GAME
-	db OPTION
-	db MYSTERY_GIFT
+	db MAINMENUITEM_CONTINUE
+	db MAINMENUITEM_NEW_GAME
+	db MAINMENUITEM_OPTION
+	db MAINMENUITEM_MYSTERY_GIFT
 	db -1
 
-MysteryStudiumMenu:
+	; MAINMENU_MYSTERY_STUDIUM
 	db 5
-	db CONTINUE
-	db NEW_GAME
-	db OPTION
-	db MYSTERY_GIFT
-	db MOBILE_STUDIUM
+	db MAINMENUITEM_CONTINUE
+	db MAINMENUITEM_NEW_GAME
+	db MAINMENUITEM_OPTION
+	db MAINMENUITEM_MYSTERY_GIFT
+	db MAINMENUITEM_MOBILE_STUDIUM
 	db -1
 
-StudiumMenu:
+	; MAINMENU_STUDIUM
 	db 4
-	db CONTINUE
-	db NEW_GAME
-	db OPTION
-	db MOBILE_STUDIUM
+	db MAINMENUITEM_CONTINUE
+	db MAINMENUITEM_NEW_GAME
+	db MAINMENUITEM_OPTION
+	db MAINMENUITEM_MOBILE_STUDIUM
 	db -1
 
 MainMenu_GetWhichMenu:
@@ -146,13 +164,13 @@
 	ld a, [wSaveFileExists]
 	and a
 	jr nz, .next
-	ld a, $0 ; New Game
+	ld a, MAINMENU_NEW_GAME
 	ret
 
 .next
 	ldh a, [hCGB]
-	cp $1
-	ld a, $1
+	cp TRUE
+	ld a, MAINMENU_CONTINUE
 	ret nz
 	ld a, BANK(sNumDailyMysteryGiftPartnerIDs)
 	call OpenSRAM
@@ -163,7 +181,7 @@
 	; This check makes no difference.
 	ld a, [wStatusFlags]
 	bit STATUSFLAGS_MAIN_MENU_MOBILE_CHOICES_F, a
-	ld a, $1 ; Continue
+	ld a, MAINMENU_CONTINUE
 	jr z, .ok
 	jr .ok
 
@@ -171,7 +189,7 @@
 	jr .ok2
 
 .ok2
-	ld a, $1 ; Continue
+	ld a, MAINMENU_CONTINUE
 	ret
 
 .mystery_gift
@@ -185,7 +203,7 @@
 	jr .ok4
 
 .ok4
-	ld a, $6 ; Mystery Gift
+	ld a, MAINMENU_MYSTERY
 	ret
 
 MainMenuJoypadLoop:
@@ -232,7 +250,7 @@
 
 .PlaceBox:
 	call CheckRTCStatus
-	and $80
+	and %10000000 ; Day count exceeded 16383
 	jr nz, .TimeFail
 	hlcoord 0, 14
 	ld b, 2
@@ -255,7 +273,7 @@
 	call GetWeekday
 	ld b, a
 	decoord 1, 15
-	call .PlaceCurrentDay
+	call .PrintDayOfWeek
 	decoord 4, 16
 	ldh a, [hHours]
 	ld c, a
@@ -284,7 +302,7 @@
 	text_far _MainMenuTimeUnknownText
 	text_end
 
-.PlaceCurrentDay:
+.PrintDayOfWeek:
 	push de
 	ld hl, .Days
 	ld a, b
@@ -323,8 +341,8 @@
 	farcall NewGame
 	ret
 
-MainMenu_Options:
-	farcall OptionsMenu
+MainMenu_Option:
+	farcall Option
 	ret
 
 MainMenu_Continue:
--- a/engine/menus/menu.asm
+++ b/engine/menus/menu.asm
@@ -277,7 +277,6 @@
 .loop
 	call Move2DMenuCursor
 	call HDMATransferTilemapToWRAMBank3 ; BUG: This function is in another bank.
-	                    ; Pointer in current bank (9) is bogus.
 	call .loop2
 	jr nc, .done
 	call _2DMenuInterpretJoypad
@@ -300,7 +299,6 @@
 	ld c, 1
 	ld b, 3
 	call AdvanceMobileInactivityTimerAndCheckExpired ; BUG: This function is in another bank.
-	                    ; Pointer in current bank (9) is bogus.
 	ret c
 	farcall Function100337
 	ret c
@@ -566,8 +564,8 @@
 	ld d, [hl]
 	push de
 
-	ld b, $10
-	ld hl, wMenuFlags
+	ld b, wMenuHeaderEnd - wMenuHeader
+	ld hl, wMenuHeader
 .loop
 	ld a, [hli]
 	ld [de], a
--- a/engine/menus/naming_screen.asm
+++ b/engine/menus/naming_screen.asm
@@ -193,7 +193,7 @@
 .LoadSprite:
 	push de
 	ld hl, vTiles0 tile $00
-	ld c, $4
+	ld c, 4
 	push bc
 	call Request2bpp
 	pop bc
@@ -698,7 +698,7 @@
 	scf
 	ret
 
-; unused
+Unreferenced_AddDakutenToCharacter:
 	ld a, [wNamingScreenCurNameLength]
 	and a
 	ret z
@@ -711,7 +711,7 @@
 
 .loop
 	ld a, [hli]
-	cp $ff
+	cp -1
 	jr z, NamingScreen_AdvanceCursor_CheckEndOfString
 	cp c
 	jr z, .done
@@ -975,7 +975,7 @@
 	ld [wNamingScreenMaxNameLength], a
 	ret
 
-.UnusedString11f7a:
+.Unreferenced_PleaseWriteAMailString:
 	db "メールを かいてね@"
 
 .InitCharset:
--- a/engine/menus/options_menu.asm
+++ b/engine/menus/options_menu.asm
@@ -10,7 +10,7 @@
 	const OPT_CANCEL       ; 7
 NUM_OPTIONS EQU const_value    ; 8
 
-_OptionsMenu:
+_Option:
 	ld hl, hInMenu
 	ld a, [hl]
 	push af
--- a/engine/menus/start_menu.asm
+++ b/engine/menus/start_menu.asm
@@ -433,10 +433,11 @@
 
 	call BufferScreen
 	farcall SaveMenu
-	jr nc, .asm_12919
+	jr nc, .saved
 	ld a, 0
 	ret
-.asm_12919
+
+.saved
 	ld a, 1
 	ret
 
@@ -444,7 +445,7 @@
 ; Game options.
 
 	call FadeToMenu
-	farcall OptionsMenu
+	farcall Option
 	ld a, 6
 	ret
 
@@ -460,13 +461,13 @@
 StartMenu_Pokedex:
 	ld a, [wPartyCount]
 	and a
-	jr z, .asm_12949
+	jr z, .empty
 
 	call FadeToMenu
 	farcall Pokedex
 	call CloseSubmenu
 
-.asm_12949
+.empty
 	ld a, 0
 	ret