#include "burner.h"

char* gameAv = NULL;
bool avOk = false;
static int nOldSelect = 0;
extern void* osd_malloc(int n);

static void CreateRomDatName(TCHAR* szRomDat)
{
	_stprintf(szRomDat, _T("D:\\config\\%s.roms.dat"), "SEGA");

	return;
}

///////////////////////////////////////////////////////////////////////////////////////////////////
//Check Romsets Dialog/////////////////////////////////////////////////////////////////////////////

static int WriteGameAvb()
{
	return 0;
}

static int DoCheck(TCHAR* buffPos)
{
	return 1;
}

int CheckGameAvb()
{
	TCHAR szRomDat[260];
	FILE* h;
	int bOK;
	int nBufferSize = nBurnDrvCount + 256;
	TCHAR* buffer = (TCHAR*)osd_malloc(nBufferSize * sizeof(TCHAR));
	if (buffer == NULL) {
		return 1;
	}

	memset(buffer, 0, nBufferSize * sizeof(TCHAR));
	CreateRomDatName(szRomDat);

	if ((h = _tfopen(szRomDat, _T("r"))) == NULL) {
		return 1;
	}

	_fgetts(buffer, nBufferSize, h);
	fclose(h);

	bOK = DoCheck(buffer);

	free(buffer);
	return bOK;
}

static int QuitRomsScan()
{
	return 1;
}

int CreateROMInfo()
{
	if (gameAv == NULL) {
		gameAv = (char*)osd_malloc(nBurnDrvCount);
		memset(gameAv, 0, nBurnDrvCount);
	}

    CheckGameAvb();

	return 1;
}

void FreeROMInfo()
{
	free(gameAv);
	gameAv = NULL;
}
