core:
- the type of ROM serial code is changed (now NTR-****-***)
This commit is contained in:
parent
0eae3afc27
commit
41297b6d8e
|
@ -266,10 +266,28 @@ static u32 ones32(u32 x)
|
||||||
|
|
||||||
void GameInfo::populate()
|
void GameInfo::populate()
|
||||||
{
|
{
|
||||||
|
const char *regions[] = { "JPFSEDIRKH",
|
||||||
|
"JPN",
|
||||||
|
"EUR",
|
||||||
|
"FRA",
|
||||||
|
"ESP",
|
||||||
|
"USA",
|
||||||
|
"NOE",
|
||||||
|
"ITA",
|
||||||
|
"RUS",
|
||||||
|
"KOR",
|
||||||
|
"HOL",
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
NDS_header * _header = NDS_getROMHeader();
|
NDS_header * _header = NDS_getROMHeader();
|
||||||
header = *_header;
|
header = *_header;
|
||||||
delete _header;
|
delete _header;
|
||||||
|
|
||||||
|
memset(ROMserial, 0, sizeof(ROMserial));
|
||||||
|
memset(ROMname, 0, sizeof(ROMname));
|
||||||
|
memset(ROMfullName, 0, sizeof(ROMfullName));
|
||||||
|
|
||||||
if (
|
if (
|
||||||
// ??? in all Homebrews game title have is 2E0000EA
|
// ??? in all Homebrews game title have is 2E0000EA
|
||||||
//(
|
//(
|
||||||
|
@ -290,16 +308,28 @@ void GameInfo::populate()
|
||||||
header.makerCode == 0x0
|
header.makerCode == 0x0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
memset(ROMserial, 0, sizeof(ROMserial));
|
|
||||||
strcpy(ROMserial, "Homebrew");
|
strcpy(ROMserial, "Homebrew");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(ROMserial, '_', sizeof(ROMserial));
|
strcpy(ROMserial,"NTR- -");
|
||||||
memcpy(ROMserial, header.gameTile, strlen(header.gameTile) < 12 ? strlen(header.gameTile) : 12);
|
memcpy(ROMserial+4, header.gameCode, 4);
|
||||||
memcpy(ROMserial+12+1, header.gameCode, 4);
|
|
||||||
memcpy(ROMserial+12+1+4, &header.makerCode, 2);
|
u32 region = (u32)(std::max<s32>(strchr(regions[0],header.gameCode[3]) - regions[0] + 1, 0));
|
||||||
memset(ROMserial+19, '\0', 1);
|
if (region != 0)
|
||||||
|
strcat(ROMserial, regions[region]);
|
||||||
|
else
|
||||||
|
strcat(ROMserial, "Unknown");
|
||||||
|
memcpy(ROMname, header.gameTile, 12);
|
||||||
|
trim(ROMname);
|
||||||
|
|
||||||
|
u8 num = (T1ReadByte((u8*)romdata, header.IconOff) == 1)?6:7;
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
wcstombs(ROMfullName[i], (wchar_t *)(romdata+header.IconOff+0x240+(i*0x100)), 0x100);
|
||||||
|
trim(ROMfullName[i]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -408,8 +438,9 @@ int NDS_LoadROM(const char *filename, const char *logicalFilename)
|
||||||
|
|
||||||
gameInfo.populate();
|
gameInfo.populate();
|
||||||
gameInfo.crc = crc32(0,(u8*)gameInfo.romdata,gameInfo.romsize);
|
gameInfo.crc = crc32(0,(u8*)gameInfo.romdata,gameInfo.romsize);
|
||||||
INFO("\nROM crc: %08X\n\n", gameInfo.crc);
|
INFO("\nROM crc: %08X\n", gameInfo.crc);
|
||||||
INFO("\nROM serial: %s\n", gameInfo.ROMserial);
|
INFO("ROM serial: %s\n", gameInfo.ROMserial);
|
||||||
|
INFO("ROM internal name: %s\n\n", gameInfo.ROMname);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -528,8 +559,9 @@ int NDS_LoadROM(const char *filename, const char *logicalFilename)
|
||||||
|
|
||||||
gameInfo.populate();
|
gameInfo.populate();
|
||||||
gameInfo.crc = crc32(0,data,size);
|
gameInfo.crc = crc32(0,data,size);
|
||||||
INFO("\nROM crc: %08X\n\n", gameInfo.crc);
|
INFO("\nROM crc: %08X\n", gameInfo.crc);
|
||||||
INFO("\nROM serial: %s\n", gameInfo.ROMserial);
|
INFO("ROM serial: %s\n", gameInfo.ROMserial);
|
||||||
|
INFO("ROM internal name: %s\n\n", gameInfo.ROMname);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,6 +284,8 @@ struct GameInfo
|
||||||
u32 crc;
|
u32 crc;
|
||||||
NDS_header header;
|
NDS_header header;
|
||||||
char ROMserial[20];
|
char ROMserial[20];
|
||||||
|
char ROMname[20];
|
||||||
|
char ROMfullName[7][0x100];
|
||||||
void populate();
|
void populate();
|
||||||
char* romdata;
|
char* romdata;
|
||||||
int romsize;
|
int romsize;
|
||||||
|
|
|
@ -543,8 +543,12 @@ BOOL CHEATS::save()
|
||||||
if (flist)
|
if (flist)
|
||||||
{
|
{
|
||||||
fprintf(flist, "; DeSmuME cheats file. VERSION %i.%03i\n", CHEAT_VERSION_MAJOR, CHEAT_VERSION_MINOR);
|
fprintf(flist, "; DeSmuME cheats file. VERSION %i.%03i\n", CHEAT_VERSION_MAJOR, CHEAT_VERSION_MINOR);
|
||||||
fprintf(flist, "Name=%s\n", gameInfo.ROMserial);
|
strcpy(buf, gameInfo.ROMfullName[0]);
|
||||||
fputs("; lists list\n", flist);
|
trim(buf);
|
||||||
|
removeSpecialChars(buf);
|
||||||
|
fprintf(flist, "Name=%s\n", buf);
|
||||||
|
fprintf(flist, "Serial=%s\n", gameInfo.ROMserial);
|
||||||
|
fputs("\n; lists list\n", flist);
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
if (list[i].num == 0) continue;
|
if (list[i].num == 0) continue;
|
||||||
|
@ -610,7 +614,7 @@ BOOL CHEATS::load()
|
||||||
line++; // only for debug
|
line++; // only for debug
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
fgets(buf, sizeof(buf), flist);
|
fgets(buf, sizeof(buf), flist);
|
||||||
strcpy(buf, trim(buf));
|
trim(buf);
|
||||||
if ((strlen(buf) == 0) || (buf[0] == ';')) continue;
|
if ((strlen(buf) == 0) || (buf[0] == ';')) continue;
|
||||||
|
|
||||||
memset(&tmp_cht, 0, sizeof(tmp_cht));
|
memset(&tmp_cht, 0, sizeof(tmp_cht));
|
||||||
|
|
|
@ -61,3 +61,21 @@ char *trim(char *s)
|
||||||
ptr[1] = '\0';
|
ptr[1] = '\0';
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *removeSpecialChars(char *s)
|
||||||
|
{
|
||||||
|
char *buf = s;
|
||||||
|
if (!s) return NULL;
|
||||||
|
if (!*s) return s;
|
||||||
|
|
||||||
|
for (int i = 0; i < strlen(s); i++)
|
||||||
|
{
|
||||||
|
if (isspace(s[i]) && (s[i] != 0x20))
|
||||||
|
*buf = 0x20;
|
||||||
|
else
|
||||||
|
*buf = s[i];
|
||||||
|
buf++;
|
||||||
|
}
|
||||||
|
*buf = 0;
|
||||||
|
return s;
|
||||||
|
}
|
|
@ -57,6 +57,7 @@ extern u8 logo_data[156];
|
||||||
|
|
||||||
extern u8 reverseBitsInByte(u8 x);
|
extern u8 reverseBitsInByte(u8 x);
|
||||||
extern char *trim(char *s);
|
extern char *trim(char *s);
|
||||||
|
extern char *removeSpecialChars(char *s);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
/* Copyright (C) 2006 yopyop
|
/* Copyright 2008-2009 DeSmuME team
|
||||||
Copyright (C) 2008 CrazyMax (mtabachenko)
|
|
||||||
Copyright (C) 2009 DeSmuME team
|
|
||||||
|
|
||||||
This file is part of DeSmuME
|
This file is part of DeSmuME
|
||||||
|
|
||||||
|
@ -16,7 +14,7 @@
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with DeSmuME; if not, write to the Free Software
|
along with DeSmuME; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
@ -34,10 +32,10 @@ void printlog(const char *fmt, ...);
|
||||||
|
|
||||||
void OpenConsole()
|
void OpenConsole()
|
||||||
{
|
{
|
||||||
COORD csize;
|
COORD csize = {0};
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
|
CONSOLE_SCREEN_BUFFER_INFO csbiInfo = {0};
|
||||||
SMALL_RECT srect;
|
SMALL_RECT srect = {0};
|
||||||
char buf[256];
|
char buf[256] = {0};
|
||||||
|
|
||||||
//dont do anything if we're already attached
|
//dont do anything if we're already attached
|
||||||
if (hConsole) return;
|
if (hConsole) return;
|
||||||
|
@ -61,40 +59,42 @@ void OpenConsole()
|
||||||
//if we failed to attach, then alloc a new console
|
//if we failed to attach, then alloc a new console
|
||||||
if(!attached)
|
if(!attached)
|
||||||
{
|
{
|
||||||
AllocConsole();
|
if (!AllocConsole()) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
|
if (hConsole == INVALID_HANDLE_VALUE) return;
|
||||||
//redirect stdio
|
//redirect stdio
|
||||||
long lStdHandle = (long)hConsole;
|
long lStdHandle = (long)hConsole;
|
||||||
int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
|
int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
|
||||||
if(hConHandle == -1)
|
if(hConHandle == -1)
|
||||||
return; //this fails from a visual studio command prompt
|
return; //this fails from a visual studio command prompt
|
||||||
|
|
||||||
|
#if 1
|
||||||
FILE *fp = _fdopen( hConHandle, "w" );
|
FILE *fp = _fdopen( hConHandle, "w" );
|
||||||
|
#else
|
||||||
|
FILE *fp = fopen( "c:\\desmume.log", "w" );
|
||||||
|
#endif
|
||||||
*stdout = *fp;
|
*stdout = *fp;
|
||||||
//and stderr
|
//and stderr
|
||||||
*stderr = *fp;
|
*stderr = *fp;
|
||||||
|
|
||||||
memset(buf,0,256);
|
|
||||||
sprintf(buf,"%s OUTPUT", EMU_DESMUME_NAME_AND_VERSION());
|
sprintf(buf,"%s OUTPUT", EMU_DESMUME_NAME_AND_VERSION());
|
||||||
SetConsoleTitle(TEXT(buf));
|
SetConsoleTitle(TEXT(buf));
|
||||||
csize.X = 60;
|
csize.X = 60;
|
||||||
csize.Y = 800;
|
csize.Y = 800;
|
||||||
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csize);
|
SetConsoleScreenBufferSize(hConsole, csize);
|
||||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo);
|
GetConsoleScreenBufferInfo(hConsole, &csbiInfo);
|
||||||
srect = csbiInfo.srWindow;
|
srect = csbiInfo.srWindow;
|
||||||
srect.Right = srect.Left + 99;
|
srect.Right = srect.Left + 99;
|
||||||
srect.Bottom = srect.Top + 64;
|
srect.Bottom = srect.Top + 64;
|
||||||
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &srect);
|
SetConsoleWindowInfo(hConsole, TRUE, &srect);
|
||||||
SetConsoleCP(GetACP());
|
SetConsoleCP(GetACP());
|
||||||
SetConsoleOutputCP(GetACP());
|
SetConsoleOutputCP(GetACP());
|
||||||
if(attached) printlog("\n");
|
if(attached) printlog("\n");
|
||||||
printlog("%s\n",EMU_DESMUME_NAME_AND_VERSION());
|
printlog("%s\n",EMU_DESMUME_NAME_AND_VERSION());
|
||||||
printlog("- compiled: %s %s\n\n",__DATE__,__TIME__);
|
printlog("- compiled: %s %s\n\n",__DATE__,__TIME__);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseConsole() {
|
void CloseConsole() {
|
||||||
|
|
|
@ -23,12 +23,41 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <algorithm>
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
|
|
||||||
CHEATS_LIST list[MAX_CHEAT_LIST] = {0};
|
CHEATS_LIST list[MAX_CHEAT_LIST] = {0};
|
||||||
u32 num = 0;
|
u32 num = 0;
|
||||||
char ROMserial[50] = {0};
|
char ROMserial[50] = {0};
|
||||||
|
|
||||||
|
static void convertSerial()
|
||||||
|
{
|
||||||
|
const char *regions[] = { "JPFSEDIRKH",
|
||||||
|
"JPN",
|
||||||
|
"EUR",
|
||||||
|
"FRA",
|
||||||
|
"ESP",
|
||||||
|
"USA",
|
||||||
|
"NOE",
|
||||||
|
"ITA",
|
||||||
|
"RUS",
|
||||||
|
"KOR",
|
||||||
|
"HOL",
|
||||||
|
|
||||||
|
};
|
||||||
|
char buf[5] = {0};
|
||||||
|
|
||||||
|
if (!ROMserial[0]) return;
|
||||||
|
|
||||||
|
memcpy(buf, &ROMserial[strlen(ROMserial)-6], 4);
|
||||||
|
sprintf(ROMserial, "NTR-%s-", buf);
|
||||||
|
u32 region = (u32)(std::max<s32>(strchr(regions[0], buf[3]) - regions[0] + 1, 0));
|
||||||
|
if (region != 0)
|
||||||
|
strcat(ROMserial, regions[region]);
|
||||||
|
else
|
||||||
|
memset(ROMserial, 0, sizeof(ROMserial));
|
||||||
|
}
|
||||||
|
|
||||||
static void cheatsClear()
|
static void cheatsClear()
|
||||||
{
|
{
|
||||||
memset(list, 0, sizeof(list));
|
memset(list, 0, sizeof(list));
|
||||||
|
@ -47,8 +76,9 @@ bool save(char *filename)
|
||||||
if (flist)
|
if (flist)
|
||||||
{
|
{
|
||||||
fprintf(flist, "; DeSmuME cheat file. VERSION %i.%03i\n", CHEAT_VERSION_MAJOR, CHEAT_VERSION_MINOR);
|
fprintf(flist, "; DeSmuME cheat file. VERSION %i.%03i\n", CHEAT_VERSION_MAJOR, CHEAT_VERSION_MINOR);
|
||||||
fprintf(flist, "Name=%s\n", ROMserial);
|
fprintf(flist, "Name=\n");
|
||||||
fputs("; lists list\n", flist);
|
fprintf(flist, "Serial=%s\n", ROMserial);
|
||||||
|
fputs("\n; lists list\n", flist);
|
||||||
for (unsigned int i = 0; i < num; i++)
|
for (unsigned int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
if (list[i].num == 0) continue;
|
if (list[i].num == 0) continue;
|
||||||
|
@ -199,6 +229,8 @@ bool load_1_3(char *fname)
|
||||||
|
|
||||||
//INFO("Loaded %i cheats\n", last);
|
//INFO("Loaded %i cheats\n", last);
|
||||||
num = last;
|
num = last;
|
||||||
|
|
||||||
|
convertSerial();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue