summaryrefslogtreecommitdiff
path: root/src/rom_8094928.c
diff options
context:
space:
mode:
authorProjectRevoTPP <projectrevotpp@hotmail.com>2017-01-10 23:17:43 -0500
committerYamaArashi <YamaArashi@users.noreply.github.com>2017-01-10 20:17:43 -0800
commitf88eeb607409528dadbf841f2cb8e805d6e86deb (patch)
tree6b4f6411a0e02bff918cb924251b68a5038ae1f8 /src/rom_8094928.c
parent6b0268e0c0fb98014cb72f8a918a33c0645162d2 (diff)
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
Diffstat (limited to 'src/rom_8094928.c')
-rw-r--r--src/rom_8094928.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/rom_8094928.c b/src/rom_8094928.c
new file mode 100644
index 000000000..8cc1857eb
--- /dev/null
+++ b/src/rom_8094928.c
@@ -0,0 +1,94 @@
+#include "global.h"
+#include "pokemon.h"
+
+extern struct PokemonStorage gPokemonStorage;
+extern u8 IsLinkDoubleBattle(void);
+extern u8 IsDoubleBattle(void);
+extern u8 battle_get_side_with_given_state(u8);
+extern u8 battle_side_get_owner(u8);
+void sub_8094998(u8 [3], u8);
+void sub_8094A74(u8 [3], u8, u32);
+
+extern u8 gUnknown_02038470[3];
+extern u8 sub_803FBBC(void);
+extern u16 gUnknown_02024A6A[];
+
+void unref_sub_8094928 (void * ptr) {
+ memcpy(ptr, &gPokemonStorage, 0x83d0);
+}
+
+void unref_sub_8094940 (void * ptr) {
+ memcpy(&gPokemonStorage, ptr, 0x83d0);
+}
+
+void sub_8094958 (void) {
+ sub_8094998(gUnknown_02038470, sub_803FBBC());
+}
+
+void sub_8094978 (u8 arg1, u8 arg2) {
+ sub_8094A74((((u8 (*) [3]) 0x0201606c))[arg1], arg2, arg1);
+}
+
+void sub_8094998 (u8 arg[3], u8 player_number) {
+ int i;
+ u32 pos;
+ u8 temp[6];
+ if (IsLinkDoubleBattle() == 1)
+ if (player_number) {
+ *arg = 0x30;
+ arg[1] = 0x45;
+ arg[2] = 0x12;
+ } else {
+ *arg = 0x03;
+ arg[1] = 0x12;
+ arg[2] = 0x45;
+ }
+ else {
+ if (!IsDoubleBattle()) {
+ pos = 1;
+ *temp = gUnknown_02024A6A[battle_get_side_with_given_state(0)];
+ for (i = 0; i <= 5; i ++) if (i != *temp) temp[pos ++] = i;
+ } else {
+ pos = 2;
+ *temp = gUnknown_02024A6A[battle_get_side_with_given_state(0)];
+ temp[1] = gUnknown_02024A6A[battle_get_side_with_given_state(2)];
+ for (i = 0; i <= 5; i ++) if ((i != *temp) && (i != temp[1])) temp[pos ++] = i;
+ }
+ for (i = 0; i <= 2; i ++) arg[i] = (temp[i << 1] << 4) | temp[(i << 1) + 1];
+ }
+}
+
+void sub_8094A74 (u8 arg[3], u8 player_number, u32 arg3) {
+ int i, j;
+ u8 temp[6];
+ if (!battle_side_get_owner(arg3)) {
+ i = battle_get_side_with_given_state(0);
+ j = battle_get_side_with_given_state(2);
+ } else {
+ i = battle_get_side_with_given_state(1);
+ j = battle_get_side_with_given_state(3);
+ }
+ if (IsLinkDoubleBattle() == 1)
+ if (player_number) {
+ *arg = 0x30;
+ arg[1] = 0x45;
+ arg[2] = 0x12;
+ } else {
+ *arg = 0x03;
+ arg[1] = 0x12;
+ arg[2] = 0x45;
+ }
+ else {
+ if (!IsDoubleBattle()) {
+ int pos = 1;
+ *temp = gUnknown_02024A6A[i];
+ for (i = 0; i <= 5; i ++) if (i != *temp) temp[pos ++] = i;
+ } else {
+ int pos = 2;
+ *temp = gUnknown_02024A6A[i];
+ temp[1] = gUnknown_02024A6A[j];
+ for (i = 0; i <= 5; i ++) if ((i != *temp) && (i != temp[1])) temp[pos ++] = i;
+ }
+ for (i = 0; i <= 2; i ++) arg[i] = (temp[i << 1] << 4) | temp[(i << 1) + 1];
+ }
+}