init.c
7.01 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/**************************************************************************
* *
* Copyright (C) 1994, 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. *
* *
*************************************************************************/
/*
* File: init.c
* Creator: hsa@sgi.com
* Create Date: Fri Oct 14 11:54:48 PDT 1994
*
*
*/
#include <ultra64.h>
#include "rdpverif.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 */
};
Vp regression_viewport_d = {
SCREEN_WD/2, SCREEN_HT/2, G_MAXZ/2, 0, /* scale */
SCREEN_WD/2, SCREEN_HT/2, G_MAXZ/2, 0, /* translate */
};
Gfx setup_rdpstate[MAX_STATIC_GFX_SIZE] = {
/*
* Image pointers are translated via RSP segment registers.
* Preset segment register 0 with 0.
*/
gsSPSegment(0, 0),
/*
* This RDP initialization sequence will setup the following modes
*
* 1 cycle mode, point sampled, non-zbuffer, smooth shaded opaque polygons
*/
gsDPPipeSync(),
/*
* scissor must be larger than background clear rectangle
*/
/* dp */ gsDPSetScissor(G_SC_NON_INTERLACE, 0, 0, SCREEN_WD,
SCREEN_HT),
/* dp */ gsDPSetCycleType(G_CYC_1CYCLE),
/* XXX must do KSEG0_TO_PHYSICAL(zbuffer), referencing zbuffer now will use segment number 2 */
/* tx */ gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, zbuffer),
/* tx */ gsDPSetTextureLOD(G_TL_TILE),
/* tx */ gsDPSetTextureLUT(G_TT_NONE),
/* tx */ gsDPSetTextureDetail(G_TD_CLAMP),
/* tx */ gsDPSetTexturePersp(G_TP_PERSP),
/* tx */ gsDPSetTileSize(0, 0, 0, 0, 0), /* needed for verilog simulation */
/* tx */ gsDPSetTileSize(1, 0, 0, 0, 0), /* needed for verilog simulation */
/* tx */ gsDPSetTile(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), /* needed for verilog simulation */
/* tx */ gsDPSetTile(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0), /* needed for verilog simulation */
/* tf */ gsDPSetTextureFilter(G_TF_BILERP),
/* tf */ gsDPSetTextureConvert(G_TC_FILT),
/* cc */ gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
/* cc */ gsDPSetCombineKey(G_CK_NONE),
/* bl */ gsDPSetAlphaCompare(G_AC_NONE),
/* bl */ gsDPSetDepthSource(G_ZS_PIXEL),
/* bl */ /* gsDPSetRenderMode(G_RM_PASS, G_RM_AA_ZB_OPA_SURF2), */
/* bl */ gsDPSetRenderMode(G_RM_OPA_SURF, G_RM_OPA_SURF2),
/* bl */ gsDPSetBlendMask(0xff),
/* mi */ gsDPSetColorDither(G_CD_DISABLE),
/* XXX must do KSEG0_TO_PHYSICAL(zbuffer), referencing zbuffer now will use segment number 2 */
/* mi */ gsDPSetDepthImage(zbuffer),
gsSPEndDisplayList(),
};
Gfx setup_rspstate[MAX_STATIC_GFX_SIZE] = {
/* XXX Initialize the matrix stack after we change host init DMEM */
gsSPViewport(&vp),
gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH | G_CULL_BACK),
gsSPEndDisplayList(),
};
Gfx clear_fb[MAX_STATIC_GFX_SIZE] = {
gsDPPipeSync(),
gsDPSetCycleType(G_CYC_FILL),
/*
* clear color, cvg = FULL or 1
*/
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, cfb_16_a),
gsDPSetFillColor(GPACK_RGBA5551(0,200,200,1) << 16 | GPACK_RGBA5551(0,200,200,1)),
gsDPFillRectangle(0, 0, SCREEN_WD-1, SCREEN_HT-1),
gsDPNoOp(),
/*
* clear z, z = max z, dz = 0
*/
gsDPPipeSync(),
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, zbuffer),
gsDPSetFillColor(GPACK_ZDZ(G_MAXFBZ, 0) << 16 | GPACK_ZDZ(G_MAXFBZ, 0)),
gsDPFillRectangle(0, 0, SCREEN_WD-1, SCREEN_HT-1),
gsDPNoOp(),
gsDPPipeSync(),
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, cfb_16_a),
gsDPSetCycleType(G_CYC_1CYCLE),
gsSPEndDisplayList(),
};
Gfx fake_clear_fb[MAX_STATIC_GFX_SIZE] = {
gsDPPipeSync(),
gsDPSetCycleType(G_CYC_FILL),
/*
* clear color, cvg = FULL or 1
*/
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, cfb_16_a),
gsDPSetFillColor(GPACK_RGBA5551(0,200,200,1) << 16 | GPACK_RGBA5551(0,200,200,1)),
/*
* This is fake clear which the c model and rtl understand
*/
gsDPSetColorImage(5, G_IM_SIZ_16b, SCREEN_WD, cfb_16_a),
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, cfb_16_a),
/*
* clear z, z = max z, dz = 0
*/
gsDPPipeSync(),
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, zbuffer),
gsDPSetFillColor(GPACK_ZDZ(G_MAXFBZ, 0) << 16 | GPACK_ZDZ(G_MAXFBZ, 0)),
gsDPSetColorImage(5, G_IM_SIZ_16b, SCREEN_WD, zbuffer),
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, zbuffer),
gsDPPipeSync(),
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, cfb_16_a),
gsDPSetCycleType(G_CYC_1CYCLE),
gsSPEndDisplayList(),
};
Gfx clear_32fb[] = {
gsDPPipeSync(),
gsDPSetCycleType(G_CYC_FILL),
/*
* clear color, cvg = FULL or 1
*/
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_32b, SCREEN_WD, cfb_16_a),
gsDPSetFillColor((0<<24) | (200<<16) | (200 << 8) | 0xff),
/* gsDPSetFillColor(0), */
gsDPFillRectangle(0, 0, SCREEN_WD-1, SCREEN_HT-1),
gsDPNoOp(),
/*
* clear z, z = max z, dz = 0
*/
gsDPPipeSync(),
/* XXX must do KSEG0_TO_PHYSICAL(zbuffer), referencing zbuffer now will use segment number 2 */
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, zbuffer),
gsDPSetFillColor(GPACK_ZDZ(G_MAXFBZ, 0) << 16 | GPACK_ZDZ(G_MAXFBZ, 0)),
gsDPFillRectangle(0, 0, SCREEN_WD-1, SCREEN_HT-1),
gsDPNoOp(),
gsDPPipeSync(),
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_32b, SCREEN_WD, cfb_16_a),
gsDPSetCycleType(G_CYC_1CYCLE),
gsSPEndDisplayList(),
};
Gfx fake_clear_32fb[] = {
gsDPPipeSync(),
gsDPSetCycleType(G_CYC_FILL),
/*
* clear color, cvg = FULL or 1
*/
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_32b, SCREEN_WD, cfb_16_a),
gsDPSetFillColor((0<<24) | (200<<16) | (200 << 8) | 0xff),
/* gsDPSetFillColor(0), */
gsDPSetColorImage(5, G_IM_SIZ_32b, SCREEN_WD, cfb_16_a),
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_32b, SCREEN_WD, cfb_16_a),
/*
* clear z, z = max z, dz = 0
*/
gsDPPipeSync(),
/* XXX must do KSEG0_TO_PHYSICAL(zbuffer), referencing zbuffer now will use segment number 2 */
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, zbuffer),
gsDPSetFillColor(GPACK_ZDZ(G_MAXFBZ, 0) << 16 | GPACK_ZDZ(G_MAXFBZ, 0)),
gsDPSetColorImage(5, G_IM_SIZ_16b, SCREEN_WD, zbuffer),
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD, zbuffer),
gsDPPipeSync(),
gsDPSetColorImage(G_IM_FMT_RGBA, G_IM_SIZ_32b, SCREEN_WD, cfb_16_a),
gsDPSetCycleType(G_CYC_1CYCLE),
gsSPEndDisplayList(),
};
/*
* smaller viewport for optional regression tests.
*/
Gfx regression_viewport[MAX_STATIC_GFX_SIZE] = {
gsSPViewport(®ression_viewport_d),
gsSPEndDisplayList(),
};