shithub: pokecrystal

Download patch

ref: 79bb2784e92de0524c69c87556f7647861c47fb8
parent: 248763b238b6f8e8cb0bc0c5db05a270f1931ae7
author: mid-kid <[email protected]>
date: Sat Jun 20 13:56:18 EDT 2020

Better label 2D menu data

--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -1141,7 +1141,7 @@
 	cp EVERSTONE
 	jr z, .NoEffect
 
-	ld a, $1
+	ld a, TRUE
 	ld [wForceEvolution], a
 	farcall EvolvePokemon
 
--- a/engine/pokemon/mon_menu.asm
+++ b/engine/pokemon/mon_menu.asm
@@ -811,8 +811,8 @@
 
 .ChooseMoveToDelete
 	call SetUpMoveScreenBG
-	ld de, DeleteMoveScreenAttrs
-	call SetMenuAttributes
+	ld de, DeleteMoveScreen2DMenuData
+	call Load2DMenuData
 	call SetUpMoveList
 	ld hl, w2DMenuFlags1
 	set 6, [hl]
@@ -848,12 +848,12 @@
 	pop af
 	ret
 
-DeleteMoveScreenAttrs:
-	db 3, 1
-	db 3, 1
-	db $40, $00
-	dn 2, 0
-	db D_UP | D_DOWN | A_BUTTON | B_BUTTON
+DeleteMoveScreen2DMenuData:
+	db 3, 1 ; cursor start y, x
+	db 3, 1 ; rows, columns
+	db $40, $00 ; flags
+	dn 2, 0 ; cursor offset
+	db D_UP | D_DOWN | A_BUTTON | B_BUTTON ; accepted buttons
 
 ManagePokemonMoves:
 	ld a, [wCurPartySpecies]
@@ -878,8 +878,8 @@
 	ld [wPartyMenuCursor], a
 	call SetUpMoveScreenBG
 	call PlaceMoveScreenArrows
-	ld de, MoveScreenAttributes
-	call SetMenuAttributes
+	ld de, MoveScreen2DMenuData
+	call Load2DMenuData
 .loop
 	call SetUpMoveList
 	ld hl, w2DMenuFlags1
@@ -1077,12 +1077,12 @@
 	call ClearSprites
 	jp ClearTilemap
 
-MoveScreenAttributes:
-	db 3, 1
-	db 3, 1
-	db $40, $00
-	dn 2, 0
-	db D_UP | D_DOWN | D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON
+MoveScreen2DMenuData:
+	db 3, 1 ; cursor start y, x
+	db 3, 1 ; rows, columns
+	db $40, $00 ; flags
+	dn 2, 0 ; cursor offsets
+	db D_UP | D_DOWN | D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON ; accepted buttons
 
 String_MoveWhere:
 	db "Where?@"
--- a/engine/pokemon/party_menu.asm
+++ b/engine/pokemon/party_menu.asm
@@ -612,8 +612,8 @@
 ; with cancel
 	xor a
 	ld [wSwitchMon], a
-	ld de, PartyMenuAttributes
-	call SetMenuAttributes
+	ld de, PartyMenu2DMenuData
+	call Load2DMenuData
 	ld a, [wPartyCount]
 	inc a
 	ld [w2DMenuNumRows], a ; list length
@@ -637,8 +637,8 @@
 
 InitPartyMenuNoCancel:
 ; no cancel
-	ld de, PartyMenuAttributes
-	call SetMenuAttributes
+	ld de, PartyMenu2DMenuData
+	call Load2DMenuData
 	ld a, [wPartyCount]
 	ld [w2DMenuNumRows], a ; list length
 	ld b, a
@@ -656,20 +656,12 @@
 	ld [wMenuJoypadFilter], a
 	ret
 
-PartyMenuAttributes:
-; cursor y
-; cursor x
-; num rows
-; num cols
-; bit 6: animate sprites  bit 5: wrap around
-; ?
-; distance between items (hi: y, lo: x)
-; allowed buttons (mask)
-	db 1, 0
-	db 0, 1
-	db $60, $00
-	dn 2, 0
-	db 0
+PartyMenu2DMenuData:
+	db 1, 0 ; cursor start y, x
+	db 0, 1 ; rows, columns
+	db $60, $00 ; flags
+	dn 2, 0 ; cursor offset
+	db 0 ; accepted buttons
 
 PartyMenuSelect:
 ; sets carry if exitted menu.
--- a/home/menu.asm
+++ b/home/menu.asm
@@ -1,8 +1,8 @@
-SetMenuAttributes::
+Load2DMenuData::
 	push hl
 	push bc
-	ld hl, w2DMenuCursorInitY
-	ld b, $8
+	ld hl, w2DMenuData
+	ld b, w2DMenuDataEnd - w2DMenuData
 .loop
 	ld a, [de]
 	inc de
@@ -9,12 +9,14 @@
 	ld [hli], a
 	dec b
 	jr nz, .loop
+
+	; Reset menu state
 	ld a, $1
-	ld [hli], a
-	ld [hli], a
+	ld [hli], a ; wMenuCursorY
+	ld [hli], a ; wMenuCursorX
 	xor a
-	ld [hli], a
-	ld [hli], a
+	ld [hli], a ; wCursorOffCharacter
+	ld [hli], a ; wCursorCurrentTile
 	ld [hli], a
 	pop bc
 	pop hl
--- a/mobile/mobile_40.asm
+++ b/mobile/mobile_40.asm
@@ -1765,7 +1765,7 @@
 .GetMoveSelection:
 	xor a
 	ldh [hBGMapMode], a
-	call Function100c74
+	call .ListMoves
 	call Function100c98
 .master_loop
 	farcall MoveInfoBox
@@ -1860,7 +1860,7 @@
 	call SafeLoadTempTilemapToTilemap
 	jp .GetMoveSelection
 
-Function100c74:
+.ListMoves:
 	hlcoord 0, 8
 	ld b, 8
 	ld c, 8
@@ -1876,8 +1876,8 @@
 	ret
 
 Function100c98:
-	ld de, .attrs
-	call SetMenuAttributes
+	ld de, .data
+	call Load2DMenuData
 	ld a, [wNumMoves]
 	inc a
 	ld [w2DMenuNumRows], a
@@ -1886,12 +1886,12 @@
 	ld [wMenuCursorY], a
 	ret
 
-.attrs
-	db 10, 1
-	db 255, 1
-	db $a0, $00
-	dn 2, 0
-	db D_UP | D_DOWN | A_BUTTON | B_BUTTON
+.data:
+	db 10, 1 ; cursor start y, x
+	db -1, 1 ; rows, columns
+	db $a0, $00 ; flags
+	dn 2, 0 ; cursor offsets
+	db D_UP | D_DOWN | A_BUTTON | B_BUTTON ; accepted buttons
 
 Mobile_PartyMenuSelect:
 	call Function100dd8
@@ -5944,7 +5944,7 @@
 	ld hl, wcd4b
 	set 1, [hl]
 	ld de, MenuData3_102a33
-	call SetMenuAttributes
+	call Load2DMenuData
 	ld a, [wcd4a]
 	inc a
 	ld [wcd4a], a
@@ -5981,11 +5981,11 @@
 	db   "@"
 
 MenuData3_102a33:
-	db 8, 11
-	db 2,  1
-	db $80, $00
-	dn 2, 0
-	db A_BUTTON
+	db 8, 11 ; cursor start y, x
+	db 2, 1 ; rows, columns
+	db $80, $00 ; flags
+	dn 2, 0 ; cursor offset
+	db A_BUTTON ; accepted buttons
 
 Function102a3b:
 	ld a, [wcd30]
@@ -6115,8 +6115,8 @@
 	ld [wMonType], a
 	ld a, [wMenuCursorY]
 	push af
-	ld de, Unknown_102b73
-	call SetMenuAttributes
+	ld de, MenuData_102b73
+	call Load2DMenuData
 	pop af
 	ld [wMenuCursorY], a
 	ld a, [wOTPartyCount]
@@ -6130,12 +6130,12 @@
 	call ByteFill
 	ret
 
-Unknown_102b73:
-	db 9, 6
-	db 255, 1
-	db $a0, $00
-	dn 1, 0
-	db D_UP | D_DOWN | A_BUTTON
+MenuData_102b73:
+	db 9, 6 ; cursor start y, x
+	db -1, 1 ; rows, columns
+	db $a0, $00 ; flags
+	dn 1, 0 ; cursor offset
+	db D_UP | D_DOWN | A_BUTTON ; accepted buttons
 
 Function102b7b:
 	xor a
@@ -6142,8 +6142,8 @@
 	ld [wMonType], a
 	ld a, [wMenuCursorY]
 	push af
-	ld de, Unknown_102b94
-	call SetMenuAttributes
+	ld de, MenuData_102b94
+	call Load2DMenuData
 	pop af
 	ld [wMenuCursorY], a
 	ld a, [wPartyCount]
@@ -6150,12 +6150,12 @@
 	ld [w2DMenuNumRows], a
 	ret
 
-Unknown_102b94:
-	db 1, 6
-	db 255, 1
-	db $a0, $00
-	dn 1, 0
-	db D_UP | D_DOWN | A_BUTTON
+MenuData_102b94:
+	db 1, 6 ; cursor start y, x
+	db 255, 1 ; rows, columns
+	db $a0, $00 ; flags
+	dn 1, 0 ; cursor offset
+	db D_UP | D_DOWN | A_BUTTON ; accepted buttons
 
 Function102b9c:
 	ld a, [wcd4d]