pspsdk-1.0+beta2
psptypes.h
Go to the documentation of this file.
1 /*
2  * PSP Software Development Kit - http://www.pspdev.org
3  * -----------------------------------------------------------------------
4  * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5  *
6  * psptypes.h - Commonly used typedefs.
7  *
8  * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
9  * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
10  * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
11  *
12  * $Id: psptypes.h 2312 2007-09-09 15:02:23Z chip $
13  */
14 
15 /* Note: Some of the structures, types, and definitions in this file were
16  extrapolated from symbolic debugging information found in the Japanese
17  version of Puzzle Bobble. */
18 
19 #ifndef _PSPTYPES_H_
20 #define _PSPTYPES_H_ 1
21 
22 #include <stdint.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #ifndef NULL
29 #ifdef __cplusplus
30 #define NULL 0
31 #else
32 #define NULL ((void *) 0)
33 #endif /* __cplusplus */
34 #endif
35 
36 /* Legacy ps2dev types. */
37 #ifndef PSP_LEGACY_TYPES_DEFINED
38 #define PSP_LEGACY_TYPES_DEFINED
39 typedef uint8_t u8;
40 typedef uint16_t u16;
41 
42 typedef uint32_t u32;
43 typedef uint64_t u64;
44 
45 typedef int8_t s8;
46 typedef int16_t s16;
47 
48 typedef int32_t s32;
49 typedef int64_t s64;
50 #endif
51 
52 #ifndef PSP_LEGACY_VOLATILE_TYPES_DEFINED
53 #define PSP_LEGACY_VOLATILE_TYPES_DEFINED
54 typedef volatile uint8_t vu8;
55 typedef volatile uint16_t vu16;
56 
57 typedef volatile uint32_t vu32;
58 typedef volatile uint64_t vu64;
59 
60 typedef volatile int8_t vs8;
61 typedef volatile int16_t vs16;
62 
63 typedef volatile int32_t vs32;
64 typedef volatile int64_t vs64;
65 #endif
66 
67 /* MIPS-like accessor macros. */
68 static __inline__ u8 _lb(u32 addr) { return *(vu8 *)addr; }
69 static __inline__ u16 _lh(u32 addr) { return *(vu16 *)addr; }
70 static __inline__ u32 _lw(u32 addr) { return *(vu32 *)addr; }
71 static __inline__ u64 _ld(u32 addr) { return *(vu64 *)addr; }
72 
73 static __inline__ void _sb(u8 val, u32 addr) { *(vu8 *)addr = val; }
74 static __inline__ void _sh(u16 val, u32 addr) { *(vu16 *)addr = val; }
75 static __inline__ void _sw(u32 val, u32 addr) { *(vu32 *)addr = val; }
76 static __inline__ void _sd(u64 val, u32 addr) { *(vu64 *)addr = val; }
77 
78 /* SCE types. */
79 typedef unsigned char SceUChar8;
84 /*typedef unsigned int SceULong128 __attribute__((mode(TI)));*/
85 
86 typedef char SceChar8;
87 typedef int16_t SceShort16;
88 typedef int32_t SceInt32;
89 typedef int64_t SceInt64;
90 typedef int64_t SceLong64;
91 /*typedef int SceLong128 __attribute__((mode(TI)));*/
92 
93 typedef float SceFloat;
94 typedef float SceFloat32;
95 
96 typedef short unsigned int SceWChar16;
97 typedef unsigned int SceWChar32;
98 
99 typedef int SceBool;
100 
101 typedef void SceVoid;
102 typedef void * ScePVoid;
103 
104 
105 /* PSP types. */
106 
107 /* Rectangles. */
108 typedef struct ScePspSRect {
109  short int x;
110  short int y;
111  short int w;
112  short int h;
113 } ScePspSRect;
114 
115 typedef struct ScePspIRect {
116  int x;
117  int y;
118  int w;
119  int h;
120 } ScePspIRect;
121 
122 typedef struct ScePspL64Rect {
123  SceLong64 x;
124  SceLong64 y;
125  SceLong64 w;
126  SceLong64 h;
127 } ScePspL64Rect;
128 
129 typedef struct ScePspFRect {
130  float x;
131  float y;
132  float w;
133  float h;
134 } ScePspFRect;
135 
136 /* 2D vectors. */
137 typedef struct ScePspSVector2 {
138  short int x;
139  short int y;
141 
142 typedef struct ScePspIVector2 {
143  int x;
144  int y;
146 
147 typedef struct ScePspL64Vector2 {
148  SceLong64 x;
149  SceLong64 y;
151 
152 typedef struct ScePspFVector2 {
153  float x;
154  float y;
156 
157 typedef union ScePspVector2 {
160  float f[2];
161  int i[2];
162 } ScePspVector2;
163 
164 /* 3D vectors. */
165 typedef struct ScePspSVector3 {
166  short int x;
167  short int y;
168  short int z;
170 
171 typedef struct ScePspIVector3 {
172  int x;
173  int y;
174  int z;
176 
177 typedef struct ScePspL64Vector3 {
178  SceLong64 x;
179  SceLong64 y;
180  SceLong64 z;
182 
183 typedef struct ScePspFVector3 {
184  float x;
185  float y;
186  float z;
188 
189 typedef union ScePspVector3 {
192  float f[3];
193  int i[3];
194 } ScePspVector3;
195 
196 /* 4D vectors. */
197 typedef struct ScePspSVector4 {
198  short int x;
199  short int y;
200  short int z;
201  short int w;
203 
204 typedef struct ScePspIVector4 {
205  int x;
206  int y;
207  int z;
208  int w;
210 
211 typedef struct ScePspL64Vector4 {
212  SceLong64 x;
213  SceLong64 y;
214  SceLong64 z;
215  SceLong64 w;
217 
218 typedef struct ScePspFVector4 {
219  float x;
220  float y;
221  float z;
222  float w;
223 } ScePspFVector4 __attribute__((aligned(16)));
225 typedef struct ScePspFVector4Unaligned {
226  float x;
227  float y;
228  float z;
229  float w;
231 
232 typedef union ScePspVector4 {
235 /* SceULong128 qw;*/ /* Missing compiler support. */
236  float f[4];
237  int i[4];
238 } ScePspVector4 __attribute__((aligned(16)));
240 /* 2D matrix types. */
241 typedef struct ScePspIMatrix2 {
245 
246 typedef struct ScePspFMatrix2 {
250 
251 typedef union ScePspMatrix2 {
257 /* SceULong128 qw[2];*/ /* Missing compiler support. */
258  float f[2][2];
259  int i[2][2];
260 } ScePspMatrix2;
261 
262 /* 3D matrix types. */
263 typedef struct ScePspIMatrix3 {
268 
269 typedef struct ScePspFMatrix3 {
274 
275 typedef union ScePspMatrix3 {
281 /* SceULong128 qw[3];*/ /* Missing compiler support. */
282  float f[3][3];
283  int i[3][3];
284 } ScePspMatrix3;
285 
286 /* 4D matrix types. */
287 typedef struct ScePspIMatrix4 {
292 } ScePspIMatrix4 __attribute__((aligned(16)));
293 
294 typedef struct ScePspIMatrix4Unaligned {
300 
301 typedef struct ScePspFMatrix4 {
306 } ScePspFMatrix4 __attribute__((aligned(16)));
307 
308 typedef struct ScePspFMatrix4Unaligned {
314 
315 typedef union ScePspMatrix4 {
321 /* SceULong128 qw[4];*/ /* Missing compiler support. */
322  float f[4][4];
323  int i[4][4];
324 } ScePspMatrix4;
325 
326 /* Quaternions. */
327 typedef struct ScePspFQuaternion {
328  float x;
329  float y;
330  float z;
331  float w;
332 } ScePspFQuaternion __attribute__((aligned(16)));
333 
335  float x;
336  float y;
337  float z;
338  float w;
340 
341 /* Colors and pixel formats. */
342 typedef struct ScePspFColor {
343  float r;
344  float g;
345  float b;
346  float a;
347 } ScePspFColor __attribute__((aligned(16)));
349 typedef struct ScePspFColorUnaligned {
350  float r;
351  float g;
352  float b;
353  float a;
355 
356 typedef unsigned int ScePspRGBA8888;
357 typedef unsigned short ScePspRGBA4444;
358 typedef unsigned short ScePspRGBA5551;
359 typedef unsigned short ScePspRGB565;
360 
361 /* Unions for converting between types. */
362 typedef union ScePspUnion32 {
363  unsigned int ui;
364  int i;
365  unsigned short us[2];
366  short int s[2];
367  unsigned char uc[4];
368  char c[4];
369  float f;
370  ScePspRGBA8888 rgba8888;
371  ScePspRGBA4444 rgba4444[2];
372  ScePspRGBA5551 rgba5551[2];
373  ScePspRGB565 rgb565[2];
374 } ScePspUnion32;
375 
376 typedef union ScePspUnion64 {
377  SceULong64 ul;
378  SceLong64 l;
379  unsigned int ui[2];
380  int i[2];
381  unsigned short us[4];
382  short int s[4];
383  unsigned char uc[8];
384  char c[8];
385  float f[2];
388  ScePspRGBA8888 rgba8888[2];
389  ScePspRGBA4444 rgba4444[4];
390  ScePspRGBA5551 rgba5551[4];
391  ScePspRGB565 rgb565[4];
392 } ScePspUnion64;
393 
394 typedef union ScePspUnion128 {
395 /* SceULong128 qw;*/ /* Missing compiler support. */
396 /* SceULong128 uq;*/
397 /* SceLong128 q;*/
398  SceULong64 ul[2];
399  SceLong64 l[2];
400  unsigned int ui[4];
401  int i[4];
402  unsigned short us[8];
403  short int s[8];
404  unsigned char uc[16];
405  char c[16];
406  float f[4];
413  ScePspRGBA8888 rgba8888[4];
414  ScePspRGBA4444 rgba4444[8];
415  ScePspRGBA5551 rgba5551[8];
416  ScePspRGB565 rgb565[8];
417 } ScePspUnion128 __attribute__((aligned(16)));
418 
419 /* Date and time. */
420 typedef struct ScePspDateTime {
421  unsigned short year;
422  unsigned short month;
423  unsigned short day;
424  unsigned short hour;
425  unsigned short minute;
426  unsigned short second;
427  unsigned int microsecond;
429 
430 #ifdef __cplusplus
431 }
432 #endif
433 
434 #endif /* _PSPTYPES_H_ */