static.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
/**************************************************************************
* *
* 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()
};