static.c 7.01 KB

/**************************************************************************
 *                                                                        *
 *               Copyright (C) 1995, Silicon Graphics, Inc.               *
 *                                                                        *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
 *  are protected by Federal copyright  law.  They  may not be disclosed  *
 *  to  third  parties  or copied or duplicated in any form, in whole or  *
 *  in part, without the prior written consent of Silicon Graphics, Inc.  *
 *                                                                        *
 *************************************************************************/

#include <ultra64.h>
#include "fill.h"
#include "static.h"
#include "texture.h"

/* 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 | G_ZBUFFER),
  gsSPTexture(0, 0, 0, 0, G_OFF),
  gsSPEndDisplayList(),
};

/* initialize the RDP state: */
Gfx rdpinit_dl[] = 
{
  gsDPSetCycleType(G_CYC_1CYCLE),
  gsDPPipelineMode(G_PM_NPRIMITIVE),
  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_PERSP),
  gsDPSetTextureFilter(G_TF_BILERP),
  gsDPSetTextureConvert(G_TC_FILT),
  gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
  gsDPSetCombineKey(G_CK_NONE),
  gsDPSetAlphaCompare(G_AC_NONE),
  gsDPSetColorDither(G_CD_DISABLE),
  gsDPSetDepthImage(zbuffer),
  gsDPPipeSync(),
  gsSPEndDisplayList(),
};



/*
 *  Define my own load macro to save a few instructions
 *
 *  load as 8-bit, render as 4-bit
 */

#define myDPSetTextureTile(fmt, siz, uls, ult, lrs, lrt, 	\
		cms, cmt, masks, maskt, shifts, shiftt) 			\
			\
	gsDPSetTile(G_IM_FMT_CI, G_IM_SIZ_8b, (((((lrs)-(uls)+1)/2 * G_IM_SIZ_8b_TILE_BYTES)+7)>>3), 0, \
        G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks,  \
        shifts),											\
	gsDPSetTile(fmt, siz, (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \
        G_TX_RENDERTILE, 0, cmt, maskt, shiftt, cms, masks,   \
        shifts),	\
    gsDPSetTileSize(G_TX_RENDERTILE,                \
            (uls)<<G_TEXTURE_IMAGE_FRAC,            \
            (ult)<<G_TEXTURE_IMAGE_FRAC,            \
            (lrs)<<G_TEXTURE_IMAGE_FRAC,            \
            (lrt)<<G_TEXTURE_IMAGE_FRAC)



#define myDPLoadTextureTile( uls, ult, lrs, lrt)	\
			\
    gsDPLoadSync(),                         		\
    gsDPLoadTile(   G_TX_LOADTILE,                  \
            (uls)<<G_TEXTURE_IMAGE_FRAC,            \
            (ult)<<G_TEXTURE_IMAGE_FRAC,            \
            (lrs/2)<<G_TEXTURE_IMAGE_FRAC,            \
            (lrt)<<G_TEXTURE_IMAGE_FRAC)

Gfx copy4b_dl[] = {

    /* init some rdp params */
    gsDPPipeSync(),
    gsDPSetTextureLUT(G_TT_RGBA16),
    gsDPSetTexturePersp(G_TP_NONE),

    gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, rsp_cfb),
    gsDPSetCycleType(G_CYC_COPY),

	gsDPLoadTLUT_pal16(0, CI4mario_smalltlut),
    gsDPPipeSync(),
    gsDPSetTextureImage(G_IM_FMT_CI, G_IM_SIZ_8b, SCREEN_WD/2, 
		&(rsp_cfb[SCREEN_OFF])),
	/*
 	 *  exact values for sl,tl,sh,th don't matter since chunk we are 
	 *	copying is always the same size.
	 */
	myDPSetTextureTile(G_IM_FMT_CI, G_IM_SIZ_4b, 0, 0, 319, 11,
		G_TX_CLAMP, G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, 
		G_TX_NOLOD, G_TX_NOLOD),

	/*
 	 *  Copy 20 blocks of height 12, 320 elements per line
	 */
    myDPLoadTextureTile( 0, 0, 319, 11),
    gsSPTextureRectangle(0, 0, 1276,
            (11 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 12, 319, 23),
    gsSPTextureRectangle(0, (12 << 2), 1276,
            (23 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 24, 319, 35),
    gsSPTextureRectangle(0, (24 << 2), 1276,
            (35 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 36, 319, 47),
    gsSPTextureRectangle(0, (36 << 2), 1276,
            (47 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 48, 319, 59),
    gsSPTextureRectangle(0, (48 << 2), 1276,
            (59 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 60, 319, 71),
    gsSPTextureRectangle(0, (60 << 2), 1276,
            (71 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 72, 319, 83),
    gsSPTextureRectangle(0, (72 << 2), 1276,
            (83 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 84, 319, 95),
    gsSPTextureRectangle(0, (84 <<2), 1276,
            (95 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 96, 319, 107),
    gsSPTextureRectangle(0, (96 << 2), 1276,
            (107 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 108, 319, 119),
    gsSPTextureRectangle(0, (108 << 2), 1276,
            (119 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 120, 319, 131),
    gsSPTextureRectangle(0, (120 << 2), 1276,
            (131 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 132, 319, 143),
    gsSPTextureRectangle(0, (132 << 2), 1276,
            (143 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 144, 319, 155),
    gsSPTextureRectangle(0, (144 << 2), 1276,
            (155 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 156, 319, 167),
    gsSPTextureRectangle(0, (156 << 2), 1276,
            (167 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 168, 319, 179),
    gsSPTextureRectangle(0, (168 << 2), 1276,
            (179 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 180, 319, 191),
    gsSPTextureRectangle(0, (180 << 2), 1276,
            (191 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 192, 319, 203),
    gsSPTextureRectangle(0, (192 << 2), 1276,
            (203 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 204, 319, 215),
    gsSPTextureRectangle(0, (204 << 2), 1276,
            (215 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 216, 319, 227),
    gsSPTextureRectangle(0, (216 << 2), 1276,
            (227 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),

    myDPLoadTextureTile( 0, 228, 319, 239),
    gsSPTextureRectangle(0, (228 << 2), 1276,
            (239 << 2), G_TX_RENDERTILE,
            0, 0, 4096, 1024),


    gsSPEndDisplayList()
};