#include "specific.h"

#define local static
#define global extern
#define defglobal

#define false 0
#define true 1

/*** cdsound.c ***/
#if 0
#define CD_PLAY_ONCE 0x100
#define CD_PLAY_THEN_RETURN 0x200

enum	{
	CD_MODE_NONE,
	CD_MODE_DATA,
	CD_MODE_AUDIO
	};
enum
	{
	CD_SYNC_STATUS,
	CD_SYNC_WAIT_START,
	CD_SYNC_WAIT_END
	};
enum
	{
	CD_STATUS_NOT_STARTED,
	CD_STATUS_PLAYING,
	CD_STATUS_FINISHED
	};

void	CD_Init(void);
void	CD_Cleanup(void);
void	CD_SetMode(int nMode);

int		CDDA_SetMasterVolume(int nVolume);
void	CDDA_SetVolume(int nVolume);
void	CDDA_Play(int nTrack);
void	CDDA_Stop(void);
void	CDDA_Pause(void);
void	CDDA_Unpause(void);
int		CDDA_Sync(int nType);
int		CDDA_GetCurrentLoc(void);

void	CDFS_UseSectorBuffer(uint32* pBuffer,int nSize);
int		CDFS_OpenFile(char* szFileName);
void	CDFS_GetSectors(int nFirstSector,int nSectors,void* pDest);
int		CDFS_LoadFile(char* szFileName,void* pDest);
int		CDFS_GetFileSize(char* szFileName);
int		CDFS_ReadBytes(void* pvDest,int nBytes);
CdlLOC*	CDFS_GetFileLoc(void);
#endif

/*** file.c ***/
#if 0
int		FILE_Load(char* szFileName,void* pDest);
int		FILE_Save(char* szFilename,void* pSrc,uint32 dwLength);
uint32	FILE_Length(char* szFileName);
int		FILE_Open(char* szFileName);
int		FILE_Read(void* pDest,int nItemSize,int nItems,int nHandle);
void	FILE_Close(int nHandle);
#endif

/*** fmv.c ***/
enum
	{
	FMV_ERROR=-1,
	FMV_OK,
	FMV_SKIP,
	FMV_START
	};

int FMV_Play(char* szFileName,int nStartFrame,int nEndFrame);

/*** gpu.c ***/
#if 0
enum {BUF_NEXT,BUF_CURRENT};

typedef struct db_struct
	{
	int			current_buffer;				// Current Buffer
	uint32*		ot;                   		// Order table pointer for work buffer
	char*		polyptr;					// current Polygon pointer
	char*		curpolybuf;					// current poly buffer
	char*		polybuf_limit;				// near the end of the current poly buffer
	int			nOTSize;					// number of OT entries
	int			nPBSize;					// size of polygon buffers
	uint32*		order_table[2];				// Pointers for Order Tables
	uint32*		poly_buffer[2];				// Pointers for PolyBuffers
	DRAWENV		draw[2];                    // Drawing environments
	DISPENV		disp[2];                    // Display environments
	}
	DB_STRUCT;
typedef void (* PFNVSYNCROUTINE)(void);
typedef int (*PFNIDLECHECKROUTINE)(void);
typedef int (*PFNIDLEROUTINE)(PFNIDLECHECKROUTINE);

global DB_STRUCT db;						// The double buffering info
global volatile uint32 GnFrameCounter;		// Global Frame Counter..
global volatile uint32 GnLastFrameCount;	// Number of frames last time...

void GPU_Init(void);
void GPU_Cleanup(void);
void GPU_ClearVRAM(void);
void GPU_UseOrderingTables(uint32* pBuffers,int nOTSize);
void GPU_UsePolygonBuffers(uint32* pBuffers,int nPBSize);
void GPU_BeginScene(void);
void GPU_EndScene(void);
int GPU_Flip(PFNIDLEROUTINE pfnIdleRoutine);
void GPU_ResetLastFrameCount( void );
uint32 GPU_GetFrameCount( void );
int GPU_FlipNoIdle( void);
void GPU_FlipNow(void);
void GPU_FlipToBuffer(int nBuffer);
RECT* GPU_GetDispRect(int nWhich);
RECT* GPU_GetDrawRect(int nWhich);
void GPU_SetScreenPosition(sint16 nX,sint16 nY);
void GPU_GetScreenPosition(sint16* pnX,sint16* pnY);
bool GPU_EnableDither(bool tEnable);
bool GPU_EnableBGClear(bool tEnable);
uint32 GPU_SetBGColour(uint8 nR,uint8 nG,uint8 nB);
#ifdef PROFILE_ME
bool GPU_EnableProfilerBar(bool tEnable);
#endif
int	GPU_SetHorizontalResolution(int nNewRes);
int	GPU_GetHorizontalResolution(void);
#endif
/*** psx_init.c ***/
void PSX_Init(void);
void PSX_Exit(void);
void PSX_Abort(void);

/*** psxmisc.c ***/
#if 0
void GTE_Init(void);

void VSYNC_Init(void);
void VSYNC_Cleanup(void);
void VSYNC_Add(PFNVSYNCROUTINE pfnRoutine);
void VSYNC_Remove(PFNVSYNCROUTINE pfnRoutine);
#endif

/*** spusound.c ***/
enum
	{
	SPU_SAMPLETYPE_OFF,
	SPU_SAMPLETYPE_NORMAL,
	SPU_SAMPLETYPE_LOOPED
	};
#define	SPU_ERR_SOUND_FAILED		(-2)
#define	SPU_ERR_SOUND_NO_FREE_SLOTS	(-1)

void	SPU_Init(void);
void	SPU_Cleanup(void);
int		SPU_LoadSamples(int nSamples,uint32* padwOffset,void* pVAB,int nVABSize);
void	SPU_FreeSamples(void);
int		SPU_Play(int nSample,int nLeftVolume,int nRightVolume,int nPitch,int nSampleType);
void	SPU_AdjustVolume(int nChannel,int nLeftVolume,int nRightVolume);
void	SPU_AdjustPitch(int nChannel,int nPitch);
void	SPU_Stop(int nChannel);
void	SPU_StopAll(void);
void	SPU_Pause(int nChannel);
void	SPU_PauseAll(void);
void	SPU_Unpause(int nChannel);
void	SPU_UnpauseAll(void);
int		SPU_Status(int nChannel);
int		SPU_UpdateStatus(void);

