From 7d4e4c0b34a613dd3c0220475ae4e448197522c1 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sat, 12 Mar 2011 23:17:12 +0100 Subject: initial commit. now I can start playing with stuff! --- include/rvl/GXBump.h | 55 ++ include/rvl/GXCull.h | 18 + include/rvl/GXDispList.h | 18 + include/rvl/GXEnum.h | 1300 +++++++++++++++++++++++++++++++++++++++++++++ include/rvl/GXGeometry.h | 82 +++ include/rvl/GXLighting.h | 94 ++++ include/rvl/GXPixel.h | 49 ++ include/rvl/GXStruct.h | 132 +++++ include/rvl/GXTev.h | 92 ++++ include/rvl/GXTexture.h | 127 +++++ include/rvl/GXTransform.h | 71 +++ include/rvl/GXVert.h | 222 ++++++++ include/rvl/OSCache.h | 61 +++ include/rvl/PPCWGPipe.h | 37 ++ include/rvl/arc.h | 115 ++++ include/rvl/mtx.h | 441 +++++++++++++++ include/rvl/tpl.h | 107 ++++ include/rvl/vifuncs.h | 48 ++ include/rvl/vitypes.h | 79 +++ 19 files changed, 3148 insertions(+) create mode 100755 include/rvl/GXBump.h create mode 100755 include/rvl/GXCull.h create mode 100755 include/rvl/GXDispList.h create mode 100755 include/rvl/GXEnum.h create mode 100755 include/rvl/GXGeometry.h create mode 100755 include/rvl/GXLighting.h create mode 100755 include/rvl/GXPixel.h create mode 100755 include/rvl/GXStruct.h create mode 100755 include/rvl/GXTev.h create mode 100755 include/rvl/GXTexture.h create mode 100755 include/rvl/GXTransform.h create mode 100755 include/rvl/GXVert.h create mode 100755 include/rvl/OSCache.h create mode 100755 include/rvl/PPCWGPipe.h create mode 100755 include/rvl/arc.h create mode 100755 include/rvl/mtx.h create mode 100755 include/rvl/tpl.h create mode 100755 include/rvl/vifuncs.h create mode 100755 include/rvl/vitypes.h (limited to 'include/rvl') diff --git a/include/rvl/GXBump.h b/include/rvl/GXBump.h new file mode 100755 index 0000000..56cbbd9 --- /dev/null +++ b/include/rvl/GXBump.h @@ -0,0 +1,55 @@ +#ifndef __GXBUMP_H__ +#define __GXBUMP_H__ + +//****************************************************************************** +// +// Graphics Library Indirect Texture (Bump) functions. +// +//****************************************************************************** + +#ifdef __cplusplus +extern "C" { +#endif + +//------------------------------------------------------------------------------ +// Bump (indirect texture functions). +//------------------------------------------------------------------------------ +extern void GXSetNumIndStages (u8 nIndStages); +extern void GXSetIndTexOrder (GXIndTexStageID ind_stage, GXTexCoordID tex_coord, + GXTexMapID tex_map); +extern void GXSetIndTexCoordScale (GXIndTexStageID ind_state, + GXIndTexScale scale_s, GXIndTexScale scale_t); +extern void GXSetIndTexMtx (GXIndTexMtxID mtx_sel, const f32 offset[2][3], s8 scale_exp); +extern void GXSetTevIndirect (GXTevStageID tev_stage, GXIndTexStageID ind_stage, + GXIndTexFormat format, GXIndTexBiasSel bias_sel, + GXIndTexMtxID matrix_sel, + GXIndTexWrap wrap_s, GXIndTexWrap wrap_t, + GXBool add_prev, GXBool ind_lod, GXIndTexAlphaSel alpha_sel); + +//------------------------------------------------------------------------------ +// Convenience functions +//------------------------------------------------------------------------------ +extern void GXSetTevDirect (GXTevStageID tev_stage); +extern void GXSetTevIndWarp (GXTevStageID tev_stage, GXIndTexStageID ind_stage, + GXBool signed_offset, GXBool replace_mode, + GXIndTexMtxID matrix_sel); +extern void GXSetTevIndTile (GXTevStageID tev_stage, GXIndTexStageID ind_stage, + u16 tilesize_s, u16 tilesize_t, + u16 tilespacing_s, u16 tilespacing_t, + GXIndTexFormat format, GXIndTexMtxID matrix_sel, + GXIndTexBiasSel bias_sel, GXIndTexAlphaSel alpha_sel); +extern void GXSetTevIndBumpST (GXTevStageID tev_stage, GXIndTexStageID ind_stage, + GXIndTexMtxID matrix_sel); +extern void GXSetTevIndBumpXYZ (GXTevStageID tev_stage, GXIndTexStageID ind_stage, + GXIndTexMtxID matrix_sel); +extern void GXSetTevIndRepeat (GXTevStageID tev_stage); + +//------------------------------------------------------------------------------ +extern void __GXSetIndirectMask ( u32 mask ); + +//------------------------------------------------------------------------------ +#ifdef __cplusplus +} +#endif + +#endif // __GXBUMP_H__ diff --git a/include/rvl/GXCull.h b/include/rvl/GXCull.h new file mode 100755 index 0000000..3584439 --- /dev/null +++ b/include/rvl/GXCull.h @@ -0,0 +1,18 @@ +#ifndef __GXCULL_H__ +#define __GXCULL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------*/ +void GXSetScissor ( u32 left, u32 top, u32 wd, u32 ht ); +void GXSetCullMode ( GXCullMode mode ); +void GXSetCoPlanar ( GXBool enable ); + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif // __GXCULL_H__ diff --git a/include/rvl/GXDispList.h b/include/rvl/GXDispList.h new file mode 100755 index 0000000..5246525 --- /dev/null +++ b/include/rvl/GXDispList.h @@ -0,0 +1,18 @@ +#ifndef __GXDISPLIST_H__ +#define __GXDISPLIST_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------*/ +void GXBeginDisplayList ( void *list, u32 size ); +u32 GXEndDisplayList ( void ); +void GXCallDisplayList ( const void *list, u32 nbytes ); + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif // __GXDISPLIST_H__ diff --git a/include/rvl/GXEnum.h b/include/rvl/GXEnum.h new file mode 100755 index 0000000..6f75a0f --- /dev/null +++ b/include/rvl/GXEnum.h @@ -0,0 +1,1300 @@ +#ifndef __GXENUM_H__ +#define __GXENUM_H__ + +/********************************/ +#ifdef __cplusplus +extern "C" { +#endif + +/********************************/ +typedef u8 GXBool; + +/********************************/ +#define GX_TRUE ((GXBool)1) +#define GX_FALSE ((GXBool)0) +#define GX_ENABLE ((GXBool)1) +#define GX_DISABLE ((GXBool)0) + +/********************************/ +typedef enum _GXAttr +{ + GX_VA_PNMTXIDX = 0, // position/normal matrix index + GX_VA_TEX0MTXIDX, // texture 0 matrix index + GX_VA_TEX1MTXIDX, // texture 1 matrix index + GX_VA_TEX2MTXIDX, // texture 2 matrix index + GX_VA_TEX3MTXIDX, // texture 3 matrix index + GX_VA_TEX4MTXIDX, // texture 4 matrix index + GX_VA_TEX5MTXIDX, // texture 5 matrix index + GX_VA_TEX6MTXIDX, // texture 6 matrix index + GX_VA_TEX7MTXIDX, // texture 7 matrix index + GX_VA_POS = 9, // position + GX_VA_NRM, // normal + GX_VA_CLR0, // color 0 + GX_VA_CLR1, // color 1 + GX_VA_TEX0, // input texture coordinate 0 + GX_VA_TEX1, // input texture coordinate 1 + GX_VA_TEX2, // input texture coordinate 2 + GX_VA_TEX3, // input texture coordinate 3 + GX_VA_TEX4, // input texture coordinate 4 + GX_VA_TEX5, // input texture coordinate 5 + GX_VA_TEX6, // input texture coordinate 6 + GX_VA_TEX7, // input texture coordinate 7 + + GX_POS_MTX_ARRAY, // position matrix array pointer + GX_NRM_MTX_ARRAY, // normal matrix array pointer + GX_TEX_MTX_ARRAY, // texture matrix array pointer + GX_LIGHT_ARRAY, // light parameter array pointer + GX_VA_NBT, // normal, bi-normal, tangent + GX_VA_MAX_ATTR, // maximum number of vertex attributes + + GX_VA_NULL = 0xff // NULL attribute (to mark end of lists) + +} GXAttr; + +#define GX_MAX_VTXDESC GX_VA_MAX_ATTR +#define GX_MAX_VTXDESCLIST_SZ (GX_MAX_VTXDESC+1) // +1 for GX_VA_NULL + +#define GX_MAX_VTXATTRFMT GX_VA_MAX_ATTR +#define GX_MAX_VTXATTRFMTLIST_SZ (GX_MAX_VTXATTRFMT+1) // +1 for GX_VA_NULL + +#define GX_MAX_VTXARRAY 16 + +/********************************/ +typedef enum _GXVtxFmt +{ + GX_VTXFMT0 = 0, + GX_VTXFMT1, + GX_VTXFMT2, + GX_VTXFMT3, + GX_VTXFMT4, + GX_VTXFMT5, + GX_VTXFMT6, + GX_VTXFMT7, + GX_MAX_VTXFMT + +} GXVtxFmt; + +#define GX_MAX_VTXFMT GX_MAX_VTXFMT + +/********************************/ +typedef enum _GXAttrType +{ + GX_NONE = 0, + GX_DIRECT, + GX_INDEX8, + GX_INDEX16 + +} GXAttrType; + +/********************************/ +typedef enum _GXTexCoordID +{ + GX_TEXCOORD0 = 0x0, // generated texture coordinate 0 + GX_TEXCOORD1, // generated texture coordinate 1 + GX_TEXCOORD2, // generated texture coordinate 2 + GX_TEXCOORD3, // generated texture coordinate 3 + GX_TEXCOORD4, // generated texture coordinate 4 + GX_TEXCOORD5, // generated texture coordinate 5 + GX_TEXCOORD6, // generated texture coordinate 6 + GX_TEXCOORD7, // generated texture coordinate 7 + GX_MAX_TEXCOORD = 8, + GX_TEXCOORD_NULL = 0xff + +} GXTexCoordID; + +#define GX_MAX_TEXCOORDGEN GX_MAX_TEXCOORD + +/********************************/ +typedef enum _GXTexGenType +{ + GX_TG_MTX3x4 = 0, + GX_TG_MTX2x4, + GX_TG_BUMP0, + GX_TG_BUMP1, + GX_TG_BUMP2, + GX_TG_BUMP3, + GX_TG_BUMP4, + GX_TG_BUMP5, + GX_TG_BUMP6, + GX_TG_BUMP7, + GX_TG_SRTG + +} GXTexGenType; + +/********************************/ +typedef enum _GXTexGenSrc +{ + GX_TG_POS = 0, + GX_TG_NRM, + GX_TG_BINRM, + GX_TG_TANGENT, + GX_TG_TEX0, + GX_TG_TEX1, + GX_TG_TEX2, + GX_TG_TEX3, + GX_TG_TEX4, + GX_TG_TEX5, + GX_TG_TEX6, + GX_TG_TEX7, + GX_TG_TEXCOORD0, + GX_TG_TEXCOORD1, + GX_TG_TEXCOORD2, + GX_TG_TEXCOORD3, + GX_TG_TEXCOORD4, + GX_TG_TEXCOORD5, + GX_TG_TEXCOORD6, + GX_TG_COLOR0, + GX_TG_COLOR1 + +} GXTexGenSrc; + +/********************************/ +typedef enum _GXCompCnt +{ +#if ( GX_REV == 1 ) + GX_POS_XY = 0, + GX_POS_XYZ = 1, + GX_NRM_XYZ = 0, + GX_NRM_NBT = 1, // not really used, just to make api consistent + GX_CLR_RGB = 0, + GX_CLR_RGBA = 1, + GX_TEX_S = 0, + GX_TEX_ST = 1 + +#else // ( GX_REV >= 2 ) + GX_POS_XY = 0, + GX_POS_XYZ = 1, + GX_NRM_XYZ = 0, + GX_NRM_NBT = 1, // one index per NBT + GX_NRM_NBT3 = 2, // one index per each of N/B/T + GX_CLR_RGB = 0, + GX_CLR_RGBA = 1, + GX_TEX_S = 0, + GX_TEX_ST = 1 + +#endif +} GXCompCnt; + +/********************************/ +typedef enum _GXCompType +{ + GX_U8 = 0, + GX_S8 = 1, + GX_U16 = 2, + GX_S16 = 3, + GX_F32 = 4, + + GX_RGB565 = 0, + GX_RGB8 = 1, + GX_RGBX8 = 2, + GX_RGBA4 = 3, + GX_RGBA6 = 4, + GX_RGBA8 = 5 + +} GXCompType; + +/********************************/ +typedef enum _GXChannelID +{ + GX_COLOR0, + GX_COLOR1, + GX_ALPHA0, + GX_ALPHA1, + GX_COLOR0A0, // Color 0 + Alpha 0 + GX_COLOR1A1, // Color 1 + Alpha 1 + GX_COLOR_ZERO, // RGBA = 0 + GX_ALPHA_BUMP, // bump alpha 0-248, RGB=0 + GX_ALPHA_BUMPN, // normalized bump alpha, 0-255, RGB=0 + GX_COLOR_NULL = 0xff + +} GXChannelID; + +/********************************/ +typedef enum _GXColorSrc +{ + GX_SRC_REG = 0, + GX_SRC_VTX + +} GXColorSrc; + +/********************************/ +typedef enum _GXLightID +{ + GX_LIGHT0 = 0x001, + GX_LIGHT1 = 0x002, + GX_LIGHT2 = 0x004, + GX_LIGHT3 = 0x008, + GX_LIGHT4 = 0x010, + GX_LIGHT5 = 0x020, + GX_LIGHT6 = 0x040, + GX_LIGHT7 = 0x080, + GX_MAX_LIGHT = 0x100, + GX_LIGHT_NULL = 0x000 +} GXLightID; + +/********************************/ +typedef enum _GXDiffuseFn +{ + GX_DF_NONE = 0, + GX_DF_SIGN, + GX_DF_CLAMP + +} GXDiffuseFn; + +/********************************/ +typedef enum _GXAttnFn +{ + GX_AF_SPEC = 0, // use specular attenuation + GX_AF_SPOT = 1, // use distance/spotlight attenuation + GX_AF_NONE // attenuation is off + +} GXAttnFn; + +/********************************/ +typedef enum _GXSpotFn +{ + GX_SP_OFF = 0, + GX_SP_FLAT, + GX_SP_COS, + GX_SP_COS2, + GX_SP_SHARP, + GX_SP_RING1, + GX_SP_RING2 +} GXSpotFn; + +/********************************/ +typedef enum _GXDistAttnFn +{ + GX_DA_OFF = 0, + GX_DA_GENTLE, + GX_DA_MEDIUM, + GX_DA_STEEP +} GXDistAttnFn; + +/********************************/ +typedef enum _GXPosNrmMtx +{ + GX_PNMTX0 = 0, + GX_PNMTX1 = 3, + GX_PNMTX2 = 6, + GX_PNMTX3 = 9, + GX_PNMTX4 = 12, + GX_PNMTX5 = 15, + GX_PNMTX6 = 18, + GX_PNMTX7 = 21, + GX_PNMTX8 = 24, + GX_PNMTX9 = 27 + +} GXPosNrmMtx; + +/********************************/ +typedef enum _GXTexMtx +{ + GX_TEXMTX0 = 30, + GX_TEXMTX1 = 33, + GX_TEXMTX2 = 36, + GX_TEXMTX3 = 39, + GX_TEXMTX4 = 42, + GX_TEXMTX5 = 45, + GX_TEXMTX6 = 48, + GX_TEXMTX7 = 51, + GX_TEXMTX8 = 54, + GX_TEXMTX9 = 57, + GX_IDENTITY = 60 + +} GXTexMtx; + +/********************************/ +#if ( GX_REV != 1 ) // Revision 2 or greater only +typedef enum _GXPTTexMtx +{ + GX_PTTEXMTX0 = 64, + GX_PTTEXMTX1 = 67, + GX_PTTEXMTX2 = 70, + GX_PTTEXMTX3 = 73, + GX_PTTEXMTX4 = 76, + GX_PTTEXMTX5 = 79, + GX_PTTEXMTX6 = 82, + GX_PTTEXMTX7 = 85, + GX_PTTEXMTX8 = 88, + GX_PTTEXMTX9 = 91, + GX_PTTEXMTX10 = 94, + GX_PTTEXMTX11 = 97, + GX_PTTEXMTX12 = 100, + GX_PTTEXMTX13 = 103, + GX_PTTEXMTX14 = 106, + GX_PTTEXMTX15 = 109, + GX_PTTEXMTX16 = 112, + GX_PTTEXMTX17 = 115, + GX_PTTEXMTX18 = 118, + GX_PTTEXMTX19 = 121, + GX_PTIDENTITY = 125 + +} GXPTTexMtx; +#endif // ( GX_REV != 1 ) + +/********************************/ +typedef enum _GXTexMtxType +{ + GX_MTX3x4 = 0, + GX_MTX2x4 + +} GXTexMtxType; + +/********************************/ +typedef enum _GXPrimitive +{ + GX_POINTS = 0xb8, + GX_LINES = 0xa8, + GX_LINESTRIP = 0xb0, + GX_TRIANGLES = 0x90, + GX_TRIANGLESTRIP = 0x98, + GX_TRIANGLEFAN = 0xa0, + GX_QUADS = 0x80 + +} GXPrimitive; + +/********************************/ +typedef enum _GXTexOffset +{ + GX_TO_ZERO, + GX_TO_SIXTEENTH, + GX_TO_EIGHTH, + GX_TO_FOURTH, + GX_TO_HALF, + GX_TO_ONE, + GX_MAX_TEXOFFSET + +} GXTexOffset; + +/********************************/ +typedef enum _GXCullMode +{ + GX_CULL_NONE, + GX_CULL_FRONT, + GX_CULL_BACK, + GX_CULL_ALL + +} GXCullMode; + +/********************************/ +typedef enum _GXClipMode +{ + // Note: these are (by design) backwards of typical enable/disables! + GX_CLIP_ENABLE = 0, + GX_CLIP_DISABLE = 1 + +} GXClipMode; + +/********************************/ +typedef enum _GXTexWrapMode +{ + GX_CLAMP, + GX_REPEAT, + GX_MIRROR, + GX_MAX_TEXWRAPMODE + +} GXTexWrapMode; + +/********************************/ +typedef enum _GXTexFilter +{ + GX_NEAR, + GX_LINEAR, + GX_NEAR_MIP_NEAR, + GX_LIN_MIP_NEAR, + GX_NEAR_MIP_LIN, + GX_LIN_MIP_LIN + +} GXTexFilter; + +/********************************/ +typedef enum _GXCITexFmt +{ + GX_TF_C4 = 0x8, + GX_TF_C8 = 0x9, + GX_TF_C14X2 = 0xa + +} GXCITexFmt; + +/********************************/ +typedef enum _GXTexFmt +{ +#if ( GX_REV == 1 ) + GX_TF_I4 = 0x0, + GX_TF_I8 = 0x1, + GX_TF_IA4 = 0x2, + GX_TF_IA8 = 0x3, + GX_TF_RGB565 = 0x4, + GX_TF_RGB5A3 = 0x5, + GX_TF_RGBA8 = 0x6, + GX_TF_CMPR = 0xE, + GX_TF_A8 = (0x20 | GX_TF_I8), + GX_TF_Z8 = (0x10 | GX_TF_I8), + GX_TF_Z16 = (0x10 | GX_TF_IA8), + GX_TF_Z24X8 = (0x10 | GX_TF_RGBA8) + +#else // ( GX_REV >= 2 ) + +#define _GX_TF_CTF 0x20 /* copy-texture-format only */ +#define _GX_TF_ZTF 0x10 /* Z-texture-format */ + + GX_TF_I4 = 0x0, + GX_TF_I8 = 0x1, + GX_TF_IA4 = 0x2, + GX_TF_IA8 = 0x3, + GX_TF_RGB565 = 0x4, + GX_TF_RGB5A3 = 0x5, + GX_TF_RGBA8 = 0x6, + GX_TF_CMPR = 0xE, + + GX_CTF_R4 = 0x0 | _GX_TF_CTF, + GX_CTF_RA4 = 0x2 | _GX_TF_CTF, + GX_CTF_RA8 = 0x3 | _GX_TF_CTF, + GX_CTF_YUVA8 = 0x6 | _GX_TF_CTF, + GX_CTF_A8 = 0x7 | _GX_TF_CTF, + GX_CTF_R8 = 0x8 | _GX_TF_CTF, + GX_CTF_G8 = 0x9 | _GX_TF_CTF, + GX_CTF_B8 = 0xA | _GX_TF_CTF, + GX_CTF_RG8 = 0xB | _GX_TF_CTF, + GX_CTF_GB8 = 0xC | _GX_TF_CTF, + + GX_TF_Z8 = 0x1 | _GX_TF_ZTF, + GX_TF_Z16 = 0x3 | _GX_TF_ZTF, + GX_TF_Z24X8 = 0x6 | _GX_TF_ZTF, + + GX_CTF_Z4 = 0x0 | _GX_TF_ZTF | _GX_TF_CTF, + GX_CTF_Z8M = 0x9 | _GX_TF_ZTF | _GX_TF_CTF, + GX_CTF_Z8L = 0xA | _GX_TF_ZTF | _GX_TF_CTF, + GX_CTF_Z16L = 0xC | _GX_TF_ZTF | _GX_TF_CTF, + + GX_TF_A8 = GX_CTF_A8 // to keep compatibility +#endif +} GXTexFmt; + +/********************************/ +typedef enum _GXTlutFmt +{ + GX_TL_IA8 = 0x0, + GX_TL_RGB565 = 0x1, + GX_TL_RGB5A3 = 0x2, + GX_MAX_TLUTFMT + +} GXTlutFmt; + +/********************************/ +typedef enum _GXTlutSize +{ + GX_TLUT_16 = 1, // number of 16 entry blocks. + GX_TLUT_32 = 2, + GX_TLUT_64 = 4, + GX_TLUT_128 = 8, + GX_TLUT_256 = 16, + GX_TLUT_512 = 32, + GX_TLUT_1K = 64, + GX_TLUT_2K = 128, + GX_TLUT_4K = 256, + GX_TLUT_8K = 512, + GX_TLUT_16K = 1024 + +} GXTlutSize; + +/********************************/ +typedef enum _GXTlut +{ + // default 256-entry TLUTs + GX_TLUT0 = 0, + GX_TLUT1, + GX_TLUT2, + GX_TLUT3, + GX_TLUT4, + GX_TLUT5, + GX_TLUT6, + GX_TLUT7, + GX_TLUT8, + GX_TLUT9, + GX_TLUT10, + GX_TLUT11, + GX_TLUT12, + GX_TLUT13, + GX_TLUT14, + GX_TLUT15, + GX_BIGTLUT0, + GX_BIGTLUT1, + GX_BIGTLUT2, + GX_BIGTLUT3 + +} GXTlut; + +/********************************/ +typedef enum _GXTexMapID +{ + GX_TEXMAP0, + GX_TEXMAP1, + GX_TEXMAP2, + GX_TEXMAP3, + GX_TEXMAP4, + GX_TEXMAP5, + GX_TEXMAP6, + GX_TEXMAP7, + GX_MAX_TEXMAP, + + GX_TEXMAP_NULL = 0xff, + GX_TEX_DISABLE = 0x100 // mask : disables texture look up + +} GXTexMapID; + +#define GX_MAX_TEXMAPS GX_MAX_TEXMAP + +/********************************/ +typedef enum _GXTexCacheSize +{ + GX_TEXCACHE_32K, + GX_TEXCACHE_128K, + GX_TEXCACHE_512K, + GX_TEXCACHE_NONE + +} GXTexCacheSize; + +/********************************/ +typedef enum _GXIndTexFormat +{ + GX_ITF_8, // 8 bit texture offsets. + GX_ITF_5, // 5 bit texture offsets. + GX_ITF_4, // 4 bit texture offsets. + GX_ITF_3, // 3 bit texture offsets. + GX_MAX_ITFORMAT + +} GXIndTexFormat; + +/********************************/ +typedef enum _GXIndTexBiasSel +{ + GX_ITB_NONE, + GX_ITB_S, + GX_ITB_T, + GX_ITB_ST, + GX_ITB_U, + GX_ITB_SU, + GX_ITB_TU, + GX_ITB_STU, + GX_MAX_ITBIAS + +} GXIndTexBiasSel; + +/********************************/ +typedef enum _GXIndTexAlphaSel +{ + GX_ITBA_OFF, + GX_ITBA_S, + GX_ITBA_T, + GX_ITBA_U, + GX_MAX_ITBALPHA + +} GXIndTexAlphaSel; + +/********************************/ +typedef enum _GXIndTexMtxID +{ + GX_ITM_OFF, + GX_ITM_0, + GX_ITM_1, + GX_ITM_2, + GX_ITM_S0 = 5, + GX_ITM_S1, + GX_ITM_S2, + GX_ITM_T0 = 9, + GX_ITM_T1, + GX_ITM_T2 + +} GXIndTexMtxID; + +/********************************/ +typedef enum _GXIndTexWrap +{ + GX_ITW_OFF, // no wrapping + GX_ITW_256, // wrap 256 + GX_ITW_128, // wrap 128 + GX_ITW_64, // wrap 64 + GX_ITW_32, // wrap 32 + GX_ITW_16, // wrap 16 + GX_ITW_0, // wrap 0 + GX_MAX_ITWRAP + +} GXIndTexWrap; + +/********************************/ +typedef enum _GXIndTexScale +{ + GX_ITS_1, // Scale by 1. + GX_ITS_2, // Scale by 1/2. + GX_ITS_4, // Scale by 1/4. + GX_ITS_8, // Scale by 1/8. + GX_ITS_16, // Scale by 1/16. + GX_ITS_32, // Scale by 1/32. + GX_ITS_64, // Scale by 1/64. + GX_ITS_128, // Scale by 1/128. + GX_ITS_256, // Scale by 1/256. + GX_MAX_ITSCALE + +} GXIndTexScale; + +/********************************/ +typedef enum _GXIndTexStageID +{ + GX_INDTEXSTAGE0, // Indirect Texture Stage Names. + GX_INDTEXSTAGE1, + GX_INDTEXSTAGE2, + GX_INDTEXSTAGE3, + GX_MAX_INDTEXSTAGE + +} GXIndTexStageID; + +/********************************/ +typedef enum _GXTevStageID +{ + GX_TEVSTAGE0, + GX_TEVSTAGE1, + GX_TEVSTAGE2, + GX_TEVSTAGE3, + GX_TEVSTAGE4, + GX_TEVSTAGE5, + GX_TEVSTAGE6, + GX_TEVSTAGE7, + GX_TEVSTAGE8, + GX_TEVSTAGE9, + GX_TEVSTAGE10, + GX_TEVSTAGE11, + GX_TEVSTAGE12, + GX_TEVSTAGE13, + GX_TEVSTAGE14, + GX_TEVSTAGE15, + GX_MAX_TEVSTAGE + +} GXTevStageID; + +#define GX_MAX_TEVSTAGES GX_MAX_TEVSTAGE + +/********************************/ +typedef enum _GXTevRegID +{ + GX_TEVPREV = 0, + GX_TEVREG0, + GX_TEVREG1, + GX_TEVREG2, + GX_MAX_TEVREG + +} GXTevRegID; + +/********************************/ +typedef enum _GXTevOp +{ +#if ( GX_REV == 1 ) + GX_TEV_ADD, + GX_TEV_SUB + +#else // ( GX_REV >= 2 ) + GX_TEV_ADD = 0, + GX_TEV_SUB = 1, + + GX_TEV_COMP_R8_GT = 8, + GX_TEV_COMP_R8_EQ = 9, + GX_TEV_COMP_GR16_GT = 10, + GX_TEV_COMP_GR16_EQ = 11, + GX_TEV_COMP_BGR24_GT = 12, + GX_TEV_COMP_BGR24_EQ = 13, + GX_TEV_COMP_RGB8_GT = 14, + GX_TEV_COMP_RGB8_EQ = 15, + + GX_TEV_COMP_A8_GT = GX_TEV_COMP_RGB8_GT, // for alpha channel + GX_TEV_COMP_A8_EQ = GX_TEV_COMP_RGB8_EQ // for alpha channel + +#endif +} GXTevOp; + +/********************************/ +typedef enum _GXTevColorArg +{ +#if ( GX_REV == 1 ) + GX_CC_CPREV, + GX_CC_APREV, + GX_CC_C0, + GX_CC_A0, + GX_CC_C1, + GX_CC_A1, + GX_CC_C2, + GX_CC_A2, + GX_CC_TEXC, + GX_CC_TEXA, + GX_CC_RASC, + GX_CC_RASA, + GX_CC_ONE, + GX_CC_HALF, + GX_CC_QUARTER, + GX_CC_ZERO, + + GX_CC_TEXRRR, + GX_CC_TEXGGG, + GX_CC_TEXBBB + +#else // ( GX_REV >= 2 ) + GX_CC_CPREV, + GX_CC_APREV, + GX_CC_C0, + GX_CC_A0, + GX_CC_C1, + GX_CC_A1, + GX_CC_C2, + GX_CC_A2, + GX_CC_TEXC, + GX_CC_TEXA, + GX_CC_RASC, + GX_CC_RASA, + GX_CC_ONE, + GX_CC_HALF, + GX_CC_KONST, + GX_CC_ZERO + +#ifndef GX_NO_LEGACY_HW1 + , // separator needed only in this case + + GX_CC_TEXRRR, // obsolete + GX_CC_TEXGGG, // obsolete + GX_CC_TEXBBB, // obsolete + + GX_CC_QUARTER = GX_CC_KONST // obsolete, to keep compatibility +#endif + +#endif +} GXTevColorArg; + +/********************************/ +typedef enum _GXTevAlphaArg +{ +#if ( GX_REV == 1 ) + GX_CA_APREV, + GX_CA_A0, + GX_CA_A1, + GX_CA_A2, + GX_CA_TEXA, + GX_CA_RASA, + GX_CA_ONE, + GX_CA_ZERO + +#else // ( GX_REV >= 2 ) + GX_CA_APREV, + GX_CA_A0, + GX_CA_A1, + GX_CA_A2, + GX_CA_TEXA, + GX_CA_RASA, + GX_CA_KONST, + GX_CA_ZERO + +#ifndef GX_NO_LEGACY_HW1 + , // separator needed only in this case + + GX_CA_ONE = GX_CA_KONST // obsolete, to keep compatibility +#endif + +#endif +} GXTevAlphaArg; + +/********************************/ +typedef enum _GXTevBias +{ + GX_TB_ZERO, + GX_TB_ADDHALF, + GX_TB_SUBHALF, + GX_MAX_TEVBIAS + +} GXTevBias; + +/********************************/ +typedef enum _GXTevClampMode +{ + GX_TC_LINEAR, + GX_TC_GE, + GX_TC_EQ, + GX_TC_LE, + GX_MAX_TEVCLAMPMODE + +} GXTevClampMode; + +/********************************/ +#if ( GX_REV != 1 ) // GX Revision 2 or later only +typedef enum _GXTevKColorID +{ + GX_KCOLOR0 = 0, + GX_KCOLOR1, + GX_KCOLOR2, + GX_KCOLOR3, + GX_MAX_KCOLOR + +} GXTevKColorID; +#endif // ( GX_REV != 1 ) + +/********************************/ +#if ( GX_REV != 1 ) // GX Revision 2 or later only +typedef enum _GXTevKColorSel +{ + GX_TEV_KCSEL_8_8 = 0x00, + GX_TEV_KCSEL_7_8 = 0x01, + GX_TEV_KCSEL_6_8 = 0x02, + GX_TEV_KCSEL_5_8 = 0x03, + GX_TEV_KCSEL_4_8 = 0x04, + GX_TEV_KCSEL_3_8 = 0x05, + GX_TEV_KCSEL_2_8 = 0x06, + GX_TEV_KCSEL_1_8 = 0x07, + + GX_TEV_KCSEL_1 = GX_TEV_KCSEL_8_8, + GX_TEV_KCSEL_3_4 = GX_TEV_KCSEL_6_8, + GX_TEV_KCSEL_1_2 = GX_TEV_KCSEL_4_8, + GX_TEV_KCSEL_1_4 = GX_TEV_KCSEL_2_8, + + GX_TEV_KCSEL_K0 = 0x0C, + GX_TEV_KCSEL_K1 = 0x0D, + GX_TEV_KCSEL_K2 = 0x0E, + GX_TEV_KCSEL_K3 = 0x0F, + GX_TEV_KCSEL_K0_R = 0x10, + GX_TEV_KCSEL_K1_R = 0x11, + GX_TEV_KCSEL_K2_R = 0x12, + GX_TEV_KCSEL_K3_R = 0x13, + GX_TEV_KCSEL_K0_G = 0x14, + GX_TEV_KCSEL_K1_G = 0x15, + GX_TEV_KCSEL_K2_G = 0x16, + GX_TEV_KCSEL_K3_G = 0x17, + GX_TEV_KCSEL_K0_B = 0x18, + GX_TEV_KCSEL_K1_B = 0x19, + GX_TEV_KCSEL_K2_B = 0x1A, + GX_TEV_KCSEL_K3_B = 0x1B, + GX_TEV_KCSEL_K0_A = 0x1C, + GX_TEV_KCSEL_K1_A = 0x1D, + GX_TEV_KCSEL_K2_A = 0x1E, + GX_TEV_KCSEL_K3_A = 0x1F + +} GXTevKColorSel; +#endif // ( GX_REV != 1 ) + +/********************************/ +#if ( GX_REV != 1 ) // GX Revision 2 or later only +typedef enum _GXTevKAlphaSel +{ + GX_TEV_KASEL_8_8 = 0x00, + GX_TEV_KASEL_7_8 = 0x01, + GX_TEV_KASEL_6_8 = 0x02, + GX_TEV_KASEL_5_8 = 0x03, + GX_TEV_KASEL_4_8 = 0x04, + GX_TEV_KASEL_3_8 = 0x05, + GX_TEV_KASEL_2_8 = 0x06, + GX_TEV_KASEL_1_8 = 0x07, + + GX_TEV_KASEL_1 = GX_TEV_KASEL_8_8, + GX_TEV_KASEL_3_4 = GX_TEV_KASEL_6_8, + GX_TEV_KASEL_1_2 = GX_TEV_KASEL_4_8, + GX_TEV_KASEL_1_4 = GX_TEV_KASEL_2_8, + + GX_TEV_KASEL_K0_R = 0x10, + GX_TEV_KASEL_K1_R = 0x11, + GX_TEV_KASEL_K2_R = 0x12, + GX_TEV_KASEL_K3_R = 0x13, + GX_TEV_KASEL_K0_G = 0x14, + GX_TEV_KASEL_K1_G = 0x15, + GX_TEV_KASEL_K2_G = 0x16, + GX_TEV_KASEL_K3_G = 0x17, + GX_TEV_KASEL_K0_B = 0x18, + GX_TEV_KASEL_K1_B = 0x19, + GX_TEV_KASEL_K2_B = 0x1A, + GX_TEV_KASEL_K3_B = 0x1B, + GX_TEV_KASEL_K0_A = 0x1C, + GX_TEV_KASEL_K1_A = 0x1D, + GX_TEV_KASEL_K2_A = 0x1E, + GX_TEV_KASEL_K3_A = 0x1F + +} GXTevKAlphaSel; +#endif // ( GX_REV != 1 ) + +/********************************/ +#if ( GX_REV != 1 ) // GX Revision 2 or later only +typedef enum _GXTevSwapSel +{ + GX_TEV_SWAP0 = 0, + GX_TEV_SWAP1, + GX_TEV_SWAP2, + GX_TEV_SWAP3, + GX_MAX_TEVSWAP + +} GXTevSwapSel; +#endif // ( GX_REV != 1 ) + +/********************************/ +#if ( GX_REV != 1 ) // GX Revision 2 or later only +typedef enum _GXTevColorChan +{ + GX_CH_RED = 0, + GX_CH_GREEN, + GX_CH_BLUE, + GX_CH_ALPHA + +} GXTevColorChan; +#endif // ( GX_REV != 1 ) + +/********************************/ +typedef enum _GXAlphaOp +{ + GX_AOP_AND, + GX_AOP_OR, + GX_AOP_XOR, + GX_AOP_XNOR, + GX_MAX_ALPHAOP + +} GXAlphaOp; + +/********************************/ +typedef enum _GXTevScale +{ + GX_CS_SCALE_1, + GX_CS_SCALE_2, + GX_CS_SCALE_4, + GX_CS_DIVIDE_2, + GX_MAX_TEVSCALE + +} GXTevScale; + +/********************************/ +typedef enum _GXFogType +{ + GX_FOG_NONE = 0x00, + + GX_FOG_PERSP_LIN = 0x02, + GX_FOG_PERSP_EXP = 0x04, + GX_FOG_PERSP_EXP2 = 0x05, + GX_FOG_PERSP_REVEXP = 0x06, + GX_FOG_PERSP_REVEXP2 = 0x07, + + GX_FOG_ORTHO_LIN = 0x0A, + GX_FOG_ORTHO_EXP = 0x0C, + GX_FOG_ORTHO_EXP2 = 0x0D, + GX_FOG_ORTHO_REVEXP = 0x0E, + GX_FOG_ORTHO_REVEXP2 = 0x0F, + + // For compatibility with former versions + GX_FOG_LIN = GX_FOG_PERSP_LIN, + GX_FOG_EXP = GX_FOG_PERSP_EXP, + GX_FOG_EXP2 = GX_FOG_PERSP_EXP2, + GX_FOG_REVEXP = GX_FOG_PERSP_REVEXP, + GX_FOG_REVEXP2 = GX_FOG_PERSP_REVEXP2 + +} GXFogType; + +/********************************/ +typedef enum _GXBlendMode +{ +#if ( GX_REV == 1 ) + GX_BM_NONE, + GX_BM_BLEND, + GX_BM_LOGIC, + GX_MAX_BLENDMODE + +#else // ( GX_REV >= 2 ) + GX_BM_NONE, + GX_BM_BLEND, + GX_BM_LOGIC, + GX_BM_SUBTRACT, + GX_MAX_BLENDMODE + +#endif +} GXBlendMode; + +/********************************/ +typedef enum _GXBlendFactor +{ + GX_BL_ZERO, + GX_BL_ONE, + GX_BL_SRCCLR, + GX_BL_INVSRCCLR, + GX_BL_SRCALPHA, + GX_BL_INVSRCALPHA, + GX_BL_DSTALPHA, + GX_BL_INVDSTALPHA, + + GX_BL_DSTCLR = GX_BL_SRCCLR, + GX_BL_INVDSTCLR = GX_BL_INVSRCCLR + +} GXBlendFactor; + +/********************************/ +typedef enum _GXCompare +{ + GX_NEVER, + GX_LESS, + GX_EQUAL, + GX_LEQUAL, + GX_GREATER, + GX_NEQUAL, + GX_GEQUAL, + GX_ALWAYS + +} GXCompare; + +/********************************/ +typedef enum _GXLogicOp +{ + GX_LO_CLEAR, + GX_LO_AND, + GX_LO_REVAND, + GX_LO_COPY, + GX_LO_INVAND, + GX_LO_NOOP, + GX_LO_XOR, + GX_LO_OR, + GX_LO_NOR, + GX_LO_EQUIV, + GX_LO_INV, + GX_LO_REVOR, + GX_LO_INVCOPY, + GX_LO_INVOR, + GX_LO_NAND, + GX_LO_SET + +} GXLogicOp; + +/********************************/ +typedef enum _GXPixelFmt +{ + GX_PF_RGB8_Z24, + GX_PF_RGBA6_Z24, + GX_PF_RGB565_Z16, + GX_PF_Z24, + GX_PF_Y8, + GX_PF_U8, + GX_PF_V8, + GX_PF_YUV420 + +} GXPixelFmt; + +/********************************/ +typedef enum _GXZFmt16 +{ + GX_ZC_LINEAR, + GX_ZC_NEAR, + GX_ZC_MID, + GX_ZC_FAR + +} GXZFmt16; + +/********************************/ +typedef enum _GXTevMode +{ + GX_MODULATE, + GX_DECAL, + GX_BLEND, + GX_REPLACE, + GX_PASSCLR + +} GXTevMode; + +/********************************/ +typedef enum _GXGamma +{ + GX_GM_1_0, + GX_GM_1_7, + GX_GM_2_2 + +} GXGamma; + +/********************************/ +typedef enum _GXProjectionType +{ + GX_PERSPECTIVE, + GX_ORTHOGRAPHIC + +} GXProjectionType; + + +/********************************/ +typedef enum _GXEvent +{ + GX_VCACHE_MISS_ALL, + GX_VCACHE_MISS_POS, + GX_VCACHE_MISS_NRM + +} GXEvent; + +/********************************/ +typedef enum _GXFBClamp +{ + GX_CLAMP_NONE, + GX_CLAMP_TOP, + GX_CLAMP_BOTTOM + +} GXFBClamp; + +/********************************/ +typedef enum _GXAnisotropy +{ + GX_ANISO_1, + GX_ANISO_2, + GX_ANISO_4, + GX_MAX_ANISOTROPY + +} GXAnisotropy; + +/********************************/ +typedef enum _GXZTexOp +{ + GX_ZT_DISABLE, + GX_ZT_ADD, + GX_ZT_REPLACE, + GX_MAX_ZTEXOP + +} GXZTexOp; + +/********************************/ +typedef enum _GXAlphaReadMode +{ + GX_READ_00, + GX_READ_FF, + GX_READ_NONE + +} GXAlphaReadMode; + +/********************************/ +typedef enum _GXPerf0 +{ + GX_PERF0_VERTICES, + GX_PERF0_CLIP_VTX, + GX_PERF0_CLIP_CLKS, + GX_PERF0_XF_WAIT_IN, + GX_PERF0_XF_WAIT_OUT, + GX_PERF0_XF_XFRM_CLKS, + GX_PERF0_XF_LIT_CLKS, + GX_PERF0_XF_BOT_CLKS, + GX_PERF0_XF_REGLD_CLKS, + GX_PERF0_XF_REGRD_CLKS, + GX_PERF0_CLIP_RATIO, + + GX_PERF0_TRIANGLES, + GX_PERF0_TRIANGLES_CULLED, + GX_PERF0_TRIANGLES_PASSED, + GX_PERF0_TRIANGLES_SCISSORED, + GX_PERF0_TRIANGLES_0TEX, + GX_PERF0_TRIANGLES_1TEX, + GX_PERF0_TRIANGLES_2TEX, + GX_PERF0_TRIANGLES_3TEX, + GX_PERF0_TRIANGLES_4TEX, + GX_PERF0_TRIANGLES_5TEX, + GX_PERF0_TRIANGLES_6TEX, + GX_PERF0_TRIANGLES_7TEX, + GX_PERF0_TRIANGLES_8TEX, + GX_PERF0_TRIANGLES_0CLR, + GX_PERF0_TRIANGLES_1CLR, + GX_PERF0_TRIANGLES_2CLR, + + GX_PERF0_QUAD_0CVG, + GX_PERF0_QUAD_NON0CVG, + GX_PERF0_QUAD_1CVG, + GX_PERF0_QUAD_2CVG, + GX_PERF0_QUAD_3CVG, + GX_PERF0_QUAD_4CVG, + GX_PERF0_AVG_QUAD_CNT, + + GX_PERF0_CLOCKS, + GX_PERF0_NONE + +} GXPerf0; + +/********************************/ +typedef enum _GXPerf1 +{ + GX_PERF1_TEXELS, + GX_PERF1_TX_IDLE, + GX_PERF1_TX_REGS, + GX_PERF1_TX_MEMSTALL, + GX_PERF1_TC_CHECK1_2, + GX_PERF1_TC_CHECK3_4, + GX_PERF1_TC_CHECK5_6, + GX_PERF1_TC_CHECK7_8, + GX_PERF1_TC_MISS, + + GX_PERF1_VC_ELEMQ_FULL, + GX_PERF1_VC_MISSQ_FULL, + GX_PERF1_VC_MEMREQ_FULL, + GX_PERF1_VC_STATUS7, + GX_PERF1_VC_MISSREP_FULL, + GX_PERF1_VC_STREAMBUF_LOW, + GX_PERF1_VC_ALL_STALLS, + GX_PERF1_VERTICES, + + GX_PERF1_FIFO_REQ, + GX_PERF1_CALL_REQ, + GX_PERF1_VC_MISS_REQ, + GX_PERF1_CP_ALL_REQ, + + GX_PERF1_CLOCKS, + GX_PERF1_NONE + +} GXPerf1; + +/********************************/ +typedef enum _GXVCachePerf +{ + GX_VC_POS, + GX_VC_NRM, + GX_VC_CLR0, + GX_VC_CLR1, + GX_VC_TEX0, + GX_VC_TEX1, + GX_VC_TEX2, + GX_VC_TEX3, + GX_VC_TEX4, + GX_VC_TEX5, + GX_VC_TEX6, + GX_VC_TEX7, + GX_VC_ALL = 0xf + +} GXVCachePerf; + +/********************************/ +typedef enum _GXCopyMode +{ + GX_COPY_PROGRESSIVE = 0, + GX_COPY_INTLC_EVEN = 2, + GX_COPY_INTLC_ODD = 3 + +} GXCopyMode; + +/********************************/ +typedef enum _GXMiscToken +{ + GX_MT_XF_FLUSH = 1, + GX_MT_DL_SAVE_CONTEXT = 2, + GX_MT_ABORT_WAIT_COPYOUT = 3, + GX_MT_NULL = 0 + +} GXMiscToken; + +/********************************/ +typedef enum _GXXFFlushVal +{ + GX_XF_FLUSH_NONE = 0, + GX_XF_FLUSH_SAFE = 8 + +} GXXFFlushVal; + +/********************************/ +// Compile-time checks to ensure that enumerations are compiled +// as 32-bit integers. If your build breaks at this line, +// please ensure that you enable the "enumerations are integers" +// option for the compiler. + +#define GXCTASSERT(cond) int GXCTASSERT( int assertion_failed[ (cond) != 0 ] ) + +GXCTASSERT(sizeof(GXAttrType) == sizeof(u32)); + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif // __GXENUM_H__ diff --git a/include/rvl/GXGeometry.h b/include/rvl/GXGeometry.h new file mode 100755 index 0000000..b85a4f0 --- /dev/null +++ b/include/rvl/GXGeometry.h @@ -0,0 +1,82 @@ +#ifndef __GXGEOMETRY_H__ +#define __GXGEOMETRY_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------*/ +#include "rvl/GXStruct.h" + +void GXSetVtxDesc ( GXAttr attr, GXAttrType type ); +void GXSetVtxDescv ( const GXVtxDescList *attrPtr ); +void GXClearVtxDesc ( void ); + +void GXSetVtxAttrFmt( + GXVtxFmt vtxfmt, + GXAttr attr, + GXCompCnt cnt, + GXCompType type, + u8 frac ); + +void GXSetVtxAttrFmtv ( GXVtxFmt vtxfmt, const GXVtxAttrFmtList *list ); +void GXSetArray ( GXAttr attr, const void *base_ptr, u8 stride ); +void GXBegin ( GXPrimitive type, GXVtxFmt vtxfmt, u16 nverts ); + +#if defined(EMU) || defined(WIN32) +void GXEnd ( void ); +#else // !EMU +static inline void GXEnd ( void ) +{ +#ifdef _DEBUG + extern GXBool __GXinBegin; + if (!__GXinBegin) + OSPanic(__FILE__, __LINE__, "GXEnd: called without a GXBegin"); + __GXinBegin = GX_FALSE; +#endif +} +#endif // EMU + +#if ( GX_REV != 1 ) // GX revision 2 or later only +void GXSetTexCoordGen2( + GXTexCoordID dst_coord, + GXTexGenType func, + GXTexGenSrc src_param, + u32 mtx, + GXBool normalize, + u32 postmtx ); +#endif // ( GX_REV != 1 ) + +#if ( GX_REV == 1 || defined(EMU) ) // GX revision 1 or emulator +void GXSetTexCoordGen( + GXTexCoordID dst_coord, + GXTexGenType func, + GXTexGenSrc src_param, + u32 mtx ); +#else // GX revision 2 or later and real hardware +static inline void GXSetTexCoordGen ( + GXTexCoordID dst_coord, + GXTexGenType func, + GXTexGenSrc src_param, + u32 mtx ) +{ + GXSetTexCoordGen2(dst_coord, func, src_param, mtx, + GX_FALSE, GX_PTIDENTITY); +} +#endif // ( GX_REV == 1 || defined(EMU) ) + + +void GXSetNumTexGens ( u8 nTexGens ); + +void GXInvalidateVtxCache ( void ); +void GXSetLineWidth ( u8 width, GXTexOffset texOffsets ); +void GXSetPointSize ( u8 pointSize, GXTexOffset texOffsets ); +void GXEnableTexOffsets ( GXTexCoordID coord, GXBool line_enable, + GXBool point_enable ); + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif // __GXGEOMETRY_H__ diff --git a/include/rvl/GXLighting.h b/include/rvl/GXLighting.h new file mode 100755 index 0000000..26139b9 --- /dev/null +++ b/include/rvl/GXLighting.h @@ -0,0 +1,94 @@ +#ifndef __GXLIGHTING_H__ +#define __GXLIGHTING_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------*/ +#include "rvl/GXStruct.h" + +/*---------------------------------------------------------------------------*/ +void GXInitLightAttn( + GXLightObj* lt_obj, + f32 a0, + f32 a1, + f32 a2, + f32 k0, + f32 k1, + f32 k2 ); + +void GXInitLightAttnA ( GXLightObj *lt_obj, f32 a0, f32 a1, f32 a2); +void GXInitLightAttnK ( GXLightObj *lt_obj, f32 k0, f32 k1, f32 k2 ); + +void GXInitLightSpot( + GXLightObj* lt_obj, + f32 cutoff, + GXSpotFn spot_func ); + +void GXInitLightDistAttn( + GXLightObj* lt_obj, + f32 ref_distance, + f32 ref_brightness, + GXDistAttnFn dist_func ); + + +void GXInitLightPos ( GXLightObj* lt_obj, f32 x, f32 y, f32 z ); +void GXInitLightColor ( GXLightObj* lt_obj, GXColor color ); +void GXLoadLightObjImm ( const GXLightObj* lt_obj, GXLightID light ); +void GXLoadLightObjIndx ( u32 lt_obj_indx, GXLightID light ); +void GXSetChanAmbColor ( GXChannelID chan, GXColor amb_color ); +void GXSetChanMatColor ( GXChannelID chan, GXColor mat_color ); +void GXSetNumChans ( u8 nChans ); + +void GXInitLightDir ( GXLightObj* lt_obj, f32 nx, f32 ny, f32 nz ); + +// New functions to set light direction and half-angle. +void GXInitSpecularDir ( GXLightObj* lt_obj, f32 nx, f32 ny, f32 nz ); +void GXInitSpecularDirHA( + GXLightObj* lt_obj, + f32 nx, + f32 ny, + f32 nz, + f32 hx, + f32 hy, + f32 hz ); + +void GXSetChanCtrl( + GXChannelID chan, + GXBool enable, + GXColorSrc amb_src, + GXColorSrc mat_src, + u32 light_mask, + GXDiffuseFn diff_fn, + GXAttnFn attn_fn ); + +/*---------------------------------------------------------------------------*/ +// Convenient Macros + +#define GXInitLightPosv(lo,vec) \ + (GXInitLightPos((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2))) + +#define GXInitLightDirv(lo,vec) \ + (GXInitLightDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2))) + +#define GXInitSpecularDirv(lo,vec) \ + (GXInitSpecularDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2))) + +#define GXInitSpecularDirHAv(lo,vec0,vec1) \ + (GXInitSpecularDirHA((lo), \ + *(f32*)(vec0), *((f32*)(vec0)+1), *((f32*)(vec0)+2), \ + *(f32*)(vec1), *((f32*)(vec1)+1), *((f32*)(vec1)+2))) + +#define GXInitLightShininess(lobj, shininess) \ + (GXInitLightAttn(lobj, 0.0F, 0.0F, 1.0F, \ + (shininess)/2.0F, 0.0F, \ + 1.0F-(shininess)/2.0F )) + + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif // __GXLIGHTING_H__ diff --git a/include/rvl/GXPixel.h b/include/rvl/GXPixel.h new file mode 100755 index 0000000..ddacc88 --- /dev/null +++ b/include/rvl/GXPixel.h @@ -0,0 +1,49 @@ +#ifndef __GXPIXEL_H__ +#define __GXPIXEL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------*/ +#include "rvl/GXEnum.h" +#include "rvl/GXStruct.h" + +/*---------------------------------------------------------------------------*/ +void GXSetFog( GXFogType type, + f32 startz, + f32 endz, + f32 nearz, + f32 farz, + GXColor color ); + +void GXSetFogColor( GXColor color ); + +void GXInitFogAdjTable( GXFogAdjTable* table, u16 width, const f32 projmtx[4][4] ); + +void GXSetFogRangeAdj( GXBool enable, u16 center, const GXFogAdjTable* table ); + +void GXSetBlendMode ( GXBlendMode type, + GXBlendFactor src_factor, + GXBlendFactor dst_factor, + GXLogicOp op ); + +void GXSetColorUpdate( GXBool update_enable ); +void GXSetAlphaUpdate( GXBool update_enable ); +void GXSetZMode( GXBool compare_enable, + GXCompare func, + GXBool update_enable ); + +void GXSetZCompLoc( GXBool before_tex ); +void GXSetPixelFmt ( GXPixelFmt pix_fmt, GXZFmt16 z_fmt ); +void GXSetDither( GXBool dither ); +void GXSetDstAlpha( GXBool enable, u8 alpha ); +void GXSetFieldMask( GXBool odd_mask, GXBool even_mask ); +void GXSetFieldMode( GXBool field_mode, GXBool half_aspect_ratio ); + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif // __GXPIXEL_H__ + +#endif diff --git a/include/rvl/GXStruct.h b/include/rvl/GXStruct.h new file mode 100755 index 0000000..2b58a98 --- /dev/null +++ b/include/rvl/GXStruct.h @@ -0,0 +1,132 @@ +#ifndef __GXSTRUCT_H__ +#define __GXSTRUCT_H__ + +/********************************/ +#ifdef __cplusplus +extern "C" { +#endif + +/********************************/ +#include "rvl/vitypes.h" + +/*---------------------------------------------------------------------------*/ + +#ifdef __MWERKS__ +#pragma warn_padding off +#endif // __MWERKS__ + +/*---------------------------------------------------------------------------*/ + +/********************************/ +typedef struct _GXColor +{ + u8 r, + g, + b, + a; + +} GXColor; + +typedef struct _GXColorS10 +{ + s16 r, g, b, a; // s10-bit components for Tev constant color +} GXColorS10; + +/********************************/ +typedef struct _GXTexObj +{ +#ifdef EMU + u32 dummy[16]; // emulator version +#else + u32 dummy[8]; // real hardware version +#endif +} GXTexObj; + +/********************************/ +typedef struct _GXTlutObj +{ + u32 dummy[3]; + +} GXTlutObj; + +/********************************/ +typedef struct _GXLightObj +{ + u32 dummy[16]; + +} GXLightObj; + +/********************************/ +typedef struct _GXVtxAttrFmtList +{ + GXAttr attr; + GXCompCnt cnt; + GXCompType type; + u8 frac; + +} GXVtxAttrFmtList; + +/********************************/ +typedef struct _GXTexRegion +{ +#ifdef EMU + u32 dummy[8]; // emulator version +#else + u32 dummy[4]; // real hardware version +#endif +} GXTexRegion; + +/********************************/ +typedef struct _GXTlutRegion +{ + u32 dummy[4]; + +} GXTlutRegion; + +/********************************/ +typedef struct _GXVtxDescList +{ + GXAttr attr; + GXAttrType type; + +} GXVtxDescList; + +/********************************/ +typedef struct _GXRenderModeObj +{ + VITVMode viTVmode; + u16 fbWidth; // no xscale from efb to xfb + u16 efbHeight; // embedded frame buffer + u16 xfbHeight; // external frame buffer, may yscale efb + u16 viXOrigin; + u16 viYOrigin; + u16 viWidth; + u16 viHeight; + VIXFBMode xFBmode; // whether single-field or double-field in + // XFB. + u8 field_rendering; // rendering fields or frames? + u8 aa; // anti-aliasing on? + u8 sample_pattern[12][2]; // aa sample pattern + u8 vfilter[7]; // vertical filter coefficients +} GXRenderModeObj; + +/********************************/ +typedef struct _GXFogAdjTable +{ + u16 r[10]; +} GXFogAdjTable; + +/********************************/ + +/*---------------------------------------------------------------------------*/ + +#ifdef __MWERKS__ +#pragma warn_padding reset +#endif // __MWERKS__ + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/rvl/GXTev.h b/include/rvl/GXTev.h new file mode 100755 index 0000000..1cecafc --- /dev/null +++ b/include/rvl/GXTev.h @@ -0,0 +1,92 @@ +#ifndef __GXTEV_H__ +#define __GXTEV_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------*/ +#include "rvl/GXStruct.h" + +/*---------------------------------------------------------------------------*/ +void GXSetTevOp(GXTevStageID id, GXTevMode mode); + +void GXSetTevColorIn( + GXTevStageID stage, + GXTevColorArg a, + GXTevColorArg b, + GXTevColorArg c, + GXTevColorArg d ); + +void GXSetTevAlphaIn( + GXTevStageID stage, + GXTevAlphaArg a, + GXTevAlphaArg b, + GXTevAlphaArg c, + GXTevAlphaArg d ); + +void GXSetTevColorOp( + GXTevStageID stage, + GXTevOp op, + GXTevBias bias, + GXTevScale scale, + GXBool clamp, + GXTevRegID out_reg ); + +void GXSetTevAlphaOp( + GXTevStageID stage, + GXTevOp op, + GXTevBias bias, + GXTevScale scale, + GXBool clamp, + GXTevRegID out_reg ); + +void GXSetTevColor( GXTevRegID id, GXColor color ); +void GXSetTevColorS10( GXTevRegID id, GXColorS10 color ); + +// Feature available in GX chip revision 1 only +// Revision 2 version is defined, but only prints error msg +void GXSetTevClampMode ( GXTevStageID stage, GXTevClampMode mode ); + +void GXSetAlphaCompare( + GXCompare comp0, + u8 ref0, + GXAlphaOp op, + GXCompare comp1, + u8 ref1 ); + +void GXSetTevOrder( + GXTevStageID stage, + GXTexCoordID coord, + GXTexMapID map, + GXChannelID color ); + +void GXSetZTexture ( GXZTexOp op, GXTexFmt fmt, u32 bias ); +void GXSetNumTevStages( u8 nStages ); + +#if ( GX_REV != 1 ) +// Features available in GX chip revision 2 or later only +void GXSetTevKColor( GXTevKColorID id, GXColor color ); +void GXSetTevKColorSel( GXTevStageID stage, GXTevKColorSel sel ); +void GXSetTevKAlphaSel( GXTevStageID stage, GXTevKAlphaSel sel ); + +void GXSetTevSwapMode( + GXTevStageID stage, + GXTevSwapSel ras_sel, + GXTevSwapSel tex_sel ); + +void GXSetTevSwapModeTable( + GXTevSwapSel table, + GXTevColorChan red, + GXTevColorChan green, + GXTevColorChan blue, + GXTevColorChan alpha ); + +#endif // ( GX_REV != 1 ) + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif // __GXTEV_H__ diff --git a/include/rvl/GXTexture.h b/include/rvl/GXTexture.h new file mode 100755 index 0000000..b51f6d5 --- /dev/null +++ b/include/rvl/GXTexture.h @@ -0,0 +1,127 @@ +#ifndef __GXTEXTURE_H__ +#define __GXTEXTURE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------*/ + +typedef GXTexRegion* (*GXTexRegionCallback) (const GXTexObj* t_obj, GXTexMapID id); +typedef GXTlutRegion* (*GXTlutRegionCallback)(u32 idx); + +/*---------------------------------------------------------------------------*/ +void GXInitTexObj( + GXTexObj* obj, + void* image_ptr, + u16 width, + u16 height, + GXTexFmt format, + GXTexWrapMode wrap_s, + GXTexWrapMode wrap_t, + GXBool mipmap); + +void GXInitTexObjCI( + GXTexObj* obj, + void* image_ptr, + u16 width, + u16 height, + GXCITexFmt format, + GXTexWrapMode wrap_s, + GXTexWrapMode wrap_t, + GXBool mipmap, + u32 tlut_name); + +void GXInitTexObjLOD( + GXTexObj* obj, + GXTexFilter min_filt, + GXTexFilter mag_filt, + f32 min_lod, + f32 max_lod, + f32 lod_bias, + GXBool bias_clamp, + GXBool do_edge_lod, + GXAnisotropy max_aniso ); + +void GXInitTexObjData ( GXTexObj* obj, void* image_ptr ); +void GXInitTexObjWrapMode ( GXTexObj* obj, GXTexWrapMode s, GXTexWrapMode t ); +void GXInitTexObjTlut ( GXTexObj* obj, u32 tlut_name ); +void GXInitTexObjFilter ( GXTexObj* obj, GXTexFilter min_filt, GXTexFilter mag_filt ); +void GXInitTexObjMaxLOD ( GXTexObj* obj, f32 max_lod ); +void GXInitTexObjMinLOD ( GXTexObj* obj, f32 min_lod ); +void GXInitTexObjLODBias ( GXTexObj* obj, f32 lod_bias ); +void GXInitTexObjBiasClamp( GXTexObj* obj, GXBool bias_clamp ); +void GXInitTexObjEdgeLOD ( GXTexObj* obj, GXBool do_edge_lod ); +void GXInitTexObjMaxAniso ( GXTexObj* obj, GXAnisotropy max_aniso ); + + +void GXInitTexObjUserData ( GXTexObj* obj, void* user_data ); +void* GXGetTexObjUserData ( const GXTexObj* obj ); + +void GXLoadTexObj ( const GXTexObj* obj, GXTexMapID id ); + +u32 GXGetTexBufferSize( + u16 width, + u16 height, + u32 format, + GXBool mipmap, + u8 max_lod ); + +void GXInitTlutObj( + GXTlutObj* tlut_obj, + void* lut, + GXTlutFmt fmt, + u16 n_entries ); + +void GXLoadTlut ( const GXTlutObj* tlut_obj, u32 tlut_name ); + +void GXInitTexCacheRegion( + GXTexRegion* region, + GXBool is_32b_mipmap, + u32 tmem_even, + GXTexCacheSize size_even, + u32 tmem_odd, + GXTexCacheSize size_odd ); + +void GXInitTexPreLoadRegion( + GXTexRegion* region, + u32 tmem_even, + u32 size_even, + u32 tmem_odd, + u32 size_odd ); + +void GXInitTlutRegion( + GXTlutRegion* region, + u32 tmem_addr, + GXTlutSize tlut_size ); + +void GXInvalidateTexRegion ( const GXTexRegion* region ); +void GXInvalidateTexAll ( void ); +void GXPreLoadEntireTexture ( const GXTexObj* tex_obj, const GXTexRegion* region ); + +GXTexRegionCallback GXSetTexRegionCallback ( GXTexRegionCallback f ); +GXTlutRegionCallback GXSetTlutRegionCallback( GXTlutRegionCallback f ); + +void GXLoadTexObjPreLoaded( + const GXTexObj* obj, + const GXTexRegion* region, + GXTexMapID id ); + +void GXSetTexCoordScaleManually(GXTexCoordID coord, + GXBool enable, + u16 ss, u16 ts); + +void GXSetTexCoordCylWrap(GXTexCoordID coord, + GXBool s_enable, + GXBool t_enable); + +void GXSetTexCoordBias(GXTexCoordID coord, + GXBool s_enable, + GXBool t_enable); + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif // __GXTEXTURE_H__ diff --git a/include/rvl/GXTransform.h b/include/rvl/GXTransform.h new file mode 100755 index 0000000..15c508a --- /dev/null +++ b/include/rvl/GXTransform.h @@ -0,0 +1,71 @@ +#ifndef __GXTRANSFORM_H__ +#define __GXTRANSFORM_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------*/ + +#define GX_PROJECTION_SZ 7 +#define GX_VIEWPORT_SZ 6 + +/*---------------------------------------------------------------------------*/ +void GXSetProjection ( const f32 mtx[4][4], GXProjectionType type ); +void GXSetProjectionv ( const f32 *ptr ); +void GXLoadPosMtxImm ( const f32 mtx[3][4], u32 id ); +void GXLoadPosMtxIndx ( u16 mtx_indx, u32 id ); +void GXLoadNrmMtxImm ( const f32 mtx[3][4], u32 id ); +void GXLoadNrmMtxImm3x3 ( const f32 mtx[3][3], u32 id ); +void GXLoadNrmMtxIndx3x3 ( u16 mtx_indx, u32 id ); +void GXSetCurrentMtx ( u32 id ); +void GXLoadTexMtxImm ( const f32 mtx[][4], u32 id, GXTexMtxType type ); +void GXLoadTexMtxIndx ( u16 mtx_indx, u32 id, GXTexMtxType type ); + +void GXProject ( + f32 x, // model coordinates + f32 y, + f32 z, + const f32 mtx[3][4], // model-view matrix + const f32* pm, // projection matrix, as returned by GXGetProjectionv + const f32* vp, // viewport, as returned by GXGetViewportv + f32* sx, // screen coordinates + f32* sy, + f32* sz ); + +void GXSetViewport( + f32 left, + f32 top, + f32 wd, + f32 ht, + f32 nearz, + f32 farz ); + +static inline void GXSetViewportv( const f32 *vp ) +{ // Note: doesn't check for NULL ptr + GXSetViewport(vp[0], vp[1], vp[2], vp[3], vp[4], vp[5]); +} + +void GXSetViewportJitter( + f32 left, + f32 top, + f32 wd, + f32 ht, + f32 nearz, + f32 farz, + u32 field ); + +void GXSetZScaleOffset ( f32 scale, f32 offset ); + +#if ( GX_REV != 1 ) +void GXSetScissorBoxOffset( s32 x_off, s32 y_off ); +#endif + +void GXSetClipMode( GXClipMode mode ); + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif // __GXTRANSFORM_H__ diff --git a/include/rvl/GXVert.h b/include/rvl/GXVert.h new file mode 100755 index 0000000..8564563 --- /dev/null +++ b/include/rvl/GXVert.h @@ -0,0 +1,222 @@ +#ifndef __GXVERT_H__ +#define __GXVERT_H__ + +#ifdef WIN32 +#include +#endif + +// NOTE: This file closely mirrors GXVert.c. +// Don't change this file without considering that one too, +// and vice-versa. + +/********************************/ +#ifdef __cplusplus +extern "C" { +#endif + +/*>*******************************(*)*******************************<*/ +#ifndef EMU // real hardware +/*---------------------------------------------* + * Write gather pipe for GFXFifo * + *---------------------------------------------*/ +#ifndef MINNOW +#define GXFIFO_ADDR 0xCC008000 +#else // MINNOW +#define GXFIFO_ADDR 0x1C008000 +#endif// MINNOW + +// SN-Phil: removed 'extern', added AT_ADDRESS +//volatile PPCWGPipe GXWGFifo AT_ADDRESS(GXFIFO_ADDR) ; +extern volatile PPCWGPipe GXWGFifo; + +#endif // !EMU +/*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +/*---------------------------------------------* + * GXVertex functions * + *---------------------------------------------*/ +//------------------------------- +// Define gfx function templates +//------------------------------- +// +// Templates syntax: +// __GXCDEF (function_prefix, num_of_components, component_type) +// __GXCDEFX(function_name, num_of_comps, src_comp_type, dest_comp_type) +// +#define __GXCDEF(prfx,n,t) __GXCDEF##n(prfx##n##t,t,t) +#define __GXCDEFX(func,n,t) __GXCDEF##n(func,t,t) + +#ifdef _DEBUG + +// 1 component +#define __GXCDEF1(func,ts,td) \ + void func(const ts x); + +// 2 components +#define __GXCDEF2(func,ts,td) \ + void func(const ts x, const ts y); + +// 3 components +#define __GXCDEF3(func,ts,td) \ + void func(const ts x, const ts y, const ts z); + +// 4 components +#define __GXCDEF4(func,ts,td) \ + void func(const ts x, const ts y, const ts z, const ts w); + + +#else // ifdef _DEBUG +/*---------------------------------------------* + * For real hardware * + *---------------------------------------------*/ +#ifndef EMU + +// 1 component +#define __GXCDEF1(func,ts,td) \ + static inline void func(const ts x) \ + { \ + GXWGFifo._##td = (td) x; \ + return; \ + } + +// 2 components +#define __GXCDEF2(func,ts,td) \ + static inline void func(const ts x, const ts y) \ + { \ + GXWGFifo._##td = (td) x; \ + GXWGFifo._##td = (td) y; \ + return; \ + } + +// 3 components +#define __GXCDEF3(func,ts,td) \ + static inline void func(const ts x, const ts y, const ts z) \ + { \ + GXWGFifo._##td = (td) x; \ + GXWGFifo._##td = (td) y; \ + GXWGFifo._##td = (td) z; \ + return; \ + } + +// 4 components +#define __GXCDEF4(func,ts,td) \ + static inline void func(const ts x, const ts y, const ts z, const ts w) \ + { \ + GXWGFifo._##td = (td) x; \ + GXWGFifo._##td = (td) y; \ + GXWGFifo._##td = (td) z; \ + GXWGFifo._##td = (td) w; \ + return; \ + } + +#endif // ifndef EMU + +#endif // ifdef _DEBUG else + +//--------------------------- +// Generate inline functions +//--------------------------- +//---- GXCmd[n][t] ---- +__GXCDEF( GXCmd, 1, u8 ) +__GXCDEF( GXCmd, 1, u16 ) +__GXCDEF( GXCmd, 1, u32 ) + +//---- GXParam[n][t] ---- +__GXCDEF( GXParam, 1, u8 ) +__GXCDEF( GXParam, 1, u16 ) +__GXCDEF( GXParam, 1, u32 ) +__GXCDEF( GXParam, 1, s8 ) +__GXCDEF( GXParam, 1, s16 ) +__GXCDEF( GXParam, 1, s32 ) +__GXCDEF( GXParam, 1, f32 ) +__GXCDEF( GXParam, 3, f32 ) // for light +__GXCDEF( GXParam, 4, f32 ) // for matrix + +//---- GXPosition[n][t] ---- + // for GX_POS_XYZ +__GXCDEF( GXPosition, 3, f32 ) +__GXCDEF( GXPosition, 3, u8 ) +__GXCDEF( GXPosition, 3, s8 ) +__GXCDEF( GXPosition, 3, u16 ) +__GXCDEF( GXPosition, 3, s16 ) + // for GX_POS_XY +__GXCDEF( GXPosition, 2, f32 ) +__GXCDEF( GXPosition, 2, u8 ) +__GXCDEF( GXPosition, 2, s8 ) +__GXCDEF( GXPosition, 2, u16 ) +__GXCDEF( GXPosition, 2, s16 ) + // for Index +__GXCDEFX( GXPosition1x16, 1, u16 ) +__GXCDEFX( GXPosition1x8, 1, u8 ) + +//---- GXNormal[n][t] ---- + // for GX_NRM or GX_NBT +__GXCDEF( GXNormal, 3, f32 ) +__GXCDEF( GXNormal, 3, s16 ) +__GXCDEF( GXNormal, 3, s8 ) + // for Index +__GXCDEFX( GXNormal1x16, 1, u16 ) +__GXCDEFX( GXNormal1x8, 1, u8 ) + +//---- GXColor[n][t] ---- + // for GX_CLR_RGBA8 or RGBX8 +__GXCDEF( GXColor, 4, u8 ) +__GXCDEF( GXColor, 1, u32 ) + // for GX_CLR_RGBA6 or RGB8 +__GXCDEF( GXColor, 3, u8 ) + // for GX_CLR_RGBA4 or RGB565 +__GXCDEF( GXColor, 1, u16 ) + // for Index +__GXCDEFX( GXColor1x16, 1, u16 ) +__GXCDEFX( GXColor1x8, 1, u8 ) + +//---- GXTexCoord[n][t] ---- + // for GX_TEX_ST +__GXCDEF( GXTexCoord, 2, f32 ) +__GXCDEF( GXTexCoord, 2, s16 ) +__GXCDEF( GXTexCoord, 2, u16 ) +__GXCDEF( GXTexCoord, 2, s8 ) +__GXCDEF( GXTexCoord, 2, u8 ) + // for GX_TEX_S +__GXCDEF( GXTexCoord, 1, f32 ) +__GXCDEF( GXTexCoord, 1, s16 ) +__GXCDEF( GXTexCoord, 1, u16 ) +__GXCDEF( GXTexCoord, 1, s8 ) +__GXCDEF( GXTexCoord, 1, u8 ) + // for Index +__GXCDEFX( GXTexCoord1x16, 1, u16 ) +__GXCDEFX( GXTexCoord1x8, 1, u8 ) + +//---- GXMatrixIndex* ---- +// GXMatrixIndex1u8 +__GXCDEF( GXMatrixIndex, 1, u8 ) +#define GXMatrixIndex1x8 GXMatrixIndex1u8 + +//------------------------ +// Undefine all templates +//------------------------ +#undef __GXCDEF +#undef __GXCDEFX +#undef __GXCDEF1 +#undef __GXCDEF2 +#undef __GXCDEF3 +#undef __GXCDEF4 + +/*---------------------------------------------------------------------------*/ +// Packing macro for a several color format +#define GXPackedRGB565(r,g,b) \ + ((u16)((((r)&0xf8)<<8)|(((g)&0xfc)<<3)|(((b)&0xf8)>>3))) +#define GXPackedRGBA4(r,g,b,a) \ + ((u16)((((r)&0xf0)<<8)|(((g)&0xf0)<<4)|(((b)&0xf0) )|(((a)&0xf0)>>4))) +#define GXPackedRGB5A3(r,g,b,a) \ + ((u16)((a)>=224 ? \ + ((((r)&0xf8)<<7)|(((g)&0xf8)<<2)|(((b)&0xf8)>>3)|(1<<15)): \ + ((((r)&0xf0)<<4)|(((g)&0xf0) )|(((b)&0xf0)>>4)|(((a)&0xe0)<<7)))) + +#ifdef __cplusplus +} +#endif + +#endif // __GXVERT_H__ + diff --git a/include/rvl/OSCache.h b/include/rvl/OSCache.h new file mode 100755 index 0000000..0957139 --- /dev/null +++ b/include/rvl/OSCache.h @@ -0,0 +1,61 @@ +/* + This header file defines the most common high level cache operations. + For finer grain control over the caches, use OSDC.h, OSIC.h, and OSLC.h + for data cache, instruction cache, and locked cache routines respectively. + */ + +#ifndef __OSCACHE_H__ +#define __OSCACHE_H__ + +/*#include +#include +#include +#include +#include */ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + L1 Data Cache Operations + *---------------------------------------------------------------------------*/ + +void DCInvalidateRange ( void* addr, u32 nBytes ); +void DCFlushRange ( void* addr, u32 nBytes ); +void DCStoreRange ( void* addr, u32 nBytes ); +void DCFlushRangeNoSync ( void* addr, u32 nBytes ); +void DCStoreRangeNoSync ( void* addr, u32 nBytes ); +void DCZeroRange ( void* addr, u32 nBytes ); +void DCTouchRange ( void* addr, u32 nBytes ); + +/*---------------------------------------------------------------------------* + L1 Instruction Cache Operations + *---------------------------------------------------------------------------*/ + +void ICInvalidateRange ( void* addr, u32 nBytes ); + +/*---------------------------------------------------------------------------* + Locked Cache Operations + *---------------------------------------------------------------------------*/ +// 0xEnnn nnnn addresses will be mapped in by LCEnable (DBAT3 will be used) +#define LC_BASE_PREFIX 0xE000 +#define LC_BASE (LC_BASE_PREFIX << 16) + +void LCEnable ( void ); +void LCDisable ( void ); +void LCLoadBlocks ( void* destTag, void* srcAddr, u32 numBlocks ); +void LCStoreBlocks ( void* destAddr, void* srcTag, u32 numBlocks ); +u32 LCLoadData ( void* destAddr, void* srcAddr, u32 nBytes ); +u32 LCStoreData ( void* destAddr, void* srcAddr, u32 nBytes ); +u32 LCQueueLength ( void ); +void LCQueueWait ( u32 len ); +void LCFlushQueue ( void ); + +#define LCGetBase() ((void*)LC_BASE) + +#ifdef __cplusplus +} +#endif + +#endif // __OSCACHE_H__ diff --git a/include/rvl/PPCWGPipe.h b/include/rvl/PPCWGPipe.h new file mode 100755 index 0000000..1354a93 --- /dev/null +++ b/include/rvl/PPCWGPipe.h @@ -0,0 +1,37 @@ +#ifndef __PPCWGPIPE_H__ +#define __PPCWGPIPE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + PPC Write Gather Pipe + + Write Gather Pipe is defined as: + PPCWGPipe wgpipe : ; + + Then, used as: + wgpipe.u8 = 0xff; + wgpipe.s16 = -5; + wgpipe.f32 = 0.10f; + *---------------------------------------------------------------------------*/ +typedef union uPPCWGPipe +{ + u8 _u8; + u16 _u16; + u32 _u32; + u64 _u64; + s8 _s8; + s16 _s16; + s32 _s32; + s64 _s64; + f32 _f32; + f64 _f64; +} PPCWGPipe; + +#ifdef __cplusplus +} +#endif + +#endif //__PPCWGPIPE_H__ diff --git a/include/rvl/arc.h b/include/rvl/arc.h new file mode 100755 index 0000000..94d5d5b --- /dev/null +++ b/include/rvl/arc.h @@ -0,0 +1,115 @@ +#ifndef __ARC_H__ +#define __ARC_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + unsigned int magic; + int fstStart; + int fstSize; + int fileStart; + int reserve[4]; + +} ARCHeader; + +#define DARCH_MAGIC 0x55aa382d + +typedef struct +{ + void* archiveStartAddr; + void* FSTStart; + void* fileStart; + u32 entryNum; + char* FSTStringStart; + u32 FSTLength; + u32 currDir; + +} ARCHandle; + +typedef struct +{ + ARCHandle* handle; + u32 startOffset; + u32 length; + +} ARCFileInfo; + +typedef struct +{ + ARCHandle* handle; + u32 entryNum; + u32 location; + u32 next; +} ARCDir; + +typedef struct +{ + ARCHandle* handle; + u32 entryNum; + BOOL isDir; + char* name; +} ARCDirEntry; + + +BOOL ARCInitHandle(void* arcStart, ARCHandle* handle); +BOOL ARCOpen(ARCHandle* handle, const char* fileName, ARCFileInfo* af); +BOOL ARCFastOpen(ARCHandle* handle, s32 entrynum, ARCFileInfo* af); +s32 ARCConvertPathToEntrynum(ARCHandle* handle, const char* pathPtr); +void* ARCGetStartAddrInMem(ARCFileInfo* af); +u32 ARCGetStartOffset(ARCFileInfo* af); +u32 ARCGetLength(ARCFileInfo* af); +BOOL ARCClose(ARCFileInfo* af); + +BOOL ARCChangeDir(ARCHandle* handle, const char* dirName); +BOOL ARCGetCurrentDir(ARCHandle* handle, char* path, u32 maxlen); + +BOOL ARCOpenDir(ARCHandle* handle, const char* dirName, ARCDir* dir); +BOOL ARCReadDir(ARCDir* dir, ARCDirEntry* dirent); +BOOL ARCCloseDir(ARCDir* dir); + +/*---------------------------------------------------------------------------* + Name: ARCTellDir + + Description: Returns the current location associated with the directory + + Arguments: dir Pre-opened ARCDir* structure + + Returns: current location + *---------------------------------------------------------------------------*/ +#define ARCTellDir(dir) ((dir)->location) + +/*---------------------------------------------------------------------------* + Name: ARCSeekDir + + Description: Sets the position of the next ARCReadDir on the directory + + Arguments: dir Pre-opened ARCDir* structure + loc location to set + + Returns: None + *---------------------------------------------------------------------------*/ +#define ARCSeekDir(dir, loc) ((dir)->location = loc) + +/*---------------------------------------------------------------------------* + Name: ARCRewindDir + + Description: Resets the position of the directory to the beginning + + Arguments: dir Pre-opened ARCDir* structure + + Returns: None + *---------------------------------------------------------------------------*/ +#define ARCRewindDir(dir) ((dir)->location = (dir)->entryNum + 1) + +#define ARCGetDirEntryName(dirent) ((dirent)->name) +#define ARCDirEntryIsDir(dirent) ((dirent)->isDir) + + +#ifdef __cplusplus +} +#endif + +#endif // __ARC_H__ diff --git a/include/rvl/mtx.h b/include/rvl/mtx.h new file mode 100755 index 0000000..3bb804e --- /dev/null +++ b/include/rvl/mtx.h @@ -0,0 +1,441 @@ +#ifndef __MTX_H__ +#define __MTX_H__ + + + + + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Default function binding configuration + *---------------------------------------------------------------------------*/ +// [Binding Rule] +// +// "MTX_USE_PS" -> When this flag is specified, it uses PS* (Paired-Single +// assembler code) functions for non-prefixed function calls. +// "MTX_USE_C " -> When this flag is specified, it uses C_* (C code) functions +// for non-prefixed function calls. +// +// If both are specified, it will be treated as MTX_USE_PS. +// If nothing is specified, NDEBUG build refers PS* functions and +// DEBUG build uses C_* functions. + +// For non-Gekko HW (e.g. emulator) +#ifndef GEKKO +#define MTX_USE_C +#undef MTX_USE_PS +#endif + +#if ( !defined(MTX_USE_PS) && !defined(MTX_USE_C) ) +#ifndef _DEBUG +#define MTX_USE_PS +#endif +#endif + +/*---------------------------------------------------------------------------* + Macro definitions + *---------------------------------------------------------------------------*/ + +// MtxPtr offset to access next Mtx of an array +#define MTX_PTR_OFFSET 3 + +// Mtx44Ptr offset to access next Mtx44 of an array +#define MTX44_PTR_OFFSET 4 + + +// matrix stack +typedef struct +{ + + u32 numMtx; + MtxPtr stackBase; + MtxPtr stackPtr; + +} MtxStack, *MtxStackPtr; + + +// degree <--> radian conversion macros +#define MTXDegToRad(a) ( (a) * 0.01745329252f ) +#define MTXRadToDeg(a) ( (a) * 57.29577951f ) + + +// Matrix-element-referencing macro. +// Insulates user from changes from row-major to column-major and vice-versa. +// Fully documents which index is row, which index is column. +// XXX this version will change once matrices are transposed. + +#define MTXRowCol(m,r,c) ((m)[(r)][(c)]) + + +/*---------------------------------------------------------------------------* + GENERAL MATRIX SECTION + *---------------------------------------------------------------------------*/ +// C version +void C_MTXIdentity ( Mtx m ); +void C_MTXCopy ( const Mtx src, Mtx dst ); +void C_MTXConcat ( const Mtx a, const Mtx b, Mtx ab ); +void C_MTXConcatArray ( const Mtx a, const Mtx* srcBase, Mtx* dstBase, u32 count ); +void C_MTXTranspose ( const Mtx src, Mtx xPose ); +u32 C_MTXInverse ( const Mtx src, Mtx inv ); +u32 C_MTXInvXpose ( const Mtx src, Mtx invX ); + +// PS assembler version +#ifdef GEKKO +void PSMTXIdentity ( Mtx m ); +void PSMTXCopy ( const Mtx src, Mtx dst ); +void PSMTXConcat ( const Mtx a, const Mtx b, Mtx ab ); +void PSMTXConcatArray ( const Mtx a, const Mtx* srcBase, Mtx* dstBase, u32 count ); +void PSMTXTranspose ( const Mtx src, Mtx xPose ); +u32 PSMTXInverse ( const Mtx src, Mtx inv ); +u32 PSMTXInvXpose ( const Mtx src, Mtx invX ); +#endif + +// Bindings +#ifdef MTX_USE_PS +#define MTXIdentity PSMTXIdentity +#define MTXCopy PSMTXCopy +#define MTXConcat PSMTXConcat +#define MTXConcatArray PSMTXConcatArray +#define MTXTranspose PSMTXTranspose +#define MTXInverse PSMTXInverse +#define MTXInvXpose PSMTXInvXpose +#else // MTX_USE_C +#define MTXIdentity C_MTXIdentity +#define MTXCopy C_MTXCopy +#define MTXConcat C_MTXConcat +#define MTXConcatArray C_MTXConcatArray +#define MTXTranspose C_MTXTranspose +#define MTXInverse C_MTXInverse +#define MTXInvXpose C_MTXInvXpose +#endif + + +/*---------------------------------------------------------------------------* + MATRIX-VECTOR SECTION + *---------------------------------------------------------------------------*/ +// C version +void C_MTXMultVec ( const Mtx m, const Vec *src, Vec *dst ); +void C_MTXMultVecArray ( const Mtx m, const Vec *srcBase, Vec *dstBase, u32 count ); +void C_MTXMultVecSR ( const Mtx m, const Vec *src, Vec *dst ); +void C_MTXMultVecArraySR ( const Mtx m, const Vec *srcBase, Vec *dstBase, u32 count ); + +// PS assembler version +#ifdef GEKKO +void PSMTXMultVec ( const Mtx m, const Vec *src, Vec *dst ); +void PSMTXMultVecArray ( const Mtx m, const Vec *srcBase, Vec *dstBase, u32 count ); +void PSMTXMultVecSR ( const Mtx m, const Vec *src, Vec *dst ); +void PSMTXMultVecArraySR ( const Mtx m, const Vec *srcBase, Vec *dstBase, u32 count ); +#endif + +// Bindings +#ifdef MTX_USE_PS +#define MTXMultVec PSMTXMultVec +#define MTXMultVecArray PSMTXMultVecArray +#define MTXMultVecSR PSMTXMultVecSR +#define MTXMultVecArraySR PSMTXMultVecArraySR +#else // MTX_USE_C +#define MTXMultVec C_MTXMultVec +#define MTXMultVecArray C_MTXMultVecArray +#define MTXMultVecSR C_MTXMultVecSR +#define MTXMultVecArraySR C_MTXMultVecArraySR +#endif + + +/*---------------------------------------------------------------------------* + MODEL MATRIX SECTION + *---------------------------------------------------------------------------*/ +// C version +void C_MTXQuat ( Mtx m, const Quaternion *q ); +void C_MTXReflect ( Mtx m, const Vec *p, const Vec *n ); + +void C_MTXTrans ( Mtx m, f32 xT, f32 yT, f32 zT ); +void C_MTXTransApply ( const Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT ); +void C_MTXScale ( Mtx m, f32 xS, f32 yS, f32 zS ); +void C_MTXScaleApply ( const Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS ); + +void C_MTXRotRad ( Mtx m, char axis, f32 rad ); +void C_MTXRotTrig ( Mtx m, char axis, f32 sinA, f32 cosA ); +void C_MTXRotAxisRad ( Mtx m, const Vec *axis, f32 rad ); + +// PS assembler version +#ifdef GEKKO +void PSMTXQuat ( Mtx m, const Quaternion *q ); +void PSMTXReflect ( Mtx m, const Vec *p, const Vec *n ); + +void PSMTXTrans ( Mtx m, f32 xT, f32 yT, f32 zT ); +void PSMTXTransApply ( const Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT ); +void PSMTXScale ( Mtx m, f32 xS, f32 yS, f32 zS ); +void PSMTXScaleApply ( const Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS ); + +void PSMTXRotRad ( Mtx m, char axis, f32 rad ); +void PSMTXRotTrig ( Mtx m, char axis, f32 sinA, f32 cosA ); +void PSMTXRotAxisRad ( Mtx m, const Vec *axis, f32 rad ); +#endif + +// Bindings +#ifdef MTX_USE_PS +#define MTXQuat PSMTXQuat +#define MTXReflect PSMTXReflect +#define MTXTrans PSMTXTrans +#define MTXTransApply PSMTXTransApply +#define MTXScale PSMTXScale +#define MTXScaleApply PSMTXScaleApply +#define MTXRotRad PSMTXRotRad +#define MTXRotTrig PSMTXRotTrig +#define MTXRotAxisRad PSMTXRotAxisRad + +#define MTXRotDeg( m, axis, deg ) \ + PSMTXRotRad( m, axis, MTXDegToRad(deg) ) +#define MTXRotAxisDeg( m, axis, deg ) \ + PSMTXRotAxisRad( m, axis, MTXDegToRad(deg) ) + +#else // MTX_USE_C +#define MTXQuat C_MTXQuat +#define MTXReflect C_MTXReflect +#define MTXTrans C_MTXTrans +#define MTXTransApply C_MTXTransApply +#define MTXScale C_MTXScale +#define MTXScaleApply C_MTXScaleApply +#define MTXRotRad C_MTXRotRad +#define MTXRotTrig C_MTXRotTrig +#define MTXRotAxisRad C_MTXRotAxisRad + +#define MTXRotDeg( m, axis, deg ) \ + C_MTXRotRad( m, axis, MTXDegToRad(deg) ) +#define MTXRotAxisDeg( m, axis, deg ) \ + C_MTXRotAxisRad( m, axis, MTXDegToRad(deg) ) + +#endif + + +// Obsolete. Don't use this if possible. +#define MTXRotAxis MTXRotAxisDeg + + +/*---------------------------------------------------------------------------* + VIEW MATRIX SECTION + *---------------------------------------------------------------------------*/ +// C version only so far +void C_MTXLookAt ( Mtx m, + const Point3d *camPos, + const Vec *camUp, + const Point3d *target ); + +// Bindings +#define MTXLookAt C_MTXLookAt + + +/*---------------------------------------------------------------------------* + PROJECTION MATRIX SECTION + *---------------------------------------------------------------------------*/ +// C version only so far +void C_MTXFrustum ( Mtx44 m, f32 t, f32 b, f32 l, f32 r, f32 n, f32 f ); +void C_MTXPerspective ( Mtx44 m, f32 fovY, f32 aspect, f32 n, f32 f ); +void C_MTXOrtho ( Mtx44 m, f32 t, f32 b, f32 l, f32 r, f32 n, f32 f ); + +// Bindings +#define MTXFrustum C_MTXFrustum +#define MTXPerspective C_MTXPerspective +#define MTXOrtho C_MTXOrtho + + +/*---------------------------------------------------------------------------* + TEXTURE PROJECTION MATRIX SECTION + *---------------------------------------------------------------------------*/ +// C version only so far +void C_MTXLightFrustum ( Mtx m, f32 t, f32 b, f32 l, f32 r, f32 n, + f32 scaleS, f32 scaleT, f32 transS, + f32 transT ); + +void C_MTXLightPerspective ( Mtx m, f32 fovY, f32 aspect, f32 scaleS, + f32 scaleT, f32 transS, f32 transT ); + +void C_MTXLightOrtho ( Mtx m, f32 t, f32 b, f32 l, f32 r, f32 scaleS, + f32 scaleT, f32 transS, f32 transT ); + +// Bindings +#define MTXLightFrustum C_MTXLightFrustum +#define MTXLightPerspective C_MTXLightPerspective +#define MTXLightOrtho C_MTXLightOrtho + + +/*---------------------------------------------------------------------------* + VECTOR SECTION + *---------------------------------------------------------------------------*/ +// C version +void C_VECAdd ( const Vec *a, const Vec *b, Vec *ab ); +void C_VECSubtract ( const Vec *a, const Vec *b, Vec *a_b ); +void C_VECScale ( const Vec *src, Vec *dst, f32 scale ); +void C_VECNormalize ( const Vec *src, Vec *unit ); +f32 C_VECSquareMag ( const Vec *v ); +f32 C_VECMag ( const Vec *v ); +f32 C_VECDotProduct ( const Vec *a, const Vec *b ); +void C_VECCrossProduct ( const Vec *a, const Vec *b, Vec *axb ); +f32 C_VECSquareDistance ( const Vec *a, const Vec *b ); +f32 C_VECDistance ( const Vec *a, const Vec *b ); +void C_VECReflect ( const Vec *src, const Vec *normal, Vec *dst ); +void C_VECHalfAngle ( const Vec *a, const Vec *b, Vec *half ); + +// PS assembler version +#ifdef GEKKO +void PSVECAdd ( const Vec *a, const Vec *b, Vec *ab ); +void PSVECSubtract ( const Vec *a, const Vec *b, Vec *a_b ); +void PSVECScale ( const Vec *src, Vec *dst, f32 scale ); +void PSVECNormalize ( const Vec *src, Vec *unit ); +f32 PSVECSquareMag ( const Vec *v ); +f32 PSVECMag ( const Vec *v ); +f32 PSVECDotProduct ( const Vec *a, const Vec *b ); +void PSVECCrossProduct ( const Vec *a, const Vec *b, Vec *axb ); +f32 PSVECSquareDistance ( const Vec *a, const Vec *b ); +f32 PSVECDistance ( const Vec *a, const Vec *b ); +#endif + +// Bindings +#ifdef MTX_USE_PS +#define VECAdd PSVECAdd +#define VECSubtract PSVECSubtract +#define VECScale PSVECScale +#define VECNormalize PSVECNormalize +#define VECSquareMag PSVECSquareMag +#define VECMag PSVECMag +#define VECDotProduct PSVECDotProduct +#define VECCrossProduct PSVECCrossProduct +#define VECSquareDistance PSVECSquareDistance +#define VECDistance PSVECDistance +#else // MTX_USE_C +#define VECAdd C_VECAdd +#define VECSubtract C_VECSubtract +#define VECScale C_VECScale +#define VECNormalize C_VECNormalize +#define VECSquareMag C_VECSquareMag +#define VECMag C_VECMag +#define VECDotProduct C_VECDotProduct +#define VECCrossProduct C_VECCrossProduct +#define VECSquareDistance C_VECSquareDistance +#define VECDistance C_VECDistance +#endif + +#define VECReflect C_VECReflect +#define VECHalfAngle C_VECHalfAngle + + +/*---------------------------------------------------------------------------* + QUATERNION SECTION + *---------------------------------------------------------------------------*/ +// C version +void C_QUATAdd ( const Quaternion *p, const Quaternion *q, Quaternion *r ); +void C_QUATSubtract ( const Quaternion *p, const Quaternion *q, Quaternion *r ); +void C_QUATMultiply ( const Quaternion *p, const Quaternion *q, Quaternion *pq ); +void C_QUATDivide ( const Quaternion *p, const Quaternion *q, Quaternion *r ); +void C_QUATScale ( const Quaternion *q, Quaternion *r, f32 scale ); +f32 C_QUATDotProduct ( const Quaternion *p, const Quaternion *q ); +void C_QUATNormalize ( const Quaternion *src, Quaternion *unit ); +void C_QUATInverse ( const Quaternion *src, Quaternion *inv ); +void C_QUATExp ( const Quaternion *q, Quaternion *r ); +void C_QUATLogN ( const Quaternion *q, Quaternion *r ); + +void C_QUATMakeClosest ( const Quaternion *q, const Quaternion *qto, Quaternion *r ); +void C_QUATRotAxisRad ( Quaternion *r, const Vec *axis, f32 rad ); +void C_QUATMtx ( Quaternion *r, const Mtx m ); + +void C_QUATLerp ( const Quaternion *p, const Quaternion *q, Quaternion *r, f32 t ); +void C_QUATSlerp ( const Quaternion *p, const Quaternion *q, Quaternion *r, f32 t ); +void C_QUATSquad ( const Quaternion *p, const Quaternion *a, const Quaternion *b, + const Quaternion *q, Quaternion *r, f32 t ); +void C_QUATCompA ( const Quaternion *qprev, const Quaternion *q, + const Quaternion *qnext, Quaternion *a ); + + +// PS assembler version +#ifdef GEKKO +void PSQUATAdd ( const Quaternion *p, const Quaternion *q, Quaternion *r ); +void PSQUATSubtract ( const Quaternion *p, const Quaternion *q, Quaternion *r ); +void PSQUATMultiply ( const Quaternion *p, const Quaternion *q, Quaternion *pq ); +void PSQUATDivide ( const Quaternion *p, const Quaternion *q, Quaternion *r ); +void PSQUATScale ( const Quaternion *q, Quaternion *r, f32 scale ); +f32 PSQUATDotProduct ( const Quaternion *p, const Quaternion *q ); +void PSQUATNormalize ( const Quaternion *src, Quaternion *unit ); +void PSQUATInverse ( const Quaternion *src, Quaternion *inv ); +#endif + + +// Bindings +#ifdef MTX_USE_PS +#define QUATAdd PSQUATAdd +#define QUATSubtract PSQUATSubtract +#define QUATMultiply PSQUATMultiply +#define QUATDivide PSQUATDivide +#define QUATScale PSQUATScale +#define QUATDotProduct PSQUATDotProduct +#define QUATNormalize PSQUATNormalize +#define QUATInverse PSQUATInverse +#else // MTX_USE_C +#define QUATAdd C_QUATAdd +#define QUATSubtract C_QUATSubtract +#define QUATMultiply C_QUATMultiply +#define QUATDivide C_QUATDivide +#define QUATScale C_QUATScale +#define QUATDotProduct C_QUATDotProduct +#define QUATNormalize C_QUATNormalize +#define QUATInverse C_QUATInverse +#endif + +#define QUATExp C_QUATExp +#define QUATLogN C_QUATLogN +#define QUATMakeClosest C_QUATMakeClosest +#define QUATRotAxisRad C_QUATRotAxisRad +#define QUATMtx C_QUATMtx +#define QUATLerp C_QUATLerp +#define QUATSlerp C_QUATSlerp +#define QUATSquad C_QUATSquad +#define QUATCompA C_QUATCompA + + +/*---------------------------------------------------------------------------* + SPECIAL PURPOSE MATRIX SECTION + *---------------------------------------------------------------------------*/ +// Only PS assembler versions are available +#ifdef GEKKO +void PSMTXReorder ( const Mtx src, ROMtx dest ); +void PSMTXROMultVecArray ( const ROMtx m, const Vec *srcBase, Vec *dstBase, u32 count ); +void PSMTXROSkin2VecArray ( const ROMtx m0, const ROMtx m1, const f32 *wtBase, const Vec *srcBase, Vec *dstBase, u32 count); +void PSMTXMultS16VecArray ( const Mtx m, const S16Vec *srcBase, Vec *dstBase, u32 count ); +void PSMTXROMultS16VecArray( const ROMtx m, const S16Vec *srcBase, Vec *dstBase, u32 count ); +#endif + + +/*---------------------------------------------------------------------------* + MATRIX STACK SECTION + *---------------------------------------------------------------------------*/ +void MTXInitStack ( MtxStack *sPtr, u32 numMtx ); +MtxPtr MTXPush ( MtxStack *sPtr, const Mtx m ); +MtxPtr MTXPushFwd ( MtxStack *sPtr, const Mtx m ); +MtxPtr MTXPushInv ( MtxStack *sPtr, const Mtx m ); +MtxPtr MTXPushInvXpose ( MtxStack *sPtr, const Mtx m ); +MtxPtr MTXPop ( MtxStack *sPtr ); +MtxPtr MTXGetStackPtr ( const MtxStack *sPtr ); + + +// macro to create a matrix stack. +// the macro exposes the use of OSAlloc() for +// ease of replacement if desired. +#define MTXAllocStack( sPtr, numMtx ) ( ((MtxStackPtr)(sPtr))->stackBase = (MtxPtr)OSAlloc( ( (numMtx) * sizeof(Mtx) ) ) ) + +// macro to free a matrix stack +#define MTXFreeStack( sPtr ) ( OSFree( (void*)( ((MtxStackPtr)(sPtr))->stackBase ) ) ) + + +/*---------------------------------------------------------------------------*/ + + +#ifdef __cplusplus +} +#endif + +#endif // __MTX_H__ + +/*===========================================================================*/ + diff --git a/include/rvl/tpl.h b/include/rvl/tpl.h new file mode 100755 index 0000000..9e68fac --- /dev/null +++ b/include/rvl/tpl.h @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------* + This TPL library provides a simple interface for TPL files, which used + to be the texture data format for the character pipeline in the Nintendo GameCube + software development kit. + This file also contains wrapper definitions for the conventional TEX API in + the new library. + *---------------------------------------------------------------------------*/ + +#ifndef TPL_H +#define TPL_H + +/*---------------------------------------------------------------------------*/ +#include "rvl/GXTexture.h" + +// Macros for conventional character pipeline functions +#ifdef COMPATIBLE_OLD_TEXPALETTE + +#define TEXPalettePtr TPLPalettePtr +#define TEXDescriptorPtr TPLDescriptorPtr +#define TEXGetPalette TPLGetPalette +#define TEXReleasePalette TPLReleasePalette +#define TEXGet TPLGet + +#define TEXGetGXTexObjFromPalette TPLGetGXTexObjFromPalette +#define TEXGetGXTexObjFromPaletteCI TPLGetGXTexObjFromPaletteCI + +#endif + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------* + Structure definitions + *---------------------------------------------------------------------------*/ +typedef struct +{ + u16 numEntries; + u8 unpacked; + u8 pad8; + + GXTlutFmt format; + Ptr data; + +} TPLClutHeader, *TPLClutHeaderPtr; + +/*---------------------------------------------------------------------------*/ +typedef struct +{ + u16 height; + u16 width; + + u32 format; + Ptr data; + + GXTexWrapMode wrapS; + GXTexWrapMode wrapT; + + GXTexFilter minFilter; + GXTexFilter magFilter; + + float LODBias; + + u8 edgeLODEnable; + u8 minLOD; + u8 maxLOD; + u8 unpacked; + +} TPLHeader, *TPLHeaderPtr; + +/*---------------------------------------------------------------------------*/ +typedef struct +{ + TPLHeaderPtr textureHeader; + TPLClutHeaderPtr CLUTHeader; + +} TPLDescriptor, *TPLDescriptorPtr; + +/*---------------------------------------------------------------------------*/ +typedef struct +{ + u32 versionNumber; + + u32 numDescriptors; + TPLDescriptorPtr descriptorArray; + +} TPLPalette, *TPLPalettePtr; + +/*---------------------------------------------------------------------------* + Function prototypes + *---------------------------------------------------------------------------*/ +void TPLBind ( TPLPalettePtr pal ); +TPLDescriptorPtr TPLGet ( TPLPalettePtr pal, u32 id ); + +void TPLGetGXTexObjFromPalette ( TPLPalettePtr pal, GXTexObj *to, u32 id ); +void TPLGetGXTexObjFromPaletteCI ( TPLPalettePtr pal, GXTexObj *to, + GXTlutObj *tlo, GXTlut tluts, u32 id ); + + + +/*---------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/rvl/vifuncs.h b/include/rvl/vifuncs.h new file mode 100755 index 0000000..fab95b4 --- /dev/null +++ b/include/rvl/vifuncs.h @@ -0,0 +1,48 @@ +#ifndef __VIFUNCS_H +#define __VIFUNCS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "rvl/vitypes.h" +#include "rvl/GXStruct.h" // for GXRenderModeObj structure + + +#define VIPadFrameBufferWidth(width) ((u16)(((u16)(width) + 15) & ~15)) + +void VIInit ( void ); +void VIFlush ( void ); +void VIWaitForRetrace ( void ); + +void VIConfigure ( const GXRenderModeObj* rm ); +void VIConfigurePan ( u16 PanPosX, u16 PanPosY, + u16 PanSizeX, u16 PanSizeY ); +void VISetNextFrameBuffer ( void *fb ); + +void *VIGetNextFrameBuffer ( void ); +void *VIGetCurrentFrameBuffer( void ); + +VIRetraceCallback VISetPreRetraceCallback (VIRetraceCallback callback); +VIRetraceCallback VISetPostRetraceCallback (VIRetraceCallback callback); + +void VISetBlack ( bool black ); +u32 VIGetRetraceCount ( void ); +u32 VIGetNextField ( void ); +u32 VIGetCurrentLine ( void ); +u32 VIGetTvFormat ( void ); +u32 VIGetScanMode ( void ); + +u32 VIGetDTVStatus ( void ); + +// For test of switch to Progressive from Interlace +void VISetVSyncTimingTest ( void ); +u32 VIGetVSyncTimingTest ( void ); + + +/********************************/ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/rvl/vitypes.h b/include/rvl/vitypes.h new file mode 100755 index 0000000..506a4f4 --- /dev/null +++ b/include/rvl/vitypes.h @@ -0,0 +1,79 @@ +#ifndef __VITYPES_H +#define __VITYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define VI_DISPLAY_PIX_SZ 2 + +#define VI_INTERLACE 0 +#define VI_NON_INTERLACE 1 +#define VI_PROGRESSIVE 2 +// 3 is reserved + +#define VI_NTSC 0 +#define VI_PAL 1 +#define VI_MPAL 2 +#define VI_DEBUG 3 +#define VI_DEBUG_PAL 4 +#define VI_EURGB60 5 +// 6,7,8,9 are reserved + +#define VI_TVMODE(FMT, INT) ( ((FMT) << 2) + (INT) ) + +typedef enum +{ + VI_TVMODE_NTSC_INT = VI_TVMODE(VI_NTSC, VI_INTERLACE), + VI_TVMODE_NTSC_DS = VI_TVMODE(VI_NTSC, VI_NON_INTERLACE), + VI_TVMODE_NTSC_PROG = VI_TVMODE(VI_NTSC, VI_PROGRESSIVE), + + VI_TVMODE_PAL_INT = VI_TVMODE(VI_PAL, VI_INTERLACE), + VI_TVMODE_PAL_DS = VI_TVMODE(VI_PAL, VI_NON_INTERLACE), + + + VI_TVMODE_EURGB60_INT = VI_TVMODE(VI_EURGB60, VI_INTERLACE), + VI_TVMODE_EURGB60_DS = VI_TVMODE(VI_EURGB60, VI_NON_INTERLACE), + VI_TVMODE_EURGB60_PROG = VI_TVMODE(VI_EURGB60, VI_PROGRESSIVE), + + VI_TVMODE_MPAL_INT = VI_TVMODE(VI_MPAL, VI_INTERLACE), + VI_TVMODE_MPAL_DS = VI_TVMODE(VI_MPAL, VI_NON_INTERLACE), + VI_TVMODE_MPAL_PROG = VI_TVMODE(VI_MPAL, VI_PROGRESSIVE), + + VI_TVMODE_DEBUG_INT = VI_TVMODE(VI_DEBUG, VI_INTERLACE), + + VI_TVMODE_DEBUG_PAL_INT = VI_TVMODE(VI_DEBUG_PAL, VI_INTERLACE), + VI_TVMODE_DEBUG_PAL_DS = VI_TVMODE(VI_DEBUG_PAL, VI_NON_INTERLACE) +} VITVMode; + +typedef enum +{ + VI_XFBMODE_SF = 0, + VI_XFBMODE_DF +} VIXFBMode; + + +#define VI_FIELD_ABOVE 1 +#define VI_FIELD_BELOW 0 + +// Maximum screen space +#define VI_MAX_WIDTH_NTSC 720 +#define VI_MAX_HEIGHT_NTSC 480 + +#define VI_MAX_WIDTH_PAL 720 +#define VI_MAX_HEIGHT_PAL 574 + +#define VI_MAX_WIDTH_MPAL 720 +#define VI_MAX_HEIGHT_MPAL 480 + +#define VI_MAX_WIDTH_EURGB60 VI_MAX_WIDTH_NTSC +#define VI_MAX_HEIGHT_EURGB60 VI_MAX_HEIGHT_NTSC + + +typedef void (*VIRetraceCallback)(u32 retraceCount); + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.2.3