diff options
-rw-r--r-- | arm9/asm/unk_020337E8.s | 74 | ||||
-rw-r--r-- | arm9/src/unk_020337E8.c | 50 | ||||
-rw-r--r-- | arm9/src/unk_0205FA2C.c | 2 | ||||
-rw-r--r-- | include/unk_020337E8.h | 25 |
4 files changed, 76 insertions, 75 deletions
diff --git a/arm9/asm/unk_020337E8.s b/arm9/asm/unk_020337E8.s deleted file mode 100644 index 99f778f2..00000000 --- a/arm9/asm/unk_020337E8.s +++ /dev/null @@ -1,74 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - - .text - - thumb_func_start FUN_020337E8 -FUN_020337E8: ; 0x020337E8 - push {r3-r5, lr} - mov r1, #0x72 - lsl r1, r1, #0x4 - bl AllocFromHeap - add r4, r0, #0x0 - add r0, #0x1f - mov r1, #0x1f - bic r0, r1 - bl DWC_Init - add r5, r0, #0x0 - add r0, r4, #0x0 - bl FreeToHeap - add r0, r5, #0x0 - pop {r3-r5, pc} - .balign 4 - - thumb_func_start FUN_0203380C -FUN_0203380C: ; 0x0203380C - push {r4, lr} - bl FUN_02028228 - add r4, r0, #0x0 - bl DWC_CheckUserData - cmp r0, #0x0 - bne _0203382A - ldr r1, _0203382C ; =0x4144414A - add r0, r4, #0x0 - bl DWC_CreateUserData - add r0, r4, #0x0 - bl DWC_ClearDirtyFlag -_0203382A: - pop {r4, pc} - .balign 4 -_0203382C: .word 0x4144414A - - thumb_func_start FUN_02033830 -FUN_02033830: ; 0x02033830 - push {r3-r4, lr} - sub sp, #0xc - bl FUN_02028228 - add r4, r0, #0x0 - add r1, sp, #0x0 - bl DWC_CreateExchangeToken - add r0, r4, #0x0 - add r1, sp, #0x0 - bl DWC_GetGsProfileId - add sp, #0xc - pop {r3-r4, pc} - - thumb_func_start FUN_0203384C -FUN_0203384C: ; 0x0203384C - push {r4, lr} - bl FUN_020286EC - bl FUN_02028228 - add r4, r0, #0x0 - bl DWC_CheckHasProfile - cmp r0, #0x0 - beq _0203386E - add r0, r4, #0x0 - bl DWC_CheckValidConsole - cmp r0, #0x0 - beq _0203386E - mov r0, #0x1 - pop {r4, pc} -_0203386E: - mov r0, #0x0 - pop {r4, pc} - .balign 4 diff --git a/arm9/src/unk_020337E8.c b/arm9/src/unk_020337E8.c new file mode 100644 index 00000000..856ba3b8 --- /dev/null +++ b/arm9/src/unk_020337E8.c @@ -0,0 +1,50 @@ +#include "unk_020337E8.h" +#include "heap.h" + +extern struct DWC_Struct *FUN_020286EC(struct SaveBlock2 *sav2); +extern struct DWC_Struct *FUN_02028228(struct DWC_Struct *); + +// DWC_init +extern s32 DWC_Init(s32); + +// DWC_account +extern void DWC_CreateExchangeToken(struct DWC_Struct *, struct DWC_token *); +extern void DWC_CreateUserData(struct DWC_Struct *, s32); +extern void DWC_ClearDirtyFlag(struct DWC_Struct *); +extern BOOL DWC_CheckHasProfile(struct DWC_Struct *); +extern BOOL DWC_CheckValidConsole(struct DWC_Struct *); +extern BOOL DWC_CheckUserData(struct DWC_Struct *); +extern s32 DWC_GetGsProfileId(struct DWC_Struct *, struct DWC_token *); + +THUMB_FUNC s32 FUN_020337E8(u32 heap_id) +{ + s32 ret = (s32)AllocFromHeap(heap_id, 0x720); + s32 ret1 = DWC_Init((ret + 0x1F) & ~0x1F); + FreeToHeap((void*)ret); + return ret1; +} + +THUMB_FUNC void FUN_0203380C(struct DWC_Struct *dwc) +{ + struct DWC_Struct * dwc1 = FUN_02028228(dwc); + if(!DWC_CheckUserData(dwc1)) + { + DWC_CreateUserData(dwc1, 0x4144414A); + DWC_ClearDirtyFlag(dwc1); + } +} + +THUMB_FUNC s32 FUN_02033830(struct DWC_Struct *dwc) +{ + struct DWC_token token; + + struct DWC_Struct * dwc1 = FUN_02028228(dwc); + DWC_CreateExchangeToken(dwc1, &token); + return DWC_GetGsProfileId(dwc1, &token); +} + +THUMB_FUNC BOOL FUN_0203384C(struct SaveBlock2 *sav2) +{ + struct DWC_Struct * dwc = FUN_02028228(FUN_020286EC(sav2)); + return (DWC_CheckHasProfile(dwc) && DWC_CheckValidConsole(dwc)); +} diff --git a/arm9/src/unk_0205FA2C.c b/arm9/src/unk_0205FA2C.c index 9aa4460f..cabd756e 100644 --- a/arm9/src/unk_0205FA2C.c +++ b/arm9/src/unk_0205FA2C.c @@ -1,11 +1,11 @@ #include "unk_0205FA2C.h" +#include "unk_020337E8.h" extern void *UNK_020F96DC; extern void *UNK_020FA6E8; extern u32 FUN_02079C70(struct SaveBlock2 *sav2); extern void FUN_0207B000(struct UnkPlayerStruct2_0205FA2C *ptr, const u8 param1[12]); extern void FUN_0207C2A4(struct UnkPlayerStruct2_0205FA2C *ptr, struct PlayerData *player_data); -extern u32 FUN_0203384C(struct SaveBlock2 *sav2); extern u32 *FUN_02038790(struct UnkSavStruct80 *param0, u16 param1, u16 param2); extern u16 *GetVarPointer(struct UnkSavStruct80 *arg, u16); extern u16 MOD06_02244660(struct UnkSavStruct80 *param0, u8 *param1); diff --git a/include/unk_020337E8.h b/include/unk_020337E8.h new file mode 100644 index 00000000..228570ea --- /dev/null +++ b/include/unk_020337E8.h @@ -0,0 +1,25 @@ +#ifndef POKEDIAMOND_UNK_020337E8_H +#define POKEDIAMOND_UNK_020337E8_H + +#include "global.h" +#include "save_block_2.h" + +// Dummy struct until DWC_account +struct DWC_Struct +{ + s32 unk0; +}; + +struct DWC_token +{ + // size: 0xC + u8 fill0[0xC]; +}; + +s32 FUN_020337E8(u32 heap_id); +void FUN_0203380C(struct DWC_Struct *); +s32 FUN_02033830(struct DWC_Struct *); +BOOL FUN_0203384C(struct SaveBlock2 *); + + +#endif // POKEDIAMOND_UNK_020337E8_H |