diff options
| author | Lucas Shaw <49287729+shawlucas@users.noreply.github.com> | 2024-04-12 23:19:59 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-12 20:19:59 -0700 |
| commit | 08f273cdf9fa97162f8a0e501c081170a9547769 (patch) | |
| tree | 5707a848861c49626e01142f4962ec7d89955f10 | |
| parent | fa63b7c79bd6707a8b75a402c17cf3cab9fbcccb (diff) | |
m_DLF.c OK (#170)
* m_DLF.c OK
* added comment
| -rw-r--r-- | include/6792F0.h | 9 | ||||
| -rw-r--r-- | include/m_DLF.h | 12 | ||||
| -rw-r--r-- | linker_scripts/jp/symbol_addrs_code.txt | 4 | ||||
| -rw-r--r-- | src/code/m_DLF.c | 97 | ||||
| -rw-r--r-- | yamls/jp/code.yaml | 2 |
5 files changed, 112 insertions, 12 deletions
diff --git a/include/6792F0.h b/include/6792F0.h deleted file mode 100644 index 7101adc..0000000 --- a/include/6792F0.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef C_6792F0_H -#define C_6792F0_H - -#include "ultra64.h" - -// void func_80055650_jp(); -// void func_8005578C_jp(); - -#endif diff --git a/include/m_DLF.h b/include/m_DLF.h new file mode 100644 index 0000000..c522580 --- /dev/null +++ b/include/m_DLF.h @@ -0,0 +1,12 @@ +#ifndef M_DLF_H +#define M_DLF_H + +#include "global.h" +#include "libc64/malloc.h" +#include "game.h" +#include "ovlmgr.h" + +void Overlay_LoadGameState(GameStateOverlay* overlayEntry); +void Overlay_FreeGameState(GameStateOverlay* overlayEntry); + +#endif diff --git a/linker_scripts/jp/symbol_addrs_code.txt b/linker_scripts/jp/symbol_addrs_code.txt index 647d7da..30576ac 100644 --- a/linker_scripts/jp/symbol_addrs_code.txt +++ b/linker_scripts/jp/symbol_addrs_code.txt @@ -55,8 +55,8 @@ func_80055214_jp = 0x80055214; // type:func func_80055248_jp = 0x80055248; // type:func func_800554D8_jp = 0x800554D8; // type:func Evw_Anime_Set = 0x80055598; // type:func -func_80055650_jp = 0x80055650; // type:func -func_8005578C_jp = 0x8005578C; // type:func +Overlay_LoadGameState = 0x80055650; // type:func +Overlay_FreeGameState = 0x8005578C; // type:func mAGrw_ClearDebugData = 0x800558B0; // type:func mAGrw_CheckRegistedData_debug = 0x800558F8; // type:func mAGrw_SetBlockData_debug = 0x800559D4; // type:func diff --git a/src/code/m_DLF.c b/src/code/m_DLF.c new file mode 100644 index 0000000..0bfb4e9 --- /dev/null +++ b/src/code/m_DLF.c @@ -0,0 +1,97 @@ +#include "m_DLF.h" + +// Function names taken from Zelda64 Decompilation + +void Overlay_LoadGameState(GameStateOverlay* overlayEntry) { + void* vramStart; + + if (overlayEntry->loadedRamAddr != NULL) { + return; + } + + vramStart = overlayEntry->vramStart; + if (vramStart == NULL) { + overlayEntry->unk_28 = 0; + return; + } + + overlayEntry->loadedRamAddr = malloc_r((uintptr_t)overlayEntry->vramEnd - (uintptr_t)vramStart); + + if (overlayEntry->loadedRamAddr != NULL) { + ovlmgr_Load(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, overlayEntry->vramEnd, + overlayEntry->loadedRamAddr); + overlayEntry->unk_14 = + (void*)((overlayEntry->unk_14 != NULL) + ? (void*)((uintptr_t)overlayEntry->unk_14 - (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); + + overlayEntry->init = + (void*)((overlayEntry->init != NULL) + ? (void*)((uintptr_t)overlayEntry->init - (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); + + overlayEntry->destroy = + (void*)((overlayEntry->destroy != NULL) + ? (void*)((uintptr_t)overlayEntry->destroy - (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); + + overlayEntry->unk_20 = + (void*)((overlayEntry->unk_20 != NULL) + ? (void*)((uintptr_t)overlayEntry->unk_20 - (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); + + overlayEntry->unk_24 = + (void*)((overlayEntry->unk_24 != NULL) + ? (void*)((uintptr_t)overlayEntry->unk_24 - (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); + + overlayEntry->unk_28 = 0; + } +} + +void Overlay_FreeGameState(GameStateOverlay* overlayEntry) { + s32 var_v0; + + if (overlayEntry->loadedRamAddr != NULL) { + var_v0 = (overlayEntry->unk_28 != 0) ? -1 : 0; + if (var_v0 == 0) { + overlayEntry->unk_14 = + (void*)((overlayEntry->unk_14 != NULL) ? (void*)((uintptr_t)overlayEntry->unk_14 + + (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); + + overlayEntry->init = + (void*)((overlayEntry->init != NULL) ? (void*)((uintptr_t)overlayEntry->init + + (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); + + overlayEntry->destroy = + (void*)((overlayEntry->destroy != NULL) ? (void*)((uintptr_t)overlayEntry->destroy + + (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); + + overlayEntry->unk_20 = + (void*)((overlayEntry->unk_20 != NULL) ? (void*)((uintptr_t)overlayEntry->unk_20 + + (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); + + overlayEntry->unk_24 = + (void*)((overlayEntry->unk_24 != NULL) ? (void*)((uintptr_t)overlayEntry->unk_24 + + (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); + + free(overlayEntry->loadedRamAddr); + overlayEntry->loadedRamAddr = NULL; + } + } +} diff --git a/yamls/jp/code.yaml b/yamls/jp/code.yaml index 1c2e5ef..c4f22b9 100644 --- a/yamls/jp/code.yaml +++ b/yamls/jp/code.yaml @@ -8,7 +8,7 @@ subsegments: - [0x675720, c, code/c_keyframe] - [0x678660, asm, code/evw_anime] - - [0x6792F0, asm, code/6792F0] + - [0x6792F0, c, code/m_DLF] - [0x679550, c, code/m_all_grow] - [0x67A020, c, code/m_actor] - [0x67C6B0, c, code/m_actor_dlftbls] |
