summaryrefslogtreecommitdiff
path: root/src/friend_area_1.c
diff options
context:
space:
mode:
authorSeth Barberee <seth.barberee@gmail.com>2020-12-31 18:30:16 -0600
committerGitHub <noreply@github.com>2020-12-31 18:30:16 -0600
commit87cd9885a9f8b38a76ab6add4a634e2a8a4837ee (patch)
tree9e7e3352cc63bf5665d192c8ebbdfd6032641f74 /src/friend_area_1.c
parent01ec8edb40c0662863e2fd14395a057be852e060 (diff)
Friend Area Decomp Work (#15)
split out and work on friend area stuff
Diffstat (limited to 'src/friend_area_1.c')
-rw-r--r--src/friend_area_1.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/friend_area_1.c b/src/friend_area_1.c
new file mode 100644
index 0000000..ae04cdf
--- /dev/null
+++ b/src/friend_area_1.c
@@ -0,0 +1,90 @@
+#include "global.h"
+#include "constants/friend_area.h"
+
+extern bool8 *gFriendAreas;
+extern void sub_809485C(u32 *r0, u32 r1, u32 r2);
+extern void sub_8094924(u32 *r0, u32 *r1, u32);
+extern void nullsub_102(u32 *r0);
+extern void sub_809488C(u32 *r0, u32 *r1, u32 r2);
+extern void sub_809486C(u32 *r0, u32 r1, u32 r2);
+
+#ifdef NONMATCHING
+u32 sub_80927A8(u32 r0, u32 r1)
+{
+ u32 temp[5];
+ s32 counter;
+
+ sub_809486C(temp, r0, r1);
+ for(counter = 0; counter < NUM_FRIEND_AREAS; counter++)
+ {
+ // TODO moves into R1 for the load else it matches
+ if(!gFriendAreas[counter])
+ temp[4] = gFriendAreas[counter];
+ else
+ temp[4] = -1;
+ sub_809488C(temp, &(temp[4]), 1);
+ }
+ nullsub_102(temp);
+ return temp[2];
+}
+#else
+NAKED u32 sub_80927A8(u32 r0, u32 r1)
+{
+ asm_unified("\tpush {r4,r5,lr}\n"
+ "\tsub sp, 0x14\n"
+ "\tadds r3, r0, 0\n"
+ "\tadds r2, r1, 0\n"
+ "\tmov r0, sp\n"
+ "\tadds r1, r3, 0\n"
+ "\tbl sub_809486C\n"
+ "\tmovs r4, 0\n"
+ "\tadd r5, sp, 0x10\n"
+"_080927BC:\n"
+ "\tldr r0, _080927F0\n"
+ "\tldr r0, [r0]\n"
+ "\tadds r0, r4\n"
+ "\tldrb r0, [r0]\n"
+ "\tcmp r0, 0\n"
+ "\tbeq _080927CC\n"
+ "\tmovs r0, 0x1\n"
+ "\tnegs r0, r0\n"
+"_080927CC:\n"
+ "\tstr r0, [sp, 0x10]\n"
+ "\tmov r0, sp\n"
+ "\tadds r1, r5, 0\n"
+ "\tmovs r2, 0x1\n"
+ "\tbl sub_809488C\n"
+ "\tadds r4, 0x1\n"
+ "\tcmp r4, 0x39\n"
+ "\tble _080927BC\n"
+ "\tmov r0, sp\n"
+ "\tbl nullsub_102\n"
+ "\tldr r0, [sp, 0x8]\n"
+ "\tadd sp, 0x14\n"
+ "\tpop {r4,r5}\n"
+ "\tpop {r1}\n"
+ "\tbx r1\n"
+ "\t.align 2, 0\n"
+"_080927F0: .4byte gFriendAreas");
+}
+#endif
+
+u32 sub_80927F4(u32 r0, u32 r1)
+{
+ u32 temp[5];
+ s32 counter;
+
+ sub_809485C(temp, r0, r1);
+ for(counter = 0; counter < NUM_FRIEND_AREAS; counter++)
+ {
+ sub_8094924(temp, &(temp[4]), 1);
+ // It's setting whether we have the friend area or not
+ if((temp[4] & 1))
+ gFriendAreas[counter] = TRUE;
+ else
+ gFriendAreas[counter] = FALSE;
+ }
+ nullsub_102(temp);
+ return temp[2];
+}
+