From 61776017dc42d46aa5cefcb40429d7d96984f703 Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Sat, 15 May 2021 19:31:22 -0500 Subject: decomp 3 files --- arm9/asm/RTC_internal.s | 53 ----------------------------------------- arm9/asm/WIFI_stubsmd5_dummy.s | 25 ------------------- arm9/asm/unk_02022504.s | 53 ----------------------------------------- arm9/lib/include/RTC_internal.h | 10 ++++++++ arm9/lib/src/RTC_internal.c | 32 +++++++++++++++++++++++++ arm9/src/WIFI_stubsmd5_dummy.c | 17 +++++++++++++ arm9/src/unk_02022504.c | 32 +++++++++++++++++++++++++ include/WIFI_stubsmd5_dummy.h | 12 ++++++++++ include/unk_02022504.h | 15 ++++++++++++ 9 files changed, 118 insertions(+), 131 deletions(-) delete mode 100644 arm9/asm/RTC_internal.s delete mode 100644 arm9/asm/WIFI_stubsmd5_dummy.s delete mode 100644 arm9/asm/unk_02022504.s create mode 100644 arm9/lib/include/RTC_internal.h create mode 100644 arm9/lib/src/RTC_internal.c create mode 100644 arm9/src/WIFI_stubsmd5_dummy.c create mode 100644 arm9/src/unk_02022504.c create mode 100644 include/WIFI_stubsmd5_dummy.h create mode 100644 include/unk_02022504.h diff --git a/arm9/asm/RTC_internal.s b/arm9/asm/RTC_internal.s deleted file mode 100644 index 408b630c..00000000 --- a/arm9/asm/RTC_internal.s +++ /dev/null @@ -1,53 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - - .text - - arm_func_start RtcSendPxiCommand -RtcSendPxiCommand: ; 0x020D61D4 - stmdb sp!, {lr} - sub sp, sp, #0x4 - mov r0, r0, lsl #0x8 - and r1, r0, #0x7f00 - mov r0, #0x5 - mov r2, #0x0 - bl PXI_SendWordByFifo -_020D61F0: ; 0x020D61F0 - cmp r0, #0x0 - movge r0, #0x1 - movlt r0, #0x0 - add sp, sp, #0x4 - ldmia sp!, {lr} - bx lr - - arm_func_start RTCi_WriteRawStatus2Async -RTCi_WriteRawStatus2Async: - ldr ip, _020D6214 ; =RtcSendPxiCommand - mov r0, #0x27 - bx r12 - .balign 4 -_020D6214: .word RtcSendPxiCommand - - arm_func_start RTCi_ReadRawTimeAsync -RTCi_ReadRawTimeAsync: - ldr ip, _020D6224 ; =RtcSendPxiCommand - mov r0, #0x12 - bx r12 - .balign 4 -_020D6224: .word RtcSendPxiCommand - - arm_func_start RTCi_ReadRawDateAsync -RTCi_ReadRawDateAsync: - ldr ip, _020D6234 ; =RtcSendPxiCommand - mov r0, #0x11 - bx r12 - .balign 4 -_020D6234: .word RtcSendPxiCommand - - arm_func_start RTCi_ReadRawDateTimeAsync -RTCi_ReadRawDateTimeAsync: - ldr ip, _020D6244 ; =RtcSendPxiCommand - mov r0, #0x10 - bx r12 - .balign 4 -_020D6244: .word RtcSendPxiCommand diff --git a/arm9/asm/WIFI_stubsmd5_dummy.s b/arm9/asm/WIFI_stubsmd5_dummy.s deleted file mode 100644 index dd3f79a7..00000000 --- a/arm9/asm/WIFI_stubsmd5_dummy.s +++ /dev/null @@ -1,25 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - - .text - - arm_func_start MD5Final -MD5Final: ; 0x020A8BA4 - ldr ip, _020A8BAC ; =DGT_Hash1GetDigest_R - bx r12 - .balign 4 -_020A8BAC: .word DGT_Hash1GetDigest_R - - arm_func_start MD5Update -MD5Update: ; 0x020A8BB0 - ldr ip, _020A8BB8 ; =DGT_Hash1SetSource - bx r12 - .balign 4 -_020A8BB8: .word DGT_Hash1SetSource - - arm_func_start MD5Init -MD5Init: ; 0x020A8BBC - ldr ip, _020A8BC4 ; =DGT_Hash1Reset - bx r12 - .balign 4 -_020A8BC4: .word DGT_Hash1Reset diff --git a/arm9/asm/unk_02022504.s b/arm9/asm/unk_02022504.s deleted file mode 100644 index e3463538..00000000 --- a/arm9/asm/unk_02022504.s +++ /dev/null @@ -1,53 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - - .text - - thumb_func_start FUN_02022504 -FUN_02022504: ; 0x02022504 - ldr r3, _0202250C ; =SavArray_get - mov r1, #0x1b - bx r3 - nop -_0202250C: .word SavArray_get - - thumb_func_start GetStoragePCPointer -GetStoragePCPointer: ; 0x02022510 - ldr r3, _02022518 ; =SavArray_get - mov r1, #0x23 - bx r3 - nop -_02022518: .word SavArray_get - - thumb_func_start FUN_0202251C -FUN_0202251C: ; 0x0202251C - ldr r3, _02022524 ; =SavArray_get - mov r1, #0x1f - bx r3 - nop -_02022524: .word SavArray_get - - thumb_func_start FUN_02022528 -FUN_02022528: ; 0x02022528 - ldr r3, _02022530 ; =SavArray_get - mov r1, #0x20 - bx r3 - nop -_02022530: .word SavArray_get - - thumb_func_start LoadHallOfFame -LoadHallOfFame: ; 0x02022534 - push {r3, lr} - add r3, r2, #0x0 - mov r2, #0x0 - bl ReadSaveFileFromFlash - pop {r3, pc} - - thumb_func_start SaveHallOfFame -SaveHallOfFame: ; 0x02022540 - ldr r3, _02022548 ; =WriteSaveFileToFlash - add r2, r1, #0x0 - mov r1, #0x0 - bx r3 - .balign 4 -_02022548: .word WriteSaveFileToFlash diff --git a/arm9/lib/include/RTC_internal.h b/arm9/lib/include/RTC_internal.h new file mode 100644 index 00000000..fb86e818 --- /dev/null +++ b/arm9/lib/include/RTC_internal.h @@ -0,0 +1,10 @@ +#ifndef NITRO_RTC_INTERNAL_H_ +#define NITRO_RTC_INTERNAL_H_ + +u32 RtcSendPxiCommand(u8 command); +u32 RTCi_WriteRawStatus2Async(void); +u32 RTCi_ReadRawTimeAsync(void); +u32 RTCi_ReadRawDateAsync(void); +u32 RTCi_ReadRawDateTimeAsync(void); + +#endif //NITRO_RTC_INTERNAL_H_ diff --git a/arm9/lib/src/RTC_internal.c b/arm9/lib/src/RTC_internal.c new file mode 100644 index 00000000..2e997eed --- /dev/null +++ b/arm9/lib/src/RTC_internal.c @@ -0,0 +1,32 @@ +#include "global.h" +#include "PXI_fifo.h" +#include "RTC_internal.h" + +u32 RTCi_ReadRawDateTimeAsync(void) +{ + return RtcSendPxiCommand(16); +} + +u32 RTCi_ReadRawDateAsync(void) +{ + return RtcSendPxiCommand(17); +} + +u32 RTCi_ReadRawTimeAsync(void) +{ + return RtcSendPxiCommand(18); +} + +u32 RTCi_WriteRawStatus2Async(void) +{ + return RtcSendPxiCommand(39); +} + +u32 RtcSendPxiCommand(u8 command) +{ + s32 data = command << 8 & 0x7f00; + if(PXI_SendWordByFifo(PXI_FIFO_TAG_RTC, data, FALSE) >= 0) + return 1; + else + return 0; +} diff --git a/arm9/src/WIFI_stubsmd5_dummy.c b/arm9/src/WIFI_stubsmd5_dummy.c new file mode 100644 index 00000000..a6447af9 --- /dev/null +++ b/arm9/src/WIFI_stubsmd5_dummy.c @@ -0,0 +1,17 @@ +#include "global.h" +#include "WIFI_stubsmd5_dummy.h" + +ARM_FUNC void MD5Final(u8 *digest, struct DGTHash1Context *context) +{ + DGT_Hash1GetDigest_R(digest, context); +} + +ARM_FUNC void MD5Update(struct DGTHash1Context *context, u8 *input, u32 length) +{ + DGT_Hash1SetSource(context, input, length); +} + +ARM_FUNC void MD5Init(struct DGTHash1Context *context) +{ + DGT_Hash1Reset(context); +} diff --git a/arm9/src/unk_02022504.c b/arm9/src/unk_02022504.c new file mode 100644 index 00000000..405ea15b --- /dev/null +++ b/arm9/src/unk_02022504.c @@ -0,0 +1,32 @@ +#include "global.h" +#include "unk_02022504.h" + +THUMB_FUNC void *FUN_02022504(struct SaveBlock2 *sav2) +{ + return SavArray_get(sav2, 27); +} + +THUMB_FUNC struct PCStorage *GetStoragePCPointer(struct SaveBlock2 *sav2) +{ + return SavArray_get(sav2, 35); +} + +THUMB_FUNC void *FUN_0202251C(struct SaveBlock2 *sav2) +{ + return SavArray_get(sav2, 31); +} + +THUMB_FUNC void *FUN_02022528(struct SaveBlock2 *sav2) +{ + return SavArray_get(sav2, 32); +} + +THUMB_FUNC u8 *LoadHallOfFame(struct SaveBlock2 *sav2, u32 heap_id, int *ret_p) +{ + return ReadSaveFileFromFlash(sav2, heap_id, 0, ret_p); +} + +THUMB_FUNC int *SaveHallOfFame(struct SaveBlock2 *sav2, u8 *data) +{ + return WriteSaveFileToFlash(sav2, 0, data); +} diff --git a/include/WIFI_stubsmd5_dummy.h b/include/WIFI_stubsmd5_dummy.h new file mode 100644 index 00000000..73e83e39 --- /dev/null +++ b/include/WIFI_stubsmd5_dummy.h @@ -0,0 +1,12 @@ +#ifndef POKEDIAMOND_WIFI_STUBSMD5_DUMMY_H +#define POKEDIAMOND_WIFI_STUBSMD5_DUMMY_H + +#include "dgt.h" + +void MD5Final(u8 *digest, struct DGTHash1Context *context); +void MD5Update(struct DGTHash1Context *context, u8 *input, u32 length); +void MD5Init(struct DGTHash1Context *context); + + +#endif //POKEDIAMOND_WIFI_STUBSMD5_DUMMY_H + diff --git a/include/unk_02022504.h b/include/unk_02022504.h new file mode 100644 index 00000000..3473ffff --- /dev/null +++ b/include/unk_02022504.h @@ -0,0 +1,15 @@ +#ifndef POKEDIAMOND_UNK_02022504_H +#define POKEDIAMOND_UNK_02022504_H + +#include "save_block_2.h" +#include "pokemon_storage_system.h" + +void *FUN_02022504(struct SaveBlock2 *sav2); +struct PCStorage *GetStoragePCPointer(struct SaveBlock2 *sav2); +void *FUN_0202251C(struct SaveBlock2 *sav2); +void *FUN_02022528(struct SaveBlock2 *sav2); +u8 *LoadHallOfFame(struct SaveBlock2 *sav2, u32 heap_id, int *ret_p); +int *SaveHallOfFame(struct SaveBlock2 *sav2, u8 *data); + +#endif //POKEDIAMOND_UNK_02022504_H + -- cgit v1.2.3 From 5d6018d667c8897e660ab1752b25884befdce5af Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Sat, 15 May 2021 19:47:03 -0500 Subject: rtc funcs are all bool --- arm9/lib/include/RTC_internal.h | 10 +++++----- arm9/lib/src/RTC_internal.c | 15 ++++++--------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/arm9/lib/include/RTC_internal.h b/arm9/lib/include/RTC_internal.h index fb86e818..77934291 100644 --- a/arm9/lib/include/RTC_internal.h +++ b/arm9/lib/include/RTC_internal.h @@ -1,10 +1,10 @@ #ifndef NITRO_RTC_INTERNAL_H_ #define NITRO_RTC_INTERNAL_H_ -u32 RtcSendPxiCommand(u8 command); -u32 RTCi_WriteRawStatus2Async(void); -u32 RTCi_ReadRawTimeAsync(void); -u32 RTCi_ReadRawDateAsync(void); -u32 RTCi_ReadRawDateTimeAsync(void); +BOOL RtcSendPxiCommand(u8 command); +BOOL RTCi_WriteRawStatus2Async(void); +BOOL RTCi_ReadRawTimeAsync(void); +BOOL RTCi_ReadRawDateAsync(void); +BOOL RTCi_ReadRawDateTimeAsync(void); #endif //NITRO_RTC_INTERNAL_H_ diff --git a/arm9/lib/src/RTC_internal.c b/arm9/lib/src/RTC_internal.c index 2e997eed..fcd4da69 100644 --- a/arm9/lib/src/RTC_internal.c +++ b/arm9/lib/src/RTC_internal.c @@ -2,31 +2,28 @@ #include "PXI_fifo.h" #include "RTC_internal.h" -u32 RTCi_ReadRawDateTimeAsync(void) +BOOL RTCi_ReadRawDateTimeAsync(void) { return RtcSendPxiCommand(16); } -u32 RTCi_ReadRawDateAsync(void) +BOOL RTCi_ReadRawDateAsync(void) { return RtcSendPxiCommand(17); } -u32 RTCi_ReadRawTimeAsync(void) +BOOL RTCi_ReadRawTimeAsync(void) { return RtcSendPxiCommand(18); } -u32 RTCi_WriteRawStatus2Async(void) +BOOL RTCi_WriteRawStatus2Async(void) { return RtcSendPxiCommand(39); } -u32 RtcSendPxiCommand(u8 command) +BOOL RtcSendPxiCommand(u8 command) { s32 data = command << 8 & 0x7f00; - if(PXI_SendWordByFifo(PXI_FIFO_TAG_RTC, data, FALSE) >= 0) - return 1; - else - return 0; + return PXI_SendWordByFifo(PXI_FIFO_TAG_RTC, data, FALSE) >= 0; } -- cgit v1.2.3 From 5f4bb52fd5d93b2638c99baee82d63b4d9b9f790 Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Sat, 15 May 2021 20:30:26 -0500 Subject: address review comments --- arm9/lib/include/RTC_internal.h | 3 ++- arm9/lib/src/RTC_internal.c | 14 ++++++++------ arm9/src/WIFI_stubsmd5_dummy.c | 2 +- arm9/src/unk_02022504.c | 2 +- include/WIFI_stubsmd5_dummy.h | 3 +-- include/unk_02022504.h | 3 +-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/arm9/lib/include/RTC_internal.h b/arm9/lib/include/RTC_internal.h index 77934291..440d8b95 100644 --- a/arm9/lib/include/RTC_internal.h +++ b/arm9/lib/include/RTC_internal.h @@ -1,7 +1,8 @@ #ifndef NITRO_RTC_INTERNAL_H_ #define NITRO_RTC_INTERNAL_H_ -BOOL RtcSendPxiCommand(u8 command); +#include "nitro/types.h" + BOOL RTCi_WriteRawStatus2Async(void); BOOL RTCi_ReadRawTimeAsync(void); BOOL RTCi_ReadRawDateAsync(void); diff --git a/arm9/lib/src/RTC_internal.c b/arm9/lib/src/RTC_internal.c index fcd4da69..c7a5f2aa 100644 --- a/arm9/lib/src/RTC_internal.c +++ b/arm9/lib/src/RTC_internal.c @@ -1,28 +1,30 @@ -#include "global.h" +#include "function_target.h" #include "PXI_fifo.h" #include "RTC_internal.h" -BOOL RTCi_ReadRawDateTimeAsync(void) +static BOOL RtcSendPxiCommand(u8 command); + +ARM_FUNC BOOL RTCi_ReadRawDateTimeAsync(void) { return RtcSendPxiCommand(16); } -BOOL RTCi_ReadRawDateAsync(void) +ARM_FUNC BOOL RTCi_ReadRawDateAsync(void) { return RtcSendPxiCommand(17); } -BOOL RTCi_ReadRawTimeAsync(void) +ARM_FUNC BOOL RTCi_ReadRawTimeAsync(void) { return RtcSendPxiCommand(18); } -BOOL RTCi_WriteRawStatus2Async(void) +ARM_FUNC BOOL RTCi_WriteRawStatus2Async(void) { return RtcSendPxiCommand(39); } -BOOL RtcSendPxiCommand(u8 command) +ARM_FUNC static BOOL RtcSendPxiCommand(u8 command) { s32 data = command << 8 & 0x7f00; return PXI_SendWordByFifo(PXI_FIFO_TAG_RTC, data, FALSE) >= 0; diff --git a/arm9/src/WIFI_stubsmd5_dummy.c b/arm9/src/WIFI_stubsmd5_dummy.c index a6447af9..6de2edca 100644 --- a/arm9/src/WIFI_stubsmd5_dummy.c +++ b/arm9/src/WIFI_stubsmd5_dummy.c @@ -1,4 +1,4 @@ -#include "global.h" +#include "function_target.h" #include "WIFI_stubsmd5_dummy.h" ARM_FUNC void MD5Final(u8 *digest, struct DGTHash1Context *context) diff --git a/arm9/src/unk_02022504.c b/arm9/src/unk_02022504.c index 405ea15b..0267a87c 100644 --- a/arm9/src/unk_02022504.c +++ b/arm9/src/unk_02022504.c @@ -26,7 +26,7 @@ THUMB_FUNC u8 *LoadHallOfFame(struct SaveBlock2 *sav2, u32 heap_id, int *ret_p) return ReadSaveFileFromFlash(sav2, heap_id, 0, ret_p); } -THUMB_FUNC int *SaveHallOfFame(struct SaveBlock2 *sav2, u8 *data) +THUMB_FUNC s32 *SaveHallOfFame(struct SaveBlock2 *sav2, u8 *data) { return WriteSaveFileToFlash(sav2, 0, data); } diff --git a/include/WIFI_stubsmd5_dummy.h b/include/WIFI_stubsmd5_dummy.h index 73e83e39..d82b55c5 100644 --- a/include/WIFI_stubsmd5_dummy.h +++ b/include/WIFI_stubsmd5_dummy.h @@ -1,12 +1,11 @@ #ifndef POKEDIAMOND_WIFI_STUBSMD5_DUMMY_H #define POKEDIAMOND_WIFI_STUBSMD5_DUMMY_H +#include "nitro/types.h" #include "dgt.h" void MD5Final(u8 *digest, struct DGTHash1Context *context); void MD5Update(struct DGTHash1Context *context, u8 *input, u32 length); void MD5Init(struct DGTHash1Context *context); - #endif //POKEDIAMOND_WIFI_STUBSMD5_DUMMY_H - diff --git a/include/unk_02022504.h b/include/unk_02022504.h index 3473ffff..aa541f85 100644 --- a/include/unk_02022504.h +++ b/include/unk_02022504.h @@ -9,7 +9,6 @@ struct PCStorage *GetStoragePCPointer(struct SaveBlock2 *sav2); void *FUN_0202251C(struct SaveBlock2 *sav2); void *FUN_02022528(struct SaveBlock2 *sav2); u8 *LoadHallOfFame(struct SaveBlock2 *sav2, u32 heap_id, int *ret_p); -int *SaveHallOfFame(struct SaveBlock2 *sav2, u8 *data); +s32 *SaveHallOfFame(struct SaveBlock2 *sav2, u8 *data); #endif //POKEDIAMOND_UNK_02022504_H - -- cgit v1.2.3