update msvc project & romdata & hack games (#1616)

update msvc project
romdata.cpp: Accurately differentiate between ASCII/UTF8/UTF8BOM in UTF8 & to LF.
stdfunc.h: fix for STD_ROM_PICK macro not booting from romdata.
d_cps1: GameConfig is correctly indexed when entering the game from romdata.
d_neogeo.cpp: update hack games.
This commit is contained in:
taoenwen 2023-12-22 09:15:29 +08:00 committed by GitHub
parent 7e6e8e3673
commit f239ce79bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 462 additions and 401 deletions

View File

@ -118,6 +118,7 @@
<ClCompile Include="..\..\src\burn\devices\intelfsh.cpp" />
<ClCompile Include="..\..\src\burn\devices\joyprocess.cpp" />
<ClCompile Include="..\..\src\burn\devices\k1ge.cpp" />
<ClCompile Include="..\..\src\burn\devices\kaneko_hit.cpp" />
<ClCompile Include="..\..\src\burn\devices\kaneko_tmap.cpp" />
<ClCompile Include="..\..\src\burn\devices\mathbox.cpp" />
<ClCompile Include="..\..\src\burn\devices\mb87078.cpp" />
@ -238,6 +239,7 @@
<ClCompile Include="..\..\src\burn\drv\pst90s\d_discoboy.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_eolith.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_eolith16.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_expro02.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_f-32.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_galpani3.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_goori.cpp" />

View File

@ -3529,6 +3529,12 @@
<ClCompile Include="..\..\src\dep\libs\libspng\spng.c">
<Filter>libs\libspng</Filter>
</ClCompile>
<ClCompile Include="..\..\src\burn\drv\pst90s\d_expro02.cpp">
<Filter>burn\drv\pst90s</Filter>
</ClCompile>
<ClCompile Include="..\..\src\burn\devices\kaneko_hit.cpp">
<Filter>burn\devices</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="Burn">

View File

@ -118,6 +118,7 @@
<ClCompile Include="..\..\src\burn\devices\intelfsh.cpp" />
<ClCompile Include="..\..\src\burn\devices\joyprocess.cpp" />
<ClCompile Include="..\..\src\burn\devices\k1ge.cpp" />
<ClCompile Include="..\..\src\burn\devices\kaneko_hit.cpp" />
<ClCompile Include="..\..\src\burn\devices\kaneko_tmap.cpp" />
<ClCompile Include="..\..\src\burn\devices\mathbox.cpp" />
<ClCompile Include="..\..\src\burn\devices\mb87078.cpp" />
@ -238,6 +239,7 @@
<ClCompile Include="..\..\src\burn\drv\pst90s\d_discoboy.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_eolith.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_eolith16.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_expro02.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_f-32.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_galpani3.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_goori.cpp" />

View File

@ -3529,6 +3529,12 @@
<ClCompile Include="..\..\src\dep\libs\libspng\spng.c">
<Filter>libs\libspng</Filter>
</ClCompile>
<ClCompile Include="..\..\src\burn\drv\pst90s\d_expro02.cpp">
<Filter>burn\drv\pst90s</Filter>
</ClCompile>
<ClCompile Include="..\..\src\burn\devices\kaneko_hit.cpp">
<Filter>burn\devices</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="Burn">

View File

@ -118,6 +118,7 @@
<ClCompile Include="..\..\src\burn\devices\intelfsh.cpp" />
<ClCompile Include="..\..\src\burn\devices\joyprocess.cpp" />
<ClCompile Include="..\..\src\burn\devices\k1ge.cpp" />
<ClCompile Include="..\..\src\burn\devices\kaneko_hit.cpp" />
<ClCompile Include="..\..\src\burn\devices\kaneko_tmap.cpp" />
<ClCompile Include="..\..\src\burn\devices\mathbox.cpp" />
<ClCompile Include="..\..\src\burn\devices\mb87078.cpp" />
@ -238,6 +239,7 @@
<ClCompile Include="..\..\src\burn\drv\pst90s\d_discoboy.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_eolith.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_eolith16.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_expro02.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_f-32.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_galpani3.cpp" />
<ClCompile Include="..\..\src\burn\drv\pst90s\d_goori.cpp" />

View File

@ -3529,6 +3529,12 @@
<ClCompile Include="..\..\src\dep\libs\libspng\spng.c">
<Filter>libs\libspng</Filter>
</ClCompile>
<ClCompile Include="..\..\src\burn\drv\pst90s\d_expro02.cpp">
<Filter>burn\drv\pst90s</Filter>
</ClCompile>
<ClCompile Include="..\..\src\burn\devices\kaneko_hit.cpp">
<Filter>burn\devices</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="cpus">

View File

@ -16545,7 +16545,7 @@ static char* szGameName = NULL;
static void SetGameConfig()
{
const char* GameName = (NULL != szGameName) ? szGameName : BurnDrvGetTextA(DRV_NAME);
const char* GameName = (NULL != szGameName) ? szGameName : (((NULL != pDataRomDesc) && (-1 != pRDI->nDescCount)) ? pRDI->szDrvName : BurnDrvGetTextA(DRV_NAME));
const struct GameConfig *k = &ConfigTable[0];
while (k->DriverName) {

View File

@ -17781,22 +17781,22 @@ struct BurnDriver BurnDrvmslug1v2 = {
// Modified by 合金弹头爱克斯
// GOTVG 20231028
static struct BurnRomInfo mslugyqRomDesc[] = {
static struct BurnRomInfo mslugqyRomDesc[] = {
{ "201-p1qy.p1", 0x100000, 0x750c90c8, 1 | BRF_ESS | BRF_PRG },
{ "201-p2dg.sp2", 0x100000, 0xc3cb544c, 1 | BRF_ESS | BRF_PRG },
MSLUG_COMPONENT
};
STDROMPICKEXT(mslugyq, mslugyq, neogeo)
STD_ROM_FN(mslugyq)
STDROMPICKEXT(mslugqy, mslugqy, neogeo)
STD_ROM_FN(mslugqy)
struct BurnDriver BurnDrvmslugyq = {
"mslugyq", "mslug", "neogeo", NULL, "2023",
struct BurnDriver BurnDrvmslugqy = {
"mslugqy", "mslug", "neogeo", NULL, "2023",
"Metal Slug - Super Vehicle-001 (Origins, Hack)\0", NULL, "hack", "Neo Geo MVS",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_HACK, 2, HARDWARE_PREFIX_CARTRIDGE | HARDWARE_SNK_NEOGEO, GBF_RUNGUN, FBF_MSLUG,
NULL, mslugyqRomInfo, mslugyqRomName, NULL, NULL, NULL, NULL, neogeoInputInfo, neogeoDIPInfo,
NULL, mslugqyRomInfo, mslugqyRomName, NULL, NULL, NULL, NULL, neogeoInputInfo, neogeoDIPInfo,
NeoInit, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
0x1000, 304, 224, 4, 3
};
@ -17804,11 +17804,11 @@ struct BurnDriver BurnDrvmslugyq = {
// Metal Slug - Super Vehicle-001 (Item Random FC2, Hack)
// Modified by Alice
// 20231204
// 20231215
static struct BurnRomInfo mslugfc1RomDesc[] = {
{ "201-p1fc1.p1", 0x100000, 0xaa915a0e, 1 | BRF_ESS | BRF_PRG },
{ "201-p2fc1.sp2", 0x100000, 0x6de5637a, 1 | BRF_ESS | BRF_PRG },
{ "201-p1fc1.p1", 0x100000, 0xdb8f7d81, 1 | BRF_ESS | BRF_PRG },
{ "201-p2fc1.sp2", 0x100000, 0xad244b93, 1 | BRF_ESS | BRF_PRG },
MSLUG_COMPONENT
};
@ -17829,11 +17829,11 @@ struct BurnDriver BurnDrvmslugfc1 = {
// Metal Slug - Super Vehicle-001 (Item Random & Powerful Enemy Defense FC2, Hack)
// Modified by Alice
// 20231204
// 20231215
static struct BurnRomInfo mslugfc2RomDesc[] = {
{ "201-p1fc2.p1", 0x100000, 0xc167facf, 1 | BRF_ESS | BRF_PRG },
{ "201-p2fc2.sp2", 0x100000, 0x1c278a37, 1 | BRF_ESS | BRF_PRG },
{ "201-p1fc2.p1", 0x100000, 0xb079dd40, 1 | BRF_ESS | BRF_PRG },
{ "201-p2fc2.sp2", 0x100000, 0xdce6a2de, 1 | BRF_ESS | BRF_PRG },
MSLUG_COMPONENT
};
@ -22285,11 +22285,11 @@ struct BurnDriver BurnDrvkof97t = {
// The King of Fighters '97 (Strengthen Innovation, Hack)
// GOTVG 20230129
// GOTVG 20231218
static struct BurnRomInfo kof97stRomDesc[] = {
{ "232-p1st.p1", 0x100000, 0x32b4ce56, 1 | BRF_ESS | BRF_PRG },
{ "232-p2st.sp2", 0x400000, 0xb0aee031, 1 | BRF_ESS | BRF_PRG },
{ "232-p1st.p1", 0x100000, 0x4d4dfd30, 1 | BRF_ESS | BRF_PRG },
{ "232-p2st.sp2", 0x400000, 0xf144c697, 1 | BRF_ESS | BRF_PRG },
KOF97_TEXT
@ -22297,7 +22297,8 @@ static struct BurnRomInfo kof97stRomDesc[] = {
{ "232-c2st.c2", 0x800000, 0x831ec266, 3 | BRF_GRA },
{ "232-c3st.c3", 0x800000, 0xb092e64f, 3 | BRF_GRA },
{ "232-c4st.c4", 0x800000, 0xd25e8a04, 3 | BRF_GRA },
KOF97_SPR3
{ "232-c5st.c5", 0x400000, 0x91771218, 3 | BRF_GRA },
{ "232-c6st.c6", 0x400000, 0x55a1bf39, 3 | BRF_GRA },
KOF97_Z80

View File

@ -4,10 +4,19 @@
#define STD_ROM_PICK(Name) \
static struct BurnRomInfo* Name##PickRom(UINT32 i) \
{ \
if (i >= sizeof(Name##RomDesc) / sizeof(Name##RomDesc[0])) { \
return NULL; \
if ((NULL != pDataRomDesc) && (-1 != pRDI->nDescCount)) { \
/* Replace with the contents of Romdata */ \
/* Differences in array pointers */ \
if (i > pRDI->nDescCount) { \
return NULL; \
} \
return pDataRomDesc + i; \
} else { \
if (i >= sizeof(Name##RomDesc) / sizeof(Name##RomDesc[0])) { \
return NULL; \
} \
return Name##RomDesc + i; \
} \
return Name##RomDesc + i; \
}
#define STDROMPICKEXT(Name, Info1, Info2) \

View File

@ -1,392 +1,419 @@
#include "burner.h"
#ifndef UINT32_MAX
#define UINT32_MAX (UINT32)4294967295
#endif
static struct RomDataInfo RDI = { 0 };
RomDataInfo* pRDI = &RDI;
struct BurnRomInfo* pDataRomDesc = NULL;
TCHAR szRomdataName[MAX_PATH] = _T("");
static TCHAR* _strqtoken(TCHAR* s, const TCHAR* delims)
{
static TCHAR* prev_str = NULL;
TCHAR* token = NULL;
if (!s) {
if (!prev_str) return NULL;
s = prev_str;
}
s += _tcsspn(s, delims);
if (s[0] == _T('\0')) {
prev_str = NULL;
return NULL;
}
if (s[0] == _T('\"')) { // time to grab quoted string!
token = ++s;
if ((s = _tcspbrk(token, _T("\"")))) {
*(s++) = '\0';
}
if (!s) {
prev_str = NULL;
return NULL;
}
} else {
token = s;
}
if ((s = _tcspbrk(s, delims))) {
*(s++) = _T('\0');
prev_str = s;
} else {
// we're at the end of the road
#if defined (_UNICODE)
prev_str = (TCHAR*)wmemchr(token, _T('\0'), MAX_PATH);
#else
prev_str = (char*)memchr((void*)token, '\0', MAX_PATH);
#endif
}
return token;
}
#define UTF8_SIGNATURE "\xef\xbb\xbf"
static INT32 IsDatUTF8BOM()
{
FILE* fp = _tfopen(szRomdataName, _T("rb"));
#include "burner.h"
#ifndef UINT32_MAX
#define UINT32_MAX (UINT32)4294967295
#endif
static struct RomDataInfo RDI = { 0 };
RomDataInfo* pRDI = &RDI;
struct BurnRomInfo* pDataRomDesc = NULL;
TCHAR szRomdataName[MAX_PATH] = _T("");
static TCHAR* _strqtoken(TCHAR* s, const TCHAR* delims)
{
static TCHAR* prev_str = NULL;
TCHAR* token = NULL;
if (!s) {
if (!prev_str) return NULL;
s = prev_str;
}
s += _tcsspn(s, delims);
if (s[0] == _T('\0')) {
prev_str = NULL;
return NULL;
}
if (s[0] == _T('\"')) { // time to grab quoted string!
token = ++s;
if ((s = _tcspbrk(token, _T("\"")))) {
*(s++) = '\0';
}
if (!s) {
prev_str = NULL;
return NULL;
}
} else {
token = s;
}
if ((s = _tcspbrk(s, delims))) {
*(s++) = _T('\0');
prev_str = s;
} else {
// we're at the end of the road
#if defined (_UNICODE)
prev_str = (TCHAR*)wmemchr(token, _T('\0'), MAX_PATH);
#else
prev_str = (char*)memchr((void*)token, '\0', MAX_PATH);
#endif
}
return token;
}
static INT32 IsUTF8Text(const void* pBuffer, long size)
{
INT32 nCode = 0;
unsigned char* start = (unsigned char*)pBuffer;
unsigned char* end = (unsigned char*)pBuffer + size;
while (start < end) {
if (*start < 0x80) { // (10000000) ASCII
if (0 == nCode) nCode = 1;
start++;
} else if (*start < 0xc0) { // (11000000) Invalid UTF-8
return 0;
} else if (*start < 0xe0) { // (11100000) 2-byte UTF-8
if (nCode < 2) nCode = 2;
if (start >= end - 1) break;
if (0x80 != (start[1] & 0xc0)) return 0;
start += 2;
} else if (*start < 0xf0) { // (11110000) 3-byte UTF-8
if (nCode < 3) nCode = 3;
if (start >= end - 2) break;
if ((0x80 != (start[1] & 0xc0)) || (0x80 != (start[2] & 0xc0))) return 0;
start += 3;
} else {
return 0;
}
}
return nCode;
}
static INT32 IsDatUTF8BOM()
{
FILE* fp = _tfopen(szRomdataName, _T("rb"));
if (NULL == fp) return -1;
// get dat size
fseek(fp, 0, SEEK_END);
INT32 nDatSize = ftell(fp);
fseek(fp, 0, SEEK_SET);
INT32 nRet = 0;
if (nDatSize > strlen(UTF8_SIGNATURE)) {
char* pszTest = (char*)malloc(nDatSize);
if (NULL != pszTest) {
fread(pszTest, nDatSize, 1, fp);
if (0 == strncmp(pszTest, UTF8_SIGNATURE, strlen(UTF8_SIGNATURE))) {
nRet = 1;
}
free(pszTest);
pszTest = NULL;
}
}
fclose(fp);
return nRet;
}
#undef UTF8_SIGNATURE
#define DELIM_TOKENS_NAME _T(" \t\r\n,%:|{}")
static INT32 LoadRomdata()
{
INT32 nType = IsDatUTF8BOM();
if (-1 == nType) return -1;
RDI.nDescCount = -1; // Failed
const TCHAR* szReadMode = (0 == nType) ? _T("rt") : _T("rt, ccs=UTF-8");
FILE* fp = _tfopen(szRomdataName, szReadMode);
if (NULL == fp) return RDI.nDescCount;
TCHAR szBuf[MAX_PATH] = { 0 };
TCHAR* pszBuf = NULL, * pszLabel = NULL, * pszInfo = NULL;
memset(RDI.szExtraRom, '\0', sizeof(RDI.szExtraRom));
memset(RDI.szFullName, '\0', sizeof(RDI.szFullName));
while (!feof(fp)) {
if (_fgetts(szBuf, MAX_PATH, fp) != NULL) {
pszBuf = szBuf;
pszLabel = _strqtoken(pszBuf, DELIM_TOKENS_NAME);
if (NULL == pszLabel) continue;
if ((_T('/') == pszLabel[0]) && (_T('/') == pszLabel[1])) continue;
if (0 == _tcsicmp(_T("ZipName"), pszLabel)) {
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if (NULL == pszInfo) break; // No romset specified
if (NULL != pDataRomDesc) {
strcpy(RDI.szZipName, TCHARToANSI(pszInfo, NULL, 0));
}
}
if (0 == _tcsicmp(_T("DrvName"), pszLabel)) {
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if (NULL == pszInfo) break; // No driver specified
if (NULL != pDataRomDesc) {
strcpy(RDI.szDrvName, TCHARToANSI(pszInfo, NULL, 0));
}
}
if (0 == _tcsicmp(_T("ExtraRom"), pszLabel)) {
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if ((NULL != pszInfo) && (NULL != pDataRomDesc)) {
strcpy(RDI.szExtraRom, TCHARToANSI(pszInfo, NULL, 0));
}
}
if (0 == _tcsicmp(_T("FullName"), pszLabel)) {
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if ((NULL != pszInfo) && (NULL != pDataRomDesc)) {
#ifdef UNICODE
_tcscpy(RDI.szFullName, pszInfo);
#else
wcscpy(RDI.szFullName, ANSIToTCHAR(pszInfo, NULL, 0));
#endif
}
}
{
// romname, len, crc, type
struct BurnRomInfo ri = { 0 };
ri.nLen = UINT32_MAX;
ri.nCrc = UINT32_MAX;
ri.nType = 0;
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if (NULL != pszInfo) {
_stscanf(pszInfo, _T("%x"), &(ri.nLen));
if (UINT32_MAX == ri.nLen) continue;
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if (NULL != pszInfo) {
_stscanf(pszInfo, _T("%x"), &(ri.nCrc));
if (UINT32_MAX == ri.nCrc) continue;
while (NULL != (pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME))) {
INT32 nValue = -1;
if (0 == _tcscmp(pszInfo, _T("BRF_PRG"))) {
ri.nType |= BRF_PRG;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_GRA"))) {
ri.nType |= BRF_GRA;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_SND"))) {
ri.nType |= BRF_SND;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_ESS"))) {
ri.nType |= BRF_ESS;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_BIOS"))) {
ri.nType |= BRF_BIOS;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_SELECT"))) {
ri.nType |= BRF_SELECT;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_OPT"))) {
ri.nType |= BRF_OPT;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_NODUMP"))) {
ri.nType |= BRF_NODUMP;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_PRG_68K"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_68K_PROGRAM_BYTESWAP")))) { // 1
ri.nType |= 1;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_PRG_68K_SIMM"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_68K_PROGRAM_NO_BYTESWAP")))) { // 2
ri.nType |= 2;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_PRG_68K_XOR_TABLE"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_Z80_PROGRAM")))) { // 3
ri.nType |= 3;
continue;
}
if (0 == _tcscmp(pszInfo, _T("CPS1_TILES"))) { // 4
ri.nType |= 4;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_GFX"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_OKIM6295_SAMPLES")))) { // 5
ri.nType |= 5;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_GFX_SIMM"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_QSOUND_SAMPLES")))) { // 6
ri.nType |= 6;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_GFX_SPLIT4"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_PIC")))) { // 7
ri.nType |= 7;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_GFX_SPLIT8"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_EXTRA_TILES_SF2EBBL_400000")))) { // 8
ri.nType |= 8;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_GFX_19XXJ"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_EXTRA_TILES_400000")))) { // 9
ri.nType |= 9;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_PRG_Z80"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_EXTRA_TILES_SF2KORYU_400000")))) { // 10
ri.nType |= 10;
continue;
}
if (0 == _tcscmp(pszInfo, _T("CPS1_EXTRA_TILES_SF2B_400000"))) { // 11
ri.nType |= 11;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_QSND"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_EXTRA_TILES_SF2MKOT_400000")))) { // 12
ri.nType |= 12;
continue;
}
if (0 == _tcscmp(pszInfo, _T("CPS2_QSND_SIMM"))) { // 13
ri.nType |= 13;
continue;
}
if (0 == _tcscmp(pszInfo, _T("CPS2_QSND_SIMM_BYTESWAP"))) { // 14
ri.nType |= 14;
continue;
}
if (0 == _tcscmp(pszInfo, _T("CPS2_ENCRYPTION_KEY"))) { // 15
ri.nType |= 15;
continue;
}
_stscanf(pszInfo, _T("%x"), &nValue);
if (-1 != nValue) {
ri.nType |= (UINT32)nValue;
continue;
}
}
if (ri.nType > 0) {
RDI.nDescCount++;
if (NULL != pDataRomDesc) {
strcpy(pDataRomDesc[RDI.nDescCount].szName, TCHARToANSI(pszLabel, NULL, 0));
pDataRomDesc[RDI.nDescCount].nLen = ri.nLen;
pDataRomDesc[RDI.nDescCount].nCrc = ri.nCrc;
pDataRomDesc[RDI.nDescCount].nType = ri.nType;
}
}
}
}
}
}
}
fclose(fp);
return RDI.nDescCount;
}
char* RomdataGetDrvName()
{
INT32 nType = IsDatUTF8BOM();
if (-1 == nType) return NULL;
const TCHAR* szReadMode = (0 == nType) ? _T("rt") : _T("rt, ccs=UTF-8");
FILE* fp = _tfopen(szRomdataName, szReadMode);
if (NULL == fp) return NULL;
TCHAR szBuf[MAX_PATH] = { 0 };
TCHAR* pszBuf = NULL, * pszLabel = NULL, * pszInfo = NULL;
while (!feof(fp)) {
if (_fgetts(szBuf, MAX_PATH, fp) != NULL) {
pszBuf = szBuf;
pszLabel = _strqtoken(pszBuf, DELIM_TOKENS_NAME);
if (NULL == pszLabel) continue;
if ((_T('/') == pszLabel[0]) && (_T('/') == pszLabel[1])) continue;
if (0 == _tcsicmp(_T("DrvName"), pszLabel)) {
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if (NULL == pszInfo) break; // No driver specified
fclose(fp);
return TCHARToANSI(pszInfo, NULL, 0);
}
}
}
fclose(fp);
return NULL;
}
#undef DELIM_TOKENS_NAME
void RomDataInit()
{
INT32 nLen = LoadRomdata();
if ((-1 != nLen) && (NULL == pDataRomDesc)) {
pDataRomDesc = (struct BurnRomInfo*)malloc((nLen + 1) * sizeof(BurnRomInfo));
if (NULL != pDataRomDesc) {
LoadRomdata();
fseek(fp, 0, SEEK_SET);
INT32 nRet = 0;
char* pszTest = (char*)malloc(nDatSize + 1);
if (NULL != pszTest) {
memset(pszTest, 0, nDatSize + 1);
fread(pszTest, nDatSize, 1, fp);
nRet = IsUTF8Text(pszTest, nDatSize);
free(pszTest);
pszTest = NULL;
}
fclose(fp);
return nRet;
}
#define DELIM_TOKENS_NAME _T(" \t\r\n,%:|{}")
static INT32 LoadRomdata()
{
INT32 nType = IsDatUTF8BOM();
if (-1 == nType) return -1;
RDI.nDescCount = -1; // Failed
const TCHAR* szReadMode = (3 == nType) ? _T("rt, ccs=UTF-8") : _T("rt");
FILE* fp = _tfopen(szRomdataName, szReadMode);
if (NULL == fp) return RDI.nDescCount;
TCHAR szBuf[MAX_PATH] = { 0 };
TCHAR* pszBuf = NULL, * pszLabel = NULL, * pszInfo = NULL;
memset(RDI.szExtraRom, '\0', sizeof(RDI.szExtraRom));
memset(RDI.szFullName, '\0', sizeof(RDI.szFullName));
while (!feof(fp)) {
if (_fgetts(szBuf, MAX_PATH, fp) != NULL) {
pszBuf = szBuf;
pszLabel = _strqtoken(pszBuf, DELIM_TOKENS_NAME);
if (NULL == pszLabel) continue;
if ((_T('/') == pszLabel[0]) && (_T('/') == pszLabel[1])) continue;
if (0 == _tcsicmp(_T("ZipName"), pszLabel)) {
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if (NULL == pszInfo) break; // No romset specified
if (NULL != pDataRomDesc) {
strcpy(RDI.szZipName, TCHARToANSI(pszInfo, NULL, 0));
}
}
if (0 == _tcsicmp(_T("DrvName"), pszLabel)) {
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if (NULL == pszInfo) break; // No driver specified
if (NULL != pDataRomDesc) {
strcpy(RDI.szDrvName, TCHARToANSI(pszInfo, NULL, 0));
}
}
if (0 == _tcsicmp(_T("ExtraRom"), pszLabel)) {
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if ((NULL != pszInfo) && (NULL != pDataRomDesc)) {
strcpy(RDI.szExtraRom, TCHARToANSI(pszInfo, NULL, 0));
}
}
if (0 == _tcsicmp(_T("FullName"), pszLabel)) {
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if ((NULL != pszInfo) && (NULL != pDataRomDesc)) {
#ifdef UNICODE
_tcscpy(RDI.szFullName, pszInfo);
#else
wcscpy(RDI.szFullName, ANSIToTCHAR(pszInfo, NULL, 0));
#endif
}
}
{
// romname, len, crc, type
struct BurnRomInfo ri = { 0 };
ri.nLen = UINT32_MAX;
ri.nCrc = UINT32_MAX;
ri.nType = 0;
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if (NULL != pszInfo) {
_stscanf(pszInfo, _T("%x"), &(ri.nLen));
if (UINT32_MAX == ri.nLen) continue;
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if (NULL != pszInfo) {
_stscanf(pszInfo, _T("%x"), &(ri.nCrc));
if (UINT32_MAX == ri.nCrc) continue;
while (NULL != (pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME))) {
INT32 nValue = -1;
if (0 == _tcscmp(pszInfo, _T("BRF_PRG"))) {
ri.nType |= BRF_PRG;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_GRA"))) {
ri.nType |= BRF_GRA;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_SND"))) {
ri.nType |= BRF_SND;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_ESS"))) {
ri.nType |= BRF_ESS;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_BIOS"))) {
ri.nType |= BRF_BIOS;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_SELECT"))) {
ri.nType |= BRF_SELECT;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_OPT"))) {
ri.nType |= BRF_OPT;
continue;
}
if (0 == _tcscmp(pszInfo, _T("BRF_NODUMP"))) {
ri.nType |= BRF_NODUMP;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_PRG_68K"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_68K_PROGRAM_BYTESWAP")))) { // 1
ri.nType |= 1;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_PRG_68K_SIMM"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_68K_PROGRAM_NO_BYTESWAP")))) { // 2
ri.nType |= 2;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_PRG_68K_XOR_TABLE"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_Z80_PROGRAM")))) { // 3
ri.nType |= 3;
continue;
}
if (0 == _tcscmp(pszInfo, _T("CPS1_TILES"))) { // 4
ri.nType |= 4;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_GFX"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_OKIM6295_SAMPLES")))) { // 5
ri.nType |= 5;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_GFX_SIMM"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_QSOUND_SAMPLES")))) { // 6
ri.nType |= 6;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_GFX_SPLIT4"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_PIC")))) { // 7
ri.nType |= 7;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_GFX_SPLIT8"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_EXTRA_TILES_SF2EBBL_400000")))) { // 8
ri.nType |= 8;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_GFX_19XXJ"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_EXTRA_TILES_400000")))) { // 9
ri.nType |= 9;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_PRG_Z80"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_EXTRA_TILES_SF2KORYU_400000")))) { // 10
ri.nType |= 10;
continue;
}
if (0 == _tcscmp(pszInfo, _T("CPS1_EXTRA_TILES_SF2B_400000"))) { // 11
ri.nType |= 11;
continue;
}
if ((0 == _tcscmp(pszInfo, _T("CPS2_QSND"))) ||
(0 == _tcscmp(pszInfo, _T("CPS1_EXTRA_TILES_SF2MKOT_400000")))) { // 12
ri.nType |= 12;
continue;
}
if (0 == _tcscmp(pszInfo, _T("CPS2_QSND_SIMM"))) { // 13
ri.nType |= 13;
continue;
}
if (0 == _tcscmp(pszInfo, _T("CPS2_QSND_SIMM_BYTESWAP"))) { // 14
ri.nType |= 14;
continue;
}
if (0 == _tcscmp(pszInfo, _T("CPS2_ENCRYPTION_KEY"))) { // 15
ri.nType |= 15;
continue;
}
_stscanf(pszInfo, _T("%x"), &nValue);
if (-1 != nValue) {
ri.nType |= (UINT32)nValue;
continue;
}
}
if (ri.nType > 0) {
RDI.nDescCount++;
if (NULL != pDataRomDesc) {
strcpy(pDataRomDesc[RDI.nDescCount].szName, TCHARToANSI(pszLabel, NULL, 0));
pDataRomDesc[RDI.nDescCount].nLen = ri.nLen;
pDataRomDesc[RDI.nDescCount].nCrc = ri.nCrc;
pDataRomDesc[RDI.nDescCount].nType = ri.nType;
}
}
}
}
}
}
}
fclose(fp);
return RDI.nDescCount;
}
char* RomdataGetDrvName()
{
INT32 nType = IsDatUTF8BOM();
if (-1 == nType) return NULL;
const TCHAR* szReadMode = (3 == nType) ? _T("rt, ccs=UTF-8") : _T("rt");
FILE* fp = _tfopen(szRomdataName, szReadMode);
if (NULL == fp) return NULL;
TCHAR szBuf[MAX_PATH] = { 0 };
TCHAR* pszBuf = NULL, * pszLabel = NULL, * pszInfo = NULL;
while (!feof(fp)) {
if (_fgetts(szBuf, MAX_PATH, fp) != NULL) {
pszBuf = szBuf;
pszLabel = _strqtoken(pszBuf, DELIM_TOKENS_NAME);
if (NULL == pszLabel) continue;
if ((_T('/') == pszLabel[0]) && (_T('/') == pszLabel[1])) continue;
if (0 == _tcsicmp(_T("DrvName"), pszLabel)) {
pszInfo = _strqtoken(NULL, DELIM_TOKENS_NAME);
if (NULL == pszInfo) break; // No driver specified
fclose(fp);
return TCHARToANSI(pszInfo, NULL, 0);
}
}
}
fclose(fp);
return NULL;
}
#undef DELIM_TOKENS_NAME
void RomDataInit()
{
INT32 nLen = LoadRomdata();
if ((-1 != nLen) && (NULL == pDataRomDesc)) {
pDataRomDesc = (struct BurnRomInfo*)malloc((nLen + 1) * sizeof(BurnRomInfo));
if (NULL != pDataRomDesc) {
LoadRomdata();
RDI.nDriverId = BurnDrvGetIndex(RDI.szDrvName);
if (-1 != RDI.nDriverId) {
BurnDrvSetZipName(RDI.szZipName, RDI.nDriverId);
}
}
}
}
void RomDataSetFullName()
{
// At this point, the driver's default ZipName has been replaced with the ZipName from the rom data
if (-1 != RDI.nDriverId) {
BurnDrvSetZipName(RDI.szZipName, RDI.nDriverId);
}
}
}
}
void RomDataSetFullName()
{
// At this point, the driver's default ZipName has been replaced with the ZipName from the rom data
RDI.nDriverId = BurnDrvGetIndex(RDI.szZipName);
if (-1 != RDI.nDriverId) {
wchar_t* szOldName = BurnDrvGetFullNameW(RDI.nDriverId);
memset(RDI.szOldName, '\0', sizeof(RDI.szOldName));
if (0 != wcscmp(szOldName, RDI.szOldName)) {
wcscpy(RDI.szOldName, szOldName);
}
BurnDrvSetFullNameW(RDI.szFullName, RDI.nDriverId);
}
}
void RomDataExit()
{
if (NULL != pDataRomDesc) {
free(pDataRomDesc);
pDataRomDesc = NULL;
if (-1 != RDI.nDriverId) {
wchar_t* szOldName = BurnDrvGetFullNameW(RDI.nDriverId);
memset(RDI.szOldName, '\0', sizeof(RDI.szOldName));
if (-1 != RDI.nDriverId) {
BurnDrvSetZipName(RDI.szDrvName, RDI.nDriverId);
if (0 != wcscmp(BurnDrvGetFullNameW(RDI.nDriverId), RDI.szOldName)) {
BurnDrvSetFullNameW(RDI.szOldName, RDI.nDriverId);
}
if (0 != wcscmp(szOldName, RDI.szOldName)) {
wcscpy(RDI.szOldName, szOldName);
}
memset(&RDI, 0, sizeof(RomDataInfo));
RDI.nDescCount = -1;
}
}
BurnDrvSetFullNameW(RDI.szFullName, RDI.nDriverId);
}
}
void RomDataExit()
{
if (NULL != pDataRomDesc) {
free(pDataRomDesc);
pDataRomDesc = NULL;
if (-1 != RDI.nDriverId) {
BurnDrvSetZipName(RDI.szDrvName, RDI.nDriverId);
if (0 != wcscmp(BurnDrvGetFullNameW(RDI.nDriverId), RDI.szOldName)) {
BurnDrvSetFullNameW(RDI.szOldName, RDI.nDriverId);
}
}
memset(&RDI, 0, sizeof(RomDataInfo));
RDI.nDescCount = -1;
}
}