summaryrefslogtreecommitdiff
path: root/arm9/src
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/src')
-rw-r--r--arm9/src/main.c12
-rw-r--r--arm9/src/pokemon.c11
-rw-r--r--arm9/src/sav_system_info.c122
-rw-r--r--arm9/src/save_arrays.c6
4 files changed, 137 insertions, 14 deletions
diff --git a/arm9/src/main.c b/arm9/src/main.c
index e1c8fb38..4f3b583c 100644
--- a/arm9/src/main.c
+++ b/arm9/src/main.c
@@ -27,7 +27,7 @@ extern BOOL FUN_0202FB80(void);
extern void InitSystemForTheGame(void);
extern void InitGraphicMemory(void);
extern void FUN_02022294(void);
-extern void FUN_0201259C(void);
+extern void GF_InitRTCWork(void);
extern void FUN_02002C14(void);
extern void FUN_02002C50(int, int);
extern struct SaveBlock2 * SaveBlock2_new(void);
@@ -40,7 +40,7 @@ extern void FUN_02089D90(int);
extern void FUN_0200A2AC(void);
extern void FUN_02015E30(void);
extern void FUN_0201B5CC(void *);
-extern void FUN_020125D4(void);
+extern void GF_RTC_UpdateOnFrame(void);
extern void FUN_02015E60(void);
extern void FUN_020222C4(void);
extern void FUN_0200A318(void);
@@ -64,7 +64,7 @@ THUMB_FUNC void NitroMain(void)
PM_GetBackLight((PMBackLightSwitch *)SDK_STATIC_BSS_START, NULL);
FUN_02022294();
- FUN_0201259C();
+ GF_InitRTCWork();
FUN_02000DF4();
FUN_02002C14();
FUN_02002C50(0, 3);
@@ -125,7 +125,7 @@ THUMB_FUNC void NitroMain(void)
gMain.unk2C++;
}
}
- FUN_020125D4();
+ GF_RTC_UpdateOnFrame();
FUN_02015E60();
FUN_020222C4();
FUN_0201B5CC(gMain.unk24);
@@ -262,7 +262,7 @@ THUMB_FUNC void FUN_02000F4C(u32 arg0, u32 arg1)
DoSoftReset(arg0);
}
-extern void FUN_0201265C(struct Unk21C4818 *, struct Unk21C4828 *);
+extern void GF_RTC_CopyDateTime(struct Unk21C4818 *, struct Unk21C4828 *);
extern void SetMTRNGSeed(u32);
extern void SetLCRNGSeed(u32);
@@ -270,7 +270,7 @@ THUMB_FUNC void InitializeMainRNG(void)
{
struct Unk21C4818 spC;
struct Unk21C4828 sp0;
- FUN_0201265C(&spC, &sp0);
+ GF_RTC_CopyDateTime(&spC, &sp0);
{
u32 r4 = gMain.unk2C;
u32 r5 = ((sp0.unk4 + sp0.unk8) << 24) + (spC.unk0 + ((256 * spC.unk4 * spC.unk8) << 16) + (sp0.unk0 << 16));
diff --git a/arm9/src/pokemon.c b/arm9/src/pokemon.c
index 3db6796a..97be796b 100644
--- a/arm9/src/pokemon.c
+++ b/arm9/src/pokemon.c
@@ -2,6 +2,7 @@
#define IN_POKEMON_C
#include "proto.h"
#include "party.h"
+#include "player_data.h"
#include "pokemon.h"
#include "filesystem.h"
#include "heap.h"
@@ -41,7 +42,7 @@ BOOL FUN_02069E7C(struct BoxPokemon * boxmon);
BOOL FUN_02069E9C(struct BoxPokemon * boxmon);
void FUN_02069ECC(struct BoxPokemon * boxmon);
void LoadWotbl_HandleAlternateForme(int species, int forme, u16 * wotbl);
-void FUN_0206A054(struct BoxPokemon * boxmon, u32 a1, u32 pokeball, u32 a3, u32 encounterType, u32 a5);
+void FUN_0206A054(struct BoxPokemon * boxmon, struct PlayerData * a1, u32 pokeball, u32 a3, u32 encounterType, u32 heap_id);
BOOL MonHasMove(struct Pokemon * pokemon, u16 move);
BOOL FUN_0206A144(struct BoxPokemon * boxmon, u32 a1);
BOOL FUN_0206A16C(u16 species, int forme, u32 a2);
@@ -3321,10 +3322,10 @@ void FUN_02069FB0(u32 r7, u32 r5, u32 r4, u32 r6, u32 sp18, u32 sp1C, u32 sp20)
}
}
-void FUN_0206A014(struct Pokemon * pokemon, u32 a1, u32 pokeball, u32 a3, u32 encounterType, u32 a5)
+void FUN_0206A014(struct Pokemon * pokemon, struct PlayerData * a1, u32 pokeball, u32 a3, u32 encounterType, u32 heap_id)
{
u32 hp;
- FUN_0206A054(&pokemon->box, a1, pokeball, a3, encounterType, a5);
+ FUN_0206A054(&pokemon->box, a1, pokeball, a3, encounterType, heap_id);
if (pokeball == ITEM_HEAL_BALL)
{
hp = GetMonData(pokemon, MON_DATA_MAXHP, NULL);
@@ -3334,9 +3335,9 @@ void FUN_0206A014(struct Pokemon * pokemon, u32 a1, u32 pokeball, u32 a3, u32 en
}
}
-void FUN_0206A054(struct BoxPokemon * boxmon, u32 a1, u32 pokeball, u32 a3, u32 encounterType, u32 a5)
+void FUN_0206A054(struct BoxPokemon * boxmon, struct PlayerData * a1, u32 pokeball, u32 a3, u32 encounterType, u32 heap_id)
{
- FUN_020808AC(boxmon, (int)a1, 0, (int)a3, (int)a5);
+ FUN_020808AC(boxmon, a1, 0, a3, heap_id);
SetBoxMonData(boxmon, MON_DATA_GAME_VERSION, (void *)&gGameVersion);
SetBoxMonData(boxmon, MON_DATA_POKEBALL, &pokeball);
SetBoxMonData(boxmon, MON_DATA_ENCOUNTER_TYPE, &encounterType);
diff --git a/arm9/src/sav_system_info.c b/arm9/src/sav_system_info.c
new file mode 100644
index 00000000..6b532b8d
--- /dev/null
+++ b/arm9/src/sav_system_info.c
@@ -0,0 +1,122 @@
+#include "global.h"
+#include "save_block_2.h"
+#include "MI_memory.h"
+#include "OS_ownerInfo.h"
+#include "RTC_api.h"
+#include "RTC_convert.h"
+#include "sav_system_info.h"
+
+#pragma thumb on
+
+extern void GF_RTC_CopyDateTime(RTCDate *, RTCTime *);
+
+u32 Sav2_SysInfo_sizeof(void)
+{
+ return sizeof(struct SavSysInfo);
+}
+
+void Sav2_SysInfo_init(struct SavSysInfo * unk)
+{
+ MI_CpuClearFast(unk, sizeof(struct SavSysInfo));
+ Sav2_SysInfo_RTC_init(&unk->rtcInfo);
+}
+
+struct SavSysInfo * Sav2_SysInfo_get(struct SaveBlock2 * sav2)
+{
+ return (struct SavSysInfo *)SavArray_get(sav2, 0);
+}
+
+struct UnkSaveStruct_0202376C_sub * Sav2_SysInfo_RTC_get(struct SaveBlock2 * sav2)
+{
+ return &Sav2_SysInfo_get(sav2)->rtcInfo;
+}
+
+void Sav2_SysInfo_InitFromSystem(struct SavSysInfo * unk)
+{
+ OSOwnerInfo info;
+ unk->rtcOffset = OS_GetOwnerRtcOffset();
+ OS_GetMacAddress(unk->macAddr);
+ OS_GetOwnerInfo(&info);
+ unk->birthMonth = info.birthday.month;
+ unk->birthDay = info.birthday.day;
+}
+
+BOOL Sav2_SysInfo_MacAddressIsMine(struct SavSysInfo * unk)
+{
+ u8 macAddr[6];
+ OS_GetMacAddress(macAddr);
+ for (int i = 0; i < 6; i++)
+ {
+ if (macAddr[i] != unk->macAddr[i])
+ return FALSE;
+ }
+ return TRUE;
+}
+
+BOOL Sav2_SysInfo_RTCOffsetIsMine(struct SavSysInfo * unk)
+{
+ return OS_GetOwnerRtcOffset() == unk->rtcOffset;
+}
+
+u8 Sav2_SysInfo_GetBirthMonth(struct SavSysInfo * unk)
+{
+ return unk->birthMonth;
+}
+
+u8 Sav2_SysInfo_GetBirthDay(struct SavSysInfo * unk)
+{
+ return unk->birthDay;
+}
+
+u8 FUN_02023820(struct SavSysInfo * unk)
+{
+ return unk->field_48;
+}
+
+void FUN_02023828(struct SavSysInfo * unk, u8 val)
+{
+ unk->field_48 = val;
+}
+
+u32 FUN_02023830(struct SavSysInfo * unk)
+{
+ return unk->field_4C;
+}
+
+void FUN_02023834(struct SavSysInfo * unk, u32 val)
+{
+ if (unk->field_4C == 0)
+ unk->field_4C = val;
+}
+
+void Sav2_SysInfo_RTC_init(struct UnkSaveStruct_0202376C_sub * sub)
+{
+ sub->field_00 = 1;
+ GF_RTC_CopyDateTime(&sub->date, &sub->time);
+ sub->daysSinceNitroEpoch = RTC_ConvertDateToDay(&sub->date);
+ sub->secondsSinceNitroEpoch = RTC_ConvertDateTimeToSecond(&sub->date, &sub->time);
+ sub->field_2C = 0;
+ sub->field_34 = 0;
+}
+
+BOOL FUN_02023874(struct UnkSaveStruct_0202376C_sub * sub)
+{
+ return sub->field_34 != 0;
+}
+
+void FUN_02023884(struct UnkSaveStruct_0202376C_sub * sub, u32 a1)
+{
+ if (sub->field_34 > 1440)
+ sub->field_34 = 1440;
+ if (sub->field_34 < a1)
+ sub->field_34 = 0;
+ else
+ sub->field_34 -= a1;
+}
+
+void FUN_020238A4(struct UnkSaveStruct_0202376C_sub * sub)
+{
+ sub->field_34 = 1440;
+ GF_RTC_CopyDateTime(&sub->date, &sub->time);
+ sub->daysSinceNitroEpoch = RTC_ConvertDateToDay(&sub->date);
+}
diff --git a/arm9/src/save_arrays.c b/arm9/src/save_arrays.c
index abd09b1c..58e1ff4c 100644
--- a/arm9/src/save_arrays.c
+++ b/arm9/src/save_arrays.c
@@ -7,7 +7,7 @@
extern u32 FUN_0202B034(void);
extern u32 FUN_0202AC20(void);
-extern u32 FUN_0202376C(void);
+extern u32 Sav2_SysInfo_sizeof(void);
extern u32 FUN_0204BE14(void);
extern u32 FUN_02034D7C(void);
extern u32 FUN_02023D64(void);
@@ -40,7 +40,7 @@ extern u32 FUN_02013B28(void);
extern u32 PCStorage_sizeof(void);
extern void FUN_0202B03C(void *);
extern void FUN_0202AC28(void *);
-extern void FUN_02023770(void *);
+extern void Sav2_SysInfo_init(void *);
extern void FUN_0204BE18(void *);
extern void FUN_02034D98(void *);
extern void FUN_02024378(void *);
@@ -78,7 +78,7 @@ const struct SaveChunkHeader UNK_020EE6E0[] = {
};
const struct SaveChunkHeader UNK_020EE700[] = {
- { 0, 0, (SAVSIZEFN)FUN_0202376C, (SAVINITFN)FUN_02023770 },
+ { 0, 0, (SAVSIZEFN)Sav2_SysInfo_sizeof, (SAVINITFN)Sav2_SysInfo_init },
{ 1, 0, (SAVSIZEFN)Sav2_PlayerData_sizeof, (SAVINITFN)Sav2_PlayerData_init },
{ 2, 0, (SAVSIZEFN)SavArray_Party_sizeof, (SAVINITFN)SavArray_Party_init },
{ 3, 0, (SAVSIZEFN)Sav2_Bag_sizeof, (SAVINITFN)Sav2_Bag_init },