Skip to content

Commit b1bf44e

Browse files
committed
Adding assertions
- Adding assertions to each specific sceGu function - Also adding printf for verbose output
1 parent 541277e commit b1bf44e

File tree

88 files changed

+595
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+595
-10
lines changed

src/gu/guInternal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ int gu_display_on;
1919
int gu_call_mode;
2020
int gu_states;
2121
GuDrawBuffer gu_draw_buffer;
22-
unsigned int* gu_object_stack[32];
22+
unsigned int* gu_object_stack[GU_OBJECT_STACK_SIZE];
2323
int gu_object_stack_depth;

src/gu/guInternal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <stdio.h>
1717
#endif
1818

19+
#define GU_OBJECT_STACK_SIZE 32
20+
1921
typedef void (*GuCallback)(int);
2022

2123
typedef struct

src/gu/sceGuAlphaFunc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
void sceGuAlphaFunc(int func, int value, int mask)
1212
{
13+
#ifdef GU_DEBUG
14+
printf("sceGuAlphaFunc(%d, %d, %d);\n", func, value, mask);
15+
assert(gu_init && "GU not initialized");
16+
assert(func >= GU_NEVER && func <= GU_GEQUAL && "Invalid alpha function");
17+
#endif
18+
1319
int arg = func | ((value & 0xff) << 8) | ((mask & 0xff) << 16);
1420
sendCommandi(ALPHA_TEST, arg);
1521
}

src/gu/sceGuAmbient.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
void sceGuAmbient(unsigned int color)
1212
{
13+
#ifdef GU_DEBUG
14+
printf("sceGuAmbient(%08X);\n", color);
15+
assert(gu_init && "GU not initialized");
16+
#endif
17+
1318
sendCommandi(AMBIENT_LIGHT_COLOR,(color));
1419
sendCommandi(AMBIENT_LIGHT_ALPHA,(color >> 24));
1520
}

src/gu/sceGuAmbientColor.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
void sceGuAmbientColor(unsigned int color)
1212
{
13+
#ifdef GU_DEBUG
14+
printf("sceGuAmbientColor(0x%08X);\n", color);
15+
assert(gu_init && "GU not initialized");
16+
#endif
17+
1318
sendCommandi(AMBIENT_COLOR, color);
1419
sendCommandi(AMBIENT_ALPHA, color >> 24);
1520
}

src/gu/sceGuBeginObject.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
void sceGuBeginObject(int vertex_type, int count, const void *indices, const void *vertices)
1212
{
13+
#ifdef GU_DEBUG
14+
printf("sceGuBeginObject(%d, %d, %p, %p);\n", vertex_type, count, indices, vertices);
15+
assert(gu_init && "GU not initialized");
16+
assert(count > 0 && count <= 255 && (count % 8) == 0 && "Invalid vertex count - must be positive, <= 65535, and multiple of 8");
17+
assert(gu_object_stack_depth < GU_OBJECT_STACK_SIZE && "Object stack overflow");
18+
#endif
19+
1320
if (vertex_type)
1421
sendCommandi(VERTEX_TYPE, vertex_type);
1522

src/gu/sceGuBlendFunc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010

1111
void sceGuBlendFunc(int op, int src, int dest, unsigned int srcfix, unsigned int destfix)
1212
{
13+
#ifdef GU_DEBUG
14+
printf("sceGuBlendFunc(%d, %d, %d, 0x%08X, 0x%08X);\n", op, src, dest, srcfix, destfix);
15+
assert(gu_init && "GU not initialized");
16+
assert(op >= GU_ADD && op <= GU_ABS && "Invalid blend operation");
17+
assert(src >= GU_OTHER_COLOR && src <= GU_FIX && "Invalid source blend factor");
18+
assert(dest >= GU_OTHER_COLOR && dest <= GU_FIX && "Invalid destination blend factor");
19+
#endif
20+
1321
sendCommandi(BLEND_MODE, src | (dest << 4) | (op << 8));
1422
sendCommandi(BLEND_FIXED_A, srcfix);
1523
sendCommandi(BLEND_FIXED_B, destfix);

src/gu/sceGuBoneMatrix.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
void sceGuBoneMatrix(unsigned int index, const ScePspFMatrix4 *matrix)
1212
{
13+
#ifdef GU_DEBUG
14+
printf("sceGuBoneMatrix(%d, %p);\n", index, matrix);
15+
assert(gu_init && "GU not initialized");
16+
assert(index < 8 && "Invalid bone matrix index");
17+
#endif
18+
1319
unsigned int offset = ((index << 1) + index) << 2; // 3*4 matrix
1420
unsigned int i, j;
1521
const float *fmatrix = (const float *)matrix;

src/gu/sceGuCallList.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
int sceGuCallList(const void *list)
1212
{
13+
#ifdef GU_DEBUG
14+
printf("sceGuCallList(%p);\n", list);
15+
assert(gu_init && "GU not initialized");
16+
#endif
17+
1318
int res;
1419
unsigned int list_addr = (unsigned int)list;
1520

src/gu/sceGuCallMode.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,11 @@
1010

1111
void sceGuCallMode(int mode)
1212
{
13+
#ifdef GU_DEBUG
14+
printf("sceGuCallMode(%d);\n", mode);
15+
assert(gu_init && "GU not initialized");
16+
assert(mode >= GU_CALL_NORMAL && mode <= GU_CALL_SIGNAL && "Invalid call mode");
17+
#endif
18+
1319
gu_call_mode = mode;
1420
}

0 commit comments

Comments
 (0)