General: Be explicit about athena's SeekOrigin type

Allows the code to still compile if the enum is turned into an enum
class.
This commit is contained in:
Lioncash 2019-09-08 16:52:55 -04:00
parent d88b14c38a
commit d10a0ac7f1
6 changed files with 170 additions and 147 deletions

View File

@ -36,7 +36,7 @@ struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) ObjectHe
AT_DECL_DNA
Value<atUint32, DNAEn> size;
ObjectIdDNA<DNAEn> objectId;
Seek<2, athena::Current> pad;
Seek<2, athena::SeekOrigin::Current> pad;
};
struct SoundMacro {
@ -908,7 +908,7 @@ struct SoundMacro {
static const CmdIntrospection Introspective;
Value<bool> varCtrlA;
Value<atInt8> a;
Seek<1, athena::Current> pad;
Seek<1, athena::SeekOrigin::Current> pad;
Value<atInt16> imm;
bool Do(SoundMacroState& st, Voice& vox) const override;
CmdOp Isa() const override { return CmdOp::SetVar; }
@ -1100,7 +1100,7 @@ struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) KeymapDN
Value<atInt8> transpose;
Value<atInt8> pan; /* -128 for surround-channel only */
Value<atInt8> prioOffset;
Seek<3, athena::Current> pad;
Seek<3, athena::SeekOrigin::Current> pad;
};
struct Keymap : BigDNA {
AT_DECL_DNA_YAML
@ -1142,7 +1142,7 @@ struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) LayerMap
Value<atInt8> prioOffset;
Value<atInt8> span;
Value<atInt8> pan;
Seek<3, athena::Current> pad;
Seek<3, athena::SeekOrigin::Current> pad;
};
struct LayerMapping : BigDNA {
AT_DECL_DNA_YAML

View File

@ -46,7 +46,7 @@ struct SongGroupIndex : AudioGroupIndex {
Value<atUint8> priority;
Value<atUint8> maxVoices;
Value<atUint8> programNo;
Seek<1, athena::Current> pad;
Seek<1, athena::SeekOrigin::Current> pad;
};
template <athena::Endian DNAEn>
struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) MusyX1PageEntryDNA : BigDNA {
@ -56,7 +56,7 @@ struct SongGroupIndex : AudioGroupIndex {
Value<atUint8> maxVoices;
Value<atUint8> unk;
Value<atUint8> programNo;
Seek<2, athena::Current> pad;
Seek<2, athena::SeekOrigin::Current> pad;
};
struct PageEntry : BigDNA {
AT_DECL_DNA_YAML
@ -94,7 +94,7 @@ struct SongGroupIndex : AudioGroupIndex {
Value<atUint8> panning;
Value<atUint8> reverb;
Value<atUint8> chorus;
Seek<3, athena::Current> pad;
Seek<3, athena::SeekOrigin::Current> pad;
};
struct MIDISetup : BigDNA {
AT_DECL_DNA_YAML
@ -130,7 +130,7 @@ struct SFXGroupIndex : AudioGroupIndex {
Value<atUint8> defVel;
Value<atUint8> panning;
Value<atUint8> defKey;
Seek<1, athena::Current> pad;
Seek<1, athena::SeekOrigin::Current> pad;
};
struct SFXEntry : BigDNA {
AT_DECL_DNA_YAML

View File

@ -31,7 +31,7 @@ struct DSPADPCMHeader : BigDNA {
Value<atInt16> x46_loop_hist1 = 0;
Value<atInt16> x48_loop_hist2 = 0;
Value<atUint8> m_pitch = 0; // Stash this in the padding
Seek<21, athena::Current> pad;
Seek<21, athena::SeekOrigin::Current> pad;
};
struct VADPCMHeader : BigDNA {
@ -156,11 +156,11 @@ public:
struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) EntryDNA : BigDNA {
AT_DECL_DNA
SampleIdDNA<DNAEn> m_sfxId;
Seek<2, athena::Current> pad;
Seek<2, athena::SeekOrigin::Current> pad;
Value<atUint32, DNAEn> m_sampleOff;
Value<atUint32, DNAEn> m_unk;
Value<atUint8, DNAEn> m_pitch;
Seek<1, athena::Current> pad2;
Seek<1, athena::SeekOrigin::Current> pad2;
Value<atUint16, DNAEn> m_sampleRate;
Value<atUint32, DNAEn> m_numSamples; // Top 8 bits is SampleFormat
Value<atUint32, DNAEn> m_loopStartSample;
@ -177,7 +177,7 @@ public:
struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) MusyX1SdirEntry : BigDNA {
AT_DECL_DNA
SampleIdDNA<DNAEn> m_sfxId;
Seek<2, athena::Current> pad;
Seek<2, athena::SeekOrigin::Current> pad;
Value<atUint32, DNAEn> m_sampleOff;
Value<atUint32, DNAEn> m_pitchSampleRate;
Value<atUint32, DNAEn> m_numSamples;
@ -188,7 +188,7 @@ public:
struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) MusyX1AbsSdirEntry : BigDNA {
AT_DECL_DNA
SampleIdDNA<DNAEn> m_sfxId;
Seek<2, athena::Current> pad;
Seek<2, athena::SeekOrigin::Current> pad;
Value<uint32_t, DNAEn> m_sampleOff;
Value<uint32_t, DNAEn> m_unk;
Value<uint32_t, DNAEn> m_pitchSampleRate;

View File

@ -88,7 +88,7 @@ struct IntrospectCmdOp {
static bool AtEnd(athena::io::IStreamReader& r) {
uint32_t v = r.readUint32Big();
r.seek(-4, athena::Current);
r.seek(-4, athena::SeekOrigin::Current);
return v == 0xffffffff;
}
@ -100,7 +100,7 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) {
head.read(r);
if (head.soundMacrosOffset) {
r.seek(head.soundMacrosOffset, athena::Begin);
r.seek(head.soundMacrosOffset, athena::SeekOrigin::Begin);
while (!AtEnd(r)) {
ObjectHeader<DNAE> objHead;
atInt64 startPos = r.position();
@ -111,12 +111,12 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) {
auto& macro = ret.m_soundMacros[objHead.objectId.id];
macro = MakeObj<SoundMacro>();
macro->template readCmds<DNAE>(r, objHead.size - 8);
r.seek(startPos + objHead.size, athena::Begin);
r.seek(startPos + objHead.size, athena::SeekOrigin::Begin);
}
}
if (head.tablesOffset) {
r.seek(head.tablesOffset, athena::Begin);
r.seek(head.tablesOffset, athena::SeekOrigin::Begin);
while (!AtEnd(r)) {
ObjectHeader<DNAE> objHead;
atInt64 startPos = r.position();
@ -139,12 +139,12 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) {
r.readUBytesToBuf(&static_cast<Curve&>(**ptr).data[0], objHead.size - 8);
break;
}
r.seek(startPos + objHead.size, athena::Begin);
r.seek(startPos + objHead.size, athena::SeekOrigin::Begin);
}
}
if (head.keymapsOffset) {
r.seek(head.keymapsOffset, athena::Begin);
r.seek(head.keymapsOffset, athena::SeekOrigin::Begin);
while (!AtEnd(r)) {
ObjectHeader<DNAE> objHead;
atInt64 startPos = r.position();
@ -159,12 +159,12 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) {
kmData.read(r);
(*km)[i] = kmData;
}
r.seek(startPos + objHead.size, athena::Begin);
r.seek(startPos + objHead.size, athena::SeekOrigin::Begin);
}
}
if (head.layersOffset) {
r.seek(head.layersOffset, athena::Begin);
r.seek(head.layersOffset, athena::SeekOrigin::Begin);
while (!AtEnd(r)) {
ObjectHeader<DNAE> objHead;
atInt64 startPos = r.position();
@ -182,7 +182,7 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) {
lmData.read(r);
lm->push_back(lmData);
}
r.seek(startPos + objHead.size, athena::Begin);
r.seek(startPos + objHead.size, athena::SeekOrigin::Begin);
}
}
@ -1019,9 +1019,9 @@ std::vector<uint8_t> AudioGroupPool::toData() const {
p.second->template writeCmds<DNAE>(fo);
objHead.size = fo.position() - startPos;
objHead.objectId = p.first;
fo.seek(startPos, athena::Begin);
fo.seek(startPos, athena::SeekOrigin::Begin);
objHead.write(fo);
fo.seek(startPos + objHead.size, athena::Begin);
fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin);
}
athena::io::Write<athena::io::PropType::None>::Do<decltype(term), DNAE>({}, term, fo);
}
@ -1049,9 +1049,9 @@ std::vector<uint8_t> AudioGroupPool::toData() const {
}
objHead.size = fo.position() - startPos;
objHead.objectId = p.first;
fo.seek(startPos, athena::Begin);
fo.seek(startPos, athena::SeekOrigin::Begin);
objHead.write(fo);
fo.seek(startPos + objHead.size, athena::Begin);
fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin);
}
athena::io::Write<athena::io::PropType::None>::Do<decltype(term), DNAE>({}, term, fo);
}
@ -1068,9 +1068,9 @@ std::vector<uint8_t> AudioGroupPool::toData() const {
}
objHead.size = fo.position() - startPos;
objHead.objectId = p.first;
fo.seek(startPos, athena::Begin);
fo.seek(startPos, athena::SeekOrigin::Begin);
objHead.write(fo);
fo.seek(startPos + objHead.size, athena::Begin);
fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin);
}
athena::io::Write<athena::io::PropType::None>::Do<decltype(term), DNAE>({}, term, fo);
}
@ -1089,14 +1089,14 @@ std::vector<uint8_t> AudioGroupPool::toData() const {
}
objHead.size = fo.position() - startPos;
objHead.objectId = p.first;
fo.seek(startPos, athena::Begin);
fo.seek(startPos, athena::SeekOrigin::Begin);
objHead.write(fo);
fo.seek(startPos + objHead.size, athena::Begin);
fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin);
}
athena::io::Write<athena::io::PropType::None>::Do<decltype(term), DNAE>({}, term, fo);
}
fo.seek(0, athena::Begin);
fo.seek(0, athena::SeekOrigin::Begin);
head.write(fo);
return fo.data();

View File

@ -13,19 +13,19 @@ namespace amuse {
static bool AtEnd64(athena::io::IStreamReader& r) {
uint64_t v = r.readUint64Big();
r.seek(-8, athena::Current);
r.seek(-8, athena::SeekOrigin::Current);
return v == 0xffffffffffffffff;
}
static bool AtEnd32(athena::io::IStreamReader& r) {
uint32_t v = r.readUint32Big();
r.seek(-4, athena::Current);
r.seek(-4, athena::SeekOrigin::Current);
return v == 0xffffffff;
}
static bool AtEnd16(athena::io::IStreamReader& r) {
uint16_t v = r.readUint16Big();
r.seek(-2, athena::Current);
r.seek(-2, athena::SeekOrigin::Current);
return v == 0xffff;
}
@ -90,29 +90,34 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) {
#if 0
/* Sound Macros */
r.seek(header.soundMacroIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(header.soundMacroIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<athena::Big>(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro);
}
/* Samples */
r.seek(header.samplIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(header.samplIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<athena::Big>(SampleId::CurNameDB, r, NameDB::Type::Sample);
}
/* Tables */
r.seek(header.tableIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(header.tableIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<athena::Big>(TableId::CurNameDB, r, NameDB::Type::Table);
}
/* Keymaps */
r.seek(header.keymapIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(header.keymapIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<athena::Big>(KeymapId::CurNameDB, r, NameDB::Type::Keymap);
}
/* Layers */
r.seek(header.layerIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(header.layerIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<athena::Big>(LayersId::CurNameDB, r, NameDB::Type::Layer);
}
#endif
if (header.type == GroupType::Song) {
@ -120,7 +125,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) {
idx = MakeObj<SongGroupIndex>();
/* Normal pages */
r.seek(header.pageTableOff, athena::Begin);
r.seek(header.pageTableOff, athena::SeekOrigin::Begin);
while (!AtEnd64(r)) {
SongGroupIndex::PageEntryDNA<athena::Big> entry;
entry.read(r);
@ -128,7 +133,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) {
}
/* Drum pages */
r.seek(header.drumTableOff, athena::Begin);
r.seek(header.drumTableOff, athena::SeekOrigin::Begin);
while (!AtEnd64(r)) {
SongGroupIndex::PageEntryDNA<athena::Big> entry;
entry.read(r);
@ -136,24 +141,26 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) {
}
/* MIDI setups */
r.seek(header.midiSetupsOff, athena::Begin);
r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin);
while (r.position() < header.groupEndOff) {
uint16_t songId = r.readUint16Big();
r.seek(2, athena::Current);
r.seek(2, athena::SeekOrigin::Current);
std::array<SongGroupIndex::MIDISetup, 16>& setup = idx->m_midiSetups[songId];
for (int i = 0; i < 16; ++i)
for (int i = 0; i < 16; ++i) {
setup[i].read(r);
if (SongId::CurNameDB)
}
if (SongId::CurNameDB) {
SongId::CurNameDB->registerPair(NameDB::generateName(songId, NameDB::Type::Song), songId);
}
}
} else if (header.type == GroupType::SFX) {
auto& idx = m_sfxGroups[header.groupId];
idx = MakeObj<SFXGroupIndex>();
/* SFX entries */
r.seek(header.pageTableOff, athena::Begin);
r.seek(header.pageTableOff, athena::SeekOrigin::Begin);
uint16_t count = r.readUint16Big();
r.seek(2, athena::Current);
r.seek(2, athena::SeekOrigin::Current);
idx->m_sfxEntries.reserve(count);
for (int i = 0; i < count; ++i) {
SFXGroupIndex::SFXEntryDNA<athena::Big> entry;
@ -164,7 +171,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) {
}
}
r.seek(header.groupEndOff, athena::Begin);
r.seek(header.groupEndOff, athena::SeekOrigin::Begin);
}
}
@ -182,29 +189,34 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade
#if 0
/* Sound Macros */
r.seek(subDataOff + header.soundMacroIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(subDataOff + header.soundMacroIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<DNAE>(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro);
}
/* Samples */
r.seek(subDataOff + header.samplIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(subDataOff + header.samplIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<DNAE>(SampleId::CurNameDB, r, NameDB::Type::Sample);
}
/* Tables */
r.seek(subDataOff + header.tableIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(subDataOff + header.tableIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<DNAE>(TableId::CurNameDB, r, NameDB::Type::Table);
}
/* Keymaps */
r.seek(subDataOff + header.keymapIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(subDataOff + header.keymapIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<DNAE>(KeymapId::CurNameDB, r, NameDB::Type::Keymap);
}
/* Layers */
r.seek(subDataOff + header.layerIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(subDataOff + header.layerIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<DNAE>(LayersId::CurNameDB, r, NameDB::Type::Layer);
}
#endif
if (header.type == GroupType::Song) {
@ -213,7 +225,7 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade
if (absOffs) {
/* Normal pages */
r.seek(header.pageTableOff, athena::Begin);
r.seek(header.pageTableOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
SongGroupIndex::PageEntryDNA<DNAE> entry;
entry.read(r);
@ -221,7 +233,7 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade
}
/* Drum pages */
r.seek(header.drumTableOff, athena::Begin);
r.seek(header.drumTableOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
SongGroupIndex::PageEntryDNA<DNAE> entry;
entry.read(r);
@ -229,19 +241,20 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade
}
/* MIDI setups */
r.seek(header.midiSetupsOff, athena::Begin);
r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin);
while (r.position() < header.groupEndOff) {
uint16_t songId;
athena::io::Read<athena::io::PropType::None>::Do<decltype(songId), DNAE>({}, songId, r);
r.seek(2, athena::Current);
r.seek(2, athena::SeekOrigin::Current);
std::array<SongGroupIndex::MIDISetup, 16>& setup = idx->m_midiSetups[songId];
for (int i = 0; i < 16; ++i)
for (int i = 0; i < 16; ++i) {
setup[i].read(r);
}
SongId::CurNameDB->registerPair(NameDB::generateName(songId, NameDB::Type::Song), songId);
}
} else {
/* Normal pages */
r.seek(subDataOff + header.pageTableOff, athena::Begin);
r.seek(subDataOff + header.pageTableOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
SongGroupIndex::MusyX1PageEntryDNA<DNAE> entry;
entry.read(r);
@ -249,7 +262,7 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade
}
/* Drum pages */
r.seek(subDataOff + header.drumTableOff, athena::Begin);
r.seek(subDataOff + header.drumTableOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
SongGroupIndex::MusyX1PageEntryDNA<DNAE> entry;
entry.read(r);
@ -257,11 +270,11 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade
}
/* MIDI setups */
r.seek(subDataOff + header.midiSetupsOff, athena::Begin);
r.seek(subDataOff + header.midiSetupsOff, athena::SeekOrigin::Begin);
while (atInt64(r.position() + 4) < groupBegin + header.groupEndOff) {
uint16_t songId;
athena::io::Read<athena::io::PropType::None>::Do<decltype(songId), DNAE>({}, songId, r);
r.seek(2, athena::Current);
r.seek(2, athena::SeekOrigin::Current);
std::array<SongGroupIndex::MIDISetup, 16>& setup = idx->m_midiSetups[songId];
for (int i = 0; i < 16; ++i) {
SongGroupIndex::MusyX1MIDISetup ent;
@ -276,24 +289,24 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade
idx = MakeObj<SFXGroupIndex>();
/* SFX entries */
r.seek(subDataOff + header.pageTableOff, athena::Begin);
r.seek(subDataOff + header.pageTableOff, athena::SeekOrigin::Begin);
uint16_t count;
athena::io::Read<athena::io::PropType::None>::Do<decltype(count), DNAE>({}, count, r);
r.seek(2, athena::Current);
r.seek(2, athena::SeekOrigin::Current);
idx->m_sfxEntries.reserve(count);
for (int i = 0; i < count; ++i) {
SFXGroupIndex::SFXEntryDNA<DNAE> entry;
entry.read(r);
r.seek(2, athena::Current);
r.seek(2, athena::SeekOrigin::Current);
idx->m_sfxEntries[entry.sfxId.id] = entry;
SFXId::CurNameDB->registerPair(NameDB::generateName(entry.sfxId.id, NameDB::Type::SFX), entry.sfxId.id);
}
}
if (absOffs)
r.seek(header.groupEndOff, athena::Begin);
r.seek(header.groupEndOff, athena::SeekOrigin::Begin);
else
r.seek(groupBegin + header.groupEndOff, athena::Begin);
r.seek(groupBegin + header.groupEndOff, athena::SeekOrigin::Begin);
}
return ret;
@ -452,43 +465,47 @@ void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, GCNData
GroupId::CurNameDB->registerPair(NameDB::generateName(header.groupId, NameDB::Type::Group), header.groupId);
/* Sound Macros */
r.seek(header.soundMacroIdsOff, athena::Begin);
r.seek(header.soundMacroIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r))
ReadRangedObjectIds<athena::Big>(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro);
/* Samples */
r.seek(header.samplIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(header.samplIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<athena::Big>(SampleId::CurNameDB, r, NameDB::Type::Sample);
}
/* Tables */
r.seek(header.tableIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(header.tableIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<athena::Big>(TableId::CurNameDB, r, NameDB::Type::Table);
}
/* Keymaps */
r.seek(header.keymapIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(header.keymapIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<athena::Big>(KeymapId::CurNameDB, r, NameDB::Type::Keymap);
}
/* Layers */
r.seek(header.layerIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(header.layerIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<athena::Big>(LayersId::CurNameDB, r, NameDB::Type::Layer);
}
if (header.type == GroupType::Song) {
/* MIDI setups */
r.seek(header.midiSetupsOff, athena::Begin);
r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin);
while (r.position() < header.groupEndOff) {
uint16_t id = r.readUint16Big();
SongId::CurNameDB->registerPair(NameDB::generateName(id, NameDB::Type::Song), id);
r.seek(2 + 5 * 16, athena::Current);
r.seek(2 + 5 * 16, athena::SeekOrigin::Current);
}
} else if (header.type == GroupType::SFX) {
/* SFX entries */
r.seek(header.pageTableOff, athena::Begin);
r.seek(header.pageTableOff, athena::SeekOrigin::Begin);
uint16_t count = r.readUint16Big();
r.seek(2, athena::Current);
r.seek(2, athena::SeekOrigin::Current);
for (int i = 0; i < count; ++i) {
SFXGroupIndex::SFXEntryDNA<athena::Big> entry;
entry.read(r);
@ -496,7 +513,7 @@ void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, GCNData
}
}
r.seek(header.groupEndOff, athena::Begin);
r.seek(header.groupEndOff, athena::SeekOrigin::Begin);
}
}
@ -511,67 +528,73 @@ void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, bool ab
GroupId::CurNameDB->registerPair(NameDB::generateName(header.groupId, NameDB::Type::Group), header.groupId);
/* Sound Macros */
r.seek(subDataOff + header.soundMacroIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(subDataOff + header.soundMacroIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<DNAE>(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro);
}
/* Samples */
r.seek(subDataOff + header.samplIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(subDataOff + header.samplIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<DNAE>(SampleId::CurNameDB, r, NameDB::Type::Sample);
}
/* Tables */
r.seek(subDataOff + header.tableIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(subDataOff + header.tableIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<DNAE>(TableId::CurNameDB, r, NameDB::Type::Table);
}
/* Keymaps */
r.seek(subDataOff + header.keymapIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(subDataOff + header.keymapIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<DNAE>(KeymapId::CurNameDB, r, NameDB::Type::Keymap);
}
/* Layers */
r.seek(subDataOff + header.layerIdsOff, athena::Begin);
while (!AtEnd16(r))
r.seek(subDataOff + header.layerIdsOff, athena::SeekOrigin::Begin);
while (!AtEnd16(r)) {
ReadRangedObjectIds<DNAE>(LayersId::CurNameDB, r, NameDB::Type::Layer);
}
if (header.type == GroupType::Song) {
/* MIDI setups */
if (absOffs) {
r.seek(header.midiSetupsOff, athena::Begin);
r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin);
while (r.position() < header.groupEndOff) {
uint16_t id;
athena::io::Read<athena::io::PropType::None>::Do<decltype(id), DNAE>({}, id, r);
SongId::CurNameDB->registerPair(NameDB::generateName(id, NameDB::Type::Song), id);
r.seek(2 + 5 * 16, athena::Current);
r.seek(2 + 5 * 16, athena::SeekOrigin::Current);
}
} else {
r.seek(subDataOff + header.midiSetupsOff, athena::Begin);
r.seek(subDataOff + header.midiSetupsOff, athena::SeekOrigin::Begin);
while (atInt64(r.position()) < groupBegin + header.groupEndOff) {
uint16_t id;
athena::io::Read<athena::io::PropType::None>::Do<decltype(id), DNAE>({}, id, r);
SongId::CurNameDB->registerPair(NameDB::generateName(id, NameDB::Type::Song), id);
r.seek(2 + 8 * 16, athena::Current);
r.seek(2 + 8 * 16, athena::SeekOrigin::Current);
}
}
} else if (header.type == GroupType::SFX) {
/* SFX entries */
r.seek(subDataOff + header.pageTableOff, athena::Begin);
r.seek(subDataOff + header.pageTableOff, athena::SeekOrigin::Begin);
uint16_t count;
athena::io::Read<athena::io::PropType::None>::Do<decltype(count), DNAE>({}, count, r);
r.seek(2, athena::Current);
r.seek(2, athena::SeekOrigin::Current);
for (int i = 0; i < count; ++i) {
SFXGroupIndex::SFXEntryDNA<DNAE> entry;
entry.read(r);
r.seek(2, athena::Current);
r.seek(2, athena::SeekOrigin::Current);
SFXId::CurNameDB->registerPair(NameDB::generateName(entry.sfxId.id, NameDB::Type::SFX), entry.sfxId.id);
}
}
if (absOffs)
r.seek(header.groupEndOff, athena::Begin);
else
r.seek(groupBegin + header.groupEndOff, athena::Begin);
if (absOffs) {
r.seek(header.groupEndOff, athena::SeekOrigin::Begin);
} else {
r.seek(groupBegin + header.groupEndOff, athena::SeekOrigin::Begin);
}
}
}
@ -861,9 +884,9 @@ std::vector<uint8_t> AudioGroupProject::toGCNData(const AudioGroupPool& pool,
}
header.groupEndOff = fo.position();
fo.seek(groupStart, athena::Begin);
fo.seek(groupStart, athena::SeekOrigin::Begin);
header.write(fo);
fo.seek(header.groupEndOff, athena::Begin);
fo.seek(header.groupEndOff, athena::SeekOrigin::Begin);
} else {
auto search2 = m_sfxGroups.find(id);
if (search2 != m_sfxGroups.end()) {
@ -897,9 +920,9 @@ std::vector<uint8_t> AudioGroupProject::toGCNData(const AudioGroupPool& pool,
}
header.groupEndOff = fo.position();
fo.seek(groupStart, athena::Begin);
fo.seek(groupStart, athena::SeekOrigin::Begin);
header.write(fo);
fo.seek(header.groupEndOff, athena::Begin);
fo.seek(header.groupEndOff, athena::SeekOrigin::Begin);
}
}
}

View File

@ -24,7 +24,7 @@ namespace amuse {
static bool AtEnd32(athena::io::IStreamReader& r) {
uint32_t v = r.readUint32Big();
r.seek(-4, athena::Current);
r.seek(-4, athena::SeekOrigin::Current);
return v == 0xffffffff;
}
@ -55,7 +55,7 @@ AudioGroupSampleDirectory::AudioGroupSampleDirectory(athena::io::IStreamReader&
for (auto& p : m_entries) {
if (p.second->m_data->m_adpcmParmOffset) {
r.seek(p.second->m_data->m_adpcmParmOffset, athena::Begin);
r.seek(p.second->m_data->m_adpcmParmOffset, athena::SeekOrigin::Begin);
r.readUBytesToBuf(&p.second->m_data->m_ADPCMParms, sizeof(ADPCMParms::DSPParms));
p.second->m_data->m_ADPCMParms.swapBigDSP();
}
@ -237,7 +237,7 @@ void AudioGroupSampleDirectory::EntryData::loadLooseWAV(SystemStringView wavPath
m_looseData.reset(new uint8_t[chunkSize]);
r.readUBytesToBuf(m_looseData.get(), chunkSize);
}
r.seek(startPos + chunkSize, athena::Begin);
r.seek(startPos + chunkSize, athena::SeekOrigin::Begin);
}
}
}
@ -388,7 +388,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataDSP(SystemStringView dsp
athena::io::FileWriter w(dspPath, false);
if (!w.hasError()) {
w.seek(0, athena::Begin);
w.seek(0, athena::SeekOrigin::Begin);
head.write(w);
}
}
@ -397,7 +397,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataDSP(SystemStringView dsp
void AudioGroupSampleDirectory::EntryData::patchMetadataVADPCM(SystemStringView vadpcmPath) {
athena::io::FileWriter w(vadpcmPath, false);
if (!w.hasError()) {
w.seek(0, athena::Begin);
w.seek(0, athena::SeekOrigin::Begin);
VADPCMHeader header;
header.m_pitchSampleRate = m_pitch << 24;
header.m_pitchSampleRate |= m_sampleRate & 0xffff;
@ -434,12 +434,12 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav
loopOffset = startPos + 36;
++readSec;
}
r.seek(startPos + chunkSize, athena::Begin);
r.seek(startPos + chunkSize, athena::SeekOrigin::Begin);
}
if (smplOffset == -1 || loopOffset == -1) {
/* Complete rewrite of RIFF layout - new smpl chunk */
r.seek(12, athena::Begin);
r.seek(12, athena::SeekOrigin::Begin);
athena::io::FileWriter w(wavPath);
if (!w.hasError()) {
w.writeUint32Little(SBIG('RIFF'));
@ -470,7 +470,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav
loop.end = getLoopEndSample();
loop.write(w);
if (chunkMagic == SBIG('smpl')) {
r.seek(chunkSize, athena::Current);
r.seek(chunkSize, athena::SeekOrigin::Current);
continue;
}
}
@ -480,7 +480,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav
}
atUint64 wavLen = w.position();
w.seek(4, athena::Begin);
w.seek(4, athena::SeekOrigin::Begin);
w.writeUint32Little(wavLen - 8);
}
r.close();
@ -489,7 +489,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav
r.close();
athena::io::FileWriter w(wavPath, false);
if (!w.hasError()) {
w.seek(smplOffset, athena::Begin);
w.seek(smplOffset, athena::SeekOrigin::Begin);
WAVSampleChunk smpl;
smpl.smplPeriod = 1000000000 / fmt.sampleRate;
smpl.midiNote = m_pitch;
@ -810,7 +810,7 @@ void AudioGroupSampleDirectory::_extractCompressed(SampleId id, const EntryData&
samps += sampleCount;
}
w.seek(0, athena::Begin);
w.seek(0, athena::SeekOrigin::Begin);
header.write(w);
} else {
return;