Adding splashpack
This commit is contained in:
@@ -1,12 +1,21 @@
|
||||
#include "renderer.hh"
|
||||
|
||||
#include "EASTL/vector.h"
|
||||
#include "psyqo/fixed-point.hh"
|
||||
#include "psyqo/gte-kernels.hh"
|
||||
#include "psyqo/gte-registers.hh"
|
||||
#include "psyqo/primitives/triangles.hh"
|
||||
#include "psyqo/soft-math.hh"
|
||||
#include "psyqo/trigonometry.hh"
|
||||
|
||||
psxsplash::Renderer* psxsplash::Renderer::instance = nullptr;
|
||||
using namespace psyqo::fixed_point_literals;
|
||||
using namespace psyqo::trig_literals;
|
||||
|
||||
psxsplash::Renderer *psxsplash::Renderer::instance = nullptr;
|
||||
|
||||
void psxsplash::Renderer::init(psyqo::GPU &gpuInstance) {
|
||||
psyqo::Kernel::assert(instance == nullptr, "A second intialization of Renderer was tried");
|
||||
psyqo::Kernel::assert(instance == nullptr,
|
||||
"A second intialization of Renderer was tried");
|
||||
|
||||
psyqo::GTE::clear<psyqo::GTE::Register::TRX, psyqo::GTE::Unsafe>();
|
||||
psyqo::GTE::clear<psyqo::GTE::Register::TRY, psyqo::GTE::Unsafe>();
|
||||
@@ -24,14 +33,12 @@ void psxsplash::Renderer::init(psyqo::GPU &gpuInstance) {
|
||||
psyqo::GTE::write<psyqo::GTE::Register::ZSF4, psyqo::GTE::Unsafe>(
|
||||
ORDERING_TABLE_SIZE / 4);
|
||||
|
||||
if(!instance) {
|
||||
if (!instance) {
|
||||
instance = new Renderer(gpuInstance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void psxsplash::Renderer::render(eastl::array<GameObject> &objects) {
|
||||
void psxsplash::Renderer::render(eastl::vector<GameObject *> &objects) {
|
||||
uint8_t parity = m_gpu.getParity();
|
||||
|
||||
auto &ot = m_ots[parity];
|
||||
@@ -47,19 +54,21 @@ void psxsplash::Renderer::render(eastl::array<GameObject> &objects) {
|
||||
|
||||
for (auto &obj : objects) {
|
||||
|
||||
psyqo::GTE::write<psyqo::GTE::Register::TRX, psyqo::GTE::Unsafe>(
|
||||
obj.position.x.raw());
|
||||
/*psyqo::GTE::write<psyqo::GTE::Register::TRX, psyqo::GTE::Unsafe>(
|
||||
obj->position.x.raw());
|
||||
psyqo::GTE::write<psyqo::GTE::Register::TRY, psyqo::GTE::Unsafe>(
|
||||
obj.position.y.raw());
|
||||
psyqo::GTE::write<psyqo::GTE::Register::TRZ, psyqo::GTE::Unsafe>(
|
||||
obj.position.z.raw());
|
||||
obj->position.y.raw());
|
||||
|
||||
|
||||
psyqo::GTE::writeUnsafe<psyqo::GTE::PseudoRegister::Rotation>(
|
||||
obj.rotation);
|
||||
obj->rotation);*/
|
||||
|
||||
for (int i = 0; i < obj.polyCount; i++) {
|
||||
|
||||
Tri& tri = obj.polygons[i];
|
||||
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++) {
|
||||
|
||||
Tri &tri = obj->polygons[i];
|
||||
|
||||
psyqo::GTE::writeUnsafe<psyqo::GTE::PseudoRegister::V0>(tri.v0);
|
||||
psyqo::GTE::writeUnsafe<psyqo::GTE::PseudoRegister::V1>(tri.v1);
|
||||
@@ -71,22 +80,22 @@ void psxsplash::Renderer::render(eastl::array<GameObject> &objects) {
|
||||
int32_t mac0 = 0;
|
||||
psyqo::GTE::read<psyqo::GTE::Register::MAC0>(
|
||||
reinterpret_cast<uint32_t *>(&mac0));
|
||||
if (mac0 <= 0)
|
||||
continue;
|
||||
// if (mac0 <= 0)
|
||||
// continue;
|
||||
|
||||
psyqo::GTE::Kernels::avsz4();
|
||||
psyqo::GTE::Kernels::avsz3();
|
||||
int32_t zIndex = 0;
|
||||
psyqo::GTE::read<psyqo::GTE::Register::OTZ>(
|
||||
reinterpret_cast<uint32_t *>(&zIndex));
|
||||
if (zIndex < 0 || zIndex >= ORDERING_TABLE_SIZE)
|
||||
continue;
|
||||
// if (zIndex < 0 || zIndex >= ORDERING_TABLE_SIZE)
|
||||
// continue;
|
||||
|
||||
psyqo::GTE::read<psyqo::GTE::Register::SXY0>(&projected[1].packed);
|
||||
psyqo::GTE::read<psyqo::GTE::Register::SXY1>(&projected[2].packed);
|
||||
psyqo::GTE::read<psyqo::GTE::Register::SXY2>(&projected[3].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::SXY2>(&projected[2].packed);
|
||||
|
||||
auto &prim = balloc.allocate<psyqo::Fragments::SimpleFragment<
|
||||
psyqo::Prim::TexturedTriangle>>();
|
||||
auto &prim =
|
||||
balloc.allocateFragment<psyqo::Prim::TexturedTriangle>();
|
||||
|
||||
prim.primitive.pointA = projected[0];
|
||||
prim.primitive.pointB = projected[1];
|
||||
@@ -94,7 +103,11 @@ void psxsplash::Renderer::render(eastl::array<GameObject> &objects) {
|
||||
prim.primitive.uvA = tri.uvA;
|
||||
prim.primitive.uvB = tri.uvB;
|
||||
prim.primitive.uvC = tri.uvC;
|
||||
prim.primitive.tpage = obj.texture;
|
||||
prim.primitive.tpage = obj->texture;
|
||||
prim.primitive.tpage.setPageX(5);
|
||||
prim.primitive.tpage.setPageY(0);
|
||||
|
||||
prim.primitive.setOpaque();
|
||||
|
||||
ot.insert(prim, zIndex);
|
||||
}
|
||||
@@ -103,7 +116,9 @@ void psxsplash::Renderer::render(eastl::array<GameObject> &objects) {
|
||||
m_gpu.chain(ot);
|
||||
}
|
||||
|
||||
void psxsplash::Renderer::vramUpload(const uint16_t * imageData, int16_t posX, int16_t posY, int16_t width, int16_t height) {
|
||||
void psxsplash::Renderer::vramUpload(const uint16_t *imageData, int16_t posX,
|
||||
int16_t posY, int16_t width,
|
||||
int16_t height) {
|
||||
psyqo::Rect uploadRect{.a = {.x = posX, .y = posY}, .b = {width, height}};
|
||||
m_gpu.uploadToVRAM(imageData, uploadRect);
|
||||
}
|
||||
Reference in New Issue
Block a user