mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-21 19:45:10 +00:00
Added rooms parsing to DynOS level gen
This commit is contained in:
parent
df346a902a
commit
c0b0debf0b
8 changed files with 112 additions and 2 deletions
|
@ -33,6 +33,7 @@ enum {
|
|||
DATA_TYPE_TRAJECTORY,
|
||||
DATA_TYPE_MOVTEX,
|
||||
DATA_TYPE_MOVTEXQC,
|
||||
DATA_TYPE_ROOMS,
|
||||
DATA_TYPE_UNUSED,
|
||||
};
|
||||
|
||||
|
@ -434,6 +435,7 @@ struct GfxData : NoCopy {
|
|||
DataNodes<Trajectory> mTrajectories;
|
||||
DataNodes<Movtex> mMovtexs;
|
||||
DataNodes<MovtexQC> mMovtexQCs;
|
||||
DataNodes<u8> mRooms;
|
||||
|
||||
// Animation data
|
||||
Array<AnimBuffer<s16> *> mAnimValues;
|
||||
|
@ -773,6 +775,10 @@ DataNode<MovtexQC>* DynOS_MovtexQC_Parse(GfxData* aGfxData, DataNode<MovtexQC>*
|
|||
void DynOS_MovtexQC_Write(FILE* aFile, GfxData* aGfxData, DataNode<MovtexQC> *aNode);
|
||||
DataNode<MovtexQC>* DynOS_MovtexQC_Load(FILE *aFile, GfxData *aGfxData);
|
||||
|
||||
DataNode<u8>* DynOS_Rooms_Parse(GfxData* aGfxData, DataNode<u8>* aNode);
|
||||
void DynOS_Rooms_Write(FILE* aFile, GfxData* aGfxData, DataNode<u8> *aNode);
|
||||
DataNode<u8>* DynOS_Rooms_Load(FILE *aFile, GfxData *aGfxData);
|
||||
|
||||
DataNode<TexData>* DynOS_Tex_Parse(GfxData* aGfxData, DataNode<TexData>* aNode);
|
||||
void DynOS_Tex_Write(FILE* aFile, GfxData* aGfxData, DataNode<TexData> *aNode);
|
||||
void DynOS_Tex_Load(FILE *aFile, GfxData *aGfxData);
|
||||
|
|
|
@ -658,7 +658,9 @@ static void ParseGfxSymbol(GfxData* aGfxData, DataNode<Gfx>* aNode, Gfx*& aHead,
|
|||
gfx_symbol_4(gsDPSetFogColor);
|
||||
gfx_symbol_2(gsSPFogPosition, false);
|
||||
gfx_symbol_1(gsDPSetAlphaCompare, false);
|
||||
|
||||
gfx_symbol_2(gsSPCopyLightEXT, false);
|
||||
gfx_symbol_2(gsSPFogFactor, false);
|
||||
|
||||
// Special symbols
|
||||
if (_Symbol == "gsSPTexture") {
|
||||
|
|
|
@ -1456,6 +1456,13 @@ static LevelScript ParseLevelScriptSymbolArg(GfxData* aGfxData, DataNode<LevelSc
|
|||
}
|
||||
}
|
||||
|
||||
// Rooms
|
||||
for (auto& _Node : aGfxData->mRooms) {
|
||||
if (_Arg == _Node->mName) {
|
||||
return (LevelScript) DynOS_Rooms_Parse(aGfxData, _Node)->mData;
|
||||
}
|
||||
}
|
||||
|
||||
// Integers
|
||||
s32 x;
|
||||
if ((_Arg[1] == 'x' && sscanf(_Arg.begin(), "%x", &x) == 1) || (sscanf(_Arg.begin(), "%d", &x) == 1)) {
|
||||
|
@ -1825,6 +1832,11 @@ static bool DynOS_Lvl_WriteBinary(const SysPath &aOutputFilename, GfxData *aGfxD
|
|||
DynOS_MovtexQC_Write(_File, aGfxData, _Node);
|
||||
}
|
||||
}
|
||||
for (auto &_Node : aGfxData->mRooms) {
|
||||
if (_Node->mLoadIndex == i) {
|
||||
DynOS_Rooms_Write(_File, aGfxData, _Node);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(_File);
|
||||
return true;
|
||||
|
@ -1884,6 +1896,10 @@ GfxData *DynOS_Lvl_LoadFromBinary(const SysPath &aPackFolder, const char *aLevel
|
|||
case DATA_TYPE_COLLISION: DynOS_Col_Load (_File, _GfxData); break;
|
||||
case DATA_TYPE_LEVEL_SCRIPT: DynOS_Lvl_Load (_File, _GfxData); break;
|
||||
case DATA_TYPE_MACRO_OBJECT: DynOS_MacroObject_Load(_File, _GfxData); break;
|
||||
case DATA_TYPE_TRAJECTORY: DynOS_Trajectory_Load (_File, _GfxData); break;
|
||||
case DATA_TYPE_MOVTEX: DynOS_Movtex_Load (_File, _GfxData); break;
|
||||
case DATA_TYPE_MOVTEXQC: DynOS_MovtexQC_Load (_File, _GfxData); break;
|
||||
case DATA_TYPE_ROOMS: DynOS_Rooms_Load (_File, _GfxData); break;
|
||||
default: _Done = true; break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,13 @@ static PointerData GetDataFromPointer(const void* aPtr, GfxData* aGfxData) {
|
|||
}
|
||||
}
|
||||
|
||||
// Rooms
|
||||
for (auto& _Node : aGfxData->mRooms) {
|
||||
if (_Node->mData == aPtr) {
|
||||
return { _Node->mName, 0 };
|
||||
}
|
||||
}
|
||||
|
||||
// Behaviors
|
||||
enum BehaviorId id = get_id_from_vanilla_behavior((const BehaviorScript*) aPtr);
|
||||
if (id >= 0 && id < id_bhv_max_count) {
|
||||
|
@ -270,6 +277,13 @@ static void *GetPointerFromData(GfxData *aGfxData, const String &aPtrName, u32 a
|
|||
}
|
||||
}
|
||||
|
||||
// Rooms
|
||||
for (auto &_Node : aGfxData->mRooms) {
|
||||
if (_Node->mName == aPtrName) {
|
||||
return (void *) _Node->mData;
|
||||
}
|
||||
}
|
||||
|
||||
// Behaviors
|
||||
enum BehaviorId id = get_id_from_behavior_name(aPtrName.begin());
|
||||
if (id >= 0 && id < id_bhv_max_count) {
|
||||
|
|
|
@ -15,6 +15,7 @@ static IfDefPtr GetNearestIfDefPointer(char *pFileBuffer) {
|
|||
{ "#ifndef VERSION_JP", 18, false },
|
||||
{ "#ifdef VERSION_EU", 17, true },
|
||||
{ "#ifdef TEXTURE_FIX", 18, false },
|
||||
{ "#if defined(VERSION_JP) || defined(VERSION_SH)", 47, false },
|
||||
};
|
||||
IfDefPtr _Nearest = { NULL, 0, false };
|
||||
for (const auto &_IfDef : sIfDefs) {
|
||||
|
@ -178,7 +179,9 @@ void DynOS_Read_Source(GfxData *aGfxData, const SysPath &aFilename) {
|
|||
} else if (_Buffer == "Lights1") {
|
||||
_DataType = DATA_TYPE_LIGHT;
|
||||
} else if (_Buffer == "u8") {
|
||||
_DataType = DATA_TYPE_TEXTURE;
|
||||
_DataType = strstr(aFilename.c_str(), "room")
|
||||
? DATA_TYPE_ROOMS
|
||||
: DATA_TYPE_TEXTURE;
|
||||
} else if (_Buffer == "Texture") {
|
||||
_DataType = DATA_TYPE_TEXTURE;
|
||||
} else if (_Buffer == "Vtx") {
|
||||
|
@ -228,6 +231,7 @@ void DynOS_Read_Source(GfxData *aGfxData, const SysPath &aFilename) {
|
|||
case DATA_TYPE_TRAJECTORY: AppendNewNode(aGfxData, aGfxData->mTrajectories, _Buffer, pDataName, pDataTokens); break;
|
||||
case DATA_TYPE_MOVTEX: AppendNewNode(aGfxData, aGfxData->mMovtexs, _Buffer, pDataName, pDataTokens); break;
|
||||
case DATA_TYPE_MOVTEXQC: AppendNewNode(aGfxData, aGfxData->mMovtexQCs, _Buffer, pDataName, pDataTokens); break;
|
||||
case DATA_TYPE_ROOMS: AppendNewNode(aGfxData, aGfxData->mRooms, _Buffer, pDataName, pDataTokens); break;
|
||||
case DATA_TYPE_UNUSED: pDataTokens = (Array<String> *) 1; break;
|
||||
}
|
||||
_Buffer.Clear();
|
||||
|
|
64
data/dynos_bin_rooms.cpp
Normal file
64
data/dynos_bin_rooms.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
#include "dynos.cpp.h"
|
||||
|
||||
extern "C" {
|
||||
}
|
||||
|
||||
/////////////
|
||||
// Parsing //
|
||||
/////////////
|
||||
|
||||
DataNode<u8>* DynOS_Rooms_Parse(GfxData* aGfxData, DataNode<u8>* aNode) {
|
||||
if (aNode->mData) return aNode;
|
||||
|
||||
// U8 data
|
||||
aNode->mSize = (u32) (aNode->mTokens.Count());
|
||||
aNode->mData = New<u8>(aNode->mSize);
|
||||
for (u32 i = 0; i != aNode->mSize; ++i) {
|
||||
aNode->mData[i] = (u8) aNode->mTokens[i].ParseInt();
|
||||
}
|
||||
aNode->mLoadIndex = aGfxData->mLoadIndex++;
|
||||
return aNode;
|
||||
}
|
||||
|
||||
/////////////
|
||||
// Writing //
|
||||
/////////////
|
||||
|
||||
void DynOS_Rooms_Write(FILE* aFile, GfxData* aGfxData, DataNode<u8> *aNode) {
|
||||
if (!aNode->mData) return;
|
||||
|
||||
// Name
|
||||
WriteBytes<u8>(aFile, DATA_TYPE_ROOMS);
|
||||
aNode->mName.Write(aFile);
|
||||
|
||||
// Data
|
||||
WriteBytes<u32>(aFile, aNode->mSize);
|
||||
for (u32 i = 0; i != aNode->mSize; ++i) {
|
||||
WriteBytes<u8>(aFile, aNode->mData[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////
|
||||
// Reading //
|
||||
/////////////
|
||||
|
||||
DataNode<u8>* DynOS_Rooms_Load(FILE *aFile, GfxData *aGfxData) {
|
||||
DataNode<u8> *_Node = New<DataNode<u8>>();
|
||||
|
||||
// Name
|
||||
_Node->mName.Read(aFile);
|
||||
|
||||
// Data
|
||||
_Node->mSize = ReadBytes<u32>(aFile);
|
||||
_Node->mData = New<u8>(_Node->mSize);
|
||||
for (u32 i = 0; i != _Node->mSize; ++i) {
|
||||
_Node->mData[i] = ReadBytes<u8>(aFile);
|
||||
}
|
||||
|
||||
// Add it
|
||||
if (aGfxData != NULL) {
|
||||
aGfxData->mRooms.Add(_Node);
|
||||
}
|
||||
|
||||
return _Node;
|
||||
}
|
|
@ -54,6 +54,10 @@ void DynOS_Gfx_Free(GfxData* aGfxData) {
|
|||
Delete(_Node->mData);
|
||||
Delete(_Node);
|
||||
}
|
||||
for (auto& _Node : aGfxData->mRooms) {
|
||||
Delete(_Node->mData);
|
||||
Delete(_Node);
|
||||
}
|
||||
Delete(aGfxData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ s32 DynOS_Level_GetCourse(s32 aLevel) {
|
|||
|
||||
const void *DynOS_Level_GetScript(s32 aLevel) {
|
||||
DynOS_Level_Init();
|
||||
return DynOS_Lvl_Get("level_bob_entry"); // DO NOT COMMIT
|
||||
return DynOS_Lvl_Get("level_jrb_entry"); // DO NOT COMMIT
|
||||
return sDynosLevelScripts[aLevel];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue