From b975f3e068fb9dbbe688445914cfb65036eeadc1 Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 2 Jan 2019 19:04:50 -0500 Subject: [PATCH] Clean up some Odd Egg and Battle Tower code and data Fixes #589 --- constants/battle_tower_constants.asm | 2 +- constants/pokemon_data_constants.asm | 12 +++++---- data/events/odd_eggs.asm | 30 ++++++++++----------- engine/events/battle_tower/battle_tower.asm | 2 +- engine/events/battle_tower/load_trainer.asm | 10 +++---- engine/events/odd_egg.asm | 14 +++++----- mobile/mobile_5c.asm | 2 +- 7 files changed, 37 insertions(+), 35 deletions(-) diff --git a/constants/battle_tower_constants.asm b/constants/battle_tower_constants.asm index 0965d626a..9bf7bd7aa 100644 --- a/constants/battle_tower_constants.asm +++ b/constants/battle_tower_constants.asm @@ -5,7 +5,7 @@ BATTLETOWER_NUM_UNIQUE_MON EQU 21 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 diff --git a/constants/pokemon_data_constants.asm b/constants/pokemon_data_constants.asm index 1aedf20cb..ac88133d6 100644 --- a/constants/pokemon_data_constants.asm +++ b/constants/pokemon_data_constants.asm @@ -97,6 +97,8 @@ MON_SAT EQUS "(wPartyMon1SpclAtk - wPartyMon1)" 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 @@ MONS_PER_BOX EQU 20 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_HOF_TEAMS = 30 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) diff --git a/data/events/odd_eggs.asm b/data/events/odd_eggs.asm index a3c942ff7..5b251645a 100644 --- a/data/events/odd_eggs.asm +++ b/data/events/odd_eggs.asm @@ -29,7 +29,6 @@ prob_total = 0 OddEggs: -OddEgg1: db PICHU db NO_ITEM db THUNDERSHOCK, CHARM, DIZZY_PUNCH, 0 @@ -43,7 +42,7 @@ OddEgg1: 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 @@ OddEgg1: bigdw 8 ; SAtk bigdw 8 ; SDef db "EGG@@@@@@@@" -OddEgg1End: db PICHU db NO_ITEM @@ -70,7 +68,7 @@ OddEgg1End: 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 @@ OddEgg1End: 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 @@ OddEgg1End: 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 @@ OddEgg1End: 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 @@ OddEgg1End: 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 @@ OddEgg1End: 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 @@ OddEgg1End: 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 @@ OddEgg1End: 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 @@ OddEgg1End: 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 @@ OddEgg1End: 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 @@ OddEgg1End: 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 @@ OddEgg1End: 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 @@ OddEgg1End: 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 diff --git a/engine/events/battle_tower/battle_tower.asm b/engine/events/battle_tower/battle_tower.asm index 981491547..dcfe6ae22 100644 --- a/engine/events/battle_tower/battle_tower.asm +++ b/engine/events/battle_tower/battle_tower.asm @@ -480,7 +480,7 @@ endr 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 diff --git a/engine/events/battle_tower/load_trainer.asm b/engine/events/battle_tower/load_trainer.asm index 517b0e48e..0e4c9d04a 100644 --- a/engine/events/battle_tower/load_trainer.asm +++ b/engine/events/battle_tower/load_trainer.asm @@ -7,7 +7,7 @@ Function_LoadOpponentTrainerAndPokemons: ; 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 @@ Function_LoadRandomBattleTowerMon: 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 @@ Function_LoadRandomBattleTowerMon: ; 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 @@ Function_LoadRandomBattleTowerMon: 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 diff --git a/engine/events/odd_egg.asm b/engine/events/odd_egg.asm index 74b971806..f58ac0770 100644 --- a/engine/events/odd_egg.asm +++ b/engine/events/odd_egg.asm @@ -39,11 +39,13 @@ _GiveOddEgg: .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 @@ _GiveOddEgg: 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 diff --git a/mobile/mobile_5c.asm b/mobile/mobile_5c.asm index 5a73ea8a6..7ba1e737f 100644 --- a/mobile/mobile_5c.asm +++ b/mobile/mobile_5c.asm @@ -242,7 +242,7 @@ CheckBTMonMovesForErrors: .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