1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-03-13 23:59:41 +01:00

Restored PSP build, added fog to it (#451)

Co-authored-by: Vicente Carrasco Álvarez <vicente.carrasco@usach.cl>
This commit is contained in:
Vicente Carrasco 2023-01-08 15:17:48 -03:00 committed by GitHub
parent bcd5de23ed
commit c7fe8ec3b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 13 deletions

View File

@ -33,11 +33,12 @@ namespace GAPI {
// Texture
struct Texture {
uint8 *memory;
int width, height, origWidth, origHeight;
int width, height, depth, origWidth, origHeight, origDepth;//todo: depth
TexFormat fmt;
uint32 opt;
Texture(int width, int height, uint32 opt) : memory(0), width(width), height(height), origWidth(width), origHeight(height), fmt(FMT_RGBA), opt(opt) {}
/*depth*/
Texture(int width, int height, int depth, uint32 opt) : memory(0), width(width), height(height), depth(depth), origWidth(width), origHeight(height), origDepth(depth), fmt(FMT_RGBA), opt(opt) {}
void init(void *data) {
ASSERT((opt & OPT_PROXY) == 0);
@ -238,19 +239,22 @@ namespace GAPI {
support.maxVectors = 0;
support.shaderBinary = false;
support.VAO = false;
support.VBO = false;
support.depthTexture = false;
support.shadowSampler = false;
support.discardFrame = false;
support.texNPOT = false;
support.tex3D = false;
support.texRG = false;
support.texBorder = false;
support.texMaxLevel = false;
support.colorFloat = false;
support.colorHalf = false;
support.texFloatLinear = false;
support.texFloat = false;
support.texHalfLinear = false;
support.texHalf = false;
support.clipDist = false;
//support.clipDist = false;
Core::width = 480;
Core::height = 272;
@ -351,9 +355,33 @@ namespace GAPI {
sceGuClearColor(*((uint32*)&c));
}
void setViewport(const Viewport &vp) {
sceGuOffset(2048 - vp.width / 2, 2048 - vp.height / 2);
sceGuViewport(2048 + vp.x, 2048 + vp.y, vp.width, vp.height);
// Previous: struct Viewport
void setViewport(const short4 &vp) {
sceGuOffset(2048 - vp.z / 2, 2048 - vp.w / 2);
sceGuViewport(2048 + vp.x, 2048 + vp.y, vp.z, vp.w);
}
/*this was giving errors on menu rendering when method was empty, see RT_ flags too*/
void setFog(const vec4 &params) {
uint32 color;
if(params.w > 0.0f){
sceGuEnable(GU_FOG);
// FFP TODO
color = 0xFF000000
| (uint32(clamp(params.x * 255.0f, 0.0f, 255.0f)) << 0)
| (uint32(clamp(params.y * 255.0f, 0.0f, 255.0f)) << 8)
| (uint32(clamp(params.z * 255.0f, 0.0f, 255.0f)) << 16);
// from 3DS
sceGuFog(24.0f, 32.0f * 1024.0f, color);
}
else{
sceGuDisable(GU_FOG);
}
}
// from other gapi, could be improved??
void setScissor(const short4 &s) {
sceGuScissor(s.x, Core::viewportDef.w - (s.y + s.w), s.x + s.z, Core::viewportDef.w - s.y);
}
void setDepthTest(bool enable) {
@ -458,8 +486,9 @@ namespace GAPI {
}
vec4 copyPixel(int x, int y) {
//pspgu.h, pspdisplay.h ??
return vec4(0.0f); // TODO: read from framebuffer
}
}
#endif
#endif

View File

@ -3489,8 +3489,11 @@ struct Level : IGame {
short4 oldViewport = Core::viewportDef;
setDefaultTarget(eye, view, false);
Core::setTarget(NULL, NULL, RT_CLEAR_DEPTH | RT_STORE_COLOR);
#ifdef FFP //fixme: psp framebuffer error?
Core::setTarget(NULL, NULL, RT_CLEAR_DEPTH | RT_CLEAR_COLOR | RT_STORE_COLOR);
#else
Core::setTarget(NULL, NULL, RT_CLEAR_DEPTH | RT_STORE_COLOR);
#endif
float aspect = setViewport(view, eye);

View File

@ -653,7 +653,7 @@ namespace Sound {
}
virtual int decode(Frame *frames, int count) {
#if _OS_PSV // TODO crash
#if defined(_OS_PSV) || defined(_OS_PSP) // TODO crash
memset(frames, 0, count * sizeof(Frame));
return count;
#endif

View File

@ -17,11 +17,11 @@ struct Texture : GAPI::Texture {
#elif defined(_GAPI_GU)
Tile4 *tiles;
CLUT *cluts;
// TODO: PSP depth ??
Texture(Tile4 *tiles, int tilesCount, CLUT *cluts, int clutsCount) : GAPI::Texture(256, 256, 1, OPT_PROXY) {
#ifdef EDRAM_TEX
this->tiles = (TR::Tile4*)GAPI::allocEDRAM(tilesCount * sizeof(tiles[0]));
this->cluts = (TR::CLUT*)GAPI::allocEDRAM(clutsCount * sizeof(cluts[0]));
this->tiles = (Tile4*)GAPI::allocEDRAM(tilesCount * sizeof(tiles[0]));
this->cluts = (CLUT*)GAPI::allocEDRAM(clutsCount * sizeof(cluts[0]));
memcpy(this->cluts, cluts, clutsCount * sizeof(cluts[0]));
#ifdef TEX_SWIZZLE
for (int i = 0; i < tilesCount; i++)

View File

@ -2047,6 +2047,37 @@ public:
strcpy(path, contentDir);
readDirectory(path);
}
#elif _OS_PSP //vita isnt called "psp2" by coincidence
//dunno if this is used (?)
static void readDirectory(char* path) {
SceUID dd = sceIoDopen(path);
size_t len = strlen(path);
SceIoDirent entry;
while (sceIoDread(dd, &entry) > 0)
{
strcat(path, entry.d_name);
if (FIO_S_ISDIR(entry.d_stat.st_mode))
{
strcat(path, "/");
readDirectory(path);
} else {
fileList.push(StrUtils::copy(path + strlen(contentDir)));
}
path[len] = 0;
}
sceIoClose(dd);
}
static void readFileList() {
char path[255];
strcpy(path, contentDir);
readDirectory(path);
}
#else
static void readFileList() {};
#endif