mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-14 18:48:04 -07:00
Updated zapd_audio_support into zelda64
This commit is contained in:
commit
5b43e4652f
24 changed files with 1884 additions and 218 deletions
|
@ -11,9 +11,10 @@ REGISTER_ZFILENODE(Audio, ZAudio);
|
|||
|
||||
ZAudio::ZAudio(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
//RegisterRequiredAttribute("CodeOffset");
|
||||
//RegisterOptionalAttribute("LangOffset", "0");
|
||||
|
||||
RegisterRequiredAttribute("SoundFontTableOffset");
|
||||
RegisterRequiredAttribute("SequenceTableOffset");
|
||||
RegisterRequiredAttribute("SampleBankTableOffset");
|
||||
RegisterRequiredAttribute("SequenceFontTableOffset");
|
||||
}
|
||||
|
||||
void ZAudio::ParseXML(tinyxml2::XMLElement* reader)
|
||||
|
@ -68,6 +69,13 @@ void ZAudio::ParseXML(tinyxml2::XMLElement* reader)
|
|||
}
|
||||
}
|
||||
|
||||
if (std::string(child->Value()) == "Soundfont")
|
||||
{
|
||||
auto name = child->Attribute("Name");
|
||||
auto index = child->IntAttribute("Index", 0);
|
||||
soundFontNames[index] = name;
|
||||
}
|
||||
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
|
@ -149,19 +157,10 @@ SampleEntry* ZAudio::ParseSampleEntry(std::vector<uint8_t> audioBank,
|
|||
sample->loop.end = BitConverter::ToInt32BE(audioBank, loopOffset + 4);
|
||||
sample->loop.count = BitConverter::ToInt32BE(audioBank, loopOffset + 8);
|
||||
|
||||
if (sample->loop.start == 0x3ADB)
|
||||
if (sample->loop.count != 0)
|
||||
{
|
||||
int bp = 0;
|
||||
}
|
||||
|
||||
if (/* sample->loop.count != 0xFFFFFFFF && */ sample->loop.count != 0)
|
||||
{
|
||||
//for (int i = 0; i < sample->loop.count; i++)
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
//if ((loopOffset + 16 + (i * 2)) >= audioBank.size())
|
||||
//break;
|
||||
|
||||
int16_t state = BitConverter::ToInt16BE(audioBank, loopOffset + 16 + (i * 2));
|
||||
sample->loop.states.push_back(state);
|
||||
}
|
||||
|
@ -189,7 +188,7 @@ SampleEntry* ZAudio::ParseSampleEntry(std::vector<uint8_t> audioBank,
|
|||
}
|
||||
else
|
||||
{
|
||||
return samples[sampleOffset];
|
||||
return samples[sampleOffset];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,30 +337,24 @@ void ZAudio::ParseRawData()
|
|||
audioSeqData = Globals::Instance->GetBaseromFile(Globals::Instance->baseRomPath.string() +
|
||||
"Audioseq");
|
||||
|
||||
//codeData = File::ReadAllBytes("baserom/code_ntsc");
|
||||
//audioTableData = File::ReadAllBytes("baserom/Audiotable_ntsc");
|
||||
//audioSeqData = File::ReadAllBytes("baserom/Audioseq_ntsc");
|
||||
//audioBankData = File::ReadAllBytes("baserom/Audiobank_ntsc");
|
||||
|
||||
// TABLE PARSING
|
||||
|
||||
// GC PAL
|
||||
//int gSoundFontTableOffset = 0x138270; // OTRTODO: Make this an XML Param
|
||||
//int gSequenceTableOffset = 0x1386A0; // OTRTODO: Make this an XML Param
|
||||
//int gSampleBankTableOffset = 0x138D90; // OTRTODO: Make this an XML Param
|
||||
//int gSequenceFontTableOffset = 0x1384E0; // OTRTODO: Make this an XML Param
|
||||
|
||||
// NMQ DBG ROM
|
||||
int gSoundFontTableOffset = 0x138290; // OTRTODO: Make this an XML Param
|
||||
int gSequenceTableOffset = 0x1386C0; // OTRTODO: Make this an XML Param
|
||||
int gSampleBankTableOffset = 0x138DB0; // OTRTODO: Make this an XML Param
|
||||
int gSequenceFontTableOffset = 0x138500; // OTRTODO: Make this an XML Param
|
||||
|
||||
// MQ DBG ROM
|
||||
//int gSoundFontTableOffset = 0x138270;
|
||||
//int gSequenceTableOffset = 0x1386A0;
|
||||
//int gSampleBankTableOffset = 0x138D90;
|
||||
//int gSequenceFontTableOffset = 0x1384E0;
|
||||
|
||||
// NTSC 1.0
|
||||
//int gSoundFontTableOffset = 0x1026A0; // OTRTODO: Make this an XML Param
|
||||
//int gSequenceTableOffset = 0x102AD0; // OTRTODO: Make this an XML Param
|
||||
//int gSampleBankTableOffset = 0x1031C0; // OTRTODO: Make this an XML Param
|
||||
//int gSequenceFontTableOffset = 0x102910; // OTRTODO: Make this an XML Param
|
||||
//int gSoundFontTableOffset = 0x1026A0;
|
||||
//int gSequenceTableOffset = 0x102AD0;
|
||||
//int gSampleBankTableOffset = 0x1031C0;
|
||||
//int gSequenceFontTableOffset = 0x102910;
|
||||
|
||||
int gSoundFontTableOffset = StringHelper::StrToL(registeredAttributes.at("SoundFontTableOffset").value, 16);
|
||||
int gSequenceTableOffset = StringHelper::StrToL(registeredAttributes.at("SequenceTableOffset").value, 16);
|
||||
int gSampleBankTableOffset = StringHelper::StrToL(registeredAttributes.at("SampleBankTableOffset").value, 16);
|
||||
int gSequenceFontTableOffset = StringHelper::StrToL(registeredAttributes.at("SequenceFontTableOffset").value, 16);
|
||||
|
||||
soundFontTable = ParseAudioTable(codeData, gSoundFontTableOffset);
|
||||
sequenceTable = ParseAudioTable(codeData, gSequenceTableOffset);
|
||||
|
|
|
@ -95,6 +95,7 @@ public:
|
|||
std::map<uint32_t, SampleEntry*> samples;
|
||||
std::vector<std::vector<uint32_t>> fontIndices;
|
||||
std::vector<std::string> seqNames;
|
||||
std::map<uint32_t, std::string> soundFontNames;
|
||||
|
||||
// First Key = Bank ID, Sec Key = LoopDataOffset, Third Key = Sample Data Offset
|
||||
std::map<uint32_t, std::map<uint32_t, std::map<uint32_t, std::string>>> sampleOffsets;
|
||||
|
|
|
@ -461,8 +461,8 @@ char* OldMain(char* infilename)
|
|||
else
|
||||
{
|
||||
char comprType[5] = {
|
||||
static_cast<char>(CommChunk.compressionTypeH >> 8), static_cast<char>(CommChunk.compressionTypeH & 0xFF),
|
||||
static_cast<char>(CommChunk.compressionTypeL >> 8), static_cast<char>(CommChunk.compressionTypeL & 0xFF), 0};
|
||||
CommChunk.compressionTypeH >> 8, CommChunk.compressionTypeH & 0xFF,
|
||||
CommChunk.compressionTypeL >> 8, CommChunk.compressionTypeL & 0xFF, 0};
|
||||
fail_parse("file is of the wrong compression type [got %s (%08x)]", &comprType,
|
||||
cType);
|
||||
}
|
||||
|
@ -603,8 +603,8 @@ char* OldMain(char* infilename)
|
|||
{
|
||||
s32 startPos = aloops[0].start, endPos = aloops[0].end;
|
||||
const char* markerNames[2] = {"start", "end"};
|
||||
Marker markers[2] = {{1, static_cast<u16>(startPos >> 16), static_cast<u16>(startPos & 0xffff)},
|
||||
{2, static_cast<u16>(endPos >> 16), static_cast<u16>(endPos & 0xffff)}};
|
||||
Marker markers[2] = {{1, startPos >> 16, startPos & 0xffff},
|
||||
{2, endPos >> 16, endPos & 0xffff}};
|
||||
write_header(ofile, "MARK", 2 + 2 * sizeof(Marker) + 1 + 5 + 1 + 3);
|
||||
s16 numMarkers = bswap16(2);
|
||||
fwrite(&numMarkers, sizeof(s16), 1, ofile);
|
||||
|
|
|
@ -68,7 +68,7 @@ ZRom::ZRom(std::string romPath)
|
|||
romData = File::ReadAllBytes(romPath);
|
||||
|
||||
version.crc = BitConverter::ToInt32BE(romData, 0x10);
|
||||
|
||||
|
||||
switch (version.crc)
|
||||
{
|
||||
case OOT_NTSC_10:
|
||||
|
@ -192,10 +192,8 @@ ZRom::ZRom(std::string romPath)
|
|||
else
|
||||
files[lines[i]] = outData;
|
||||
|
||||
//File::WriteAllBytes(StringHelper::Sprintf("baserom/%s", lines[i]), files[lines[i]]);
|
||||
//File::WriteAllBytes(StringHelper::Sprintf("baserom/%s", lines[i].c_str()), files[lines[i]]);
|
||||
}
|
||||
|
||||
int bp = 0;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> ZRom::GetFile(std::string fileName)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue