#define _STRICT_UNION_
#define _CLX_
#define _CLX2_

#include <shinobi.h>
#include <kamui2.h>
#include <sg_sycbl.h>

Int UserMain(void);
Int UserInit(void);
Int Kamui_Init(void);
void NextFrame(void);
void ReadMaple(void);

void main(void)
{
    SYE_CBL_CABLE cable;

#ifdef __GNUC__
	shinobi_workaround();
#endif
	/* Initialize Video Mode */
    cable = syCblCheckCable();
    if (cable == SYE_CBL_CABLE_VGA) {
		sbInitSystem((int)KM_DSPMODE_VGA, (int)KM_DSPBPP_RGB565, 1);
    } else {
		sbInitSystem((int)KM_DSPMODE_NTSCNI640x480, (int)KM_DSPBPP_RGB565, 1);
    }

	UserInit();

	/* Render Loop */
	while(UserMain())
	{
		pdExecPeripheralServer();
	}
	sbExitSystem();
}

Int UserInit(void)
{
	Kamui_Init();
}

Int UserMain(void)
{
	ReadMaple();
	NextFrame();
	return 1;
}