static.c
4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
* 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(),
};