From 13c196eda57ebbdb3c7e14bebd2985f1edceae34 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 21 Oct 2017 19:51:28 -0700 Subject: More battle_tower work --- include/battle_tower.h | 3 +- include/global.h | 85 +++++++++++++++++++++++++++++++++++++++---------- include/record_mixing.h | 2 +- 3 files changed, 72 insertions(+), 18 deletions(-) (limited to 'include') diff --git a/include/battle_tower.h b/include/battle_tower.h index 75ea405ab..e70930faa 100644 --- a/include/battle_tower.h +++ b/include/battle_tower.h @@ -1,7 +1,8 @@ #ifndef GUARD_BATTLE_TOWER_H #define GUARD_BATTLE_TOWER_H -void sub_8134AC0(void *); +void sub_813461C(u8 levelType); +void sub_8134AC0(struct BattleTowerRecord *); u16 sub_8135D3C(u8); void sub_8135FF4(u8*); diff --git a/include/global.h b/include/global.h index 7c1ac9c68..6a7f6396c 100644 --- a/include/global.h +++ b/include/global.h @@ -727,26 +727,79 @@ struct Pokedex /*0x44*/ u8 seen[DEX_FLAGS_NO]; }; +// struct EReaderTrainerPokemon +// { +// /*0x00, 0x4CC*/u16 unk0; +// /*0x02, 0x4CE*/u16 unk2; +// /*0x04, 0x4D0*/u8 unk4[0x8]; +// /*0x0C, 0x4D8*/u8 level; +// /*0x0D, 0x4D9*/u8 unk9[0x1F]; +// }; + +// struct EReaderTrainer +// { +// /*0x00, 0x498*/u8 filler_0[2]; +// /*0x02, 0x49A*/u16 unk2; +// /*0x04, 0x49C*/u8 filler_4[0x30]; +// /*0x34, 0x4CC*/struct EReaderTrainerPokemon party[3]; +// /*0xB8, 0x550*/u32 unkB8; +// }; + +struct SaveBlock2_1 +{ + u32 filler_0[0x29]; +}; + +struct BattleTowerTrainer +{ + u8 trainerClass; + u8 name[8]; + u8 teamFlags; + u16 padding; + u16 easyChat[6]; +}; + +struct BattleTowerRecord // record mixing +{ + /*0x00*/u8 var_0; + /*0x01*/u8 trainerClass; + /*0x02*/u16 var_2; + /*0x04*/u8 name[8]; + /*0x0C*/u8 var_C[5]; + u8 filler[0x93]; +}; + +struct BattleTowerEReaderTrainer +{ + /*0x00*/u8 unk0; + /*0x01*/u8 trainerClass; + /*0x02*/u16 filler_2; + /*0x04*/u8 name[8]; + /*0x0B*/u8 ereaderTrainer[0xB0]; +}; + struct SaveBlock2_Sub { - /*0x0000, 0x00A8*/ u8 filler_000[0x3D8]; - /*0x03D8, 0x0480*/ u16 var_480; - /*0x03DA, 0x0482*/ u16 var_482; + /*0x0000, 0x00A8*/ struct BattleTowerRecord var_A8; + /*0x00A4, 0x014C*/ struct BattleTowerRecord var_14C[5]; + /*0x03D8, 0x0480*/ u16 firstMonSpecies; // species of the first pokemon in the player's battle tower party + /*0x03DA, 0x0482*/ u16 defeatedBySpecies; // species of the pokemon that defated the player in their battle tower streak. /*0x03DC, 0x0484*/ u8 filler_3DC[0x14]; - /*0x03F0, 0x0498*/ u8 ereaderTrainer[0xBC]; - /*0x04AC, 0x0554*/ u8 var_4AC; - /*0x04AD, 0x0555*/ u8 var_4AD; + /*0x03F0, 0x0498*/ struct BattleTowerEReaderTrainer ereaderTrainer; + /*0x04AC, 0x0554*/ u8 battleTowerLevelType:1; // 0 = level 50; 1 = level 100 + /*0x04AD, 0x0555*/ u8 var_4AD; // used by tv, but ultimately does nothing, since both code paths are identical /*0x04AE, 0x0556*/ u8 var_4AE[2]; - /*0x04B0, 0x0558*/ u16 var_4B0; - /*0x04B2, 0x055A*/ u16 var_4B2; - /*0x04B4, 0x055C*/ u16 var_4B4; - /*0x04B6, 0x055E*/ u16 var_4B6; - /*0x04B8, 0x0560*/ u16 recordWinStreak[2]; - /*0x04BC, 0x0564*/ u8 filler_4BC[0xC]; - /*0x04C8, 0x0570*/ u16 var_4C8; - /*0x04CA, 0x0572*/ u16 var_4CA; - /*0x04CC, 0x0574*/ u16 winStreak[2]; - /*0x04D0, 0x0578*/ u8 var_4D0; + /*0x04B0, 0x0558*/ u16 var_4B0[2]; + /*0x04B4, 0x055C*/ u16 var_4B4[2]; + /*0x04B8, 0x0560*/ u16 recordWinStreaks[2]; + /*0x04BC, 0x0564*/ u8 battleTowerTrainerId; // index for gBattleTowerTrainers table + /*0x04BD, 0x0565*/ u8 var_4BD[0x3]; + /*0x04C0, 0x0568*/ u8 var_4C0; + /*0x04C1, 0x0569*/ u8 var_4C1[0x7]; + /*0x04C8, 0x0570*/ u16 totalBattleTowerWins; + /*0x04CA, 0x0572*/ u16 bestBattleTowerWinStreak; + /*0x04CC, 0x0574*/ u16 currentWinStreaks[2]; + /*0x04D0, 0x0578*/ u8 lastStreakLevelType; // 0 = level 50, 1 = level 100. level type of the last streak. Used by tv to report the level mode. /*0x04D1, 0x0579*/ u8 filler_4D1[0x317]; }; diff --git a/include/record_mixing.h b/include/record_mixing.h index ca60b04a7..96105f3f7 100644 --- a/include/record_mixing.h +++ b/include/record_mixing.h @@ -21,7 +21,7 @@ u16 *GetPlayerRecvBuffer(u8 player); void sub_80B9A78(void); void sub_80B9A88(u8 *a); void sub_80B9B1C(u8 *a, size_t size, u8 index); -void sub_80B9B70(u8 *a, size_t size, u8 index); +void sub_80B9B70(void *a, u32 size, u8 index); u8 sub_80B9BBC(u16 *a); void sub_80B9BC4(u8 *, size_t, u8[][2], u8 d, u8 e); u8 sub_80B9C4C(u8 *a); -- cgit v1.2.3 From 949a003bd1c81ae927764401a07bd83e2debb9b5 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sun, 22 Oct 2017 15:43:32 -0700 Subject: Move battle_tower level50 mons to src/ --- include/battle_tower.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) (limited to 'include') diff --git a/include/battle_tower.h b/include/battle_tower.h index e70930faa..2f3be2763 100644 --- a/include/battle_tower.h +++ b/include/battle_tower.h @@ -1,6 +1,93 @@ #ifndef GUARD_BATTLE_TOWER_H #define GUARD_BATTLE_TOWER_H +enum +{ + F_EV_SPREAD_HP = 1 << 0, + F_EV_SPREAD_ATTACK = 1 << 1, + F_EV_SPREAD_DEFENSE = 1 << 2, + F_EV_SPREAD_SPEED = 1 << 3, + F_EV_SPREAD_SP_ATTACK = 1 << 4, + F_EV_SPREAD_SP_DEFENSE = 1 << 5, +}; + +enum +{ + BATTLE_TOWER_ITEM_NONE, + BATTLE_TOWER_ITEM_KINGS_ROCK, + BATTLE_TOWER_ITEM_SITRUS_BERRY, + BATTLE_TOWER_ITEM_ORAN_BERRY, + BATTLE_TOWER_ITEM_CHESTO_BERRY, + BATTLE_TOWER_ITEM_HARD_STONE, + BATTLE_TOWER_ITEM_FOCUS_BAND, + BATTLE_TOWER_ITEM_PERSIM_BERRY, + BATTLE_TOWER_ITEM_MIRACLE_SEED, + BATTLE_TOWER_ITEM_BERRY_JUICE, + BATTLE_TOWER_ITEM_MACHO_BRACE, + BATTLE_TOWER_ITEM_SILVER_POWDER, + BATTLE_TOWER_ITEM_CHERI_BERRY, + BATTLE_TOWER_ITEM_BLACK_GLASSES, + BATTLE_TOWER_ITEM_BLACK_BELT, + BATTLE_TOWER_ITEM_SOUL_DEW, + BATTLE_TOWER_ITEM_CHOICE_BAND, + BATTLE_TOWER_ITEM_MAGNET, + BATTLE_TOWER_ITEM_SILK_SCARF, + BATTLE_TOWER_ITEM_WHITE_HERB, + BATTLE_TOWER_ITEM_DEEP_SEA_SCALE, + BATTLE_TOWER_ITEM_DEEP_SEA_TOOTH, + BATTLE_TOWER_ITEM_MYSTIC_WATER, + BATTLE_TOWER_ITEM_SHARP_BEAK, + BATTLE_TOWER_ITEM_QUICK_CLAW, + BATTLE_TOWER_ITEM_LEFTOVERS, + BATTLE_TOWER_ITEM_RAWST_BERRY, + BATTLE_TOWER_ITEM_LIGHT_BALL, + BATTLE_TOWER_ITEM_POISON_BARB, + BATTLE_TOWER_ITEM_NEVER_MELT_ICE, + BATTLE_TOWER_ITEM_ASPEAR_BERRY, + BATTLE_TOWER_ITEM_SPELL_TAG, + BATTLE_TOWER_ITEM_BRIGHT_POWDER, + BATTLE_TOWER_ITEM_LEPPA_BERRY, + BATTLE_TOWER_ITEM_SCOPE_LENS, + BATTLE_TOWER_ITEM_TWISTED_SPOON, + BATTLE_TOWER_ITEM_METAL_COAT, + BATTLE_TOWER_ITEM_MENTAL_HERB, + BATTLE_TOWER_ITEM_CHARCOAL, + BATTLE_TOWER_ITEM_PECHA_BERRY, + BATTLE_TOWER_ITEM_SOFT_SAND, + BATTLE_TOWER_ITEM_LUM_BERRY, + BATTLE_TOWER_ITEM_DRAGON_SCALE, + BATTLE_TOWER_ITEM_DRAGON_FANG, + BATTLE_TOWER_ITEM_IAPAPA_BERRY, + BATTLE_TOWER_ITEM_WIKI_BERRY, + BATTLE_TOWER_ITEM_SEA_INCENSE, + BATTLE_TOWER_ITEM_SHELL_BELL, + BATTLE_TOWER_ITEM_SALAC_BERRY, + BATTLE_TOWER_ITEM_LANSAT_BERRY, + BATTLE_TOWER_ITEM_APICOT_BERRY, + BATTLE_TOWER_ITEM_STARF_BERRY, + BATTLE_TOWER_ITEM_LIECHI_BERRY, + BATTLE_TOWER_ITEM_STICK, + BATTLE_TOWER_ITEM_LAX_INCENSE, + BATTLE_TOWER_ITEM_AGUAV_BERRY, + BATTLE_TOWER_ITEM_FIGY_BERRY, + BATTLE_TOWER_ITEM_THICK_CLUB, + BATTLE_TOWER_ITEM_MAGO_BERRY, + BATTLE_TOWER_ITEM_METAL_POWDER, + BATTLE_TOWER_ITEM_PETAYA_BERRY, + BATTLE_TOWER_ITEM_LUCKY_PUNCH, + BATTLE_TOWER_ITEM_GANLON_BERRY, +}; + +struct BattleTowerPokemon +{ + /*0x00*/u16 species; + /*0x02*/u8 item; + /*0x03*/u8 teamFlags; + /*0x04*/u16 moves[4]; + /*0x0C*/u8 evSpread; + /*0x0D*/u8 nature; +}; + void sub_813461C(u8 levelType); void sub_8134AC0(struct BattleTowerRecord *); u16 sub_8135D3C(u8); -- cgit v1.2.3 From f90bc99a49a3d4fa60e96cd6fbcb546f8e3a1da0 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Mon, 23 Oct 2017 17:45:02 -0700 Subject: Move all battle_tower data into src/ --- include/global.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 6a7f6396c..11611dc41 100644 --- a/include/global.h +++ b/include/global.h @@ -755,8 +755,9 @@ struct BattleTowerTrainer u8 trainerClass; u8 name[8]; u8 teamFlags; - u16 padding; - u16 easyChat[6]; + struct { + u16 easyChat[6]; + } greeting; }; struct BattleTowerRecord // record mixing -- cgit v1.2.3 From e27be38588bc1d2d3e26e10c87d5de91a5cbab21 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Mon, 23 Oct 2017 19:32:10 -0700 Subject: More decomp of battle_tower --- include/easy_chat.h | 1 + include/global.h | 18 ++++++++++++++---- include/pokemon.h | 46 +++++++++++++++++++++++----------------------- 3 files changed, 38 insertions(+), 27 deletions(-) (limited to 'include') diff --git a/include/easy_chat.h b/include/easy_chat.h index 8a820353f..b59adedd5 100644 --- a/include/easy_chat.h +++ b/include/easy_chat.h @@ -1080,6 +1080,7 @@ u8 sub_80EB868(u8); void sub_80EB890(u8); u8 sub_80EB8C0(void); u16 sub_80EB8EC(void); +u8 *sub_80EB544(u8 *dst, u16 *words, u16 arg2, u16 arg3); #if GERMAN u32 de_sub_80EB748(u32, u32); diff --git a/include/global.h b/include/global.h index 11611dc41..1431bf772 100644 --- a/include/global.h +++ b/include/global.h @@ -766,8 +766,11 @@ struct BattleTowerRecord // record mixing /*0x01*/u8 trainerClass; /*0x02*/u16 var_2; /*0x04*/u8 name[8]; - /*0x0C*/u8 var_C[5]; - u8 filler[0x93]; + /*0x0C*/u8 var_C[4]; + /*0x10*/struct { + u16 easyChat[6]; + } greeting; + /*0x1C*/u8 filler[0x87]; }; struct BattleTowerEReaderTrainer @@ -775,8 +778,14 @@ struct BattleTowerEReaderTrainer /*0x00*/u8 unk0; /*0x01*/u8 trainerClass; /*0x02*/u16 filler_2; - /*0x04*/u8 name[8]; - /*0x0B*/u8 ereaderTrainer[0xB0]; + /*0x04*/u8 name[7]; + /*0x0B*/u8 filler_B[0x5]; + /*0x10*/struct { + u16 easyChat[6]; + } greeting; + /*0x1C*/u8 filler_1C[0x18]; + /*0x34*/struct UnknownPokemonStruct party[3]; + /*0xB8*/u32 unk_B0; }; struct SaveBlock2_Sub @@ -788,6 +797,7 @@ struct SaveBlock2_Sub /*0x03DC, 0x0484*/ u8 filler_3DC[0x14]; /*0x03F0, 0x0498*/ struct BattleTowerEReaderTrainer ereaderTrainer; /*0x04AC, 0x0554*/ u8 battleTowerLevelType:1; // 0 = level 50; 1 = level 100 + /*0x04AC, 0x0554*/ u8 unk_554:1; /*0x04AD, 0x0555*/ u8 var_4AD; // used by tv, but ultimately does nothing, since both code paths are identical /*0x04AE, 0x0556*/ u8 var_4AE[2]; /*0x04B0, 0x0558*/ u16 var_4B0[2]; diff --git a/include/pokemon.h b/include/pokemon.h index 4c3e27609..554d18aa6 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -288,29 +288,29 @@ struct Pokemon struct UnknownPokemonStruct { - u16 species; - u16 heldItem; - u16 moves[4]; - u8 level; - u8 ppBonuses; - u8 hpEV; - u8 attackEV; - u8 defenseEV; - u8 speedEV; - u8 spAttackEV; - u8 spDefenseEV; - u32 otId; - u32 hpIV:5; - u32 attackIV:5; - u32 defenseIV:5; - u32 speedIV:5; - u32 spAttackIV:5; - u32 spDefenseIV:5; - u32 gap:1; - u32 altAbility:1; - u32 personality; - u8 nickname[POKEMON_NAME_LENGTH + 1]; - u8 friendship; + /*0x00*/u16 species; + /*0x02*/u16 heldItem; + /*0x04*/u16 moves[4]; + /*0x0C*/u8 level; + /*0x0D*/u8 ppBonuses; + /*0x0E*/u8 hpEV; + /*0x0F*/u8 attackEV; + /*0x10*/u8 defenseEV; + /*0x11*/u8 speedEV; + /*0x12*/u8 spAttackEV; + /*0x13*/u8 spDefenseEV; + /*0x14*/u32 otId; + /*0x18*/u32 hpIV:5; + /*0x18*/u32 attackIV:5; + /*0x19*/u32 defenseIV:5; + /*0x19*/u32 speedIV:5; + /*0x1A*/u32 spAttackIV:5; + /*0x1A*/u32 spDefenseIV:5; + /*0x1B*/u32 gap:1; + /*0x1B*/u32 altAbility:1; + /*0x1C*/u32 personality; + /*0x20*/u8 nickname[POKEMON_NAME_LENGTH + 1]; + /*0x2B*/u8 friendship; }; struct BattlePokemon -- cgit v1.2.3 From 978ca50dad8de72a3940b5423fd5c3b87c13eb46 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 28 Oct 2017 17:35:37 -0700 Subject: Even more battle tower decompilation --- include/global.h | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 1431bf772..4cc5f6bcc 100644 --- a/include/global.h +++ b/include/global.h @@ -681,10 +681,12 @@ struct SaveBlock1 /* 0x02025734 */ /*0x2B0D*/ u8 outbreakPokemonProbability; /*0x2B0E*/ u16 outbreakUnk5; /*0x2B10*/ struct GabbyAndTyData gabbyAndTyData; - /*0x2B1C*/ u16 unk2B1C[6]; - /*0x2B28*/ u16 unk2B28[6]; - /*0x2B34*/ u16 unk2B34[6]; - /*0x2B40*/ u16 unk2B40[6]; + /*0x2B1C*/ struct { + /*0x2B1C*/ u16 unk2B1C[6]; + /*0x2B28*/ u16 unk2B28[6]; + /*0x2B34*/ u16 unk2B34[6]; + /*0x2B40*/ u16 unk2B40[6]; + } easyChats; /*0x2B4C*/ struct MailStruct mail[16]; /*0x2D8C*/ u8 unk2D8C[4]; /*0x2D90*/ u8 filler_2D90[0x4]; @@ -766,11 +768,12 @@ struct BattleTowerRecord // record mixing /*0x01*/u8 trainerClass; /*0x02*/u16 var_2; /*0x04*/u8 name[8]; - /*0x0C*/u8 var_C[4]; + /*0x0C*/u8 trainerId[4]; /*0x10*/struct { u16 easyChat[6]; } greeting; - /*0x1C*/u8 filler[0x87]; + /*0x1C*/struct UnknownPokemonStruct party[3]; + /*0xA0*/u32 checksum; }; struct BattleTowerEReaderTrainer @@ -785,7 +788,7 @@ struct BattleTowerEReaderTrainer } greeting; /*0x1C*/u8 filler_1C[0x18]; /*0x34*/struct UnknownPokemonStruct party[3]; - /*0xB8*/u32 unk_B0; + /*0xB8*/u32 checksum; }; struct SaveBlock2_Sub @@ -793,8 +796,9 @@ struct SaveBlock2_Sub /*0x0000, 0x00A8*/ struct BattleTowerRecord var_A8; /*0x00A4, 0x014C*/ struct BattleTowerRecord var_14C[5]; /*0x03D8, 0x0480*/ u16 firstMonSpecies; // species of the first pokemon in the player's battle tower party - /*0x03DA, 0x0482*/ u16 defeatedBySpecies; // species of the pokemon that defated the player in their battle tower streak. - /*0x03DC, 0x0484*/ u8 filler_3DC[0x14]; + /*0x03DA, 0x0482*/ u16 defeatedBySpecies; // species of the pokemon that defated the player + /*0x03DC, 0x0484*/ u8 defeatedByTrainerName[8]; + /*0x03E4, 0x048C*/ u8 firstMonNickname[POKEMON_NAME_LENGTH]; // nickname of the first pokemon in the player's battle tower party /*0x03F0, 0x0498*/ struct BattleTowerEReaderTrainer ereaderTrainer; /*0x04AC, 0x0554*/ u8 battleTowerLevelType:1; // 0 = level 50; 1 = level 100 /*0x04AC, 0x0554*/ u8 unk_554:1; @@ -805,8 +809,8 @@ struct SaveBlock2_Sub /*0x04B8, 0x0560*/ u16 recordWinStreaks[2]; /*0x04BC, 0x0564*/ u8 battleTowerTrainerId; // index for gBattleTowerTrainers table /*0x04BD, 0x0565*/ u8 var_4BD[0x3]; - /*0x04C0, 0x0568*/ u8 var_4C0; - /*0x04C1, 0x0569*/ u8 var_4C1[0x7]; + /*0x04C0, 0x0568*/ u16 prizeItem; + /*0x04C2, 0x056A*/ u8 var_4C2[0x6]; /*0x04C8, 0x0570*/ u16 totalBattleTowerWins; /*0x04CA, 0x0572*/ u16 bestBattleTowerWinStreak; /*0x04CC, 0x0574*/ u16 currentWinStreaks[2]; -- cgit v1.2.3 From c677029e155aa5f0ef61de708588a36085fd36b4 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 28 Oct 2017 22:18:48 -0700 Subject: More battle_tower decomp --- include/battle_tower.h | 3 +++ include/global.h | 7 ++++++- include/tv.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/battle_tower.h b/include/battle_tower.h index 2f3be2763..5f6cd3b87 100644 --- a/include/battle_tower.h +++ b/include/battle_tower.h @@ -92,5 +92,8 @@ void sub_813461C(u8 levelType); void sub_8134AC0(struct BattleTowerRecord *); u16 sub_8135D3C(u8); void sub_8135FF4(u8*); +u8 sub_8135FBC(void); +u8 sub_8135FD8(void); +void sub_813601C(void); #endif // GUARD_BATTLE_TOWER_H diff --git a/include/global.h b/include/global.h index 4cc5f6bcc..41cffe3c2 100644 --- a/include/global.h +++ b/include/global.h @@ -786,7 +786,12 @@ struct BattleTowerEReaderTrainer /*0x10*/struct { u16 easyChat[6]; } greeting; - /*0x1C*/u8 filler_1C[0x18]; + /*0x1C*/struct { + u16 easyChat[6]; + } farewellPlayerLost; + /*0x28*/struct { + u16 easyChat[6]; + } farewellPlayerWon; /*0x34*/struct UnknownPokemonStruct party[3]; /*0xB8*/u32 checksum; }; diff --git a/include/tv.h b/include/tv.h index 3243fff2c..a933e1779 100644 --- a/include/tv.h +++ b/include/tv.h @@ -107,5 +107,6 @@ void sub_80BE3BC(void); void UpdateTVShowsPerDay(u16); void sub_80C045C(); void sub_80BF088(u8, s32); +void sub_80BFD20(void); #endif // GUARD_TV_H -- cgit v1.2.3 From b9252e4f2803fe14bd7dd8385da595931b82c8d6 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 28 Oct 2017 22:59:19 -0700 Subject: Give more descriptive names for battle tower structs --- include/global.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 41cffe3c2..9b4320c81 100644 --- a/include/global.h +++ b/include/global.h @@ -780,7 +780,7 @@ struct BattleTowerEReaderTrainer { /*0x00*/u8 unk0; /*0x01*/u8 trainerClass; - /*0x02*/u16 filler_2; + /*0x02*/u16 filler_2; // TODO: this gets set in MEScrCmd_addtrainer /*0x04*/u8 name[7]; /*0x0B*/u8 filler_B[0x5]; /*0x10*/struct { @@ -796,10 +796,10 @@ struct BattleTowerEReaderTrainer /*0xB8*/u32 checksum; }; -struct SaveBlock2_Sub +struct BattleTowerData { - /*0x0000, 0x00A8*/ struct BattleTowerRecord var_A8; - /*0x00A4, 0x014C*/ struct BattleTowerRecord var_14C[5]; + /*0x0000, 0x00A8*/ struct BattleTowerRecord playerRecord; + /*0x00A4, 0x014C*/ struct BattleTowerRecord records[5]; // from record mixing /*0x03D8, 0x0480*/ u16 firstMonSpecies; // species of the first pokemon in the player's battle tower party /*0x03DA, 0x0482*/ u16 defeatedBySpecies; // species of the pokemon that defated the player /*0x03DC, 0x0484*/ u8 defeatedByTrainerName[8]; @@ -807,13 +807,13 @@ struct SaveBlock2_Sub /*0x03F0, 0x0498*/ struct BattleTowerEReaderTrainer ereaderTrainer; /*0x04AC, 0x0554*/ u8 battleTowerLevelType:1; // 0 = level 50; 1 = level 100 /*0x04AC, 0x0554*/ u8 unk_554:1; - /*0x04AD, 0x0555*/ u8 var_4AD; // used by tv, but ultimately does nothing, since both code paths are identical + /*0x04AD, 0x0555*/ u8 battleOutcome; /*0x04AE, 0x0556*/ u8 var_4AE[2]; - /*0x04B0, 0x0558*/ u16 var_4B0[2]; - /*0x04B4, 0x055C*/ u16 var_4B4[2]; + /*0x04B0, 0x0558*/ u16 curChallengeWins[2]; // number of wins in the current challenge. (challenges consist of 7 battles) + /*0x04B4, 0x055C*/ u16 curStreakChallengesCompleted[2]; // number of challenges completed in the current streak. /*0x04B8, 0x0560*/ u16 recordWinStreaks[2]; /*0x04BC, 0x0564*/ u8 battleTowerTrainerId; // index for gBattleTowerTrainers table - /*0x04BD, 0x0565*/ u8 var_4BD[0x3]; + /*0x04BD, 0x0565*/ u8 selectedPartyMons[0x3]; // indices of the 3 selected player party mons. /*0x04C0, 0x0568*/ u16 prizeItem; /*0x04C2, 0x056A*/ u8 var_4C2[0x6]; /*0x04C8, 0x0570*/ u16 totalBattleTowerWins; @@ -844,7 +844,7 @@ struct SaveBlock2 /* 0x02024EA4 */ /*0x90*/ u8 filler_90[0x8]; /*0x98*/ struct Time localTimeOffset; /*0xA0*/ struct Time lastBerryTreeUpdate; - /*0xA8*/ struct SaveBlock2_Sub filler_A8; + /*0xA8*/ struct BattleTowerData battleTower; }; struct MapPosition -- cgit v1.2.3 From fc786f80fd10732d23759e7c647f15406a5162d0 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sun, 29 Oct 2017 16:51:25 -0700 Subject: Decompile a few nonmatchings in battle_tower --- include/global.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 9b4320c81..43ffcae0c 100644 --- a/include/global.h +++ b/include/global.h @@ -780,7 +780,7 @@ struct BattleTowerEReaderTrainer { /*0x00*/u8 unk0; /*0x01*/u8 trainerClass; - /*0x02*/u16 filler_2; // TODO: this gets set in MEScrCmd_addtrainer + /*0x02*/u16 var_2; // TODO: this gets set in MEScrCmd_addtrainer /*0x04*/u8 name[7]; /*0x0B*/u8 filler_B[0x5]; /*0x10*/struct { -- cgit v1.2.3 From 87c0040c1adca9b41a779a89a1aaedc63849f0df Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Tue, 31 Oct 2017 23:38:46 -0700 Subject: Decompile FillBattleTowerTrainerParty() --- include/battle_tower.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/battle_tower.h b/include/battle_tower.h index 5f6cd3b87..4b5e66eac 100644 --- a/include/battle_tower.h +++ b/include/battle_tower.h @@ -81,7 +81,7 @@ enum struct BattleTowerPokemon { /*0x00*/u16 species; - /*0x02*/u8 item; + /*0x02*/u8 item; // entry in gBattleTowerHeldItems /*0x03*/u8 teamFlags; /*0x04*/u16 moves[4]; /*0x0C*/u8 evSpread; -- cgit v1.2.3 From fea6c54f45a22493768d57c16fb9b916cfdeadde Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Wed, 1 Nov 2017 21:33:03 -0700 Subject: Decompile Debug_FillEReaderTrainerWithPlayerData --- include/global.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 43ffcae0c..8461624cb 100644 --- a/include/global.h +++ b/include/global.h @@ -781,8 +781,8 @@ struct BattleTowerEReaderTrainer /*0x00*/u8 unk0; /*0x01*/u8 trainerClass; /*0x02*/u16 var_2; // TODO: this gets set in MEScrCmd_addtrainer - /*0x04*/u8 name[7]; - /*0x0B*/u8 filler_B[0x5]; + /*0x04*/u8 name[8]; + /*0x0C*/u8 trainerId[4]; /*0x10*/struct { u16 easyChat[6]; } greeting; -- cgit v1.2.3 From c5cda9f16442780794852af54635f6526c4c031a Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Wed, 1 Nov 2017 23:52:26 -0700 Subject: Use descriptive variable and function names for battle_tower code --- include/battle_tower.h | 12 ++++++------ include/global.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/battle_tower.h b/include/battle_tower.h index 4b5e66eac..a54ae6bc7 100644 --- a/include/battle_tower.h +++ b/include/battle_tower.h @@ -81,19 +81,19 @@ enum struct BattleTowerPokemon { /*0x00*/u16 species; - /*0x02*/u8 item; // entry in gBattleTowerHeldItems + /*0x02*/u8 heldItem; // entry in sBattleTowerHeldItems /*0x03*/u8 teamFlags; /*0x04*/u16 moves[4]; /*0x0C*/u8 evSpread; /*0x0D*/u8 nature; }; -void sub_813461C(u8 levelType); +u16 GetCurrentBattleTowerWinStreak(u8); void sub_8134AC0(struct BattleTowerRecord *); u16 sub_8135D3C(u8); -void sub_8135FF4(u8*); -u8 sub_8135FBC(void); -u8 sub_8135FD8(void); -void sub_813601C(void); +void SetEReaderTrainerName(u8*); +u8 GetEReaderTrainerPicIndex(void); +u8 GetEReaderTrainerClassNameIndex(void); +void ValidateEReaderTrainer(void); #endif // GUARD_BATTLE_TOWER_H diff --git a/include/global.h b/include/global.h index 8461624cb..fcdd4109c 100644 --- a/include/global.h +++ b/include/global.h @@ -764,9 +764,9 @@ struct BattleTowerTrainer struct BattleTowerRecord // record mixing { - /*0x00*/u8 var_0; + /*0x00*/u8 battleTowerLevelType; // 0 = level 50, 1 = level 100 /*0x01*/u8 trainerClass; - /*0x02*/u16 var_2; + /*0x02*/u16 winStreak; /*0x04*/u8 name[8]; /*0x0C*/u8 trainerId[4]; /*0x10*/struct { @@ -780,7 +780,7 @@ struct BattleTowerEReaderTrainer { /*0x00*/u8 unk0; /*0x01*/u8 trainerClass; - /*0x02*/u16 var_2; // TODO: this gets set in MEScrCmd_addtrainer + /*0x02*/u16 winStreak; /*0x04*/u8 name[8]; /*0x0C*/u8 trainerId[4]; /*0x10*/struct { @@ -809,8 +809,8 @@ struct BattleTowerData /*0x04AC, 0x0554*/ u8 unk_554:1; /*0x04AD, 0x0555*/ u8 battleOutcome; /*0x04AE, 0x0556*/ u8 var_4AE[2]; - /*0x04B0, 0x0558*/ u16 curChallengeWins[2]; // number of wins in the current challenge. (challenges consist of 7 battles) - /*0x04B4, 0x055C*/ u16 curStreakChallengesCompleted[2]; // number of challenges completed in the current streak. + /*0x04B0, 0x0558*/ u16 curChallengeBattleNum[2]; // 1-based index of battle in the current challenge. (challenges consist of 7 battles) + /*0x04B4, 0x055C*/ u16 curStreakChallengesNum[2]; // 1-based index of the current challenge in the current streak. /*0x04B8, 0x0560*/ u16 recordWinStreaks[2]; /*0x04BC, 0x0564*/ u8 battleTowerTrainerId; // index for gBattleTowerTrainers table /*0x04BD, 0x0565*/ u8 selectedPartyMons[0x3]; // indices of the 3 selected player party mons. -- cgit v1.2.3 From 2a682aec81c9de708d19e0ade1efef0a4f9db245 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Thu, 2 Nov 2017 17:55:40 -0700 Subject: Define constants for special battle_tower trainer ids --- include/battle_tower.h | 3 +++ include/global.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/battle_tower.h b/include/battle_tower.h index a54ae6bc7..8f179a68c 100644 --- a/include/battle_tower.h +++ b/include/battle_tower.h @@ -1,6 +1,9 @@ #ifndef GUARD_BATTLE_TOWER_H #define GUARD_BATTLE_TOWER_H +#define BATTLE_TOWER_EREADER_TRAINER_ID 200 +#define BATTLE_TOWER_RECORD_MIXING_TRAINER_BASE_ID 100 + enum { F_EV_SPREAD_HP = 1 << 0, diff --git a/include/global.h b/include/global.h index fcdd4109c..d73cd5fdf 100644 --- a/include/global.h +++ b/include/global.h @@ -815,7 +815,7 @@ struct BattleTowerData /*0x04BC, 0x0564*/ u8 battleTowerTrainerId; // index for gBattleTowerTrainers table /*0x04BD, 0x0565*/ u8 selectedPartyMons[0x3]; // indices of the 3 selected player party mons. /*0x04C0, 0x0568*/ u16 prizeItem; - /*0x04C2, 0x056A*/ u8 var_4C2[0x6]; + /*0x04C2, 0x056A*/ u8 filler_4C2[0x6]; /*0x04C8, 0x0570*/ u16 totalBattleTowerWins; /*0x04CA, 0x0572*/ u16 bestBattleTowerWinStreak; /*0x04CC, 0x0574*/ u16 currentWinStreaks[2]; -- cgit v1.2.3 From 0a95d8d97fde65213b31ed2e0412dde218b61590 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Thu, 2 Nov 2017 17:57:33 -0700 Subject: Cleanup unused structs --- include/global.h | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index d73cd5fdf..29804a5a9 100644 --- a/include/global.h +++ b/include/global.h @@ -729,29 +729,6 @@ struct Pokedex /*0x44*/ u8 seen[DEX_FLAGS_NO]; }; -// struct EReaderTrainerPokemon -// { -// /*0x00, 0x4CC*/u16 unk0; -// /*0x02, 0x4CE*/u16 unk2; -// /*0x04, 0x4D0*/u8 unk4[0x8]; -// /*0x0C, 0x4D8*/u8 level; -// /*0x0D, 0x4D9*/u8 unk9[0x1F]; -// }; - -// struct EReaderTrainer -// { -// /*0x00, 0x498*/u8 filler_0[2]; -// /*0x02, 0x49A*/u16 unk2; -// /*0x04, 0x49C*/u8 filler_4[0x30]; -// /*0x34, 0x4CC*/struct EReaderTrainerPokemon party[3]; -// /*0xB8, 0x550*/u32 unkB8; -// }; - -struct SaveBlock2_1 -{ - u32 filler_0[0x29]; -}; - struct BattleTowerTrainer { u8 trainerClass; -- cgit v1.2.3