Skip to content

Commit 95da2b3

Browse files
authored
Merge pull request #282 from fjtrujy/improve_scgeu
Keeps improving the `sceGu` definitions and implementation
2 parents 3b3dcde + 36a4b80 commit 95da2b3

Some content is hidden

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

41 files changed

+151
-99
lines changed

src/gu/pspgu.h

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ extern "C" {
5959
#define GU_FACE_NORMAL_REVERSE (19)
6060
#define GU_PATCH_FACE (20)
6161
#define GU_FRAGMENT_2X (21)
62+
#define GU_MAX_STATUS (22)
6263

6364
/* Matrix modes */
6465
#define GU_PROJECTION (0)
@@ -285,6 +286,15 @@ extern "C" {
285286
#define GU_SYNC_WHAT_STALL (3)
286287
#define GU_SYNC_WHAT_CANCEL (4)
287288

289+
/* Call mode */
290+
#define GU_CALL_NORMAL (0)
291+
#define GU_CALL_SIGNAL (1)
292+
293+
/* Signal models */
294+
#define GU_SIGNAL_WAIT (1)
295+
#define GU_SIGNAL_NOWAIT (2)
296+
#define GU_SIGNAL_PAUSE (3)
297+
288298
/* Signals */
289299
#define GU_CALLBACK_SIGNAL (1)
290300
#define GU_CALLBACK_FINISH (4)
@@ -293,6 +303,10 @@ extern "C" {
293303
#define GU_BEHAVIOR_SUSPEND (1)
294304
#define GU_BEHAVIOR_CONTINUE (2)
295305

306+
/* Break mode */
307+
#define GU_BREAK_PAUSE (0)
308+
#define GU_BREAK_CANCEL (1)
309+
296310
/* Color Macros, maps 8 bit unsigned channels into one 32-bit value */
297311
#define GU_ABGR(a,b,g,r) (((a) << 24)|((b) << 16)|((g) << 8)|(r))
298312
#define GU_ARGB(a,r,g,b) GU_ABGR((a),(b),(g),(r))
@@ -429,8 +443,22 @@ void sceGuInit(void);
429443
**/
430444
void sceGuTerm(void);
431445

432-
void sceGuBreak(int a0);
433-
void sceGuContinue(void);
446+
/**
447+
* Break the display list
448+
*
449+
* @param mode - Mode to break the display list. Valid modes are:
450+
* - GU_BREAK_PAUSE - Pause the display list
451+
* - GU_BREAK_CANCEL - Cancel drawing queue
452+
* @return 0 for success, < 0 for failure
453+
**/
454+
int sceGuBreak(int mode);
455+
456+
/**
457+
* Continue the display list
458+
*
459+
* @return 0 for success, < 0 for failure
460+
**/
461+
int sceGuContinue(void);
434462

435463
/**
436464
* Setup signal handler
@@ -962,7 +990,18 @@ void sceGuColorMaterial(int components);
962990
**/
963991
void sceGuAlphaFunc(int func, int value, int mask);
964992

993+
/**
994+
* Set the ambient light color
995+
*
996+
* @param color - The light color to set
997+
**/
965998
void sceGuAmbient(unsigned int color);
999+
1000+
/**
1001+
* Set the ambient color
1002+
*
1003+
* @param color - The color to set
1004+
**/
9661005
void sceGuAmbientColor(unsigned int color);
9671006

9681007
/**
@@ -1244,10 +1283,10 @@ void sceGuTexLevelMode(unsigned int mode, float bias);
12441283
* - GU_ENVIRONMENT_MAP
12451284
*
12461285
* @param mode - Which mode to use
1247-
* @param a1 - Unknown
1248-
* @param a2 - Unknown
1286+
* @param lu - Light U
1287+
* @param lv - Light V
12491288
**/
1250-
void sceGuTexMapMode(int mode, unsigned int a1, unsigned int a2);
1289+
void sceGuTexMapMode(int mode, unsigned int lu, unsigned int lv);
12511290

12521291
/**
12531292
* Set texture-mode parameters
@@ -1262,10 +1301,10 @@ void sceGuTexMapMode(int mode, unsigned int a1, unsigned int a2);
12621301
*
12631302
* @param tpsm - Which texture format to use
12641303
* @param maxmips - Number of mipmaps to use (0-8)
1265-
* @param a2 - Unknown, set to 0
1304+
* @param mc - Multiclut on/off (0/1)
12661305
* @param swizzle - GU_TRUE(1) to swizzle texture-reads
12671306
**/
1268-
void sceGuTexMode(int tpsm, int maxmips, int a2, int swizzle);
1307+
void sceGuTexMode(int tpsm, int maxmips, int mc, int swizzle);
12691308

12701309
/**
12711310
* Set texture offset
@@ -1345,7 +1384,7 @@ void sceGuClutLoad(int num_blocks, const void* cbp);
13451384
* @param cpsm - Which pixel format to use for the palette
13461385
* @param shift - Shifts color index by that many bits to the right
13471386
* @param mask - Masks the color index with this bitmask after the shift (0-0xFF)
1348-
* @param a3 - Unknown, set to 0
1387+
* @param csa - Read-out start location (16-palette units)
13491388
**/
13501389
void sceGuClutMode(unsigned int cpsm, unsigned int shift, unsigned int mask, unsigned int a3);
13511390

@@ -1410,7 +1449,12 @@ void sceGuDrawBezier(int vtype, int ucount, int vcount, const void* indices, con
14101449
**/
14111450
void sceGuPatchDivide(unsigned int ulevel, unsigned int vlevel);
14121451

1413-
void sceGuPatchFrontFace(unsigned int a0);
1452+
/**
1453+
* Set front face for patches (beziers and splines)
1454+
*
1455+
* @param mode - Desired front face mode (GU_CW | GU_CCW)
1456+
**/
1457+
void sceGuPatchFrontFace(unsigned int mode);
14141458

14151459
/**
14161460
* Set primitive for patches (beziers and splines)
@@ -1465,7 +1509,17 @@ void sceGuBoneMatrix(unsigned int index, const ScePspFMatrix4* matrix);
14651509
**/
14661510
void sceGuMorphWeight(int index, float weight);
14671511

1468-
void sceGuDrawArrayN(int primitive_type, int vertex_type, int count, int a3, const void* indices, const void* vertices);
1512+
/**
1513+
* Draw an array of primitives
1514+
*
1515+
* @param primitive_type - Type of primitive to draw
1516+
* @param vertex_type - Type of vertex to draw
1517+
* @param vcount - Number of vertices to draw
1518+
* @param primcount - Number of primitives to draw
1519+
* @param indices - Pointer to index buffer
1520+
* @param vertices - Pointer to vertex buffer
1521+
**/
1522+
void sceGuDrawArrayN(int primitive_type, int vertex_type, int vcount, int primcount, const void* indices, const void* vertices);
14691523

14701524
/**
14711525
* Set how the display should be set

src/gu/resetValues.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void resetValues()
1919
gu_object_stack_depth = 0;
2020

2121
gu_display_on = 0;
22-
gu_call_mode = 0;
22+
gu_call_mode = GU_CALL_NORMAL;
2323

2424
gu_draw_buffer.pixel_size = 1;
2525
gu_draw_buffer.frame_width = 0;

src/gu/sceGuAlphaFunc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
#include "guInternal.h"
1010

11-
void sceGuAlphaFunc(int a0, int a1, int a2)
11+
void sceGuAlphaFunc(int func, int value, int mask)
1212
{
13-
int arg = a0 | ((a1 & 0xff) << 8) | ((a2 & 0xff) << 16);
13+
int arg = func | ((value & 0xff) << 8) | ((mask & 0xff) << 16);
1414
sendCommandi(ALPHA_TEST, arg);
1515
}

src/gu/sceGuAmbient.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
void sceGuAmbient(unsigned int color)
1212
{
13-
sendCommandi(AMBIENT_LIGHT_COLOR,(color & 0xffffff));
13+
sendCommandi(AMBIENT_LIGHT_COLOR,(color));
1414
sendCommandi(AMBIENT_LIGHT_ALPHA,(color >> 24));
1515
}

src/gu/sceGuAmbientColor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
void sceGuAmbientColor(unsigned int color)
1212
{
13-
sendCommandi(AMBIENT_COLOR, color & 0xffffff);
13+
sendCommandi(AMBIENT_COLOR, color);
1414
sendCommandi(AMBIENT_ALPHA, color >> 24);
1515
}

src/gu/sceGuBeginObject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88

99
#include "guInternal.h"
1010

11-
void sceGuBeginObject(int vertex_type, int a1, const void *indices, const void *vertices)
11+
void sceGuBeginObject(int vertex_type, int count, const void *indices, const void *vertices)
1212
{
1313
if (vertex_type)
1414
sendCommandi(VERTEX_TYPE, vertex_type);
1515

1616
if (indices)
1717
{
1818
sendCommandi(BASE, (((unsigned int)indices) >> 8) & 0xf0000);
19-
sendCommandi(IADDR, ((unsigned int)indices) & 0xffffff);
19+
sendCommandi(IADDR, ((unsigned int)indices));
2020
}
2121

2222
if (vertices)
2323
{
2424
sendCommandi(BASE, (((unsigned int)vertices) >> 8) & 0x0f0000);
25-
sendCommandi(VADDR, ((unsigned int)vertices) & 0xffffff);
25+
sendCommandi(VADDR, ((unsigned int)vertices));
2626
}
2727

28-
sendCommandi(BOUNDING_BOX, a1);
28+
sendCommandi(BOUNDING_BOX, count);
2929

3030
// store start to new object
3131

src/gu/sceGuBlendFunc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
void sceGuBlendFunc(int op, int src, int dest, unsigned int srcfix, unsigned int destfix)
1212
{
1313
sendCommandi(BLEND_MODE, src | (dest << 4) | (op << 8));
14-
sendCommandi(BLEND_FIXED_A, srcfix & 0xffffff);
15-
sendCommandi(BLEND_FIXED_B, destfix & 0xffffff);
14+
sendCommandi(BLEND_FIXED_A, srcfix);
15+
sendCommandi(BLEND_FIXED_B, destfix);
1616
}

src/gu/sceGuBreak.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* Copyright (c) 2005 Jesper Svennevid
77
*/
88

9-
#include "guInternal.h"
9+
#include "pspge.h"
1010

11-
void sceGuBreak(int a0)
11+
int sceGuBreak(int mode)
1212
{
13-
// FIXME
14-
//sceGeBreak(a0,0x527a68);
13+
PspGeBreakParam bParam;
14+
return sceGeBreak(mode, &bParam);
1515
}

src/gu/sceGuCallList.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void sceGuCallList(const void *list)
1212
{
1313
unsigned int list_addr = (unsigned int)list;
1414

15-
if (gu_call_mode == 1)
15+
if (gu_call_mode == GU_CALL_SIGNAL)
1616
{
1717
sendCommandi(SIGNAL, (list_addr >> 16) | 0x110000);
1818
sendCommandi(END, list_addr & 0xffff);
@@ -21,6 +21,6 @@ void sceGuCallList(const void *list)
2121
else
2222
{
2323
sendCommandi(BASE, (list_addr >> 8) & 0xf0000);
24-
sendCommandiStall(CALL, list_addr & 0xffffff);
24+
sendCommandiStall(CALL, list_addr);
2525
}
2626
}

src/gu/sceGuClutLoad.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
void sceGuClutLoad(int num_blocks, const void *cbp)
1212
{
13-
sendCommandi(CLUT_BUF_PTR, ((unsigned int)cbp) & 0xffffff);
13+
sendCommandi(CLUT_BUF_PTR, ((unsigned int)cbp));
1414
sendCommandi(CLUT_BUF_WIDTH, (((unsigned int)cbp) >> 8) & 0xf0000);
1515
sendCommandi(CLUT_LOAD, num_blocks);
1616
}

0 commit comments

Comments
 (0)