summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth Barberee <seth.barberee@gmail.com>2020-10-15 16:56:25 -0500
committerSeth Barberee <seth.barberee@gmail.com>2020-10-15 16:56:25 -0500
commit6c9dd59b5691cd7d5a19c740e8d22779e6a101aa (patch)
tree5c118704c157a9aa4ae0ad8eb47c72527d7eb98d
parent6da3c8269f2ff4940f4ccf9ebf7ce99489aae080 (diff)
nonmatch bc I'm so close on those
-rw-r--r--asm/code_800558C.s82
-rw-r--r--include/code_800558C.h1
-rwxr-xr-xld_script.txt1
-rw-r--r--src/code_800558C.c151
-rw-r--r--src/save1.c6
5 files changed, 156 insertions, 85 deletions
diff --git a/asm/code_800558C.s b/asm/code_800558C.s
index 8d7524b..ad90f29 100644
--- a/asm/code_800558C.s
+++ b/asm/code_800558C.s
@@ -1559,86 +1559,4 @@ _08006094:
_080060A4: .4byte 0x000003ff
thumb_func_end sub_8005838
- thumb_func_start sub_80060A8
-sub_80060A8:
- push {lr}
- ldr r1, _080060D8
- ldr r0, _080060DC
- ldr r0, [r0]
- str r0, [r1]
- ldr r2, _080060E0
- movs r1, 0
- ldr r0, [r2]
- cmp r0, 0
- bne _080060BE
- movs r1, 0x1
-_080060BE:
- str r1, [r2]
- ldr r2, _080060E4
- movs r1, 0
- ldr r0, [r2]
- cmp r0, 0
- bne _080060CC
- movs r1, 0x1
-_080060CC:
- str r1, [r2]
- ldr r1, _080060E8
- movs r0, 0
- strb r0, [r1]
- pop {r0}
- bx r0
- .align 2, 0
-_080060D8: .4byte gUnknown_2026E3C
-_080060DC: .4byte gUnknown_2026E58
-_080060E0: .4byte gUnknown_2026E54
-_080060E4: .4byte gUnknown_2026E50
-_080060E8: .4byte gUnknown_2026E38
- thumb_func_end sub_80060A8
-
- thumb_func_start sub_80060EC
-sub_80060EC:
- push {lr}
- ldr r1, _08006130
- ldr r0, _08006134
- ldr r0, [r0]
- str r0, [r1]
- ldr r2, _08006138
- movs r1, 0
- ldr r0, [r2]
- cmp r0, 0
- bne _08006102
- movs r1, 0x1
-_08006102:
- str r1, [r2]
- ldr r2, _0800613C
- movs r1, 0
- ldr r0, [r2]
- cmp r0, 0
- bne _08006110
- movs r1, 0x1
-_08006110:
- str r1, [r2]
- ldr r0, _08006140
- ldrh r2, [r0]
- movs r0, 0xF8
- lsls r0, 5
- ands r0, r2
- lsrs r0, 8
- movs r1, 0x1F
- ands r1, r2
- bl sub_800CC44
- ldr r1, _08006144
- movs r0, 0x1
- strb r0, [r1]
- pop {r0}
- bx r0
- .align 2, 0
-_08006130: .4byte gUnknown_2026E3C
-_08006134: .4byte gUnknown_2026E58
-_08006138: .4byte gUnknown_2026E54
-_0800613C: .4byte gUnknown_2026E50
-_08006140: .4byte gUnknown_2026E4E
-_08006144: .4byte gUnknown_2026E38
- thumb_func_end sub_80060EC
-
.align 2, 0 @ Don't pad with nop.
diff --git a/include/code_800558C.h b/include/code_800558C.h
index e1b3432..ac037c8 100644
--- a/include/code_800558C.h
+++ b/include/code_800558C.h
@@ -2,5 +2,6 @@
#define GUARD_code_800558C_H
extern void *gUnknown_203B078;
+void sub_80060EC(void);
#endif //GUARD_code_800558C_H
diff --git a/ld_script.txt b/ld_script.txt
index 8ecdc86..6b51a42 100755
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -61,6 +61,7 @@ SECTIONS {
src/sprite.o(.text);
asm/sprite.o(.text);
asm/code_800558C.o(.text);
+ src/code_800558C.o(.text);
src/random.o(.text);
src/text.o(.text);
. = ALIGN(4);
diff --git a/src/code_800558C.c b/src/code_800558C.c
new file mode 100644
index 0000000..773e773
--- /dev/null
+++ b/src/code_800558C.c
@@ -0,0 +1,151 @@
+#include "global.h"
+#include "code_800558C.h"
+
+extern u32 gUnknown_203B47C;
+
+extern u32 gUnknown_2026E3C;
+extern u32 gUnknown_2026E58;
+extern u32 gUnknown_2026E54;
+extern u32 gUnknown_2026E50;
+extern u16 gUnknown_2026E4E;
+extern u8 gUnknown_2026E38;
+
+extern void sub_800CC44(u32 r0, u32 r1);
+
+// Unused
+#ifndef NONMATCHING
+NAKED
+#endif
+void sub_80060A8(void)
+{
+#ifdef NONMATCHING
+ // TODO ordering of statements is wrong but regs are good so f*** it.
+ // My mv/ldr stuff for temp is out of order
+ u32 temp;
+ gUnknown_2026E3C = gUnknown_2026E58;
+
+ temp = 0;
+ if (gUnknown_2026E54 == 0)
+ {
+ temp = 1;
+ }
+ gUnknown_2026E54 = temp;
+
+ temp = 0;
+
+ if (gUnknown_2026E50 == 0)
+ {
+ temp = 1;
+ }
+ gUnknown_2026E50 = temp;
+
+ gUnknown_2026E38 = 0;
+#else
+ asm_unified("\tpush {lr}\n"
+ "\tldr r1, _080060D8\n"
+ "\tldr r0, _080060DC\n"
+ "\tldr r0, [r0]\n"
+ "\tstr r0, [r1]\n"
+ "\tldr r2, _080060E0\n"
+ "\tmovs r1, 0\n"
+ "\tldr r0, [r2]\n"
+ "\tcmp r0, 0\n"
+ "\tbne _080060BE\n"
+ "\tmovs r1, 0x1\n"
+"_080060BE:\n"
+ "\tstr r1, [r2]\n"
+ "\tldr r2, _080060E4\n"
+ "\tmovs r1, 0\n"
+ "\tldr r0, [r2]\n"
+ "\tcmp r0, 0\n"
+ "\tbne _080060CC\n"
+ "\tmovs r1, 0x1\n"
+"_080060CC:\n"
+ "\tstr r1, [r2]\n"
+ "\tldr r1, _080060E8\n"
+ "\tmovs r0, 0\n"
+ "\tstrb r0, [r1]\n"
+ "\tpop {r0}\n"
+ "\tbx r0\n"
+ "\t.align 2, 0\n"
+"_080060D8: .4byte gUnknown_2026E3C\n"
+"_080060DC: .4byte gUnknown_2026E58\n"
+"_080060E0: .4byte gUnknown_2026E54\n"
+"_080060E4: .4byte gUnknown_2026E50\n"
+"_080060E8: .4byte gUnknown_2026E38");
+
+#endif
+}
+
+#ifndef NONMATCHING
+NAKED
+#endif
+void sub_80060EC(void)
+{
+#ifdef NONMATCHING
+ // TODO ordering of statements is wrong but regs are good so f*** it.
+ u32 temp;
+ gUnknown_2026E3C = gUnknown_2026E58;
+ temp = 0;
+
+ if (gUnknown_2026E54 == 0)
+ {
+ temp = 1;
+ }
+ gUnknown_2026E54 = temp;
+
+ temp = 0;
+
+ if (gUnknown_2026E50 == 0)
+ {
+ temp = 1;
+ }
+ gUnknown_2026E50 = temp;
+
+ sub_800CC44((gUnknown_2026E4E & (0xF8 << 5)) >> 8, gUnknown_2026E4E & 0x1F);
+ gUnknown_2026E38 = 1;
+#else
+ asm_unified("\tpush {lr}\n"
+ "\tldr r1, _08006130\n"
+ "\tldr r0, _08006134\n"
+ "\tldr r0, [r0]\n"
+ "\tstr r0, [r1]\n"
+ "\tldr r2, _08006138\n"
+ "\tmovs r1, 0\n"
+ "\tldr r0, [r2]\n"
+ "\tcmp r0, 0\n"
+ "\tbne _08006102\n"
+ "\tmovs r1, 0x1\n"
+ "_08006102:\n"
+ "\tstr r1, [r2]\n"
+ "\tldr r2, _0800613C\n"
+ "\tmovs r1, 0\n"
+ "\tldr r0, [r2]\n"
+ "\tcmp r0, 0\n"
+ "\tbne _08006110\n"
+ "\tmovs r1, 0x1\n"
+ "_08006110:\n"
+ "\tstr r1, [r2]\n"
+ "\tldr r0, _08006140\n"
+ "\tldrh r2, [r0]\n"
+ "\tmovs r0, 0xF8\n"
+ "\tlsls r0, 5\n"
+ "\tands r0, r2\n"
+ "\tlsrs r0, 8\n"
+ "\tmovs r1, 0x1F\n"
+ "\tands r1, r2\n"
+ "\tbl sub_800CC44\n"
+ "\tldr r1, _08006144\n"
+ "\tmovs r0, 0x1\n"
+ "\tstrb r0, [r1]\n"
+ "\tpop {r0}\n"
+ "\tbx r0\n"
+ "\t.align 2, 0\n"
+ "_08006130: .4byte gUnknown_2026E3C\n"
+ "_08006134: .4byte gUnknown_2026E58\n"
+ "_08006138: .4byte gUnknown_2026E54\n"
+ "_0800613C: .4byte gUnknown_2026E50\n"
+ "_08006140: .4byte gUnknown_2026E4E\n"
+ "_08006144: .4byte gUnknown_2026E38");
+#endif
+}
diff --git a/src/save1.c b/src/save1.c
index 5b8ad19..a194557 100644
--- a/src/save1.c
+++ b/src/save1.c
@@ -1,4 +1,6 @@
#include "global.h"
+#include "code_800558C.h"
+#include "input.h"
struct UnkSaveStruct1
@@ -36,9 +38,7 @@ extern void sub_8011860();
extern void xxx_draw_string_80144C4();
extern void nullsub_8(u8);
extern void sub_8005180();
-extern void sub_80060EC();
extern void sub_800CB20();
-extern void sub_800485C();
extern void CopySpritesToOam();
extern void sub_8005304();
extern void TransferBGPaletteBuffer();
@@ -69,7 +69,7 @@ void sub_8012A18()
sub_8005180();
sub_80060EC();
sub_800CB20();
- sub_800485C();
+ sub_800485C(); // Input related
CopySpritesToOam();
sub_8005304();
TransferBGPaletteBuffer();