/*---------------------------------------------------------------------------*
  Project:  NitroSDK - MB - demos - multiboot
  File:     common.h

  Copyright 2003,2004 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: common.h,v $
  Revision 1.9  2004/10/05 06:47:54  sato_masaki
  Added setup menu. Made several other small small revisions.

  Revision 1.8  2004/10/04 13:40:25  terui
  Unified game group ID with u32 type.

  Revision 1.7  2004/09/30 08:28:35  yosizaki
  add SDK_MAKEGGID_SYSTEM macro.

  Revision 1.6  2004/09/30 03:05:17  sato_masaki
  - Changed so that name of parent device is obtained from NVRAM.
  - Changed so that you cycle through channels when initializing.

  Revision 1.5  2004/09/10 03:02:47  sato_masaki
  Changed comments about channel

  Revision 1.4  2004/09/10 02:29:51  miya
  Changed output channel

  Revision 1.3  2004/09/08 00:23:27  sato_masaki
  Changed register number of MBGameRegistry to 2

  Revision 1.2  2004/08/25 04:28:20  sato_masaki
  Mounting MB_CommStartSending function

  Revision 1.1  2004/08/10 07:32:03  yosizaki
  (none)

  $NoKeywords: $
 *---------------------------------------------------------------------------*/
#if !defined(NITRO_MB_DEMO_MULTIBOOT_DATA_H_)
#define NITRO_MB_DEMO_MULTIBOOT_DATA_H_


#include <nitro.h>
#include <nitro/mb.h>


/*
 * Definitions common to entire multiboot demo
 */


/******************************************************************************/
/* constant */

/*
 * Game group ID.
 *
 * Because specification of GGID has been enabled for individual files
 * in the MBGameRegistry structure, specification with MB_Init()
 * may become meaningless in the future.
 */
#define SDK_MAKEGGID_SYSTEM(num)    (0x003FFF00 | (num))
#define MY_GGID         SDK_MAKEGGID_SYSTEM(0x20)

/*
 * Channel that parent uses for distribution
 *
 * The multiboot child device runs through all available channels,
 * so any of the values permitted by the WM
 * library (currently 1, 7, and 13) can be used.
 *
 * This is made variable when avoiding communication congestion
 * for the user application.
 * The timing of the channel changes is determined by the application.
 * However, for example, an opportunity could be provided to press Restart
 * in response to a bad response.
 */
#define PARENT_CHANNEL  13

/* Maximum number of items displayed in child device list */
#define DISP_LIST_NUM   (15)

/* DMA number assigned to MB library */
#define MB_DMA_NO       2

/* Total number of games registered in this demo */
#define GAME_PROG_MAX   2

/* Information on the multiboot game programs provided in this demo */
extern const MBGameRegistry mbGameList[GAME_PROG_MAX];

/* Values for fame sequence status in this demo */
enum
{
	STATE_NONE,
	STATE_MENU,
	STATE_MB_PARENTINIT,
	STATE_MB_PARENT
} ;


/******************************************************************************/
/* variable */

/* Work area allocated to MB library*/
extern u32  cwork[ MB_SYSTEM_BUF_SIZE / sizeof(u32) ];

/* Game sequence status for this demo  */
extern u8 prog_state;


/******************************************************************************/
/* function */

/* Key trigger detection */
u16  ReadKeySetTrigger(u16 keyset);

/* rotation of val value in min - max range by offset amount */
BOOL RotateU8(u8 *val, u8 min, u8 max, s8 offset);

/* Initialize parent device */
void ParentInit(void);

/* Parent device main procedure for each frame */
void ParentMain(void);

/* initialize file buffer pointer */
void InitFileBuffer(void);

/* set parent MP send size */
void SetParentSendSize( u16 p_size );

/* get parent MP send size */
u16 GetParentSendSize( void );

/* set child connection maximum */
void SetMaxEntry( u8 num );

/* get child connection maximum */
u8 GetMaxEntry( void );

/* auto operation setting of parent */
void SetAutoOperation( u8 fAccept, u8 fSend, u8 fBoot );

#endif  /* !defined(NITRO_MB_DEMO_MULTIBOOT_DATA_H_) */
