Skip to content

Commit

Permalink
#15 fix PSP build
Browse files Browse the repository at this point in the history
  • Loading branch information
XProger committed May 24, 2018
1 parent 36b7355 commit 800eaac
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 113 deletions.
4 changes: 4 additions & 0 deletions src/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ struct Camera : ICamera {
fov = firstPerson ? 90.0f : 65.0f;
znear = firstPerson ? 8.0f : 32.0f;
zfar = 45.0f * 1024.0f;

#ifdef _OS_PSP
znear = 256.0f;
#endif
}
};

Expand Down
12 changes: 12 additions & 0 deletions src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,29 @@ namespace Core {
}

void setLighting(Quality value) {
#ifdef _OS_PSP
lighting = LOW;
#else
lighting = value;
#endif
}

void setShadows(Quality value) {
#ifdef _OS_PSP
shadows = LOW;
#else
shadows = value;
#endif
}

void setWater(Quality value) {
#ifdef _OS_PSP
water = LOW;
#else
if (value > LOW && !(support.texFloat || support.texHalf))
value = LOW;
water = value;
#endif
}
} detail;

Expand Down
61 changes: 40 additions & 21 deletions src/gapi_gu.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
#include <pspgu.h>
#include <pspgum.h>

#define FFP
#define TEX_SWIZZLE
//#define EDRAM_MESH
#define EDRAM_TEX
#define PROFILE_MARKER(title)
#define PROFILE_LABEL(id, name, label)
#define PROFILE_TIMING(time)

namespace GAPI {

Expand All @@ -22,6 +21,16 @@ namespace GAPI {
short3 coord;
};

// Shader
struct Shader {
void init(Core::Pass pass, int type, int *def, int defCount) {}
void deinit() {}
void bind() {}
void setParam(UniformType uType, const vec4 &value, int count = 1) {}
void setParam(UniformType uType, const mat4 &value, int count = 1) {}
void setParam(UniformType uType, const Basis &value, int count = 1) {}
};

// Texture
struct Texture {
uint8 *memory;
Expand Down Expand Up @@ -100,9 +109,9 @@ namespace GAPI {

void setFilterQuality(int value) {
if (value > Core::Settings::LOW)
opt &= ~NEAREST;
opt &= ~OPT_NEAREST;
else
opt |= NEAREST;
opt |= OPT_NEAREST;
}
};

Expand All @@ -117,17 +126,16 @@ namespace GAPI {

Mesh(bool dynamic) : iBuffer(NULL), vBuffer(NULL), dynamic(dynamic) {}

void init(Index *indices, int iCount, ::Vertex *vertices, int vCount, int aCount, bool dynamic) {
void init(Index *indices, int iCount, ::Vertex *vertices, int vCount, int aCount) {
this->iCount = iCount;
this->vCount = vCount;
this->dynamic = dynamic;

if (dynamic)
return;

#ifdef EDRAM_MESH
iBuffer = (Index*)Core::allocEDRAM(iCount * sizeof(Index));
vBuffer = (Vertex*)Core::allocEDRAM(vCount * sizeof(Vertex));
iBuffer = (Index*)allocEDRAM(iCount * sizeof(Index));
vBuffer = (Vertex*)allocEDRAM(vCount * sizeof(Vertex));
#else
iBuffer = new Index[iCount];
vBuffer = new Vertex[vCount];
Expand Down Expand Up @@ -171,12 +179,7 @@ namespace GAPI {
}
}

void bind(const MeshRange &range) const {
ASSERT(iBuffer != NULL);
ASSERT(vBuffer != NULL);
Core::active.iBuffer = iBuffer;
Core::active.vBuffer = vBuffer + range.vStart;
}
void bind(const MeshRange &range) const {}

void initNextRange(MeshRange &range, int &aIndex) const {
range.aIndex = -1;
Expand All @@ -193,8 +196,8 @@ namespace GAPI {
static int EDRAM_SIZE;

void* allocEDRAM(int size) {
LOG("EDRAM ALLOC: offset: %d size %d (free %d)\n", Core::EDRAM_OFFSET, size, EDRAM_SIZE - (Core::EDRAM_OFFSET + size));
if (Core::EDRAM_OFFSET + size > EDRAM_SIZE)
LOG("EDRAM ALLOC: offset: %d size %d (free %d)\n", EDRAM_OFFSET, size, EDRAM_SIZE - (EDRAM_OFFSET + size));
if (EDRAM_OFFSET + size > EDRAM_SIZE)
LOG("! EDRAM overflow !\n");

void *ptr = ((char*)sceGeEdramGetAddr()) + EDRAM_OFFSET;
Expand Down Expand Up @@ -290,11 +293,11 @@ namespace GAPI {
}

mat4 ortho(float l, float r, float b, float t, float znear, float zfar) {
return mat4(mat4::PROJ_ZERO_POS, l, r, b, t, znear, zfar);
return mat4(mat4::PROJ_NEG_POS, l, r, b, t, znear, zfar);
}

mat4 perspective(float fov, float aspect, float znear, float zfar) {
return mat4(mat4::PROJ_ZERO_POS, fov, aspect, znear, zfar);
return mat4(mat4::PROJ_NEG_POS, fov, aspect, znear, zfar);
}

bool beginFrame() {
Expand Down Expand Up @@ -397,12 +400,28 @@ namespace GAPI {
sceGumMatrixMode(GU_MODEL);
sceGumLoadMatrix((ScePspFMatrix4*)&m);

sceGumDrawArray(GU_TRIANGLES, GU_TEXTURE_16BIT | GU_COLOR_8888 | GU_NORMAL_16BIT | GU_VERTEX_16BIT | GU_INDEX_16BIT | GU_TRANSFORM_3D, range.iCount, mesh->iBuffer + range.iStart, mesh->vBuffer);
sceGumDrawArray(GU_TRIANGLES, GU_TEXTURE_16BIT | GU_COLOR_8888 | GU_NORMAL_16BIT | GU_VERTEX_16BIT | GU_INDEX_16BIT | GU_TRANSFORM_3D, range.iCount, mesh->iBuffer + range.iStart, mesh->vBuffer + range.vStart);
}

vec4 copyPixel(int x, int y) {
return vec4(0.0f); // TODO: read from framebuffer
}

void initPSO(PSO *pso) {
ASSERT(pso);
ASSERT(pso && pso->data == NULL);
pso->data = &pso;
}

void deinitPSO(PSO *pso) {
ASSERT(pso);
ASSERT(pso->data != NULL);
pso->data = NULL;
}

void bindPSO(const PSO *pso) {
//
}
}

#endif
7 changes: 1 addition & 6 deletions src/inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -1417,9 +1417,6 @@ struct Inventory {
}

void renderGameBG() {
#ifdef _OS_PSP
return;
#endif
Index indices[6] = { 0, 1, 2, 0, 2, 3 };
Vertex vertices[4];
vertices[0].coord = short4(-32767, 32767, 0, 0);
Expand All @@ -1437,9 +1434,7 @@ struct Inventory {

game->setShader(Core::passFilter, Shader::DEFAULT, false, false);
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR || !background[0]) {
for (int i = 0; i < 4; i++)
vertices[i].light.x = vertices[i].light.y = vertices[i].light.z = 0;
Core::whiteTex->bind(sDiffuse); // black background
Core::blackTex->bind(sDiffuse); // black background
} else
background[0]->bind(sDiffuse); // blured grayscale image

Expand Down
Loading

0 comments on commit 800eaac

Please sign in to comment.