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

Generated on Tue Jul 24 15:21:22 2007 for PSPSDK-Rev2272 by  doxygen 1.5.2