mirror of
https://github.com/pspdev/pspsdk.git
synced 2026-01-07 15:24:35 +00:00
Merge pull request #320 from fjtrujy/sceguDebug
Creating `libpspgud` library
This commit is contained in:
@@ -12,10 +12,11 @@ CFLAGS = @PSPSDK_CFLAGS@
|
||||
libpspguincludedir = @PSPSDK_INCLUDEDIR@
|
||||
libpspguinclude_HEADERS = pspgu.h
|
||||
|
||||
lib_LIBRARIES = libpspgu.a
|
||||
lib_LIBRARIES = libpspgu.a libpspgud.a
|
||||
|
||||
noinst_HEADERS = guInternal.h
|
||||
|
||||
# Regular library (no debug assertions)
|
||||
libpspgu_a_SOURCES = \
|
||||
guInternal.c \
|
||||
sceGuAlphaFunc.c \
|
||||
@@ -112,3 +113,7 @@ libpspgu_a_SOURCES = \
|
||||
sceGuViewport.c \
|
||||
vram.c
|
||||
|
||||
# Debug library (with debug assertions)
|
||||
libpspgud_a_SOURCES = $(libpspgu_a_SOURCES)
|
||||
libpspgud_a_CFLAGS = $(CFLAGS) -DGU_DEBUG
|
||||
|
||||
|
||||
@@ -19,5 +19,5 @@ int gu_display_on;
|
||||
int gu_call_mode;
|
||||
int gu_states;
|
||||
GuDrawBuffer gu_draw_buffer;
|
||||
unsigned int* gu_object_stack[32];
|
||||
unsigned int* gu_object_stack[GU_OBJECT_STACK_SIZE];
|
||||
int gu_object_stack_depth;
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
|
||||
#include "pspgu.h"
|
||||
|
||||
#ifdef GU_DEBUG
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#define GU_OBJECT_STACK_SIZE 32
|
||||
|
||||
typedef void (*GuCallback)(int);
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuAlphaFunc(int func, int value, int mask)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuAlphaFunc(%d, %d, %d);\n", func, value, mask);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(func >= GU_NEVER && func <= GU_GEQUAL && "Invalid alpha function");
|
||||
#endif
|
||||
|
||||
int arg = func | ((value & 0xff) << 8) | ((mask & 0xff) << 16);
|
||||
sendCommandi(ALPHA_TEST, arg);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
void sceGuAmbient(unsigned int color)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuAmbient(%08X);\n", color);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandi(AMBIENT_LIGHT_COLOR,(color));
|
||||
sendCommandi(AMBIENT_LIGHT_ALPHA,(color >> 24));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
void sceGuAmbientColor(unsigned int color)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuAmbientColor(0x%08X);\n", color);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandi(AMBIENT_COLOR, color);
|
||||
sendCommandi(AMBIENT_ALPHA, color >> 24);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
void sceGuBeginObject(int vertex_type, int count, const void *indices, const void *vertices)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuBeginObject(%d, %d, %p, %p);\n", vertex_type, count, indices, vertices);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(count > 0 && count <= 255 && (count % 8) == 0 && "Invalid vertex count - must be positive, <= 65535, and multiple of 8");
|
||||
assert(gu_object_stack_depth < GU_OBJECT_STACK_SIZE && "Object stack overflow");
|
||||
#endif
|
||||
|
||||
if (vertex_type)
|
||||
sendCommandi(VERTEX_TYPE, vertex_type);
|
||||
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
|
||||
void sceGuBlendFunc(int op, int src, int dest, unsigned int srcfix, unsigned int destfix)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuBlendFunc(%d, %d, %d, 0x%08X, 0x%08X);\n", op, src, dest, srcfix, destfix);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(op >= GU_ADD && op <= GU_ABS && "Invalid blend operation");
|
||||
assert(src >= GU_OTHER_COLOR && src <= GU_FIX && "Invalid source blend factor");
|
||||
assert(dest >= GU_OTHER_COLOR && dest <= GU_FIX && "Invalid destination blend factor");
|
||||
#endif
|
||||
|
||||
sendCommandi(BLEND_MODE, src | (dest << 4) | (op << 8));
|
||||
sendCommandi(BLEND_FIXED_A, srcfix);
|
||||
sendCommandi(BLEND_FIXED_B, destfix);
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuBoneMatrix(unsigned int index, const ScePspFMatrix4 *matrix)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuBoneMatrix(%d, %p);\n", index, matrix);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(index < 8 && "Invalid bone matrix index");
|
||||
#endif
|
||||
|
||||
unsigned int offset = ((index << 1) + index) << 2; // 3*4 matrix
|
||||
unsigned int i, j;
|
||||
const float *fmatrix = (const float *)matrix;
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
int sceGuCallList(const void *list)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuCallList(%p);\n", list);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
int res;
|
||||
unsigned int list_addr = (unsigned int)list;
|
||||
|
||||
|
||||
@@ -10,5 +10,11 @@
|
||||
|
||||
void sceGuCallMode(int mode)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuCallMode(%d);\n", mode);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(mode >= GU_CALL_NORMAL && mode <= GU_CALL_SIGNAL && "Invalid call mode");
|
||||
#endif
|
||||
|
||||
gu_call_mode = mode;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
void sceGuClear(int flags)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuClear(%d);\n", flags);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(flags >= 0 && "Invalid clear flags");
|
||||
assert((flags & ~(GU_COLOR_BUFFER_BIT | GU_STENCIL_BUFFER_BIT | GU_DEPTH_BUFFER_BIT | GU_FAST_CLEAR_BIT)) == 0 && "Invalid clear flags");
|
||||
#endif
|
||||
|
||||
GuContext *context = &gu_contexts[gu_curr_context];
|
||||
unsigned int filter;
|
||||
struct Vertex
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
void sceGuClearColor(unsigned int color)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuClearColor(0x%08X);\n", color);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
GuContext* context = &gu_contexts[gu_curr_context];
|
||||
context->clear_color = color;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuClearDepth(unsigned int depth)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuClearDepth(%u);\n", depth);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(depth <= 65535 && "Invalid depth value");
|
||||
#endif
|
||||
|
||||
GuContext* context = &gu_contexts[gu_curr_context];
|
||||
context->clear_depth = depth;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,29 @@
|
||||
|
||||
void sceGuClearStencil(unsigned int stencil)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuClearStencil(%u);\n", stencil);
|
||||
assert(gu_init && "GU not initialized");
|
||||
switch (gu_draw_buffer.pixel_size)
|
||||
{
|
||||
case GU_PSM_8888:
|
||||
assert(stencil <= 255 && "Invalid stencil value for GU_PSM_8888");
|
||||
break;
|
||||
case GU_PSM_4444:
|
||||
assert(stencil <= 15 && "Invalid stencil value for GU_PSM_4444");
|
||||
break;
|
||||
case GU_PSM_5551:
|
||||
assert(stencil <= 1 && "Invalid stencil value for GU_PSM_5551");
|
||||
break;
|
||||
case GU_PSM_5650:
|
||||
assert(0 && "Stencil not supported for GU_PSM_5650");
|
||||
break;
|
||||
default:
|
||||
assert(0 && "Invalid pixel format");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
GuContext* context = &gu_contexts[gu_curr_context];
|
||||
context->clear_stencil = stencil;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuClutLoad(int num_blocks, const void *cbp)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuClutLoad(%d, %p);\n", num_blocks, cbp);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(num_blocks > 0 && num_blocks <= 65535 && "Invalid number of CLUT blocks");
|
||||
#endif
|
||||
|
||||
sendCommandi(CLUT_BUF_PTR, ((unsigned int)cbp));
|
||||
sendCommandi(CLUT_BUF_WIDTH, (((unsigned int)cbp) >> 8) & 0xf0000);
|
||||
sendCommandi(CLUT_LOAD, num_blocks);
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuClutMode(unsigned int cpsm, unsigned int shift, unsigned int mask, unsigned int csa)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuClutMode(%08X, %08X, %08X, %08X);\n", cpsm, shift, mask, csa);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(cpsm >= GU_PSM_5650 && cpsm <= GU_PSM_8888 && "Invalid CLUT pixel format");
|
||||
#endif
|
||||
|
||||
unsigned int argument = (cpsm) | (shift << 2) | (mask << 8) | (csa << 16);
|
||||
sendCommandi(CLUT_FORMAT, argument);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,9 @@
|
||||
|
||||
void sceGuColor(unsigned int color)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sceGuMaterial(GU_AMBIENT | GU_DIFFUSE | GU_SPECULAR, color);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuColorFunc(int func, unsigned int color, unsigned int mask)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuColorFunc(%d, 0x%08X, 0x%08X);\n", func, color, mask);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(func >= GU_NEVER && func <= GU_NOTEQUAL && "Invalid color function");
|
||||
#endif
|
||||
|
||||
sendCommandi(COLOR_TEST, func & 0x03);
|
||||
sendCommandi(COLOR_REF, color);
|
||||
sendCommandi(COLOR_TESTMASK, mask);
|
||||
|
||||
@@ -10,5 +10,11 @@
|
||||
|
||||
void sceGuColorMaterial(int components)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuColorMaterial(%d);\n", components);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((components >= 0) && ((components & ~(GU_AMBIENT | GU_DIFFUSE | GU_SPECULAR)) == 0) && "Invalid material components");
|
||||
#endif
|
||||
|
||||
sendCommandi(MATERIAL_COLOR, components);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
* Copyright (c) 2005 Jesper Svennevid
|
||||
*/
|
||||
|
||||
#include "pspge.h"
|
||||
#include "guInternal.h"
|
||||
|
||||
int sceGuContinue(void)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuContinue();\n");
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
return sceGeContinue();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,20 @@
|
||||
|
||||
void sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, void *src, int dx, int dy, int destw, void *dest)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuCopyImage(%d, %d, %d, %d, %d, %d, %p, %d, %d, %d, %p);\n", psm, sx, sy, width, height, srcw, src, dx, dy, destw, dest);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(psm >= GU_PSM_5650 && psm <= GU_PSM_8888 && "Invalid pixel format");
|
||||
assert(width > 0 && width <= 1023 && "Invalid width");
|
||||
assert(height > 0 && height <= 1023 && "Invalid height");
|
||||
assert(srcw > 8 && srcw <= 1024 && (srcw & 0x7) == 0 && "Invalid source width, must be multiple of 8");
|
||||
assert(destw > 8 && destw <= 1024 && (destw & 0x7) == 0 && "Invalid destination width, must be multiple of 8");
|
||||
assert(sx >= 0 && sx < 1023 && "Invalid source X");
|
||||
assert(sy >= 0 && sy < 1023 && "Invalid source Y");
|
||||
assert(dx >= 0 && dx < 1023 && "Invalid destination X");
|
||||
assert(dy >= 0 && dy < 1023 && "Invalid destination Y");
|
||||
#endif
|
||||
|
||||
sendCommandi(TRANSFER_SRC, ((unsigned int)src));
|
||||
sendCommandi(TRANSFER_SRC_W, ((((unsigned int)src) & 0xff000000) >> 8) | srcw);
|
||||
sendCommandi(TRANSFER_SRC_OFFSET, (sy << 10) | sx);
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
void sceGuDepthBuffer(void *zbp, int zbw)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDepthBuffer(%p, %d);\n", zbp, zbw);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((zbw & 0x1FFF) == 0 && "Depth buffer pointer must be 8192-byte aligned");
|
||||
assert(zbw > 64 && zbw <= 1024 && (zbw & 0x3F) == 0 && "Invalid depth buffer width, must be multiple of 64");
|
||||
#endif
|
||||
|
||||
sendCommandi(Z_BUF_PTR, ((unsigned int)zbp));
|
||||
sendCommandi(Z_BUF_WIDTH, ((((unsigned int)zbp) & 0xff000000) >> 8) | zbw);
|
||||
|
||||
|
||||
@@ -10,5 +10,11 @@
|
||||
|
||||
void sceGuDepthFunc(int function)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDepthFunc(%d);\n", function);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(function >= GU_NEVER && function <= GU_GEQUAL && "Invalid depth function");
|
||||
#endif
|
||||
|
||||
sendCommandi(Z_TEST, function);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,11 @@
|
||||
|
||||
void sceGuDepthMask(int mask)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDepthMask(%d);\n", mask);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((mask == 0 || mask == 1) && "Invalid depth mask");
|
||||
#endif
|
||||
|
||||
sendCommandi(Z_MASK, mask);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
void sceGuDepthOffset(unsigned int offset)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDepthOffset(%08X);\n", offset);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
GuContext* context = &gu_contexts[gu_curr_context];
|
||||
context->depth_offset = offset;
|
||||
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
void sceGuDepthRange(int near, int far)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDepthRange(%d, %d);\n", near, far);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(near >= 0 && near <= 65535 && "Invalid near plane");
|
||||
assert(far >= 0 && far <= 65535 && "Invalid far plane");
|
||||
#endif
|
||||
|
||||
GuContext *context = &gu_contexts[gu_curr_context];
|
||||
|
||||
unsigned int max = (unsigned int)near + (unsigned int)far;
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuDisable(int state)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDisable(%d);\n", state);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(state >= 0 && state < GU_MAX_STATUS && "Invalid state");
|
||||
#endif
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case GU_ALPHA_TEST:
|
||||
|
||||
@@ -13,6 +13,13 @@
|
||||
|
||||
void sceGuDispBuffer(int width, int height, void *dispbp, int dispbw)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDispBuffer(%d, %d, %p, %d);\n", width, height, dispbp, dispbw);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(((unsigned int)dispbp & 0x1F) == 0 && "Display buffer pointer must be 32-byte aligned");
|
||||
assert(dispbw >= 64 && dispbw <= 1024 && (dispbw & 0x3F) == 0 && "Display buffer width must be multiple of 64");
|
||||
#endif
|
||||
|
||||
gu_draw_buffer.width = width;
|
||||
gu_draw_buffer.height = height;
|
||||
gu_draw_buffer.disp_buffer = dispbp;
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
|
||||
int sceGuDisplay(int state)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDisplay(%d);\n", state);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((state == GU_TRUE || state == GU_FALSE) && "Invalid display state");
|
||||
#endif
|
||||
|
||||
if (state == GU_TRUE)
|
||||
sceDisplaySetFrameBuf((void *)((unsigned int)ge_edram_address + (unsigned int)gu_draw_buffer.disp_buffer), gu_draw_buffer.frame_width, gu_draw_buffer.pixel_size, PSP_DISPLAY_SETBUF_NEXTVSYNC);
|
||||
else
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
void sceGuDrawArray(int prim, int vtype, int count, const void *indices, const void *vertices)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDrawArray(%d, %d, %d, %p, %p);\n", prim, vtype, count, indices, vertices);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(count > 0 && count <= 65535 && "Invalid vertex count");
|
||||
assert(prim >= GU_POINTS && prim <= GU_SPRITES && "Invalid primitive type");
|
||||
#endif
|
||||
|
||||
if (vtype)
|
||||
sendCommandi(VERTEX_TYPE, vtype);
|
||||
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
|
||||
void sceGuDrawArrayN(int primitive_type, int vertex_type, int vcount, int primcount, const void *indices, const void *vertices)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDrawArrayN(%d, %d, %d, %d, %p, %p);\n", primitive_type, vertex_type, vcount, primcount, indices, vertices);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(vcount > 0 && vcount <= 65535 && "Invalid vertex count");
|
||||
assert(primcount > 0 && primcount <= 65535 && "Invalid primitive count");
|
||||
assert(primitive_type >= GU_POINTS && primitive_type <= GU_TRIANGLE_FAN && "Invalid primitive type");
|
||||
#endif
|
||||
|
||||
if (vertex_type)
|
||||
sendCommandi(VERTEX_TYPE, vertex_type);
|
||||
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
void sceGuDrawBezier(int vertex_type, int ucount, int vcount, const void *indices, const void *vertices)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDrawBezier(%d, %d, %d, %p, %p);\n", vertex_type, ucount, vcount, indices, vertices);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(ucount > 1 && ucount <= 255 && (ucount % 3) == 1 && "Invalid U count, must be 3*N+1");
|
||||
assert(vcount > 1 && vcount <= 255 && (vcount % 3) == 1 && "Invalid V count, must be 3*N+1");
|
||||
#endif
|
||||
|
||||
if (vertex_type)
|
||||
sendCommandi(VERTEX_TYPE, vertex_type);
|
||||
|
||||
|
||||
@@ -10,6 +10,15 @@
|
||||
|
||||
void sceGuDrawBuffer(int psm, void *fbp, int frame_width)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDrawBuffer(%d, %p, %d);\n", psm, fbp, frame_width);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(((unsigned int)fbp & 0x1FFF) == 0 && "Frame buffer pointer must be 8192-byte aligned");
|
||||
assert(frame_width >= 64 && frame_width <= 1024 && "Frame width must be between 64 and 1024");
|
||||
assert((frame_width & 63) == 0 && "Frame width must be a multiple of 64");
|
||||
assert(psm >= GU_PSM_5650 && psm <= GU_PSM_8888 && "Invalid pixel format");
|
||||
#endif
|
||||
|
||||
gu_draw_buffer.pixel_size = psm;
|
||||
gu_draw_buffer.frame_width = frame_width;
|
||||
gu_draw_buffer.frame_buffer = fbp;
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
|
||||
void sceGuDrawBufferList(int psm, void *fbp, int fbw)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDrawBufferList(%d, %p, %d);\n", psm, fbp, fbw);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(((unsigned int)fbp & 0x1FFF) == 0 && "Frame buffer pointer must be 8192-byte aligned");
|
||||
assert(fbw >= 64 && fbw <= 1024 && (fbw & 0x3F) == 0 && "Frame buffer width must be multiple of 64");
|
||||
assert(psm >= GU_PSM_5650 && psm <= GU_PSM_8888 && "Invalid pixel format");
|
||||
#endif
|
||||
|
||||
sendCommandi(FRAMEBUF_PIX_FORMAT, psm);
|
||||
sendCommandi(FRAME_BUF_PTR, (unsigned int)fbp);
|
||||
sendCommandi(FRAME_BUF_WIDTH, ((((unsigned int)fbp) & 0xff000000) >> 8) | fbw);
|
||||
|
||||
@@ -10,6 +10,15 @@
|
||||
|
||||
void sceGuDrawSpline(int vertex_type, int ucount, int vcount, int uedge, int vedge, const void *indices, const void *vertices)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuDrawSpline(%d, %d, %d, %d, %d, %p, %p);\n", vertex_type, ucount, vcount, uedge, vedge, indices, vertices);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(ucount >= 4 && ucount <= 255 && "Invalid U count - must be between 4 and 255");
|
||||
assert(vcount >= 4 && vcount <= 255 && "Invalid V count - must be between 4 and 255");
|
||||
assert(uedge >= 0 && uedge <= 3 && "Invalid U edge");
|
||||
assert(vedge >= 0 && vedge <= 3 && "Invalid V edge");
|
||||
#endif
|
||||
|
||||
if (vertex_type)
|
||||
sendCommandi(VERTEX_TYPE, vertex_type);
|
||||
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuEnable(int state)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuEnable(%d);\n", state);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(state >= 0 && state < GU_MAX_STATUS && "Invalid enable state");
|
||||
#endif
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case GU_ALPHA_TEST:
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
|
||||
int sceGuEndObject(void)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuEndObject();\n");
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(gu_object_stack_depth > 0 && "Object stack underflow");
|
||||
#endif
|
||||
|
||||
int res;
|
||||
|
||||
gu_object_stack_depth--;
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
|
||||
int sceGuFinishId(unsigned int id)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuFinishId(%08X);\n", id);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
int ret;
|
||||
int intr;
|
||||
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
|
||||
void sceGuFog(float near, float far, unsigned int color)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuFog(%f, %f, %08X);\n", near, far, color);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(near >= 0.0f && "Invalid fog near value");
|
||||
assert(far > near && "Fog far must be greater than near");
|
||||
assert(far <= 65535.0f && "Fog far value too large");
|
||||
#endif
|
||||
|
||||
float distance = far - near;
|
||||
|
||||
if (distance)
|
||||
|
||||
@@ -10,5 +10,11 @@
|
||||
|
||||
void sceGuFrontFace(int order)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuFrontFace(%d);\n", order);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((order == GU_CW || order == GU_CCW) && "Invalid front face order");
|
||||
#endif
|
||||
|
||||
sendCommandi(CULL, order ? 0 : 1);
|
||||
}
|
||||
|
||||
@@ -308,15 +308,27 @@ void callbackSig(int id, void *arg)
|
||||
|
||||
int sceGuInit(void)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuInit();\n");
|
||||
assert(!gu_init && "GU already initialized");
|
||||
#endif
|
||||
|
||||
int res;
|
||||
PspGeCallbackData callback;
|
||||
|
||||
ge_edram_address = sceGeEdramGetAddr();
|
||||
#ifdef GU_DEBUG
|
||||
assert(ge_edram_address != NULL && "Failed to get EDRAM address");
|
||||
#endif
|
||||
|
||||
sceGuResetGlobalVariables();
|
||||
|
||||
res = sceKernelCreateEventFlag("SceGuSignal", PSP_EVENT_WAITMULTIPLE, 3, 0);
|
||||
if (res < 0)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("Failed to create event flag: %d\n", res);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
gu_settings.kernel_event_flag = res;
|
||||
@@ -328,6 +340,9 @@ int sceGuInit(void)
|
||||
res = sceGeSetCallback(&callback);
|
||||
if (res < 0)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("Failed to set GE callback: %d\n", res);
|
||||
#endif
|
||||
sceKernelDeleteEventFlag(gu_settings.kernel_event_flag);
|
||||
gu_settings.kernel_event_flag = -1;
|
||||
return res;
|
||||
@@ -338,6 +353,9 @@ int sceGuInit(void)
|
||||
res = sceGeListEnQueue((void *)((unsigned int)ge_init_list & 0x1fffffff), NULL, gu_settings.ge_callback_id, NULL);
|
||||
if (res < 0)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("Failed to enqueue GE list: %d\n", res);
|
||||
#endif
|
||||
sceKernelDeleteEventFlag(gu_settings.kernel_event_flag);
|
||||
sceGeUnsetCallback(gu_settings.ge_callback_id);
|
||||
gu_settings.ge_callback_id = -1;
|
||||
@@ -352,5 +370,6 @@ int sceGuInit(void)
|
||||
gu_settings.swapBuffersCallback = NULL;
|
||||
gu_settings.swapBuffersBehaviour = PSP_DISPLAY_SETBUF_NEXTHSYNC;
|
||||
|
||||
gu_init = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,14 @@
|
||||
|
||||
void sceGuLight(int light, int type, int components, const ScePspFVector3 *position)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuLight(%d, %d, %d, %p);\n", light, type, components, position);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(light >= 0 && light <= 3 && "Invalid light index");
|
||||
assert(type >= GU_DIRECTIONAL && type <= GU_SPOTLIGHT && "Invalid light type");
|
||||
assert(components >= GU_AMBIENT && components <= GU_DIFFUSE_AND_SPECULAR && "Invalid light components");
|
||||
#endif
|
||||
|
||||
int offset = light * 3;
|
||||
int ltype;
|
||||
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuLightAtt(int light, float atten0, float atten1, float atten2)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuLightAtt(%d, %f, %f, %f);\n", light, atten0, atten1, atten2);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(light >= 0 && light <= 3 && "Invalid light index");
|
||||
#endif
|
||||
|
||||
int offset = light * 3;
|
||||
|
||||
sendCommandf(LIGHT0_CONSTANT_ATTEN + offset, atten0);
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuLightColor(int light, int component, unsigned int color)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuLightColor(%d, %d, 0x%08X);\n", light, component, color);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(light >= 0 && light <= 3 && "Invalid light index");
|
||||
assert(component >= GU_AMBIENT && component <= GU_DIFFUSE_AND_SPECULAR && "Invalid light component");
|
||||
#endif
|
||||
|
||||
int offset = light * 3;
|
||||
|
||||
|
||||
@@ -10,5 +10,11 @@
|
||||
|
||||
void sceGuLightMode(int mode)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuLightMode(%d);\n", mode);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(mode >= GU_SINGLE_COLOR && mode <= GU_SEPARATE_SPECULAR_COLOR && "Invalid light mode");
|
||||
#endif
|
||||
|
||||
sendCommandi(LIGHT_MODE, mode);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,13 @@
|
||||
#include "guInternal.h"
|
||||
|
||||
void sceGuLightSpot(int light, const ScePspFVector3 *direction, float exponent, float cutoff)
|
||||
{
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuLightSpot(%d, %p, %f, %f);\n", light, direction, exponent, cutoff);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(light >= 0 && light <= 3 && "Invalid light index");
|
||||
#endif
|
||||
|
||||
int offset = light * 3;
|
||||
sendCommandf(LIGHT0_EXPONENT_ATTEN + light, exponent);
|
||||
sendCommandf(LIGHT0_CUTOFF_ATTEN + light, cutoff);
|
||||
|
||||
@@ -10,5 +10,11 @@
|
||||
|
||||
void sceGuLogicalOp(int op)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuLogicalOp(%d);\n", op);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(op >= GU_CLEAR && op <= GU_SET && "Invalid logical operation");
|
||||
#endif
|
||||
|
||||
sendCommandi(LOGIC_OP, op & 0x0f);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
void sceGuMaterial(int mode, int color)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuMaterial(%d, %08X);\n", mode, color);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(mode >= 0 && "Invalid material mode");
|
||||
assert((mode & ~(GU_AMBIENT | GU_DIFFUSE | GU_SPECULAR)) == 0 && "Invalid material mode flags");
|
||||
#endif
|
||||
|
||||
if (mode & GU_AMBIENT) {
|
||||
sendCommandi(AMBIENT_COLOR, color);
|
||||
sendCommandi(AMBIENT_ALPHA, color >> 24);
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
void sceGuModelColor(unsigned int emissive, unsigned int ambient, unsigned int diffuse, unsigned int specular)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuModelColor(%08X, %08X, %08X, %08X);\n", emissive, ambient, diffuse, specular);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandi(MATERIAL_EMISSIVE, emissive);
|
||||
sendCommandi(MATERIAL_DIFFUSE, diffuse);
|
||||
sendCommandi(AMBIENT_COLOR, ambient);
|
||||
|
||||
@@ -10,5 +10,11 @@
|
||||
|
||||
void sceGuMorphWeight(int index, float weight)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuMorphWeight(%d, %f);\n", index, weight);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(index >= 0 && index <= 7 && "Invalid morph weight index");
|
||||
#endif
|
||||
|
||||
sendCommandf(MORPH_WEIGHT0 + index, weight);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
void sceGuOffset(unsigned int x, unsigned int y)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuOffset(%08X, %08X);\n", x, y);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(x < 4096 && "X offset too large");
|
||||
assert(y < 4096 && "Y offset too large");
|
||||
#endif
|
||||
|
||||
sendCommandi(OFFSET_X, x << 4);
|
||||
sendCommandi(OFFSET_Y, y << 4);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,12 @@
|
||||
|
||||
void sceGuPatchDivide(unsigned int ulevel, unsigned int vlevel)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuPatchDivide(%08X, %08X);\n", ulevel, vlevel);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(ulevel >= 1 && ulevel <= 64 && "Invalid U level - must be between 1 and 64");
|
||||
assert(vlevel >= 1 && vlevel <= 64 && "Invalid V level - must be between 1 and 64");
|
||||
#endif
|
||||
|
||||
sendCommandi(PATCH_DIVISION, (vlevel << 8) | ulevel);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,11 @@
|
||||
|
||||
void sceGuPatchFrontFace(unsigned int mode)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuPatchFrontFace(%u);\n", mode);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((mode == GU_CW || mode == GU_CCW) && "Invalid patch front face mode");
|
||||
#endif
|
||||
|
||||
sendCommandi(PATCH_FACING, mode);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuPatchPrim(int prim)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuPatchPrim(%d);\n", prim);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((prim == GU_POINTS || prim == GU_LINE_STRIP || prim == GU_TRIANGLE_STRIP) && "Invalid patch primitive");
|
||||
#endif
|
||||
|
||||
switch (prim)
|
||||
{
|
||||
case GU_POINTS:
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
void sceGuPixelMask(unsigned int mask)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuPixelMask(%08X);\n", mask);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandi(MASK_COLOR, mask);
|
||||
sendCommandi(MASK_ALPHA, mask >> 24);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
|
||||
void sceGuScissor(int x, int y, int w, int h)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuScissor(%d, %d, %d, %d);\n", x, y, w, h);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(w > 0 && h > 0 && "Invalid scissor dimensions");
|
||||
assert(x >= 0 && y >= 0 && "Invalid scissor position");
|
||||
assert(x + w <= 480 && y + h <= 272 && "Scissor region too large");
|
||||
#endif
|
||||
|
||||
GuContext *context = &gu_contexts[gu_curr_context];
|
||||
|
||||
context->scissor_start[0] = x;
|
||||
|
||||
@@ -10,5 +10,9 @@
|
||||
|
||||
void sceGuSendCommandf(int cmd, float argument)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandf(cmd,argument);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,9 @@
|
||||
|
||||
void sceGuSendCommandi(int cmd, int argument)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandi(cmd, argument);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
|
||||
int sceGuSendList(int mode, const void *list, PspGeContext *context)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuSendList(%d, %p, %p);\n", mode, list, context);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((mode == GU_HEAD || mode == GU_TAIL) && "Invalid list mode");
|
||||
#endif
|
||||
|
||||
PspGeListArgs args;
|
||||
int list_id;
|
||||
int callback;
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
void sceGuSetAllStatus(int status)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuSetAllStatus(%d);\n", status);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
unsigned int i;
|
||||
for (i = 0; i < GU_MAX_STATUS; ++i)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void *sceGuSetCallback(int signal, GuCallback callback)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuSetCallback(%d, %p);\n", signal, callback);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((signal == GU_CALLBACK_SIGNAL || signal == GU_CALLBACK_FINISH) && "Invalid signal");
|
||||
#endif
|
||||
|
||||
GuCallback old_callback = NULL;
|
||||
|
||||
switch (signal)
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
void sceGuSetDither(const ScePspIMatrix4 *matrix)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuSetDither(%p);\n", matrix);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandi(DITH0, (matrix->x.x & 0x0f) | ((matrix->x.y & 0x0f) << 4) | ((matrix->x.z & 0x0f) << 8) | ((matrix->x.w & 0x0f) << 12));
|
||||
sendCommandi(DITH1, (matrix->y.x & 0x0f) | ((matrix->y.y & 0x0f) << 4) | ((matrix->y.z & 0x0f) << 8) | ((matrix->y.w & 0x0f) << 12));
|
||||
sendCommandi(DITH2, (matrix->z.x & 0x0f) | ((matrix->z.y & 0x0f) << 4) | ((matrix->z.z & 0x0f) << 8) | ((matrix->z.w & 0x0f) << 12));
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuSetMatrix(int type, const ScePspFMatrix4 *matrix)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuSetMatrix(%d, %p);\n", type, matrix);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(type >= GU_PROJECTION && type <= GU_TEXTURE && "Invalid matrix type");
|
||||
#endif
|
||||
|
||||
unsigned int i, j;
|
||||
const float *fmatrix = (const float *)matrix;
|
||||
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
void sceGuSetStatus(int state, int status)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuSetStatus(%d, %d);\n", state, status);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(state >= 0 && state < GU_MAX_STATUS && "Invalid state");
|
||||
assert((status == 0 || status == 1) && "Invalid status");
|
||||
#endif
|
||||
|
||||
if (status)
|
||||
sceGuEnable(state);
|
||||
else
|
||||
|
||||
@@ -10,5 +10,11 @@
|
||||
|
||||
void sceGuShadeModel(int mode)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuShadeModel(%d);\n", mode);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((mode == GU_FLAT || mode == GU_SMOOTH) && "Invalid shade model");
|
||||
#endif
|
||||
|
||||
sendCommandi(SHADE_MODE, mode);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
void sceGuSignal(int mode, int id)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuSignal(%d, %d);\n", mode, id);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(mode >= GU_SIGNAL_WAIT && mode <= GU_SIGNAL_PAUSE && "Invalid signal mode");
|
||||
assert(id >= 0 && id <= 65535 && "Invalid signal ID, must be between 0 and 65535");
|
||||
#endif
|
||||
|
||||
sendCommandi(SIGNAL, ((mode & 0xff) << 16) | (id & 0xffff));
|
||||
sendCommandi(END, 0);
|
||||
|
||||
|
||||
@@ -10,5 +10,10 @@
|
||||
|
||||
void sceGuSpecular(float power) // specular power
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuSpecular(%f);\n", power);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandf(MATERIAL_SPECULAR_COEF, power);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
|
||||
int sceGuStart(int ctype, void *list)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuStart(%d, %p);\n", ctype, list);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((ctype == GU_DIRECT || ctype == GU_CALL || ctype == GU_SEND) && "Invalid context type");
|
||||
#endif
|
||||
|
||||
int intr;
|
||||
GuContext *context = &gu_contexts[ctype];
|
||||
unsigned int *local_list = (unsigned int *)(((unsigned int)list) | 0x40000000);
|
||||
|
||||
@@ -10,5 +10,14 @@
|
||||
|
||||
void sceGuStencilFunc(int func, int ref, int mask)
|
||||
{
|
||||
sendCommandi(STENCIL_TEST, func | ((ref & 0xff) << 8) | ((mask & 0xff) << 16));
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuStencilFunc(%d, %d, %d);\n", func, ref, mask);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(func >= GU_NEVER && func <= GU_GEQUAL && "Invalid stencil function");
|
||||
assert(ref >= 0 && ref <= 255 && "Invalid stencil reference");
|
||||
assert(mask >= 0 && mask <= 255 && "Invalid stencil mask");
|
||||
#endif
|
||||
|
||||
int arg = func | ((ref & 0xff) << 8) | ((mask & 0xff) << 16);
|
||||
sendCommandi(STENCIL_TEST, arg);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,14 @@
|
||||
|
||||
void sceGuStencilOp(int fail, int zfail, int zpass)
|
||||
{
|
||||
sendCommandi(STENCIL_OP, fail | (zfail << 8) | (zpass << 16));
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuStencilOp(%d, %d, %d);\n", fail, zfail, zpass);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(fail >= GU_KEEP && fail <= GU_DECR && "Invalid stencil fail operation");
|
||||
assert(zfail >= GU_KEEP && zfail <= GU_DECR && "Invalid stencil zfail operation");
|
||||
assert(zpass >= GU_KEEP && zpass <= GU_DECR && "Invalid stencil zpass operation");
|
||||
#endif
|
||||
|
||||
int arg = fail | (zfail << 8) | (zpass << 16);
|
||||
sendCommandi(STENCIL_OP, arg);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
|
||||
void *sceGuSwapBuffers(void)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuSwapBuffers();\n");
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
if (gu_settings.swapBuffersCallback)
|
||||
{
|
||||
gu_settings.swapBuffersCallback(&gu_draw_buffer.disp_buffer, &gu_draw_buffer.frame_buffer);
|
||||
|
||||
@@ -13,6 +13,13 @@
|
||||
|
||||
int sceGuSync(int mode, int what)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuSync(%d, %d);\n", mode, what);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((mode == GU_SYNC_FINISH || mode == GU_SYNC_LIST || mode == GU_SYNC_SEND || mode == GU_SYNC_SIGNAL || mode == GU_SYNC_DONE) && "Invalid sync mode");
|
||||
assert((what == GU_SYNC_WAIT || what == GU_SYNC_NOWAIT) && "Invalid sync what");
|
||||
#endif
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case GU_SYNC_FINISH:
|
||||
|
||||
@@ -13,6 +13,13 @@
|
||||
|
||||
void sceGuTerm(void)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTerm();\n");
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(gu_settings.kernel_event_flag >= 0 && "Invalid kernel event flag");
|
||||
assert(gu_settings.ge_callback_id >= 0 && "Invalid GE callback ID");
|
||||
#endif
|
||||
|
||||
sceKernelDeleteEventFlag(gu_settings.kernel_event_flag);
|
||||
sceGeUnsetCallback(gu_settings.ge_callback_id);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,10 @@
|
||||
|
||||
void sceGuTexEnvColor(unsigned int color)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexEnvColor(0x%08X);\n", color);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandi(TEX_ENV_COLOR, color);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,13 @@
|
||||
|
||||
void sceGuTexFilter(int min, int mag)
|
||||
{
|
||||
sendCommandi(TEX_FILTER, (mag << 8) | min);
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexFilter(%d, %d);\n", min, mag);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(min >= GU_NEAREST && min <= GU_LINEAR_MIPMAP_LINEAR && "Invalid minification filter");
|
||||
assert(mag >= GU_NEAREST && mag <= GU_LINEAR && "Invalid magnification filter");
|
||||
#endif
|
||||
|
||||
int arg = min | (mag << 8);
|
||||
sendCommandi(TEX_FILTER, arg);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,10 @@
|
||||
|
||||
void sceGuTexFlush(void)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexFlush();\n");
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandi(TEX_FLUSH, 0);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,14 @@
|
||||
|
||||
void sceGuTexFunc(int tfx, int tcc)
|
||||
{
|
||||
GuContext *context = &gu_contexts[gu_curr_context];
|
||||
context->texture_function = (tcc << 8) | tfx;
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexFunc(%d, %d);\n", tfx, tcc);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(tfx >= GU_TFX_MODULATE && tfx <= GU_TFX_ADD && "Invalid texture function");
|
||||
assert(tcc >= GU_TCC_RGB && tcc <= GU_TCC_RGBA && "Invalid texture color component");
|
||||
#endif
|
||||
|
||||
sendCommandi(TEX_FUNC, ((tcc << 8) | tfx) | context->fragment_2x);
|
||||
GuContext *context = &gu_contexts[gu_curr_context];
|
||||
context->texture_function = tfx | (tcc << 8);
|
||||
sendCommandi(TEX_FUNC, context->texture_function | context->fragment_2x);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,18 @@ static inline int getExp(int val)
|
||||
|
||||
void sceGuTexImage(int mipmap, int width, int height, int tbw, const void *tbp)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexImage(%d, %d, %d, %d, %p);\n", mipmap, width, height, tbw, tbp);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(((unsigned int)tbp & 0xF) == 0 && "Texture buffer pointer must be 16-byte aligned");
|
||||
assert(mipmap >= 0 && mipmap <= 7 && "Invalid mipmap level");
|
||||
assert(width >= 1 && width <= 512 && "Invalid texture width");
|
||||
assert(height >= 1 && height <= 512 && "Invalid texture height");
|
||||
assert(tbw >= 1 && tbw <= 1024 && "Invalid texture buffer width");
|
||||
assert((width & (width - 1)) == 0 && "Texture width must be power of 2");
|
||||
assert((height & (height - 1)) == 0 && "Texture height must be power of 2");
|
||||
#endif
|
||||
|
||||
GECommand texAddr = (GECommand)(TEX_ADDR0 + mipmap);
|
||||
GECommand texBufWidth = (GECommand)(TEX_BUF_WIDTH0 + mipmap);
|
||||
GECommand texSize = (GECommand)(TEX_SIZE0 + mipmap);
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
|
||||
void sceGuTexLevelMode(unsigned int mode, float bias)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexLevelMode(%08X, %f);\n", mode, bias);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((mode == GU_TEXTURE_AUTO || mode == GU_TEXTURE_CONST || mode == GU_TEXTURE_SLOPE) && "Invalid texture level mode");
|
||||
#endif
|
||||
|
||||
int offset = (int)truncf(bias * 16.0f);
|
||||
|
||||
// mip map bias?
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuTexMapMode(int mode, unsigned int lu, unsigned int lv)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexMapMode(%d, %08X, %08X);\n", mode, lu, lv);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((mode == GU_TEXTURE_COORDS || mode == GU_TEXTURE_MATRIX || mode == GU_ENVIRONMENT_MAP) && "Invalid texture map mode");
|
||||
#endif
|
||||
|
||||
GuContext *context = &gu_contexts[gu_curr_context];
|
||||
|
||||
context->texture_map_mode = mode & 0x03;
|
||||
|
||||
@@ -10,6 +10,16 @@
|
||||
|
||||
void sceGuTexMode(int tpsm, int maxmips, int mc, int swizzle)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexMode(%d, %d, %d, %d);\n", tpsm, maxmips, mc, swizzle);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((tpsm == GU_PSM_5650 || tpsm == GU_PSM_5551 || tpsm == GU_PSM_4444 ||
|
||||
tpsm == GU_PSM_8888 || tpsm == GU_PSM_T4 || tpsm == GU_PSM_T8) && "Invalid texture pixel format");
|
||||
assert(maxmips >= 0 && maxmips <= 7 && "Invalid max mipmaps");
|
||||
assert(mc >= 0 && mc <= 1 && "Invalid multiclut value");
|
||||
assert(swizzle >= 0 && swizzle <= 1 && "Invalid texture swizzle");
|
||||
#endif
|
||||
|
||||
GuContext *context = &gu_contexts[gu_curr_context];
|
||||
context->texture_mode = tpsm;
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
void sceGuTexOffset(float u, float v)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexOffset(%f, %f);\n", u, v);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandf(TEX_OFFSET_U, u);
|
||||
sendCommandf(TEX_OFFSET_V, v);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
void sceGuTexProjMapMode(int mode)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexProjMapMode(%d);\n", mode);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((mode == GU_POSITION || mode == GU_UV || mode == GU_NORMALIZED_NORMAL || mode == GU_NORMAL) && "Invalid texture projection map mode");
|
||||
#endif
|
||||
|
||||
GuContext *context = &gu_contexts[gu_curr_context];
|
||||
|
||||
context->texture_proj_map_mode = ((mode & 0x03) << 8);
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
void sceGuTexScale(float u, float v)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexScale(%f, %f);\n", u, v);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandf(TEX_SCALE_U, u);
|
||||
sendCommandf(TEX_SCALE_V, v);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,10 @@
|
||||
|
||||
void sceGuTexSlope(float slope)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexSlope(%f);\n", slope);
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandf(TEX_LOD_SLOPE, slope);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,10 @@
|
||||
|
||||
void sceGuTexSync()
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexSync();\n");
|
||||
assert(gu_init && "GU not initialized");
|
||||
#endif
|
||||
|
||||
sendCommandi(TEX_SYNC, 0);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,13 @@
|
||||
|
||||
void sceGuTexWrap(int u, int v)
|
||||
{
|
||||
sendCommandi(TEX_WRAP, (v << 8) | (u));
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuTexWrap(%d, %d);\n", u, v);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert((u == GU_CLAMP || u == GU_REPEAT) && "Invalid U wrap mode");
|
||||
assert((v == GU_CLAMP || v == GU_REPEAT) && "Invalid V wrap mode");
|
||||
#endif
|
||||
|
||||
int arg = u | (v << 8);
|
||||
sendCommandi(TEX_WRAP, arg);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,15 @@
|
||||
|
||||
void sceGuViewport(int cx, int cy, int width, int height)
|
||||
{
|
||||
#ifdef GU_DEBUG
|
||||
printf("sceGuViewport(%d, %d, %d, %d);\n", cx, cy, width, height);
|
||||
assert(gu_init && "GU not initialized");
|
||||
assert(width > 0 && height > 0 && "Invalid viewport dimensions");
|
||||
assert(width <= 4096 && height <= 4096 && "Viewport dimensions too large");
|
||||
assert(cx >= 0 && cx <= 4095 && "Invalid viewport X coordinate");
|
||||
assert(cy >= 0 && cy <= 4095 && "Invalid viewport Y coordinate");
|
||||
#endif
|
||||
|
||||
float sx, sy, tx, ty;
|
||||
sx = (float)(width) * 0.5f;
|
||||
sy = (float)(height) * -0.5f;
|
||||
|
||||
Reference in New Issue
Block a user