From feea29929125d9496c7a17037250532a8d3e3bfd Mon Sep 17 00:00:00 2001 From: Malkierian Date: Thu, 27 Mar 2025 20:27:01 -0700 Subject: [PATCH 1/3] Revert "Set Sample Rate to 32000 hz (#4780)" (#5234) This reverts commit 9455579f4272953ecace1d812e1f43f3e0761193. --- soh/soh/OTRGlobals.cpp | 13 +++++++++--- soh/src/code/audio_init_params.c | 34 ++++++++++++++++---------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 6eb0e667b..4e5f3be8a 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -355,7 +355,7 @@ OTRGlobals::OTRGlobals() { overlay->LoadFont("Fipps", 32.0f, "fonts/Fipps-Regular.otf"); overlay->SetCurrentFont(CVarGetString(CVAR_GAME_OVERLAY_FONT, "Press Start 2P")); - context->InitAudio({ .SampleRate = 32000, .SampleLength = 1024, .DesiredBuffered = 1680 }); + context->InitAudio({ .SampleRate = 44100, .SampleLength = 1024, .DesiredBuffered = 2480 }); SPDLOG_INFO("Starting Ship of Harkinian version {} (Branch: {} | Commit: {})", (char*)gBuildVersion, (char*)gGitBranch, (char*)gGitCommitHash); @@ -531,8 +531,15 @@ void OTRAudio_Thread() { //AudioMgr_ThreadEntry(&gAudioMgr); // 528 and 544 relate to 60 fps at 32 kHz 32000/60 = 533.333.. // in an ideal world, one third of the calls should use num_samples=544 and two thirds num_samples=528 - #define SAMPLES_HIGH 560 - #define SAMPLES_LOW 528 + //#define SAMPLES_HIGH 560 + //#define SAMPLES_LOW 528 + // PAL values + //#define SAMPLES_HIGH 656 + //#define SAMPLES_LOW 624 + + // 44KHZ values + #define SAMPLES_HIGH 752 + #define SAMPLES_LOW 720 #define AUDIO_FRAMES_PER_UPDATE (R_UPDATE_RATE > 0 ? R_UPDATE_RATE : 1 ) #define NUM_AUDIO_CHANNELS 2 diff --git a/soh/src/code/audio_init_params.c b/soh/src/code/audio_init_params.c index 02593f8e4..12653c6dc 100644 --- a/soh/src/code/audio_init_params.c +++ b/soh/src/code/audio_init_params.c @@ -68,22 +68,22 @@ ReverbSettings D_80133420[][3] = { }; AudioSpec gAudioSpecs[18] = { - { 32000, 1, 24, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 24, 4, 0, 0, 2, D_80133420[1], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 23, 4, 0, 0, 2, D_80133420[4], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 23, 4, 0, 0, 2, D_80133420[5], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 24, 4, 0, 0, 2, D_80133420[6], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 24, 4, 0, 0, 2, D_80133420[7], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 24, 4, 0, 0, 2, D_80133420[9], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 28, 3, 0, 0, 2, D_80133420[10], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0x4800, 0, 0x5000, 0, 0, 0, 0 }, - { 32000, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0, 0, 0x5000, 0x4800, 0, 0, 0 }, - { 32000, 1, 22, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 22, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 16, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 24, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 24, 4, 0, 0, 2, D_80133420[1], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 23, 4, 0, 0, 2, D_80133420[4], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 23, 4, 0, 0, 2, D_80133420[5], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 24, 4, 0, 0, 2, D_80133420[6], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 24, 4, 0, 0, 2, D_80133420[7], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 24, 4, 0, 0, 2, D_80133420[9], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 23, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 28, 3, 0, 0, 2, D_80133420[10], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0x4800, 0, 0x5000, 0, 0, 0, 0 }, + { 44100, 1, 28, 3, 0, 0, 1, D_80133420[11], 0x300, 0x200, 0x7FFF, 0, 0, 0, 0x5000, 0x4800, 0, 0, 0 }, + { 44100, 1, 22, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 22, 4, 0, 0, 2, D_80133420[8], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, + { 44100, 1, 16, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, { 22050, 1, 24, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2880, 0, 0, 0 }, - { 32000, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2600, 0, 0, 0 }, + { 44100, 1, 24, 4, 0, 0, 2, D_80133420[2], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x5000, 0x2600, 0, 0, 0 }, }; From 32923d83f21e06437123a2d18a4b587bc7486a86 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 27 Mar 2025 23:31:04 -0400 Subject: [PATCH 2/3] Don't place items on Chest game. (#5233) This causes it to fall back on vanilla behavior, fixing the crash Where it tried to draw something invalid. --- .../Enhancements/randomizer/3drando/item_pool.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp index aca9c49d3..9b1fd2bf0 100644 --- a/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/item_pool.cpp @@ -826,18 +826,7 @@ void GenerateItemPool() { AddItemToMainPool(RG_TREASURE_GAME_SMALL_KEY, 6); // 6 individual keys } else if (ctx->GetOption(RSK_SHUFFLE_CHEST_MINIGAME).Is(RO_CHEST_GAME_PACK)) { AddItemToMainPool(RG_TREASURE_GAME_SMALL_KEY); // 1 key which will behave as a pack of 6 - } else { - ctx->PlaceItemInLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_1, RG_GREEN_RUPEE, false, true); - ctx->PlaceItemInLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_2, RG_GREEN_RUPEE, false, true); - ctx->PlaceItemInLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_3, RG_BLUE_RUPEE, false, true); - ctx->PlaceItemInLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_4, RG_BLUE_RUPEE, false, true); - ctx->PlaceItemInLocation(RC_MARKET_TREASURE_CHEST_GAME_ITEM_5, RG_RED_RUPEE, false, true); - ctx->PlaceItemInLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_1, RG_TREASURE_GAME_SMALL_KEY, false, true); - ctx->PlaceItemInLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_2, RG_TREASURE_GAME_SMALL_KEY, false, true); - ctx->PlaceItemInLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_3, RG_TREASURE_GAME_SMALL_KEY, false, true); - ctx->PlaceItemInLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_4, RG_TREASURE_GAME_SMALL_KEY, false, true); - ctx->PlaceItemInLocation(RC_MARKET_TREASURE_CHEST_GAME_KEY_5, RG_TREASURE_GAME_SMALL_KEY, false, true); - }; + } if (ctx->GetOption(RSK_SHUFFLE_TOKENS).Is(RO_TOKENSANITY_OFF)) { for (RandomizerCheck loc : ctx->GetLocations(ctx->allLocations, RCTYPE_SKULL_TOKEN)) { From b66623c152d24df78fb5ea699e5206a20eafe037 Mon Sep 17 00:00:00 2001 From: Archez Date: Fri, 28 Mar 2025 04:30:56 -0400 Subject: [PATCH 3/3] Fix freezard graphics crash with enemy health scaling (#5232) --- soh/src/overlays/actors/ovl_En_Fz/z_en_fz.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.c index 8aaab1631..3f843446d 100644 --- a/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -720,6 +720,15 @@ void EnFz_Draw(Actor* thisx, PlayState* play) { index = (6 - this->actor.colChkInfo.health) >> 1; + // SOH [Enhancement] - With enemy health scaling, the Freezards health could cause an index out of bounds for the + // displayLists, so we need to recompute the index based on the scaled health (using the maximum health value) and + // clamp the final result for safety. + if (CVarGetInteger(CVAR_ENHANCEMENT("EnemySizeScalesHealth"), 0)) { + u8 scaledHealth = (u8)(((f32)this->actor.colChkInfo.health / this->actor.maximumHealth) * 6); + index = (6 - scaledHealth) >> 1; + index = CLAMP(index, 0, 2); + } + OPEN_DISPS(play->state.gfxCtx); if (this->actor.colChkInfo.health == 0) {