diff options
-rw-r--r-- | arm9/src/unk_020851B8.c | 76 | ||||
-rw-r--r-- | include/unk_020851B8.h | 10 |
2 files changed, 44 insertions, 42 deletions
diff --git a/arm9/src/unk_020851B8.c b/arm9/src/unk_020851B8.c index adf8f1ef..474e78dd 100644 --- a/arm9/src/unk_020851B8.c +++ b/arm9/src/unk_020851B8.c @@ -1,67 +1,65 @@ #include "global.h" #include "heap.h" +#include "constants/items.h" #include "unk_020851B8.h" +static inline void _clear(u8 *ptr) { + *ptr++ = 0; + *ptr++ = 0; + *ptr++ = 0; + *ptr++ = 0; + *ptr++ = 0; + *ptr++ = 0; + *ptr++ = 0; + *ptr++ = 0; + *ptr++ = 0; + *ptr++ = 0; + *ptr++ = 0; + *ptr++ = 0; +} + 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; + struct UnkStruct_020851B8 *ptr = AllocFromHeap(heap_id, sizeof(struct UnkStruct_020851B8)); + _clear((u8 *) ptr); + return ptr; } -THUMB_FUNC void FUN_020851DC(struct UnkStruct_020851B8 *param0, u32 param1, BOOL param2) +THUMB_FUNC void FUN_020851DC(struct UnkStruct_020851B8 *param0, u32 item_id, BOOL param2) { - u16 flag = param1 - 0x95; - FUN_02085200((u32*) param0, flag); + u16 berry_id = item_id - FIRST_BERRY_IDX; + FUN_02085200(param0, berry_id); if (param2 == TRUE) { - param0->unk00[0x8] = flag; + param0->unk_8 = berry_id; } } 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; + param0->unk_9 = param1; + param0->unk_A = param2; + param0->unk_B = param3; } -THUMB_FUNC void FUN_02085200(u32 *param0, u16 param1) +THUMB_FUNC void FUN_02085200(struct UnkStruct_020851B8 *param0, u16 berry_id) { - u32 index = param1 / 32; - u32 tag = 1 << (param1 % 32); - u32 value = *(param0 + index); - *(param0 + index) = value | tag; + u32 index = berry_id / 32; + u32 tag = 1 << (berry_id % 32); + u32 value = param0->flags[index]; + param0->flags[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; - } +THUMB_FUNC u8 FUN_02085224(struct UnkStruct_020851B8 *param0, u16 berry_id) { + u32 index = berry_id / 32; + u32 tag = 1 << (berry_id % 32); - return (r2 << 0x18) >> 0x18; + return param0->flags[index] & tag ? 1 : 0; } THUMB_FUNC void FUN_0208524C(struct UnkStruct_020851B8 *param0, u8 *param1, u8 *param2) { - *param1 = param0->unk00[0x9]; - *param2 = param0->unk00[0xA]; + *param1 = param0->unk_9; + *param2 = param0->unk_A; } diff --git a/include/unk_020851B8.h b/include/unk_020851B8.h index 63725aea..ca47a91c 100644 --- a/include/unk_020851B8.h +++ b/include/unk_020851B8.h @@ -2,14 +2,18 @@ #define POKEDIAMOND_UNK_020851B8_H struct UnkStruct_020851B8 { - u8 unk00[0xC]; + 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(u32 *param0, u16 param1); -u32 FUN_02085224(u32 *param0, u16 param1); +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 |