diff --git a/src/wx/cmdevents.cpp b/src/wx/cmdevents.cpp index 0094a300..166eeda9 100644 --- a/src/wx/cmdevents.cpp +++ b/src/wx/cmdevents.cpp @@ -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((*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; diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index b492b7b2..d057977e 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -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 } -#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); diff --git a/src/wx/pre-build.cmd b/src/wx/pre-build.cmd index d9eeb35f..22b84aa4 100644 --- a/src/wx/pre-build.cmd +++ b/src/wx/pre-build.cmd @@ -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 diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 66d62b73..87532a0a 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -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; diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index 45c88f29..9583dd76 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -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; diff --git a/src/wx/xrc/GBAROMInfo.xrc b/src/wx/xrc/GBAROMInfo.xrc index c77ab8f4..e120c668 100644 --- a/src/wx/xrc/GBAROMInfo.xrc +++ b/src/wx/xrc/GBAROMInfo.xrc @@ -1,6 +1,7 @@ + Rom Information wxVERTICAL @@ -17,6 +18,54 @@ wxALL 5 + + + + + wxALL + 5 + + + + wxALL + 5 + + + + + + wxALL + 5 + + + + wxALL + 5 + + + + + + wxALL + 5 + + + + wxALL + 5 + + + + + + wxALL + 5 + + + + wxALL + 5 +