1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-02 15:55:59 +00:00
oot/src/code/z_DLF.c

112 lines
4.6 KiB
C
Raw Normal View History

#include "global.h"
#include "terminal.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) {
osSyncPrintf("既にリンクされています\n"); // "Already linked"
2020-03-17 04:31:30 +00:00
return;
}
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) {
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;
}
}
}