summaryrefslogtreecommitdiff
path: root/arm9/src
diff options
context:
space:
mode:
authorAkira Akashi <rubenru09@aol.com>2021-05-26 03:30:42 +0100
committerGitHub <noreply@github.com>2021-05-26 03:30:42 +0100
commitee7aa44008bebf78301dd0f9d99306dc1a1b6502 (patch)
tree962ac39843c509cd6cbff6a85287258a3a9f3a5b /arm9/src
parent10bb8f2d4317fd606fef6c0d3b7345fd324fe583 (diff)
parent7d10ba28169226bf00b741f7d01bc3386b383343 (diff)
Merge branch 'master' into unkk_020851B8
Diffstat (limited to 'arm9/src')
-rw-r--r--arm9/src/error_handling.c2
-rw-r--r--arm9/src/filesystem.c20
-rw-r--r--arm9/src/game_init.c10
-rw-r--r--arm9/src/gf_rtc.c183
-rw-r--r--arm9/src/heap.c24
-rw-r--r--arm9/src/main.c2
-rw-r--r--arm9/src/poke_overlay.c16
-rw-r--r--arm9/src/pokemon.c10
-rw-r--r--arm9/src/sav_chatot.c4
-rw-r--r--arm9/src/save.c2
-rw-r--r--arm9/src/scrcmd_24.c6
-rw-r--r--arm9/src/script.c2
-rw-r--r--arm9/src/script_pokemon_util.c2
-rw-r--r--arm9/src/text.c2
-rw-r--r--arm9/src/unk_0200BA78.c2
-rw-r--r--arm9/src/unk_02016B94.c19
-rw-r--r--arm9/src/unk_02024E64.c6
-rw-r--r--arm9/src/unk_0202ABBC.c6
-rw-r--r--arm9/src/unk_0202E29C.c2
-rw-r--r--arm9/src/unk_0202F150.c8
-rw-r--r--arm9/src/unk_0206439C.c16
21 files changed, 272 insertions, 72 deletions
diff --git a/arm9/src/error_handling.c b/arm9/src/error_handling.c
index 7f006039..0b76ccff 100644
--- a/arm9/src/error_handling.c
+++ b/arm9/src/error_handling.c
@@ -5,7 +5,7 @@
-THUMB_FUNC void ErrorHandling(void)
+THUMB_FUNC void GF_AssertFail(void)
{
if (FUN_02031810())
{
diff --git a/arm9/src/filesystem.c b/arm9/src/filesystem.c
index 3775b0b8..ed82acb9 100644
--- a/arm9/src/filesystem.c
+++ b/arm9/src/filesystem.c
@@ -176,7 +176,7 @@ THUMB_FUNC void ReadFromNarcMemberByPathAndId(void * dest, const char * path, s3
FS_ReadFile(&file, &chunk_size, 4);
FS_ReadFile(&file, &num_files, 2);
if (num_files <= file_idx)
- ErrorHandling();
+ GF_AssertFail();
chunk_starts[1] = chunk_starts[0] + chunk_size;
FS_SeekFile(&file, (s32)(chunk_starts[1] + 4), FS_SEEK_SET);
FS_ReadFile(&file, &chunk_size, 4);
@@ -191,7 +191,7 @@ THUMB_FUNC void ReadFromNarcMemberByPathAndId(void * dest, const char * path, s3
else
chunk_size = size;
if (chunk_size == 0)
- ErrorHandling();
+ GF_AssertFail();
FS_ReadFile(&file, dest, (s32)chunk_size);
FS_CloseFile(&file);
}
@@ -217,7 +217,7 @@ THUMB_FUNC void * AllocAndReadFromNarcMemberByPathAndId(const char * path, s32 f
FS_ReadFile(&file, &chunk_size, 4);
FS_ReadFile(&file, &num_files, 2);
if (num_files <= file_idx)
- ErrorHandling();
+ GF_AssertFail();
chunk_starts[1] = chunk_starts[0] + chunk_size;
FS_SeekFile(&file, (s32)(chunk_starts[1] + 4), FS_SEEK_SET);
FS_ReadFile(&file, &chunk_size, 4);
@@ -232,7 +232,7 @@ THUMB_FUNC void * AllocAndReadFromNarcMemberByPathAndId(const char * path, s32 f
else
chunk_size = size;
if (chunk_size == 0)
- ErrorHandling();
+ GF_AssertFail();
switch (r4)
{
case 0:
@@ -297,7 +297,7 @@ THUMB_FUNC u32 GetNarcMemberSizeByIdPair(NarcId narc_id, s32 file_idx)
FS_ReadFile(&file, &chunk_size, 4);
FS_ReadFile(&file, &num_files, 2);
if (num_files <= file_idx)
- ErrorHandling();
+ GF_AssertFail();
chunk_starts[1] = chunk_starts[0] + chunk_size;
FS_SeekFile(&file, (s32)(chunk_starts[1] + 4), FS_SEEK_SET);
FS_ReadFile(&file, &chunk_size, 4);
@@ -309,7 +309,7 @@ THUMB_FUNC u32 GetNarcMemberSizeByIdPair(NarcId narc_id, s32 file_idx)
FS_SeekFile(&file, (s32)(chunk_starts[2] + 8 + file_start + 0), FS_SEEK_SET);
chunk_size = file_end - file_start;
if (chunk_size == 0)
- ErrorHandling();
+ GF_AssertFail();
// Bug: File is never closed
return chunk_size;
}
@@ -349,7 +349,7 @@ THUMB_FUNC void * NARC_AllocAndReadWholeMember(NARC * narc, u32 file_id, u32 hea
u32 file_end;
void * dest;
if (narc->num_files <= file_id)
- ErrorHandling();
+ GF_AssertFail();
FS_SeekFile(&narc->file, (s32)(narc->btaf_start + 12 + 8 * file_id), FS_SEEK_SET);
FS_ReadFile(&narc->file, &file_start, 4);
FS_ReadFile(&narc->file, &file_end, 4);
@@ -367,7 +367,7 @@ THUMB_FUNC void NARC_ReadWholeMember(NARC * narc, u32 file_id, void * dest)
u32 file_start;
u32 file_end;
if (narc->num_files <= file_id)
- ErrorHandling();
+ GF_AssertFail();
FS_SeekFile(&narc->file, (s32)(narc->btaf_start + 12 + 8 * file_id), FS_SEEK_SET);
FS_ReadFile(&narc->file, &file_start, 4);
FS_ReadFile(&narc->file, &file_end, 4);
@@ -380,7 +380,7 @@ THUMB_FUNC u32 NARC_GetMemberSize(NARC * narc, u32 file_id)
u32 file_start;
u32 file_end;
if (narc->num_files <= file_id)
- ErrorHandling();
+ GF_AssertFail();
FS_SeekFile(&narc->file, (s32)(narc->btaf_start + 12 + 8 * file_id), FS_SEEK_SET);
FS_ReadFile(&narc->file, &file_start, 4);
FS_ReadFile(&narc->file, &file_end, 4);
@@ -391,7 +391,7 @@ THUMB_FUNC void NARC_ReadFromMember(NARC * narc, u32 file_id, u32 pos, u32 size,
{
u32 file_start;
if (narc->num_files <= file_id)
- ErrorHandling();
+ GF_AssertFail();
FS_SeekFile(&narc->file, (s32)(narc->btaf_start + 12 + 8 * file_id), FS_SEEK_SET);
FS_ReadFile(&narc->file, &file_start, 4);
FS_SeekFile(&narc->file, (s32)(narc->gmif_start + 8 + file_start + pos), FS_SEEK_SET);
diff --git a/arm9/src/game_init.c b/arm9/src/game_init.c
index 12d18629..64ea7a54 100644
--- a/arm9/src/game_init.c
+++ b/arm9/src/game_init.c
@@ -181,12 +181,12 @@ void InitSystemForTheGame(void)
void InitGraphicMemory(void)
{
GX_SetBankForLCDC(0x1FF);
- MIi_CpuClearFast(0, (void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
+ MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
GX_DisableBankForLCDC();
- MIi_CpuClearFast(0xC0, (void *)HW_OAM, HW_OAM_SIZE);
- MIi_CpuClearFast(0xC0, (void *)HW_DB_OAM, HW_DB_OAM_SIZE);
- MIi_CpuClearFast(0, (void *)HW_PLTT, HW_PLTT_SIZE);
- MIi_CpuClearFast(0, (void *)HW_DB_PLTT, HW_DB_PLTT_SIZE);
+ MI_CpuFillFast((void *)HW_OAM, 0xC0, HW_OAM_SIZE);
+ MI_CpuFillFast((void *)HW_DB_OAM, 0xC0, HW_DB_OAM_SIZE);
+ MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE);
+ MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE);
}
void * FUN_020161A4(u32 heap_id, const char * path)
diff --git a/arm9/src/gf_rtc.c b/arm9/src/gf_rtc.c
new file mode 100644
index 00000000..02fa735f
--- /dev/null
+++ b/arm9/src/gf_rtc.c
@@ -0,0 +1,183 @@
+#include "global.h"
+#include "MI_memory.h"
+#include "gf_rtc.h"
+#include "RTC_convert.h"
+
+typedef struct GF_RTC_Work
+{
+ BOOL getDateTimeSuccess;
+ BOOL getDateTimeLock;
+ s32 getDateTimeSleep;
+ RTCResult getDateTimeErrorCode;
+ RTCDate date; // 10
+ RTCTime time; // 20
+ RTCDate date_async; // 2C
+ RTCTime time_async; // 3C
+} GF_RTC_Work;
+
+GF_RTC_Work sGFRTCWork;
+
+#define MAX_SECONDS (3155759999ll)
+
+void GF_RTC_GetDateTime(GF_RTC_Work * work);
+
+THUMB_FUNC void GF_InitRTCWork(void)
+{
+ RTC_Init();
+ __builtin__clear(&sGFRTCWork, sizeof(sGFRTCWork));
+ sGFRTCWork.getDateTimeSuccess = FALSE;
+ sGFRTCWork.getDateTimeLock = FALSE;
+ sGFRTCWork.getDateTimeSleep = 0;
+ GF_RTC_GetDateTime(&sGFRTCWork);
+}
+
+THUMB_FUNC void GF_RTC_UpdateOnFrame(void)
+{
+ if (!sGFRTCWork.getDateTimeLock)
+ {
+ if (++sGFRTCWork.getDateTimeSleep > 10)
+ {
+ sGFRTCWork.getDateTimeSleep = 0;
+ GF_RTC_GetDateTime(&sGFRTCWork);
+ }
+ }
+}
+
+THUMB_FUNC void GF_RTC_GetDateTime_Callback(RTCResult result, void * data)
+{
+ GF_RTC_Work * work = (GF_RTC_Work *)data;
+ work->getDateTimeErrorCode = result;
+ GF_ASSERT(result == RTC_RESULT_SUCCESS);
+ work->getDateTimeSuccess = TRUE;
+ work->date = work->date_async;
+ work->time = work->time_async;
+ work->getDateTimeLock = FALSE;
+}
+
+THUMB_FUNC void GF_RTC_GetDateTime(GF_RTC_Work * work)
+{
+ work->getDateTimeLock = TRUE;
+ RTCResult result = RTC_GetDateTimeAsync(&work->date_async, &work->time_async, GF_RTC_GetDateTime_Callback, work);
+ work->getDateTimeErrorCode = result;
+ GF_ASSERT(result == RTC_RESULT_SUCCESS);
+}
+
+THUMB_FUNC void GF_RTC_CopyDateTime(RTCDate * date, RTCTime * time)
+{
+ GF_ASSERT(sGFRTCWork.getDateTimeSuccess == TRUE);
+ *date = sGFRTCWork.date;
+ *time = sGFRTCWork.time;
+}
+
+THUMB_FUNC void GF_RTC_CopyTime(RTCTime * time)
+{
+ GF_ASSERT(sGFRTCWork.getDateTimeSuccess == TRUE);
+ *time = sGFRTCWork.time;
+}
+
+THUMB_FUNC void GF_RTC_CopyDate(RTCDate * date)
+{
+ GF_ASSERT(sGFRTCWork.getDateTimeSuccess == TRUE);
+ *date = sGFRTCWork.date;
+}
+
+THUMB_FUNC s32 GF_RTC_TimeToSec(void)
+{
+ RTCTime* time = &sGFRTCWork.time;
+ return 60 * time->minute + 3600 * time->hour + time->second;
+}
+
+THUMB_FUNC s64 GF_RTC_DateTimeToSec(void)
+{
+ return RTC_ConvertDateTimeToSecond(&sGFRTCWork.date, &sGFRTCWork.time);
+}
+
+static inline BOOL IsLeapYear(s32 year)
+{
+ return ((year % 4) == 0 && (year % 100) != 0) || ((year % 400) == 0);
+}
+
+THUMB_FUNC s32 GF_RTC_GetDayOfYear(const RTCDate * date)
+{
+ RTCDate date_stack;
+ s32 days;
+ static const u16 sGF_DaysPerMonth[] = {
+ 0, // Jan
+ 31, // Feb
+ 59, // Mar
+ 90, // Apr
+ 120, // May
+ 151, // Jun
+ 181, // Jul
+ 212, // Aug
+ 243, // Sep
+ 273, // Oct
+ 304, // Nov
+ 334, // Dec
+ };
+
+ days = date->day;
+ days += sGF_DaysPerMonth[date->month - 1];
+ if (date->month >= RTC_MONTH_MARCH && IsLeapYear(date->year))
+ days++;
+ date_stack = *date;
+ date_stack.month = RTC_MONTH_JANUARY;
+ date_stack.day = 1;
+ RTC_ConvertDateToDay(&date_stack);
+ RTC_ConvertDateToDay(date);
+ return days;
+}
+
+enum RTC_TimeOfDay GF_RTC_GetTimeOfDay(void);
+enum RTC_TimeOfDay GF_RTC_GetTimeOfDayByHour(s32 hour);
+
+THUMB_FUNC BOOL IsNighttime(void)
+{
+ switch (GF_RTC_GetTimeOfDay())
+ {
+ case RTC_TIMEOFDAY_NITE:
+ case RTC_TIMEOFDAY_LATE:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+THUMB_FUNC enum RTC_TimeOfDay GF_RTC_GetTimeOfDay(void)
+{
+ RTCTime time;
+ GF_RTC_CopyTime(&time);
+ return GF_RTC_GetTimeOfDayByHour(time.hour);
+}
+
+THUMB_FUNC enum RTC_TimeOfDay GF_RTC_GetTimeOfDayByHour(s32 hour)
+{
+ static const u8 sTimeOfDayByHour[] = {
+ // 00:00 - 03:59
+ RTC_TIMEOFDAY_LATE, RTC_TIMEOFDAY_LATE, RTC_TIMEOFDAY_LATE, RTC_TIMEOFDAY_LATE,
+ // 04:00 - 09:59
+ RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN, RTC_TIMEOFDAY_MORN,
+ // 10:00 - 16:59
+ RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY, RTC_TIMEOFDAY_DAY,
+ // 17:00 - 19:59
+ RTC_TIMEOFDAY_EVE, RTC_TIMEOFDAY_EVE, RTC_TIMEOFDAY_EVE,
+ // 20:00 - 23:59
+ RTC_TIMEOFDAY_NITE, RTC_TIMEOFDAY_NITE, RTC_TIMEOFDAY_NITE, RTC_TIMEOFDAY_NITE,
+ };
+
+ GF_ASSERT(hour >= 0 && hour < 24);
+ return sTimeOfDayByHour[hour];
+}
+
+THUMB_FUNC s64 GF_RTC_TimeDelta(s64 first, s64 last)
+{
+ RTCDate maxDate = { 99, 12, 31, 0 };
+ RTCTime maxTime = { 23, 59, 59 };
+
+ s64 check = RTC_ConvertDateTimeToSecond(&maxDate, &maxTime);
+ GF_ASSERT(check == MAX_SECONDS);
+ if (first < last)
+ return last - first;
+ else
+ return last + (MAX_SECONDS - first);
+}
diff --git a/arm9/src/heap.c b/arm9/src/heap.c
index 7ae25c3b..7f35fdcc 100644
--- a/arm9/src/heap.c
+++ b/arm9/src/heap.c
@@ -73,7 +73,7 @@ THUMB_FUNC void FUN_020166C8(u32 *param0, u32 param1, u32 param2, u32 pre_size)
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
param0 += 2;
@@ -162,27 +162,27 @@ THUMB_FUNC u32 FUN_02016834(u32 param0, u32 param1, u32 param2, s32 param3)
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
return 0;
}
@@ -204,7 +204,7 @@ THUMB_FUNC void FUN_020168D0(u32 heap_id)
}
else
{
- ErrorHandling();
+ GF_AssertFail();
}
UNK_021C4D28.unk00[UNK_021C4D28.unk10[heap_id]] = 0;
@@ -306,7 +306,7 @@ void FreeToHeap(void *ptr)
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
void FreeToHeapExplicit(u32 param0, void *param1)
@@ -329,7 +329,7 @@ void FreeToHeapExplicit(u32 param0, void *param1)
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
THUMB_FUNC u32 FUN_02016AF8(u32 param0)
@@ -340,7 +340,7 @@ THUMB_FUNC u32 FUN_02016AF8(u32 param0)
return NNS_FndGetTotalFreeSizeForExpHeap(UNK_021C4D28.unk00[index]);
}
- ErrorHandling();
+ GF_AssertFail();
return 0;
}
@@ -354,7 +354,7 @@ THUMB_FUNC void FUN_02016B20(u32 param0, u32 param1, u32 param2)
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
THUMB_FUNC void FUN_02016B44(void *ptr, u32 param1)
@@ -371,7 +371,7 @@ THUMB_FUNC void FUN_02016B44(void *ptr, u32 param1)
NNS_FndResizeForMBlockExpHeap(UNK_021C4D28.unk00[index], ptr - 16, param1);
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
THUMB_FUNC u32 FUN_02016B90(u32 param0)
diff --git a/arm9/src/main.c b/arm9/src/main.c
index 314c4509..7a8a14d8 100644
--- a/arm9/src/main.c
+++ b/arm9/src/main.c
@@ -170,7 +170,7 @@ THUMB_FUNC void Main_RunOverlayManager(void)
THUMB_FUNC void RegisterMainOverlay(FSOverlayID id, const struct Unk21DBE18 * arg1)
{
if (UNK_02016FA8.unkC != NULL)
- ErrorHandling();
+ GF_AssertFail();
UNK_02016FA8.unk8 = id;
UNK_02016FA8.unkC = arg1;
}
diff --git a/arm9/src/poke_overlay.c b/arm9/src/poke_overlay.c
index 4dd98670..e11ecbb6 100644
--- a/arm9/src/poke_overlay.c
+++ b/arm9/src/poke_overlay.c
@@ -9,9 +9,9 @@ static struct LoadedOverlay gLoadedOverlays[3][8];
THUMB_FUNC void FreeOverlayAllocation(struct LoadedOverlay * loaded)
{
if (loaded->active != TRUE)
- ErrorHandling();
+ GF_AssertFail();
if (FS_UnloadOverlay(MI_PROCESSOR_ARM9, loaded->id) != TRUE)
- ErrorHandling();
+ GF_AssertFail();
loaded->active = FALSE;
}
@@ -35,7 +35,7 @@ THUMB_FUNC s32 GetOverlayLoadDestination(FSOverlayID id)
u8 *end;
u8 *start;
if (FS_LoadOverlayInfo(&info, MI_PROCESSOR_ARM9, id) != TRUE)
- ErrorHandling();
+ GF_AssertFail();
start = (u8 *)HW_ITCM_IMAGE;
end = (u8 *)HW_ITCM_END;
if (info.header.ram_address <= end && info.header.ram_address >= start)
@@ -72,7 +72,7 @@ THUMB_FUNC BOOL HandleLoadOverlay(FSOverlayID id, s32 a1)
}
if (r6 >= 8)
{
- ErrorHandling();
+ GF_AssertFail();
return FALSE;
}
if (r7 == OVERLAY_LOAD_ITCM || r7 == OVERLAY_LOAD_DTCM)
@@ -91,7 +91,7 @@ THUMB_FUNC BOOL HandleLoadOverlay(FSOverlayID id, s32 a1)
result = LoadOverlayNoInitAsync(MI_PROCESSOR_ARM9, id);
break;
default:
- ErrorHandling();
+ GF_AssertFail();
return FALSE;
}
if (r7 == OVERLAY_LOAD_ITCM || r7 == OVERLAY_LOAD_DTCM)
@@ -100,7 +100,7 @@ THUMB_FUNC BOOL HandleLoadOverlay(FSOverlayID id, s32 a1)
}
if (result == 0)
{
- ErrorHandling();
+ GF_AssertFail();
return FALSE;
}
return TRUE;
@@ -120,7 +120,7 @@ THUMB_FUNC BOOL CanOverlayBeLoaded(FSOverlayID id)
{
if ((start >= start2 && start < end2) || (end > start2 && end <= end2) || (start <= start2 && end >= end2))
{
- ErrorHandling();
+ GF_AssertFail();
return FALSE;
}
}
@@ -146,7 +146,7 @@ THUMB_FUNC BOOL GetOverlayRamBounds(FSOverlayID id, void ** start, void ** end)
{
FSOverlayInfo info;
if (!FS_LoadOverlayInfo(&info, MI_PROCESSOR_ARM9, id)) {
- ErrorHandling();
+ GF_AssertFail();
return FALSE;
}
*start = (void *)info.header.ram_address;
diff --git a/arm9/src/pokemon.c b/arm9/src/pokemon.c
index b3e53d1a..29075833 100644
--- a/arm9/src/pokemon.c
+++ b/arm9/src/pokemon.c
@@ -176,14 +176,14 @@ const s8 sNatureStatMods[][5] = {
void ZeroMonData(struct Pokemon * pokemon)
{
- MIi_CpuClearFast(0, pokemon, sizeof(struct Pokemon));
+ MI_CpuClearFast(pokemon, sizeof(struct Pokemon));
ENCRYPT_BOX(&pokemon->box);
ENCRYPT_PTY(pokemon);
}
void ZeroBoxMonData(struct BoxPokemon * boxmon)
{
- MIi_CpuClearFast(0, boxmon, sizeof(struct BoxPokemon));
+ MI_CpuClearFast(boxmon, sizeof(struct BoxPokemon));
ENCRYPT_BOX(boxmon);
}
@@ -272,7 +272,7 @@ void CreateMon(struct Pokemon * pokemon, int species, int level, int fixedIV, in
FreeToHeap(mail);
capsule = 0;
SetMonData(pokemon, MON_DATA_CAPSULE, &capsule);
- MIi_CpuClearFast(0, seal_coords, sizeof(seal_coords));
+ MI_CpuClearFast(seal_coords, sizeof(seal_coords));
SetMonData(pokemon, MON_DATA_SEAL_COORDS, seal_coords);
CalcMonLevelAndStats(pokemon);
}
@@ -3004,7 +3004,7 @@ void CopyBoxPokemonToPokemon(struct BoxPokemon * src, struct Pokemon * dest)
SetMonData(dest, MON_DATA_MAIL_STRUCT, mail);
FreeToHeap(mail);
SetMonData(dest, MON_DATA_CAPSULE, &sp0);
- MIi_CpuClearFast(0, &sp4, sizeof(sp4));
+ MI_CpuClearFast(&sp4, sizeof(sp4));
SetMonData(dest, MON_DATA_SEAL_COORDS, &sp4);
CalcMonLevelAndStats(dest);
}
@@ -3724,7 +3724,7 @@ void Pokemon_RemoveCapsule(struct Pokemon * pokemon)
{
u8 sp0 = 0;
CapsuleArray sp1;
- MIi_CpuClearFast(0, &sp1, sizeof(sp1));
+ MI_CpuClearFast(&sp1, sizeof(sp1));
SetMonData(pokemon, MON_DATA_CAPSULE, &sp0);
SetMonData(pokemon, MON_DATA_SEAL_COORDS, &sp1);
}
diff --git a/arm9/src/sav_chatot.c b/arm9/src/sav_chatot.c
index 7b240a99..86786e66 100644
--- a/arm9/src/sav_chatot.c
+++ b/arm9/src/sav_chatot.c
@@ -10,7 +10,7 @@ THUMB_FUNC u32 Sav2_Chatot_sizeof(void)
THUMB_FUNC void Sav2_Chatot_init(struct SaveChatotSoundClip * chatot)
{
- MIi_CpuClear32(0, chatot, sizeof(struct SaveChatotSoundClip));
+ MI_CpuClear32(chatot, sizeof(struct SaveChatotSoundClip));
chatot->exists = FALSE;
}
@@ -94,5 +94,5 @@ THUMB_FUNC void Chatot_Encode(struct SaveChatotSoundClip * chatot, const s8 * da
THUMB_FUNC void Chatot_copy(struct SaveChatotSoundClip * dest, const struct SaveChatotSoundClip * src)
{
- MIi_CpuCopyFast(src, dest, sizeof(struct SaveChatotSoundClip));
+ MI_CpuCopyFast(src, dest, sizeof(struct SaveChatotSoundClip));
}
diff --git a/arm9/src/save.c b/arm9/src/save.c
index 85d18d06..89bd8374 100644
--- a/arm9/src/save.c
+++ b/arm9/src/save.c
@@ -82,7 +82,7 @@ BOOL FUN_0202263C(struct SaveBlock2 * sav2)
FlashClobberChunkFooter(sav2, 1, (u32)(sav2->unk_20220[1] == 0 ? 1 : 0));
FlashClobberChunkFooter(sav2, 0, (u32)(sav2->unk_20220[0]));
FlashClobberChunkFooter(sav2, 1, (u32)(sav2->unk_20220[1]));
- MIi_CpuClearFast(-1u, r6, 0x1000);
+ MI_CpuFillFast(r6, -1u, 0x1000);
for (int i = 0; i < 64; i++)
{
FlashWriteChunk((u32)(0x1000 * i), r6, 0x1000);
diff --git a/arm9/src/scrcmd_24.c b/arm9/src/scrcmd_24.c
index d3f955d0..9c8f8d4b 100644
--- a/arm9/src/scrcmd_24.c
+++ b/arm9/src/scrcmd_24.c
@@ -62,7 +62,7 @@ THUMB_FUNC asm BOOL ScrCmd_Unk01C7(struct ScriptContext* ctx)
ldr r0, [r4, #0x0]
cmp r0, #0x0
bne _02045DFC
- bl ErrorHandling
+ bl GF_AssertFail
_02045DFC:
ldr r0, [r4, #0x0]
bl FUN_02037D5C
@@ -199,7 +199,7 @@ THUMB_FUNC asm BOOL ScrCmd_Unk0223(struct ScriptContext* ctx)
ldr r4, [r0, #0x0]
cmp r4, #0x0
bne _02045FB2
- bl ErrorHandling
+ bl GF_AssertFail
_02045FB2:
ldrb r0, [r4, #0x16]
cmp r0, #0x0
@@ -257,7 +257,7 @@ THUMB_FUNC asm BOOL ScrCmd_Unk0225(struct ScriptContext* ctx)
ldr r4, [r0, #0x0]
cmp r4, #0x0
bne _02045FB2
- bl ErrorHandling
+ bl GF_AssertFail
_02045FB2:
ldrb r0, [r4, #0x16]
cmp r0, #0x0
diff --git a/arm9/src/script.c b/arm9/src/script.c
index 2fa80058..3de2ee73 100644
--- a/arm9/src/script.c
+++ b/arm9/src/script.c
@@ -76,7 +76,7 @@ THUMB_FUNC u8 RunScriptCommand(struct ScriptContext *ctx)
cmdCode = ScriptReadHalfword(ctx);
if (cmdCode >= ctx->cmdCount)
{
- ErrorHandling();
+ GF_AssertFail();
ctx->mode = 0;
return FALSE;
}
diff --git a/arm9/src/script_pokemon_util.c b/arm9/src/script_pokemon_util.c
index a3518bf4..55519ca3 100644
--- a/arm9/src/script_pokemon_util.c
+++ b/arm9/src/script_pokemon_util.c
@@ -109,7 +109,7 @@ struct Pokemon * GetFirstAliveMonInParty_CrashIfNone(struct PlayerParty * party)
if(MonNotFaintedOrEgg(mon))
return mon;
}
- ErrorHandling();
+ GF_AssertFail();
return 0;
}
diff --git a/arm9/src/text.c b/arm9/src/text.c
index 5078f229..8676cbcc 100644
--- a/arm9/src/text.c
+++ b/arm9/src/text.c
@@ -331,7 +331,7 @@ THUMB_FUNC u16 *FUN_0201C1B0(void)
void *res = AllocFromHeap(0, 32 * 24 * sizeof(u16));
struct UnkStruct_0200B870_sub * var;
void *tmp = FUN_02006BB0(NARC_GRAPHIC_FONT, 5, 0, &var, 0);
- MIi_CpuCopy32(var->unk_14, res, 32 * 24 * sizeof(u16));
+ MI_CpuCopy32(var->unk_14, res, 32 * 24 * sizeof(u16));
FreeToHeap(tmp);
return res;
}
diff --git a/arm9/src/unk_0200BA78.c b/arm9/src/unk_0200BA78.c
index d98b5374..457001ef 100644
--- a/arm9/src/unk_0200BA78.c
+++ b/arm9/src/unk_0200BA78.c
@@ -25,7 +25,7 @@ THUMB_FUNC void FUN_0200BAAC(
{
if (param0->data[i] >= 0xa2 && param0->data[i] <= 0xab)
{
- MIi_CpuCopy32(
+ MI_CpuCopy32(
&param0->unk_4->unk_14[(param0->data[i] - 0xa2) << 5], dest + i * 0x20, 0x20);
}
else
diff --git a/arm9/src/unk_02016B94.c b/arm9/src/unk_02016B94.c
index a8be5958..e01b3133 100644
--- a/arm9/src/unk_02016B94.c
+++ b/arm9/src/unk_02016B94.c
@@ -312,7 +312,7 @@ THUMB_FUNC void FUN_02016C18(
{
param0->unk08[param1].unk08 = AllocFromHeap(param0->unk00, param2->unk08);
- MIi_CpuClear16(0, param0->unk08[param1].unk08, param2->unk08);
+ MI_CpuClear16(param0->unk08[param1].unk08, param2->unk08);
param0->unk08[param1].unk0c = param2->unk08;
param0->unk08[param1].unk10 = param2->unk0c;
@@ -2580,11 +2580,11 @@ THUMB_FUNC void FUN_02017C98(const void *param0, void *param1, u32 param2)
if (((u32)param0 % 4) == 0 && ((u32)param1 % 4) == 0 && ((u16)param2 % 4) == 0)
{
- MIi_CpuCopy32(param0, param1, param2);
+ MI_CpuCopy32(param0, param1, param2);
return;
}
- MIi_CpuCopy16(param0, param1, param2);
+ MI_CpuCopy16(param0, param1, param2);
}
THUMB_FUNC void FUN_02017CD0(struct UnkStruct_02016B94_2 *param0, u32 param1)
@@ -2749,7 +2749,7 @@ THUMB_FUNC void FUN_02017F48(
r5 = r5 << 0x18 | r5 << 0x10 | r5 << 8 | r5;
}
- MIi_CpuClearFast(r5, st4, st0);
+ MI_CpuFillFast(st4, r5, st0);
FUN_02017E84((u8)param1, st4, param0->unk08[param1].unk1f * param4, st0);
FreeToHeap(st4);
@@ -3285,7 +3285,7 @@ THUMB_FUNC void FUN_02018744(struct UnkStruct_02016B94_2 *param0, u32 param1)
{
if (param0->unk08[param1].unk08 != NULL)
{
- MIi_CpuClear16(0, param0->unk08[param1].unk08, param0->unk08[param1].unk0c);
+ MI_CpuClear16(param0->unk08[param1].unk08, param0->unk08[param1].unk0c);
FUN_02017CD0(param0, param1);
}
}
@@ -3294,7 +3294,7 @@ THUMB_FUNC void FUN_02018768(struct UnkStruct_02016B94_2 *param0, u32 param1, u1
{
if (param0->unk08[param1].unk08 != NULL)
{
- MIi_CpuClear16(param2, param0->unk08[param1].unk08, param0->unk08[param1].unk0c);
+ MI_CpuFill16(param0->unk08[param1].unk08, param2, param0->unk08[param1].unk0c);
FUN_02017CD0(param0, param1);
}
}
@@ -3303,7 +3303,7 @@ THUMB_FUNC void FUN_0201878C(struct UnkStruct_02016B94_2 *param0, u32 param1, u1
{
if (param0->unk08[param1].unk08 != NULL)
{
- MIi_CpuClear16(param2, param0->unk08[param1].unk08, param0->unk08[param1].unk0c);
+ MI_CpuFill16(param0->unk08[param1].unk08, param2, param0->unk08[param1].unk0c);
FUN_0201AC68(param0, param1);
}
}
@@ -4905,9 +4905,10 @@ THUMB_FUNC void FillWindowPixelBuffer(struct Window *window, u8 param1)
param1 |= param1 << 4;
}
- MIi_CpuClearFast((u32)((param1 << 0x18) | (param1 << 0x10) | (param1 << 0x8) | param1),
+ MI_CpuFillFast(
window->unk0c,
- (u32)(window->unk00->unk08[window->unk04].unk1f * window->width * window->height));
+ (u32)((param1 << 0x18) | (param1 << 0x10) | (param1 << 0x8) | param1),
+ (u32)(window->unk00->unk08[window->unk04].unk1f * window->width * window->height));
}
THUMB_FUNC void BlitBitmapRectToWindow(struct Window *window,
diff --git a/arm9/src/unk_02024E64.c b/arm9/src/unk_02024E64.c
index d8682531..ad6a7eac 100644
--- a/arm9/src/unk_02024E64.c
+++ b/arm9/src/unk_02024E64.c
@@ -10,14 +10,14 @@ THUMB_FUNC u32 FUN_02024E64()
THUMB_FUNC void FUN_02024E6C(struct UnkStruct_02024E64 *param0)
{
- MIi_CpuClearFast(0, param0, sizeof(struct UnkStruct_02024E64));
+ MI_CpuClearFast(param0, sizeof(struct UnkStruct_02024E64));
FUN_020250A4(param0->unk0);
FUN_02025484(param0->unk700);
- MIi_CpuClear16(0xFFFF, param0->rival_name_buf, sizeof(param0->rival_name_buf) / sizeof(u16));
- MIi_CpuClear16(0xFFFF, param0->unk734, sizeof(param0->unk734) / sizeof(u16));
+ MI_CpuFill16(param0->rival_name_buf, EOS, sizeof(param0->rival_name_buf) / sizeof(u16));
+ MI_CpuFill16(param0->unk734, EOS, sizeof(param0->unk734) / sizeof(u16));
}
THUMB_FUNC struct UnkStruct_02024E64 *FUN_02024EB4(struct SaveBlock2 *sav2)
diff --git a/arm9/src/unk_0202ABBC.c b/arm9/src/unk_0202ABBC.c
index 7bc9d3fc..75a43f60 100644
--- a/arm9/src/unk_0202ABBC.c
+++ b/arm9/src/unk_0202ABBC.c
@@ -15,7 +15,7 @@ THUMB_FUNC u32 FUN_0202ABC8()
THUMB_FUNC void FUN_0202ABCC(struct Unk0202ABBC* unk)
{
- MIi_CpuClearFast(0, unk, 0xf4);
+ MI_CpuClearFast(unk, sizeof(struct Unk0202ABBC));
}
THUMB_FUNC u16 FUN_0202ABDC(struct Unk0202ABBC* unk)
@@ -30,12 +30,12 @@ THUMB_FUNC void FUN_0202ABE4(struct Unk0202ABBC* unk, u16 data)
THUMB_FUNC void FUN_0202ABEC(void *srcp, void *destp)
{
- MIi_CpuCopyFast(srcp, destp, 0xec);
+ MI_CpuCopyFast(srcp, destp, 0xec);
}
THUMB_FUNC void FUN_0202ABF8(void *destp, void *srcp)
{
- MIi_CpuCopyFast(srcp, destp, 0xec);
+ MI_CpuCopyFast(srcp, destp, 0xec);
}
THUMB_FUNC u32 FUN_0202AC08(struct Unk0202ABBC* unk)
diff --git a/arm9/src/unk_0202E29C.c b/arm9/src/unk_0202E29C.c
index 938107f2..2b088d6f 100644
--- a/arm9/src/unk_0202E29C.c
+++ b/arm9/src/unk_0202E29C.c
@@ -432,7 +432,7 @@ THUMB_FUNC s32 FUN_0202E844(u32 param0)
count++;
}
- ErrorHandling();
+ GF_AssertFail();
return 0;
}
diff --git a/arm9/src/unk_0202F150.c b/arm9/src/unk_0202F150.c
index 1586dae5..09b5b56f 100644
--- a/arm9/src/unk_0202F150.c
+++ b/arm9/src/unk_0202F150.c
@@ -95,7 +95,7 @@ THUMB_FUNC u32 FUN_0202F150(u32 param0, u32 param1)
r4 = 1;
if (UNK_021C59F4.unk04 == 0)
{
- ErrorHandling();
+ GF_AssertFail();
}
}
@@ -1191,7 +1191,7 @@ THUMB_FUNC void FUN_020304D4(u32 param0)
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
THUMB_FUNC void FUN_020304F0(u32 param0)
@@ -1202,7 +1202,7 @@ THUMB_FUNC void FUN_020304F0(u32 param0)
return;
}
- ErrorHandling();
+ GF_AssertFail();
}
THUMB_FUNC void FUN_0203050C()
@@ -1741,7 +1741,7 @@ THUMB_FUNC u32 FUN_02030B3C(u32 param0, u8 *param1, u32 param2)
{
if (FUN_02031190() != 0)
{
- ErrorHandling();
+ GF_AssertFail();
return 0;
}
diff --git a/arm9/src/unk_0206439C.c b/arm9/src/unk_0206439C.c
new file mode 100644
index 00000000..80d93557
--- /dev/null
+++ b/arm9/src/unk_0206439C.c
@@ -0,0 +1,16 @@
+#include "global.h"
+#include "heap.h"
+#include "party.h"
+#include "save_block_2.h"
+#include "unk_0206439C.h"
+
+THUMB_FUNC struct UnkStruct_0206439C* FUN_0206439C(u32 heap_id, u8 mon_idx, struct SaveBlock2* sav2)
+{
+ struct UnkStruct_0206439C* ret = AllocFromHeapAtEnd(heap_id, sizeof(struct UnkStruct_0206439C));
+ struct PlayerParty* party = SavArray_PlayerParty_get(sav2);
+
+ ret->pokemon = GetPartyMonByIndex(party, mon_idx);
+ ret->unk4 = NULL;
+
+ return ret;
+}