shithub: pokecrystal

Download patch

ref: b975f3e068fb9dbbe688445914cfb65036eeadc1
parent: 583838a39d0c9ddd2440f9c12747a616b377e7ec
author: Rangi <[email protected]>
date: Wed Jan 2 14:04:50 EST 2019

Clean up some Odd Egg and Battle Tower code and data

Fixes #589

--- a/constants/battle_tower_constants.asm
+++ b/constants/battle_tower_constants.asm
@@ -5,7 +5,7 @@
 BATTLETOWER_NUM_UNIQUE_TRAINERS EQU 70
 
 BATTLETOWER_TRAINERDATALENGTH EQU $24
-BATTLE_TOWER_STRUCT_LENGTH EQU $e0 ; NAME_LENGTH + BATTLETOWER_PARTY_LENGTH * (PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH) + BATTLETOWER_TRAINERDATALENGTH
+BATTLE_TOWER_STRUCT_LENGTH EQUS "(NAME_LENGTH + BATTLETOWER_PARTY_LENGTH * NICKNAMED_MON_STRUCT_LENGTH + BATTLETOWER_TRAINERDATALENGTH)"
 
 ; BattleTowerAction writebyte arguments (see engine/events/battle_tower/battle_tower.asm)
 	const_def
--- a/constants/pokemon_data_constants.asm
+++ b/constants/pokemon_data_constants.asm
@@ -97,6 +97,8 @@
 MON_SDF                EQUS "(wPartyMon1SpclDef - wPartyMon1)"
 BOXMON_STRUCT_LENGTH   EQUS "(wPartyMon1End - wPartyMon1)"
 PARTYMON_STRUCT_LENGTH EQUS "(wPartyMon1StatsEnd - wPartyMon1)"
+
+NICKNAMED_MON_STRUCT_LENGTH EQUS "(PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH)"
 REDMON_STRUCT_LENGTH EQU 44
 
 ; caught data
@@ -121,9 +123,9 @@
 NUM_BOXES    EQU 14
 
 ; hall of fame
-HOF_MON_LENGTH = 1 + 2 + 2 + 1 + (MON_NAME_LENGTH + -1) ; species, id, dvs, level, nick
-HOF_LENGTH = 1 + HOF_MON_LENGTH * PARTY_LENGTH + 1 ; win count, party, terminator
-NUM_HOF_TEAMS = 30
+HOF_MON_LENGTH EQU 1 + 2 + 2 + 1 + (MON_NAME_LENGTH + -1) ; species, id, dvs, level, nick
+HOF_LENGTH EQU 1 + HOF_MON_LENGTH * PARTY_LENGTH + 1 ; win count, party, terminator
+NUM_HOF_TEAMS EQU 30
 
 ; evolution types (used in data/pokemon/evos_attacks.asm)
 	const_def 1
@@ -150,8 +152,8 @@
 NUM_GRASSMON EQU 7 ; data/wild/*_grass.asm table size
 NUM_WATERMON EQU 3 ; data/wild/*_water.asm table size
 
-GRASS_WILDDATA_LENGTH EQU (NUM_GRASSMON * 2 + 1) * 3 + 2
-WATER_WILDDATA_LENGTH EQU (NUM_WATERMON * 2 + 1) * 1 + 2
+GRASS_WILDDATA_LENGTH EQU 2 + (1 + NUM_GRASSMON * 2) * 3
+WATER_WILDDATA_LENGTH EQU 2 + (1 + NUM_WATERMON * 2) * 1
 FISHGROUP_DATA_LENGTH EQU 1 + 2 * 3
 
 NUM_ROAMMON_MAPS EQU 16 ; RoamMaps table size (see data/wild/roammon_maps.asm)
--- a/data/events/odd_eggs.asm
+++ b/data/events/odd_eggs.asm
@@ -29,7 +29,6 @@
 
 OddEggs:
 
-OddEgg1:
 	db PICHU
 	db NO_ITEM
 	db THUNDERSHOCK, CHARM, DIZZY_PUNCH, 0
@@ -43,7 +42,7 @@
 	bigdw 0
 	dn 0, 0, 0, 0 ; DVs
 	db 30, 20, 10, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -55,7 +54,6 @@
 	bigdw 8 ; SAtk
 	bigdw 8 ; SDef
 	db "EGG@@@@@@@@"
-OddEgg1End:
 
 	db PICHU
 	db NO_ITEM
@@ -70,7 +68,7 @@
 	bigdw 0
 	dn 2, 10, 10, 10 ; DVs
 	db 30, 20, 10, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -96,7 +94,7 @@
 	bigdw 0
 	dn 0, 0, 0, 0 ; DVs
 	db 35, 20, 10, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -122,7 +120,7 @@
 	bigdw 0
 	dn 2, 10, 10, 10 ; DVs
 	db 35, 20, 10, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -148,7 +146,7 @@
 	bigdw 0
 	dn 0, 0, 0, 0 ; DVs
 	db 15, 20, 10, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -174,7 +172,7 @@
 	bigdw 0
 	dn 2, 10, 10, 10 ; DVs
 	db 15, 20, 10, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -200,7 +198,7 @@
 	bigdw 0
 	dn 0, 0, 0, 0 ; DVs
 	db 35, 30, 10, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -226,7 +224,7 @@
 	bigdw 0
 	dn 2, 10, 10, 10 ; DVs
 	db 35, 30, 10, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -252,7 +250,7 @@
 	bigdw 0
 	dn 0, 0, 0, 0 ; DVs
 	db 25, 10, 0, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -278,7 +276,7 @@
 	bigdw 0
 	dn 2, 10, 10, 10 ; DVs
 	db 25, 10, 0, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -304,7 +302,7 @@
 	bigdw 0
 	dn 0, 0, 0, 0 ; DVs
 	db 30, 30, 10, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -330,7 +328,7 @@
 	bigdw 0
 	dn 2, 10, 10, 10 ; DVs
 	db 30, 30, 10, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -356,7 +354,7 @@
 	bigdw 0
 	dn 0, 0, 0, 0 ; DVs
 	db 35, 10, 0, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
@@ -382,7 +380,7 @@
 	bigdw 0
 	dn 2, 10, 10, 10 ; DVs
 	db 35, 10, 0, 0 ; PP
-	db 20 ; Happiness
+	db 20 ; Step cycles to hatch
 	db 0, 0, 0 ; Pokerus, Caught data
 	db 5 ; Level
 	db 0, 0 ; Status
--- a/engine/events/battle_tower/battle_tower.asm
+++ b/engine/events/battle_tower/battle_tower.asm
@@ -480,7 +480,7 @@
 	ld a, [hl]
 	ld [de], a
 	pop hl
-	ld bc, PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH
+	ld bc, NICKNAMED_MON_STRUCT_LENGTH
 	add hl, bc
 	pop de
 	dec d
--- a/engine/events/battle_tower/load_trainer.asm
+++ b/engine/events/battle_tower/load_trainer.asm
@@ -7,7 +7,7 @@
 	; Fill wBT_OTTrainer with zeros
 	xor a
 	ld hl, wBT_OTTrainer
-	ld bc, wBT_OTTrainerEnd - wBT_OTTrainer
+	ld bc, BATTLE_TOWER_STRUCT_LENGTH
 	call ByteFill
 
 	; Write $ff into the Item-Slots
@@ -104,7 +104,7 @@
 	ld a, [wBTChoiceOfLvlGroup]
 	dec a
 	ld hl, BattleTowerMons
-	ld bc, BattleTowerMons2 - BattleTowerMons1 ; size of one level group
+	ld bc, BATTLETOWER_NUM_UNIQUE_MON * NICKNAMED_MON_STRUCT_LENGTH
 	call AddNTimes
 
 	ldh a, [hRandomAdd]
@@ -122,7 +122,7 @@
 	; Check if mon was already loaded before
 	; Check current and the 2 previous teams
 	; includes check if item is double at the current team
-	ld bc, PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH
+	ld bc, NICKNAMED_MON_STRUCT_LENGTH
 	call AddNTimes
 	ld a, [hli]
 	ld b, a
@@ -165,13 +165,13 @@
 	cp b
 	jr z, .FindARandomBattleTowerMon
 
-	ld bc, PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH
+	ld bc, NICKNAMED_MON_STRUCT_LENGTH
 	call CopyBytes
 
 	ld a, [wNamedObjectIndexBuffer]
 	push af
 	push de
-	ld hl, - (PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH)
+	ld hl, -NICKNAMED_MON_STRUCT_LENGTH
 	add hl, de
 	ld a, [hl]
 	ld [wNamedObjectIndexBuffer], a
--- a/engine/events/odd_egg.asm
+++ b/engine/events/odd_egg.asm
@@ -39,11 +39,13 @@
 .done
 
 	ld hl, OddEggs
-	ld a, OddEgg1End - OddEgg1
+	ld a, NICKNAMED_MON_STRUCT_LENGTH
 	call AddNTimes
 
-	ld de, wOddEggSpecies
-	ld bc, PARTYMON_STRUCT_LENGTH + 2 * MON_NAME_LENGTH
+	; Writes to wOddEgg, wOddEggName, and wOddEggOTName,
+	; even though OddEggs does not have data for wOddEggOTName
+	ld de, wOddEgg
+	ld bc, NICKNAMED_MON_STRUCT_LENGTH + MON_NAME_LENGTH
 	call CopyBytes
 
 	ld a, EGG_TICKET
@@ -64,10 +66,10 @@
 	ld [wMobileMonSpeciesPointerBuffer], a
 	ld a, HIGH(wMobileMonSpeciesBuffer - 1)
 	ld [wMobileMonSpeciesPointerBuffer + 1], a
-	; load pointer to wOddEggSpecies in wMobileMonStructurePointerBuffer
-	ld a, LOW(wOddEggSpecies)
+	; load pointer to wOddEgg in wMobileMonStructurePointerBuffer
+	ld a, LOW(wOddEgg)
 	ld [wMobileMonStructurePointerBuffer], a
-	ld a, HIGH(wOddEggSpecies)
+	ld a, HIGH(wOddEgg)
 	ld [wMobileMonStructurePointerBuffer + 1], a
 
 	; load Odd Egg Name in wTempOddEggNickname
--- a/mobile/mobile_5c.asm
+++ b/mobile/mobile_5c.asm
@@ -242,7 +242,7 @@
 
 .done
 	pop hl
-	ld de, PARTYMON_STRUCT_LENGTH + MON_NAME_LENGTH
+	ld de, NICKNAMED_MON_STRUCT_LENGTH
 	add hl, de
 	dec c
 	jr nz, .loop