1 /*---------------------------------------------------------------------------* 2 Project: Dolphin 3 File: G2D.h (Dolphin 2D API by Paul Donnelly, Nov. 1999) 4 5 Copyright 1998, 1999 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Log: G2D.h,v $ 14 Revision 1.1 2005/11/30 06:54:02 yasuh-to 15 Header file that wraps the Dolphin header file 16 17 Revision 1.1.1.1 2005/05/12 02:41:06 yasuh-to 18 Ported from dolphin source tree. 19 20 21 2 1999/12/12 10:09p Paul 22 23 1 1999/12/09 12:29p Paul 24 25 *---------------------------------------------------------------------------*/ 26 27 #ifndef G2DAPI_H 28 #define G2DAPI_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #include <demo.h> 35 36 typedef enum 37 { 38 G2D_CTG_TEXTURE = 0x0, // Tiles with this format use texture mapping. 39 // The texture format is specified within the GXTexObj 40 41 G2D_CTG_RGB_DIRECT = 0x1, // Tiles with this format have direct RGB8 color only 42 G2D_CTG_RGBA_INDEX8 = 0x2, // Tiles with this format have 8-bit indexed RGBA8 color only 43 G2D_CTG_EMPTY = 0x3 // Tiles with this format are not rendered at all 44 } 45 G2DMatCtg; 46 47 typedef struct 48 { 49 s32 nReserved; // Used by the API for sorting 50 G2DMatCtg nCategory; // Material Category 51 GXColor *color; // Material Color 52 GXTexObj *to; // Texture object 53 u8 *clut; // Color Look-Up Table 54 //s16 nWidth; // Width of texture map (32, 64, 128, 256, 512, 1024) 55 //s16 nHeight; // Height of texture map (32, 64, 128, 256, 512, 1024) 56 } 57 G2DMatDesc; 58 59 typedef struct 60 { 61 u8 nMaterial; // Tile type / texture-map selection 62 u8 nS; // S texture coordinate 63 u8 nT; // T texture coordinate 64 u8 nCI; // Color Index 65 u8 aUser[4]; // User data 66 } 67 G2DTileDesc; 68 69 typedef struct 70 { 71 void *map; // Map of tile indices 72 s8 nHS; // Horizontal Shift (Width of layer = 1<<nHS) 73 s8 nVS; // Vertical Shift (Height of layer = 1<<nVS) 74 s8 nBPI; // Bytes per Index (1,2) 75 s16 nTileWidth; // Width of tiles in pixels (should be >=16, power of 2) 76 s16 nTileHeight; // Height of tiles in pixels (should be >=16, power of 2) 77 s8 bWrap; // Whether layer wraps or not 78 u8 nNumMaterials; // Number of tile types 79 80 G2DTileDesc *tileDesc; // Tile Descriptor Table - specifies Type and S,T 81 // coordinates or Color RGB or Color Index for each tile 82 G2DMatDesc *matDesc; // Material Descriptor Table - specifies texture map or 83 // CLUT used by tiles of this type, plus material color 84 } 85 G2DLayer; 86 87 typedef struct 88 { 89 u16 nTlcS; // Top Left S coordinate within texture map (in pixels) 90 u16 nTlcT; // Top Left T coordinate within texture map (in pixels) 91 u16 nWidth; // Width of sprite (in pixels) 92 u16 nHeight; // Height of sprite (in pixels) 93 GXTexObj *to; // Source Texture Map (RGBA) 94 95 f32 rS0, rT0; // Normalized texture coordinates 96 f32 rS1, rT1; // No need to set these if you call G2DInitSprite 97 } 98 G2DSprite; 99 100 typedef struct 101 { 102 f32 rPosX; // Position vector X component (measured in tile coordinates) 103 f32 rPosY; // Position vector Y component (measured in tile coordinates) 104 f32 rOriX; // Normalized orientation vector X component 105 f32 rOriY; // Normalized orientation vector Y component 106 } 107 G2DPosOri; // 2D Position and Orientation 108 109 extern void G2DInitSprite( G2DSprite *sprite ); 110 extern void G2DDrawSprite( G2DSprite *sprite, G2DPosOri *posOri ); 111 extern void G2DDrawLayer( G2DLayer *layer, s8 *aSortBuffer ); 112 extern void G2DSetCamera( G2DPosOri *po ); 113 extern void G2DInitWorld( u32 nWorldX, u32 nWorldY ); 114 extern void G2DSetViewport( u16 nLeft, u16 nTop, u16 nWidth, u16 nHeight ); 115 116 #ifdef __cplusplus 117 } 118 #endif 119 120 /* Prevent re-inclusion */ 121 #endif 122