static.c 4.17 KB
/*
 * static.c
 *
 * Contains static display lists for trivial.c
 *
 */

#include "trivial.h"

/*
 * Z-buffer.  Defined in zbuf.c 
 */
extern unsigned short zbuffer[];

/*
 * Remember, viewport structures have 2 bits of fraction in them.
 */
static Vp       vp =
{
	SCREEN_WD * 2, SCREEN_HT * 2, G_MAXZ / 2, 0,	/*
													 * scale 
													 */
	SCREEN_WD * 2, SCREEN_HT * 2, G_MAXZ / 2, 0,	/*
													 * translate 
													 */
};

/*
 * initialize the RSP state: 
 */
Gfx             rspinit_dl[] =
{
	gsSPViewport(&vp),
	gsSPClearGeometryMode(G_SHADE | G_SHADING_SMOOTH | G_CULL_BOTH |
						  G_FOG | G_LIGHTING | G_TEXTURE_GEN |
						  G_TEXTURE_GEN_LINEAR | G_LOD),
	gsSPTexture(0, 0, 0, 0, G_OFF),
	gsSPEndDisplayList(),
};

/*
 * initialize the RDP state: 
 */
Gfx             rdpinit_dl[] =
{
	gsDPSetCycleType(G_CYC_1CYCLE),
	gsDPPipelineMode(G_PM_1PRIMITIVE),
	gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0, SCREEN_WD, SCREEN_HT),
	gsDPSetTextureLOD(G_TL_TILE),
	gsDPSetTextureLUT(G_TT_NONE),
	gsDPSetTextureDetail(G_TD_CLAMP),
	gsDPSetTexturePersp(G_TP_NONE),
	gsDPSetTextureFilter(G_TF_BILERP),
	gsDPSetTextureConvert(G_TC_FILT),
	gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
	gsDPSetCombineKey(G_CK_NONE),
	gsDPSetAlphaCompare(G_AC_NONE),
	gsDPSetDepthSource(G_ZS_PIXEL),
	gsDPSetColorDither(G_CD_DISABLE),
	gsDPPipeSync(),
	gsSPEndDisplayList(),
};

/*
 * Clear the CFB and Zbuf
 * * A gDPSetColorImage must be done before this display list is called,
 * * (and afterwards as well before drawing).
 */
Gfx             scrnclr_dl[] =
{
	gsDPPipeSync(),				/*
								 * Not sure if necessary 
								 */
  /*
   * When in fill mode, must not have AA or ZBUF bits set 
   */
	gsDPSetRenderMode(G_RM_OPA_SURF, G_RM_OPA_SURF2),
	gsDPSetCycleType(G_CYC_FILL),
  /*
   * Clear color; coverage = 1 
   */
	gsDPSetFillColor(GPACK_RGBA5551(0, 0, 0, 1) << 16 |
					 GPACK_RGBA5551(0, 0, 0, 1)),
	gsDPFillRectangle(0, 0, SCREEN_WD - 1, SCREEN_HT - 1),
	gsDPNoOp(),					/*
								 * Necessary ? 
								 */
	gsDPPipeSync(),
  /*
   * Clear Z, z = max z, dz = 0 
   */
	gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD,
					  OS_K0_TO_PHYSICAL(zbuffer)),
	gsDPSetFillColor(GPACK_ZDZ(G_MAXFBZ, 0) << 16 | GPACK_ZDZ(G_MAXFBZ, 0)),
	gsDPFillRectangle(0, 0, SCREEN_WD - 1, SCREEN_HT - 1),
	gsDPNoOp(),					/*
								 * Necessary ? 
								 */
	gsDPPipeSync(),
	gsDPSetCycleType(G_CYC_1CYCLE),		/*
										 * Put 1-cycle mode back 
										 */
  /*
   *  Set the rasterization mode we'll use for triangles.
   * Rasterization Mode = Anti-aliased, Z-buffered; Opaque surfaces.
   */
	gsDPSetRenderMode(G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2),
	gsSPEndDisplayList()
};

/*
 * This group of vertices, and accompanying display list, demonstrate
 * three overlapping (in Z) Gouraud triangles.
 */
static Vtx      s3overlap_vtx[] =
{
	{-100, 70, -9, 0,       0, 128 << 6, 0x00, 0x00, 0xff, 0xff},
	{-100, 10, -9, 0, 64 << 6, 128 << 6, 0x00, 0xff, 0x00, 0xff},
	{100, 40, -5, 0,  64 << 6,       0, 0xff, 0x00, 0x00, 0xff},
	{-10, -90, -9, 0,       0, 128 << 6, 0x00, 0x00, 0xff, 0xff},
	{40, -50, -9, 0,  64 << 6, 128 << 6, 0x00, 0xff, 0x00, 0xff},
	{-100, 90, -5, 0, 64 << 6,       0, 0xff, 0x00, 0x00, 0xff},
	{100, 70, -9, 0,        0, 128 << 6, 0x00, 0x00, 0xff, 0xff},
	{50, 100, -9, 0,  64 << 6, 128 << 6, 0x00, 0xff, 0x00, 0xff},
	{-40, -90, -5, 0, 64 << 6,       0, 0xff, 0x00, 0x00, 0xff}
};

Gfx             shadeoverlaptri_dl[] =
{
	gsSPSetGeometryMode(G_SHADE | G_SHADING_SMOOTH | G_ZBUFFER),
	gsSPVertex(&(s3overlap_vtx[0]), 9, 0),
	gsSP1Triangle(0, 1, 2, 0),
	gsSP1Triangle(3, 4, 5, 0),
	gsSP1Triangle(6, 7, 8, 0),
	gsSPEndDisplayList(),
};


#include "brick.h"

Gfx             texrect_dl[] =
{
	gsSPSetGeometryMode(G_SHADE | G_SHADING_SMOOTH | G_ZBUFFER),
	gsSPTexture(0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON),
	gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB),
	gsDPSetTextureFilter(G_TF_BILERP),
	gsDPLoadTextureBlock(brick, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0,
             G_TX_WRAP | G_TX_MIRROR, G_TX_WRAP | G_TX_MIRROR,
             5, 5, G_TX_NOLOD, G_TX_NOLOD),
	gsSPVertex(&(s3overlap_vtx[0]), 9, 0),
	gsSP1Triangle(0, 1, 2, 0),
	gsSP1Triangle(3, 4, 5, 0),
	gsSP1Triangle(6, 7, 8, 0),
	gsSPEndDisplayList(),
};