1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-13 03:14:38 +00:00

Overlay Functions Cleanup (#1235)

* Cleanup load functions

* Some cleanup

* forgot .

* Split off Overlay_Load

* review

* OverlayRelocationType -> MIPSRelocationType

* Reloc type macro and mips relocations
This commit is contained in:
Derek Hensley 2022-05-31 11:28:17 -07:00 committed by GitHub
parent 6eeb217225
commit bd6b51a869
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 135 additions and 124 deletions

View file

@ -20,77 +20,6 @@ char D_80134488[0x18] = {
0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
};
s32 Overlay_Load(u32 vRomStart, u32 vRomEnd, void* vRamStart, void* vRamEnd, void* allocatedVRamAddr) {
s32 pad;
u32 end;
u32 bssSize;
OverlayRelocationSection* ovl;
u32 relocCnt;
u32 ovlOffset;
u32 size;
size = vRomEnd - vRomStart;
end = (u32)allocatedVRamAddr + size;
if (gOverlayLogSeverity >= 3) {
// "Start loading dynamic link function"
osSyncPrintf("\nダイナミックリンクファンクションのロードを開始します\n");
}
if (gOverlayLogSeverity >= 3) {
// "DMA transfer of TEXT, DATA, RODATA + rel (%08x-%08x)"
osSyncPrintf("TEXT,DATA,RODATA+relを転送します(%08x-%08x)\n", allocatedVRamAddr, end);
}
DmaMgr_SendRequest0((u32)allocatedVRamAddr, vRomStart, size);
ovlOffset = ((s32*)end)[-1];
ovl = (OverlayRelocationSection*)((u32)end - ovlOffset);
if (gOverlayLogSeverity >= 3) {
osSyncPrintf("TEXT(%08x), DATA(%08x), RODATA(%08x), BSS(%08x)\n", ovl->textSize, ovl->dataSize, ovl->rodataSize,
ovl->bssSize);
}
if (gOverlayLogSeverity >= 3) {
osSyncPrintf("リロケーションします\n"); // "Relocate"
}
Overlay_Relocate(allocatedVRamAddr, ovl, vRamStart);
bssSize = ovl->bssSize;
if (bssSize != 0) {
if (gOverlayLogSeverity >= 3) {
// "Clear BSS area (% 08x-% 08x)"
osSyncPrintf("BSS領域をクリアします(%08x-%08x)\n", end, end + ovl->bssSize);
}
size = ovl->bssSize;
bssSize = size;
bzero((void*)end, bssSize);
relocCnt = ovl->nRelocations;
(void)relocCnt; // suppresses set but unused warning
}
size = (u32)&ovl->relocations[ovl->nRelocations] - (u32)ovl;
if (gOverlayLogSeverity >= 3) {
// "Clear REL area (%08x-%08x)"
osSyncPrintf("REL領域をクリアします(%08x-%08x)\n", ovl, (u32)ovl + size);
}
bzero(ovl, size);
size = (u32)vRamEnd - (u32)vRamStart;
osWritebackDCache(allocatedVRamAddr, size);
osInvalICache(allocatedVRamAddr, size);
if (gOverlayLogSeverity >= 3) {
// "Finish loading dynamic link function"
osSyncPrintf("ダイナミックリンクファンクションのロードを終了します\n\n");
}
return size;
}
// possibly some kind of new() function
void* func_800FC800(u32 size) {
if (size == 0) {