shithub: pokered

Download patch

ref: 6adbaefde14f5e9039aa42a6c96ce476a4107925
parent: 47cd734276eade428671f720e8d01a45c4fd2bc2
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Sat Nov 28 12:11:12 EST 2020

Keep wGrassMons and wWaterMons together with a UNION

--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -2013,18 +2013,19 @@
 .menuselected
 	ld [wTextBoxID], a
 	call DisplayTextBoxID
+ ; handle menu input if it's not the old man tutorial
 	ld a, [wBattleType]
 	dec a
-	jp nz, .handleBattleMenuInput ; handle menu input if it's not the old man tutorial
+	jp nz, .handleBattleMenuInput
 ; the following happens for the old man tutorial
-	; Temporarily save the player name in wGrassRate,
-	; which is supposed to get overwritten when entering a
-	; map with wild Pokémon.
-	; Due to an oversight, the data may not get
-	; overwritten (on Cinnabar and Route 21) and the infamous
-	; Missingno. glitch can show up.
+	; Temporarily save the player name in wLinkEnemyTrainerName.
+	; Since wLinkEnemyTrainerName == wGrassRate, this affects wild encounters.
+	; The wGrassRate byte and following wGrassMons buffer are supposed
+	; to get overwritten when entering a map with wild Pokémon,
+	; but an oversight prevents this in Cinnabar and Route 21,
+	; so the infamous MissingNo. glitch can show up.
 	ld hl, wPlayerName
-	ld de, wGrassRate
+	ld de, wLinkEnemyTrainerName
 	ld bc, NAME_LENGTH
 	call CopyData
 	ld hl, .oldManName
--- a/wram.asm
+++ b/wram.asm
@@ -3035,30 +3035,32 @@
 wEventFlags::
 	flag_array NUM_EVENTS
 
+
+UNION
+wGrassRate:: db
+wGrassMons::
+	ds 10 * 2
+
+	ds 8
+
+wWaterRate:: db
+wWaterMons::
+	ds 10 * 2
+
+NEXTU
 wLinkEnemyTrainerName::
 ; linked game's trainer name
+	ds NAME_LENGTH
 
-wGrassRate::
 	ds 1
 
-wGrassMons::
-;	ds 20
-
-	ds 11
-; Overload wGrassMons
 wSerialEnemyDataBlock::
+;	ds $1a8
+
 	ds 9
 
 wEnemyPartyCount:: ds 1
 wEnemyPartyMons::  ds PARTY_LENGTH + 1
-
-; Overload enemy party data
-UNION
-
-wWaterRate:: db
-wWaterMons:: db
-
-NEXTU
 
 wEnemyMons::
 wEnemyMon1:: party_struct wEnemyMon1