ScummVM API documentation
psx_pcgpu.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef ICB_LIBGPU_H_
28 #define ICB_LIBGPU_H_
29 
30 namespace ICB {
31 
32 
33 // For storing user data in the OT entry e.g. texture pointer
34 extern void *OTusrData;
35 
36 #define OTSetUser(usr) OTusrData = (usr)
37 
38 // For choosing which texture to store in the OT list
39 #define ChooseTexture(texture) OTSetUser((texture))
40 
41 /*
42  * Primitive list:
43  *
44  * Name |Size*1|Shade |Vertex |Texture| Function
45  * ---------+------+-------+-------+-------+------------------------
46  * POLY_F3 | 6 |Flat | 3 |OFF | Flat Triangle
47  * POLY_FT3 | 9 |Flat | 3 |ON | Flat Textured Triangle
48  * POLY_G3 | 8 |Gouraud| 3 |OFF | Gouraud Triangle
49  * POLY_GT3 |11 |Gouraud| 3 |ON | Gouraud Textured Triangle
50  * POLY_F4 | 7 |Flat | 4 |OFF | Flat Quadrangle
51  * POLY_FT4 |11 |Flat | 4 |ON | Flat Textured Quadrangle
52  * POLY_G4 |10 |Gouraud| 4 |OFF | Gouraud Quadrangle
53  * POLY_GT4 |14 |Gouraud| 4 |ON | Gouraud Textured Quadrangle
54  * ---------+------+-------+-------+-------+------------------------
55  * LINE_F2 | 5 |Flat | 2 | - | unconnected Flat Line
56  * LINE_G2 | 6 |Gouraud| 2 | - | unconnected Gouraud Line
57  * LINE_F3 | 7 |Flat | 3 | - | 3-connected Flat Line
58  * LINE_G3 | 9 |Gouraud| 3 | - | 3-connected Gouraud Line
59  * LINE_F4 | 8 |Flat | 4 | - | 4-connected Flat Line
60  * LINE_G4 |11 |Gouraud| 4 | - | 4-connected Gouraud Line
61  * ---------+------+-------+-------+-------+------------------------
62  * SPRT | 6 |Flat | 1 |ON | free size Sprite
63  * SPRT_16 | 5 |Flat | 1 |ON | 16x16 Sprite
64  * SPRT_8 | 5 |Flat | 1 |ON | 8x8 Sprite
65  * ---------+------+-------+-------+-------+------------------------
66  * TILE | 5 |Flat | 1 |OFF | free size Sprite
67  * TILE_16 | 4 |Flat | 1 |OFF | 16x16 Sprite
68  * TILE_8 | 4 |Flat | 1 |OFF | 8x8 Sprite
69  * TILE_1 | 4 |Flat | 1 |OFF | 1x1 Sprite
70  * ---------+------+-------+-------+-------+------------------------
71  * DR_TWIN | 3 | - | - | - | Texture Window
72  * DR_AREA | 3 | - | - | - | Drawing Area
73  * DR_OFFSET| 3 | - | - | - | Drawing Offset
74  * DR_MODE | 3 | - | - | - | Drawing Mode
75  * DR_ENV |16 | - | - | - | Drawing Environment
76  * DR_MOVE | 6 | - | - | - | MoveImage
77  * DR_LOAD |17 | - | - | - | LoadImage
78  * DR_TPAGE | 2 | - | - | - | Drawing TPage
79  * DR_STP | 3 | - | - | - | Drawing STP
80  *
81  * *1: in int32-word
82  *
83  * Texture Attributes:
84  * abr: ambient rate
85  * abr 0 1 2 3
86  * -------------------------------------
87  * Front 0.5 1.0 0.5 -1.0
88  * Back 0.5 1.0 1.0 1.0
89  *
90  * tp: texture mode
91  * tp 0 1 2
92  * -----------------------------
93  * depth 4bit 8bit 16bit
94  * color CLUT CLUT DIRECT
95  */
96 
97 /*
98  * Time-out Cycle
99  */
100 #define WAIT_TIME 0x800000
101 
102 /*
103  * General Macros
104  */
105 #define limitRange(x, l, h) ((x) = ((x) < (l) ? (l) : (x) > (h) ? (h) : (x)))
106 
107 /*
108  * Set/Add Vector/Rectangle Attributes
109  */
110 #define setVector(v, _x, _y, _z) (v)->vx = _x, (v)->vy = _y, (v)->vz = _z
111 
112 #define applyVector(v, _x, _y, _z, op) (v)->vx op _x, (v)->vy op _y, (v)->vz op _z
113 
114 #define copyVector(v0, v1) (v0)->vx = (v1)->vx, (v0)->vy = (v1)->vy, (v0)->vz = (v1)->vz
115 
116 #define addVector(v0, v1) (v0)->vx += (v1)->vx, (v0)->vy += (v1)->vy, (v0)->vz += (v1)->vz
117 
118 #define dumpVector(str, v) GPU_printf("%s=(%d,%d,%d)\n", str, (v)->vx, (v)->vy, (v)->vz)
119 
120 #define dumpMatrix(x) \
121  GPU_printf("\t%5d,%5d,%5d\n", (x)->m[0][0], (x)->m[0][1], (x)->m[0][2]), GPU_printf("\t%5d,%5d,%5d\n", (x)->m[1][0], (x)->m[1][1], (x)->m[1][2]), \
122  GPU_printf("\t%5d,%5d,%5d\n", (x)->m[2][0], (x)->m[2][1], (x)->m[2][2])
123 
124 #define setRECT(r, _x, _y, _w, _h) (r)->x = (_x), (r)->y = (_y), (r)->w = (_w), (r)->h = (_h)
125 
126 /*
127  * Set Primitive Attributes
128  */
129 #define setTPage(p, tp, abr, x, y) ((p)->tpage = getTPage(tp, abr, x, y))
130 
131 #define setClut(p, x, y) ((p)->clut = getClut(x, y))
132 
133 /*
134  * Set Primitive Colors
135  */
136 #define setRGB0(p, _r0, _g0, _b0) (p)->r0 = _r0, (p)->g0 = _g0, (p)->b0 = _b0
137 
138 #define setRGB1(p, _r1, _g1, _b1) (p)->r1 = _r1, (p)->g1 = _g1, (p)->b1 = _b1
139 
140 #define setRGB2(p, _r2, _g2, _b2) (p)->r2 = _r2, (p)->g2 = _g2, (p)->b2 = _b2
141 
142 #define setRGB3(p, _r3, _g3, _b3) (p)->r3 = _r3, (p)->g3 = _g3, (p)->b3 = _b3
143 
144 /*
145  * Set Primitive Screen Points
146  */
147 #define setXY0(p, _x0, _y0) (p)->x0 = (_x0), (p)->y0 = (_y0)
148 
149 #define setXY2(p, _x0, _y0, _x1, _y1) (p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x1), (p)->y1 = (_y1)
150 
151 #define setXY3(p, _x0, _y0, _x1, _y1, _x2, _y2) (p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x1), (p)->y1 = (_y1), (p)->x2 = (_x2), (p)->y2 = (_y2)
152 
153 #define setXY4(p, _x0, _y0, _x1, _y1, _x2, _y2, _x3, _y3) \
154  (p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x1), (p)->y1 = (_y1), (p)->x2 = (_x2), (p)->y2 = (_y2), (p)->x3 = (_x3), (p)->y3 = (_y3)
155 
156 #define setXYWH(p, _x0, _y0, _w, _h) \
157  (p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x0) + (_w), (p)->y1 = (_y0), (p)->x2 = (_x0), (p)->y2 = (_y0) + (_h), (p)->x3 = (_x0) + (_w), (p)->y3 = (_y0) + (_h)
158 
159 /*
160  * Set Primitive Width/Height
161  */
162 #define setWH(p, _w, _h) (p)->w = _w, (p)->h = _h
163 
164 /*
165  * Set Primitive Texture Points
166  */
167 #define setUV0(p, _u0, _v0) (p)->u0 = (_u0), (p)->v0 = (_v0)
168 
169 #define setUV3(p, _u0, _v0, _u1, _v1, _u2, _v2) (p)->u0 = (_u0), (p)->v0 = (_v0), (p)->u1 = (_u1), (p)->v1 = (_v1), (p)->u2 = (_u2), (p)->v2 = (_v2)
170 
171 #define setUV4(p, _u0, _v0, _u1, _v1, _u2, _v2, _u3, _v3) \
172  (p)->u0 = (_u0), (p)->v0 = (_v0), (p)->u1 = (_u1), (p)->v1 = (_v1), (p)->u2 = (_u2), (p)->v2 = (_v2), (p)->u3 = (_u3), (p)->v3 = (_v3)
173 
174 #define setUVWH(p, _u0, _v0, _w, _h) \
175  (p)->u0 = (_u0), (p)->v0 = (_v0), (p)->u1 = (_u0) + (_w), (p)->v1 = (_v0), (p)->u2 = (_u0), (p)->v2 = (_v0) + (_h), (p)->u3 = (_u0) + (_w), (p)->v3 = (_v0) + (_h)
176 
177 /*
178  * Primitive Handling Macros
179  */
180 #define setusr(p, _usr) (((P_TAG *)(p))->usr = (void *)(_usr))
181 #define setz(p, _z) (((P_TAG *)(p))->z0 = (uint16)(_z))
182 #define setlen(p, _len) (((P_TAG *)(p))->len = (uint8)(_len))
183 #define setaddr(p, _addr) (((P_TAG *)(p))->addr = (void *)(_addr))
184 #define setcode(p, _code) (((P_TAG *)(p))->code = (uint8)(_code))
185 
186 #define getlen(p) (uint8)(((P_TAG *)(p))->len)
187 #define getcode(p) (uint8)(((P_TAG *)(p))->code)
188 #define getaddr(p) (void *)(((P_TAG *)(p))->addr)
189 
190 #define nextPrim(p) (void *)(((P_TAG *)(p))->addr)
191 #define isendprim(p) ((((P_TAG *)(p))->addr) == (void *)UINTPTR_MAX)
192 
193 #define addPrim(ot, p) setaddr(p, getaddr(ot)), setaddr(ot, p), setz(p, 0), setusr(p, 0)
194 #define addPrimZ(ot, p, z0) setaddr(p, getaddr(ot)), setaddr(ot, p), setz(p, z0), setusr(p, 0)
195 #define addPrimZUsr(ot, p, z0, usr) setaddr(p, getaddr(ot)), setaddr(ot, p), setz(p, z0), setusr(p, usr)
196 #define addPrims(ot, p0, p1) setaddr(p1, getaddr(ot)), setaddr(ot, p0)
197 
198 #define catPrim(p0, p1) setaddr(p0, p1)
199 #define termPrim(p) setaddr(p, (void *)UINTPTR_MAX)
200 
201 #define setSemiTrans(p, abe) ((abe) ? setcode(p, getcode(p) | 0x02) : setcode(p, getcode(p) & ~0x02))
202 
203 #define setShadeTex(p, tge) ((tge) ? setcode(p, getcode(p) | 0x01) : setcode(p, getcode(p) & ~0x01))
204 
205 #define getTPage(tp, abr, x, y) ((((tp)&0x3) << 7) | (((abr)&0x3) << 5) | (((y)&0x100) >> 4) | (((x)&0x3ff) >> 6) | (((y)&0x200) << 2))
206 
207 #define getClut(x, y) ((y << 6) | ((x >> 4) & 0x3f))
208 
209 #define dumpTPage(tpage) \
210  GPU_printf("tpage: (%d,%d,%d,%d)\n", ((tpage) >> 7) & 0x003, ((tpage) >> 5) & 0x003, ((tpage) << 6) & 0x7c0, (((tpage) << 4) & 0x100) + (((tpage) >> 2) & 0x200))
211 
212 #define dumpClut(clut) GPU_printf("clut: (%d,%d)\n", (clut & 0x3f) << 4, (clut >> 6))
213 
214 #define _get_mode(dfe, dtd, tpage) ((0xe1000000) | ((dtd) ? 0x0200 : 0) | ((dfe) ? 0x0400 : 0) | ((tpage)&0x9ff))
215 
216 #define setDrawTPage(p, dfe, dtd, tpage) setlen(p, 1), ((uint32 *)(p))[2] = _get_mode(dfe, dtd, tpage)
217 
218 #define _get_tw(tw) \
219  (tw ? ((0xe2000000) | ((((tw)->y & 0xff) >> 3) << 15) | ((((tw)->x & 0xff) >> 3) << 10) | (((~((tw)->h - 1) & 0xff) >> 3) << 5) | (((~((tw)->w - 1) & 0xff) >> 3))) : 0)
220 
221 #define setTexWindow(p, tw) setlen(p, 2), ((uint32 *)(p))[1] = _get_tw(tw), ((uint32 *)(p))[2] = 0
222 
223 #define _get_len(rect) (((rect)->w * (rect)->h + 1) / 2 + 4)
224 
225 #define setDrawLoad(pt, rect) \
226  (_get_len(rect) <= 16) ? ((setlen(pt, _get_len(rect))), ((pt)->code[0] = 0xa0000000), ((pt)->code[1] = *((uint32 *)&(rect)->x)), \
227  ((pt)->code[2] = *((uint32 *)&(rect)->w)), ((pt)->p[_get_len(rect) - 4] = 0x01000000)) \
228  : ((setlen(pt, 0)))
229 
230 /* Primitive Lentgh Code */
231 /*-------------------------------------------------------------------- */
232 /* */
233 #define setPolyF3(p) setlen(p, 4 + 3), setcode(p, 0x20)
234 #define setPolyFT3(p) setlen(p, 7 + 3), setcode(p, 0x24)
235 #define setPolyG3(p) setlen(p, 6 + 3), setcode(p, 0x30)
236 #define setPolyGT3(p) setlen(p, 9 + 3), setcode(p, 0x34)
237 #define setPolyF4(p) setlen(p, 5 + 4), setcode(p, 0x28)
238 #define setPolyFT4(p) setlen(p, 9 + 4), setcode(p, 0x2c)
239 #define setPolyG4(p) setlen(p, 8 + 4), setcode(p, 0x38)
240 #define setPolyGT4(p) setlen(p, 12 + 4), setcode(p, 0x3c)
241 
242 #define setSprt8(p) setlen(p, 3 + 1), setcode(p, 0x74)
243 #define setSprt16(p) setlen(p, 3 + 1), setcode(p, 0x7c)
244 #define setSprt(p) setlen(p, 4 + 1), setcode(p, 0x64)
245 
246 #define setTile1(p) setlen(p, 2 + 1), setcode(p, 0x68)
247 #define setTile8(p) setlen(p, 2 + 1), setcode(p, 0x70)
248 #define setTile16(p) setlen(p, 2 + 1), setcode(p, 0x78)
249 #define setTile(p) setlen(p, 3 + 1), setcode(p, 0x60)
250 #define setLineF2(p) setlen(p, 3 + 2), setcode(p, 0x40)
251 #define setLineG2(p) setlen(p, 4 + 2), setcode(p, 0x50)
252 #define setLineF3(p) setlen(p, 5 + 3), setcode(p, 0x48), (p)->pad = 0x55555555
253 #define setLineG3(p) setlen(p, 7 + 3), setcode(p, 0x58), (p)->pad = 0x55555555, (p)->p2 = 0
254 #define setLineF4(p) setlen(p, 6 + 4), setcode(p, 0x4c), (p)->pad = 0x55555555
255 #define setLineG4(p) setlen(p, 9 + 4), setcode(p, 0x5c), (p)->pad = 0x55555555, (p)->p2 = 0, (p)->p3 = 0
256 
257 /*
258  * Rectangle:
259  */
260 typedef struct {
261  int16 x, y; /* offset point on VRAM */
262  int16 w, h; /* width and height */
263 } RECT16;
264 
265 typedef struct {
266  int32 x, y; /* offset point on VRAM */
267  int32 w, h; /* width and height */
268 } RECT32;
269 
270 typedef struct {
271  void *addr;
272  uint16 len;
273  uint16 z0;
274  void *usr;
275  uint8 r0, g0, b0, code;
276 } P_TAG;
277 
278 typedef struct { uint8 r0, g0, b0, code; } P_CODE;
279 
280 typedef struct {
281  void *addr;
282  uint16 len;
283  uint16 z0;
284  void *usr;
285  uint8 r0, g0, b0, code;
286 } OT_tag;
287 
288 typedef struct {
289  P_TAG tag;
290  uint8 r0, g0, b0, code;
291 } P_HEADER;
292 
293 /*
294  * Environment
295  */
296 typedef struct {
297  P_TAG tag;
298  uint32 code[15];
299 } DR_ENV; /* Packed Drawing Environment */
300 
301 typedef struct {
302  RECT16 clip; /* clip area */
303  int16 ofs[2]; /* drawing offset */
304  RECT16 tw; /* texture window */
305  uint16 tpage; /* texture page */
306  uint8 dtd; /* dither flag (0:off, 1:on) */
307  uint8 dfe; /* flag to draw on display area (0:off 1:on) */
308  uint8 isbg; /* enable to auto-clear */
309  uint8 r0, g0, b0; /* initital background color */
310  DR_ENV dr_env; /* reserved */
311 } DRAWENV;
312 
313 typedef struct {
314  RECT16 disp; /* display area */
315  RECT16 screen; /* display start point */
316  uint8 isinter; /* interlace 0: off 1: on */
317  uint8 isrgb24; /* RGB24 bit mode */
318  uint8 pad0, pad1; /* reserved */
319 } DISPENV;
320 
321 /*
322  * Polygon Primitive Definitions
323  */
324 
325 typedef struct {
326  P_TAG tag;
327  uint8 r0, g0, b0, code;
328  int32 x0, y0;
329  int32 x1, y1;
330  int32 x2, y2;
331 } POLY_F3; /* Flat Triangle */
332 
333 typedef struct {
334  P_TAG tag;
335  uint8 r0, g0, b0, code;
336  int32 x0, y0;
337  int32 x1, y1;
338  int32 x2, y2;
339  int32 x3, y3;
340 } POLY_F4; /* Flat Quadrangle */
341 
342 typedef struct {
343  P_TAG tag;
344  uint8 r0, g0, b0, code;
345  int32 x0, y0;
346  uint16 u0, v0;
347  int32 x1, y1;
348  uint16 u1, v1;
349  int32 x2, y2;
350  uint16 u2, v2;
351 } POLY_FT3; /* Flat Textured Triangle */
352 
353 typedef struct {
354  P_TAG tag;
355  uint8 r0, g0, b0, code;
356  int32 x0, y0;
357  uint16 u0, v0;
358  int32 x1, y1;
359  uint16 u1, v1;
360  int32 x2, y2;
361  uint16 u2, v2;
362  int32 x3, y3;
363  uint16 u3, v3;
364 } POLY_FT4; /* Flat Textured Quadrangle */
365 
366 typedef struct {
367  P_TAG tag;
368  uint8 r0, g0, b0, code;
369  int32 x0, y0;
370  uint8 r1, g1, b1, pad1;
371  int32 x1, y1;
372  uint8 r2, g2, b2, pad2;
373  int32 x2, y2;
374 } POLY_G3; /* Gouraud Triangle */
375 
376 typedef struct {
377  P_TAG tag;
378  uint8 r0, g0, b0, code;
379  int32 x0, y0;
380  uint8 r1, g1, b1, pad1;
381  int32 x1, y1;
382  uint8 r2, g2, b2, pad2;
383  int32 x2, y2;
384  uint8 r3, g3, b3, pad3;
385  int32 x3, y3;
386 } POLY_G4; /* Gouraud Quadrangle */
387 
388 typedef struct {
389  P_TAG tag;
390  uint8 r0, g0, b0, code;
391  int32 x0, y0;
392  uint16 u0, v0;
393  uint8 r1, g1, b1, p1;
394  int32 x1, y1;
395  uint16 u1, v1;
396  uint8 r2, g2, b2, p2;
397  int32 x2, y2;
398  uint16 u2, v2;
399 } POLY_GT3; /* Gouraud Textured Triangle */
400 
401 typedef struct {
402  P_TAG tag;
403  uint8 r0, g0, b0, code;
404  int32 x0, y0;
405  uint16 u0, v0;
406  uint8 r1, g1, b1, p1;
407  int32 x1, y1;
408  uint16 u1, v1;
409  uint8 r2, g2, b2, p2;
410  int32 x2, y2;
411  uint16 u2, v2;
412  uint8 r3, g3, b3, p3;
413  int32 x3, y3;
414  uint16 u3, v3;
415 } POLY_GT4; /* Gouraud Textured Quadrangle */
416 
417 /*
418  * Line Primitive Definitions
419  */
420 typedef struct {
421  P_TAG tag;
422  uint8 r0, g0, b0, code;
423  int32 x0, y0;
424  int32 x1, y1;
425 } LINE_F2; /* Unconnected Flat Line */
426 
427 typedef struct {
428  P_TAG tag;
429  uint8 r0, g0, b0, code;
430  int32 x0, y0;
431  uint8 r1, g1, b1, p1;
432  int32 x1, y1;
433 } LINE_G2; /* Unconnected Gouraud Line */
434 
435 typedef struct {
436  P_TAG tag;
437  uint8 r0, g0, b0, code;
438  int32 x0, y0;
439  int32 x1, y1;
440  int32 x2, y2;
441  uint32 pad;
442 } LINE_F3; /* 2 connected Flat Line */
443 
444 typedef struct {
445  P_TAG tag;
446  uint8 r0, g0, b0, code;
447  int32 x0, y0;
448  uint8 r1, g1, b1, p1;
449  int32 x1, y1;
450  uint8 r2, g2, b2, p2;
451  int32 x2, y2;
452  uint32 pad;
453 } LINE_G3; /* 2 connected Gouraud Line */
454 
455 typedef struct {
456  P_TAG tag;
457  uint8 r0, g0, b0, code;
458  int32 x0, y0;
459  int32 x1, y1;
460  int32 x2, y2;
461  int32 x3, y3;
462  uint32 pad;
463 } LINE_F4; /* 3 connected Flat Line Quadrangle */
464 
465 typedef struct {
466  P_TAG tag;
467  uint8 r0, g0, b0, code;
468  int32 x0, y0;
469  uint8 r1, g1, b1, p1;
470  int32 x1, y1;
471  uint8 r2, g2, b2, p2;
472  int32 x2, y2;
473  uint8 r3, g3, b3, p3;
474  int32 x3, y3;
475  uint32 pad;
476 } LINE_G4; /* 3 connected Gouraud Line */
477 
478 /*
479  * Sprite Primitive Definitions
480  */
481 typedef struct {
482  P_TAG tag;
483  uint8 r0, g0, b0, code;
484  int32 x0, y0;
485  uint16 u0, v0;
486  int16 w, h;
487 } SPRT; /* free size Sprite */
488 
489 typedef struct {
490  P_TAG tag;
491  uint8 r0, g0, b0, code;
492  int32 x0, y0;
493  uint16 u0, v0;
494 } SPRT_16; /* 16x16 Sprite */
495 
496 typedef struct {
497  P_TAG tag;
498  uint8 r0, g0, b0, code;
499  int32 x0, y0;
500  uint16 u0, v0;
501 } SPRT_8; /* 8x8 Sprite */
502 
503 /*
504  * Tile Primitive Definitions
505  */
506 typedef struct {
507  P_TAG tag;
508  uint8 r0, g0, b0, code;
509  int32 x0, y0;
510  int16 w, h;
511 } TILE; /* free size Tile */
512 
513 typedef struct {
514  P_TAG tag;
515  uint8 r0, g0, b0, code;
516  int32 x0, y0;
517 } TILE_16; /* 16x16 Tile */
518 
519 typedef struct {
520  P_TAG tag;
521  uint8 r0, g0, b0, code;
522  int32 x0, y0;
523 } TILE_8; /* 8x8 Tile */
524 
525 typedef struct {
526  P_TAG tag;
527  uint8 r0, g0, b0, code;
528  int32 x0, y0;
529 } TILE_1; /* 1x1 Tile */
530 
531 /*
532  * Special Primitive Definitions
533  */
534 typedef struct {
535  P_TAG tag;
536  uint32 code[2];
537 } DR_MODE; /* Drawing Mode */
538 
539 typedef struct {
540  P_TAG tag;
541  uint32 code[2];
542 } DR_TWIN; /* Texture Window */
543 
544 typedef struct {
545  P_TAG tag;
546  uint32 code[2];
547 } DR_AREA; /* Drawing Area */
548 
549 typedef struct {
550  P_TAG tag;
551  uint32 code[2];
552 } DR_OFFSET; /* Drawing Offset */
553 
554 typedef struct {/* MoveImage */
555  P_TAG tag;
556  uint32 code[5];
557 } DR_MOVE;
558 
559 typedef struct {/* LoadImage */
560  P_TAG tag;
561  uint32 code[3];
562  uint32 p[13];
563 } DR_LOAD;
564 
565 typedef struct {
566  P_TAG tag;
567  uint32 code[1];
568 } DR_TPAGE; /* Drawing TPage */
569 
570 typedef struct {
571  P_TAG tag;
572  uint32 code[2];
573 } DR_STP; /* Drawing STP */
574 
575 /*
576  * Font Stream Parameters
577  */
578 #define FNT_MAX_ID 8 /* max number of stream ID */
579 #define FNT_MAX_SPRT 1024 /* max number of sprites in all streams */
580 
581 /*
582  * Multi-purpose Sony-TMD primitive
583  */
584 typedef struct {
585  uint32 id;
586  uint8 r0, g0, b0, p0; /* Color of vertex 0 */
587  uint8 r1, g1, b1, p1; /* Color of vertex 1 */
588  uint8 r2, g2, b2, p2; /* Color of vertex 2 */
589  uint8 r3, g3, b3, p3; /* Color of vertex 3 */
590  uint16 tpage, clut; /* texture page ID, clut ID */
591  uint8 u0, v0, u1, v1; /* texture corner point */
592  uint8 u2, v2, u3, v3;
593 
594  /* independent vertex model */
595  SVECTOR x0, x1, x2, x3; /* 3D corner point */
596  SVECTOR n0, n1, n2, n3; /* 3D corner normal vector */
597 
598  /* Common vertex model */
599  SVECTOR *v_ofs; /* offset to vertex database */
600  SVECTOR *n_ofs; /* offset to normal database */
601 
602  uint16 vert0, vert1; /* index of vertex */
603  uint16 vert2, vert3;
604  uint16 norm0, norm1; /* index of normal */
605  uint16 norm2, norm3;
606 
607 } TMD_PRIM;
608 
609 /*
610  * Multi-purpose TIM image
611  */
612 typedef struct {
613  uint32 mode; /* pixel mode */
614  RECT16 *crect; /* CLUT rectangle on frame buffer */
615  uint32 *caddr; /* CLUT address on main memory */
616  RECT16 *prect; /* texture image rectangle on frame buffer */
617  uint32 *paddr; /* texture image address on main memory */
618 } TIM_IMAGE;
619 
620 extern int32 LoadImage(RECT16 *rect, uint32 *p);
621 extern OT_tag *ClearOTag(OT_tag *ot, uint32 n);
622 extern OT_tag *ClearOTagR(OT_tag *ot, uint32 n);
623 extern void DrawOTag(OT_tag *p);
624 extern void DrawPrim(void *p);
625 
626 } // End of namespace ICB
627 
628 #endif /* _LIBGPU_H_ */
Definition: psx_pcgpu.h:342
Definition: psx_pcgpu.h:455
Definition: psx_pcgpu.h:584
Definition: psx_pcgpu.h:296
Definition: px_capri_maths.h:53
Definition: psx_pcgpu.h:612
Definition: psx_pcgpu.h:265
Definition: psx_pcgpu.h:333
Definition: psx_pcgpu.h:427
Definition: psx_pcgpu.h:435
Definition: actor.h:32
Definition: psx_pcgpu.h:570
Definition: psx_pcgpu.h:565
Definition: psx_pcgpu.h:519
Definition: psx_pcgpu.h:366
Definition: psx_pcgpu.h:525
Definition: psx_pcgpu.h:278
Definition: psx_pcgpu.h:544
Definition: psx_pcgpu.h:481
Definition: psx_pcgpu.h:401
Definition: psx_pcgpu.h:420
Definition: psx_pcgpu.h:534
Definition: psx_pcgpu.h:376
Definition: psx_pcgpu.h:465
Definition: psx_pcgpu.h:554
Definition: psx_pcgpu.h:549
Definition: psx_pcgpu.h:513
Definition: psx_pcgpu.h:496
Definition: psx_pcgpu.h:388
Definition: psx_pcgpu.h:353
Definition: psx_pcgpu.h:301
Definition: psx_pcgpu.h:270
Definition: psx_pcgpu.h:288
Definition: psx_pcgpu.h:280
Definition: psx_pcgpu.h:539
Definition: psx_pcgpu.h:506
Definition: psx_pcgpu.h:444
Definition: psx_pcgpu.h:260
Definition: psx_pcgpu.h:489
Definition: psx_pcgpu.h:559
Definition: psx_pcgpu.h:313
Definition: psx_pcgpu.h:325