PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
draw_environment.c
1#include <tamtypes.h>
2
3#include <gif_tags.h>
4#include <gs_gp.h>
5
6#include <draw.h>
7
8qword_t *draw_pixel_alpha_control(qword_t *q, int enable)
9{
10
11 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
12 q++;
13 PACK_GIFTAG(q, GS_SET_PABE(enable), GS_REG_PABE);
14 q++;
15
16 return q;
17
18}
19
20qword_t *draw_alpha_blending(qword_t *q, int context, blend_t *blend)
21{
22
23 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
24 q++;
25 PACK_GIFTAG(q, GS_SET_ALPHA(blend->color1,blend->color2,blend->alpha,
26 blend->color3,blend->fixed_alpha), GS_REG_ALPHA + context);
27 q++;
28
29 return q;
30
31}
32
33qword_t *draw_framebuffer(qword_t *q, int context, framebuffer_t *frame)
34{
35
36 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
37 q++;
38 PACK_GIFTAG(q, GS_SET_FRAME(frame->address>>11,frame->width>>6,frame->psm,frame->mask), GS_REG_FRAME + context);
39 q++;
40
41 return q;
42
43}
44
45qword_t *draw_zbuffer(qword_t *q, int context, zbuffer_t *zbuffer)
46{
47
48 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
49 q++;
50 PACK_GIFTAG(q, GS_SET_ZBUF(zbuffer->address>>11,zbuffer->zsm,zbuffer->mask), GS_REG_ZBUF + context);
51 q++;
52
53 return q;
54
55}
56
57qword_t *draw_texturebuffer(qword_t *q, int context, texbuffer_t *texture, clutbuffer_t *clut)
58{
59
60 if(clut->storage_mode == CLUT_STORAGE_MODE2)
61 {
62 clut->start = 0;
63 }
64
65 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
66 q++;
67
68 PACK_GIFTAG(q, GS_SET_TEX0(texture->address>>6,texture->width>>6,texture->psm,
69 texture->info.width,texture->info.height,texture->info.components,texture->info.function,
70 clut->address>>6,clut->psm,clut->storage_mode,clut->start,clut->load_method), GS_REG_TEX0 + context);
71 q++;
72
73 return q;
74
75}
76
77qword_t *draw_clutbuffer(qword_t *q, int context, int psm, clutbuffer_t *clut)
78{
79
80 if (clut->storage_mode == CLUT_STORAGE_MODE2)
81 {
82 clut->start = 0;
83 }
84
85 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
86 q++;
87
88 PACK_GIFTAG(q, GS_SET_TEX2(psm,clut->address>>6,clut->psm,clut->storage_mode,clut->start,clut->load_method), GS_REG_TEX2 + context);
89 q++;
90
91 return q;
92
93}
94
95qword_t *draw_clut_offset(qword_t *q, int cbw, int u, int v)
96{
97
98 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
99 q++;
100
101 PACK_GIFTAG(q, GS_SET_TEXCLUT(cbw,u,v), GS_REG_TEXCLUT);
102 q++;
103
104 return q;
105
106}
107
108qword_t *draw_dithering(qword_t *q, int enable)
109{
110
111 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
112 q++;
113
114 PACK_GIFTAG(q, GS_SET_DTHE(enable), GS_REG_DTHE);
115 q++;
116
117 return q;
118
119}
120
121qword_t *draw_dither_matrix(qword_t *q,char *dm)
122{
123
124 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
125 q++;
126
127 PACK_GIFTAG(q, GS_SET_DIMX(dm[0], dm[1], dm[2], dm[3],
128 dm[4], dm[5], dm[6], dm[7],
129 dm[8], dm[9], dm[10],dm[11],
130 dm[12],dm[13],dm[14],dm[15]), GS_REG_DIMX);
131 q++;
132
133 return q;
134
135}
136
137qword_t *draw_fog_color(qword_t *q, unsigned char r, unsigned char g, unsigned char b)
138{
139
140 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
141 q++;
142
143 PACK_GIFTAG(q, GS_SET_FOGCOL(r,g,b), GS_REG_FOGCOL);
144 q++;
145
146 return q;
147
148}
149
150qword_t *draw_scan_masking(qword_t *q, int mask)
151{
152
153 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
154 q++;
155
156 PACK_GIFTAG(q,GS_SET_SCANMSK(mask),GS_REG_SCANMSK);
157 q++;
158
159 return q;
160
161}
162
163qword_t *draw_color_clamping(qword_t *q, int enable)
164{
165
166 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
167 q++;
168
169 PACK_GIFTAG(q,GS_SET_COLCLAMP(enable),GS_REG_COLCLAMP);
170 q++;
171
172 return q;
173
174}
175
176qword_t *draw_alpha_correction(qword_t *q, int context, int alpha)
177{
178
179 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
180 q++;
181
182 PACK_GIFTAG(q,GS_SET_FBA(alpha),GS_REG_FBA + context);
183 q++;
184
185 return q;
186
187}
188
189qword_t *draw_primitive_xyoffset(qword_t *q, int context, float x, float y)
190{
191
192 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
193 q++;
194
195 PACK_GIFTAG(q, GS_SET_XYOFFSET((int)(x*16.0f),(int)(y*16.0f)), GS_REG_XYOFFSET + context);
196 q++;
197
198 return q;
199
200}
201
202qword_t *draw_primitive_override(qword_t *q, int mode)
203{
204
205 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
206 q++;
207
208 PACK_GIFTAG(q, GS_SET_PRMODECONT(mode),GS_REG_PRMODECONT);
209 q++;
210
211 return q;
212
213}
214
215qword_t *draw_primitive_override_setting(qword_t *q, int context, prim_t *prim)
216{
217
218 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
219 q++;
220
221 PACK_GIFTAG(q, GS_SET_PRMODE(prim->shading,prim->mapping,prim->fogging,
222 prim->blending,prim->antialiasing,prim->mapping_type,
223 context,prim->colorfix), GS_REG_PRMODE);
224 q++;
225
226 return q;
227
228}
229
230qword_t *draw_texture_sampling(qword_t *q, int context, lod_t *lod)
231{
232
233 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
234 q++;
235
236 PACK_GIFTAG(q, GS_SET_TEX1(lod->calculation,lod->max_level,lod->mag_filter,lod->min_filter,lod->mipmap_select,lod->l,(int)(lod->k*16.0f)), GS_REG_TEX1 + context);
237 q++;
238
239 return q;
240
241}
242
243qword_t *draw_mipmap1(qword_t *q, int context, mipmap_t *mipmap)
244{
245
246 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
247 q++;
248
249 PACK_GIFTAG(q, GS_SET_MIPTBP1(mipmap->address1,mipmap->width1,
250 mipmap->address2,mipmap->width2,
251 mipmap->address3,mipmap->width3), GS_REG_MIPTBP1 + context);
252 q++;
253
254 return q;
255
256}
257
258qword_t *draw_mipmap2(qword_t *q, int context, mipmap_t *mipmap)
259{
260
261 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
262 q++;
263
264 PACK_GIFTAG(q, GS_SET_MIPTBP2(mipmap->address1,mipmap->width1,
265 mipmap->address2,mipmap->width2,
266 mipmap->address3,mipmap->width3), GS_REG_MIPTBP2 + context);
267 q++;
268
269 return q;
270
271}
272
273qword_t *draw_scissor_area(qword_t *q, int context, int x0, int x1, int y0, int y1)
274{
275
276 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
277 q++;
278
279 PACK_GIFTAG(q, GS_SET_SCISSOR(x0,x1,y0,y1), GS_REG_SCISSOR + context);
280 q++;
281
282 return q;
283
284}
285
286qword_t *draw_pixel_test(qword_t *q, int context, atest_t *atest, dtest_t *dtest, ztest_t *ztest)
287{
288
289 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
290 q++;
291
292 PACK_GIFTAG(q, GS_SET_TEST(atest->enable,atest->method,atest->compval,atest->keep,
293 dtest->enable,dtest->pass,
294 ztest->enable,ztest->method), GS_REG_TEST + context);
295 q++;
296
297 return q;
298
299}
300
301qword_t *draw_texture_wrapping(qword_t *q, int context, texwrap_t *wrap)
302{
303
304 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
305 q++;
306
307 PACK_GIFTAG(q, GS_SET_CLAMP(wrap->horizontal,wrap->vertical,wrap->minu,
308 wrap->maxu,wrap->minv,wrap->maxv), GS_REG_CLAMP + context);
309 q++;
310
311 return q;
312
313}
314
315qword_t *draw_texture_expand_alpha(qword_t *q, unsigned char zero_value, int expand, unsigned char one_value)
316{
317
318 PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0,GIF_FLG_PACKED,1), GIF_REG_AD);
319 q++;
320
321 PACK_GIFTAG(q, GS_SET_TEXA(zero_value,expand,one_value), GS_REG_TEXA);
322 q++;
323
324 return q;
325
326}
qword_t * draw_pixel_alpha_control(qword_t *q, int enable)
qword_t * draw_alpha_correction(qword_t *q, int context, int alpha)
qword_t * draw_alpha_blending(qword_t *q, int context, blend_t *blend)
qword_t * draw_framebuffer(qword_t *q, int context, framebuffer_t *frame)
qword_t * draw_clut_offset(qword_t *q, int cbw, int u, int v)
qword_t * draw_zbuffer(qword_t *q, int context, zbuffer_t *zbuffer)
qword_t * draw_texturebuffer(qword_t *q, int context, texbuffer_t *texbuffer, clutbuffer_t *clut)
qword_t * draw_clutbuffer(qword_t *q, int context, int psm, clutbuffer_t *clut)
qword_t * draw_dithering(qword_t *q, int enable)
qword_t * draw_dither_matrix(qword_t *q, char *dm)
qword_t * draw_fog_color(qword_t *q, unsigned char r, unsigned char g, unsigned char b)
qword_t * draw_color_clamping(qword_t *q, int enable)
qword_t * draw_scan_masking(qword_t *q, int mask)
qword_t * draw_primitive_override(qword_t *q, int mode)
qword_t * draw_primitive_override_setting(qword_t *q, int context, prim_t *prim)
qword_t * draw_primitive_xyoffset(qword_t *q, int context, float x, float y)
qword_t * draw_texture_expand_alpha(qword_t *q, unsigned char zero_value, int expand, unsigned char one_value)
qword_t * draw_mipmap1(qword_t *q, int context, mipmap_t *mipmap)
qword_t * draw_texture_wrapping(qword_t *q, int context, texwrap_t *wrap)
qword_t * draw_texture_sampling(qword_t *q, int context, lod_t *lod)
qword_t * draw_mipmap2(qword_t *q, int context, mipmap_t *mipmap)
qword_t * draw_scissor_area(qword_t *q, int context, int x0, int x1, int y0, int y1)
qword_t * draw_pixel_test(qword_t *q, int context, atest_t *atest, dtest_t *dtest, ztest_t *ztest)
#define GIF_REG_AD
Definition gif_tags.h:72
#define GIF_FLG_PACKED
Definition gif_tags.h:35
#define GS_REG_SCANMSK
Definition gs_gp.h:67
#define GS_REG_SCISSOR
Definition gs_gp.h:87
#define GS_REG_DTHE
Definition gs_gp.h:101
#define GS_REG_ZBUF
Definition gs_gp.h:125
#define GS_REG_PRMODECONT
Definition gs_gp.h:61
#define GS_REG_TEX1
Definition gs_gp.h:43
#define GS_REG_MIPTBP2
Definition gs_gp.h:75
#define GS_REG_FBA
Definition gs_gp.h:113
#define GS_REG_TEXCLUT
Definition gs_gp.h:65
#define GS_REG_TEXA
Definition gs_gp.h:81
#define GS_REG_TEX2
Definition gs_gp.h:49
#define GS_REG_CLAMP
Definition gs_gp.h:31
#define GS_REG_TEST
Definition gs_gp.h:105
#define GS_REG_DIMX
Definition gs_gp.h:99
#define GS_REG_FOGCOL
Definition gs_gp.h:83
#define GS_REG_XYOFFSET
Definition gs_gp.h:55
#define GS_REG_MIPTBP1
Definition gs_gp.h:69
#define GS_REG_PABE
Definition gs_gp.h:111
#define GS_REG_TEX0
Definition gs_gp.h:25
#define GS_REG_COLCLAMP
Definition gs_gp.h:103
#define GS_REG_PRMODE
Definition gs_gp.h:63
#define GS_REG_FRAME
Definition gs_gp.h:119
#define GS_REG_ALPHA
Definition gs_gp.h:93