


#include "include.h"
#include "sound.h"

void adxtestCycle(void);
void adxtestDraw(void);



char *xdatestStrings[] = 
{
	"ADX Test",
	"Press @X to play the test ADX",
	"Press @C to stop the test ADX",
	"Press START to quit"
};


int adxtestState=0;
XAFileType *adxtestCur=NULL;


void adxtestStart(void)
{
	cycle_routine = adxtestCycle;
	draw_routine = adxtestDraw;
}


void adxtestEnd(void)
{
	menuStart();

	if (adxtestState)
	{
		XAstop();							// Stop playing the current ADX
		ADXT_Destroy(adxtestCur->adxt);		// Free the file handle
		FREE(adxtestCur);					// Free the structure for the XA stuff
		adxtestCur = NULL;					// dum de dum de dum......
	} // end-if	
}


void adxtestCycle(void)
{
	// Play the ADX
	if((pReadPad->debounce[0] & PAD_CROSS) && (!adxtestState))
	{
		adxtestCur = XAgetFileInfo("test.adx");
		XAplayChannel(adxtestCur, 1, 0, 64);
		adxtestState=1;
	} // end-if

	// Stop the ADX
	if((pReadPad->debounce[0] & PAD_CIRCLE) && (adxtestState))
	{
		adxtestState=0;

		XAstop();							// Stop playing the current ADX
		ADXT_Destroy(adxtestCur->adxt);		// Free the file handle
		FREE(adxtestCur);					// Free the structure for the XA stuff
		adxtestCur = NULL;					// dum de dum de dum......

	} // end-if
}


void adxtestDraw(void)
{
int x;


	x = -319 + ((640 - fontExtentW(font, xdatestStrings[0])) >> 1);
	fontPrint(font, x, -100, xdatestStrings[0], 128, 128, 0);

	if (!adxtestState)
	{
		x = -319 + ((640 - fontExtentW(font, xdatestStrings[1])) >> 1);
		fontPrint(font, x, -60, xdatestStrings[1], 128, 128, 128);
		x = -319 + ((640 - fontExtentW(font, xdatestStrings[2])) >> 1);
		fontPrint(font, x, -40, xdatestStrings[2], 32, 32, 32);
	} else {
		x = -319 + ((640 - fontExtentW(font, xdatestStrings[1])) >> 1);
		fontPrint(font, x, -60, xdatestStrings[1], 32, 32, 32);
		x = -319 + ((640 - fontExtentW(font, xdatestStrings[2])) >> 1);
		fontPrint(font, x, -40, xdatestStrings[2], 128, 128, 128);
	} // end-if-else
}


