/*---------------------------------------------------------------------------*
  Project:  NitroSystem - build - demos - g2d - demolib - g2d_demolib
  File:     system.h

  Copyright 2004,2005 Nintendo.  All rights reserved.

  These coded instructions, statements, and computer programs contain
  proprietary information of Nintendo of America Inc. and/or Nintendo
  Company Ltd., and are protected by Federal copyright law.  They may
  not be disclosed to third parties or copied or duplicated in any form,
  in whole or in part, without the prior written consent of Nintendo.

  $Log: system.h,v $
  Revision 1.8  06/29/2005 04:43:58  hatamoto_minoru
  Fixed typos: NitroSyetem -> NitroSystem

  Revision 1.7  01/25/2005 01:56:02  kitani_toshikazu
  Corrected comment

  Revision 1.6  01/24/2005 09:41:42  kitani_toshikazu
  Changed the multicell initialization function to use the new API

  Revision 1.5  11/04/2004 01:46:33  hatamoto_minoru
  Revised comments

  Revision 1.4  06/10/2004 08:42:55  hatamoto_minoru
  Added G2DDemo_Free.

  Revision 1.3  06/08/2004 07:36:40  hatamoto_minoru
  Changed so that memory management performed by the heap manager

  Revision 1.2  06/03/2004 08:52:23  hatamoto_minoru
  Adjusted source

  Revision 1.1  06/03/2004 04:57:42  nishida
  Registered the initial version.

  $NoKeywords: $
 *---------------------------------------------------------------------------*/
#ifndef G2D_DEMO_SYSTEM_H_
#define G2D_DEMO_SYSTEM_H_

#ifdef __cplusplus
extern "C" {
#endif


/*---------------------------------------------------------------------------*
    Initialization related.
 *---------------------------------------------------------------------------*/

void G2DDemo_CommonInit(void);
void G2DDemo_CameraSetup(void);
void G2DDemo_MaterialSetup(void);


/*---------------------------------------------------------------------------*
    Gamepad-related
 *---------------------------------------------------------------------------*/

// gamepad structure
typedef struct
{
    u16     trigger;
    u16     release;
    u16     button;
}
G2DDemoGamePad;

// gamepad work
extern G2DDemoGamePad   gGamePad;

#define G2DDEMO_IS_TRIGGER(key)     (gGamePad.trigger & key)
#define G2DDEMO_IS_RELEASE(key)     (gGamePad.release & key)
#define G2DDEMO_IS_PRESS(key)       (gGamePad.button  & key)

void G2DDemo_ReadGamePad(void);


/*---------------------------------------------------------------------------*
    Other cases:
 *---------------------------------------------------------------------------*/

extern NNSFndHeapHandle       gHeapHandle;      // The heap handle

NNSG2dCellAnimation*          G2DDemo_GetNewCellAnimation( u16 num );
NNSG2dNode*                   G2DDemo_GetNewNode( u16 num );

/*
NNSG2dMultiCellAnimation*     G2DDemo_GetNewMultiCellAnimation
(
    u16                                numNode,
    const NNSG2dCellAnimBankData*      pAnimBank,
    const NNSG2dCellDataBank*          pCellDataBank ,
    const NNSG2dMultiCellDataBank*     pMultiCellDataBank
);
*/

NNSG2dMultiCellAnimation*     G2DDemo_GetNewMultiCellAnimation
(
    const NNSG2dCellAnimBankData*      pAnimBank,
    const NNSG2dCellDataBank*          pCellDataBank ,
    const NNSG2dMultiCellDataBank*     pMultiCellDataBank,
    NNSG2dMCType                       mcType
);

static inline void G2DDemo_MTX_Rot22( MtxFx22* m, fx32 sinVal, fx32 cosVal )
{
    SDK_NULL_ASSERT( m );
    m->_00 = cosVal;
    m->_01 = sinVal;
    m->_10 = -sinVal;
    m->_11 = cosVal;
}

inline void* G2DDemo_Alloc(u32 size)
{
	SDK_ASSERT( size > 0 );
    return NNS_FndAllocFromExpHeap(gHeapHandle, size);
}

inline void G2DDemo_Free(void* memBlock)
{
	SDK_ASSERT( NNS_FndFindContainHeap(memBlock) == gHeapHandle );
    NNS_FndFreeToExpHeap(gHeapHandle, memBlock);
}

extern void VBlankIntr( void );


#ifdef __cplusplus
}/* extern "C" */
#endif

// G2D_DEMO_SYSTEM_H_
#endif

