ScummVM API documentation
psx_poly.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_DEANPOLY_H
28 #define ICB_DEANPOLY_H
29 
30 namespace ICB {
31 
32 #define GPUCODE_MODE_SHADE_TEX (1 << 0)
33 #define GPUCODE_MODE_SEMI_TRANS (1 << 1)
34 
35 // GPU Primitive codes. Please remember that 3 and 4 point lines require the pad field setting to 0x55555555.
36 #define GPUCODE_POLY_F3 (0x20)
37 #define GPUCODE_POLY_FT3 (0x24)
38 #define GPUCODE_POLY_G3 (0x30)
39 #define GPUCODE_POLY_GT3 (0x34)
40 #define GPUCODE_POLY_F4 (0x28)
41 #define GPUCODE_POLY_FT4 (0x2c)
42 #define GPUCODE_POLY_G4 (0x38)
43 #define GPUCODE_POLY_GT4 (0x3c)
44 
45 #define GPUCODE_SPRT (0x64)
46 #define GPUCODE_SPRT_8 (0x74)
47 #define GPUCODE_SPRT_16 (0x7c)
48 
49 #define GPUCODE_TILE (0x60)
50 #define GPUCODE_TILE_1 (0x68)
51 #define GPUCODE_TILE_8 (0x70)
52 #define GPUCODE_TILE_16 (0x78)
53 
54 #define GPUCODE_LINE_F2 (0x40)
55 #define GPUCODE_LINE_G2 (0x50)
56 #define GPUCODE_LINE_F3 (0x48)
57 #define GPUCODE_LINE_G3 (0x58)
58 #define GPUCODE_LINE_F4 (0x4c)
59 #define GPUCODE_LINE_G4 (0x5c)
60 
61 #define GPUSIZE_POLY_F3 (4 + 3)
62 #define GPUSIZE_POLY_FT3 (7 + 3)
63 #define GPUSIZE_POLY_G3 (6 + 3)
64 #define GPUSIZE_POLY_GT3 (9 + 3)
65 #define GPUSIZE_POLY_F4 (5 + 4)
66 #define GPUSIZE_POLY_FT4 (9 + 4)
67 #define GPUSIZE_POLY_G4 (8 + 4)
68 #define GPUSIZE_POLY_GT4 (12 + 4)
69 
70 #define GPUSIZE_SPRT (4 + 1)
71 #define GPUSIZE_SPRT_8 (3 + 1)
72 #define GPUSIZE_SPRT_16 (3 + 1)
73 
74 #define GPUSIZE_TILE (3 + 1)
75 #define GPUSIZE_TILE_1 (2 + 1)
76 #define GPUSIZE_TILE_8 (2 + 1)
77 #define GPUSIZE_TILE_16 (2 + 1)
78 
79 #define GPUSIZE_LINE_F2 (3 + 2)
80 #define GPUSIZE_LINE_G2 (4 + 2)
81 #define GPUSIZE_LINE_F3 (5 + 3)
82 #define GPUSIZE_LINE_G3 (7 + 3)
83 #define GPUSIZE_LINE_F4 (6 + 4)
84 #define GPUSIZE_LINE_G4 (9 + 4)
85 
86 #define GPUSIZE_DR_TPAGE (1)
87 #define GPUSIZE_TAG (4)
88 
89 #define GPUSIZE_TPOLY_F3 (GPUSIZE_DR_TPAGE + GPUSIZE_POLY_F3 + GPUSIZE_TAG)
90 #define GPUSIZE_TPOLY_F4 (GPUSIZE_DR_TPAGE + GPUSIZE_POLY_F4 + GPUSIZE_TAG)
91 #define GPUSIZE_TPOLY_G3 (GPUSIZE_DR_TPAGE + GPUSIZE_POLY_G3 + GPUSIZE_TAG)
92 #define GPUSIZE_TPOLY_G4 (GPUSIZE_DR_TPAGE + GPUSIZE_POLY_G4 + GPUSIZE_TAG)
93 
94 #define GPUSIZE_TLINE_F2 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_F3 + GPUSIZE_TAG)
95 #define GPUSIZE_TLINE_G2 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_G2 + GPUSIZE_TAG)
96 #define GPUSIZE_TLINE_F3 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_F3 + GPUSIZE_TAG)
97 #define GPUSIZE_TLINE_G3 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_G3 + GPUSIZE_TAG)
98 #define GPUSIZE_TLINE_F4 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_F4 + GPUSIZE_TAG)
99 #define GPUSIZE_TLINE_G4 (GPUSIZE_DR_TPAGE + GPUSIZE_LINE_G4 + GPUSIZE_TAG)
100 
101 #define GPUSIZE_TSPRT (GPUSIZE_DR_TPAGE + GPUSIZE_SPRT + GPUSIZE_TAG)
102 #define GPUSIZE_TSPRT_8 (GPUSIZE_DR_TPAGE + GPUSIZE_SPRT_8 + GPUSIZE_TAG)
103 #define GPUSIZE_TSPRT_16 (GPUSIZE_DR_TPAGE + GPUSIZE_SPRT_16 + GPUSIZE_TAG)
104 
105 #define GPUSIZE_TTILE (GPUSIZE_DR_TPAGE + GPUSIZE_TILE + GPUSIZE_TAG)
106 #define GPUSIZE_TTILE_1 (GPUSIZE_DR_TPAGE + GPUSIZE_TILE_1 + GPUSIZE_TAG)
107 #define GPUSIZE_TTILE_8 (GPUSIZE_DR_TPAGE + GPUSIZE_TILE_8 + GPUSIZE_TAG)
108 #define GPUSIZE_TTILE_16 (GPUSIZE_DR_TPAGE + GPUSIZE_TILE_16 + GPUSIZE_TAG)
109 
110 #define setTcode(p, tc) (*(uint32 *)&(((P_TAG *)(p))->r0) = (uint32)(tc))
111 
112 #define zeroTagPoly(p) (setaddr((&(p)->tag_poly), 0), setlen((&(p)->tag_poly), 0) = 0)
113 
114 #define setlen(p, _len) (((P_TAG *)(p))->len = (uint8)(_len))
115 
116 #define setTDrawTPageSize(p, s) setlen((p), (s)), setTcode((p), _get_mode(0, 1, 0))
117 
118 #define setTDrawTPage(p) setTDrawTPageSize((p), 1)
119 
120 #define setTPolyF3(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_F3), setcode(&((p)->tag_poly), GPUCODE_POLY_F3), zeroTagPoly((p))
121 #define setTPolyF4(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_F4), setcode(&((p)->tag_poly), GPUCODE_POLY_F4), zeroTagPoly((p))
122 
123 #define setTPolyG3(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_G3), setcode(&((p)->tag_poly), GPUCODE_POLY_G3), zeroTagPoly((p))
124 #define setTPolyG4(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_G4), setcode(&((p)->tag_poly), GPUCODE_POLY_G4), zeroTagPoly((p))
125 
126 #define setTLineF2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F2), setcode(&((p)->tag_poly), GPUCODE_LINE_F2), zeroTagPoly((p))
127 #define setTLineG2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G2), setcode(&((p)->tag_poly), GPUCODE_LINE_G2), zeroTagPoly((p))
128 #define setTLineF3(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F3), setcode(&((p)->tag_poly), GPUCODE_LINE_F3), zeroTagPoly((p)), ((p)->pad) = 0x55555555
129 #define setTLineG3(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G3), setcode(&((p)->tag_poly), GPUCODE_LINE_G3), zeroTagPoly((p)), ((p)->pad) = 0x55555555
130 #define setTLineF4(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F4), setcode(&((p)->tag_poly), GPUCODE_LINE_F4), zeroTagPoly((p)), ((p)->pad) = 0x55555555
131 #define setTLineG4(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G4), setcode(&((p)->tag_poly), GPUCODE_LINE_G4), zeroTagPoly((p)), ((p)->pad) = 0x55555555
132 
133 #define setTSprt(p) setTDrawTPageSize((p), GPUSIZE_TSPRT), setcode(&((p)->tag_poly), GPUCODE_SPRT), zeroTagPoly((p))
134 #define setTSprt8(p) setTDrawTPageSize((p), GPUSIZE_TSPRT_8), setcode(&((p)->tag_poly), GPUCODE_SPRT_8), zeroTagPoly((p))
135 #define setTSprt16(p) setTDrawTPageSize((p), GPUSIZE_TSPRT_16), setcode(&((p)->tag_poly), GPUCODE_SPRT_16), zeroTagPoly((p))
136 
137 #define setTTile(p) setTDrawTPageSize((p), GPUSIZE_TTILE), setcode(&((p)->tag_poly), GPUCODE_TILE), zeroTagPoly((p))
138 #define setTTile1(p) setTDrawTPageSize((p), GPUSIZE_TTILE_1), setcode(&((p)->tag_poly), GPUCODE_TILE_1), zeroTagPoly((p))
139 #define setTTile8(p) setTDrawTPageSize((p), GPUSIZE_TTILE_8), setcode(&((p)->tag_poly), GPUCODE_TILE_8), zeroTagPoly((p))
140 #define setTTile16(p) setTDrawTPageSize((p), GPUSIZE_TTILE_16), setcode(&((p)->tag_poly), GPUCODE_TILE_16), zeroTagPoly((p))
141 
142 #define setTSemiTrans(p, abe) setSemiTrans(&((p)->tag_poly), (abe))
143 #define setTABRMode(p, abr) setTcode((p), _get_mode(0, 1, (abr << 5)))
144 #define setTSprtTPage(p, tp) setTcode((p), _get_mode(0, 1, (tp)))
145 #define setTSprtTPageABR(p, t, a) setTcode((p), _get_mode(0, 1, (((t)&0x19f) | ((a) << 5))))
146 
147 #define addPrimSize(ot, p, size) (p)->tag = ((*(ot)) | ((size) << 24)), *((ot)) = (((uint32)(p) << 8) >> 8)
148 
149 typedef struct __tpoly_f3 {
150  P_TAG tag;
151  OT_tag tag_poly;
152  uint8 r0, g0, b0, code;
153  int32 x0, y0;
154  int32 x1, y1;
155  int32 x2, y2;
156 } TPOLY_F3; // Flat Triangle with ABR control
157 
158 typedef struct __tpoly_f4 {
159  P_TAG tag;
160  OT_tag tag_poly;
161  uint8 r0, g0, b0, code;
162  int32 x0, y0;
163  int32 x1, y1;
164  int32 x2, y2;
165  int32 x3, y3;
166 } TPOLY_F4; // Flat Quadrangle with ABR control
167 
168 typedef struct __tpoly_g3 {
169  P_TAG tag;
170  OT_tag tag_poly;
171  uint8 r0, g0, b0, code;
172  int32 x0, y0;
173  uint8 r1, g1, b1, pad1;
174  int32 x1, y1;
175  uint8 r2, g2, b2, pad2;
176  int32 x2, y2;
177 } TPOLY_G3; // Gouraud Triangle with ABR control
178 
179 typedef struct __tpoly_g4 {
180  P_TAG tag;
181  OT_tag tag_poly;
182  uint8 r0, g0, b0, code;
183  int32 x0, y0;
184  uint8 r1, g1, b1, pad1;
185  int32 x1, y1;
186  uint8 r2, g2, b2, pad2;
187  int32 x2, y2;
188  uint8 r3, g3, b3, pad3;
189  int32 x3, y3;
190 } TPOLY_G4; // Gouraud Quadrangle with ABR control
191 
192 typedef struct __tline_f2 {
193  P_TAG tag;
194  OT_tag tag_poly;
195  uint8 r0, g0, b0, code;
196  int32 x0, y0;
197  int32 x1, y1;
198 } TLINE_F2; // Unconnected Flat Line with ABR control
199 
200 typedef struct __tline_g2 {
201  P_TAG tag;
202  OT_tag tag_poly;
203  uint8 r0, g0, b0, code;
204  int32 x0, y0;
205  uint8 r1, g1, b1, p1;
206  int32 x1, y1;
207 } TLINE_G2; // Unconnected Gouraud Line with ABR control
208 
209 typedef struct __tline_f3 {
210  P_TAG tag;
211  OT_tag tag_poly;
212  uint8 r0, g0, b0, code;
213  int32 x0, y0;
214  int32 x1, y1;
215  int32 x2, y2;
216  uint32 pad;
217 } TLINE_F3; // 2 connected Flat Line with ABR control
218 
219 typedef struct __tline_g3 {
220  P_TAG tag;
221  OT_tag tag_poly;
222  uint8 r0, g0, b0, code;
223  int32 x0, y0;
224  uint8 r1, g1, b1, p1;
225  int32 x1, y1;
226  uint8 r2, g2, b2, p2;
227  int32 x2, y2;
228  uint32 pad;
229 } TLINE_G3; // 2 connected Gouraud Line with ABR control
230 
231 typedef struct __tline_f4 {
232  P_TAG tag;
233  OT_tag tag_poly;
234  uint8 r0, g0, b0, code;
235  int32 x0, y0;
236  int32 x1, y1;
237  int32 x2, y2;
238  int32 x3, y3;
239  uint32 pad;
240 } TLINE_F4; // 3 connected Flat Line Quadrangle with ABR control
241 
242 typedef struct __tline_g4 {
243  P_TAG tag;
244  OT_tag tag_poly;
245  uint8 r0, g0, b0, code;
246  int32 x0, y0;
247  uint8 r1, g1, b1, p1;
248  int32 x1, y1;
249  uint8 r2, g2, b2, p2;
250  int32 x2, y2;
251  uint8 r3, g3, b3, p3;
252  int32 x3, y3;
253  uint32 pad;
254 } TLINE_G4; // 3 connected Gouraud Line with ABR control
255 
256 // Sprite Primitive Definitions
257 typedef struct __tsprt {
258  P_TAG tag;
259  OT_tag tag_poly;
260  uint8 r0, g0, b0, code;
261  int32 x0, y0;
262  uint8 u0, v0;
263  uint16 clut;
264  int16 w, h;
265 } TSPRT; // Free size Sprite with TPage/ABR control
266 
267 typedef struct __tsprt_16 {
268  P_TAG tag;
269  OT_tag tag_poly;
270  uint8 r0, g0, b0, code;
271  int32 x0, y0;
272  uint8 u0, v0;
273  uint16 clut;
274 } TSPRT_16; // 16x16 Sprite with TPage/ABR control
275 
276 typedef struct __tsprt_8 {
277  P_TAG tag;
278  OT_tag tag_poly;
279  uint8 r0, g0, b0, code;
280  int32 x0, y0;
281  uint8 u0, v0;
282  uint16 clut;
283 } TSPRT_8; // 8x8 Sprite with TPage/ABR control
284 
285 typedef struct __ttile {
286  P_TAG tag;
287  OT_tag tag_poly;
288  uint8 r0, g0, b0, code;
289  int32 x0, y0;
290  int16 w, h;
291 } TTILE; // free size Tile with ABR control
292 
293 typedef struct __ttile16 {
294  P_TAG tag;
295  OT_tag tag_poly;
296  uint8 r0, g0, b0, code;
297  int32 x0, y0;
298 } TTILE_16; // 16x16 Tile with ABR control
299 
300 typedef struct __ttile_8 {
301  P_TAG tag;
302  OT_tag tag_poly;
303  uint8 r0, g0, b0, code;
304  int32 x0, y0;
305 } TTILE_8; // 8x8 Tile with ABR control
306 
307 typedef struct __ttile_1 {
308  P_TAG tag;
309  OT_tag tag_poly;
310  uint8 r0, g0, b0, code;
311  int32 x0, y0;
312 } TTILE_1; // 1x1 Tile with ABR control
313 
314 } // End of namespace ICB
315 
316 #endif // __DEANPOLY_H
Definition: psx_poly.h:276
Definition: psx_poly.h:158
Definition: actor.h:32
Definition: psx_poly.h:257
Definition: psx_poly.h:242
Definition: psx_poly.h:149
Definition: psx_poly.h:307
Definition: psx_poly.h:200
Definition: psx_poly.h:219
Definition: psx_poly.h:179
Definition: psx_poly.h:285
Definition: psx_poly.h:293
Definition: psx_poly.h:231
Definition: psx_poly.h:168
Definition: psx_pcgpu.h:270
Definition: psx_pcgpu.h:280
Definition: psx_poly.h:300
Definition: psx_poly.h:192
Definition: psx_poly.h:267
Definition: psx_poly.h:209