Merge branch 'zapd_audio_support' into zelda64

This commit is contained in:
Kevin Alexis Contreras 2022-06-01 15:11:11 -05:00
commit 0320107fc0
54 changed files with 3629 additions and 1850 deletions

View file

@ -0,0 +1,5 @@
<Root>
<File Name="code" OutName="audio" RangeStart="0x0" RangeEnd="0x12CBB0">
<Audio Name="audio" Offset="0x00"/>
</File>
</Root>

View file

@ -0,0 +1,5 @@
<Root>
<File Name="code" OutName="audio" RangeStart="0x0" RangeEnd="0x12CBB0">
<Audio Name="audio" Offset="0x00"/>
</File>
</Root>

View file

@ -30,7 +30,8 @@
#include "ichain.h"
#include "regs.h"
#define AUDIO_HEAP_SIZE 0x38000
//#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.
#define SYSTEM_HEAP_SIZE (1024 * 1024 * 4)
#ifdef __cplusplus

View file

@ -120,7 +120,8 @@ typedef struct {
/* 0x08 */ s16 book[1]; // size 8 * order * npredictors. 8-byte aligned
} AdpcmBook; // size >= 0x8
typedef struct {
typedef struct
{
union {
struct {
/* 0x00 */ u32 codec : 4;

View file

@ -100,7 +100,7 @@
<PreprocessorDefinitions>NOINCLUDE_GAME_PRINTF;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;ENABLE_OPENGL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<BasicRuntimeChecks>StackFrameRuntimeCheck</BasicRuntimeChecks>
</ClCompile>

File diff suppressed because it is too large Load diff

View file

@ -36,6 +36,7 @@
#include <Utils/StringHelper.h>
#include <SDL2/SDL_scancode.h>
#include <Audio.h>
OTRGlobals* OTRGlobals::Instance;
@ -57,8 +58,15 @@ extern "C" void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples);
extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len);
extern "C" int AudioPlayer_Buffered(void);
extern "C" int AudioPlayer_GetDesiredBuffered(void);
extern "C" void ResourceMgr_CacheDirectory(const char* resName);
// C->C++ Bridge
extern "C" void OTRAudio_Init()
{
// Precache all our samples, sequences, etc...
ResourceMgr_CacheDirectory("audio");
}
extern "C" void InitOTR() {
OTRGlobals::Instance = new OTRGlobals();
auto t = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("version");
@ -72,6 +80,7 @@ extern "C" void InitOTR() {
clearMtx = (uintptr_t)&gMtxClear;
OTRMessage_Init();
OTRAudio_Init();
DebugConsole_Init();
Debug_Init();
}
@ -175,7 +184,7 @@ extern "C" void Graph_StartFrame() {
// C->C++ Bridge
extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
if (!audio.initialized && 0) {
if (!audio.initialized) {
audio.initialized = true;
std::thread([]() {
for (;;) {
@ -263,7 +272,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
last_fps = fps;
last_update_rate = R_UPDATE_RATE;
if (0) {
{
std::unique_lock<std::mutex> Lock(audio.mutex);
while (audio.processing) {
audio.cv_from_thread.wait(Lock);
@ -530,12 +539,235 @@ extern "C" CollisionHeader* ResourceMgr_LoadColByName(const char* path)
return (CollisionHeader*)colHeader;
}
extern "C" Vtx * ResourceMgr_LoadVtxByName(const char* path)
extern "C" Vtx* ResourceMgr_LoadVtxByName(const char* path)
{
auto res = std::static_pointer_cast<Ship::Array>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path));
return (Vtx*)res->vertices.data();
}
extern "C" char* ResourceMgr_LoadSeqByID(int seqID)
{
std::string fmtStr = "audio/sequences/seq_%02X";
return OTRGlobals::Instance->context->GetResourceManager()->LoadFile(StringHelper::Sprintf(fmtStr.c_str(), seqID)).get()->buffer.get();
}
extern "C" int ResourceMgr_GetSeqSizeByID(int seqID)
{
return OTRGlobals::Instance->context->GetResourceManager()
->LoadFile(StringHelper::Sprintf("audio/sequences/seq_%02X", seqID))
.get()
->dwBufferSize;
}
std::map<std::string, SoundFontSample*> cachedCustomSFs;
extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(int romOffset)
{
auto str = StringHelper::Sprintf("audio/samples/sample_%08X", romOffset);
if (cachedCustomSFs.find(str) != cachedCustomSFs.end())
return cachedCustomSFs[str];
// Check if our file is actually a wav...
auto sampleRaw = OTRGlobals::Instance->context->GetResourceManager()->LoadFile(str);
uint32_t* strem = (uint32_t*)sampleRaw->buffer.get();
uint8_t* strem2 = (uint8_t*)strem;
if (strem2[0] == 'R' && strem2[1] == 'I' && strem2[2] == 'F' && strem2[3] == 'F')
{
SoundFontSample* sampleC = (SoundFontSample*)malloc(sizeof(SoundFontSample));
*strem++; // RIFF
*strem++; // size
*strem++; // WAVE
*strem++; // fmt
int fmtChunkSize = *strem++;
// OTRTODO: Make sure wav format is what the audio driver wants!
strem = (uint32_t*)&strem2[0x0C + fmtChunkSize + 8 + 4];
sampleC->size = *strem++;
sampleC->sampleAddr = (uint8_t*)strem;
sampleC->codec = CODEC_S16;
// OTRTODO: Grab loop data from wav
sampleC->loop = (AdpcmLoop*)malloc(sizeof(AdpcmLoop));
sampleC->loop->start = 0;
sampleC->loop->end = sampleC->size / 2;
sampleC->loop->count = 0;
cachedCustomSFs[str] = sampleC;
return sampleC;
}
auto sample = std::static_pointer_cast<Ship::AudioSample>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(str));
if (sample == nullptr)
return NULL;
if (sample->cachedGameAsset != nullptr)
{
SoundFontSample* sampleC = (SoundFontSample*)sample->cachedGameAsset;
return (SoundFontSample*)sample->cachedGameAsset;
}
else
{
SoundFontSample* sampleC = (SoundFontSample*)malloc(sizeof(SoundFontSample));
sampleC->sampleAddr = sample->data.data();
sampleC->size = sample->data.size();
sampleC->codec = sample->codec;
sampleC->medium = sample->medium;
sampleC->unk_bit26 = sample->unk_bit26;
sampleC->unk_bit25 = sample->unk_bit25;
sampleC->book = (AdpcmBook*)malloc(sizeof(AdpcmBook) + (sample->book.books.size() * sizeof(int16_t)));
sampleC->book->npredictors = sample->book.npredictors;
sampleC->book->order = sample->book.order;
for (int i = 0; i < sample->book.books.size(); i++)
sampleC->book->book[i] = sample->book.books[i];
sampleC->loop = (AdpcmLoop*)malloc(sizeof(AdpcmLoop));
sampleC->loop->start = sample->loop.start;
sampleC->loop->end = sample->loop.end;
sampleC->loop->count = sample->loop.count;
for (int i = 0; i < sample->loop.states.size(); i++)
sampleC->loop->state[i] = sample->loop.states[i];
sample->cachedGameAsset = sampleC;
return sampleC;
}
}
extern "C" SoundFont* ResourceMgr_LoadAudioSoundFont(int fontIndex) {
auto soundFont =
std::static_pointer_cast<Ship::AudioSoundFont>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(
StringHelper::Sprintf("audio/fonts/font_%02X", fontIndex)));
if (soundFont == nullptr)
return NULL;
if (soundFont->cachedGameAsset != nullptr)
{
return (SoundFont*)soundFont->cachedGameAsset;
}
else
{
SoundFont* soundFontC = (SoundFont*)malloc(sizeof(SoundFont));
soundFontC->numDrums = soundFont->drums.size();
soundFontC->numInstruments = soundFont->instruments.size();
soundFontC->numSfx = soundFont->soundEffects.size();
soundFontC->sampleBankId1 = soundFont->data1 >> 8;
soundFontC->sampleBankId2 = soundFont->data1 & 0xFF;
soundFontC->drums = (Drum**)malloc(sizeof(Drum*) * soundFont->drums.size());
for (int i = 0; i < soundFont->drums.size(); i++)
{
Drum* drum = (Drum*)malloc(sizeof(Drum));
drum->releaseRate = soundFont->drums[i].releaseRate;
drum->pan = soundFont->drums[i].pan;
drum->loaded = 0;
if (soundFont->drums[i].env.size() == 0)
drum->envelope = NULL;
else
{
drum->envelope = (AdsrEnvelope*)malloc(sizeof(AdsrEnvelope) * soundFont->drums[i].env.size());
for (int k = 0; k < soundFont->drums[i].env.size(); k++)
{
drum->envelope[k].delay = BOMSWAP16(soundFont->drums[i].env[k]->delay);
drum->envelope[k].arg = BOMSWAP16(soundFont->drums[i].env[k]->arg);
}
}
drum->sound.sample = ResourceMgr_LoadAudioSample(soundFont->drums[i].offset);
drum->sound.tuning = soundFont->drums[i].tuning;
soundFontC->drums[i] = drum;
}
soundFontC->instruments = (Instrument**)malloc(sizeof(Instrument*) * soundFont->instruments.size());
for (int i = 0; i < soundFont->instruments.size(); i++) {
if (soundFont->instruments[i].isValidEntry)
{
Instrument* inst = (Instrument*)malloc(sizeof(Instrument));
inst->loaded = 0;
inst->releaseRate = soundFont->instruments[i].releaseRate;
inst->normalRangeLo = soundFont->instruments[i].normalRangeLo;
inst->normalRangeHi = soundFont->instruments[i].normalRangeHi;
if (soundFont->instruments[i].env.size() == 0)
inst->envelope = NULL;
else
{
inst->envelope = (AdsrEnvelope*)malloc(sizeof(AdsrEnvelope) * soundFont->instruments[i].env.size());
for (int k = 0; k < soundFont->instruments[i].env.size(); k++)
{
inst->envelope[k].delay = BOMSWAP16(soundFont->instruments[i].env[k]->delay);
inst->envelope[k].arg = BOMSWAP16(soundFont->instruments[i].env[k]->arg);
}
}
if (soundFont->instruments[i].lowNotesSound != nullptr)
{
inst->lowNotesSound.sample =
ResourceMgr_LoadAudioSample(soundFont->instruments[i].lowNotesSound->sampleOffset);
inst->lowNotesSound.tuning = soundFont->instruments[i].lowNotesSound->tuning;
} else {
inst->lowNotesSound.sample = NULL;
inst->lowNotesSound.tuning = 0;
}
if (soundFont->instruments[i].normalNotesSound != nullptr) {
inst->normalNotesSound.sample =
ResourceMgr_LoadAudioSample(soundFont->instruments[i].normalNotesSound->sampleOffset);
inst->normalNotesSound.tuning = soundFont->instruments[i].normalNotesSound->tuning;
} else {
inst->normalNotesSound.sample = NULL;
inst->normalNotesSound.tuning = 0;
}
if (soundFont->instruments[i].highNotesSound != nullptr) {
inst->highNotesSound.sample =
ResourceMgr_LoadAudioSample(soundFont->instruments[i].highNotesSound->sampleOffset);
inst->highNotesSound.tuning = soundFont->instruments[i].highNotesSound->tuning;
} else {
inst->highNotesSound.sample = NULL;
inst->highNotesSound.tuning = 0;
}
soundFontC->instruments[i] = inst;
} else
{
soundFontC->instruments[i] = nullptr;
}
}
soundFontC->soundEffects = (SoundFontSound*)malloc(sizeof(SoundFontSound) * soundFont->soundEffects.size());
for (int i = 0; i < soundFont->soundEffects.size(); i++)
{
soundFontC->soundEffects[i].sample = ResourceMgr_LoadAudioSample(soundFont->soundEffects[i]->sampleOffset);
soundFontC->soundEffects[i].tuning = soundFont->soundEffects[i]->tuning;
}
soundFont->cachedGameAsset = soundFontC;
return soundFontC;
}
}
extern "C" int ResourceMgr_OTRSigCheck(char* imgData)
{
uintptr_t i = (uintptr_t)(imgData);

View file

@ -24,8 +24,8 @@ private:
#endif
#ifndef __cplusplus
void InitOTR();
void Graph_ProcessFrame(void (*run_one_game_iter)(void));
void OTRAudio_Init();
void InitAudio();
void Graph_StartFrame();
void Graph_ProcessGfxCommands(Gfx* commands);
void OTRLogString(const char* src);

View file

@ -445,7 +445,9 @@ void osViExtendVStart(u32 arg0)
}
#if 0
AudioTable gSoundFontTable = { 0 };
#else
AudioTable gSoundFontTable = { 0x0026,
0x0000,
0x00000000,
@ -795,7 +797,11 @@ AudioTable gSoundFontTable = { 0x0026,
},
}
};
#endif
#if 0
AudioTable gSequenceTable = { 0 };
#else
AudioTable gSequenceTable = { 0x006E,
0x0000,
0x00000000,
@ -1585,7 +1591,7 @@ AudioTable gSequenceTable = { 0x006E,
0x0000,
},
{
0x00000028,
0x00000028,
0x00000000,
0x02,
0x02,
@ -1791,9 +1797,12 @@ AudioTable gSequenceTable = { 0x006E,
0x0000,
0x0000,
},
}
};
} };
#endif
#if 0
AudioTable gSampleBankTable = { 0 };
#else
AudioTable gSampleBankTable = { 0x0007,
0x0000,
0x00000000,
@ -1864,7 +1873,9 @@ AudioTable gSampleBankTable = { 0x0007,
},
}
};
#endif
// OTRTODO: Implement This in OTR File
u8 gSequenceFontTable[0x1C0] = {
0xDC,
0x00,

View file

@ -84,7 +84,6 @@ void AudioMgr_Unlock(AudioMgr* audioMgr) {
}
void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr) {
return; // OTRTODO64
AudioPlayer_Init();
memset(audioMgr,0, sizeof(AudioMgr));

View file

@ -10,6 +10,8 @@ void AudioHeap_DiscardSampleCaches(void);
void AudioHeap_DiscardSampleBank(s32 sampleBankId);
void AudioHeap_DiscardSampleBanks(void);
extern bool gUseLegacySD;
f32 func_800DDE20(f32 arg0) {
return 256.0f * gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled / arg0;
}
@ -1201,7 +1203,11 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) {
}
}
void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) {
void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample)
{
if (!gUseLegacySD)
return;
if (sample != NULL) {
if (sample->sampleAddr == entry->allocatedAddr) {
sample->sampleAddr = entry->sampleAddr;

View file

@ -4,6 +4,7 @@
#include "ultra64.h"
#include "global.h"
#include "soh/OTRGlobals.h"
#define MK_ASYNC_MSG(retData, tableType, id, status) (((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (status))
#define ASYNC_TBLTYPE(v) ((u8)(v >> 16))
@ -37,11 +38,11 @@ void AudioLoad_ProcessAsyncLoads(s32 resetStatus);
void AudioLoad_ProcessAsyncLoadUnkMedium(AudioAsyncLoad* asyncLoad, s32 resetStatus);
void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus);
void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo, s32 temporary);
void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocInfo* relocInfo);
void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocInfo* relocInfo, int fontId);
void AudioLoad_DiscardFont(s32 fontId);
uintptr_t AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad);
uintptr_t AudioLoad_SyncLoad(u32 tableType, u32 tableId, s32* didAllocate);
uintptr_t AudioLoad_GetRealTableIndex(s32 tableType, u32 tableId);
u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 tableId);
void* AudioLoad_SearchCaches(s32 tableType, s32 id);
AudioTable* AudioLoad_GetLoadTable(s32 tableType);
void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium);
@ -75,6 +76,11 @@ void* sUnusedHandler = NULL;
s32 gAudioContextInitalized = false;
uintptr_t fontStart;
uint32_t fontOffsets[8192];
bool gUseLegacySD = false;
void AudioLoad_DecreaseSampleDmaTtls(void) {
u32 i;
@ -279,8 +285,11 @@ void AudioLoad_InitSampleDmaBuffers(s32 arg0) {
}
s32 AudioLoad_IsFontLoadComplete(s32 fontId) {
return true;
if (fontId == 0xFF) {
return true;
} else if (gAudioContext.fontLoadStatus[fontId] >= 2) {
return true;
} else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= 2) {
@ -353,6 +362,9 @@ void AudioLoad_InitTable(AudioTable* table, uintptr_t romAddr, u16 unkMediumPara
for (i = 0; i < table->numEntries; i++) {
if ((table->entries[i].size != 0) && (table->entries[i].medium == MEDIUM_CART)) {
if (romAddr == fontStart)
fontOffsets[i] = table->entries[i].romAddr;
table->entries[i].romAddr += romAddr;
}
}
@ -401,7 +413,8 @@ void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1) {
s32 AudioLoad_SyncLoadSample(SoundFontSample* sample, s32 fontId) {
void* sampleAddr;
if (sample->unk_bit25 == 1) {
if (sample->unk_bit25 == 1)
{
if (sample->medium != MEDIUM_RAM) {
sampleAddr = AudioHeap_AllocSampleCache(sample->size, fontId, (void*)sample->sampleAddr, sample->medium,
CACHE_PERSISTENT);
@ -549,7 +562,7 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) {
s32 numFonts;
s32 fontId;
if (seqId >= gAudioContext.numSequences) {
if (gUseLegacySD && seqId >= gAudioContext.numSequences) {
return 0;
}
@ -561,18 +574,27 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) {
while (numFonts > 0) {
fontId = gAudioContext.sequenceFontTable[index++];
AudioLoad_SyncLoadFont(fontId);
//if (gUseLegacySD)
AudioLoad_SyncLoadFont(fontId);
numFonts--;
}
seqData = AudioLoad_SyncLoadSeq(seqId);
if (seqData == NULL) {
return 0;
}
AudioSeq_ResetSequencePlayer(seqPlayer);
seqPlayer->seqId = seqId;
seqPlayer->defaultFont = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId);
if (gUseLegacySD)
seqPlayer->defaultFont = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId);
else
seqPlayer->defaultFont = fontId;
seqPlayer->seqData = seqData;
seqPlayer->enabled = 1;
seqPlayer->scriptState.pc = seqData;
@ -638,12 +660,22 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) {
s32 didAllocate;
RelocInfo relocInfo;
s32 realFontId = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId);
//s32 realFontId = fontId;
if (gAudioContext.fontLoadStatus[realFontId] == 1) {
return NULL;
}
sampleBankId1 = gAudioContext.soundFonts[realFontId].sampleBankId1;
sampleBankId2 = gAudioContext.soundFonts[realFontId].sampleBankId2;
if (!gUseLegacySD) {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId);
sampleBankId1 = sf->sampleBankId1;
sampleBankId2 = sf->sampleBankId2;
} else {
sampleBankId1 = gAudioContext.soundFonts[realFontId].sampleBankId1;
sampleBankId2 = gAudioContext.soundFonts[realFontId].sampleBankId2;
}
relocInfo.sampleBankId1 = sampleBankId1;
relocInfo.sampleBankId2 = sampleBankId2;
@ -686,13 +718,39 @@ uintptr_t AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
if (ret != NULL) {
*didAllocate = false;
status = 2;
} else {
table = AudioLoad_GetLoadTable(tableType);
size = table->entries[realId].size;
size = ALIGN16(size);
medium = table->entries[id].medium;
cachePolicy = table->entries[id].cachePolicy;
romAddr = table->entries[realId].romAddr;
} else
{
char* seqData = 0;
SoundFont* fnt;
if (!gUseLegacySD && tableType == SEQUENCE_TABLE)
{
seqData = ResourceMgr_LoadSeqByID(id);
size = ResourceMgr_GetSeqSizeByID(id);
size -= 2;
medium = seqData[0];
cachePolicy = seqData[1];
romAddr = 0;
seqData += 2;
}
else if (!gUseLegacySD && tableType == FONT_TABLE)
{
fnt = ResourceMgr_LoadAudioSoundFont(id);
size = sizeof(SoundFont);
medium = 2;
cachePolicy = 0;
romAddr = 0;
}
else
{
table = AudioLoad_GetLoadTable(tableType);
size = table->entries[realId].size;
size = ALIGN16(size);
medium = table->entries[id].medium;
cachePolicy = table->entries[id].cachePolicy;
romAddr = table->entries[realId].romAddr;
}
switch (cachePolicy) {
case 0:
ret = AudioHeap_AllocPermanent(tableType, realId, size);
@ -725,7 +783,14 @@ uintptr_t AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
if (medium == MEDIUM_UNK) {
AudioLoad_SyncDmaUnkMedium(romAddr, ret, size, (s16)table->unkMediumParam);
} else {
AudioLoad_SyncDma(romAddr, ret, size, medium);
if (!gUseLegacySD && tableType == SEQUENCE_TABLE && seqData != NULL) {
AudioLoad_SyncDma(seqData, ret, size, medium);
} else if (!gUseLegacySD && tableType == FONT_TABLE) {
AudioLoad_SyncDma(fnt, ret, size, medium);
}
else {
AudioLoad_SyncDma(romAddr, ret, size, medium);
}
}
status = cachePolicy == 0 ? 5 : 2;
@ -748,9 +813,15 @@ uintptr_t AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
return ret;
}
uintptr_t AudioLoad_GetRealTableIndex(s32 tableType, u32 id) {
u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id) {
if ((tableType == SEQUENCE_TABLE || tableType == FONT_TABLE) && !gUseLegacySD) {
return id;
}
AudioTable* table = AudioLoad_GetLoadTable(tableType);
// If the size is 0, then this entry actually redirects to another entry.
// The rom address is actually an index into the same table where the "real" data is.
if (table->entries[id].size == 0) {
id = table->entries[id].romAddr;
}
@ -801,29 +872,62 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
Drum* drum;
SoundFontSound* sfx;
s32 i;
s32 numDrums = gAudioContext.soundFonts[fontId].numDrums;
s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments;
s32 numSfx = gAudioContext.soundFonts[fontId].numSfx;
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId);
s32 numDrums = 0;
s32 numInstruments = 0;
s32 numSfx = 0;
if (gUseLegacySD) {
numDrums = gAudioContext.soundFonts[fontId].numDrums;
numInstruments = gAudioContext.soundFonts[fontId].numInstruments;
numSfx = gAudioContext.soundFonts[fontId].numSfx;
} else {
numDrums = sf->numDrums;
numInstruments = sf->numInstruments;
numSfx = sf->numSfx;
}
void** ptrs = (void**)mem;
#define BASE_OFFSET(x) (uintptr_t)((uintptr_t)(x) + (uintptr_t)(mem))
#define BASE_OFFSET(x) (void*)((u32)(x) + (u32)(mem))
reloc2 = ptrs[0];
if (1) {}
if ((reloc2 != 0) && (numDrums != 0)) {
if ((reloc2 != 0 || !gUseLegacySD) && (numDrums != 0))
{
ptrs[0] = BASE_OFFSET(reloc2);
for (i = 0; i < numDrums; i++) {
reloc = ((Drum**)ptrs[0])[i];
for (i = 0; i < numDrums; i++)
{
if (gUseLegacySD)
reloc = ((Drum**)ptrs[0])[i];
if (reloc != 0) {
reloc = BASE_OFFSET(reloc);
if (reloc != 0 || !gUseLegacySD)
{
if (gUseLegacySD)
{
reloc = BASE_OFFSET(reloc);
((Drum**)ptrs[0])[i] = drum = reloc;
}
((Drum**)ptrs[0])[i] = drum = reloc;
if (!drum->loaded) {
AudioLoad_RelocateSample(&drum->sound, mem, relocInfo);
reloc = drum->envelope;
drum->envelope = BASE_OFFSET(reloc);
drum->loaded = 1;
if (!gUseLegacySD)
drum = sf->drums[i];
if (!drum->loaded)
{
if (!gUseLegacySD)
{
AudioLoad_RelocateSample(&sf->drums[i]->sound, mem, relocInfo, fontOffsets[fontId]);
//reloc = drum->envelope;
drum->loaded = 1;
}
else
{
AudioLoad_RelocateSample(&drum->sound, mem, relocInfo, fontOffsets[fontId]);
reloc = drum->envelope;
drum->envelope = BASE_OFFSET(reloc);
drum->loaded = 1;
}
}
}
}
@ -831,14 +935,19 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
reloc2 = ptrs[1];
if (1) {}
if ((reloc2 != 0) && (numSfx != 0)) {
if ((reloc2 != 0 || !gUseLegacySD) && (numSfx != 0)) {
ptrs[1] = BASE_OFFSET(reloc2);
for (i = 0; i < numSfx; i++) {
reloc = (SoundFontSound*)ptrs[1] + i;
if (reloc != 0) {
sfx = reloc;
if (sfx->sample != NULL) {
AudioLoad_RelocateSample(sfx, mem, relocInfo);
if (reloc != 0 || !gUseLegacySD)
{
if (!gUseLegacySD) {
AudioLoad_RelocateSample(&sf->soundEffects[i].sample, mem, relocInfo, fontOffsets[fontId]);
} else {
sfx = reloc;
if (sfx->sample != NULL) {
AudioLoad_RelocateSample(sfx, mem, relocInfo, fontOffsets[fontId]);
}
}
}
}
@ -848,22 +957,34 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
numInstruments = 0x7E;
}
for (i = 2; i <= 2 + numInstruments - 1; i++) {
if (ptrs[i] != NULL) {
int startI = gUseLegacySD ? 2 : 0;
int startEC = gUseLegacySD ? 2 + numInstruments - 1 : numInstruments - 1;
//for (i = 2; i <= 2 + numInstruments - 1; i++) {
for (i = startI; i <= startEC; i++) {
if (!gUseLegacySD || ptrs[i] != NULL)
{
ptrs[i] = BASE_OFFSET(ptrs[i]);
inst = ptrs[i];
if (!inst->loaded) {
if (inst->normalRangeLo != 0) {
AudioLoad_RelocateSample(&inst->lowNotesSound, mem, relocInfo);
if (gUseLegacySD)
inst = ptrs[i];
else
inst = sf->instruments[i];
if (inst != NULL && !inst->loaded) {
if (inst->normalRangeLo != 0)
{
AudioLoad_RelocateSample(&inst->lowNotesSound, mem, relocInfo, fontOffsets[fontId]);
}
AudioLoad_RelocateSample(&inst->normalNotesSound, mem, relocInfo);
AudioLoad_RelocateSample(&inst->normalNotesSound, mem, relocInfo, fontOffsets[fontId]);
if (inst->normalRangeHi != 0x7F) {
AudioLoad_RelocateSample(&inst->highNotesSound, mem, relocInfo);
AudioLoad_RelocateSample(&inst->highNotesSound, mem, relocInfo, fontOffsets[fontId]);
}
reloc = inst->envelope;
inst->envelope = BASE_OFFSET(reloc);
if (gUseLegacySD)
inst->envelope = BASE_OFFSET(reloc);
inst->loaded = 1;
}
}
@ -871,9 +992,11 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
#undef BASE_OFFSET
gAudioContext.soundFonts[fontId].drums = ptrs[0];
gAudioContext.soundFonts[fontId].soundEffects = ptrs[1];
gAudioContext.soundFonts[fontId].instruments = (Instrument**)(ptrs + 2);
if (gUseLegacySD) {
gAudioContext.soundFonts[fontId].drums = ptrs[0];
gAudioContext.soundFonts[fontId].soundEffects = ptrs[1];
gAudioContext.soundFonts[fontId].instruments = (Instrument**)(ptrs + 2);
}
}
void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium) {
@ -1275,21 +1398,25 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
uintptr_t bankStart = ResourceMgr_LoadFileRaw(_AudiobankSegmentRomStart);
uintptr_t tableStart = ResourceMgr_LoadFileRaw(_AudiotableSegmentRomStart);
fontStart = bankStart;
AudioLoad_InitTable(gAudioContext.sequenceTable, seqStart, 0);
AudioLoad_InitTable(gAudioContext.soundFontTable, bankStart, 0);
AudioLoad_InitTable(gAudioContext.sampleBankTable, tableStart, 0);
numFonts = gAudioContext.soundFontTable->numEntries;
gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont));
for (i = 0; i < numFonts; i++) {
AudioLoad_InitSoundFontMeta(i);
}
if (gUseLegacySD) {
for (i = 0; i < numFonts; i++) {
AudioLoad_InitSoundFontMeta(i);
}
AudioLoad_InitSwapFont();
AudioLoad_InitSwapFont();
}
if (temp_v0_3 = AudioHeap_Alloc(&gAudioContext.audioInitPool, D_8014A6C4.permanentPoolSize), temp_v0_3 == NULL) {
// cast away const from D_8014A6C4
*((size_t*)&D_8014A6C4.permanentPoolSize) = 0;
// *((u32*)&D_8014A6C4.permanentPoolSize) = 0;
}
AudioHeap_AllocPoolInit(&gAudioContext.permanentPool, temp_v0_3, D_8014A6C4.permanentPoolSize);
@ -1459,28 +1586,40 @@ s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) {
AudioTable* seqTable;
size_t size;
if (seqId >= gAudioContext.numSequences) {
if (gUseLegacySD && seqId >= gAudioContext.numSequences) {
*isDone = 0;
return -1;
}
seqId = AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId);
seqTable = AudioLoad_GetLoadTable(SEQUENCE_TABLE);
slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos];
if (slowLoad->status == LOAD_STATUS_DONE) {
slowLoad->status = LOAD_STATUS_WAITING;
}
slowLoad->sample.sampleAddr = NULL;
slowLoad->isDone = isDone;
size = seqTable->entries[seqId].size;
size = ALIGN16(size);
if (!gUseLegacySD) {
char* seqData = ResourceMgr_LoadSeqByID(seqId);
size = ResourceMgr_GetSeqSizeByID(seqId) - 2;
slowLoad->curDevAddr = seqData + 2;
slowLoad->medium = seqData[0];
} else {
size = seqTable->entries[seqId].size;
size = ALIGN16(size);
slowLoad->curDevAddr = seqTable->entries[seqId].romAddr;
slowLoad->medium = seqTable->entries[seqId].medium;
}
slowLoad->curRamAddr = ramAddr;
slowLoad->status = LOAD_STATUS_START;
slowLoad->bytesRemaining = size;
slowLoad->ramAddr = ramAddr;
slowLoad->curDevAddr = seqTable->entries[seqId].romAddr;
slowLoad->medium = seqTable->entries[seqId].medium;
slowLoad->seqOrFontId = seqId;
if (slowLoad->medium == MEDIUM_UNK) {
@ -1693,7 +1832,7 @@ void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, uintptr_t ramAddr, size_t si
#define RELOC(v, base) (reloc = (uintptr_t)((uintptr_t)(v) + (uintptr_t)(base)))
void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocInfo* relocInfo) {
void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocInfo* relocInfo, int fontId) {
// OTRTODO: This is hack to detect whether or not the sample has been relocated.
size_t maxSoundBankSize = 0x3EB2A0; // sample bank 0 is largest size at 0x3EB2A0
if ((uintptr_t)mem <= maxSoundBankSize) {
@ -1705,32 +1844,58 @@ void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocIn
void* reloc;
// OTRTODO: Seems precarious to assume the RAM is never <= 0x3EB2A0, but it largely works.
if ((uintptr_t)sound->sample < maxSoundBankSize) {
sample = sound->sample = RELOC(sound->sample, mem);
if (sample->size != 0 && sample->unk_bit25 != 1) {
sample->loop = RELOC(sample->loop, mem);
sample->book = RELOC(sample->book, mem);
if ((uintptr_t)sound->sample < maxSoundBankSize || !gUseLegacySD)
{
if (!gUseLegacySD) {
SoundFontSample* sample2 = sound;
// Resolve the sample medium 2-bit bitfield into a real value based on relocInfo.
switch (sample->medium) {
case 0:
sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1);
sample->medium = relocInfo->medium1;
break;
case 1:
sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr2);
sample->medium = relocInfo->medium2;
break;
case 2:
case 3:
// Invalid? This leaves sample->medium as MEDIUM_CART and MEDIUM_DISK_DRIVE
// respectively, and the sampleAddr unrelocated.
break;
if (sample2->unk_bit25 != 1)
{
//if (sample2->size == 0x5CC8)
//{
// switch (sample2->medium) {
// case 0:
// sample2->medium = relocInfo->medium1;
// break;
// case 1:
// sample2->medium = relocInfo->medium2;
// break;
// }
// sample2->unk_bit25 = 1;
// if (sample2->unk_bit26 && (sample2->medium != MEDIUM_RAM)) {
// // gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample2;
// }
//}
}
} else {
sample = sound->sample = RELOC(sound->sample, mem);
sample->unk_bit25 = 1;
if (sample->unk_bit26 && (sample->medium != MEDIUM_RAM)) {
gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample;
if (sample->size != 0 && sample->unk_bit25 != 1) {
sample->loop = RELOC(sample->loop, mem);
sample->book = RELOC(sample->book, mem);
// Resolve the sample medium 2-bit bitfield into a real value based on relocInfo.
switch (sample->medium) {
case 0:
sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1);
sample->medium = relocInfo->medium1;
break;
case 1:
sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr2);
sample->medium = relocInfo->medium2;
break;
case 2:
case 3:
// Invalid? This leaves sample->medium as MEDIUM_CART and MEDIUM_DISK_DRIVE
// respectively, and the sampleAddr unrelocated.
break;
}
sample->unk_bit25 = 1;
if (sample->unk_bit26 && (sample->medium != MEDIUM_RAM)) {
gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample;
}
}
}
}
@ -1983,9 +2148,17 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo
gAudioContext.numUsedSamples = 0;
numDrums = gAudioContext.soundFonts[fontId].numDrums;
numInstruments = gAudioContext.soundFonts[fontId].numInstruments;
numSfx = gAudioContext.soundFonts[fontId].numSfx;
if (!gUseLegacySD) {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId);
numDrums = sf->numDrums;
numInstruments = sf->numInstruments;
numSfx = sf->numSfx;
} else {
numDrums = gAudioContext.soundFonts[fontId].numDrums;
numInstruments = gAudioContext.soundFonts[fontId].numInstruments;
numSfx = gAudioContext.soundFonts[fontId].numSfx;
}
for (i = 0; i < numInstruments; i++) {
instrument = Audio_GetInstrumentInner(fontId, i);
@ -2030,6 +2203,7 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo
}
sample = gAudioContext.usedSamples[i];
if (sample->medium == MEDIUM_RAM) {
continue;
}
@ -2106,10 +2280,19 @@ void AudioLoad_LoadPermanentSamples(void) {
for (i = 0; i < gAudioContext.permanentPool.count; i++) {
RelocInfo relocInfo;
if (gAudioContext.permanentCache[i].tableType == FONT_TABLE) {
if (gAudioContext.permanentCache[i].tableType == FONT_TABLE)
{
fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.permanentCache[i].id);
relocInfo.sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1;
relocInfo.sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2;
//fontId = gAudioContext.permanentCache[i].id;
if (!gUseLegacySD) {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId);
relocInfo.sampleBankId1 = sf->sampleBankId1;
relocInfo.sampleBankId2 = sf->sampleBankId2;
} else {
relocInfo.sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1;
relocInfo.sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2;
}
if (relocInfo.sampleBankId1 != 0xFF) {
relocInfo.sampleBankId1 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId1);

View file

@ -1,6 +1,8 @@
#include "global.h"
#include "Cvar.h"
extern bool gUseLegacySD;
void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {
f32 volRight, volLeft;
s32 smallPanIndex;
@ -307,7 +309,7 @@ SoundFontSound* Audio_InstrumentGetSound(Instrument* instrument, s32 semitone) {
Instrument* Audio_GetInstrumentInner(s32 fontId, s32 instId) {
Instrument* inst;
if (fontId == 0xFF) {
return NULL;
}
@ -317,16 +319,31 @@ Instrument* Audio_GetInstrumentInner(s32 fontId, s32 instId) {
return NULL;
}
if (instId >= gAudioContext.soundFonts[fontId].numInstruments) {
gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x3000000;
return NULL;
int instCnt = 0;
if (gUseLegacySD) {
instCnt = gAudioContext.soundFonts[fontId].numInstruments;
inst = gAudioContext.soundFonts[fontId].instruments[instId];
if (instId >= gAudioContext.soundFonts[fontId].numInstruments)
if (instId >= instCnt) {
gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x3000000;
return NULL;
}
} else {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId);
if (instId >= sf->numInstruments)
return NULL;
inst = sf->instruments[instId];
}
inst = gAudioContext.soundFonts[fontId].instruments[instId];
if (inst == NULL) {
gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x1000000;
return inst;
}
return inst;
}
@ -343,12 +360,17 @@ Drum* Audio_GetDrum(s32 fontId, s32 drumId) {
return NULL;
}
if (drumId >= gAudioContext.soundFonts[fontId].numDrums) {
gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x4000000;
return NULL;
}
if (gUseLegacySD) {
if (drumId >= gAudioContext.soundFonts[fontId].numDrums) {
gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x4000000;
return NULL;
}
drum = gAudioContext.soundFonts[fontId].drums[drumId];
drum = gAudioContext.soundFonts[fontId].drums[drumId];
} else {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId);
drum = sf->drums[drumId];
}
if (drum == NULL) {
gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x5000000;
@ -369,12 +391,17 @@ SoundFontSound* Audio_GetSfx(s32 fontId, s32 sfxId) {
return NULL;
}
if (sfxId >= gAudioContext.soundFonts[fontId].numSfx) {
gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x4000000;
return NULL;
}
if (gUseLegacySD) {
if (sfxId >= gAudioContext.soundFonts[fontId].numSfx) {
gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x4000000;
return NULL;
}
sfx = &gAudioContext.soundFonts[fontId].soundEffects[sfxId];
sfx = &gAudioContext.soundFonts[fontId].soundEffects[sfxId];
} else {
SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId);
sfx = &sf->soundEffects[sfxId];
}
if (sfx == NULL) {
gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x5000000;

View file

@ -938,8 +938,16 @@ u8 AudioSeq_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** inst
*instOut = NULL;
return 0;
}
adsr->envelope = inst->envelope;
adsr->releaseRate = inst->releaseRate;
if (inst->envelope != NULL)
{
adsr->envelope = inst->envelope;
adsr->releaseRate = (inst->releaseRate);
}
else {
adsr->envelope = gDefaultEnvelope;
}
*instOut = inst;
instId += 2;
return instId;

View file

@ -749,8 +749,10 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
cmd = AudioSynth_LoadWaveSamples(cmd, noteSubEu, synthState, nSamplesToLoad);
noteSamplesDmemAddrBeforeResampling = DMEM_UNCOMPRESSED_NOTE + (synthState->samplePosInt * 2);
synthState->samplePosInt += nSamplesToLoad;
} else {
} else
{
audioFontSample = noteSubEu->sound.soundFontSound->sample;
loopInfo = audioFontSample->loop;
loopEndPos = loopInfo->end;
sampleAddr = audioFontSample->sampleAddr;
@ -822,6 +824,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
noteFinished = true;
}
}
switch (audioFontSample->codec) {
case CODEC_ADPCM:
@ -848,6 +851,9 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
goto skip;
case CODEC_S16:
AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, (samplesLenAdjusted * 2) + 0x20);
AudioSynth_LoadBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, ALIGN16(nSamplesToLoad * 2),
audioFontSample->sampleAddr + (synthState->samplePosInt * 2));
flags = A_CONTINUE;
skipBytes = 0;
nSamplesProcessed = samplesLenAdjusted;
@ -860,7 +866,8 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
if (nFramesToDecode != 0) {
frameIndex = (synthState->samplePosInt + skipInitialSamples - nFirstFrameSamplesToIgnore) / 16;
sampleDataOffset = frameIndex * frameSize;
if (audioFontSample->medium == MEDIUM_RAM) {
if (audioFontSample->medium == MEDIUM_RAM)
{
sampleData = (u8*)(sampleDataStart + sampleDataOffset + sampleAddr);
} else if (audioFontSample->medium == MEDIUM_UNK) {
return cmd;
@ -1024,7 +1031,8 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
unk7 = noteSubEu->unk_07;
unkE = noteSubEu->unk_0E;
buf = &synthState->synthesisBuffers->panSamplesBuffer[0x18];
if (unk7 != 0 && noteSubEu->unk_0E != 0) {
if (unk7 != 0 && noteSubEu->unk_0E != 0)
{
AudioSynth_DMemMove(cmd++, DMEM_TEMP, DMEM_SCRATCH2, aiBufLen * 2);
thing = DMEM_SCRATCH2 - unk7;
if (synthState->unk_1A != 0) {

View file

@ -7,8 +7,6 @@ u8 D_8012D200[] = {
void func_800C3C20(void) {
s32 i;
return; // OTRTODO64
for (i = 0; (i < ARRAY_COUNT(D_8012D200)) & 0xFFFFFFFF; i++) {
Audio_StopSfxByBank(D_8012D200[i]);
}

View file

@ -212,11 +212,7 @@ AudioTask* func_800E5000(void) {
task = &gAudioContext.currTask->task.t;
task->type = M_AUDTASK;
task->flags = 0;
//task->ucode_boot = D_801120C0;
task->ucode_boot_size = 0x1000;
//task->ucode_data_size = ((rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64)) - 1;
//task->ucode = D_801120C0;
//task->ucode_data = rspAspMainDataStart;
task->ucode_size = 0x1000;
task->dram_stack = NULL;
task->dram_stack_size = 0;

View file

@ -1250,7 +1250,7 @@ s32 Audio_SetGanonDistVol(u8 targetVol);
// Function originally not called, so repurposing for DPad input
void func_800EC960(u8 dpad) {
if (dpad) {
sOcarinaAllowedBtnMask =
sOcarinaAllowedBtnMask =
(BTN_A | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT | BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT);
sOcarinaABtnMap = BTN_A;
sOcarinaCUPBtnMap = BTN_CUP | BTN_DUP;
@ -3502,7 +3502,6 @@ void func_800F4A70(void);
void func_800F5CF8(void);
void func_800F3054(void) {
return; // OTRTODO64
if (func_800FAD34() == 0) {
sAudioUpdateTaskStart = gAudioContext.totalTaskCnt;
sAudioUpdateStartTime = osGetTime();
@ -4096,7 +4095,7 @@ void func_800F4870(u8 arg0) {
}
// (name derived from debug strings, should probably update. used in ganon/ganon_boss scenes)
s32 Audio_SetGanonDistVol(u8 targetVol)
s32 Audio_SetGanonDistVol(u8 targetVol)
{
u8 phi_v0;
u16 phi_v0_2;
@ -4256,7 +4255,6 @@ void Audio_ClearSariaBgmAtPos(Vec3f* pos) {
* equally between the two bgm channels. Split based on note priority
*/
void Audio_SplitBgmChannels(s8 volSplit) {
return;
u8 volume;
u8 notePriority;
u16 channelBits;
@ -4521,15 +4519,13 @@ void func_800F5C2C(void) {
sPrevMainBgmSeqId = NA_BGM_DISABLED;
}
void Audio_PlayFanfare(u16 seqId)
void Audio_PlayFanfare(u16 seqId)
{
u16 sp26;
u32 sp20;
u8* sp1C;
u8* sp18;
return; // OTRTODO64
sp26 = func_800FA0B4(SEQ_PLAYER_FANFARE);
sp1C = func_800E5E84(sp26 & 0xFF, &sp20);
sp18 = func_800E5E84(seqId & 0xFF, &sp20);

View file

@ -122,7 +122,7 @@ void Audio_ClearBGMMute(u8 channelIdx) {
}
}
void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* vol, s8* reverbAdd)
void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* vol, s8* reverbAdd)
{
u8 i;
SoundRequest* req;
@ -204,7 +204,7 @@ void Audio_RemoveMatchingSoundRequests(u8 aspect, SoundBankEntry* cmp) {
}
}
void Audio_ProcessSoundRequest(void)
void Audio_ProcessSoundRequest(void)
{
u16 sfxId;
u8 count;
@ -307,7 +307,7 @@ void Audio_ProcessSoundRequest(void)
}
}
void Audio_RemoveSoundBankEntry(u8 bankId, u8 entryIndex)
void Audio_RemoveSoundBankEntry(u8 bankId, u8 entryIndex)
{
SoundBankEntry* entry = &gSoundBanks[bankId][entryIndex];
u8 i;
@ -335,7 +335,7 @@ void Audio_RemoveSoundBankEntry(u8 bankId, u8 entryIndex)
}
}
void Audio_ChooseActiveSounds(u8 bankId)
void Audio_ChooseActiveSounds(u8 bankId)
{
u8 numChosenSounds;
u8 numChannels;
@ -492,7 +492,7 @@ void Audio_ChooseActiveSounds(u8 bankId)
}
}
void Audio_PlayActiveSounds(u8 bankId)
void Audio_PlayActiveSounds(u8 bankId)
{
u8 entryIndex;
SequenceChannel* channel;
@ -553,7 +553,7 @@ void Audio_PlayActiveSounds(u8 bankId)
}
}
void Audio_StopSfxByBank(u8 bankId)
void Audio_StopSfxByBank(u8 bankId)
{
SoundBankEntry* entry;
s32 pad;
@ -579,8 +579,6 @@ void func_800F8884(u8 bankId, Vec3f* pos) {
u8 entryIndex = gSoundBanks[bankId][0].next;
u8 prevEntryIndex = 0;
return; // OTRTODO64
while (entryIndex != 0xFF) {
entry = &gSoundBanks[bankId][entryIndex];
if (entry->posX == &pos->x) {
@ -617,7 +615,7 @@ void Audio_StopSfxByPos(Vec3f* pos) {
Audio_RemoveMatchingSoundRequests(2, &cmp);
}
void Audio_StopSfxByPosAndId(Vec3f* pos, u16 sfxId)
void Audio_StopSfxByPosAndId(Vec3f* pos, u16 sfxId)
{
SoundBankEntry* entry;
u8 entryIndex = gSoundBanks[SFX_BANK(sfxId)][0].next;
@ -678,7 +676,6 @@ void Audio_StopSfxById(u32 sfxId) {
u8 entryIndex = gSoundBanks[SFX_BANK(sfxId)][0].next;
u8 prevEntryIndex = 0;
SoundBankEntry cmp;
return; // OTRTODO64
while (entryIndex != 0xFF) {
entry = &gSoundBanks[SFX_BANK(sfxId)][entryIndex];
@ -738,9 +735,8 @@ void func_800F8F88(void) {
}
}
u8 Audio_IsSfxPlaying(u32 sfxId)
u8 Audio_IsSfxPlaying(u32 sfxId)
{
return; // OTRTODO64
SoundBankEntry* entry;
u8 entryIndex = gSoundBanks[SFX_BANK(sfxId)][0].next;

View file

@ -204,7 +204,6 @@ void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx) {
}
void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx) {
return; // OTRTODO64
static s16 soundEffects[] = {
0,
NA_SE_EV_WATER_WALL - SFX_FLAG,