2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
|
|
|
#include "vt.h"
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
void Overlay_LoadGameState(GameStateOverlay* overlayEntry) {
|
|
|
|
if (overlayEntry->loadedRamAddr != NULL) {
|
2021-09-04 13:33:19 +00:00
|
|
|
osSyncPrintf("既にリンクされています\n"); // "Already linked"
|
2020-03-17 04:31:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-10-04 05:18:50 +00:00
|
|
|
if (overlayEntry->vramStart == NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_28 = 0;
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->loadedRamAddr = Overlay_AllocateAndLoad(overlayEntry->vromStart, overlayEntry->vromEnd,
|
|
|
|
overlayEntry->vramStart, overlayEntry->vramEnd);
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (overlayEntry->loadedRamAddr == NULL) {
|
2021-09-04 13:33:19 +00:00
|
|
|
osSyncPrintf("ロードに失敗しました\n"); // "Loading failed"
|
2020-03-17 04:31:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
osSyncPrintf(VT_FGCOL(GREEN));
|
2020-03-22 21:19:43 +00:00
|
|
|
osSyncPrintf("OVL(d):Seg:%08x-%08x Ram:%08x-%08x Off:%08x %s\n", overlayEntry->vramStart, overlayEntry->vramEnd,
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->loadedRamAddr,
|
|
|
|
(u32)overlayEntry->loadedRamAddr + (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart,
|
2020-03-22 21:19:43 +00:00
|
|
|
(u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr, "");
|
2020-03-17 04:31:30 +00:00
|
|
|
osSyncPrintf(VT_RST);
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (overlayEntry->unk_14 != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_14 = (void*)((u32)overlayEntry->unk_14 -
|
|
|
|
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr));
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_14 = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (overlayEntry->init != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->init = (void*)((u32)overlayEntry->init -
|
|
|
|
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr));
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->init = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (overlayEntry->destroy != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->destroy = (void*)((u32)overlayEntry->destroy -
|
|
|
|
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr));
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->destroy = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (overlayEntry->unk_20 != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_20 = (void*)((u32)overlayEntry->unk_20 -
|
|
|
|
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr));
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_20 = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (overlayEntry->unk_24 != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_24 = (void*)((u32)overlayEntry->unk_24 -
|
|
|
|
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr));
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_24 = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
overlayEntry->unk_28 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
void Overlay_FreeGameState(GameStateOverlay* overlayEntry) {
|
|
|
|
if (overlayEntry->loadedRamAddr != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
s32 temp = overlayEntry->unk_28 != 0 ? -1 : 0;
|
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (temp == 0) {
|
|
|
|
if (overlayEntry->unk_14 != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_14 = (void*)((u32)overlayEntry->unk_14 +
|
|
|
|
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr));
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_14 = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (overlayEntry->init != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->init = (void*)((u32)overlayEntry->init +
|
|
|
|
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr));
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->init = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (overlayEntry->destroy != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->destroy = (void*)((u32)overlayEntry->destroy +
|
|
|
|
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr));
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->destroy = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (overlayEntry->unk_20 != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_20 = (void*)((u32)overlayEntry->unk_20 +
|
|
|
|
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr));
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_20 = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-03-22 21:19:43 +00:00
|
|
|
if (overlayEntry->unk_24 != NULL) {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_24 = (void*)((u32)overlayEntry->unk_24 +
|
|
|
|
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr));
|
2020-03-22 21:19:43 +00:00
|
|
|
} else {
|
2020-03-17 04:31:30 +00:00
|
|
|
overlayEntry->unk_24 = NULL;
|
2020-03-22 21:19:43 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
|
|
|
SystemArena_FreeDebug(overlayEntry->loadedRamAddr, "../z_DLF.c", 149);
|
|
|
|
overlayEntry->loadedRamAddr = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|