From 394939347c152b7a682bc7b8481b0fb80a932e90 Mon Sep 17 00:00:00 2001 From: Kevin Alexis Contreras <36680385+KiritoDv@users.noreply.github.com> Date: Mon, 13 Jun 2022 10:05:42 -0500 Subject: [PATCH] Code cleanup and fixes on 64bits --- soh/include/z64.h | 15 ++++++++++----- soh/include/z64camera.h | 2 +- soh/soh/OTRGlobals.cpp | 2 +- soh/src/code/audio_init_params.c | 4 ++++ soh/src/code/audio_load.c | 3 +-- soh/src/code/z_bgcheck.c | 8 ++++++-- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/soh/include/z64.h b/soh/include/z64.h index 05a32a1f9..901c7a70f 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -30,8 +30,13 @@ #include "ichain.h" #include "regs.h" -//#define AUDIO_HEAP_SIZE 0x38000 -#define AUDIO_HEAP_SIZE 0x3800000 // The original audio heap size was too small. The heap would exceed capacity and corrupt everything in its path. +#if defined(_WIN64) || defined(__x86_64__) +#define _SOH64 +#define AUDIO_HEAP_SIZE 0x70000 +#else +#define AUDIO_HEAP_SIZE 0x38000 +#endif + #define SYSTEM_HEAP_SIZE (1024 * 1024 * 4) #ifdef __cplusplus @@ -537,9 +542,9 @@ typedef enum { /* 4 */ TEXT_STATE_CHOICE, /* 5 */ TEXT_STATE_EVENT, /* 6 */ TEXT_STATE_DONE, - /* 7 */ TEXT_STATE_SONG_DEMO_DONE, - /* 8 */ TEXT_STATE_8, - /* 9 */ TEXT_STATE_9, + /* 7 */ TEXT_STATE_SONG_DEMO_DONE, + /* 8 */ TEXT_STATE_8, + /* 9 */ TEXT_STATE_9, /* 10 */ TEXT_STATE_AWAITING_NEXT } TextState; diff --git a/soh/include/z64camera.h b/soh/include/z64camera.h index 51f8a45b1..a25129bc7 100644 --- a/soh/include/z64camera.h +++ b/soh/include/z64camera.h @@ -1157,7 +1157,7 @@ typedef struct { } CamColChk; // size = 0x28 typedef struct { - /* 0x000 */ char paramData[0xFF]; + /* 0x000 */ char paramData[0x14 * sizeof(void*)]; /* 0x050 */ Vec3f at; /* 0x05C */ Vec3f eye; /* 0x068 */ Vec3f up; diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index c96c0df62..b244c5086 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -579,7 +579,7 @@ extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(int romOffset) if (strem2[0] == 'R' && strem2[1] == 'I' && strem2[2] == 'F' && strem2[3] == 'F') { - SoundFontSample* sampleC = (SoundFontSample*)malloc(sizeof(SoundFontSample)); + SoundFontSample* sampleC = new SoundFontSample; *strem++; // RIFF *strem++; // size diff --git a/soh/src/code/audio_init_params.c b/soh/src/code/audio_init_params.c index 6b8bc18fe..fa8f17a07 100644 --- a/soh/src/code/audio_init_params.c +++ b/soh/src/code/audio_init_params.c @@ -10,7 +10,11 @@ const s16 D_8014A6C0[] = { 0x0030, // gTatumsPerBeat }; +#ifdef _SOH64 const AudioContextInitSizes D_8014A6C4 = { 0x57F00, 0x2E0E0, 0xFCE0 }; +#else +const AudioContextInitSizes D_8014A6C4 = { 0x37F00, 0xE0E0, 0xBCE0 }; +#endif ReverbSettings D_80133420[][3] = { { diff --git a/soh/src/code/audio_load.c b/soh/src/code/audio_load.c index 587eb4194..b0e538334 100644 --- a/soh/src/code/audio_load.c +++ b/soh/src/code/audio_load.c @@ -718,8 +718,7 @@ uintptr_t AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) { if (ret != NULL) { *didAllocate = false; status = 2; - } else - { + } else { char* seqData = 0; SoundFont* fnt; diff --git a/soh/src/code/z_bgcheck.c b/soh/src/code/z_bgcheck.c index 7c8d86dfa..0fca4a29d 100644 --- a/soh/src/code/z_bgcheck.c +++ b/soh/src/code/z_bgcheck.c @@ -1516,7 +1516,11 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis if (globalCtx->sceneNum == SCENE_MALON_STABLE) { // "/* BGCheck LonLon Size %dbyte */\n" osSyncPrintf("/* BGCheck LonLonサイズ %dbyte */\n", 0x3520); - colCtx->memSize = 0x3520 * (sizeof(void*) / 4); // 64-bit build needs more memory + #ifdef _SOH64 + colCtx->memSize = 0x3520 * (sizeof(void*) / 4); + #else + colCtx->memSize = 0x3520; + #endif } else { // "/* BGCheck Mini Size %dbyte */\n" osSyncPrintf("/* BGCheck ミニサイズ %dbyte */\n", 0x4E20); @@ -3787,7 +3791,7 @@ void CollisionHeader_SegmentedToVirtual(CollisionHeader* colHeader) { /** * Convert CollisionHeader Segmented to Virtual addressing */ -void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest) +void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest) { if (ResourceMgr_OTRSigCheck(colHeader)) colHeader = ResourceMgr_LoadColByName(colHeader);