Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

psptypes.h

Go to the documentation of this file.
00001 /*
00002  * PSP Software Development Kit - http://www.pspdev.org
00003  * -----------------------------------------------------------------------
00004  * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
00005  *
00006  * psptypes.h - Commonly used typedefs.
00007  *
00008  * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
00009  * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
00010  * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
00011  *
00012  * $Id: psptypes.h 540 2005-07-08 19:35:10Z warren $
00013  */
00014 
00015 /* Note: Some of the structures, types, and definitions in this file were
00016    extrapolated from symbolic debugging information found in the Japanese
00017    version of Puzzle Bobble. */
00018 
00019 #ifndef _PSPTYPES_H_
00020 #define _PSPTYPES_H_ 1
00021 
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif
00025 
00026 #ifndef NULL
00027 #ifdef __cplusplus
00028 #define NULL    0
00029 #else
00030 #define NULL    ((void *) 0)
00031 #endif /* __cplusplus */
00032 #endif
00033 
00034 /* Legacy ps2dev types. */
00035 typedef unsigned char                   u8;
00036 typedef unsigned short                  u16;
00037 
00038 typedef volatile unsigned char          vu8;
00039 typedef volatile unsigned short         vu16;
00040 
00041 typedef unsigned int                    u32;
00042 typedef unsigned long long              u64;
00043 
00044 typedef volatile unsigned int           vu32;
00045 typedef volatile unsigned long long     vu64;
00046 
00047 typedef signed char                     s8;
00048 typedef signed short                    s16;
00049 
00050 typedef volatile signed char            vs8;
00051 typedef volatile signed short           vs16;
00052 
00053 typedef signed int                      s32;
00054 typedef signed long long                s64;
00055 
00056 typedef volatile signed int             vs32;
00057 typedef volatile signed long long       vs64;
00058 
00059 /* MIPS-like accessor macros. */
00060 static __inline__ u8  _lb(u32 addr) { return *(vu8 *)addr; }
00061 static __inline__ u16 _lh(u32 addr) { return *(vu16 *)addr; }
00062 static __inline__ u32 _lw(u32 addr) { return *(vu32 *)addr; }
00063 static __inline__ u64 _ld(u32 addr) { return *(vu64 *)addr; }
00064 
00065 static __inline__ void _sb(u8 val, u32 addr) { *(vu8 *)addr = val; }
00066 static __inline__ void _sh(u16 val, u32 addr) { *(vu16 *)addr = val; }
00067 static __inline__ void _sw(u32 val, u32 addr) { *(vu32 *)addr = val; }
00068 static __inline__ void _sd(u64 val, u32 addr) { *(vu64 *)addr = val; }
00069 
00070 /* Common integer types. */
00071 typedef unsigned char u_char8;
00072 typedef short unsigned int u_short16;
00073 typedef short unsigned int u_int16;
00074 typedef unsigned int u_int32;
00075 typedef unsigned long long u_int64;
00076 typedef unsigned long long u_long64;
00077 /*typedef unsigned int u_long128 __attribute__((mode(TI)));*/
00078 
00079 typedef char char8;
00080 typedef short int short16;
00081 typedef short int int16;
00082 typedef int int32;
00083 typedef signed long long int64;
00084 typedef signed long long long64;
00085 /*typedef int long128 __attribute__((mode(TI)));*/
00086 
00087 /* SCE types. */
00088 typedef unsigned char SceUChar8;
00089 typedef short unsigned int SceUShort16;
00090 typedef unsigned int SceUInt32;
00091 typedef long long unsigned int SceUInt64;
00092 typedef long long unsigned int SceULong64;
00093 /*typedef unsigned int SceULong128 __attribute__((mode(TI)));*/
00094 
00095 typedef char SceChar8;
00096 typedef short int SceShort16;
00097 typedef int SceInt32;
00098 typedef long long int SceInt64;
00099 typedef long long int SceLong64;
00100 /*typedef int SceLong128 __attribute__((mode(TI)));*/
00101 
00102 typedef float SceFloat;
00103 typedef float SceFloat32;
00104 
00105 typedef short unsigned int SceWChar16;
00106 typedef unsigned int SceWChar32;
00107 
00108 typedef int SceBool;
00109 
00110 typedef void SceVoid;
00111 typedef void * ScePVoid;
00112 
00113 
00114 /* PSP types. */
00115 
00116 /* Rectangles. */
00117 typedef struct ScePspSRect {
00118         short int       x;
00119         short int       y;
00120         short int       w;
00121         short int       h;
00122 } ScePspSRect;
00123 
00124 typedef struct ScePspIRect {
00125         int     x;
00126         int     y;
00127         int     w;
00128         int     h;
00129 } ScePspIRect;
00130 
00131 typedef struct ScePspL64Rect {
00132         SceLong64       x;
00133         SceLong64       y;
00134         SceLong64       w;
00135         SceLong64       h;
00136 } ScePspL64Rect;
00137 
00138 typedef struct ScePspFRect {
00139         float   x;
00140         float   y;
00141         float   w;
00142         float   h;
00143 } ScePspFRect;
00144 
00145 /* 2D vectors. */
00146 typedef struct ScePspSVector2 {
00147         short int       x;
00148         short int       y;
00149 } ScePspSVector2;
00150 
00151 typedef struct ScePspIVector2 {
00152         int     x;
00153         int     y;
00154 } ScePspIVector2;
00155 
00156 typedef struct ScePspL64Vector2 {
00157         SceLong64       x;
00158         SceLong64       y;
00159 } ScePspL64Vector2;
00160 
00161 typedef struct ScePspFVector2 {
00162         float   x;
00163         float   y;
00164 } ScePspFVector2;
00165 
00166 typedef union ScePspVector2 {
00167         ScePspFVector2  fv;
00168         ScePspIVector2  iv;
00169         float                   f[2];
00170         int                     i[2];
00171 } ScePspVector2;
00172 
00173 /* 3D vectors. */
00174 typedef struct ScePspSVector3 {
00175         short int       x;
00176         short int       y;
00177         short int       z;
00178 } ScePspSVector3;
00179 
00180 typedef struct ScePspIVector3 {
00181         int     x;
00182         int     y;
00183         int     z;
00184 } ScePspIVector3;
00185 
00186 typedef struct ScePspL64Vector3 {
00187         SceLong64       x;
00188         SceLong64       y;
00189         SceLong64       z;
00190 } ScePspL64Vector3;
00191 
00192 typedef struct ScePspFVector3 {
00193         float   x;
00194         float   y;
00195         float   z;
00196 } ScePspFVector3;
00197 
00198 typedef union ScePspVector3 {
00199         ScePspFVector3  fv;
00200         ScePspIVector3  iv;
00201         float                   f[3];
00202         int                     i[3];
00203 } ScePspVector3;
00204 
00205 /* 4D vectors. */
00206 typedef struct ScePspSVector4 {
00207         short int       x;
00208         short int       y;
00209         short int       z;
00210         short int       w;
00211 } ScePspSVector4;
00212 
00213 typedef struct ScePspIVector4 {
00214         int     x;
00215         int     y;
00216         int     z;
00217         int     w;
00218 } ScePspIVector4;
00219 
00220 typedef struct ScePspL64Vector4 {
00221         SceLong64       x;
00222         SceLong64       y;
00223         SceLong64       z;
00224         SceLong64       w;
00225 } ScePspL64Vector4;
00226 
00227 typedef struct ScePspFVector4 {
00228         float   x;
00229         float   y;
00230         float   z;
00231         float   w;
00232 } ScePspFVector4 __attribute__((aligned(16)));
00233 
00234 typedef struct ScePspFVector4Unaligned {
00235         float   x;
00236         float   y;
00237         float   z;
00238         float   w;
00239 } ScePspFVector4Unaligned;
00240 
00241 typedef union ScePspVector4 {
00242         ScePspFVector4  fv;
00243         ScePspIVector4  iv;
00244 /*      SceULong128     qw;*/   /* Missing compiler support. */
00245         float                   f[4];
00246         int                     i[4];
00247 } ScePspVector4 __attribute__((aligned(16)));
00248 
00249 /* 2D matrix types. */
00250 typedef struct ScePspIMatrix2 {
00251         ScePspIVector2  x;
00252         ScePspIVector2  y;
00253 } ScePspIMatrix2;
00254 
00255 typedef struct ScePspFMatrix2 {
00256         ScePspFVector2  x;
00257         ScePspFVector2  y;
00258 } ScePspFMatrix2;
00259 
00260 typedef union ScePspMatrix2 {
00261         ScePspFMatrix2  fm;
00262         ScePspIMatrix2  im;
00263         ScePspFVector2  fv[2];
00264         ScePspIVector2  iv[2];
00265         ScePspVector2   v[2];
00266 /*      SceULong128     qw[2];*/        /* Missing compiler support. */
00267         float                   f[2][2];
00268         int                     i[2][2];
00269 } ScePspMatrix2;
00270 
00271 /* 3D matrix types. */
00272 typedef struct ScePspIMatrix3 {
00273         ScePspIVector3  x;
00274         ScePspIVector3  y;
00275         ScePspIVector3  z;
00276 } ScePspIMatrix3;
00277 
00278 typedef struct ScePspFMatrix3 {
00279         ScePspFVector3  x;
00280         ScePspFVector3  y;
00281         ScePspFVector3  z;
00282 } ScePspFMatrix3;
00283 
00284 typedef union ScePspMatrix3 {
00285         ScePspFMatrix3  fm;
00286         ScePspIMatrix3  im;
00287         ScePspFVector3  fv[3];
00288         ScePspIVector3  iv[3];
00289         ScePspVector3   v[3];
00290 /*      SceULong128     qw[3];*/        /* Missing compiler support. */
00291         float                   f[3][3];
00292         int                     i[3][3];
00293 } ScePspMatrix3;
00294 
00295 /* 4D matrix types. */
00296 typedef struct ScePspIMatrix4 {
00297         ScePspIVector4  x;
00298         ScePspIVector4  y;
00299         ScePspIVector4  z;
00300         ScePspIVector4  w;
00301 } ScePspIMatrix4 __attribute__((aligned(16)));
00302 
00303 typedef struct ScePspIMatrix4Unaligned {
00304         ScePspIVector4  x;
00305         ScePspIVector4  y;
00306         ScePspIVector4  z;
00307         ScePspIVector4  w;
00308 } ScePspIMatrix4Unaligned;
00309 
00310 typedef struct ScePspFMatrix4 {
00311         ScePspFVector4  x;
00312         ScePspFVector4  y;
00313         ScePspFVector4  z;
00314         ScePspFVector4  w;
00315 } ScePspFMatrix4 __attribute__((aligned(16)));
00316 
00317 typedef struct ScePspFMatrix4Unaligned {
00318         ScePspFVector4  x;
00319         ScePspFVector4  y;
00320         ScePspFVector4  z;
00321         ScePspFVector4  w;
00322 } ScePspFMatrix4Unaligned;
00323 
00324 typedef union ScePspMatrix4 {
00325         ScePspFMatrix4  fm;
00326         ScePspIMatrix4  im;
00327         ScePspFVector4  fv[4];
00328         ScePspIVector4  iv[4];
00329         ScePspVector4   v[4];
00330 /*      SceULong128     qw[4];*/        /* Missing compiler support. */
00331         float                   f[4][4];
00332         int                     i[4][4];
00333 } ScePspMatrix4;
00334 
00335 /* Quaternions. */
00336 typedef struct ScePspFQuaternion {
00337         float   x;
00338         float   y;
00339         float   z;
00340         float   w;
00341 } ScePspFQuaternion __attribute__((aligned(16)));
00342 
00343 typedef struct ScePspFQuaternionUnaligned {
00344         float   x;
00345         float   y;
00346         float   z;
00347         float   w;
00348 } ScePspFQuaternionUnaligned;
00349 
00350 /* Colors and pixel formats. */
00351 typedef struct ScePspFColor {
00352         float   r;
00353         float   g;
00354         float   b;
00355         float   a;
00356 } ScePspFColor __attribute__((aligned(16)));
00357 
00358 typedef struct ScePspFColorUnaligned {
00359         float   r;
00360         float   g;
00361         float   b;
00362         float   a;
00363 } ScePspFColorUnaligned;
00364 
00365 typedef unsigned int ScePspRGBA8888;
00366 typedef unsigned short ScePspRGBA4444;
00367 typedef unsigned short ScePspRGBA5551;
00368 typedef unsigned short ScePspRGB565;
00369 
00370 /* Unions for converting between types. */
00371 typedef union ScePspUnion32 {
00372         unsigned int    ui;
00373         int                     i;
00374         unsigned short  us[2];
00375         short int               s[2];
00376         unsigned char   uc[4];
00377         char                    c[4];
00378         float                   f;
00379         ScePspRGBA8888  rgba8888;
00380         ScePspRGBA4444  rgba4444[2];
00381         ScePspRGBA5551  rgba5551[2];
00382         ScePspRGB565    rgb565[2];
00383 } ScePspUnion32;
00384 
00385 typedef union ScePspUnion64 {
00386         SceULong64              ul;
00387         SceLong64               l;
00388         unsigned int    ui[2];
00389         int                     i[2];
00390         unsigned short  us[4];
00391         short int               s[4];
00392         unsigned char   uc[8];
00393         char                    c[8];
00394         float                   f[2];
00395         ScePspSRect     sr;
00396         ScePspSVector4  sv;
00397         ScePspRGBA8888  rgba8888[2];
00398         ScePspRGBA4444  rgba4444[4];
00399         ScePspRGBA5551  rgba5551[4];
00400         ScePspRGB565    rgb565[4];
00401 } ScePspUnion64;
00402 
00403 typedef union ScePspUnion128 {
00404 /*      SceULong128     qw;*/   /* Missing compiler support. */
00405 /*      SceULong128     uq;*/
00406 /*      SceLong128      q;*/
00407         SceULong64              ul[2];
00408         SceLong64               l[2];
00409         unsigned int    ui[4];
00410         int                     i[4];
00411         unsigned short  us[8];
00412         short int               s[8];
00413         unsigned char   uc[16];
00414         char                    c[16];
00415         float                   f[4];
00416         ScePspFRect     fr;
00417         ScePspIRect     ir;
00418         ScePspFVector4  fv;
00419         ScePspIVector4  iv;
00420         ScePspFQuaternion fq;
00421         ScePspFColor    fc;
00422         ScePspRGBA8888  rgba8888[4];
00423         ScePspRGBA4444  rgba4444[8];
00424         ScePspRGBA5551  rgba5551[8];
00425         ScePspRGB565    rgb565[8];
00426 } ScePspUnion128 __attribute__((aligned(16)));
00427 
00428 /* Date and time. */
00429 typedef struct ScePspDateTime {
00430         unsigned short  year;
00431         unsigned short  month;
00432         unsigned short  day;
00433         unsigned short  hour;
00434         unsigned short  minute;
00435         unsigned short  second;
00436         unsigned int    microsecond;
00437 } ScePspDateTime;
00438 
00439 #ifdef __cplusplus
00440 }
00441 #endif
00442 
00443 #endif /* _PSPTYPES_H_ */

Generated on Wed Sep 28 07:52:08 2005 for pspsdk-1.0+beta by  doxygen 1.4.4