PSP: Less broken rendering

This commit is contained in:
UnknownShadow200 2023-04-07 13:05:03 +10:00
parent c07d34a5fc
commit d96aba237b
2 changed files with 39 additions and 30 deletions

View File

@ -60,6 +60,8 @@ static void guInit(void) {
sceGuScissor(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
sceGuDisable(GU_SCISSOR_TEST);
//sceGuEnable(GU_CLIP_PLANES);
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
sceGuFinish();
@ -137,13 +139,18 @@ void Gfx_ClearCol(PackedCol color) {
}
void Gfx_SetColWriteMask(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
//glColorMask(r, g, b, a);
/* TODO implemenet */
unsigned int mask = 0xffffffff;
if (r) mask &= 0xffffff00;
if (g) mask &= 0xffff00ff;
if (b) mask &= 0xff00ffff;
if (a) mask &= 0x00ffffff;
//sceGuPixelMask(mask); TODO implement
}
void Gfx_SetDepthWrite(cc_bool enabled) { sceGuDepthMask(enabled); }
void Gfx_SetDepthTest(cc_bool enabled) { GU_Toggle(GU_DEPTH_TEST); }
//void Gfx_SetDepthTest(cc_bool enabled) { sceGuDisable(GU_DEPTH_TEST); }
/*########################################################################################################################*
*---------------------------------------------------------Matrices--------------------------------------------------------*
@ -305,11 +312,11 @@ void Gfx_DepthOnlyRendering(cc_bool depthOnly) {
*---------------------------------------------------------Matrices--------------------------------------------------------*
*#########################################################################################################################*/
static int matrix_modes[] = { GU_PROJECTION, GU_VIEW };
static ScePspFMatrix4 tmp_matrix;
void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
ScePspFMatrix4 m;
gumLoadMatrix(&m, matrix);
sceGuSetMatrix(matrix_modes[type], &m);
gumLoadMatrix(&tmp_matrix, matrix);
sceGuSetMatrix(matrix_modes[type], &tmp_matrix);
}
void Gfx_LoadIdentityMatrix(MatrixType type) {
@ -349,14 +356,17 @@ void Gfx_DrawVb_Lines(int verticesCount) {
}
void Gfx_DrawVb_IndexedTris_Range(int verticesCount, int startVertex) {
sceGuDrawArray(GU_TRIANGLES, gfx_fields | GU_INDEX_16BIT, verticesCount, gfx_indices, gfx_vertices + startVertex * gfx_stride);
sceGuDrawArray(GU_TRIANGLES, gfx_fields | GU_INDEX_16BIT, ICOUNT(verticesCount),
gfx_indices, gfx_vertices + startVertex * gfx_stride);
}
void Gfx_DrawVb_IndexedTris(int verticesCount) {
sceGuDrawArray(GU_TRIANGLES, gfx_fields | GU_INDEX_16BIT, verticesCount, gfx_indices, gfx_vertices);
sceGuDrawArray(GU_TRIANGLES, gfx_fields | GU_INDEX_16BIT, ICOUNT(verticesCount),
gfx_indices, gfx_vertices);
}
void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
sceGuDrawArray(GU_TRIANGLES, gfx_fields | GU_INDEX_16BIT, verticesCount, gfx_indices, gfx_vertices + startVertex * SIZEOF_VERTEX_TEXTURED);
sceGuDrawArray(GU_TRIANGLES, gfx_fields | GU_INDEX_16BIT, ICOUNT(verticesCount),
gfx_indices, gfx_vertices + startVertex * SIZEOF_VERTEX_TEXTURED);
}
#endif

View File

@ -9,7 +9,6 @@
#include "Utils.h"
#include "Errors.h"
#include <errno.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@ -19,14 +18,13 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <stdio.h>
#include <pspkernel.h>
#include <pspnet_inet.h>
#include <pspnet_resolver.h>
#include <psprtc.h>
#define NS_PER_SEC 1000000000ULL
const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
const cc_result ReturnCode_FileNotFound = ENOENT;
const cc_result ReturnCode_SocketInProgess = EINPROGRESS;
const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK;
@ -64,13 +62,16 @@ void Mem_Free(void* mem) {
/*########################################################################################################################*
*------------------------------------------------------Logging/Time-------------------------------------------------------*
*#########################################################################################################################*/
/* TODO: check this is actually accurate */
cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
if (end < beg) return 0;
return (end - beg) / 1000;
return end - beg;
}
void Platform_Log(const char* msg, int len) {
int fd = sceKernelStdout();
sceIoWrite(fd, msg, len);
sceIoWrite(fd, "\n", 1);
//pspDebugSioPutData(msg, len);
//pspDebugSioPutData("\n", 1);
}
@ -83,25 +84,23 @@ TimeMS DateTime_CurrentUTC_MS(void) {
}
void DateTime_CurrentLocal(struct DateTime* t) {
struct timeval cur;
struct tm loc_time;
gettimeofday(&cur, NULL);
localtime_r(&cur.tv_sec, &loc_time);
pspTime curTime;
sceRtcGetCurrentClockLocalTime(&curTime);
t->year = loc_time.tm_year + 1900;
t->month = loc_time.tm_mon + 1;
t->day = loc_time.tm_mday;
t->hour = loc_time.tm_hour;
t->minute = loc_time.tm_min;
t->second = loc_time.tm_sec;
t->year = curTime.year;
t->month = curTime.month;
t->day = curTime.day;
t->hour = curTime.hour;
t->minute = curTime.minutes;
t->second = curTime.seconds;
}
#define US_PER_SEC 1000000ULL
cc_uint64 Stopwatch_Measure(void) {
struct timespec t;
// sceKernelGetSystemTimeWide
/* TODO: CLOCK_MONOTONIC_RAW ?? */
clock_gettime(CLOCK_MONOTONIC, &t);
return (cc_uint64)t.tv_sec * NS_PER_SEC + t.tv_nsec;
// TODO: sceKernelGetSystemTimeWide
struct SceKernelTimeval cur;
sceKernelLibcGettimeofday(&cur, NULL);
return (cc_uint64)cur.tv_sec * US_PER_SEC + cur.tv_usec;
}