shithub: pokecrystal

Download patch

ref: ce16317f33fc534a6724f5ccfd0901bf2888862b
parent: 20dc31115e0234eb3819ce5b0d5dcfa7c009f8ea
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Sat Jan 22 16:43:09 EST 2022

`ClearWindowData` clears four menu data buffers, each the same size

--- a/home/menu.asm
+++ b/home/menu.asm
@@ -754,14 +754,14 @@
 	ret
 
 ClearWindowData::
-	ld hl, wWindowStackPointer
-	call .bytefill
+	ld hl, wMenuMetadata
+	call .ClearMenuData
 	ld hl, wMenuHeader
-	call .bytefill
-	ld hl, wMenuDataFlags
-	call .bytefill
-	ld hl, w2DMenuCursorInitY
-	call .bytefill
+	call .ClearMenuData
+	ld hl, wMenuData
+	call .ClearMenuData
+	ld hl, wMoreMenuData
+	call .ClearMenuData
 
 	ldh a, [rSVBK]
 	push af
@@ -781,8 +781,11 @@
 	ldh [rSVBK], a
 	ret
 
-.bytefill
-	ld bc, $10
+.ClearMenuData:
+	ld bc, wMenuMetadataEnd - wMenuMetadata
+	assert wMenuMetadataEnd - wMenuMetadata == wMenuHeaderEnd - wMenuHeader
+	assert wMenuMetadataEnd - wMenuMetadata == wMenuDataEnd - wMenuData
+	assert wMenuMetadataEnd - wMenuMetadata == wMoreMenuDataEnd - wMoreMenuData
 	xor a
 	call ByteFill
 	ret
--- a/wram.asm
+++ b/wram.asm
@@ -1630,6 +1630,7 @@
 wRequested1bppSource:: dw
 wRequested1bppDest:: dw
 
+wMenuMetadata::
 wWindowStackPointer:: dw
 wMenuJoypad:: db
 wMenuSelection:: db
@@ -1637,8 +1638,8 @@
 wWhichIndexSet:: db
 wScrollingMenuCursorPosition:: db
 wWindowStackSize:: db
-
 	ds 8
+wMenuMetadataEnd::
 
 ; menu header
 wMenuHeader::
@@ -1686,6 +1687,7 @@
 ENDU
 wMenuDataEnd::
 
+wMoreMenuData::
 w2DMenuData::
 w2DMenuCursorInitY:: db
 w2DMenuCursorInitX:: db
@@ -1710,8 +1712,8 @@
 wMenuCursorX:: db
 wCursorOffCharacter:: db
 wCursorCurrentTile:: dw
-
 	ds 3
+wMoreMenuDataEnd::
 
 wOverworldDelay:: db
 wTextDelayFrames:: db