sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
gsTexture.h
Go to the documentation of this file.
1
5// ____ ___ | / _____ _____
6// | __ | |___/ | |
7// |___| ___| | \ __|__ | gsKit Open Source Project.
8// ----------------------------------------------------------------------
9// Copyright 2004 - Chris "Neovanglist" Gilbert <Neovanglist@LainOS.org>
10// Licenced under Academic Free License version 2.0
11// Review gsKit README & LICENSE files for further details.
12//
13// gsTexture.h - Header for gsTexture.c
14//
15
16#ifndef __GSTEXTURE_H__
17#define __GSTEXTURE_H__
18
19#include "gsKit.h"
20
21#define GS_ST 0x02
22#define GS_UV 0x03
23#define GS_TEX0_1 0x06
24#define GS_TEX0_2 0x07
25#define GS_TEX1_1 0x14
26#define GS_TEX1_2 0x15
27#define GS_TEX2_1 0x16
28#define GS_TEX2_2 0x17
29#define GS_TEXCLUT 0x1c
30#define GS_SCANMSK 0x22
31#define GS_MIPTBP1_1 0x34
32#define GS_MIPTBP1_2 0x35
33#define GS_MIPTBP2_1 0x36
34#define GS_MIPTBP2_2 0x37
35#define GS_TEXA 0x3b
36#define GS_TEXFLUSH 0x3f
37
38#define GS_CLUT_NONE 0x00
39#define GS_CLUT_PALLETE 0x01
40#define GS_CLUT_TEXTURE 0x02
41
42#define GS_CLUT_STOREMODE_NOLOAD 0x00
43#define GS_CLUT_STOREMODE_LOAD 0x01
44#define GS_CLUT_STOREMODE_LOAD_CBP0 0x02
45#define GS_CLUT_STOREMODE_LOAD_CBP1 0x03
46#define GS_CLUT_STOREMODE_COMPARE_CBP0 0x04
47#define GS_CLUT_STOREMODE_COMPARE_CBP1 0x05
48
49#define GS_SETREG_COLCLAMP(clamp) ((u64)(clamp))
50
51#define GS_SETREG_MIPTBP1_1 GS_SETREG_MIPTBP1
52#define GS_SETREG_MIPTBP1_2 GS_SETREG_MIPTBP1
53#define GS_SETREG_MIPTBP1(tbp1, tbw1, tbp2, tbw2, tbp3, tbw3) \
54 ((u64)(tbp1) | ((u64)(tbw1) << 14) | \
55 ((u64)(tbp2) << 20) | ((u64)(tbw2) << 34) | \
56 ((u64)(tbp3) << 40) | ((u64)(tbw3) << 54))
57
58#define GS_SETREG_MIPTBP2_1 GS_SETREG_MIPTBP2
59#define GS_SETREG_MIPTBP2_2 GS_SETREG_MIPTBP2
60#define GS_SETREG_MIPTBP2(tbp4, tbw4, tbp5, tbw5, tbp6, tbw6) \
61 ((u64)(tbp4) | ((u64)(tbw4) << 14) | \
62 ((u64)(tbp5) << 20) | ((u64)(tbw5) << 34) | \
63 ((u64)(tbp6) << 40) | ((u64)(tbw6) << 54))
64
65#define GS_SETREG_TEX0_1 GS_SETREG_TEX0
66#define GS_SETREG_TEX0_2 GS_SETREG_TEX0
67#define GS_SETREG_TEX0(tbp, tbw, psm, tw, th, tcc, tfx,cbp, cpsm, csm, csa, cld) \
68 ((u64)(tbp) | ((u64)(tbw) << 14) | \
69 ((u64)(psm) << 20) | ((u64)(tw) << 26) | \
70 ((u64)(th) << 30) | ((u64)(tcc) << 34) | \
71 ((u64)(tfx) << 35) | ((u64)(cbp) << 37) | \
72 ((u64)(cpsm) << 51) | ((u64)(csm) << 55) | \
73 ((u64)(csa) << 56) | ((u64)(cld) << 61))
74
75#define GS_SETREG_TEX1_1 GS_SETREG_TEX1
76#define GS_SETREG_TEX1_2 GS_SETREG_TEX1
77#define GS_SETREG_TEX1(lcm, mxl, mmag, mmin, mtba, l, k) \
78 ((u64)(lcm) | ((u64)(mxl) << 2) | \
79 ((u64)(mmag) << 5) | ((u64)(mmin) << 6) | \
80 ((u64)(mtba) << 9) | ((u64)(l) << 19) | \
81 ((u64)(k) << 32))
82
83#define GS_SETREG_TEX2_1 GS_SETREG_TEX2
84#define GS_SETREG_TEX2_2 GS_SETREG_TEX2
85#define GS_SETREG_TEX2(psm, cbp, cpsm, csm, csa, cld) \
86 (((u64)(psm) << 20) | ((u64)(cbp) << 37) | \
87 ((u64)(cpsm) << 51) | ((u64)(csm) << 55) | \
88 ((u64)(csa) << 56) | ((u64)(cld) << 61))
89
90#define GS_SETREG_TEXA(ta0, aem, ta1) \
91 ((u64)(ta0) | ((u64)(aem) << 15) | ((u64)(ta1) << 32))
92
93#define GS_SETREG_TEXCLUT(cbw, cou, cov) \
94 ((u64)(cbw) | ((u64)(cou) << 6) | ((u64)(cov) << 12))
95
96#define GS_SETREG_TRXDIR(xdr) ((u64)(xdr))
97
98#define GS_SETREG_TRXPOS(ssax, ssay, dsax, dsay, dir) \
99 ((u64)(ssax) | ((u64)(ssay) << 16) | \
100 ((u64)(dsax) << 32) | ((u64)(dsay) << 48) | \
101 ((u64)(dir) << 59))
102
103#define GS_SETREG_TRXREG(rrw, rrh) \
104 ((u64)(rrw) | ((u64)(rrh) << 32))
105
106#define GS_SETREG_UV(u, v) ((u64)(u) | ((u64)(v) << 16))
107
108#define GS_SETREG_STQ(s, t) ((u64)(s) | ((u64)(t) << 32))
109
110#define GS_SETREG_BITBLTBUF(sbp, sbw, spsm, dbp, dbw, dpsm) \
111 ((u64)(sbp) | ((u64)(sbw) << 16) | \
112 ((u64)(spsm) << 24) | ((u64)(dbp) << 32) | \
113 ((u64)(dbw) << 48) | ((u64)(dpsm) << 56))
114
115#ifdef __cplusplus
116extern "C" {
117#endif
118u32 gsKit_texture_size_ee(int width, int height, int psm);
119u32 gsKit_texture_size(int width, int height, int psm);
120void gsKit_texture_to_psm16(GSTEXTURE *Texture);
121void gsKit_texture_send(u32 *mem, int width, int height, u32 tbp, u32 psm, u32 tbw, u8 clut);
122void gsKit_texture_send_inline(GSGLOBAL *gsGlobal, u32 *mem, int width, int height, u32 tbp, u32 psm, u32 tbw, u8 clut);
123void gsKit_texture_upload(GSGLOBAL *gsGlobal, GSTEXTURE *Texture);
124
125void gsKit_prim_sprite_texture_3d(GSGLOBAL *gsGlobal, const GSTEXTURE *Texture, float x1, float y1, int iz1, float u1, float v1,
126 float x2, float y2, int iz2, float u2, float v2,
127 u64 color);
128
129void gsKit_prim_sprite_striped_texture_3d(GSGLOBAL *gsGlobal, const GSTEXTURE *Texture, float x1, float y1, int iz1, float u1, float v1,
130 float x2, float y2, int iz2, float u2, float v2,
131 u64 color);
132
133void gskit_prim_list_sprite_texture_uv_3d(GSGLOBAL *gsGlobal, const GSTEXTURE *Texture, int count, const GSPRIMUVPOINT *vertices);
134void gskit_prim_list_sprite_texture_uv_flat(GSGLOBAL *gsGlobal, const GSTEXTURE *Texture, int count, const u128 *flatContent);
135void gskit_prim_list_sprite_texture_uv_flat_color(GSGLOBAL *gsGlobal, const GSTEXTURE *Texture, gs_rgbaq color, int count, const GSPRIMUVPOINTFLAT *vertices);
136
137void gsKit_prim_triangle_texture_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
138 float x1, float y1, int iz1, float u1, float v1,
139 float x2, float y2, int iz2, float u2, float v2,
140 float x3, float y3, int iz3, float u3, float v3, u64 color);
141
142void gsKit_prim_triangle_goraud_texture_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
143 float x1, float y1, int iz1, float u1, float v1,
144 float x2, float y2, int iz2, float u2, float v2,
145 float x3, float y3, int iz3, float u3, float v3,
146 u64 color1, u64 color2, u64 color3);
147
148void gsKit_prim_list_triangle_goraud_texture_uv_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, int count, const GSPRIMUVPOINT *vertices);
149void gsKit_prim_list_triangle_goraud_texture_stq_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture, int count, const GSPRIMSTQPOINT *vertices);
150
151void gsKit_prim_triangle_strip_texture(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
152 float *TriStrip, int segments, int iz, u64 color);
153
154void gsKit_prim_triangle_strip_texture_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
155 float *TriStrip, int segments, u64 color);
156
157void gsKit_prim_triangle_fan_texture(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
158 float *TriFan, int verticies, int iz, u64 color);
159
160void gsKit_prim_triangle_fan_texture_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
161 float *TriFan, int verticies, u64 color);
162
163void gsKit_prim_quad_texture_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
164 float x1, float y1, int iz1, float u1, float v1,
165 float x2, float y2, int iz2, float u2, float v2,
166 float x3, float y3, int iz3, float u3, float v3,
167 float x4, float y4, int iz4, float u4, float v4, u64 color);
168
169void gsKit_prim_quad_goraud_texture_3d(GSGLOBAL *gsGlobal, GSTEXTURE *Texture,
170 float x1, float y1, int iz1, float u1, float v1,
171 float x2, float y2, int iz2, float u2, float v2,
172 float x3, float y3, int iz3, float u3, float v3,
173 float x4, float y4, int iz4, float u4, float v4,
174 u64 color1, u64 color2, u64 color3, u64 color4);
175
176
177#define gsKit_prim_sprite_texture(gsGlobal, Texture, x1, y1, u1, v1, \
178 x2, y2, u2, v2, \
179 z, color) \
180 gsKit_prim_sprite_texture_3d(gsGlobal, Texture, x1, y1, z, u1, v1, \
181 x2, y2, z, u2, v2, color);
182
183#define gsKit_prim_sprite_striped_texture(gsGlobal, Texture, x1, y1, u1, v1, \
184 x2, y2, u2, v2, \
185 z, color) \
186 gsKit_prim_sprite_striped_texture_3d(gsGlobal, Texture, x1, y1, z, u1, v1, \
187 x2, y2, z, u2, v2, color);
188
189#define gsKit_prim_triangle_texture(gsGlobal, Texture, x1, y1, u1, v1, \
190 x2, y2, u2, v2, \
191 x3, y3, u3, v3, \
192 z, color) \
193 gsKit_prim_triangle_texture_3d(gsGlobal, Texture, x1, y1, z, u1, v1, \
194 x2, y2, z, u2, v2, \
195 x3, y3, z, u3, v3, color);
196
197#define gsKit_prim_triangle_goraud_texture(gsGlobal, Texture, x1, y1, u1, v1, \
198 x2, y2, u2, v2, \
199 x3, y3, u3, v3, \
200 z, color1, color2, color3) \
201 gsKit_prim_triangle_goraud_texture_3d(gsGlobal, Texture, x1, y1, z, u1, v1, \
202 x2, y2, z, u2, v2, \
203 x3, y3, z, u3, v3, color1, color2, color3);
204
205#define gsKit_prim_quad_texture(gsGlobal, Texture, x1, y1, u1, v1, \
206 x2, y2, u2, v2, \
207 x3, y3, u3, v3, \
208 x4, y4, u4, v4, \
209 z, color) \
210 gsKit_prim_quad_texture_3d(gsGlobal, Texture, x1, y1, z, u1, v1, \
211 x2, y2, z, u2, v2, \
212 x3, y3, z, u3, v3, \
213 x4, y4, z, u4, v4, color);
214
215#define gsKit_prim_quad_goraud_texture(gsGlobal, Texture, x1, y1, u1, v1, \
216 x2, y2, u2, v2, \
217 x3, y3, u3, v3, \
218 x4, y4, u4, v4, \
219 z, color1, color2, color3, color4) \
220 gsKit_prim_quad_goraud_texture_3d(gsGlobal, Texture, x1, y1, z, u1, v1, \
221 x2, y2, z, u2, v2, \
222 x3, y3, z, u3, v3, \
223 x4, y4, z, u4, v4, color1, color2, color3, color4);
224
225#ifdef __cplusplus
226}
227#endif
228
229#endif /* __GSTEXTURE_H__ */