mirror of
https://github.com/zeldaret/mm.git
synced 2026-06-17 06:47:43 -04:00
Load Docs (#1222)
* Sync with OoT * Macro cleanup * Some cleanup/rename load system name to Fragment * Format * bss * Some clarifying comments regarding fragments * PR suggestions * size_t and numRelocations
This commit is contained in:
+35
-16
@@ -1,6 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
#include "z64load.h"
|
||||
#include "loadfragment.h"
|
||||
|
||||
void Overlay_LoadGameState(GameStateOverlay* overlayEntry) {
|
||||
void* vramStart;
|
||||
@@ -13,29 +13,38 @@ void Overlay_LoadGameState(GameStateOverlay* overlayEntry) {
|
||||
overlayEntry->unk_28 = 0;
|
||||
return;
|
||||
}
|
||||
overlayEntry->loadedRamAddr = Load2_AllocateAndLoad(overlayEntry->vromStart, overlayEntry->vromEnd,
|
||||
(uintptr_t)vramStart, (uintptr_t)overlayEntry->vramEnd);
|
||||
overlayEntry->loadedRamAddr = Overlay_AllocateAndLoad(overlayEntry->vromStart, overlayEntry->vromEnd,
|
||||
(uintptr_t)vramStart, (uintptr_t)overlayEntry->vramEnd);
|
||||
if (overlayEntry->loadedRamAddr != NULL) {
|
||||
|
||||
overlayEntry->unk_14 = (uintptr_t)(
|
||||
(overlayEntry->unk_14 != NULL)
|
||||
? (void*)((uintptr_t)overlayEntry->unk_14 - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry))
|
||||
? (void*)((uintptr_t)overlayEntry->unk_14 -
|
||||
(intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
|
||||
: NULL);
|
||||
overlayEntry->init =
|
||||
(uintptr_t)((overlayEntry->init != NULL)
|
||||
? (void*)((uintptr_t)overlayEntry->init - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry))
|
||||
: NULL);
|
||||
|
||||
overlayEntry->init = (uintptr_t)(
|
||||
(overlayEntry->init != NULL)
|
||||
? (void*)((uintptr_t)overlayEntry->init -
|
||||
(intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
|
||||
: NULL);
|
||||
|
||||
overlayEntry->destroy = (uintptr_t)(
|
||||
(overlayEntry->destroy != NULL)
|
||||
? (void*)((uintptr_t)overlayEntry->destroy - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry))
|
||||
? (void*)((uintptr_t)overlayEntry->destroy -
|
||||
(intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
|
||||
: NULL);
|
||||
|
||||
overlayEntry->unk_20 = (uintptr_t)(
|
||||
(overlayEntry->unk_20 != NULL)
|
||||
? (void*)((uintptr_t)overlayEntry->unk_20 - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry))
|
||||
? (void*)((uintptr_t)overlayEntry->unk_20 -
|
||||
(intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
|
||||
: NULL);
|
||||
|
||||
overlayEntry->unk_24 = (uintptr_t)(
|
||||
(overlayEntry->unk_24 != NULL)
|
||||
? (void*)((uintptr_t)overlayEntry->unk_24 - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry))
|
||||
? (void*)((uintptr_t)overlayEntry->unk_24 -
|
||||
(intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
|
||||
: NULL);
|
||||
|
||||
overlayEntry->unk_28 = 0;
|
||||
@@ -50,24 +59,34 @@ void Overlay_FreeGameState(GameStateOverlay* overlayEntry) {
|
||||
if (var_v0 == 0) {
|
||||
overlayEntry->unk_14 = (uintptr_t)(
|
||||
(overlayEntry->unk_14 != NULL)
|
||||
? (void*)((uintptr_t)overlayEntry->unk_14 + (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry))
|
||||
? (void*)((uintptr_t)overlayEntry->unk_14 +
|
||||
(intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
|
||||
: NULL);
|
||||
|
||||
overlayEntry->init = (uintptr_t)(
|
||||
(overlayEntry->init != NULL)
|
||||
? (void*)((uintptr_t)overlayEntry->init + (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry))
|
||||
? (void*)((uintptr_t)overlayEntry->init +
|
||||
(intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
|
||||
: NULL);
|
||||
|
||||
overlayEntry->destroy = (uintptr_t)(
|
||||
(overlayEntry->destroy != NULL)
|
||||
? (void*)((uintptr_t)overlayEntry->destroy + (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry))
|
||||
? (void*)((uintptr_t)overlayEntry->destroy +
|
||||
(intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
|
||||
: NULL);
|
||||
|
||||
overlayEntry->unk_20 = (uintptr_t)(
|
||||
(overlayEntry->unk_20 != NULL)
|
||||
? (void*)((uintptr_t)overlayEntry->unk_20 + (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry))
|
||||
? (void*)((uintptr_t)overlayEntry->unk_20 +
|
||||
(intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
|
||||
: NULL);
|
||||
|
||||
overlayEntry->unk_24 = (uintptr_t)(
|
||||
(overlayEntry->unk_24 != NULL)
|
||||
? (void*)((uintptr_t)overlayEntry->unk_24 + (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry))
|
||||
? (void*)((uintptr_t)overlayEntry->unk_24 +
|
||||
(intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
|
||||
: NULL);
|
||||
|
||||
SystemArena_Free(overlayEntry->loadedRamAddr);
|
||||
overlayEntry->loadedRamAddr = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user