summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arm9/asm/unk_020851B8.s102
-rw-r--r--arm9/src/unk_020851B8.c45
-rw-r--r--include/unk_020851B8.h19
3 files changed, 64 insertions, 102 deletions
diff --git a/arm9/asm/unk_020851B8.s b/arm9/asm/unk_020851B8.s
deleted file mode 100644
index 95c8ad82..00000000
--- a/arm9/asm/unk_020851B8.s
+++ /dev/null
@@ -1,102 +0,0 @@
- .include "asm/macros.inc"
- .include "global.inc"
-
- .text
-
- thumb_func_start FUN_020851B8
-FUN_020851B8: ; 0x020851B8
- push {r3, lr}
- mov r1, #0xc
- bl AllocFromHeap
- mov r1, #0x0
- strb r1, [r0, #0x0]
- strb r1, [r0, #0x1]
- strb r1, [r0, #0x2]
- strb r1, [r0, #0x3]
- strb r1, [r0, #0x4]
- strb r1, [r0, #0x5]
- strb r1, [r0, #0x6]
- strb r1, [r0, #0x7]
- strb r1, [r0, #0x8]
- strb r1, [r0, #0x9]
- strb r1, [r0, #0xa]
- strb r1, [r0, #0xb]
- pop {r3, pc}
-
- thumb_func_start FUN_020851DC
-FUN_020851DC: ; 0x020851DC
- push {r4-r6, lr}
- sub r1, #0x95
- lsl r1, r1, #0x10
- lsr r6, r1, #0x10
- add r1, r6, #0x0
- add r5, r0, #0x0
- add r4, r2, #0x0
- bl FUN_02085200
- cmp r4, #0x1
- bne _020851F4
- strb r6, [r5, #0x8]
-_020851F4:
- pop {r4-r6, pc}
- .balign 4
-
- thumb_func_start FUN_020851F8
-FUN_020851F8: ; 0x020851F8
- strb r1, [r0, #0x9]
- strb r2, [r0, #0xa]
- strb r3, [r0, #0xb]
- bx lr
-
- thumb_func_start FUN_02085200
-FUN_02085200: ; 0x02085200
- push {r3-r6}
- lsr r6, r1, #0x1f
- lsl r5, r1, #0x1b
- lsr r2, r1, #0x5
- lsl r4, r2, #0x2
- sub r5, r5, r6
- mov r1, #0x1b
- ror r5, r1
- ldr r3, [r0, r4]
- mov r2, #0x1
- add r1, r6, r5
- lsl r2, r1
- add r1, r3, #0x0
- orr r1, r2
- str r1, [r0, r4]
- pop {r3-r6}
- bx lr
- .balign 4
-
- thumb_func_start FUN_02085224
-FUN_02085224: ; 0x02085224
- push {r4-r5}
- lsr r5, r1, #0x1f
- lsl r4, r1, #0x1b
- lsr r1, r1, #0x5
- lsl r1, r1, #0x2
- sub r4, r4, r5
- mov r3, #0x1b
- ror r4, r3
- mov r2, #0x1
- add r3, r5, r4
- add r4, r2, #0x0
- lsl r4, r3
- ldr r0, [r0, r1]
- tst r0, r4
- bne _02085244
- mov r2, #0x0
-_02085244:
- lsl r0, r2, #0x18
- lsr r0, r0, #0x18
- pop {r4-r5}
- bx lr
-
- thumb_func_start FUN_0208524C
-FUN_0208524C: ; 0x0208524C
- ldrb r3, [r0, #0x9]
- strb r3, [r1, #0x0]
- ldrb r0, [r0, #0xa]
- strb r0, [r2, #0x0]
- bx lr
- .balign 4
diff --git a/arm9/src/unk_020851B8.c b/arm9/src/unk_020851B8.c
new file mode 100644
index 00000000..592d16d6
--- /dev/null
+++ b/arm9/src/unk_020851B8.c
@@ -0,0 +1,45 @@
+#include "global.h"
+#include "unk_020851B8.h"
+#include "constants/items.h"
+#include "heap.h"
+
+THUMB_FUNC struct UnkStruct_020851B8 *FUN_020851B8(u32 heap_id)
+{
+ struct UnkStruct_020851B8 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct_020851B8));
+ __builtin__clear(ptr, sizeof(struct UnkStruct_020851B8));
+ return ptr;
+}
+
+THUMB_FUNC void FUN_020851DC(struct UnkStruct_020851B8 *param0, u32 item_id, BOOL param2)
+{
+ u16 berry_id = item_id - FIRST_BERRY_IDX;
+ FUN_02085200(param0, berry_id);
+
+ if (param2 == TRUE)
+ {
+ param0->unk_8 = berry_id;
+ }
+}
+
+THUMB_FUNC void FUN_020851F8(struct UnkStruct_020851B8 *param0, u8 param1, u8 param2, u8 param3)
+{
+ param0->unk_9 = param1;
+ param0->unk_A = param2;
+ param0->unk_B = param3;
+}
+
+THUMB_FUNC void FUN_02085200(struct UnkStruct_020851B8 *param0, u16 berry_id)
+{
+ param0->flags[berry_id / 32] |= 1 << (berry_id % 32);
+}
+
+THUMB_FUNC u8 FUN_02085224(struct UnkStruct_020851B8 *param0, u16 berry_id)
+{
+ return param0->flags[berry_id / 32] & (1 << (berry_id % 32)) ? 1 : 0;
+}
+
+THUMB_FUNC void FUN_0208524C(struct UnkStruct_020851B8 *param0, u8 *param1, u8 *param2)
+{
+ *param1 = param0->unk_9;
+ *param2 = param0->unk_A;
+}
diff --git a/include/unk_020851B8.h b/include/unk_020851B8.h
new file mode 100644
index 00000000..ca47a91c
--- /dev/null
+++ b/include/unk_020851B8.h
@@ -0,0 +1,19 @@
+#ifndef POKEDIAMOND_UNK_020851B8_H
+#define POKEDIAMOND_UNK_020851B8_H
+
+struct UnkStruct_020851B8 {
+ u32 flags[2];
+ u8 unk_8;
+ u8 unk_9;
+ u8 unk_A;
+ u8 unk_B;
+};
+
+struct UnkStruct_020851B8 *FUN_020851B8(u32 heap_id);
+void FUN_020851DC(struct UnkStruct_020851B8 *param0, u32 param1, BOOL param2);
+void FUN_020851F8(struct UnkStruct_020851B8 *param0, u8 param1, u8 param2, u8 param3);
+void FUN_02085200(struct UnkStruct_020851B8 *param0, u16 param1);
+u8 FUN_02085224(struct UnkStruct_020851B8 *param0, u16 param1);
+void FUN_0208524C(struct UnkStruct_020851B8 *param0, u8 *param1, u8 *param2);
+
+#endif // POKEDIAMOND_UNK_020851B8_H