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