From f88eeb607409528dadbf841f2cb8e805d6e86deb Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Tue, 10 Jan 2017 23:17:43 -0500 Subject: more labels and finish decompiling battle_ai.c except for unk_24 (#184) * labels for save_menu_util.c * formatting, i suck at it * fix sub_80712B4 to not use MyTask struct * pls don't kill me * current changes * decompile BattleAICmd_if_damage_bonus * formatting * label thinking struct unk8 * decompile BattleAICMd_if_status_not_in_party * decompile more battle_ai.c functions * Began decompilation of a random file * decompile BattleAICmd_if_can_faint and BattleAICmd_if_cant_faint * decompile unk_3F and unk_40 * decompile if_move_effect and if_not_move_effect * formatting, silly * decompile if_last_move_did_damage and if_encored * decompile unk_45 if_random_2 and unk_47 * decompile get_hold_effect and get_gender * decompile is_first_turn and get_stockpile_count * decompile unk_4C and get_item * decompile unk_4E unk_4F and unk_50 * decompile get_protect_count and the remaining stub macros * decompile call jump and unk_5A * decompile if_level_cond * decompile the last AI macros besides unk_24 * finish decompiling battle_ai.c except for unk_24 --- include/battle.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'include/battle.h') diff --git a/include/battle.h b/include/battle.h index d58b234e3..4f1bc70e1 100644 --- a/include/battle.h +++ b/include/battle.h @@ -38,7 +38,7 @@ struct AI_ThinkingStruct /* 0x2016800 */ /* 0x01 */ u8 moveConsidered; /* 0x02 */ u16 unk2; /* 0x04 */ s8 score[4]; // score? -/* 0x08 */ u32 unk8; +/* 0x08 */ u32 funcResult; /* 0x0C */ u32 aiFlags; /* 0x10 */ u8 unk10; /* 0x11 */ u8 aiLogicId; @@ -54,14 +54,22 @@ struct SmallBattleStruct1 u8 unk4; }; +struct SmallItemStruct +{ + u8 item[2][2]; +}; + struct BattleStruct /* 0x2000000 */ { u8 filler0[0x1601C]; struct SmallBattleStruct1 unk; - u8 filler1[0xAB]; // 0x2016020 + u8 filler1[0x68]; // 0x2016020 + u8 unk88; + u8 filler1_2[0x42]; /* 0x160CB */ u8 linkPlayerIndex; - u8 filler2[0x734]; - struct AI_ThinkingStruct ai; + struct SmallItemStruct item; + u8 filler2[0x730]; + struct AI_ThinkingStruct ai; /* 0x2016800 */ }; extern struct BattleStruct battle_2000000; -- cgit v1.2.3 From ed8f49d5e1418309cbc4f705a242d073258c8639 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 28 Jan 2017 13:51:14 -0800 Subject: tabs to spaces --- include/battle.h | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'include/battle.h') diff --git a/include/battle.h b/include/battle.h index 4f1bc70e1..82ed5f29c 100644 --- a/include/battle.h +++ b/include/battle.h @@ -19,17 +19,17 @@ struct Trainer { - /*0x00*/ u8 partyFlags; - /*0x01*/ u8 trainerClass; - /*0x02*/ u8 encounterMusic:7; - /*0x02*/ u8 gender:1; - /*0x03*/ u8 trainerPic; - /*0x04*/ u8 trainerName[12]; - /*0x10*/ u16 items[4]; - /*0x18*/ bool8 doubleBattle; - /*0x1C*/ u32 aiFlags; - /*0x20*/ u8 partySize; - /*0x24*/ void *party; + /*0x00*/ u8 partyFlags; + /*0x01*/ u8 trainerClass; + /*0x02*/ u8 encounterMusic:7; + /*0x02*/ u8 gender:1; + /*0x03*/ u8 trainerPic; + /*0x04*/ u8 trainerName[12]; + /*0x10*/ u16 items[4]; + /*0x18*/ bool8 doubleBattle; + /*0x1C*/ u32 aiFlags; + /*0x20*/ u8 partySize; + /*0x24*/ void *party; }; struct AI_ThinkingStruct /* 0x2016800 */ @@ -48,28 +48,28 @@ struct AI_ThinkingStruct /* 0x2016800 */ struct SmallBattleStruct1 { - u8 unk1; - u8 unk2; - u8 unk3; - u8 unk4; + u8 unk1; + u8 unk2; + u8 unk3; + u8 unk4; }; struct SmallItemStruct { - u8 item[2][2]; + u8 item[2][2]; }; struct BattleStruct /* 0x2000000 */ { - u8 filler0[0x1601C]; - struct SmallBattleStruct1 unk; - u8 filler1[0x68]; // 0x2016020 - u8 unk88; - u8 filler1_2[0x42]; - /* 0x160CB */ u8 linkPlayerIndex; - struct SmallItemStruct item; - u8 filler2[0x730]; - struct AI_ThinkingStruct ai; /* 0x2016800 */ + u8 filler0[0x1601C]; + struct SmallBattleStruct1 unk; + u8 filler1[0x68]; // 0x2016020 + u8 unk88; + u8 filler1_2[0x42]; + /* 0x160CB */ u8 linkPlayerIndex; + struct SmallItemStruct item; + u8 filler2[0x730]; + struct AI_ThinkingStruct ai; /* 0x2016800 */ }; extern struct BattleStruct battle_2000000; -- cgit v1.2.3 From c22eb152ced1fe3bc8f9f0342a47d429bfa4c5a0 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Thu, 2 Feb 2017 00:50:47 -0500 Subject: label, document, reorganize, and clean up battle_ai.c (#228) label, document, reorganize, and clean up battle_ai.c --- include/battle.h | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'include/battle.h') diff --git a/include/battle.h b/include/battle.h index 82ed5f29c..be5b5f2d2 100644 --- a/include/battle.h +++ b/include/battle.h @@ -17,6 +17,15 @@ #define BATTLE_TYPE_LEGENDARY 0x2000 #define BATTLE_TYPE_REGI 0x4000 +#define AI_ACTION_UNK1 0x0001 +#define AI_ACTION_UNK2 0x0002 +#define AI_ACTION_UNK3 0x0004 +#define AI_ACTION_UNK4 0x0008 +#define AI_ACTION_UNK5 0x0010 +#define AI_ACTION_UNK6 0x0020 +#define AI_ACTION_UNK7 0x0040 +#define AI_ACTION_UNK8 0x0080 + struct Trainer { /*0x00*/ u8 partyFlags; @@ -32,15 +41,24 @@ struct Trainer /*0x24*/ void *party; }; +struct UnknownStruct1 +{ + /*0x00*/ u16 unk0[2][8]; + /*0x20*/ u8 unk20[2]; + /*0x22*/ u8 unk22[2]; + /*0x24*/ u16 items[4]; + /*0x2C*/ u8 unk8; +}; + struct AI_ThinkingStruct /* 0x2016800 */ { -/* 0x00 */ u8 unk0; -/* 0x01 */ u8 moveConsidered; -/* 0x02 */ u16 unk2; +/* 0x00 */ u8 aiState; +/* 0x01 */ u8 movesetIndex; +/* 0x02 */ u16 moveConsidered; /* 0x04 */ s8 score[4]; // score? /* 0x08 */ u32 funcResult; /* 0x0C */ u32 aiFlags; -/* 0x10 */ u8 unk10; +/* 0x10 */ u8 aiAction; /* 0x11 */ u8 aiLogicId; /* 0x12 */ u8 filler12[6]; /* 0x18 */ u8 unk18[4]; @@ -56,7 +74,7 @@ struct SmallBattleStruct1 struct SmallItemStruct { - u8 item[2][2]; + u8 itemLocal[2][3]; }; struct BattleStruct /* 0x2000000 */ @@ -64,14 +82,17 @@ struct BattleStruct /* 0x2000000 */ u8 filler0[0x1601C]; struct SmallBattleStruct1 unk; u8 filler1[0x68]; // 0x2016020 - u8 unk88; + u8 safariFleeRate; u8 filler1_2[0x42]; /* 0x160CB */ u8 linkPlayerIndex; - struct SmallItemStruct item; - u8 filler2[0x730]; - struct AI_ThinkingStruct ai; /* 0x2016800 */ + /* 0x160CC */ struct SmallItemStruct item; + u8 filler2[0x72E]; + /* 0x16800 */ struct AI_ThinkingStruct ai; /* 0x2016800 */ + u8 filler1681C[0x1E4]; + /* 0x16A00 */ struct UnknownStruct1 unk_2016A00_2; }; +extern struct UnknownStruct1 unk_2016A00; extern struct BattleStruct battle_2000000; extern struct AI_ThinkingStruct gAIThinkingSpace; -- cgit v1.2.3 From f21587ea9eb1190ac2136d72deb7929c1e1169eb Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sat, 11 Feb 2017 00:38:59 -0500 Subject: misc labels and memcpy/set cleanups (#232) * some labels and enumerate player speeds * clear up speed enums * GetPlayerSpeed * oops * start decompiling mauville_old_man.c * formatting * decompile more of mauville_old_man.c * someone fix this please * formatting * make ROM build again * formatting again * make ROM match again * label, document, reorganize, and clean up battle_ai.c * move stuff to battle.h and get rid of battle_2000000 * various changes * labeling * minor labels and formatting * contest ai labels and misc stuff --- include/battle.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 12 deletions(-) (limited to 'include/battle.h') diff --git a/include/battle.h b/include/battle.h index be5b5f2d2..daaa78cd3 100644 --- a/include/battle.h +++ b/include/battle.h @@ -17,15 +17,36 @@ #define BATTLE_TYPE_LEGENDARY 0x2000 #define BATTLE_TYPE_REGI 0x4000 -#define AI_ACTION_UNK1 0x0001 -#define AI_ACTION_UNK2 0x0002 -#define AI_ACTION_UNK3 0x0004 -#define AI_ACTION_UNK4 0x0008 +#define AI_ACTION_DONE 0x0001 +#define AI_ACTION_FLEE 0x0002 +#define AI_ACTION_WATCH 0x0004 +#define AI_ACTION_DO_NOT_ATTACK 0x0008 #define AI_ACTION_UNK5 0x0010 #define AI_ACTION_UNK6 0x0020 #define AI_ACTION_UNK7 0x0040 #define AI_ACTION_UNK8 0x0080 +#define MAX_TRAINER_ITEMS 4 +#define MAX_MON_MOVES 4 + +// needed to match the hack that is get_item, thanks cam, someone else clean this up later. +extern u8 unk_2000000[]; + +// to do: maybe try to reduce the defines needed to match? +#define BATTLE_STRUCT ((struct BattleStruct *)(unk_2000000)) +#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(unk_2000000 + 0x16800)) +#define UNK_2016A00_STRUCT ((struct UnknownStruct1 *)(unk_2000000 + 0x16A00)) +#define AI_STACK ((struct AI_Stack *)(unk_2000000 + 0x16C00)) +#define AI_ARRAY_160CC ((struct SmallItemStruct *)(unk_2000000 + 0x160CC)) + +enum +{ + WEATHER_SUN, + WEATHER_RAIN, + WEATHER_SANDSTORM, + WEATHER_HAIL, +}; + struct Trainer { /*0x00*/ u8 partyFlags; @@ -41,13 +62,19 @@ struct Trainer /*0x24*/ void *party; }; -struct UnknownStruct1 +struct UnknownStruct1 // AI_Opponent_Info? { - /*0x00*/ u16 unk0[2][8]; + /*0x00*/ u16 movesUsed[2][8]; // 0xFFFF means move not used (confuse self hit, etc) /*0x20*/ u8 unk20[2]; /*0x22*/ u8 unk22[2]; /*0x24*/ u16 items[4]; - /*0x2C*/ u8 unk8; + /*0x2C*/ u8 numOfItems; +}; + +struct AI_Stack +{ + u8 *ptr[8]; + u8 size; }; struct AI_ThinkingStruct /* 0x2016800 */ @@ -61,7 +88,7 @@ struct AI_ThinkingStruct /* 0x2016800 */ /* 0x10 */ u8 aiAction; /* 0x11 */ u8 aiLogicId; /* 0x12 */ u8 filler12[6]; -/* 0x18 */ u8 unk18[4]; +/* 0x18 */ u8 simulatedRNG[4]; }; struct SmallBattleStruct1 @@ -70,6 +97,7 @@ struct SmallBattleStruct1 u8 unk2; u8 unk3; u8 unk4; + // unknown size }; struct SmallItemStruct @@ -82,18 +110,33 @@ struct BattleStruct /* 0x2000000 */ u8 filler0[0x1601C]; struct SmallBattleStruct1 unk; u8 filler1[0x68]; // 0x2016020 - u8 safariFleeRate; + /* 0x16089 */ u8 safariFleeRate; u8 filler1_2[0x42]; /* 0x160CB */ u8 linkPlayerIndex; /* 0x160CC */ struct SmallItemStruct item; u8 filler2[0x72E]; /* 0x16800 */ struct AI_ThinkingStruct ai; /* 0x2016800 */ - u8 filler1681C[0x1E4]; - /* 0x16A00 */ struct UnknownStruct1 unk_2016A00_2; + u8 filler1681C[0x1E4]; + /* 0x16A00 */ struct UnknownStruct1 unk_2016A00_2; +}; + +struct UnknownStruct4 +{ + u8 filler0[0x3]; + u16 unk4; + u16 unk6; + u8 unk8; + u8 unk9; + u8 fillerA[0x9]; + u8 taunt:4; + u8 unkC:4; + u8 fillerD[0x2]; + u8 unk16; + u8 filler17[0x4]; }; extern struct UnknownStruct1 unk_2016A00; -extern struct BattleStruct battle_2000000; +extern struct UnknownStruct4 gUnknown_02024CA8[]; extern struct AI_ThinkingStruct gAIThinkingSpace; #endif // GUARD_BATTLE_H -- cgit v1.2.3 From 6035511c139549a0291b6b3d43b9b080f792b2b6 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sat, 18 Mar 2017 04:00:15 +0100 Subject: reorganize and add new headers for many files --- include/battle.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include/battle.h') diff --git a/include/battle.h b/include/battle.h index daaa78cd3..4b9144721 100644 --- a/include/battle.h +++ b/include/battle.h @@ -107,9 +107,12 @@ struct SmallItemStruct struct BattleStruct /* 0x2000000 */ { - u8 filler0[0x1601C]; + u8 filler0[0x15DDE]; + /*0x15DDE*/ u8 unk15DDE; + /*0x15DDF*/ u8 unk15DDF; + /*0x15DE0*/ u8 filler15DE0[0x23C]; // 0xAF off? struct SmallBattleStruct1 unk; - u8 filler1[0x68]; // 0x2016020 + u8 filler1[0x68]; /* 0x16089 */ u8 safariFleeRate; u8 filler1_2[0x42]; /* 0x160CB */ u8 linkPlayerIndex; -- cgit v1.2.3