diff options
author | Gogume1er <gogume1er@gmail.com> | 2021-05-25 00:27:09 +0200 |
---|---|---|
committer | Gogume1er <gogume1er@gmail.com> | 2021-05-25 00:27:09 +0200 |
commit | 015a7675e6ffcf234a856528a02e58d62a32f044 (patch) | |
tree | 02f1592525d6870bbf7acee1187e01dacd9042ef | |
parent | febbf5dc3d673ae40df7b6c545a40e945e6eda17 (diff) |
decompile unk_020851B8
-rw-r--r-- | arm9/asm/unk_020851B8.s | 102 | ||||
-rw-r--r-- | arm9/src/unk_020851B8.c | 67 | ||||
-rw-r--r-- | include/unk_020851B8.h | 15 |
3 files changed, 82 insertions, 102 deletions
diff --git a/arm9/asm/unk_020851B8.s b/arm9/asm/unk_020851B8.s deleted file mode 100644 index a6ed91ad..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..adf8f1ef --- /dev/null +++ b/arm9/src/unk_020851B8.c @@ -0,0 +1,67 @@ +#include "global.h" +#include "heap.h" +#include "unk_020851B8.h" + +THUMB_FUNC struct UnkStruct_020851B8 *FUN_020851B8(u32 heap_id) +{ + struct UnkStruct_020851B8 *ret = (struct UnkStruct_020851B8 *) AllocFromHeap(heap_id, sizeof(struct UnkStruct_020851B8)); + ret->unk00[0x0] = 0; + ret->unk00[0x1] = 0; + ret->unk00[0x2] = 0; + ret->unk00[0x3] = 0; + ret->unk00[0x4] = 0; + ret->unk00[0x5] = 0; + ret->unk00[0x6] = 0; + ret->unk00[0x7] = 0; + ret->unk00[0x8] = 0; + ret->unk00[0x9] = 0; + ret->unk00[0xA] = 0; + ret->unk00[0xB] = 0; + + return ret; +} + +THUMB_FUNC void FUN_020851DC(struct UnkStruct_020851B8 *param0, u32 param1, BOOL param2) +{ + u16 flag = param1 - 0x95; + FUN_02085200((u32*) param0, flag); + + if (param2 == TRUE) + { + param0->unk00[0x8] = flag; + } +} + +THUMB_FUNC void FUN_020851F8(struct UnkStruct_020851B8 *param0, u8 param1, u8 param2, u8 param3) +{ + param0->unk00[0x9] = param1; + param0->unk00[0xA] = param2; + param0->unk00[0xB] = param3; +} + +THUMB_FUNC void FUN_02085200(u32 *param0, u16 param1) +{ + u32 index = param1 / 32; + u32 tag = 1 << (param1 % 32); + u32 value = *(param0 + index); + *(param0 + index) = value | tag; +} + +THUMB_FUNC u32 FUN_02085224(u32 *param0, u16 param1) { + u32 r2 = 1; + u32 index = param1 / 32; + u32 tag = 1 << (param1 % 32); + + if (*(param0 + index) & tag) + { + r2 = 0; + } + + return (r2 << 0x18) >> 0x18; +} + +THUMB_FUNC void FUN_0208524C(struct UnkStruct_020851B8 *param0, u8 *param1, u8 *param2) +{ + *param1 = param0->unk00[0x9]; + *param2 = param0->unk00[0xA]; +} diff --git a/include/unk_020851B8.h b/include/unk_020851B8.h new file mode 100644 index 00000000..63725aea --- /dev/null +++ b/include/unk_020851B8.h @@ -0,0 +1,15 @@ +#ifndef POKEDIAMOND_UNK_020851B8_H +#define POKEDIAMOND_UNK_020851B8_H + +struct UnkStruct_020851B8 { + u8 unk00[0xC]; +}; + +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(u32 *param0, u16 param1); +u32 FUN_02085224(u32 *param0, u16 param1); +void FUN_0208524C(struct UnkStruct_020851B8 *param0, u8 *param1, u8 *param2); + +#endif // POKEDIAMOND_UNK_020851B8_H |