diff --git a/output.bin b/output.bin index 9b8443c..6dc40e7 100644 Binary files a/output.bin and b/output.bin differ diff --git a/src/gameobject.hh b/src/gameobject.hh index e89c530..9fd59d5 100644 --- a/src/gameobject.hh +++ b/src/gameobject.hh @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -7,7 +8,11 @@ namespace psxsplash { +// LSB is active in flags + class GameObject final { + typedef Utilities::BitSpan IsActive; + typedef Utilities::BitField GameObjectFlags; public: union { Tri *polygons; @@ -15,8 +20,15 @@ class GameObject final { }; psyqo::Vec3 position; psyqo::Matrix33 rotation; + // linear & angular velocity placeholders uint16_t polyCount; int16_t luaFileIndex; + union { + GameObjectFlags flags; + uint32_t flagsAsInt; + }; + bool isActive() const { return flags.get(); } + void setActive(bool active) { flags.set(active); } }; -static_assert(sizeof(GameObject) == 56, "GameObject is not 56 bytes"); +static_assert(sizeof(GameObject) == 60, "GameObject is not 56 bytes"); } // namespace psxsplash \ No newline at end of file diff --git a/src/scenemanager.hh b/src/scenemanager.hh index 7f3e399..3991600 100644 --- a/src/scenemanager.hh +++ b/src/scenemanager.hh @@ -21,6 +21,7 @@ class SceneManager { psxsplash::Lua L; psxsplash::SplashPackLoader m_loader; + eastl::vector m_luaFiles; eastl::vector m_gameObjects; eastl::vector m_navmeshes; diff --git a/src/splashpack.cpp b/src/splashpack.cpp index 0aaee1a..593f60a 100644 --- a/src/splashpack.cpp +++ b/src/splashpack.cpp @@ -25,7 +25,8 @@ struct SPLASHPACKFileHeader { psyqo::GTE::PackedVec3 playerStartPos; psyqo::GTE::PackedVec3 playerStartRot; psyqo::FixedPoint<12, uint16_t> playerHeight; - uint16_t pad[2]; + uint16_t sceneLuaFileIndex; + uint16_t pad; }; struct SPLASHPACKTextureAtlas { @@ -64,6 +65,8 @@ void SplashPackLoader::LoadSplashpack(uint8_t *data, SplashpackSceneSetup &setup curentPointer += sizeof(psxsplash::LuaFile); } + setup.sceneLuaFile = setup.luaFiles[header->sceneLuaFileIndex]; + for (uint16_t i = 0; i < header->gameObjectCount; i++) { psxsplash::GameObject *go = reinterpret_cast(curentPointer); go->polygons = reinterpret_cast(data + go->polygonsOffset); diff --git a/src/splashpack.hh b/src/splashpack.hh index 080dca1..0a8c360 100644 --- a/src/splashpack.hh +++ b/src/splashpack.hh @@ -11,6 +11,7 @@ namespace psxsplash { struct SplashpackSceneSetup { + LuaFile* sceneLuaFile; eastl::vector luaFiles; eastl::vector objects; eastl::vector navmeshes;