Splashpack fixes, rendering from splaspack now works
This commit is contained in:
@@ -7,8 +7,8 @@
|
|||||||
#include "psyqo/gpu.hh"
|
#include "psyqo/gpu.hh"
|
||||||
#include "psyqo/scene.hh"
|
#include "psyqo/scene.hh"
|
||||||
|
|
||||||
#include "renderer.hh"
|
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
|
#include "renderer.hh"
|
||||||
#include "splashpack.hh"
|
#include "splashpack.hh"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -25,7 +25,7 @@ class PSXSplash final : public psyqo::Application {
|
|||||||
class MainScene final : public psyqo::Scene {
|
class MainScene final : public psyqo::Scene {
|
||||||
void frame() override;
|
void frame() override;
|
||||||
void start(StartReason reason) override;
|
void start(StartReason reason) override;
|
||||||
eastl::vector<psxsplash::GameObject*> objects;
|
eastl::vector<psxsplash::GameObject *> objects;
|
||||||
};
|
};
|
||||||
|
|
||||||
PSXSplash psxSplash;
|
PSXSplash psxSplash;
|
||||||
@@ -48,7 +48,6 @@ void PSXSplash::createScene() {
|
|||||||
pushScene(&mainScene);
|
pushScene(&mainScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainScene::start(StartReason reason) {
|
void MainScene::start(StartReason reason) {
|
||||||
objects = psxsplash::LoadSplashpack(bin2c_output_bin);
|
objects = psxsplash::LoadSplashpack(bin2c_output_bin);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -4,6 +4,7 @@
|
|||||||
#include "psyqo/fixed-point.hh"
|
#include "psyqo/fixed-point.hh"
|
||||||
#include "psyqo/gte-kernels.hh"
|
#include "psyqo/gte-kernels.hh"
|
||||||
#include "psyqo/gte-registers.hh"
|
#include "psyqo/gte-registers.hh"
|
||||||
|
#include "psyqo/primitives/common.hh"
|
||||||
#include "psyqo/primitives/triangles.hh"
|
#include "psyqo/primitives/triangles.hh"
|
||||||
#include "psyqo/soft-math.hh"
|
#include "psyqo/soft-math.hh"
|
||||||
#include "psyqo/trigonometry.hh"
|
#include "psyqo/trigonometry.hh"
|
||||||
@@ -54,18 +55,11 @@ void psxsplash::Renderer::render(eastl::vector<GameObject *> &objects) {
|
|||||||
|
|
||||||
for (auto &obj : objects) {
|
for (auto &obj : objects) {
|
||||||
|
|
||||||
/*psyqo::GTE::write<psyqo::GTE::Register::TRX, psyqo::GTE::Unsafe>(
|
auto transform = psyqo::SoftMath::generateRotationMatrix33(
|
||||||
obj->position.x.raw());
|
0, psyqo::SoftMath::Axis::X, m_trig);
|
||||||
psyqo::GTE::write<psyqo::GTE::Register::TRY, psyqo::GTE::Unsafe>(
|
|
||||||
obj->position.y.raw());
|
|
||||||
|
|
||||||
|
|
||||||
psyqo::GTE::writeUnsafe<psyqo::GTE::PseudoRegister::Rotation>(
|
psyqo::GTE::writeUnsafe<psyqo::GTE::PseudoRegister::Rotation>(
|
||||||
obj->rotation);*/
|
transform);
|
||||||
|
|
||||||
psyqo::GTE::write<psyqo::GTE::Register::TRZ, psyqo::GTE::Unsafe>(1024);
|
|
||||||
psyqo::GTE::writeUnsafe<psyqo::GTE::PseudoRegister::Rotation>(
|
|
||||||
obj->rotation);
|
|
||||||
for (int i = 0; i < obj->polyCount; i++) {
|
for (int i = 0; i < obj->polyCount; i++) {
|
||||||
|
|
||||||
Tri &tri = obj->polygons[i];
|
Tri &tri = obj->polygons[i];
|
||||||
@@ -80,23 +74,24 @@ void psxsplash::Renderer::render(eastl::vector<GameObject *> &objects) {
|
|||||||
int32_t mac0 = 0;
|
int32_t mac0 = 0;
|
||||||
psyqo::GTE::read<psyqo::GTE::Register::MAC0>(
|
psyqo::GTE::read<psyqo::GTE::Register::MAC0>(
|
||||||
reinterpret_cast<uint32_t *>(&mac0));
|
reinterpret_cast<uint32_t *>(&mac0));
|
||||||
// if (mac0 <= 0)
|
if (mac0 <= 0)
|
||||||
// continue;
|
continue;
|
||||||
|
|
||||||
psyqo::GTE::Kernels::avsz3();
|
psyqo::GTE::Kernels::avsz3();
|
||||||
int32_t zIndex = 0;
|
int32_t zIndex = 0;
|
||||||
psyqo::GTE::read<psyqo::GTE::Register::OTZ>(
|
psyqo::GTE::read<psyqo::GTE::Register::OTZ>(
|
||||||
reinterpret_cast<uint32_t *>(&zIndex));
|
reinterpret_cast<uint32_t *>(&zIndex));
|
||||||
// if (zIndex < 0 || zIndex >= ORDERING_TABLE_SIZE)
|
if (zIndex < 0 || zIndex >= ORDERING_TABLE_SIZE)
|
||||||
// continue;
|
continue;
|
||||||
|
|
||||||
psyqo::GTE::read<psyqo::GTE::Register::SXY0>(&projected[0].packed);
|
psyqo::GTE::read<psyqo::GTE::Register::SXY0>(&projected[0].packed);
|
||||||
psyqo::GTE::read<psyqo::GTE::Register::SXY1>(&projected[1].packed);
|
psyqo::GTE::read<psyqo::GTE::Register::SXY1>(&projected[1].packed);
|
||||||
psyqo::GTE::read<psyqo::GTE::Register::SXY2>(&projected[2].packed);
|
psyqo::GTE::read<psyqo::GTE::Register::SXY2>(&projected[2].packed);
|
||||||
|
|
||||||
auto &prim =
|
auto &prim =
|
||||||
balloc.allocateFragment<psyqo::Prim::TexturedTriangle>();
|
balloc.allocateFragment<psyqo::Prim::GouraudTexturedTriangle>();
|
||||||
|
|
||||||
|
|
||||||
prim.primitive.pointA = projected[0];
|
prim.primitive.pointA = projected[0];
|
||||||
prim.primitive.pointB = projected[1];
|
prim.primitive.pointB = projected[1];
|
||||||
prim.primitive.pointC = projected[2];
|
prim.primitive.pointC = projected[2];
|
||||||
@@ -104,8 +99,11 @@ void psxsplash::Renderer::render(eastl::vector<GameObject *> &objects) {
|
|||||||
prim.primitive.uvB = tri.uvB;
|
prim.primitive.uvB = tri.uvB;
|
||||||
prim.primitive.uvC = tri.uvC;
|
prim.primitive.uvC = tri.uvC;
|
||||||
prim.primitive.tpage = obj->texture;
|
prim.primitive.tpage = obj->texture;
|
||||||
prim.primitive.tpage.setPageX(5);
|
prim.primitive.tpage.setDithering(true);
|
||||||
prim.primitive.tpage.setPageY(0);
|
prim.primitive.setColorA(tri.colorA);
|
||||||
|
prim.primitive.setColorB(tri.colorB);
|
||||||
|
prim.primitive.setColorC(tri.colorC);
|
||||||
|
|
||||||
|
|
||||||
prim.primitive.setOpaque();
|
prim.primitive.setOpaque();
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Renderer final {
|
|||||||
Renderer(const Renderer&) = delete;
|
Renderer(const Renderer&) = delete;
|
||||||
Renderer& operator=(const Renderer&) = delete;
|
Renderer& operator=(const Renderer&) = delete;
|
||||||
|
|
||||||
static constexpr size_t ORDERING_TABLE_SIZE = 1024;
|
static constexpr size_t ORDERING_TABLE_SIZE = 4096*16;
|
||||||
static constexpr size_t BUMP_ALLOCATOR_SIZE = 100000;
|
static constexpr size_t BUMP_ALLOCATOR_SIZE = 100000;
|
||||||
|
|
||||||
static void init(psyqo::GPU &gpuInstance);
|
static void init(psyqo::GPU &gpuInstance);
|
||||||
|
|||||||
@@ -7,33 +7,43 @@
|
|||||||
|
|
||||||
namespace psxsplash {
|
namespace psxsplash {
|
||||||
|
|
||||||
eastl::vector<psxsplash::GameObject*> LoadSplashpack(uint8_t *data) {
|
eastl::vector<psxsplash::GameObject *> LoadSplashpack(uint8_t *data) {
|
||||||
psyqo::Kernel::assert(data != nullptr, "Splashpack loading data pointer is null");
|
psyqo::Kernel::assert(data != nullptr,
|
||||||
|
"Splashpack loading data pointer is null");
|
||||||
psxsplash::SPLASHPACKFileHeader *header =
|
psxsplash::SPLASHPACKFileHeader *header =
|
||||||
reinterpret_cast<psxsplash::SPLASHPACKFileHeader *>(data);
|
reinterpret_cast<psxsplash::SPLASHPACKFileHeader *>(data);
|
||||||
psyqo::Kernel::assert(memcmp(header->magic, "SP", 2) == 0, "Splashpack has incorrect magic");
|
psyqo::Kernel::assert(memcmp(header->magic, "SP", 2) == 0,
|
||||||
|
"Splashpack has incorrect magic");
|
||||||
|
|
||||||
eastl::vector<psxsplash::GameObject*> gameObjects;
|
eastl::vector<psxsplash::GameObject *> gameObjects;
|
||||||
gameObjects.reserve(header->gameObjectCount);
|
gameObjects.reserve(header->gameObjectCount);
|
||||||
|
|
||||||
uint8_t* curentPointer = data + sizeof(psxsplash::SPLASHPACKFileHeader);
|
uint8_t *curentPointer = data + sizeof(psxsplash::SPLASHPACKFileHeader);
|
||||||
|
|
||||||
for(uint16_t i = 0; i < header->gameObjectCount; i++) {
|
for (uint16_t i = 0; i < header->gameObjectCount; i++) {
|
||||||
psxsplash::GameObject* go = reinterpret_cast<psxsplash::GameObject*>(curentPointer);
|
psxsplash::GameObject *go =
|
||||||
go->polygons = reinterpret_cast<psxsplash::Tri*>(data + go->polygonsOffset);
|
reinterpret_cast<psxsplash::GameObject *>(curentPointer);
|
||||||
|
go->polygons =
|
||||||
|
reinterpret_cast<psxsplash::Tri *>(data + go->polygonsOffset);
|
||||||
gameObjects.push_back(go);
|
gameObjects.push_back(go);
|
||||||
curentPointer += sizeof(psxsplash::GameObject);
|
curentPointer += sizeof(psxsplash::GameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint16_t i = 0; i < header->textureAtlasCount; i++) {
|
for (uint16_t i = 0; i < header->textureAtlasCount; i++) {
|
||||||
psxsplash::SPLASHPACKTextureAtlas* atlas = reinterpret_cast<psxsplash::SPLASHPACKTextureAtlas *>(curentPointer);
|
psxsplash::SPLASHPACKTextureAtlas *atlas =
|
||||||
|
reinterpret_cast<psxsplash::SPLASHPACKTextureAtlas *>(
|
||||||
uint8_t* offsetData = data + atlas->polygonsOffset; // Ensure correct byte offset
|
curentPointer);
|
||||||
uint16_t* castedData = reinterpret_cast<uint16_t*>(offsetData); // Safe cast
|
|
||||||
psxsplash::Renderer::getInstance().vramUpload(castedData, atlas->x, atlas->y, atlas->width, atlas->height);
|
uint8_t *offsetData =
|
||||||
|
data + atlas->polygonsOffset; // Ensure correct byte offset
|
||||||
|
uint16_t *castedData =
|
||||||
|
reinterpret_cast<uint16_t *>(offsetData); // Safe cast
|
||||||
|
psxsplash::Renderer::getInstance().vramUpload(
|
||||||
|
castedData, atlas->x, atlas->y, atlas->width, atlas->height);
|
||||||
|
curentPointer += sizeof(psxsplash::SPLASHPACKTextureAtlas);
|
||||||
}
|
}
|
||||||
|
|
||||||
return gameObjects;
|
return gameObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace psxsplash
|
||||||
|
|||||||
Reference in New Issue
Block a user