summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Hensley <hensley.derek58@gmail.com>2023-06-23 21:26:36 -0700
committerGitHub <noreply@github.com>2023-06-24 14:26:36 +1000
commit5619dc5b5e3a1507feb7828ccfd70fe67268ece4 (patch)
treefbe6c35e740d095b949a809c11f32ea662b6d51b
parentaa9e368561ae13106daa14da4e2bf0656bfc70da (diff)
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
-rw-r--r--include/color.h4
-rw-r--r--include/loadfragment.h42
-rw-r--r--include/macros.h7
-rw-r--r--include/variables.h3
-rw-r--r--include/z64load.h31
-rw-r--r--src/boot_O2/loadfragment.c146
-rw-r--r--src/boot_O2/loadfragment2.c132
-rw-r--r--src/code/graph.c2
-rw-r--r--src/code/z_DLF.c51
-rw-r--r--src/code/z_actor.c11
-rw-r--r--src/code/z_actor_dlftbls.c4
-rw-r--r--src/code/z_effect_soft_sprite.c27
-rw-r--r--src/code/z_kaleido_manager.c10
-rw-r--r--src/code/z_lifemeter.c1
-rw-r--r--src/code/z_overlay.c8
-rw-r--r--src/overlays/actors/ovl_En_Twig/z_en_twig.c1
-rw-r--r--tools/disasm/functions.txt12
-rw-r--r--tools/disasm/variables.txt2
-rw-r--r--tools/sizes/boot_functions.csv12
19 files changed, 308 insertions, 198 deletions
diff --git a/include/color.h b/include/color.h
index b49ab8d78..def50caa8 100644
--- a/include/color.h
+++ b/include/color.h
@@ -73,4 +73,8 @@ typedef union{
#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 24) | (((g) & 0xFF) << 16) | (((b) & 0xFF) << 8) | (((a) & 0xFF) << 0))
+#define RGBA16_GET_R(pixel) (((pixel) >> 11) & 0x1F)
+#define RGBA16_GET_G(pixel) (((pixel) >> 6) & 0x1F)
+#define RGBA16_GET_B(pixel) (((pixel) >> 1) & 0x1F)
+
#endif
diff --git a/include/loadfragment.h b/include/loadfragment.h
new file mode 100644
index 000000000..db1f3a322
--- /dev/null
+++ b/include/loadfragment.h
@@ -0,0 +1,42 @@
+#ifndef LOADFRAGMENT_H
+#define LOADFRAGMENT_H
+
+#include "PR/ultratypes.h"
+#include "libc/stdint.h"
+#include "libc/stddef.h"
+
+extern s32 gOverlayLogSeverity;
+
+#define RELOC_SECTION(reloc) ((reloc) >> 30)
+#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF)
+#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000)
+#define RELOC_TYPE_SHIFT 24
+
+/* MIPS Relocation Types */
+#define R_MIPS_32 2
+#define R_MIPS_26 4
+#define R_MIPS_HI16 5
+#define R_MIPS_LO16 6
+
+typedef enum {
+ /* 0 */ RELOC_SECTION_NULL,
+ /* 1 */ RELOC_SECTION_TEXT,
+ /* 2 */ RELOC_SECTION_DATA,
+ /* 3 */ RELOC_SECTION_RODATA,
+ /* 4 */ RELOC_SECTION_MAX
+} RelocSectionId;
+
+typedef struct OverlayRelocationSection {
+ /* 0x00 */ size_t textSize;
+ /* 0x04 */ size_t dataSize;
+ /* 0x08 */ size_t rodataSize;
+ /* 0x0C */ size_t bssSize;
+ /* 0x10 */ u32 numRelocations;
+ /* 0x14 */ u32 relocations[1]; // array count is numRelocations
+} OverlayRelocationSection; // size >= 0x18
+
+// Fragment overlay load functions
+size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart, uintptr_t vramEnd, void* allocatedRamAddr);
+void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart, uintptr_t vramEnd);
+
+#endif
diff --git a/include/macros.h b/include/macros.h
index 7924066b6..1755a398c 100644
--- a/include/macros.h
+++ b/include/macros.h
@@ -104,10 +104,6 @@
#define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x))
#define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x))
-#define RGBA16_GET_R(pixel) (((pixel) >> 11) & 0x1F)
-#define RGBA16_GET_G(pixel) (((pixel) >> 6) & 0x1F)
-#define RGBA16_GET_B(pixel) (((pixel) >> 1) & 0x1F)
-
#define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5))
#define SWAP(type, a, b) \
@@ -118,7 +114,4 @@
} \
(void)0
-#define OVERLAY_RELOCATION_OFFSET(overlayEntry) ((uintptr_t)((overlayEntry)->vramStart) - (uintptr_t)((overlayEntry)->loadedRamAddr))
-#define VRAM_PTR_SIZE(entry) ((uintptr_t)((entry)->vramEnd) - (uintptr_t)((entry)->vramStart))
-
#endif // MACROS_H
diff --git a/include/variables.h b/include/variables.h
index 9882fa0f4..a5d05901f 100644
--- a/include/variables.h
+++ b/include/variables.h
@@ -35,9 +35,6 @@ extern const char* sCpuExceptions[18];
extern const char* sFpuExceptions[6];
extern FaultDrawer* sFaultDrawContext;
extern FaultDrawer sFaultDrawerDefault;
-extern s32 gLoadLogSeverity;
-extern s32 gLoad2LogSeverity;
-
// extern UNK_TYPE1 sGfxPrintFontTLUT;
// extern UNK_TYPE1 sGfxPrintRainbowTLUT;
// extern UNK_TYPE1 sGfxPrintRainbowData;
diff --git a/include/z64load.h b/include/z64load.h
deleted file mode 100644
index 8570faf25..000000000
--- a/include/z64load.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef Z64LOAD_H
-#define Z64LOAD_H
-
-#include "PR/ultratypes.h"
-
-#define RELOCATE_ADDR(addr, vRamStart, allocu32) ((addr) - (vRamStart) + (allocu32))
-
-#define RELOC_SECTION(reloc) ((reloc) >> 30)
-#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF)
-#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000)
-#define RELOC_TYPE_SHIFT 24
-
-/* MIPS Relocation Types */
-#define R_MIPS_32 2
-#define R_MIPS_26 4
-#define R_MIPS_HI16 5
-#define R_MIPS_LO16 6
-
-typedef struct {
- /* 0x00 */ u32 textSize;
- /* 0x04 */ u32 dataSize;
- /* 0x08 */ u32 rodataSize;
- /* 0x0C */ u32 bssSize;
- /* 0x10 */ u32 nRelocations;
- /* 0x14 */ u32 relocations[1];
-} OverlayRelocationSection; // size >= 0x18
-
-size_t Load2_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd, void* allocatedVRamAddr);
-void* Load2_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd);
-
-#endif
diff --git a/src/boot_O2/loadfragment.c b/src/boot_O2/loadfragment.c
index 17ed6b8ef..517c82bbb 100644
--- a/src/boot_O2/loadfragment.c
+++ b/src/boot_O2/loadfragment.c
@@ -1,42 +1,81 @@
/**
* @file loadfragment.c
*
- * Functions used to process and relocate overlays
+ * Functions used to process and relocate dynamically loadable code segments (overlays).
*
* @note:
- * These are completly unused in favor of the functions in `loadfragment2.c`.
+ * These are completly unused in favor of the fragment overlay functions in `loadfragment2.c`.
*
- * The main difference between them seems to be the lack of vRamEnd arguments here.
+ * The main difference between them seems to be the lack of vramEnd arguments here.
* Instead they are calculated on the fly.
*/
#include "global.h"
#include "system_malloc.h"
-#include "z64load.h"
+#include "loadfragment.h"
s32 gLoadLogSeverity = 2;
-void Load_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintptr_t vRamStart) {
- u32 sections[4];
+// Extract MIPS register rs from an instruction word
+#define MIPS_REG_RS(insn) (((insn) >> 0x15) & 0x1F)
+
+// Extract MIPS register rt from an instruction word
+#define MIPS_REG_RT(insn) (((insn) >> 0x10) & 0x1F)
+
+// Extract MIPS jump target from an instruction word
+#define MIPS_JUMP_TARGET(insn) (((insn)&0x03FFFFFF) << 2)
+
+/**
+ * Performs runtime relocation of overlay files, loadable code segments.
+ *
+ * Overlays are expected to be loadable anywhere in direct-mapped cached (KSEG0) memory, with some appropriate
+ * alignment requirements; memory addresses in such code must be updated once loaded to execute properly.
+ * When compiled, overlays are given 'fake' KSEG0 RAM addresses larger than the total possible available main memory
+ * (>= 0x80800000), such addresses are referred to as Virtual RAM (VRAM) to distinguish them. When loading the overlay,
+ * the relocation table produced at compile time is consulted to determine where and how to update these VRAM addresses
+ * to correct RAM addresses based on the location the overlay was loaded at, enabling the code to execute at this
+ * address as if it were compiled to run at this address.
+ *
+ * Each relocation is represented by a packed 32-bit value, formatted in the following way:
+ * - [31:30] 2-bit section id, taking values from the `RelocSectionId` enum.
+ * - [29:24] 6-bit relocation type describing which relocation operation should be performed. Same as ELF32 MIPS.
+ * - [23: 0] 24-bit section-relative offset indicating where in the section to apply this relocation.
+ *
+ * @param allocatedRamAddr Memory address the binary was loaded at.
+ * @param ovlRelocs Overlay relocation section containing overlay section layout and runtime relocations.
+ * @param vramStart Virtual RAM address that the overlay was compiled at.
+ */
+void Fragment_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, uintptr_t vramStart) {
+ u32 sections[RELOC_SECTION_MAX];
u32* relocDataP;
u32 reloc;
uintptr_t relocatedAddress;
u32 i;
u32* luiInstRef;
- uintptr_t allocu32 = (uintptr_t)allocatedVRamAddr;
+ uintptr_t allocu32 = (uintptr_t)allocatedRamAddr;
u32* regValP;
+ //! MIPS ELF relocation does not generally require tracking register values, so at first glance it appears this
+ //! register tracking was an unnecessary complication. However there is a bug in the IDO compiler that can cause
+ //! relocations to be emitted in the wrong order under rare circumstances when the compiler attempts to reuse a
+ //! previous HI16 relocation for a different LO16 relocation as an optimization. This register tracking is likely
+ //! a workaround to prevent improper matching of unrelated HI16 and LO16 relocations that would otherwise arise
+ //! due to the incorrect ordering.
u32* luiRefs[32];
u32 luiVals[32];
u32 isLoNeg;
if (gLoadLogSeverity >= 3) {}
- sections[0] = 0;
- sections[1] = allocu32;
- sections[2] = allocu32 + ovl->textSize;
- sections[3] = sections[2] + ovl->dataSize;
-
- for (i = 0; i < ovl->nRelocations; i++) {
- reloc = ovl->relocations[i];
+ sections[RELOC_SECTION_NULL] = 0;
+ sections[RELOC_SECTION_TEXT] = allocu32;
+ sections[RELOC_SECTION_DATA] = allocu32 + ovlRelocs->textSize;
+ sections[RELOC_SECTION_RODATA] = sections[RELOC_SECTION_DATA] + ovlRelocs->dataSize;
+
+ for (i = 0; i < ovlRelocs->numRelocations; i++) {
+ // This will always resolve to a 32-bit aligned address as each section
+ // containing code or pointers must be aligned to at least 4 bytes and the
+ // MIPS ABI defines the offset of both 16-bit and 32-bit relocations to be
+ // the start of the 32-bit word containing the target.
+ reloc = ovlRelocs->relocations[i];
relocDataP = (u32*)(sections[RELOC_SECTION(reloc)] + RELOC_OFFSET(reloc));
switch (RELOC_TYPE_MASK(reloc)) {
@@ -46,7 +85,7 @@ void Load_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintp
// Check address is valid for relocation
if ((*relocDataP & 0x0F000000) == 0) {
- *relocDataP = RELOCATE_ADDR(*relocDataP, vRamStart, allocu32);
+ *relocDataP = *relocDataP - vramStart + allocu32;
} else if (gLoadLogSeverity >= 3) {
}
break;
@@ -56,10 +95,11 @@ void Load_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintp
// Extract the address from the target field of the J-type MIPS instruction.
// Relocate the address and update the instruction.
- *relocDataP =
- (*relocDataP & 0xFC000000) |
- ((RELOCATE_ADDR(PHYS_TO_K0((*relocDataP & 0x03FFFFFF) << 2), vRamStart, allocu32) & 0x0FFFFFFF) >>
- 2);
+ if (1) {
+ *relocDataP =
+ (*relocDataP & 0xFC000000) |
+ (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - vramStart + allocu32) & 0x0FFFFFFF) >> 2);
+ }
break;
case R_MIPS_HI16 << RELOC_TYPE_SHIFT:
@@ -83,7 +123,7 @@ void Load_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintp
// Check address is valid for relocation
if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) {
- relocatedAddress = RELOCATE_ADDR((*regValP << 0x10) + (s16)*relocDataP, vRamStart, allocu32);
+ relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - vramStart + allocu32;
isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0;
*luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg);
*relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF);
@@ -94,97 +134,97 @@ void Load_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintp
}
}
-size_t Load_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, void* allocatedVRamAddr,
- size_t allocatedBytes) {
- size_t size = vRomEnd - vRomStart;
+size_t Fragment_Load(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart, void* allocatedRamAddr,
+ size_t allocatedBytes) {
+ size_t size = vromEnd - vromStart;
void* end;
s32 pad;
- OverlayRelocationSection* ovl;
+ OverlayRelocationSection* ovlRelocs;
if (gLoadLogSeverity >= 3) {}
if (gLoadLogSeverity >= 3) {}
- end = (uintptr_t)allocatedVRamAddr + size;
- DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size);
+ end = (uintptr_t)allocatedRamAddr + size;
+ DmaMgr_SendRequest0(allocatedRamAddr, vromStart, size);
- ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]);
+ ovlRelocs = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]);
if (gLoadLogSeverity >= 3) {}
- if (allocatedBytes < ovl->bssSize + size) {
+ if (allocatedBytes < ovlRelocs->bssSize + size) {
if (gLoadLogSeverity >= 3) {}
return 0;
}
- allocatedBytes = ovl->bssSize + size;
+ allocatedBytes = ovlRelocs->bssSize + size;
if (gLoadLogSeverity >= 3) {}
- Load_Relocate(allocatedVRamAddr, ovl, vRamStart);
+ Fragment_Relocate(allocatedRamAddr, ovlRelocs, vramStart);
- if (ovl->bssSize != 0) {
+ if (ovlRelocs->bssSize != 0) {
if (gLoadLogSeverity >= 3) {}
- bzero(end, ovl->bssSize);
+ bzero(end, ovlRelocs->bssSize);
}
- osWritebackDCache(allocatedVRamAddr, allocatedBytes);
- osInvalICache(allocatedVRamAddr, allocatedBytes);
+ osWritebackDCache(allocatedRamAddr, allocatedBytes);
+ osInvalICache(allocatedRamAddr, allocatedBytes);
if (gLoadLogSeverity >= 3) {}
return allocatedBytes;
}
-void* Load_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart) {
- size_t size = vRomEnd - vRomStart;
+void* Fragment_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart) {
+ size_t size = vromEnd - vromStart;
void* end;
- void* allocatedVRamAddr;
+ void* allocatedRamAddr;
uintptr_t ovlOffset;
- OverlayRelocationSection* ovl;
+ OverlayRelocationSection* ovlRelocs;
size_t allocatedBytes;
if (gLoadLogSeverity >= 3) {}
- allocatedVRamAddr = SystemArena_MallocR(size);
- end = (uintptr_t)allocatedVRamAddr + size;
+ allocatedRamAddr = SystemArena_MallocR(size);
+ end = (uintptr_t)allocatedRamAddr + size;
if (gLoadLogSeverity >= 3) {}
- DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size);
+ DmaMgr_SendRequest0(allocatedRamAddr, vromStart, size);
if (gLoadLogSeverity >= 3) {}
ovlOffset = (uintptr_t)end - 4;
- ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]);
+ ovlRelocs = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]);
if (1) {}
- allocatedBytes = ovl->bssSize + size;
+ allocatedBytes = ovlRelocs->bssSize + size;
- allocatedVRamAddr = SystemArena_Realloc(allocatedVRamAddr, allocatedBytes);
+ allocatedRamAddr = SystemArena_Realloc(allocatedRamAddr, allocatedBytes);
if (gLoadLogSeverity >= 3) {}
- if (allocatedVRamAddr == NULL) {
+ if (allocatedRamAddr == NULL) {
if (gLoadLogSeverity >= 3) {}
- return allocatedVRamAddr;
+ return allocatedRamAddr;
}
- end = (uintptr_t)allocatedVRamAddr + size;
- ovl = (OverlayRelocationSection*)((uintptr_t)end - *(uintptr_t*)ovlOffset);
+ end = (uintptr_t)allocatedRamAddr + size;
+ ovlRelocs = (OverlayRelocationSection*)((uintptr_t)end - *(uintptr_t*)ovlOffset);
if (gLoadLogSeverity >= 3) {}
- Load_Relocate(allocatedVRamAddr, ovl, vRamStart);
+ Fragment_Relocate(allocatedRamAddr, ovlRelocs, vramStart);
- if (ovl->bssSize != 0) {
+ if (ovlRelocs->bssSize != 0) {
if (gLoadLogSeverity >= 3) {}
- bzero(end, ovl->bssSize);
+ bzero(end, ovlRelocs->bssSize);
}
- osInvalICache(allocatedVRamAddr, allocatedBytes);
+ osInvalICache(allocatedRamAddr, allocatedBytes);
if (gLoadLogSeverity >= 3) {}
- return allocatedVRamAddr;
+ return allocatedRamAddr;
}
diff --git a/src/boot_O2/loadfragment2.c b/src/boot_O2/loadfragment2.c
index 51b651c2b..6925aaaac 100644
--- a/src/boot_O2/loadfragment2.c
+++ b/src/boot_O2/loadfragment2.c
@@ -1,37 +1,78 @@
/**
* @file loadfragment2.c
*
- * Functions used to process and relocate overlays
+ * Functions used to process and relocate dynamically loadable code segments (overlays).
*
+ * @note:
+ * These are for specific fragment overlays with the .ovl file extension
*/
#include "global.h"
#include "system_malloc.h"
-#include "z64load.h"
+#include "loadfragment.h"
-s32 gLoad2LogSeverity = 2;
+s32 gOverlayLogSeverity = 2;
-void Load2_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uintptr_t vRamStart) {
- u32 sections[4];
+// Extract MIPS register rs from an instruction word
+#define MIPS_REG_RS(insn) (((insn) >> 0x15) & 0x1F)
+
+// Extract MIPS register rt from an instruction word
+#define MIPS_REG_RT(insn) (((insn) >> 0x10) & 0x1F)
+
+// Extract MIPS jump target from an instruction word
+#define MIPS_JUMP_TARGET(insn) (((insn)&0x03FFFFFF) << 2)
+
+/**
+ * Performs runtime relocation of overlay files, loadable code segments.
+ *
+ * Overlays are expected to be loadable anywhere in direct-mapped cached (KSEG0) memory, with some appropriate
+ * alignment requirements; memory addresses in such code must be updated once loaded to execute properly.
+ * When compiled, overlays are given 'fake' KSEG0 RAM addresses larger than the total possible available main memory
+ * (>= 0x80800000), such addresses are referred to as Virtual RAM (VRAM) to distinguish them. When loading the overlay,
+ * the relocation table produced at compile time is consulted to determine where and how to update these VRAM addresses
+ * to correct RAM addresses based on the location the overlay was loaded at, enabling the code to execute at this
+ * address as if it were compiled to run at this address.
+ *
+ * Each relocation is represented by a packed 32-bit value, formatted in the following way:
+ * - [31:30] 2-bit section id, taking values from the `RelocSectionId` enum.
+ * - [29:24] 6-bit relocation type describing which relocation operation should be performed. Same as ELF32 MIPS.
+ * - [23: 0] 24-bit section-relative offset indicating where in the section to apply this relocation.
+ *
+ * @param allocatedRamAddress Memory address the binary was loaded at.
+ * @param ovlRelocs Overlay relocation section containing overlay section layout and runtime relocations.
+ * @param vramStart Virtual RAM address that the overlay was compiled at.
+ */
+void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, uintptr_t vramStart) {
+ u32 sections[RELOC_SECTION_MAX];
u32* relocDataP;
u32 reloc;
uintptr_t relocatedAddress;
u32 i;
u32* luiInstRef;
- uintptr_t allocu32 = (uintptr_t)allocatedVRamAddr;
+ uintptr_t allocu32 = (uintptr_t)allocatedRamAddr;
u32* regValP;
+ //! MIPS ELF relocation does not generally require tracking register values, so at first glance it appears this
+ //! register tracking was an unnecessary complication. However there is a bug in the IDO compiler that can cause
+ //! relocations to be emitted in the wrong order under rare circumstances when the compiler attempts to reuse a
+ //! previous HI16 relocation for a different LO16 relocation as an optimization. This register tracking is likely
+ //! a workaround to prevent improper matching of unrelated HI16 and LO16 relocations that would otherwise arise
+ //! due to the incorrect ordering.
u32* luiRefs[32];
u32 luiVals[32];
u32 isLoNeg;
- if (gLoad2LogSeverity >= 3) {}
+ if (gOverlayLogSeverity >= 3) {}
- sections[0] = 0;
- sections[1] = allocu32;
- sections[2] = allocu32 + ovl->textSize;
- sections[3] = sections[2] + ovl->dataSize;
+ sections[RELOC_SECTION_NULL] = 0;
+ sections[RELOC_SECTION_TEXT] = allocu32;
+ sections[RELOC_SECTION_DATA] = allocu32 + ovlRelocs->textSize;
+ sections[RELOC_SECTION_RODATA] = sections[RELOC_SECTION_DATA] + ovlRelocs->dataSize;
- for (i = 0; i < ovl->nRelocations; i++) {
- reloc = ovl->relocations[i];
+ for (i = 0; i < ovlRelocs->numRelocations; i++) {
+ // This will always resolve to a 32-bit aligned address as each section
+ // containing code or pointers must be aligned to at least 4 bytes and the
+ // MIPS ABI defines the offset of both 16-bit and 32-bit relocations to be
+ // the start of the 32-bit word containing the target.
+ reloc = ovlRelocs->relocations[i];
relocDataP = (u32*)(sections[RELOC_SECTION(reloc)] + RELOC_OFFSET(reloc));
switch (RELOC_TYPE_MASK(reloc)) {
@@ -41,8 +82,8 @@ void Load2_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uint
// Check address is valid for relocation
if ((*relocDataP & 0x0F000000) == 0) {
- *relocDataP = RELOCATE_ADDR(*relocDataP, vRamStart, allocu32);
- } else if (gLoad2LogSeverity >= 3) {
+ *relocDataP = *relocDataP - vramStart + allocu32;
+ } else if (gOverlayLogSeverity >= 3) {
}
break;
@@ -51,10 +92,11 @@ void Load2_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uint
// Extract the address from the target field of the J-type MIPS instruction.
// Relocate the address and update the instruction.
- *relocDataP =
- (*relocDataP & 0xFC000000) |
- ((RELOCATE_ADDR(PHYS_TO_K0((*relocDataP & 0x03FFFFFF) << 2), vRamStart, allocu32) & 0x0FFFFFFF) >>
- 2);
+ if (1) {
+ *relocDataP =
+ (*relocDataP & 0xFC000000) |
+ (((PHYS_TO_K0(MIPS_JUMP_TARGET(*relocDataP)) - vramStart + allocu32) & 0x0FFFFFFF) >> 2);
+ }
break;
case R_MIPS_HI16 << RELOC_TYPE_SHIFT:
@@ -78,58 +120,58 @@ void Load2_Relocate(void* allocatedVRamAddr, OverlayRelocationSection* ovl, uint
// Check address is valid for relocation
if ((((*luiInstRef << 0x10) + (s16)*relocDataP) & 0x0F000000) == 0) {
- relocatedAddress = RELOCATE_ADDR((*regValP << 0x10) + (s16)*relocDataP, vRamStart, allocu32);
+ relocatedAddress = ((*regValP << 0x10) + (s16)*relocDataP) - vramStart + allocu32;
isLoNeg = (relocatedAddress & 0x8000) ? 1 : 0;
*luiInstRef = (*luiInstRef & 0xFFFF0000) | (((relocatedAddress >> 0x10) & 0xFFFF) + isLoNeg);
*relocDataP = (*relocDataP & 0xFFFF0000) | (relocatedAddress & 0xFFFF);
- } else if (gLoad2LogSeverity >= 3) {
+ } else if (gOverlayLogSeverity >= 3) {
}
break;
}
}
}
-size_t Load2_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd,
- void* allocatedVRamAddr) {
+size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart, uintptr_t vramEnd,
+ void* allocatedRamAddr) {
s32 pad[2];
- s32 size = vRomEnd - vRomStart;
+ s32 size = vromEnd - vromStart;
void* end;
- OverlayRelocationSection* ovl;
+ OverlayRelocationSection* ovlRelocs;
- if (gLoad2LogSeverity >= 3) {}
- if (gLoad2LogSeverity >= 3) {}
+ if (gOverlayLogSeverity >= 3) {}
+ if (gOverlayLogSeverity >= 3) {}
- end = (uintptr_t)allocatedVRamAddr + size;
- DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size);
+ end = (uintptr_t)allocatedRamAddr + size;
+ DmaMgr_SendRequest0(allocatedRamAddr, vromStart, size);
- ovl = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]);
+ ovlRelocs = (OverlayRelocationSection*)((uintptr_t)end - ((s32*)end)[-1]);
- if (gLoad2LogSeverity >= 3) {}
- if (gLoad2LogSeverity >= 3) {}
+ if (gOverlayLogSeverity >= 3) {}
+ if (gOverlayLogSeverity >= 3) {}
- Load2_Relocate(allocatedVRamAddr, ovl, vRamStart);
+ Overlay_Relocate(allocatedRamAddr, ovlRelocs, vramStart);
- if (ovl->bssSize != 0) {
- if (gLoad2LogSeverity >= 3) {}
- bzero(end, ovl->bssSize);
+ if (ovlRelocs->bssSize != 0) {
+ if (gOverlayLogSeverity >= 3) {}
+ bzero(end, ovlRelocs->bssSize);
}
- size = vRamEnd - vRamStart;
+ size = vramEnd - vramStart;
- osWritebackDCache(allocatedVRamAddr, size);
- osInvalICache(allocatedVRamAddr, size);
+ osWritebackDCache(allocatedRamAddr, size);
+ osInvalICache(allocatedRamAddr, size);
- if (gLoad2LogSeverity >= 3) {}
+ if (gOverlayLogSeverity >= 3) {}
return size;
}
-void* Load2_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd) {
- void* allocatedVRamAddr = SystemArena_MallocR(vRamEnd - vRamStart);
+void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart, uintptr_t vramEnd) {
+ void* allocatedRamAddr = SystemArena_MallocR(vramEnd - vramStart);
- if (allocatedVRamAddr != NULL) {
- Load2_LoadOverlay(vRomStart, vRomEnd, vRamStart, vRamEnd, allocatedVRamAddr);
+ if (allocatedRamAddr != NULL) {
+ Overlay_Load(vromStart, vromEnd, vramStart, vramEnd, allocatedRamAddr);
}
- return allocatedVRamAddr;
+ return allocatedRamAddr;
}
diff --git a/src/code/graph.c b/src/code/graph.c
index eca40bbaf..f4f04fc1f 100644
--- a/src/code/graph.c
+++ b/src/code/graph.c
@@ -101,7 +101,7 @@ void* Graph_FaultAddrConv(void* address, void* param) {
s32 i;
for (i = 0; i < gGraphNumGameStates; i++, gameStateOvl++) {
- diff = VRAM_PTR_SIZE(gameStateOvl);
+ diff = (uintptr_t)gameStateOvl->vramEnd - (uintptr_t)gameStateOvl->vramStart;
ramStart = gameStateOvl->loadedRamAddr;
ramConv = (uintptr_t)gameStateOvl->vramStart - (uintptr_t)ramStart;
diff --git a/src/code/z_DLF.c b/src/code/z_DLF.c
index aa5c0325d..036777d49 100644
--- a/src/code/z_DLF.c
+++ b/src/code/z_DLF.c
@@ -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;
}
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index ac014e5ca..9d1ec98a5 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -4,8 +4,8 @@
*/
#include "global.h"
+#include "loadfragment.h"
#include "z64horse.h"
-#include "z64load.h"
#include "z64quake.h"
#include "z64rumble.h"
#include "overlays/actors/ovl_En_Horse/z_en_horse.h"
@@ -3157,7 +3157,7 @@ ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) {
ActorOverlay* overlayEntry = &gActorOverlayTable[index];
ActorInit* actorInit;
- overlaySize = VRAM_PTR_SIZE(overlayEntry);
+ overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart;
if (overlayEntry->vramStart == NULL) {
actorInit = overlayEntry->initInfo;
@@ -3178,14 +3178,15 @@ ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) {
return NULL;
}
- Load2_LoadOverlay(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart,
- overlayEntry->vramEnd, overlayEntry->loadedRamAddr);
+ Overlay_Load(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, overlayEntry->vramEnd,
+ overlayEntry->loadedRamAddr);
overlayEntry->numLoaded = 0;
}
actorInit = (uintptr_t)(
(overlayEntry->initInfo != NULL)
- ? (void*)((uintptr_t)overlayEntry->initInfo - (intptr_t)OVERLAY_RELOCATION_OFFSET(overlayEntry))
+ ? (void*)((uintptr_t)overlayEntry->initInfo -
+ (intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
: NULL);
}
diff --git a/src/code/z_actor_dlftbls.c b/src/code/z_actor_dlftbls.c
index 1008cceab..2e2f80a50 100644
--- a/src/code/z_actor_dlftbls.c
+++ b/src/code/z_actor_dlftbls.c
@@ -52,7 +52,7 @@ void ActorOverlayTable_FaultClient(void* arg0, void* arg1) {
FaultDrawer_Printf("No. RamStart- RamEnd cn Name\n");
for (actorId = 0, overlayEntry = &gActorOverlayTable[0]; actorId < gMaxActorId; actorId++, overlayEntry++) {
- overlaySize = VRAM_PTR_SIZE(overlayEntry);
+ overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart;
if (overlayEntry->loadedRamAddr != NULL) {
FaultDrawer_Printf("%3d %08x-%08x %3d %s\n", actorId, overlayEntry->loadedRamAddr,
(u32)overlayEntry->loadedRamAddr + overlaySize, overlayEntry->numLoaded, "");
@@ -69,7 +69,7 @@ void* ActorOverlayTable_FaultAddrConv(void* address, void* param) {
ActorId actorId;
for (actorId = 0; actorId < gMaxActorId; actorId++, actorOvl++) {
- diff = VRAM_PTR_SIZE(actorOvl);
+ diff = (uintptr_t)actorOvl->vramEnd - (uintptr_t)actorOvl->vramStart;
ramStart = actorOvl->loadedRamAddr;
ramConv = (uintptr_t)actorOvl->vramStart - (uintptr_t)ramStart;
diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c
index 186608729..0c247998e 100644
--- a/src/code/z_effect_soft_sprite.c
+++ b/src/code/z_effect_soft_sprite.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "z64load.h"
+#include "loadfragment.h"
EffectSsInfo sEffectSsInfo = { NULL, 0, 0 };
@@ -164,7 +164,7 @@ void EffectSS_Copy(PlayState* play, EffectSs* effectsSs) {
void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initData) {
s32 index;
u32 overlaySize;
- EffectSsOverlay* entry = &gParticleOverlayTable[type];
+ EffectSsOverlay* overlayEntry = &gParticleOverlayTable[type];
EffectSsInit* initInfo;
if (EffectSS_FindFreeSpace(priority, &index) != 0) {
@@ -173,24 +173,27 @@ void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initData) {
}
sEffectSsInfo.searchIndex = index + 1;
- overlaySize = VRAM_PTR_SIZE(entry);
+ overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart;
- if (entry->vramStart == NULL) {
- initInfo = entry->initInfo;
+ if (overlayEntry->vramStart == NULL) {
+ initInfo = overlayEntry->initInfo;
} else {
- if (entry->loadedRamAddr == NULL) {
- entry->loadedRamAddr = ZeldaArena_MallocR(overlaySize);
+ if (overlayEntry->loadedRamAddr == NULL) {
+ overlayEntry->loadedRamAddr = ZeldaArena_MallocR(overlaySize);
- if (entry->loadedRamAddr == NULL) {
+ if (overlayEntry->loadedRamAddr == NULL) {
return;
}
- Load2_LoadOverlay(entry->vromStart, entry->vromEnd, entry->vramStart, entry->vramEnd, entry->loadedRamAddr);
+ Overlay_Load(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, overlayEntry->vramEnd,
+ overlayEntry->loadedRamAddr);
}
- initInfo = (uintptr_t)((entry->initInfo != NULL)
- ? (void*)((uintptr_t)entry->initInfo - (intptr_t)OVERLAY_RELOCATION_OFFSET(entry))
- : NULL);
+ initInfo = (uintptr_t)(
+ (overlayEntry->initInfo != NULL)
+ ? (void*)((uintptr_t)overlayEntry->initInfo -
+ (intptr_t)((uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr))
+ : NULL);
}
if (initInfo->init != NULL) {
diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c
index 0d9f30a08..a84e74776 100644
--- a/src/code/z_kaleido_manager.c
+++ b/src/code/z_kaleido_manager.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "z64load.h"
+#include "loadfragment.h"
#define KALEIDO_OVERLAY(name) \
{ \
@@ -24,7 +24,7 @@ void* KaleidoManager_FaultAddrConv(void* address, void* param) {
size_t diff;
if (kaleidoMgrOvl != NULL) {
- diff = VRAM_PTR_SIZE(kaleidoMgrOvl);
+ diff = (uintptr_t)kaleidoMgrOvl->vramEnd - (uintptr_t)kaleidoMgrOvl->vramStart;
ramStart = kaleidoMgrOvl->loadedRamAddr;
ramConv = (uintptr_t)kaleidoMgrOvl->vramStart - (uintptr_t)ramStart;
@@ -39,7 +39,7 @@ void* KaleidoManager_FaultAddrConv(void* address, void* param) {
void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl) {
ovl->loadedRamAddr = sKaleidoAreaPtr;
- Load2_LoadOverlay(ovl->vromStart, ovl->vromEnd, ovl->vramStart, ovl->vramEnd, ovl->loadedRamAddr);
+ Overlay_Load(ovl->vromStart, ovl->vromEnd, ovl->vramStart, ovl->vramEnd, ovl->loadedRamAddr);
ovl->offset = (uintptr_t)ovl->loadedRamAddr - (uintptr_t)ovl->vramStart;
gKaleidoMgrCurOvl = ovl;
}
@@ -47,7 +47,7 @@ void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl) {
void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) {
if (ovl->loadedRamAddr != NULL) {
ovl->offset = 0;
- bzero(ovl->loadedRamAddr, VRAM_PTR_SIZE(ovl));
+ bzero(ovl->loadedRamAddr, (uintptr_t)ovl->vramEnd - (uintptr_t)ovl->vramStart);
ovl->loadedRamAddr = NULL;
gKaleidoMgrCurOvl = NULL;
}
@@ -59,7 +59,7 @@ void KaleidoManager_Init(PlayState* play) {
u32 i;
for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) {
- size = VRAM_PTR_SIZE(&gKaleidoMgrOverlayTable[i]);
+ size = (uintptr_t)gKaleidoMgrOverlayTable[i].vramEnd - (uintptr_t)gKaleidoMgrOverlayTable[i].vramStart;
if (size > largestSize) {
largestSize = size;
}
diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c
index 5d1299bbf..d9abe151d 100644
--- a/src/code/z_lifemeter.c
+++ b/src/code/z_lifemeter.c
@@ -1,3 +1,4 @@
+#include "prevent_bss_reordering.h"
#include "global.h"
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
#include "interface/parameter_static/parameter_static.h"
diff --git a/src/code/z_overlay.c b/src/code/z_overlay.c
index 2c8c8d6d7..2e348c336 100644
--- a/src/code/z_overlay.c
+++ b/src/code/z_overlay.c
@@ -13,7 +13,7 @@
*/
#include "global.h"
-#include "z64load.h"
+#include "loadfragment.h"
void* TransitionOverlay_VramToRam(TransitionOverlay* overlayEntry, void* vramAddr) {
void* loadedRamAddr = Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr);
@@ -40,13 +40,13 @@ s32 TransitionOverlay_Load(TransitionOverlay* overlayEntry) {
return 3;
}
if (Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr) == NULL) {
- loadedRamAddr = ZeldaArena_Malloc(VRAM_PTR_SIZE(overlayEntry));
+ loadedRamAddr = ZeldaArena_Malloc((uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart);
if (loadedRamAddr == NULL) {
return -1;
}
- Load2_LoadOverlay(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart,
- overlayEntry->vramEnd, loadedRamAddr);
+ Overlay_Load(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, overlayEntry->vramEnd,
+ loadedRamAddr);
overlayEntry->loadInfo.addr = Lib_VirtualToPhysical(loadedRamAddr);
overlayEntry->loadInfo.count = 1;
return 0;
diff --git a/src/overlays/actors/ovl_En_Twig/z_en_twig.c b/src/overlays/actors/ovl_En_Twig/z_en_twig.c
index aefc6385b..7ad778659 100644
--- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c
+++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c
@@ -3,7 +3,6 @@
* Overlay: ovl_En_Twig
* Description: Beaver Race Ring
*/
-
#include "z_en_twig.h"
#include "objects/object_twig/object_twig.h"
diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt
index 64fe6b2ec..d7c955ea4 100644
--- a/tools/disasm/functions.txt
+++ b/tools/disasm/functions.txt
@@ -109,12 +109,12 @@
0x800848B8:("FaultDrawer_Init",),
0x80084940:("func_80084940",),
0x80084968:("func_80084968",),
- 0x800849A0:("Load_Relocate",),
- 0x80084C0C:("Load_LoadOverlay",),
- 0x80084CD0:("Load_AllocateAndLoad",),
- 0x80084DB0:("Load2_Relocate",),
- 0x8008501C:("Load2_LoadOverlay",),
- 0x800850C8:("Load2_AllocateAndLoad",),
+ 0x800849A0:("Fragment_Relocate",),
+ 0x80084C0C:("Fragment_Load",),
+ 0x80084CD0:("Fragment_AllocateAndLoad",),
+ 0x80084DB0:("Overlay_Relocate",),
+ 0x8008501C:("Overlay_Load",),
+ 0x800850C8:("Overlay_AllocateAndLoad",),
0x80085130:("PadUtils_Init",),
0x80085150:("func_80085150",),
0x80085158:("PadUtils_ResetPressRel",),
diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt
index b581ef1e6..3376dbef4 100644
--- a/tools/disasm/variables.txt
+++ b/tools/disasm/variables.txt
@@ -28,7 +28,7 @@
0x80096BE0:("sFaultDrawContext","FaultDrawer*","",0x4),
0x80096BE4:("sFaultDrawerDefault","FaultDrawer","",0x3c),
0x80096C20:("gLoadLogSeverity","UNK_TYPE4","",0x4),
- 0x80096C30:("gLoad2LogSeverity","UNK_TYPE4","",0x4),
+ 0x80096C30:("gOverlayLogSeverity","UNK_TYPE4","",0x4),
0x80096C40:("sStackInfoListStart","StackEntry*","",0x4),
0x80096C44:("sStackInfoListEnd","StackEntry*","",0x4),
0x80096C50:("sGfxPrintFontTLUT","u16","[64]",0x80),
diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv
index ecc9eed27..276d4954c 100644
--- a/tools/sizes/boot_functions.csv
+++ b/tools/sizes/boot_functions.csv
@@ -106,12 +106,12 @@ asm/non_matchings/boot/fault_drawer/FaultDrawer_SetInputCallback.s,FaultDrawer_S
asm/non_matchings/boot/fault_drawer/FaultDrawer_Init.s,FaultDrawer_Init,0x800848B8,0x22
asm/non_matchings/boot/boot_80084940/func_80084940.s,func_80084940,0x80084940,0xA
asm/non_matchings/boot/boot_80084940/func_80084968.s,func_80084968,0x80084968,0xE
-asm/non_matchings/boot/loadfragment/Load_Relocate.s,Load_Relocate,0x800849A0,0x9B
-asm/non_matchings/boot/loadfragment/Load_LoadOverlay.s,Load_LoadOverlay,0x80084C0C,0x31
-asm/non_matchings/boot/loadfragment/Load_AllocateAndLoad.s,Load_AllocateAndLoad,0x80084CD0,0x38
-asm/non_matchings/boot/loadfragment2/Load2_Relocate.s,Load2_Relocate,0x80084DB0,0x9B
-asm/non_matchings/boot/loadfragment2/Load2_LoadOverlay.s,Load2_LoadOverlay,0x8008501C,0x2B
-asm/non_matchings/boot/loadfragment2/Load2_AllocateAndLoad.s,Load2_AllocateAndLoad,0x800850C8,0x1A
+asm/non_matchings/boot/loadfragment/Fragment_Relocate.s,Fragment_Relocate,0x800849A0,0x9B
+asm/non_matchings/boot/loadfragment/Fragment_Load.s,Fragment_Load,0x80084C0C,0x31
+asm/non_matchings/boot/loadfragment/Fragment_AllocateAndLoad.s,Fragment_AllocateAndLoad,0x80084CD0,0x38
+asm/non_matchings/boot/loadfragment2/Overlay_Relocate.s,Overlay_Relocate,0x80084DB0,0x9B
+asm/non_matchings/boot/loadfragment2/Overlay_Load.s,Overlay_Load,0x8008501C,0x2B
+asm/non_matchings/boot/loadfragment2/Overlay_AllocateAndLoad.s,Overlay_AllocateAndLoad,0x800850C8,0x1A
asm/non_matchings/boot/padutils/PadUtils_Init.s,PadUtils_Init,0x80085130,0x8
asm/non_matchings/boot/padutils/func_80085150.s,func_80085150,0x80085150,0x2
asm/non_matchings/boot/padutils/PadUtils_ResetPressRel.s,PadUtils_ResetPressRel,0x80085158,0x3