// #define HEAP_UNIT_TEST // enable for heap unit testing, disables heapInit()

// -------------------------------------------------------------------------
// testinit.c
//
// This contains an example of starting up the ac audio systems.
//
// COPYRIGHT (C) SEGA OF AMERICA, INC. 1998
// All rights reserved.
//
// Information and source code samples contained herein are 
// provided "as-is", without representations or warranties, and 
// are subject to change without notice.
//
// SEGA OF AMERICA, INC. cannot support modifications or 
// derivative works created from the sample source code provided. 
// Developers may use, reproduce, and modify portions or entire 
// sections of the sample source code for the purposes of creating
// Dreamcast applications.  
//
// Sample source code contained herein may not be appropriate 
// for use under all circumstances.  Please consult Developer 
// documentation provided along with your Dreamcast unit for
// additional information and suggestions.
//
// Author: Ralph "Cooksey" Thomas
//
// Tabs: 4
//
// Rev:		11/20/98	Code moved to this file
//			2/19/99		Started porting to SHC environment
// -------------------------------------------------------------------------
    
#include <am.h>

// ----------------------------------------------------------------------------------------------
// The driver...
// ----------------------------------------------------------------------------------------------
   
#define DRIVER_NAME								"Audio64.drv"	
#define INTERRUPT_ARRAY_LENGTH					64

// --------------------------------------------------------------------------------------------------------------
// testInit, Shutdown this is the sequence of am calls necessary to start up and shutdown the 
// am library.
// --------------------------------------------------------------------------------------------------------------
  
void testShutdown(void)
{
;
}

KTBOOL testInit(void)
{
volatile KTU32 *driverImage			=	KTNULL;
KTU32 driverSize					=	0;

//acPrintf("Using DA-64 Driver: %s\n",DRIVER_NAME);

// get the size of the driver
if(acFileGetSize(DRIVER_NAME,&driverSize)==KTFALSE)
	{
	acPrintf("ERROR: Unable to get the size for %s\n",DRIVER_NAME);
	return KTFALSE;
	}

// get a temp buffer
if((driverImage=syMalloc(driverSize))==KTNULL)
	{
	acPrintf("ERROR: Unable to allocate %u bytes of SH4 memory for %s\n",driverSize,DRIVER_NAME);
	return KTFALSE;
	}

// load the driver
if(acFileLoad(DRIVER_NAME,driverImage)==KTFALSE)
	{
	acPrintf("ERROR: Unable to load %s\n",DRIVER_NAME);
	return KTFALSE;
	}

// init the ac system
acSystemInit();

// install the driver
if(acSystemInstallDriver((KTU32 *)driverImage,driverSize,INTERRUPT_ARRAY_LENGTH)==KTFALSE)
	{
	acPrintf("ERROR: Unable to install ARM driver %s\n",DRIVER_NAME);
	return KTFALSE;
	}

return KTTRUE;
}

