/*
	Overlay Tutorial
	Original: Takashi Kashima
	Revision: 1999.07.6 Roger Wong
*/

#include <shinobi.h>

#include <sg_Cache.h>

#include "mw_utils.h"
#include "overlay1.h"
#include "overlay2.h"

// The overlay number is determined by the order 
// the overlay is placed in the "Overlays" tab of
// the project window. The main application is
// defined as Overlay #0. Each overlay gets its
// own entry in the _overlay_section_address table.

#define OVERLAY1_NUMBER		***Index of first overlay***
#define OVERLAY2_NUMBER		***Index of second overlay***

// binary file name
#define OVERLAY1_FILENAME	"Filename of first overlay"
#define OVERLAY2_FILENAME	"Filename of second overlay"

void njUserInit(void)
{
    njSetBorderColor( 0 ) ;
    sbInitSystem(NJD_RESOLUTION_320x240_NTSCNI, NJD_FRAMEBUFFER_MODE_RGB565, 1);

    njInitVertexBuffer(100000, 0, 100000, 0, 0);
    njInitPrint(NULL, 0, 0);
    njSetBackColor(0x00000000, 0x00000000, 0x000000FF);
}

Sint32	gCount	= 0;
Sint32	gVar	= 0; /*global variable*/

Sint32 njUserMain(void)
{
	Sint32 result;
	void*	pAddr;

	gCount++;

	pAddr		= (void *)overlay_section_address[OVERLAY1_NUMBER];
	if (MWLoadOverlay(OVERLAY1_FILENAME, pAddr))
	{
		result = func_ol1(gCount);
	}
	
	pAddr		= (void *)overlay_section_address[OVERLAY2_NUMBER];
	if (MWLoadOverlay(OVERLAY2_FILENAME, pAddr))
	{
		result = func_ol2(gCount);
	}

    njPrintC(NJM_LOCATION(4,  2), "Overlay Tutorial");
    return NJD_USER_CONTINUE;
}

void njUserExit(void)
{
    njExitPrint();
    sbExitSystem();
}

