mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-21 10:49:23 +00:00
Added functionality to determine what AGSC a sound ID belongs to
This commit is contained in:
30
src/Core/Resource/CAudioGroup.h
Normal file
30
src/Core/Resource/CAudioGroup.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef CAUDIOGROUP
|
||||
#define CAUDIOGROUP
|
||||
|
||||
#include "CResource.h"
|
||||
|
||||
// Very limited functionality - mostly just intended to find the AGSC that a sound ID belongs to
|
||||
class CAudioGroup : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eAudioGroup)
|
||||
friend class CAudioGroupLoader;
|
||||
|
||||
TString mGroupName;
|
||||
u32 mGroupID;
|
||||
std::vector<u16> mDefineIDs;
|
||||
|
||||
public:
|
||||
CAudioGroup(CResourceEntry *pEntry = 0)
|
||||
: CResource(pEntry)
|
||||
, mGroupID(-1)
|
||||
{}
|
||||
|
||||
// Accessors
|
||||
inline TString GroupName() const { return mGroupName; }
|
||||
inline u32 GroupID() const { return mGroupID; }
|
||||
inline u32 NumSoundDefineIDs() const { return mDefineIDs.size(); }
|
||||
inline u16 SoundDefineIDByIndex(u32 Index) const { return mDefineIDs[Index]; }
|
||||
};
|
||||
|
||||
#endif // CAUDIOGROUP
|
||||
|
||||
25
src/Core/Resource/CAudioLookupTable.h
Normal file
25
src/Core/Resource/CAudioLookupTable.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef CAUDIOLOOKUPTABLE
|
||||
#define CAUDIOLOOKUPTABLE
|
||||
|
||||
#include "CResource.h"
|
||||
|
||||
class CAudioLookupTable : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eAudioLookupTable)
|
||||
friend class CAudioGroupLoader;
|
||||
std::vector<u16> mDefineIDs;
|
||||
|
||||
public:
|
||||
CAudioLookupTable(CResourceEntry *pEntry = 0)
|
||||
: CResource(pEntry)
|
||||
{}
|
||||
|
||||
inline u16 FindSoundDefineID(u32 SoundID)
|
||||
{
|
||||
ASSERT(SoundID >= 0 && SoundID < mDefineIDs.size());
|
||||
return mDefineIDs[SoundID];
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CAUDIOLOOKUPTABLE
|
||||
|
||||
@@ -53,7 +53,7 @@ TString GetResourceTypeName(EResType Type)
|
||||
case eAreaSurfaceBounds: return "Area Surface Bounds";
|
||||
case eAreaOctree: return "Area Octree";
|
||||
case eAreaVisibilityTree: return "Area Visibility Tree";
|
||||
case eAudioGroupSet: return "Audio Group Set";
|
||||
case eAudioGroup: return "Audio Group Set";
|
||||
case eAudioMacro: return "Audio Macro";
|
||||
case eAudioSample: return "Audio Sample";
|
||||
case eAudioLookupTable: return "Audio Lookup Table";
|
||||
@@ -177,7 +177,7 @@ TString GetResourceCookedExtension(EResType Type, EGame Game)
|
||||
CResourceTypeRegistrant__##CookedExtension gResourceTypeRegistrant__##CookedExtension;
|
||||
|
||||
REGISTER_RESOURCE_TYPE(AFSM, eStateMachine, ePrimeDemo, eEchoes)
|
||||
REGISTER_RESOURCE_TYPE(AGSC, eAudioGroupSet, ePrimeDemo, eCorruptionProto)
|
||||
REGISTER_RESOURCE_TYPE(AGSC, eAudioGroup, ePrimeDemo, eCorruptionProto)
|
||||
REGISTER_RESOURCE_TYPE(ANCS, eAnimSet, ePrimeDemo, eEchoes)
|
||||
REGISTER_RESOURCE_TYPE(ANIM, eAnimation, ePrimeDemo, eReturns)
|
||||
REGISTER_RESOURCE_TYPE(ATBL, eAudioLookupTable, ePrimeDemo, eCorruption)
|
||||
|
||||
30
src/Core/Resource/CStringList.h
Normal file
30
src/Core/Resource/CStringList.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef CSTRINGLIST
|
||||
#define CSTRINGLIST
|
||||
|
||||
#include "CResource.h"
|
||||
|
||||
class CStringList : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eStringList)
|
||||
friend class CAudioGroupLoader;
|
||||
std::vector<TString> mStringList;
|
||||
|
||||
public:
|
||||
CStringList(CResourceEntry *pEntry = 0)
|
||||
: CResource(pEntry)
|
||||
{}
|
||||
|
||||
inline u32 NumStrings() const
|
||||
{
|
||||
return mStringList.size();
|
||||
}
|
||||
|
||||
inline TString StringByIndex(u32 Index) const
|
||||
{
|
||||
ASSERT(Index >= 0 && Index < mStringList.size());
|
||||
return mStringList[Index];
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CSTRINGLIST
|
||||
|
||||
@@ -18,7 +18,7 @@ enum EResType
|
||||
eAreaSurfaceBounds,
|
||||
eAreaOctree,
|
||||
eAreaVisibilityTree,
|
||||
eAudioGroupSet,
|
||||
eAudioGroup,
|
||||
eAudioMacro,
|
||||
eAudioSample,
|
||||
eAudioLookupTable,
|
||||
|
||||
78
src/Core/Resource/Factory/CAudioGroupLoader.cpp
Normal file
78
src/Core/Resource/Factory/CAudioGroupLoader.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
#include "CAudioGroupLoader.h"
|
||||
|
||||
CAudioGroup* CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CResourceEntry *pEntry)
|
||||
{
|
||||
// For now we only load sound define IDs and the group ID!
|
||||
// Version check
|
||||
u32 Check = rAGSC.PeekLong();
|
||||
EGame Game = (Check == 0x1 ? eEchoes : ePrime);
|
||||
CAudioGroup *pOut = new CAudioGroup(pEntry);
|
||||
|
||||
// Read header, navigate to Proj chunk
|
||||
if (Game == ePrime)
|
||||
{
|
||||
rAGSC.ReadString();
|
||||
pOut->mGroupName = rAGSC.ReadString();
|
||||
u32 PoolSize = rAGSC.ReadLong();
|
||||
rAGSC.Seek(PoolSize + 0x4, SEEK_CUR);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
rAGSC.Seek(0x4, SEEK_CUR);
|
||||
pOut->mGroupName = rAGSC.ReadString();
|
||||
pOut->mGroupID = rAGSC.ReadShort();
|
||||
u32 PoolSize = rAGSC.ReadLong();
|
||||
rAGSC.Seek(0xC + PoolSize, SEEK_CUR);
|
||||
}
|
||||
|
||||
// Read needed data from the Proj chunk
|
||||
u32 ProjStart = rAGSC.Tell();
|
||||
rAGSC.Seek(0x4, SEEK_CUR);
|
||||
u16 GroupID = rAGSC.ReadShort();
|
||||
u16 GroupType = rAGSC.ReadShort();
|
||||
rAGSC.Seek(0x14, SEEK_CUR);
|
||||
u32 SfxTableStart = rAGSC.ReadLong();
|
||||
|
||||
if (Game == ePrime)
|
||||
pOut->mGroupID = GroupID;
|
||||
else
|
||||
ASSERT(pOut->mGroupID == GroupID);
|
||||
|
||||
if (GroupType == 1)
|
||||
{
|
||||
rAGSC.Seek(ProjStart + SfxTableStart, SEEK_SET);
|
||||
u16 NumSounds = rAGSC.ReadShort();
|
||||
rAGSC.Seek(0x2, SEEK_CUR);
|
||||
|
||||
for (u32 iSfx = 0; iSfx < NumSounds; iSfx++)
|
||||
{
|
||||
pOut->mDefineIDs.push_back( rAGSC.ReadShort() );
|
||||
rAGSC.Seek(0x8, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
||||
return pOut;
|
||||
}
|
||||
|
||||
CAudioLookupTable* CAudioGroupLoader::LoadATBL(IInputStream& rATBL, CResourceEntry *pEntry)
|
||||
{
|
||||
CAudioLookupTable *pOut = new CAudioLookupTable(pEntry);
|
||||
u32 NumMacroIDs = rATBL.ReadLong();
|
||||
|
||||
for (u32 iMacro = 0; iMacro < NumMacroIDs; iMacro++)
|
||||
pOut->mDefineIDs.push_back( rATBL.ReadShort() );
|
||||
|
||||
return pOut;
|
||||
}
|
||||
|
||||
CStringList* CAudioGroupLoader::LoadSTLC(IInputStream& rSTLC, CResourceEntry *pEntry)
|
||||
{
|
||||
CStringList *pOut = new CStringList(pEntry);
|
||||
u32 NumStrings = rSTLC.ReadLong();
|
||||
|
||||
for (u32 iStr = 0; iStr < NumStrings; iStr++)
|
||||
pOut->mStringList[iStr] = rSTLC.ReadString();
|
||||
|
||||
return pOut;
|
||||
}
|
||||
18
src/Core/Resource/Factory/CAudioGroupLoader.h
Normal file
18
src/Core/Resource/Factory/CAudioGroupLoader.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef CAUDIOGROUPLOADER_H
|
||||
#define CAUDIOGROUPLOADER_H
|
||||
|
||||
#include "Core/Resource/CAudioGroup.h"
|
||||
#include "Core/Resource/CAudioLookupTable.h"
|
||||
#include "Core/Resource/CStringList.h"
|
||||
|
||||
class CAudioGroupLoader
|
||||
{
|
||||
CAudioGroupLoader() {}
|
||||
|
||||
public:
|
||||
static CAudioGroup* LoadAGSC(IInputStream& rAGSC, CResourceEntry *pEntry);
|
||||
static CAudioLookupTable* LoadATBL(IInputStream& rATBL, CResourceEntry *pEntry);
|
||||
static CStringList* LoadSTLC(IInputStream& rSTLC, CResourceEntry *pEntry);
|
||||
};
|
||||
|
||||
#endif // CAUDIOGROUPLOADER_H
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "CAnimationLoader.h"
|
||||
#include "CAnimSetLoader.h"
|
||||
#include "CAreaLoader.h"
|
||||
#include "CAudioGroupLoader.h"
|
||||
#include "CCollisionLoader.h"
|
||||
#include "CDependencyGroupLoader.h"
|
||||
#include "CFontLoader.h"
|
||||
@@ -35,6 +36,8 @@ public:
|
||||
case eAnimation: return new CAnimation(pEntry);
|
||||
case eAnimSet: return new CAnimSet(pEntry);
|
||||
case eArea: return new CGameArea(pEntry);
|
||||
case eAudioGroup: return new CAudioGroup(pEntry);
|
||||
case eAudioLookupTable: return new CAudioLookupTable(pEntry);
|
||||
case eDynamicCollision: return new CCollisionMeshGroup(pEntry);
|
||||
case eDependencyGroup: return new CDependencyGroup(pEntry);
|
||||
case eFont: return new CFont(pEntry);
|
||||
@@ -43,6 +46,7 @@ public:
|
||||
case eSkeleton: return new CSkeleton(pEntry);
|
||||
case eSkin: return new CSkin(pEntry);
|
||||
case eStaticGeometryMap: return new CPoiToWorld(pEntry);
|
||||
case eStringList: return new CStringList(pEntry);
|
||||
case eStringTable: return new CStringTable(pEntry);
|
||||
case eTexture: return new CTexture(pEntry);
|
||||
case eWorld: return new CWorld(pEntry);
|
||||
@@ -54,7 +58,6 @@ public:
|
||||
{
|
||||
// Warning: It is the caller's responsibility to check if the required resource is already in memory before calling this function.
|
||||
if (!rInput.IsValid()) return nullptr;
|
||||
|
||||
CResource *pRes = nullptr;
|
||||
|
||||
switch (pEntry->ResourceType())
|
||||
@@ -63,6 +66,8 @@ public:
|
||||
case eAnimEventData: pRes = CUnsupportedFormatLoader::LoadEVNT(rInput, pEntry); break;
|
||||
case eAnimSet: pRes = CAnimSetLoader::LoadANCSOrCHAR(rInput, pEntry); break;
|
||||
case eArea: pRes = CAreaLoader::LoadMREA(rInput, pEntry); break;
|
||||
case eAudioGroup: pRes = CAudioGroupLoader::LoadAGSC(rInput, pEntry); break;
|
||||
case eAudioLookupTable: pRes = CAudioGroupLoader::LoadATBL(rInput, pEntry); break;
|
||||
case eDependencyGroup: pRes = CDependencyGroupLoader::LoadDGRP(rInput, pEntry); break;
|
||||
case eDynamicCollision: pRes = CCollisionLoader::LoadDCLN(rInput, pEntry); break;
|
||||
case eFont: pRes = CFontLoader::LoadFONT(rInput, pEntry); break;
|
||||
@@ -78,6 +83,7 @@ public:
|
||||
case eSkin: pRes = CSkinLoader::LoadCSKR(rInput, pEntry); break;
|
||||
case eStateMachine2: pRes = CUnsupportedFormatLoader::LoadFSM2(rInput, pEntry); break;
|
||||
case eStaticGeometryMap: pRes = CPoiToWorldLoader::LoadEGMC(rInput, pEntry); break;
|
||||
case eStringList: pRes = CAudioGroupLoader::LoadSTLC(rInput, pEntry); break;
|
||||
case eStringTable: pRes = CStringLoader::LoadSTRG(rInput, pEntry); break;
|
||||
case eTexture: pRes = CTextureDecoder::LoadTXTR(rInput, pEntry); break;
|
||||
case eWorld: pRes = CWorldLoader::LoadMLVL(rInput, pEntry); break;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define TRESPTR_H
|
||||
|
||||
#include "CResource.h"
|
||||
#include "Core/GameProject/CGameProject.h"
|
||||
|
||||
template <typename ResType>
|
||||
class TResPtr
|
||||
|
||||
Reference in New Issue
Block a user