FPS cam movement, dynamic subdivision, Navmeshes
This commit is contained in:
@@ -10,13 +10,37 @@
|
||||
|
||||
namespace psxsplash {
|
||||
|
||||
eastl::vector<psxsplash::GameObject *> LoadSplashpack(uint8_t *data) {
|
||||
struct SPLASHPACKFileHeader {
|
||||
char magic[2];
|
||||
uint16_t version;
|
||||
uint16_t gameObjectCount;
|
||||
uint16_t navmeshCount;
|
||||
uint16_t textureAtlasCount;
|
||||
uint16_t clutCount;
|
||||
uint16_t pad[2];
|
||||
};
|
||||
|
||||
struct SPLASHPACKTextureAtlas {
|
||||
uint32_t polygonsOffset;
|
||||
uint16_t width, height;
|
||||
uint16_t x, y;
|
||||
};
|
||||
|
||||
struct SPLASHPACKClut {
|
||||
uint32_t clutOffset;
|
||||
uint16_t clutPackingX;
|
||||
uint16_t clutPackingY;
|
||||
uint16_t length;
|
||||
uint16_t pad;
|
||||
};
|
||||
|
||||
void SplashPackLoader::LoadSplashpack(uint8_t *data) {
|
||||
psyqo::Kernel::assert(data != nullptr, "Splashpack loading data pointer is null");
|
||||
psxsplash::SPLASHPACKFileHeader *header = reinterpret_cast<psxsplash::SPLASHPACKFileHeader *>(data);
|
||||
psyqo::Kernel::assert(memcmp(header->magic, "SP", 2) == 0, "Splashpack has incorrect magic");
|
||||
|
||||
eastl::vector<psxsplash::GameObject *> gameObjects;
|
||||
gameObjects.reserve(header->gameObjectCount);
|
||||
navmeshes.reserve(header->navmeshCount);
|
||||
|
||||
uint8_t *curentPointer = data + sizeof(psxsplash::SPLASHPACKFileHeader);
|
||||
|
||||
@@ -27,23 +51,28 @@ eastl::vector<psxsplash::GameObject *> LoadSplashpack(uint8_t *data) {
|
||||
curentPointer += sizeof(psxsplash::GameObject);
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < header->navmeshCount; i++) {
|
||||
psxsplash::Navmesh *navmesh = reinterpret_cast<psxsplash::Navmesh *>(curentPointer);
|
||||
navmesh->polygons = reinterpret_cast<psxsplash::NavMeshTri *>(data + navmesh->polygonsOffset);
|
||||
navmeshes.push_back(navmesh);
|
||||
curentPointer += sizeof(psxsplash::Navmesh);
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < header->textureAtlasCount; i++) {
|
||||
psxsplash::SPLASHPACKTextureAtlas *atlas = reinterpret_cast<psxsplash::SPLASHPACKTextureAtlas *>(curentPointer);
|
||||
|
||||
uint8_t *offsetData = data + atlas->polygonsOffset;
|
||||
uint8_t *offsetData = data + atlas->polygonsOffset;
|
||||
uint16_t *castedData = reinterpret_cast<uint16_t *>(offsetData);
|
||||
psxsplash::Renderer::getInstance().vramUpload(castedData, atlas->x, atlas->y, atlas->width, atlas->height);
|
||||
psxsplash::Renderer::GetInstance().VramUpload(castedData, atlas->x, atlas->y, atlas->width, atlas->height);
|
||||
curentPointer += sizeof(psxsplash::SPLASHPACKTextureAtlas);
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < header->clutCount; i++) {
|
||||
psxsplash::SPLASHPACKClut *clut = reinterpret_cast<psxsplash::SPLASHPACKClut *>(curentPointer);
|
||||
uint8_t* clutOffset = data + clut->clutOffset;
|
||||
psxsplash::Renderer::getInstance().vramUpload((uint16_t*) clutOffset, clut->clutPackingX * 16, clut->clutPackingY, clut->length, 1);
|
||||
uint8_t *clutOffset = data + clut->clutOffset;
|
||||
psxsplash::Renderer::GetInstance().VramUpload((uint16_t *)clutOffset, clut->clutPackingX * 16,
|
||||
clut->clutPackingY, clut->length, 1);
|
||||
curentPointer += sizeof(psxsplash::SPLASHPACKClut);
|
||||
}
|
||||
|
||||
return gameObjects;
|
||||
}
|
||||
|
||||
} // namespace psxsplash
|
||||
|
||||
Reference in New Issue
Block a user