Added basic lua wrapper, currently can't retrieve from registry
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <psyqo/primitives/common.hh>
|
||||
|
||||
#include "gameobject.hh"
|
||||
#include "lua.h"
|
||||
#include "mesh.hh"
|
||||
#include "psyqo/fixed-point.hh"
|
||||
#include "psyqo/gte-registers.hh"
|
||||
@@ -15,6 +16,7 @@ namespace psxsplash {
|
||||
struct SPLASHPACKFileHeader {
|
||||
char magic[2];
|
||||
uint16_t version;
|
||||
uint16_t luaFileCount;
|
||||
uint16_t gameObjectCount;
|
||||
uint16_t navmeshCount;
|
||||
uint16_t textureAtlasCount;
|
||||
@@ -22,7 +24,15 @@ struct SPLASHPACKFileHeader {
|
||||
psyqo::GTE::PackedVec3 playerStartPos;
|
||||
psyqo::GTE::PackedVec3 playerStartRot;
|
||||
psyqo::FixedPoint<12, uint16_t> playerHeight;
|
||||
uint16_t pad[1];
|
||||
uint16_t pad[2];
|
||||
};
|
||||
|
||||
struct SPLASHPACKLuaFile {
|
||||
union {
|
||||
uint32_t luaCodeOffset;
|
||||
const char* luaCode;
|
||||
};
|
||||
uint32_t length;
|
||||
};
|
||||
|
||||
struct SPLASHPACKTextureAtlas {
|
||||
@@ -39,7 +49,7 @@ struct SPLASHPACKClut {
|
||||
uint16_t pad;
|
||||
};
|
||||
|
||||
void SplashPackLoader::LoadSplashpack(uint8_t *data) {
|
||||
void SplashPackLoader::LoadSplashpack(uint8_t *data, psxsplash::Lua &lua) {
|
||||
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");
|
||||
@@ -53,9 +63,17 @@ void SplashPackLoader::LoadSplashpack(uint8_t *data) {
|
||||
|
||||
uint8_t *curentPointer = data + sizeof(psxsplash::SPLASHPACKFileHeader);
|
||||
|
||||
for (uint16_t i = 0; i < header->luaFileCount; i++) {
|
||||
psxsplash::SPLASHPACKLuaFile *luaHeader = reinterpret_cast<psxsplash::SPLASHPACKLuaFile *>(curentPointer);
|
||||
luaHeader->luaCode = reinterpret_cast<const char*>(data + luaHeader->luaCodeOffset);
|
||||
lua.LoadLuaFile(luaHeader->luaCode, luaHeader->length);
|
||||
curentPointer += sizeof(psxsplash::SPLASHPACKLuaFile);
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < header->gameObjectCount; i++) {
|
||||
psxsplash::GameObject *go = reinterpret_cast<psxsplash::GameObject *>(curentPointer);
|
||||
go->polygons = reinterpret_cast<psxsplash::Tri *>(data + go->polygonsOffset);
|
||||
lua.RegisterGameObject(go);
|
||||
gameObjects.push_back(go);
|
||||
curentPointer += sizeof(psxsplash::GameObject);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user