#define _STRICT_UNION_
#define _CLX_
#define _CLX2_

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

#define	RMIN	  0.0f		/* minimum number of random-number */
#define	RMAX	200.0f		/* maximum number of random-number */

extern int		padflag, count;
extern float	XAng1, YAng1, ZAng1;

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

void main(void)
{
    SYE_CBL_CABLE cable;

	/* 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();
		if(padflag == 0)	/* Pad was pressed ? */
		{
			if((count % 300) == 0)
			{
				XAng1 = ((int)(rand() * ((RMAX - RMIN) / RAND_MAX) + RMIN) - 100.0f) / 5000.0f;
				YAng1 = ((int)(rand() * ((RMAX - RMIN) / RAND_MAX) + RMIN) - 100.0f) / 5000.0f;
				ZAng1 = ((int)(rand() * ((RMAX - RMIN) / RAND_MAX) + RMIN) - 100.0f) / 5000.0f;
			}
			count++;
			if(count > 100000){ count = 0;}
		}
	return 1;
}
