Added GBA ROM information parsed from No-Intro dat files. The No-Intro dats (Standard and Scene) are to be unzipped into the directory where the vbam.ini file is.

This commit is contained in:
skidau 2015-05-15 14:53:52 +00:00
parent f2274347ae
commit 516b819143
6 changed files with 167 additions and 12 deletions

View File

@ -462,6 +462,12 @@ static bool maker_lt(const rom_maker &r1, const rom_maker &r2)
return wxStrcmp(r1.code, r2.code) < 0;
}
void SetDialogLabel(wxDialog* dlg, wxChar* id, wxString ts, size_t l)
{
ts.Replace(wxT("&"), wxT("&&"), true);
(dynamic_cast<wxControl*>((*dlg).FindWindow(wxXmlResource::GetXRCID(id))))->SetLabel(ts);
}
EVT_HANDLER_MASK(RomInformation, "ROM information...", CMDEN_GB | CMDEN_GBA)
{
wxString s;
@ -719,8 +725,15 @@ EVT_HANDLER_MASK(RomInformation, "ROM information...", CMDEN_GB | CMDEN_GBA)
case IMAGE_GBA:
{
IdentifyRom();
wxDialog* dlg = GetXRCDialog("GBAROMInfo");
setlabs("Title", rom[0xa0], 12);
wxString rom_crc32;
rom_crc32.Printf(wxT("%08X"), panel->rom_crc32);
SetDialogLabel(dlg, wxT("Title"), panel->rom_name, 30);
setlabs("IntTitle", rom[0xa0], 12);
SetDialogLabel(dlg, wxT("Scene"), panel->rom_scene_rls_name, 30);
SetDialogLabel(dlg, wxT("Release"), panel->rom_scene_rls, 4);
SetDialogLabel(dlg, wxT("CRC32"), rom_crc32, 8);
setlabs("GameCode", rom[0xac], 4);
setlabs("MakerCode", rom[0xb0], 2);
const rom_maker m = { s.c_str() }, *rm;

View File

@ -31,6 +31,9 @@ GameArea::GameArea()
void GameArea::LoadGame(const wxString &name)
{
rom_scene_rls = wxT("-");
rom_scene_rls_name = wxT("-");
rom_name = wxT("");
// fex just crashes if file does not exist and it's compressed,
// so check first
wxFileName fnfn(name);
@ -221,6 +224,8 @@ void GameArea::LoadGame(const wxString &name)
return;
}
rom_crc32 = crc32(0L, rom, rom_size);
if (loadpatch)
{
// don't use real rom size or it might try to resize rom[]
@ -233,13 +238,6 @@ void GameArea::LoadGame(const wxString &name)
// that means we no longer really know rom_size either <sigh>
}
#if 0 // disabled in win32 version for undocumented "problems"
// FIXME: store original value
if (gopts.skip_intro)
*((u32*)rom) = 0xea00002e;
#endif
wxFileConfig* cfg = wxGetApp().overrides;
wxString id = wxString((const char*)&rom[0xac], wxConvLibc, 4);

View File

@ -1,5 +1,5 @@
cd ..\..\src\wx
..\..\..\dependencies\AStyle\bin\astyle --recursive --style=allman --indent=tab=4 --align-pointer=type --align-reference=name --break-blocks --pad-oper --pad-header --unpad-paren --delete-empty-lines --break-closing-brackets --keep-one-line-blocks --keep-one-line-statements --convert-tabs --remove-comment-prefix --mode=c *.cpp *.h
..\..\..\dependencies\AStyle\bin\astyle --recursive -n --style=allman --indent=tab=4 --align-pointer=type --align-reference=name --break-blocks --pad-oper --pad-header --unpad-paren --delete-empty-lines --break-closing-brackets --keep-one-line-blocks --keep-one-line-statements --convert-tabs --remove-comment-prefix --mode=c *.cpp *.h
cmake -P copy-events.cmake
..\..\..\dependencies\wxrc xrc\*.xrc -o wxvbam.xrs
..\..\..\dependencies\bin2c wxvbam.xrs builtin-xrc.h builtin_xrs

View File

@ -12,6 +12,7 @@
#include <wx/wfstream.h>
#include <wx/mstream.h>
#include <wx/sstream.h>
#include <wx/txtstrm.h>
#include <wx/cmdline.h>
#include <wx/regex.h>
@ -195,6 +196,27 @@ bool wxvbamApp::OnInit()
for (int i = config_path.size() - 1; i >= 0 ; i--)
{
wxFileName fn(config_path[i], wxT("vba-over.ini"));
wxFileName rdb(config_path[i], wxT("Nintendo - Game Boy Advance*.dat"));
wxFileName scene_rdb(config_path[i], wxT("Nintendo - Game Boy Advance (Scene)*.dat"));
wxString f = wxFindFirstFile(scene_rdb.GetFullPath(), wxFILE);
if (!f.empty() && wxFileName(f).IsFileReadable())
rom_database_scene = f;
f = wxFindFirstFile(rdb.GetFullPath(), wxFILE);
while (!f.empty())
{
if (f == rom_database_scene.GetFullPath())
{
f = wxFindNextFile();
}
else if (wxFileName(f).IsFileReadable())
{
rom_database = f;
break;
}
}
if (!fn.IsFileReadable())
continue;
@ -844,6 +866,66 @@ LinkMode MainFrame::GetConfiguredLinkMode()
return LINK_DISCONNECTED;
}
void MainFrame::IdentifyRom()
{
if (!panel->rom_name.empty())
return;
panel->rom_name = panel->loaded_game.GetFullName();
wxString name;
wxString scene_rls;
wxString scene_name;
wxString rom_crc32_str;
rom_crc32_str.Printf(_("crc %08X"), panel->rom_crc32);
if (wxGetApp().rom_database_scene.FileExists())
{
wxFileInputStream input(wxGetApp().rom_database_scene.GetFullPath());
wxTextInputStream text(input, wxT("\x09"), wxConvUTF8);
while (input.IsOk() && !input.Eof())
{
wxString line = text.ReadLine();
if (line.StartsWith(wxT("\tname")))
{
scene_rls = line.AfterFirst('[').BeforeFirst(']');
scene_name = line.AfterLast(' ').BeforeLast('"');
}
if (line.StartsWith(wxT("\trom")) && line.Contains(rom_crc32_str))
{
panel->rom_scene_rls = scene_rls;
panel->rom_scene_rls_name = scene_name;
panel->rom_name = scene_name;
break;
}
}
}
if (wxGetApp().rom_database.FileExists())
{
wxFileInputStream input(wxGetApp().rom_database.GetFullPath());
wxTextInputStream text(input, wxT("\x09"), wxConvUTF8);
while (input.IsOk() && !input.Eof())
{
wxString line = text.ReadLine();
if (line.StartsWith(wxT("\tname")))
{
name = line.AfterFirst('"').BeforeLast('"');
}
if (line.StartsWith(wxT("\trom")) && line.Contains(rom_crc32_str))
{
panel->rom_name = name;
break;
}
}
}
}
// global event filter
// apparently required for win32; just setting accel table still misses
// a few keys (e.g. only ctrl-x works for exit, but not esc & ctrl-q;

View File

@ -78,6 +78,10 @@ public:
wxFileConfig* cfg;
// vba-over.ini
wxFileConfig* overrides;
wxFileName rom_database;
wxFileName rom_database_scene;
MainFrame* frame;
// use this to get ms since program lauch
wxStopWatch timer;
@ -228,6 +232,8 @@ public:
// Returns the link mode to set according to the options
LinkMode GetConfiguredLinkMode();
void IdentifyRom();
// Start GDB listener
void GDBBreak();
@ -429,6 +435,16 @@ public:
char* rewind_mem; // should be u8, really
int num_rewind_states;
int next_rewind_state;
// Loaded rom information
IMAGE_TYPE loaded;
wxFileName loaded_game;
u32 rom_crc32;
wxString rom_name;
wxString rom_scene_rls;
wxString rom_scene_rls_name;
u32 rom_size;
// FIXME: size this properly
#define REWIND_SIZE 400000
// FIXME: make this a config option
@ -458,9 +474,6 @@ protected:
// set minsize of frame & panel to scaled screen size
void AdjustMinSize();
IMAGE_TYPE loaded;
u32 rom_size;
wxFileName loaded_game;
wxString batdir, statedir;
int basic_width, basic_height;

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
<object class="wxDialog" name="GBAROMInfo">
<title>Rom Information</title>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
@ -17,6 +18,54 @@
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Internal title:</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="IntTitle"/>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Scene Release:</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="Scene"/>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Release Number:</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="Release"/>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>CRC32:</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="CRC32"/>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Game code:</label>