diff --git a/soh/include/dr_libs b/soh/include/dr_libs new file mode 160000 index 000000000..9cb7092ac --- /dev/null +++ b/soh/include/dr_libs @@ -0,0 +1 @@ +Subproject commit 9cb7092ac8c75a82b5c6ea72652ca8d0091d7ffa diff --git a/soh/soh/Enhancements/accessible-actors/AccessibleActorList.cpp b/soh/soh/Enhancements/accessible-actors/AccessibleActorList.cpp index 8f09a52ed..d1912baa7 100644 --- a/soh/soh/Enhancements/accessible-actors/AccessibleActorList.cpp +++ b/soh/soh/Enhancements/accessible-actors/AccessibleActorList.cpp @@ -1,4 +1,6 @@ #include "ActorAccessibility.h" +#include "soh/OTRGlobals.h" + #include #include @@ -25,9 +27,9 @@ extern "C" { void EnKarebaba_DeadItemDrop(EnKarebaba*, PlayState*); } //Declarations specific to Torches -#include "overlays\actors\ovl_Obj_Syokudai\z_obj_syokudai.h" +#include "overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h" //Declarations specific to dogs -#include "overlays\actors\ovl_En_Dog\z_en_dog.h" +#include "overlays/actors/ovl_En_Dog/z_en_dog.h" extern "C" { void EnDog_FollowPlayer(EnDog*, PlayState*); s8 EnDog_CanFollow(EnDog*, PlayState*); @@ -303,7 +305,7 @@ void accessible_area_change(AccessibleActor* actor) { //kakariko village attenuation else if (actor->play->sceneNum == 82) { if (actor->sceneIndex == 83 || actor->sceneIndex == 81 || actor->sceneIndex == 96) { - actor->policy.runsAlways == true; + actor->policy.runsAlways = true; actor->policy.ydist = 5000; if (actor->xzDistToPlayer > 700) { if (actor->sceneIndex == 81) { @@ -650,9 +652,9 @@ void accessible_audio_compass_cleanup(AccessibleActor* actor) } void accessible_audio_compass(AccessibleActor* actor) { Player* player = GET_PLAYER(actor->play); - if (player->stateFlags1 & PLAYER_STATE1_TARGETING || player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) + if (player->stateFlags1 & PLAYER_STATE1_Z_TARGETING || player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) return; - OSContPad* trackerButtonsPressed = LUS::Context::GetInstance()->GetControlDeck()->GetPads(); + OSContPad* trackerButtonsPressed = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetControlDeck())->GetPads(); AudioCompassData* data = (AudioCompassData*)actor->userData; bool compassCombo = trackerButtonsPressed != nullptr && trackerButtonsPressed[0].button & buttonList[11] && trackerButtonsPressed[0].button & buttonList[6]; @@ -671,7 +673,7 @@ void accessible_audio_compass(AccessibleActor* actor) { /* Player* player = GET_PLAYER(actor->play); - if (player->stateFlags1 & PLAYER_STATE1_TARGETING || player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) + if (player->stateFlags1 & PLAYER_STATE1_Z_TARGETING || player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) return; actor->world.pos = player->actor.world.pos; diff --git a/soh/soh/Enhancements/accessible-actors/ActorAccessibility.cpp b/soh/soh/Enhancements/accessible-actors/ActorAccessibility.cpp index aaa414706..aca2cb37f 100644 --- a/soh/soh/Enhancements/accessible-actors/ActorAccessibility.cpp +++ b/soh/soh/Enhancements/accessible-actors/ActorAccessibility.cpp @@ -1,6 +1,7 @@ #include "ActorAccessibility.h" #include "AccessibleAudioEngine.h" #include "soh/OTRGlobals.h" +#include "resource/type/Blob.h" #include #include @@ -55,9 +56,8 @@ typedef std::unordered_set SceneList_t;//A list of scenes which have alread typedef struct { std::string path; - std::shared_ptr resource; + std::shared_ptr resource; std::shared_ptr decodedSample;//Set if the record is for a raw sample as opposed to a SFX. - }SfxRecord; class AudioGlossaryData { @@ -425,7 +425,7 @@ int ActorAccessibility_GetRandomStartingFrameCount(int min, int max) { return; if (actor->policy.aimAssist.isProvider) { if (player->stateFlags1 & PLAYER_STATE1_FIRST_PERSON && - (player->stateFlags1 & PLAYER_STATE1_BOOMERANG_IN_HAND || + (player->stateFlags1 & PLAYER_STATE1_USING_BOOMERANG || player->stateFlags1 & PLAYER_STATE1_ITEM_IN_HAND)) { ActorAccessibility_SetSoundPitch(actor, 9, actor->aimAssist.pitch); actor->aimAssist.framesSinceAimAssist++; @@ -527,7 +527,7 @@ int ActorAccessibility_GetRandomStartingFrameCount(int min, int max) { return; } - OSContPad* trackerButtonsPressed = LUS::Context::GetInstance()->GetControlDeck()->GetPads(); + OSContPad* trackerButtonsPressed = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetControlDeck())->GetPads(); bool comboStartGlossary = trackerButtonsPressed != nullptr && trackerButtonsPressed[0].button & buttons[10] && trackerButtonsPressed[0].button & buttons[6]; if (comboStartGlossary) { @@ -750,7 +750,7 @@ int ActorAccessibility_GetRandomStartingFrameCount(int min, int max) { { SfxRecord tempRecord; std::string fullPath = SfxExtractor::getExternalFileName(sfxId); - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadFile(fullPath); + auto res = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource(fullPath)); if(res == nullptr) return NULL;//Resource doesn't exist, user's gotta run the extractor. @@ -760,8 +760,8 @@ return NULL;//Resource doesn't exist, user's gotta run the extractor. tempRecord.path = ss.str(); aa->sfxMap[sfxId] = tempRecord; record = &aa->sfxMap[sfxId]; - aa->audioEngine->cacheDecodedSample(record->path, record->resource->Buffer.data(), - record->resource->Buffer.size()); + aa->audioEngine->cacheDecodedSample(record->path, record->resource->GetRawPointer(), + record->resource->GetPointerSize()); } else record = &it->second; @@ -780,11 +780,11 @@ return NULL;//Resource doesn't exist, user's gotta run the extractor. std::stringstream ss; ss << "audio/samples/" << key; std::string fullPath = ss.str(); - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(fullPath); + auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(fullPath); if (res == nullptr) return NULL; // Resource doesn't exist, user's gotta run the extractor. AudioDecoder decoder; - decoder.setSample((LUS::AudioSample*)res.get()); + decoder.setSample((SOH::AudioSample*)res.get()); s16* wav; size_t wavSize = decoder.decodeToWav(&wav); diff --git a/soh/soh/Enhancements/accessible-actors/SfxExtractor.cpp b/soh/soh/Enhancements/accessible-actors/SfxExtractor.cpp index d681b76aa..24d20f2dc 100644 --- a/soh/soh/Enhancements/accessible-actors/SfxExtractor.cpp +++ b/soh/soh/Enhancements/accessible-actors/SfxExtractor.cpp @@ -1,19 +1,16 @@ #include "SfxExtractor.h" -#include "dr_libs/wav.h" +#include "dr_libs/dr_wav.h" #include "soh/Enhancements/speechsynthesizer/SpeechSynthesizer.h" #include "soh/Enhancements/tts/tts.h" #include "miniaudio.h" -#include "z64.h" -#include "functions.h" #include "soh/OTRGlobals.h" #include "SfxTable.h" #include const char* GetLanguageCode(); extern "C" { -extern Vec3f D_801333D4; -extern f32 D_801333E0; -extern s8 D_801333E8; -extern u8 D_801333F0; +#include "z64.h" +#include "functions.h" +#include "variables.h" void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples); extern bool freezeGame; } @@ -57,8 +54,8 @@ void SfxExtractor::setEndOfInput() { endOfInput -= 2; } } -void SfxExtractor::renderOutput() { +void SfxExtractor::renderOutput() { ma_channel_converter_config config = ma_channel_converter_config_init(ma_format_s16, 2, NULL, 1, NULL, ma_channel_mix_mode_default); ma_channel_converter converter; @@ -88,10 +85,11 @@ void SfxExtractor::renderOutput() { mark += thisChunk; } drwav_uninit(&wav); - archive->AddFile(fileName.c_str(), (uintptr_t)mem, size); - + std::vector fileData((uint8_t*)mem, (uint8_t*)mem + size); drwav_free(mem, NULL); + archive->WriteFile(fileName.c_str(), fileData); } + void SfxExtractor::setup() { try { @@ -100,7 +98,7 @@ void SfxExtractor::setup() { captureThreadState = CT_WAITING; OTRAudio_InstallSfxCaptureThread(); // Make sure we're starting from a clean slate. - std::string sohAccessibilityPath = LUS::Context::GetPathRelativeToAppDirectory("accessibility.otr"); + std::string sohAccessibilityPath = Ship::Context::GetPathRelativeToAppDirectory("accessibility.otr"); if (std::filesystem::exists(sohAccessibilityPath)) { currentStep = STEP_ERROR_OTR; return; @@ -114,9 +112,10 @@ void SfxExtractor::setup() { sfxToRip.push(sfxTable[i]); currentStep = STEP_MAIN; - for (int i = 1; i < 10; i++) + for (int i = 1; i < 10; i++) { progressMilestones[i - 1] = sfxToRip.size() - ((int)ceil(sfxToRip.size() * (i / 10.0f))); - archive = LUS::Archive::CreateArchive("accessibility.otr", sfxToRip.size()); + } + archive = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->AddArchive("accessibility.otr"); } catch (...) { currentStep = STEP_ERROR; } } @@ -129,7 +128,7 @@ void SfxExtractor::ripNextSfx() { // Was the last sfx a loop? If so then we need to stop it, and then we need to run audio out to nowhere for as long // as it takes to get back to a blank slate. if (currentSfx != -1) { - Audio_StopSfxByPos(&D_801333D4); + Audio_StopSfxByPos(&gSfxDefaultPos); captureThreadState = CT_PRIMING; currentSfx = -1; @@ -144,7 +143,7 @@ void SfxExtractor::ripNextSfx() { sfxToRip.pop(); startOfInput = 0; endOfInput = 0; - Audio_PlaySoundGeneral(currentSfx, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + Audio_PlaySoundGeneral(currentSfx, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); { auto lock = OTRAudio_Lock(); @@ -162,8 +161,8 @@ void SfxExtractor::finished() { Audio_QueueSeqCmd(NA_BGM_TITLE); if (currentStep == STEP_ERROR || currentStep == STEP_ERROR_OTR) { - Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Audio_PlaySoundGeneral(NA_SE_EN_GANON_LAUGH, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + Audio_PlaySoundGeneral(NA_SE_EN_GANON_LAUGH, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); std::stringstream ss; ss << "Sorry, we tried to extract the sound effects, but Ganondorf overruled us with an iron fist." << std::endl; diff --git a/soh/soh/Enhancements/accessible-actors/SfxExtractor.h b/soh/soh/Enhancements/accessible-actors/SfxExtractor.h index 98087d37c..59795a6b5 100644 --- a/soh/soh/Enhancements/accessible-actors/SfxExtractor.h +++ b/soh/soh/Enhancements/accessible-actors/SfxExtractor.h @@ -1,7 +1,7 @@ #pragma once #include "libultraship/libultraship.h" class SfxExtractor { - std::shared_ptr archive; + std::shared_ptr archive; int currentStep; int captureThreadState; std::queue sfxToRip; diff --git a/soh/soh/Enhancements/accessible-actors/accessibility_cues.cpp b/soh/soh/Enhancements/accessible-actors/accessibility_cues.cpp index 85b500fbb..9b7382ef7 100644 --- a/soh/soh/Enhancements/accessible-actors/accessibility_cues.cpp +++ b/soh/soh/Enhancements/accessible-actors/accessibility_cues.cpp @@ -292,7 +292,7 @@ class Wall: protected TerrainCueSound { play(); ActorAccessibility_SeekSound(this, 0, 44100 * 2); } - f32 pitchModifier; + f32 pitchModifier = 0.0; if (targetPitch < 0) pitchModifier = LERP(2.5, 0.5 + targetPitch, (f32)frames / 20.0f); @@ -396,13 +396,12 @@ class Lava : protected TerrainCueSound { f32 probeSpeed; // Approximate for now. Vec3f velocity; Vec3f expectedVelocity; - int terrainDiscovered; + int terrainDiscovered = DISCOVERED_NOTHING; CollisionPoly* floorPoly; CollisionPoly* wallPoly; s32 wallBgId; f32 wallHeight; s32 floorBgId; - f32 yDistToWater; f32 pushedSpeed; bool disabled; // Only used for debugging. bool trackingMode; // A debugging feature which forces Link to move along the probe's path. Used to catch collision @@ -549,7 +548,7 @@ class Lava : protected TerrainCueSound { return wallHeight; } D_80854798.y = 18.0f; - D_80854798.z = player->ageProperties->unk_38 + 10.0f; + D_80854798.z = player->ageProperties->wallCheckRadius + 10.0f; f32 wallYaw = Math_Atan2S(poly->normal.z, poly->normal.x); f32 nx = COLPOLY_GET_NORMAL(poly->normal.x); f32 ny = COLPOLY_GET_NORMAL(poly->normal.y); @@ -583,7 +582,7 @@ class Lava : protected TerrainCueSound { // passing in the real player with a temporarily modified pos vector, I'm using this fake player instance // instead. These functions only need the player's position and shape rotation vectors set. if (Player_PosVsWallLineTest(actor->play, &fakePlayer, &D_80854798, &testPoly, &bgId, &collisionResult) && - abs(wallYaw - Math_Atan2S(testPoly->normal.z, testPoly->normal.x)) < 0x4000 && + std::abs(wallYaw - Math_Atan2S(testPoly->normal.z, testPoly->normal.x)) < 0x4000 && !func_80041E18(&actor->play->colCtx, testPoly, bgId)) { wallHeight = 399.96002f; } @@ -702,7 +701,7 @@ class Lava : protected TerrainCueSound { floorHeight = BgCheck_EntityRaycastFloor3(&actor->play->colCtx, &floorPoly, &floorBgId, &pos); if ((floorHeight - playerHeight) > 100.0) { destroyCurrentSound(); - pos.y - floorHeight; + pos.y -= floorHeight; // TODO remove? platform.setPosition(pos); platform.run(); return true; @@ -874,9 +873,9 @@ class Lava : protected TerrainCueSound { wallCheckHeight = 15.0f; ceilingCheckHeight = 30.0f; } else { - wallCheckRadius = player->ageProperties->unk_38; + wallCheckRadius = player->ageProperties->wallCheckRadius; wallCheckHeight = 26.0f; - ceilingCheckHeight = player->ageProperties->unk_00; + ceilingCheckHeight = player->ageProperties->ceilingCheckHeight; } // The virtual cue actors travel in lines relative to Link's angle. rot = ActorAccessibility_ComputeRelativeAngle(&player->actor.world.rot, &relRot); diff --git a/soh/soh/Enhancements/audio/AudioDecoder.cpp b/soh/soh/Enhancements/audio/AudioDecoder.cpp index fe7a22da0..710d2ebe8 100644 --- a/soh/soh/Enhancements/audio/AudioDecoder.cpp +++ b/soh/soh/Enhancements/audio/AudioDecoder.cpp @@ -1,70 +1,68 @@ #include "AudioDecoder.h" #include "z64audio.h" -#include "dr_libs/wav.h" +#define DR_WAV_IMPLEMENTATION +#include "dr_libs/dr_wav.h" #include #define WAV_DECODE_CHUNK_SIZE 64 -//A handful of definitions need to be copied from mixer.c. +// A handful of definitions need to be copied from mixer.c. #define ROUND_UP_32(v) (((v) + 31) & ~31) -//The below is copied verbatim from mixer.c. +// The below is copied verbatim from mixer.c. static inline int16_t clamp16(int32_t v) { if (v < -0x8000) { return -0x8000; } else if (v > 0x7fff) { return 0x7fff; + } else { + return v; } } - AudioDecoder::AudioDecoder() { - prev1 = 0; - prev2 = 0; - - } -AudioDecoder::~AudioDecoder() -{ - +AudioDecoder::AudioDecoder() { + prev1 = 0; + prev2 = 0; } -void AudioDecoder::setSample(LUS::AudioSample* sample) -{ - this->sample.codec = sample->sample.codec; - this->sample.loop.start = sample->sample.loop->start; - this->sample.loop.end = sample->sample.loop->end; - this->sample.loop.count = sample->sample.loop->count; +AudioDecoder::~AudioDecoder() { +} +void AudioDecoder::setSample(SOH::AudioSample* sample) { + this->sample.codec = sample->sample.codec; + this->sample.loop.start = sample->sample.loop->start; + this->sample.loop.end = sample->sample.loop->end; + this->sample.loop.count = sample->sample.loop->count; - if (sample->book.book == nullptr) + if (sample->book.book == nullptr) memset(adpcm_table, 0, 8 * 2 * 8 * 2); - else + else memcpy(adpcm_table, sample->sample.book->book, -16 * sample->sample.book->order * sample->sample.book->npredictors); - prev1 = 0; - prev2 = 0; - in = sample->sample.sampleAddr; - inStart = in; - inEnd = in + sample->sample.size; + 16 * sample->sample.book->order * sample->sample.book->npredictors); + prev1 = 0; + prev2 = 0; + in = sample->sample.sampleAddr; + inStart = in; + inEnd = in + sample->sample.size; } void AudioDecoder::setSample(SoundFontSample* sample) { - this->sample.codec = sample->codec; - this->sample.loop.start = sample->loop->start; - this->sample.loop.end = sample->loop->end; - this->sample.loop.count = sample->loop->count; + this->sample.codec = sample->codec; + this->sample.loop.start = sample->loop->start; + this->sample.loop.end = sample->loop->end; + this->sample.loop.count = sample->loop->count; - if (sample->book->book == nullptr) + if (sample->book->book == nullptr) memset(adpcm_table, 0, 8 * 2 * 8 * 2); - else - memcpy(adpcm_table, sample->book->book, - 16 * sample->book->order * sample->book->npredictors); - prev1 = 0; - prev2 = 0; - in = sample->sampleAddr; - inStart = in; - inEnd = in + sample->size; + else + memcpy(adpcm_table, sample->book->book, 16 * sample->book->order * sample->book->npredictors); + prev1 = 0; + prev2 = 0; + in = sample->sampleAddr; + inStart = in; + inEnd = in + sample->size; } - size_t AudioDecoder::decode(int16_t * out, size_t nSamples) { - size_t samplesOut = 0; - size_t nbytes = nSamples * 2; - // Prevent the decoder from using more output bytes than declared to be available by the callee. - nbytes -= 31; - nbytes = ROUND_UP_32(nbytes); - while (nbytes > 0 && in < inEnd) { +size_t AudioDecoder::decode(int16_t* out, size_t nSamples) { + size_t samplesOut = 0; + size_t nbytes = nSamples * 2; + // Prevent the decoder from using more output bytes than declared to be available by the callee. + nbytes -= 31; + nbytes = ROUND_UP_32(nbytes); + while (nbytes > 0 && in < inEnd) { int shift = *in >> 4; // should be in 0..12 or 0..14 int table_index = *in++ & 0xf; // should be in 0..7 int16_t(*tbl)[8] = adpcm_table[table_index]; @@ -94,45 +92,43 @@ void AudioDecoder::setSample(SoundFontSample* sample) { acc >>= 11; *out++ = clamp16(acc); samplesOut++; - } prev1 = out[-1]; prev2 = out[-2]; } nbytes -= 16 * sizeof(int16_t); - } - return samplesOut; - + } + return samplesOut; } -size_t AudioDecoder::decodeToWav (int16_t** buffer) -{ - int16_t* wavOut = nullptr; +size_t AudioDecoder::decodeToWav(int16_t** buffer) { + int16_t* wavOut = nullptr; - drwav_data_format format; - format.bitsPerSample = 16; - format.channels = 1; - format.container = drwav_container_riff; - format.format = DR_WAVE_FORMAT_PCM; -//Todo: figure out how to really determine the sample rate. CODEC_ADPCM tends to stream at higher rates (usually 20KHZ) while CODEC_SMALL_ADPCM is usually around 14000. They're still not consistent though. - if (sample.codec == CODEC_ADPCM) + drwav_data_format format; + format.bitsPerSample = 16; + format.channels = 1; + format.container = drwav_container_riff; + format.format = DR_WAVE_FORMAT_PCM; + // Todo: figure out how to really determine the sample rate. CODEC_ADPCM tends to stream at higher rates (usually + // 20KHZ) while CODEC_SMALL_ADPCM is usually around 14000. They're still not consistent though. + if (sample.codec == CODEC_ADPCM) format.sampleRate = 20000; - else if (sample.codec = CODEC_SMALL_ADPCM) + else if (sample.codec = CODEC_SMALL_ADPCM) format.sampleRate = 14000; - else + else throw std::runtime_error("AudioDecoder: Unsupported codec."); - drwav wav; - size_t wavSize; - if (!drwav_init_memory_write(&wav, (void**) &wavOut, &wavSize, &format, nullptr)) + drwav wav; + size_t wavSize; + if (!drwav_init_memory_write(&wav, (void**)&wavOut, &wavSize, &format, nullptr)) throw std::runtime_error("AudioDecoder: Unable to initialize wave writer."); - int16_t chunk[WAV_DECODE_CHUNK_SIZE]; - //Don't decode past the end of the loop. - size_t samplesLeft = sample.loop.end; - //Unless the loop is 0? - if (samplesLeft == 0) + int16_t chunk[WAV_DECODE_CHUNK_SIZE]; + // Don't decode past the end of the loop. + size_t samplesLeft = sample.loop.end; + // Unless the loop is 0? + if (samplesLeft == 0) samplesLeft = sample.loop.count; - while (samplesLeft > 0) { + while (samplesLeft > 0) { size_t samplesRead = decode(chunk, WAV_DECODE_CHUNK_SIZE); if (samplesRead > samplesLeft) samplesRead = samplesLeft; @@ -145,10 +141,8 @@ size_t AudioDecoder::decodeToWav (int16_t** buffer) throw std::runtime_error("AudioDecoder: Unable to write wave data."); } samplesLeft -= samplesRead; - - } - drwav_uninit(&wav); - *buffer = wavOut; + } + drwav_uninit(&wav); + *buffer = wavOut; return wavSize; - } diff --git a/soh/soh/Enhancements/audio/AudioDecoder.h b/soh/soh/Enhancements/audio/AudioDecoder.h index 89264ef8a..fb2c021f2 100644 --- a/soh/soh/Enhancements/audio/AudioDecoder.h +++ b/soh/soh/Enhancements/audio/AudioDecoder.h @@ -1,31 +1,30 @@ #pragma once -//A standalone, incremental audio sample decoder. -//Based on the ADPCM decoding routines in mixer.c. +// A standalone, incremental audio sample decoder. +// Based on the ADPCM decoding routines in mixer.c. #include "libultraship/libultraship.h" #include "soh/resource/type/AudioSample.h" #include "z64audio.h" -class AudioDecoder -{ +class AudioDecoder { struct { int codec; - struct - { + struct { int start; int end; int count; - }loop; + } loop; } sample; uint8_t *in, *inStart, *inEnd; int16_t adpcm_table[8][2][8]; - int16_t prev1, prev2;//The internal decoder takes an array of 16 shorts which it calls ADPCM_STATE. Strictly speaking only the last two decoded samples are needed for continuation. + int16_t prev1, prev2; // The internal decoder takes an array of 16 shorts which it calls ADPCM_STATE. Strictly + // speaking only the last two decoded samples are needed for continuation. public: AudioDecoder(); ~AudioDecoder(); - //Support both LUS samples and Z64 samples. - void setSample(LUS::AudioSample* sample); + // Support both SOH samples and Z64 samples. + void setSample(SOH::AudioSample* sample); void setSample(SoundFontSample* sample); size_t decode(int16_t* out, size_t nSamples); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index 130e917cc..0d96da967 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -288,12 +288,10 @@ void GameInteractor_ExecuteOnSetGameLanguage() { GameInteractor::Instance->ExecuteHooks(); } -void GameInteractor_ExecuteOnGameStillFrozen() -{ +void GameInteractor_ExecuteOnGameStillFrozen() { GameInteractor::Instance->ExecuteHooks(); } - // MARK: - System void GameInteractor_RegisterOnAssetAltChange(void (*fn)(void)) { diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index 4f48492e0..22a372c89 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -77,7 +77,6 @@ void GameInteractor_ExecuteOnSetGameLanguage(); void GameInteractor_ExecuteOnGameStillFrozen(); - // MARK: - System void GameInteractor_RegisterOnAssetAltChange(void (*fn)(void)); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 94330e412..ac4a963b0 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -127,11 +127,17 @@ Sail* Sail::Instance; #include "soh/resource/importer/BackgroundFactory.h" #include "soh/config/ConfigUpdaters.h" +#include "soh/ShipInit.hpp" #if !defined(__SWITCH__) && !defined(__WIIU__) #include "Enhancements/accessible-actors/ActorAccessibility.h" #endif +extern "C" { +#include "src/overlays/actors/ovl_En_Dns/z_en_dns.h" +} + void SoH_ProcessDroppedFiles(std::string filePath); + OTRGlobals* OTRGlobals::Instance; SaveManager* SaveManager::Instance; CustomMessageManager* CustomMessageManager::Instance; @@ -288,7 +294,7 @@ OTRGlobals::OTRGlobals() { } } - std::string sohAccessibilityPath = LUS::Context::GetPathRelativeToAppDirectory("accessibility.otr"); + std::string sohAccessibilityPath = Ship::Context::GetPathRelativeToAppDirectory("accessibility.otr"); if (std::filesystem::exists(sohAccessibilityPath)) { OTRFiles.push_back(sohAccessibilityPath); } diff --git a/soh/soh/SohGui/SohMenuSettings.cpp b/soh/soh/SohGui/SohMenuSettings.cpp index 5de660102..ba4c5a32a 100644 --- a/soh/soh/SohGui/SohMenuSettings.cpp +++ b/soh/soh/SohGui/SohMenuSettings.cpp @@ -196,12 +196,12 @@ void SohMenu::AddMenuSettings() { .RaceDisable(false) .Options(CheckboxOptions().Tooltip("Disables the automatic re-centering of the camera when idle.")); - AddWidget(path "Accessible Audio Cues", WIDGET_CVAR_CHECKBOX) + AddWidget(path, "Accessible Audio Cues", WIDGET_CVAR_CHECKBOX) .CVar("gA11yAudioInteraction") .RaceDisable(false) .Options(CheckboxOptions().Tooltip("Enables accessibility audio cues")); - AddWidget(path "Extract Sfx", WIDGET_CVAR_CHECKBOX) + AddWidget(path, "Extract Sfx", WIDGET_CVAR_CHECKBOX) .CVar("gExtractSfx") .RaceDisable(false) .Options(CheckboxOptions().Tooltip("Extracts the sfx to be used in accessible audio cues, must be run once for the audio cues to play then restart game")); diff --git a/soh/src/code/code_800F9280.c b/soh/src/code/code_800F9280.c index c90450d50..dc15d4b1f 100644 --- a/soh/src/code/code_800F9280.c +++ b/soh/src/code/code_800F9280.c @@ -374,8 +374,8 @@ extern f32 D_80130F28; void Audio_QueueSeqCmd(u32 cmd) { if (freezeGame) - return;//No music during SFX rip. - // + return; // No music during SFX rip. + // u8 op = cmd >> 28; if (op == 0 || op == 2 || op == 12) { u8 seqId = cmd & 0xFF; diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 5a24c1f75..859c6634c 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -80,7 +80,7 @@ #include "textures/place_title_cards/g_pn_56.h" #include "textures/place_title_cards/g_pn_57.h" #endif -bool freezeActors= false; +bool freezeActors = false; static CollisionPoly* sCurCeilingPoly; static s32 sCurCeilingBgId; @@ -2559,8 +2559,6 @@ u32 D_80116068[ACTORCAT_MAX] = { void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { - - Actor* refActor; Actor* actor; Player* player; diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index c8d72f533..aa1580d9e 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -21,7 +21,7 @@ #include #include -bool freezeGame = false;//Used for SFX ripper. +bool freezeGame = false; // Used for SFX ripper. TransitionUnk sTrnsnUnk; s32 gTrnsnUnkState; VisMono gPlayVisMono;