Skip to content

Commit

Permalink
Merge pull request #68 from fjtrujy/listSpriteVertex
Browse files Browse the repository at this point in the history
Add list of vertices using sprite
  • Loading branch information
rickgaiser committed Aug 21, 2023
2 parents d5e8a99 + 6a51380 commit a745f10
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 174 deletions.
139 changes: 21 additions & 118 deletions ee/gs/include/gsInit.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,26 +291,20 @@
#define GSKIT_GIF_PRIM_TRIFAN_TEXTURED 0x1D00
#define GSKIT_GIF_PRIM_QUAD_TEXTURED 0x1E00

/// gsKit GIFTAG data format "FLG"
#define GSKIT_GIF_FLG_PACKED 0
#define GSKIT_GIF_FLG_REGLIST 1
#define GSKIT_GIF_FLG_IMAGE 2


// DMA Packet Header "GIF Tag" For Packets Sent To GIF

// A+D Data
/// A+D GIFTAG
#define GIF_TAG_AD(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(0) << 58) | \
((u64)(1) << 60);
#define GIF_TAG_AD(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_PACKED,1)
// Point Primitive
/// Point Primitive GIFTAG
#define GIF_TAG_POINT(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(4) << 60);
#define GIF_TAG_POINT(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,4)
/// Point Primitive REGLIST
#define GIF_TAG_POINT_REGS \
((u64)(GS_PRIM) << 0) | \
Expand All @@ -320,13 +314,7 @@

// Line Primitive
/// Line Primitive GIFTAG
#define GIF_TAG_LINE(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(4) << 60);
#define GIF_TAG_LINE(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,4)
/// Line Primitive REGLIST
#define GIF_TAG_LINE_REGS \
((u64)(GS_PRIM) << 0) | \
Expand All @@ -336,13 +324,7 @@

// Line Goraud Primitive
/// Line Goraud Primitive GIFTAG
#define GIF_TAG_LINE_GORAUD(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(6) << 60);
#define GIF_TAG_LINE_GORAUD(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,6)
/// Line Goraud Primitive REGLIST
#define GIF_TAG_LINE_GORAUD_REGS \
((u64)(GS_PRIM) << 0) | \
Expand All @@ -354,13 +336,7 @@

// Triangle Primitive
/// Triangle Primitive GIFTAG
#define GIF_TAG_TRIANGLE(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(6) << 60);
#define GIF_TAG_TRIANGLE(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,6)
/// Triangle Primitive REGLIST
#define GIF_TAG_TRIANGLE_REGS \
((u64)(GS_PRIM) << 0) | \
Expand All @@ -372,13 +348,7 @@

// Sprite Primitive
/// Sprite Primitive GIFTAG
#define GIF_TAG_SPRITE(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(4) << 60);
#define GIF_TAG_SPRITE(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,4)
/// Sprite Primitive REGLIST
#define GIF_TAG_SPRITE_REGS \
((u64)(GS_PRIM) << 0) | \
Expand All @@ -388,13 +358,7 @@

// Quad Primitive
/// Quad Primitive GIFTAG
#define GIF_TAG_QUAD(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(6) << 60);
#define GIF_TAG_QUAD(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,6)
/// Quad Primitive REGLIST
#define GIF_TAG_QUAD_REGS \
((u64)(GS_PRIM) << 0) | \
Expand All @@ -406,13 +370,7 @@

// Gouraud Shaded Triangle Primitive
/// Gouraud Shaded Triangle Primitive GIFTAG
#define GIF_TAG_TRIANGLE_GOURAUD(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(8) << 60);
#define GIF_TAG_TRIANGLE_GOURAUD(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,8)
/// Gouraud Shaded Triangle Primitive REGLIST
#define GIF_TAG_TRIANGLE_GOURAUD_REGS \
((u64)(GS_PRIM) << 0) | \
Expand All @@ -426,13 +384,7 @@

// Gouraud Shaded Quad Primitive
/// Gouraud Shaded Quad Primitive GIFTAG
#define GIF_TAG_QUAD_GOURAUD(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(10) << 60);
#define GIF_TAG_QUAD_GOURAUD(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,10)
/// Gouraud Shaded Quad Primitive REGLIST
#define GIF_TAG_QUAD_GOURAUD_REGS \
((u64)(GS_PRIM) << 0) | \
Expand All @@ -448,13 +400,7 @@

// Textured Sprite Primitive
/// Textured Sprite Primitive GIFTAG
#define GIF_TAG_SPRITE_TEXTURED(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(8) << 60);
#define GIF_TAG_SPRITE_TEXTURED(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,8)
/// Textured Sprite Primitive REGLIST
#define GIF_TAG_SPRITE_TEXTURED_REGS(ctx) \
((u64)(GS_TEX0_1 + ctx) << 0) | \
Expand All @@ -468,13 +414,7 @@

// Textured Triangle Primitive
/// Textured Triangle Primitive GIFTAG
#define GIF_TAG_TRIANGLE_TEXTURED(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(10) << 60);
#define GIF_TAG_TRIANGLE_TEXTURED(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,10)
/// Textured Triangle Primitive REGLIST
#define GIF_TAG_TRIANGLE_TEXTURED_REGS(ctx) \
((u64)(GS_TEX0_1 + ctx) << 0) | \
Expand All @@ -490,13 +430,7 @@

// Textured Quad Primitive
/// Textured Quad Primitive GIFTAG
#define GIF_TAG_QUAD_TEXTURED(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(12) << 60);
#define GIF_TAG_QUAD_TEXTURED(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,12)
/// Textured Quad Primitive REGLIST
#define GIF_TAG_QUAD_TEXTURED_REGS(ctx) \
((u64)(GS_TEX0_1 + ctx) << 0) | \
Expand All @@ -514,13 +448,7 @@

// Textured Triangle Goraud Primitive
/// Textured Triangle Goraud Primitive GIFTAG
#define GIF_TAG_TRIANGLE_GORAUD_TEXTURED(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(12) << 60);
#define GIF_TAG_TRIANGLE_GORAUD_TEXTURED(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,12)
/// Textured Triangle Goraud Primitive REGLIST
#define GIF_TAG_TRIANGLE_GORAUD_TEXTURED_REGS(ctx) \
((u64)(GS_TEX0_1 + ctx) << 0) | \
Expand All @@ -536,34 +464,9 @@
((u64)(GS_XYZ2) << 40) | \
((u64)(GIF_NOP) << 44);

/// Textured Triangle YV Goraud Primitive REGLIST
#define GIF_TAG_TRIANGLE_GORAUD_TEXTURED_UV_REGS(ctx) \
GIF_TAG_TRIANGLE_GORAUD_TEXTURED_REGS(ctx)

/// Textured Triangle STQ Goraud Primitive REGLIST
#define GIF_TAG_TRIANGLE_GORAUD_TEXTURED_STQ_REGS(ctx) \
((u64)(GS_TEX0_1 + ctx) << 0) | \
((u64)(GS_PRIM) << 4) | \
((u64)(GS_RGBAQ) << 8) | \
((u64)(GS_ST) << 12) | \
((u64)(GS_XYZ2) << 16) | \
((u64)(GS_RGBAQ) << 20) | \
((u64)(GS_ST) << 24) | \
((u64)(GS_XYZ2) << 28) | \
((u64)(GS_RGBAQ) << 32) | \
((u64)(GS_ST) << 36) | \
((u64)(GS_XYZ2) << 40) | \
((u64)(GIF_NOP) << 44);

// Textured Quad Goraud Primitive
/// Textured Quad Goraud Primitive GIFTAG
#define GIF_TAG_QUAD_GORAUD_TEXTURED(NLOOP) \
((u64)(NLOOP) << 0) | \
((u64)(1) << 15) | \
((u64)(0) << 46) | \
((u64)(0) << 47) | \
((u64)(1) << 58) | \
((u64)(14) << 60);
#define GIF_TAG_QUAD_GORAUD_TEXTURED(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,14)
/// Textured Quad Goraud Primitive REGLIST
#define GIF_TAG_QUAD_GORAUD_TEXTURED_REGS(ctx) \
((u64)(GS_TEX0_1 + ctx) << 0) | \
Expand Down Expand Up @@ -1080,7 +983,7 @@ typedef union {
};
} __attribute__((packed,aligned(8))) gs_rgbaq_t;

typedef union {
typedef union {
u64 st;
struct {
float s;
Expand Down
18 changes: 9 additions & 9 deletions ee/gs/include/gsPrimitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ extern "C" {
#endif

void gsKit_prim_point(GSGLOBAL *gsGlobal, float x, float y, int iz, u64 color);
void gsKit_prim_list_points(GSGLOBAL *gsGlobal, int count, const void *vertices);
void gsKit_prim_list_points(GSGLOBAL *gsGlobal, int count, const GSPRIMPOINT *vertices);

void gsKit_prim_line_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1,
float x2, float y2, int iz2, u64 color);

void gsKit_prim_line_goraud_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1, float x2, float y2, int iz2, u64 color1, u64 color2);
void gsKit_prim_list_line_goraud_3d(GSGLOBAL *gsGlobal, int count, const void *vertices);
void gsKit_prim_list_line_goraud_3d(GSGLOBAL *gsGlobal, int count, const GSPRIMPOINT *vertices);

void gsKit_prim_line_strip(GSGLOBAL *gsGlobal, float *LineStrip, int segments, int iz, u64 color);

Expand All @@ -64,8 +64,8 @@ void gsKit_prim_triangle_gouraud_3d(GSGLOBAL *gsGlobal, float x1, float y1, int
float x3, float y3, int iz3,
u64 color1, u64 color2, u64 color3);

void gsKit_prim_list_triangle_gouraud_3d(GSGLOBAL *gsGlobal, int count, const void *vertices);
void gsKit_prim_list_triangle_gouraud_3d(GSGLOBAL *gsGlobal, int count, const GSPRIMPOINT *vertices);

void gsKit_prim_quad_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1,
float x2, float y2, int iz2,
float x3, float y3, int iz3,
Expand All @@ -77,14 +77,14 @@ void gsKit_prim_quad_gouraud_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1,
float x4, float y4, int iz4,
u64 color1, u64 color2,
u64 color3, u64 color4);


#define gsKit_prim_line(gsGlobal, x1, y1, \
x2, y2, \
z, color) \
gsKit_prim_line_3d(gsGlobal, x1, y1, z, \
x2, y2, z, color);

#define gsKit_prim_line_goraud(gsGlobal, x1, y1, \
x2, y2, \
z, color1, color2) \
Expand Down Expand Up @@ -117,7 +117,7 @@ void gsKit_prim_quad_gouraud_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1,
x2, y2, z, \
x3, y3, z, \
x4, y4, z, color);

#define gsKit_prim_quad_gouraud(gsGlobal, x1, y1, \
x2, y2, \
x3, y3, \
Expand All @@ -127,8 +127,8 @@ void gsKit_prim_quad_gouraud_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1,
x2, y2, z, \
x3, y3, z, \
x4, y4, z, \
color1, color2, color3, color4);
color1, color2, color3, color4);


#ifdef __cplusplus
}
Expand Down
6 changes: 4 additions & 2 deletions ee/gs/include/gsTexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ void gsKit_prim_sprite_striped_texture_3d(GSGLOBAL *gsGlobal, const GSTEXTURE *T
float x2, float y2, int iz2, float u2, float v2,
u64 color);

void gskit_prim_list_sprite_texture_uv_3d(GSGLOBAL *gsGlobal, const GSTEXTURE *Texture, int count, const GSPRIMUVPOINT *vertices);

void gsKit_prim_triangle_texture_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
float x1, float y1, int iz1, float u1, float v1,
float x2, float y2, int iz2, float u2, float v2,
Expand All @@ -137,8 +139,8 @@ void gsKit_prim_triangle_goraud_texture_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Textur
float x3, float y3, int iz3, float u3, float v3,
u64 color1, u64 color2, u64 color3);

void gsKit_prim_list_triangle_goraud_texture_uv_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, int count, const void *vertices);
void gsKit_prim_list_triangle_goraud_texture_stq_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, int count, const void *vertices);
void gsKit_prim_list_triangle_goraud_texture_uv_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, int count, const GSPRIMUVPOINT *vertices);
void gsKit_prim_list_triangle_goraud_texture_stq_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, int count, const GSPRIMSTQPOINT *vertices);

void gsKit_prim_triangle_strip_texture(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
float *TriStrip, int segments, int iz, u64 color);
Expand Down
2 changes: 1 addition & 1 deletion ee/gs/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GS_TEXT_MANAGER_OBJS = gsTextManagerInternals.o gsKit_TexManager_init.o gsKit_Te

GS_TEXTURE_OBJS = gsKit_texture_size_ee.o gsKit_texture_size.o gsKit_texture_to_psm16.o \
gsKit_texture_send.o gsKit_texture_send_inline.o gsKit_texture_upload.o gsKit_prim_sprite_texture_3d.o \
gsKit_prim_sprite_striped_texture_3d.o gsKit_prim_triangle_texture_3d.o \
gsKit_prim_sprite_striped_texture_3d.o gsKit_prim_triangle_texture_3d.o gskit_prim_list_sprite_texture_uv_3d.o \
gsKit_prim_triangle_goraud_texture_3d.o gsKit_prim_list_triangle_goraud_texture_uv_3d.o gsKit_prim_list_triangle_goraud_texture_stq_3d.o \
gsKit_prim_triangle_strip_texture.o gsKit_prim_triangle_strip_texture_3d.o gsKit_prim_triangle_fan_texture.o \
gsKit_prim_triangle_fan_texture_3d.o gsKit_prim_quad_texture_3d.o gsKit_prim_quad_goraud_texture_3d.o
Expand Down
6 changes: 3 additions & 3 deletions ee/gs/src/gsCore.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void gsKit_setactive(GSGLOBAL *gsGlobal)

p_data = p_store = (u64 *)gsGlobal->dma_misc;

*p_data++ = GIF_TAG( 4, 1, 0, 0, 0, 1 );
*p_data++ = GIF_TAG( 4, 1, 0, 0, GSKIT_GIF_FLG_PACKED, 1 );
*p_data++ = GIF_AD;

// Context 1
Expand Down Expand Up @@ -287,7 +287,7 @@ void gsKit_set_scissor(GSGLOBAL *gsGlobal, u64 ScissorBounds) {
u64 *p_data;
u64 *p_store;

if (ScissorBounds == GS_SCISSOR_RESET)
if (ScissorBounds == GS_SCISSOR_RESET)
ScissorBounds = GS_SETREG_SCISSOR(0, gsGlobal->Width - 1, 0, gsGlobal->Height - 1);

p_data = p_store = gsKit_heap_alloc(gsGlobal, 1, 16, GIF_AD);
Expand Down Expand Up @@ -484,7 +484,7 @@ void gsKit_set_drawfield(GSGLOBAL *gsGlobal, u8 field)
(u32)p_data = (u32)p_store = gsGlobal->dma_misc;
*p_data++ = GIF_TAG( 1, 1, 0, 0, 0, 1);
*p_data++ = GIF_TAG( 1, 1, 0, 0, GSKIT_GIF_FLG_PACKED, 1);
*p_data++ = GIF_AD;
if (field == GS_FIELD_NORMAL) { //Draw both
Expand Down
2 changes: 1 addition & 1 deletion ee/gs/src/gsInit.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void gsKit_init_screen(GSGLOBAL *gsGlobal)

p_data = p_store = (u64 *)gsGlobal->dma_misc;

*p_data++ = GIF_TAG( size - 1, 1, 0, 0, 0, 1 );
*p_data++ = GIF_TAG( size - 1, 1, 0, 0, GSKIT_GIF_FLG_PACKED, 1 );
*p_data++ = GIF_AD;

*p_data++ = 1;
Expand Down
2 changes: 1 addition & 1 deletion ee/gs/src/gsMisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void gsKit_vram_dump(GSGLOBAL *gsGlobal, char *Path, u32 StartAddr, u32 EndAddr)
*p_data++ = DMA_TAG( 6, 0, DMA_CNT, 0, 0, 0 );
*p_data++ = 0;

*p_data++ = GIF_TAG( 5, 1, 0, 0, 0, 1 );
*p_data++ = GIF_TAG( 5, 1, 0, 0, GSKIT_GIF_FLG_PACKED, 1 );
*p_data++ = GIF_AD;

*p_data++ = GS_SETREG_BITBLTBUF(StartAddr / 64, (4095.9375 / 64), 0, 0, 0, 0);
Expand Down
Loading

0 comments on commit a745f10

Please sign in to comment.