Move the GB ROM Info dialog to its own class

* Move the Game Maker information to a separate helper method.
* Make the dialog strings more localizable.
This commit is contained in:
Fabrice de Gans 2023-03-26 15:28:04 -07:00 committed by Fabrice de Gans
parent d1f6500098
commit bad388e0aa
9 changed files with 930 additions and 801 deletions

File diff suppressed because it is too large Load Diff

View File

@ -771,6 +771,8 @@ set(
dialogs/directories-config.cpp
dialogs/display-config.cpp
dialogs/game-boy-config.cpp
dialogs/game-maker.cpp
dialogs/gb-rom-info.cpp
widgets/group-check-box.cpp
widgets/keep-on-top-styler.cpp
widgets/option-validator.cpp
@ -822,6 +824,8 @@ set(
dialogs/directories-config.h
dialogs/display-config.h
dialogs/game-boy-config.h
dialogs/game-maker.h
dialogs/gb-rom-info.h
dialogs/validated-child.h
widgets/dpi-support.h
widgets/group-check-box.h

View File

@ -1,6 +1,7 @@
#include "wxvbam.h"
#include <algorithm>
#include <wx/aboutdlg.h>
#include <wx/ffile.h>
#include <wx/numdlg.h>
@ -16,14 +17,10 @@
#include "../gba/agbprint.h"
#include "config/option-proxy.h"
#include "config/option.h"
#include "dialogs/game-maker.h"
#if (wxMAJOR_VERSION < 3)
#define GetXRCDialog(n) \
wxStaticCast(wxGetApp().frame->FindWindow(XRCID(n)), wxDialog)
#else
#define GetXRCDialog(n) \
wxStaticCast(wxGetApp().frame->FindWindowByName(n), wxDialog)
#endif
bool cmditem_lt(const struct cmditem& cmd1, const struct cmditem& cmd2)
{
@ -280,236 +277,6 @@ EVT_HANDLER(wxID_FILE10, "Load recent ROM 10")
panel->LoadGame(gopts.recent->GetHistoryFile(9));
}
static const struct rom_maker {
const wxString code, name;
} makers[] = {
{ wxT("01"), wxT("Nintendo") },
{ wxT("02"), wxT("Rocket Games") },
{ wxT("08"), wxT("Capcom") },
{ wxT("09"), wxT("Hot B Co.") },
{ wxT("0A"), wxT("Jaleco") },
{ wxT("0B"), wxT("Coconuts Japan") },
{ wxT("0C"), wxT("Coconuts Japan/G.X.Media") },
{ wxT("0H"), wxT("Starfish") },
{ wxT("0L"), wxT("Warashi Inc.") },
{ wxT("0N"), wxT("Nowpro") },
{ wxT("0P"), wxT("Game Village") },
{ wxT("13"), wxT("Electronic Arts Japan") },
{ wxT("18"), wxT("Hudson Soft Japan") },
{ wxT("19"), wxT("S.C.P.") },
{ wxT("1A"), wxT("Yonoman") },
{ wxT("1G"), wxT("SMDE") },
{ wxT("1P"), wxT("Creatures Inc.") },
{ wxT("1Q"), wxT("TDK Deep Impresion") },
{ wxT("20"), wxT("Destination Software") },
{ wxT("22"), wxT("VR 1 Japan") },
{ wxT("25"), wxT("San-X") },
{ wxT("28"), wxT("Kemco Japan") },
{ wxT("29"), wxT("Seta") },
{ wxT("2H"), wxT("Ubisoft Japan") },
{ wxT("2K"), wxT("NEC InterChannel") },
{ wxT("2L"), wxT("Tam") },
{ wxT("2M"), wxT("Jordan") },
{ wxT("2N"), wxT("Smilesoft") },
{ wxT("2Q"), wxT("Mediakite") },
{ wxT("36"), wxT("Codemasters") },
{ wxT("37"), wxT("GAGA Communications") },
{ wxT("38"), wxT("Laguna") },
{ wxT("39"), wxT("Telstar Fun and Games") },
{ wxT("41"), wxT("Ubi Soft Entertainment") },
{ wxT("42"), wxT("Sunsoft") },
{ wxT("47"), wxT("Spectrum Holobyte") },
{ wxT("49"), wxT("IREM") },
{ wxT("4D"), wxT("Malibu Games") },
{ wxT("4F"), wxT("Eidos/U.S. Gold") },
{ wxT("4J"), wxT("Fox Interactive") },
{ wxT("4K"), wxT("Time Warner Interactive") },
{ wxT("4Q"), wxT("Disney") },
{ wxT("4S"), wxT("Black Pearl") },
{ wxT("4X"), wxT("GT Interactive") },
{ wxT("4Y"), wxT("RARE") },
{ wxT("4Z"), wxT("Crave Entertainment") },
{ wxT("50"), wxT("Absolute Entertainment") },
{ wxT("51"), wxT("Acclaim") },
{ wxT("52"), wxT("Activision") },
{ wxT("53"), wxT("American Sammy Corp.") },
{ wxT("54"), wxT("Take 2 Interactive") },
{ wxT("55"), wxT("Hi Tech") },
{ wxT("56"), wxT("LJN LTD.") },
{ wxT("58"), wxT("Mattel") },
{ wxT("5A"), wxT("Mindscape/Red Orb Ent.") },
{ wxT("5C"), wxT("Taxan") },
{ wxT("5D"), wxT("Midway") },
{ wxT("5F"), wxT("American Softworks") },
{ wxT("5G"), wxT("Majesco Sales Inc") },
{ wxT("5H"), wxT("3DO") },
{ wxT("5K"), wxT("Hasbro") },
{ wxT("5L"), wxT("NewKidCo") },
{ wxT("5M"), wxT("Telegames") },
{ wxT("5N"), wxT("Metro3D") },
{ wxT("5P"), wxT("Vatical Entertainment") },
{ wxT("5Q"), wxT("LEGO Media") },
{ wxT("5S"), wxT("Xicat Interactive") },
{ wxT("5T"), wxT("Cryo Interactive") },
{ wxT("5W"), wxT("Red Storm Ent./BKN Ent.") },
{ wxT("5X"), wxT("Microids") },
{ wxT("5Z"), wxT("Conspiracy Entertainment Corp.") },
{ wxT("60"), wxT("Titus Interactive Studios") },
{ wxT("61"), wxT("Virgin Interactive") },
{ wxT("62"), wxT("Maxis") },
{ wxT("64"), wxT("LucasArts Entertainment") },
{ wxT("67"), wxT("Ocean") },
{ wxT("69"), wxT("Electronic Arts") },
{ wxT("6E"), wxT("Elite Systems Ltd.") },
{ wxT("6F"), wxT("Electro Brain") },
{ wxT("6G"), wxT("The Learning Company") },
{ wxT("6H"), wxT("BBC") },
{ wxT("6J"), wxT("Software 2000") },
{ wxT("6L"), wxT("BAM! Entertainment") },
{ wxT("6M"), wxT("Studio 3") },
{ wxT("6Q"), wxT("Classified Games") },
{ wxT("6S"), wxT("TDK Mediactive") },
{ wxT("6U"), wxT("DreamCatcher") },
{ wxT("6V"), wxT("JoWood Productions") },
{ wxT("6W"), wxT("SEGA") },
{ wxT("6X"), wxT("Wannado Edition") },
{ wxT("6Y"), wxT("LSP") },
{ wxT("6Z"), wxT("ITE Media") },
{ wxT("70"), wxT("Infogrames") },
{ wxT("71"), wxT("Interplay") },
{ wxT("72"), wxT("JVC Musical Industries Inc") },
{ wxT("73"), wxT("Parker Brothers") },
{ wxT("75"), wxT("SCI") },
{ wxT("78"), wxT("THQ") },
{ wxT("79"), wxT("Accolade") },
{ wxT("7A"), wxT("Triffix Ent. Inc.") },
{ wxT("7C"), wxT("Microprose Software") },
{ wxT("7D"), wxT("Universal Interactive Studios") },
{ wxT("7F"), wxT("Kemco") },
{ wxT("7G"), wxT("Rage Software") },
{ wxT("7H"), wxT("Encore") },
{ wxT("7J"), wxT("Zoo") },
{ wxT("7K"), wxT("BVM") },
{ wxT("7L"), wxT("Simon & Schuster Interactive") },
{ wxT("7M"), wxT("Asmik Ace Entertainment Inc./AIA") },
{ wxT("7N"), wxT("Empire Interactive") },
{ wxT("7Q"), wxT("Jester Interactive") },
{ wxT("7T"), wxT("Scholastic") },
{ wxT("7U"), wxT("Ignition Entertainment") },
{ wxT("7W"), wxT("Stadlbauer") },
{ wxT("80"), wxT("Misawa") },
{ wxT("83"), wxT("LOZC") },
{ wxT("8B"), wxT("Bulletproof Software") },
{ wxT("8C"), wxT("Vic Tokai Inc.") },
{ wxT("8J"), wxT("General Entertainment") },
{ wxT("8N"), wxT("Success") },
{ wxT("8P"), wxT("SEGA Japan") },
{ wxT("91"), wxT("Chun Soft") },
{ wxT("92"), wxT("Video System") },
{ wxT("93"), wxT("BEC") },
{ wxT("96"), wxT("Yonezawa/S'pal") },
{ wxT("97"), wxT("Kaneko") },
{ wxT("99"), wxT("Victor Interactive Software") },
{ wxT("9A"), wxT("Nichibutsu/Nihon Bussan") },
{ wxT("9B"), wxT("Tecmo") },
{ wxT("9C"), wxT("Imagineer") },
{ wxT("9F"), wxT("Nova") },
{ wxT("9H"), wxT("Bottom Up") },
{ wxT("9L"), wxT("Hasbro Japan") },
{ wxT("9N"), wxT("Marvelous Entertainment") },
{ wxT("9P"), wxT("Keynet Inc.") },
{ wxT("9Q"), wxT("Hands-On Entertainment") },
{ wxT("A0"), wxT("Telenet") },
{ wxT("A1"), wxT("Hori") },
{ wxT("A4"), wxT("Konami") },
{ wxT("A6"), wxT("Kawada") },
{ wxT("A7"), wxT("Takara") },
{ wxT("A9"), wxT("Technos Japan Corp.") },
{ wxT("AA"), wxT("JVC") },
{ wxT("AC"), wxT("Toei Animation") },
{ wxT("AD"), wxT("Toho") },
{ wxT("AF"), wxT("Namco") },
{ wxT("AG"), wxT("Media Rings Corporation") },
{ wxT("AH"), wxT("J-Wing") },
{ wxT("AK"), wxT("KID") },
{ wxT("AL"), wxT("MediaFactory") },
{ wxT("AP"), wxT("Infogrames Hudson") },
{ wxT("AQ"), wxT("Kiratto. Ludic Inc") },
{ wxT("B0"), wxT("Acclaim Japan") },
{ wxT("B1"), wxT("ASCII") },
{ wxT("B2"), wxT("Bandai") },
{ wxT("B4"), wxT("Enix") },
{ wxT("B6"), wxT("HAL Laboratory") },
{ wxT("B7"), wxT("SNK") },
{ wxT("B9"), wxT("Pony Canyon Hanbai") },
{ wxT("BA"), wxT("Culture Brain") },
{ wxT("BB"), wxT("Sunsoft") },
{ wxT("BD"), wxT("Sony Imagesoft") },
{ wxT("BF"), wxT("Sammy") },
{ wxT("BG"), wxT("Magical") },
{ wxT("BJ"), wxT("Compile") },
{ wxT("BL"), wxT("MTO Inc.") },
{ wxT("BN"), wxT("Sunrise Interactive") },
{ wxT("BP"), wxT("Global A Entertainment") },
{ wxT("BQ"), wxT("Fuuki") },
{ wxT("C0"), wxT("Taito") },
{ wxT("C2"), wxT("Kemco") },
{ wxT("C3"), wxT("Square Soft") },
{ wxT("C5"), wxT("Data East") },
{ wxT("C6"), wxT("Tonkin House") },
{ wxT("C8"), wxT("Koei") },
{ wxT("CA"), wxT("Konami/Palcom/Ultra") },
{ wxT("CB"), wxT("Vapinc/NTVIC") },
{ wxT("CC"), wxT("Use Co.,Ltd.") },
{ wxT("CD"), wxT("Meldac") },
{ wxT("CE"), wxT("FCI/Pony Canyon") },
{ wxT("CF"), wxT("Angel") },
{ wxT("CM"), wxT("Konami Computer Entertainment Osaka") },
{ wxT("CP"), wxT("Enterbrain") },
{ wxT("D1"), wxT("Sofel") },
{ wxT("D2"), wxT("Quest") },
{ wxT("D3"), wxT("Sigma Enterprises") },
{ wxT("D4"), wxT("Ask Kodansa") },
{ wxT("D6"), wxT("Naxat") },
{ wxT("D7"), wxT("Copya System") },
{ wxT("D9"), wxT("Banpresto") },
{ wxT("DA"), wxT("TOMY") },
{ wxT("DB"), wxT("LJN Japan") },
{ wxT("DD"), wxT("NCS") },
{ wxT("DF"), wxT("Altron Corporation") },
{ wxT("DH"), wxT("Gaps Inc.") },
{ wxT("DN"), wxT("ELF") },
{ wxT("E2"), wxT("Yutaka") },
{ wxT("E3"), wxT("Varie") },
{ wxT("E5"), wxT("Epoch") },
{ wxT("E7"), wxT("Athena") },
{ wxT("E8"), wxT("Asmik Ace Entertainment Inc.") },
{ wxT("E9"), wxT("Natsume") },
{ wxT("EA"), wxT("King Records") },
{ wxT("EB"), wxT("Atlus") },
{ wxT("EC"), wxT("Epic/Sony Records") },
{ wxT("EE"), wxT("IGS") },
{ wxT("EL"), wxT("Spike") },
{ wxT("EM"), wxT("Konami Computer Entertainment Tokyo") },
{ wxT("EN"), wxT("Alphadream Corporation") },
{ wxT("F0"), wxT("A Wave") },
{ wxT("G1"), wxT("PCCW") },
{ wxT("G4"), wxT("KiKi Co Ltd") },
{ wxT("G5"), wxT("Open Sesame Inc.") },
{ wxT("G6"), wxT("Sims") },
{ wxT("G7"), wxT("Broccoli") },
{ wxT("G8"), wxT("Avex") },
{ wxT("G9"), wxT("D3 Publisher") },
{ wxT("GB"), wxT("Konami Computer Entertainment Japan") },
{ wxT("GD"), wxT("Square-Enix") },
{ wxT("HY"), wxT("Sachen") }
};
#define num_makers (sizeof(makers) / sizeof(makers[0]))
static bool maker_lt(const rom_maker& r1, const rom_maker& r2)
{
return wxStrcmp(r1.code, r2.code) < 0;
}
void SetDialogLabel(wxDialog* dlg, const wxString& id, wxString ts, size_t l)
{
(void)l; // unused params
@ -532,11 +299,6 @@ EVT_HANDLER_MASK(RomInformation, "ROM information...", CMDEN_GB | CMDEN_GBA)
s.Printf(wxT("%02x"), (unsigned int)b); \
setlab(id); \
} while (0)
#define setblabs(id, b, ts) \
do { \
s.Printf(wxT("%02x (%s)"), (unsigned int)b, ts.c_str()); \
setlab(id); \
} while (0)
#define setlabs(id, ts, l) \
do { \
s = wxString((const char*)&(ts), wxConvLibc, l); \
@ -544,221 +306,9 @@ EVT_HANDLER_MASK(RomInformation, "ROM information...", CMDEN_GB | CMDEN_GBA)
} while (0)
switch (panel->game_type()) {
case IMAGE_GB: {
wxDialog* dlg = GetXRCDialog("GBROMInfo");
setlabs("Title", gbRom[0x134], 15);
setblab("Color", gbRom[0x143]);
if (gbRom[0x14b] == 0x33)
s = wxString((const char*)&gbRom[0x144], wxConvUTF8, 2);
else
s.Printf(wxT("%02x"), gbRom[0x14b]);
setlab("MakerCode");
const rom_maker m = { s, wxString() }, *rm;
rm = std::lower_bound(&makers[0], &makers[num_makers], m, maker_lt);
if (rm < &makers[num_makers] && !wxStrcmp(m.code, rm->code))
s = rm->name;
else
s = _("Unknown");
setlab("MakerName");
setblab("UnitCode", gbRom[0x146]);
wxString type;
switch (gbRom[0x147]) {
case 0x00:
type = _("ROM");
break;
case 0x01:
type = _("ROM + MBC1");
break;
case 0x02:
type = _("ROM + MBC1 + RAM");
break;
case 0x03:
type = _("ROM + MBC1 + RAM + BATT");
break;
case 0x05:
type = _("ROM + MBC2");
break;
case 0x06:
type = _("ROM + MBC2 + BATT");
break;
case 0x0b:
type = _("ROM + MMM01");
break;
case 0x0c:
type = _("ROM + MMM01 + RAM");
break;
case 0x0d:
type = _("ROM + MMM01 + RAM + BATT");
break;
case 0x0f:
type = _("ROM + MBC3 + TIMER + BATT");
break;
case 0x10:
type = _("ROM + MBC3 + TIMER + RAM + BATT");
break;
case 0x11:
type = _("ROM + MBC3");
break;
case 0x12:
type = _("ROM + MBC3 + RAM");
break;
case 0x13:
type = _("ROM + MBC3 + RAM + BATT");
break;
case 0x19:
type = _("ROM + MBC5");
break;
case 0x1a:
type = _("ROM + MBC5 + RAM");
break;
case 0x1b:
type = _("ROM + MBC5 + RAM + BATT");
break;
case 0x1c:
type = _("ROM + MBC5 + RUMBLE");
break;
case 0x1d:
type = _("ROM + MBC5 + RUMBLE + RAM");
break;
case 0x1e:
type = _("ROM + MBC5 + RUMBLE + RAM + BATT");
break;
case 0x22:
type = _("ROM + MBC7 + BATT");
break;
case 0x55:
type = _("Game Genie");
break;
case 0x56:
type = _("Game Shark 3.0");
break;
case 0xfc:
type = _("ROM + POCKET CAMERA");
break;
case 0xfd:
type = _("ROM + BANDAI TAMA5");
break;
case 0xfe:
type = _("ROM + HuC-3");
break;
case 0xff:
type = _("ROM + HuC-1");
break;
default:
type = _("Unknown");
}
setblabs("DeviceType", gbRom[0x147], type);
switch (gbRom[0x148]) {
case 0:
type = wxT("32K");
break;
case 1:
type = wxT("64K");
break;
case 2:
type = wxT("128K");
break;
case 3:
type = wxT("256K");
break;
case 4:
type = wxT("512K");
break;
case 5:
type = wxT("1M");
break;
case 6:
type = wxT("2M");
break;
case 7:
type = wxT("4M");
break;
default:
type = _("Unknown");
}
setblabs("ROMSize", gbRom[0x148], type);
switch (gbRom[0x149]) {
case 0:
type = _("None");
break;
case 1:
type = wxT("2K");
break;
case 2:
type = wxT("8K");
break;
case 3:
type = wxT("32K");
break;
case 4:
type = wxT("128K");
break;
case 5:
type = wxT("64K");
break;
}
setblabs("RAMSize", gbRom[0x149], type);
setblab("DestCode", gbRom[0x14a]);
setblab("LicCode", gbRom[0x14b]);
setblab("Version", gbRom[0x14c]);
s.Printf(wxT("%02x (%02x)"), g_gbCartData.actual_header_checksum(), g_gbCartData.header_checksum());
setlab("CRC");
s.Printf(wxT("%04x (%04x)"), g_gbCartData.actual_global_checksum(), g_gbCartData.global_checksum());
setlab("Checksum");
dlg->Fit();
ShowModal(dlg);
} break;
case IMAGE_GB:
ShowModal(GetXRCDialog("GBROMInfo"));
break;
case IMAGE_GBA: {
IdentifyRom();
wxDialog* dlg = GetXRCDialog("GBAROMInfo");
@ -771,14 +321,7 @@ EVT_HANDLER_MASK(RomInformation, "ROM information...", CMDEN_GB | CMDEN_GBA)
SetDialogLabel(dlg, wxT("CRC32"), rom_crc32, 8);
setlabs("GameCode", rom[0xac], 4);
setlabs("MakerCode", rom[0xb0], 2);
const rom_maker m = { s, wxString() }, *rm;
rm = std::lower_bound(&makers[0], &makers[num_makers], m, maker_lt);
if (rm < &makers[num_makers] && !wxStrcmp(m.code, rm->code))
s = rm->name;
else
s = _("Unknown");
s = dialogs::GetGameMakerName(s.ToStdString());
setlab("MakerName");
setblab("UnitCode", rom[0xb3]);
s.Printf(wxT("%02x"), (unsigned int)rom[0xb4]);

View File

@ -0,0 +1,248 @@
#include "game-maker.h"
#include <unordered_map>
#include <wx/translation.h>
namespace dialogs {
const wxString& GetGameMakerName(const std::string& makerCode) {
static const std::unordered_map<std::string, wxString> kGameMakersMap = {
{"01", "Nintendo R&&D1"},
{"02", "Rocket Games"},
{"08", "Capcom"},
{"09", "Hot B Co."},
{"0A", "Jaleco"},
{"0B", "Coconuts Japan"},
{"0C", "Coconuts Japan/G.X.Media"},
{"0H", "Starfish"},
{"0L", "Warashi Inc."},
{"0N", "Nowpro"},
{"0P", "Game Village"},
{"13", "Electronic Arts Japan"},
{"18", "Hudson Soft Japan"},
{"19", "S.C.P."},
{"1A", "Yonoman"},
{"1G", "SMDE"},
{"1P", "Creatures Inc."},
{"1Q", "TDK Deep Impresion"},
{"20", "Destination Software"},
{"22", "VR 1 Japan"},
{"25", "San-X"},
{"28", "Kemco Japan"},
{"29", "Seta"},
{"2H", "Ubisoft Japan"},
{"2K", "NEC InterChannel"},
{"2L", "Tam"},
{"2M", "Jordan"},
{"2N", "Smilesoft"},
{"2Q", "Mediakite"},
{"31", "Nintendo"},
{"36", "Codemasters"},
{"37", "GAGA Communications"},
{"38", "Laguna"},
{"39", "Telstar Fun and Games"},
{"41", "Ubi Soft Entertainment"},
{"42", "Sunsoft"},
{"47", "Spectrum Holobyte"},
{"49", "IREM"},
{"4D", "Malibu Games"},
{"4F", "Eidos/U.S. Gold"},
{"4J", "Fox Interactive"},
{"4K", "Time Warner Interactive"},
{"4Q", "Disney"},
{"4S", "Black Pearl"},
{"4X", "GT Interactive"},
{"4Y", "RARE"},
{"4Z", "Crave Entertainment"},
{"50", "Absolute Entertainment"},
{"51", "Acclaim"},
{"52", "Activision"},
{"53", "American Sammy Corp."},
{"54", "Take 2 Interactive"},
{"55", "Hi Tech"},
{"56", "LJN LTD."},
{"58", "Mattel"},
{"5A", "Mindscape/Red Orb Ent."},
{"5C", "Taxan"},
{"5D", "Midway"},
{"5F", "American Softworks"},
{"5G", "Majesco Sales Inc"},
{"5H", "3DO"},
{"5K", "Hasbro"},
{"5L", "NewKidCo"},
{"5M", "Telegames"},
{"5N", "Metro3D"},
{"5P", "Vatical Entertainment"},
{"5Q", "LEGO Media"},
{"5S", "Xicat Interactive"},
{"5T", "Cryo Interactive"},
{"5W", "Red Storm Ent./BKN Ent."},
{"5X", "Microids"},
{"5Z", "Conspiracy Entertainment Corp."},
{"60", "Titus Interactive Studios"},
{"61", "Virgin Interactive"},
{"62", "Maxis"},
{"64", "LucasArts Entertainment"},
{"67", "Ocean"},
{"69", "Electronic Arts"},
{"6E", "Elite Systems Ltd."},
{"6F", "Electro Brain"},
{"6G", "The Learning Company"},
{"6H", "BBC"},
{"6J", "Software 2000"},
{"6L", "BAM! Entertainment"},
{"6M", "Studio 3"},
{"6Q", "Classified Games"},
{"6S", "TDK Mediactive"},
{"6U", "DreamCatcher"},
{"6V", "JoWood Productions"},
{"6W", "SEGA"},
{"6X", "Wannado Edition"},
{"6Y", "LSP"},
{"6Z", "ITE Media"},
{"70", "Infogrames"},
{"71", "Interplay"},
{"72", "JVC Musical Industries Inc"},
{"73", "Parker Brothers"},
{"75", "SCI"},
{"78", "THQ"},
{"79", "Accolade"},
{"7A", "Triffix Ent. Inc."},
{"7C", "Microprose Software"},
{"7D", "Universal Interactive Studios"},
{"7F", "Kemco"},
{"7G", "Rage Software"},
{"7H", "Encore"},
{"7J", "Zoo"},
{"7K", "BVM"},
{"7L", "Simon & Schuster Interactive"},
{"7M", "Asmik Ace Entertainment Inc./AIA"},
{"7N", "Empire Interactive"},
{"7Q", "Jester Interactive"},
{"7T", "Scholastic"},
{"7U", "Ignition Entertainment"},
{"7W", "Stadlbauer"},
{"80", "Misawa"},
{"83", "LOZC"},
{"8B", "Bulletproof Software"},
{"8C", "Vic Tokai Inc."},
{"8J", "General Entertainment"},
{"8N", "Success"},
{"8P", "SEGA Japan"},
{"91", "Chun Soft"},
{"92", "Video System"},
{"93", "BEC"},
{"96", "Yonezawa/S'pal"},
{"97", "Kaneko"},
{"99", "Victor Interactive Software"},
{"9A", "Nichibutsu/Nihon Bussan"},
{"9B", "Tecmo"},
{"9C", "Imagineer"},
{"9F", "Nova"},
{"9H", "Bottom Up"},
{"9L", "Hasbro Japan"},
{"9N", "Marvelous Entertainment"},
{"9P", "Keynet Inc."},
{"9Q", "Hands-On Entertainment"},
{"A0", "Telenet"},
{"A1", "Hori"},
{"A4", "Konami"},
{"A6", "Kawada"},
{"A7", "Takara"},
{"A9", "Technos Japan Corp."},
{"AA", "JVC"},
{"AC", "Toei Animation"},
{"AD", "Toho"},
{"AF", "Namco"},
{"AG", "Media Rings Corporation"},
{"AH", "J-Wing"},
{"AK", "KID"},
{"AL", "MediaFactory"},
{"AP", "Infogrames Hudson"},
{"AQ", "Kiratto. Ludic Inc"},
{"B0", "Acclaim Japan"},
{"B1", "ASCII"},
{"B2", "Bandai"},
{"B4", "Enix"},
{"B6", "HAL Laboratory"},
{"B7", "SNK"},
{"B9", "Pony Canyon Hanbai"},
{"BA", "Culture Brain"},
{"BB", "Sunsoft"},
{"BD", "Sony Imagesoft"},
{"BF", "Sammy"},
{"BG", "Magical"},
{"BJ", "Compile"},
{"BL", "MTO Inc."},
{"BN", "Sunrise Interactive"},
{"BP", "Global A Entertainment"},
{"BQ", "Fuuki"},
{"C0", "Taito"},
{"C2", "Kemco"},
{"C3", "Square Soft"},
{"C5", "Data East"},
{"C6", "Tonkin House"},
{"C8", "Koei"},
{"CA", "Konami/Palcom/Ultra"},
{"CB", "Vapinc/NTVIC"},
{"CC", "Use Co.,Ltd."},
{"CD", "Meldac"},
{"CE", "FCI/Pony Canyon"},
{"CF", "Angel"},
{"CM", "Konami Computer Entertainment Osaka"},
{"CP", "Enterbrain"},
{"D1", "Sofel"},
{"D2", "Quest"},
{"D3", "Sigma Enterprises"},
{"D4", "Ask Kodansa"},
{"D6", "Naxat"},
{"D7", "Copya System"},
{"D9", "Banpresto"},
{"DA", "TOMY"},
{"DB", "LJN Japan"},
{"DD", "NCS"},
{"DF", "Altron Corporation"},
{"DH", "Gaps Inc."},
{"DN", "ELF"},
{"E2", "Yutaka"},
{"E3", "Varie"},
{"E5", "Epoch"},
{"E7", "Athena"},
{"E8", "Asmik Ace Entertainment Inc."},
{"E9", "Natsume"},
{"EA", "King Records"},
{"EB", "Atlus"},
{"EC", "Epic/Sony Records"},
{"EE", "IGS"},
{"EL", "Spike"},
{"EM", "Konami Computer Entertainment Tokyo"},
{"EN", "Alphadream Corporation"},
{"F0", "A Wave"},
{"G1", "PCCW"},
{"G4", "KiKi Co Ltd"},
{"G5", "Open Sesame Inc."},
{"G6", "Sims"},
{"G7", "Broccoli"},
{"G8", "Avex"},
{"G9", "D3 Publisher"},
{"GB", "Konami Computer Entertainment Japan"},
{"GD", "Square-Enix"},
{"HY", "Sachen"}};
// Localized strings.
static const wxString kUnknownMakerCode = _("Unknown");
static const wxString kInvalidMakerCode = _("Invalid");
if (makerCode.size() != 2) {
return kInvalidMakerCode;
}
const auto iter = kGameMakersMap.find(makerCode);
if (iter == kGameMakersMap.end()) {
return kUnknownMakerCode;
}
return iter->second;
}
} // namespace dialogs

View File

@ -0,0 +1,18 @@
#ifndef VBAM_WX_DIALOGS_GAME_MAKER_H_
#define VBAM_WX_DIALOGS_GAME_MAKER_H_
#include <string>
#include <wx/string.h>
namespace dialogs {
// TODO: Move this file to an internal directory once GBARomInfo has been
// converted.
// Returns the Game Maker as a string.
const wxString& GetGameMakerName(const std::string& makerCode);
} // namespace dialogs
#endif // VBAM_WX_DIALOGS_GAME_MAKER_H_

View File

@ -0,0 +1,218 @@
#include "dialogs/gb-rom-info.h"
#include <wx/control.h>
#include <wx/xrc/xmlres.h>
#include "../common/sizes.h"
#include "../gb/gb.h"
#include "dialogs/game-maker.h"
#include "dialogs/validated-child.h"
namespace dialogs {
namespace {
// Returns a localized string indicating the cartridge type (mapper) for the loaded GB/GBC
// cartridge.
wxString GetCartType() {
wxString mapper_type;
switch (g_gbCartData.mapper_type()) {
case gbCartData::MapperType::kNone:
mapper_type = _("No mapper");
break;
case gbCartData::MapperType::kMbc1:
mapper_type = _("MBC1");
break;
case gbCartData::MapperType::kMbc2:
mapper_type = _("MBC2");
break;
case gbCartData::MapperType::kMbc3:
mapper_type = _("MBC3");
break;
case gbCartData::MapperType::kMbc5:
mapper_type = _("MBC5");
break;
case gbCartData::MapperType::kMbc6:
mapper_type = _("MBC6");
break;
case gbCartData::MapperType::kMbc7:
mapper_type = _("MBC7");
break;
case gbCartData::MapperType::kPocketCamera:
mapper_type = _("Pocket Camera");
break;
case gbCartData::MapperType::kMmm01:
mapper_type = _("MMM01");
break;
case gbCartData::MapperType::kHuC1:
mapper_type = _("HuC-1");
break;
case gbCartData::MapperType::kHuC3:
mapper_type = _("HuC-3");
break;
case gbCartData::MapperType::kTama5:
mapper_type = _("Bandai TAMA5");
break;
case gbCartData::MapperType::kGameGenie:
mapper_type = _("Game Genie");
break;
case gbCartData::MapperType::kGameShark:
mapper_type = _("Game Shark");
break;
case gbCartData::MapperType::kUnknown:
mapper_type = _("Unknown");
break;
}
const wxString has_ram = g_gbCartData.HasRam() ? _(" + RAM") : "";
const wxString has_rtc = g_gbCartData.has_rtc() ? _(" + RTC") : "";
const wxString has_battery = g_gbCartData.has_battery() ? _(" + Battery") : "";
const wxString has_rumble = g_gbCartData.has_rumble() ? _(" + Rumble") : "";
const wxString has_motion = g_gbCartData.has_sensor() ? _(" + Motion Sensor") : "";
return wxString::Format(_("%02X (%s%s%s%s%s%s)"), g_gbCartData.mapper_flag(), mapper_type,
has_ram, has_rtc, has_battery, has_rumble, has_motion);
}
// Returns a localized string indicating SGB support for the loaded GB/GBC cartridge.
wxString GetCartSGBFlag() {
if (g_gbCartData.sgb_support()) {
return wxString::Format(_("%02X (Supported)"), g_gbCartData.sgb_flag());
} else {
return wxString::Format(_("%02X (Not supported)"), g_gbCartData.sgb_flag());
}
}
// Returns a localized string indicating CGB support for the loaded GB/GBC cartridge.
wxString GetCartCGBFlag() {
switch (g_gbCartData.cgb_support()) {
case gbCartData::CGBSupport::kNone:
return wxString::Format(_("%02X (Not supported)"), g_gbCartData.cgb_flag());
case gbCartData::CGBSupport::kSupported:
return wxString::Format(_("%02X (Supported)"), g_gbCartData.cgb_flag());
case gbCartData::CGBSupport::kRequired:
return wxString::Format(_("%02X (Required)"), g_gbCartData.cgb_flag());
default:
// Unreachable.
assert(false);
return "";
}
}
// Returns a localized string indicating the ROM size of the loaded GB/GBC cartridge.
wxString GetCartRomSize() {
switch (g_gbCartData.rom_size()) {
case k32KiB:
return wxString::Format(_("%02X (32 KiB)"), g_gbCartData.rom_flag());
case k64KiB:
return wxString::Format(_("%02X (64 KiB)"), g_gbCartData.rom_flag());
case k128KiB:
return wxString::Format(_("%02X (128 KiB)"), g_gbCartData.rom_flag());
case k256KiB:
return wxString::Format(_("%02X (256 KiB)"), g_gbCartData.rom_flag());
case k512KiB:
return wxString::Format(_("%02X (512 KiB)"), g_gbCartData.rom_flag());
case k1MiB:
return wxString::Format(_("%02X (1 MiB)"), g_gbCartData.rom_flag());
case k2MiB:
return wxString::Format(_("%02X (2 MiB)"), g_gbCartData.rom_flag());
case k4MiB:
return wxString::Format(_("%02X (4 MiB)"), g_gbCartData.rom_flag());
default:
return wxString::Format(_("%02X (Unknown)"), g_gbCartData.rom_flag());
}
}
// Returns a localized string indicating the ROM size of the loaded GB/GBC cartridge.
wxString GetCartRamSize() {
switch (g_gbCartData.ram_size()) {
case 0:
return wxString::Format(_("%02X (None)"), g_gbCartData.ram_flag());
case k256B:
return wxString::Format(_("%02X (256 B)"), g_gbCartData.ram_flag());
case k512B:
return wxString::Format(_("%02X (512 B)"), g_gbCartData.ram_flag());
case k2KiB:
return wxString::Format(_("%02X (2 KiB)"), g_gbCartData.ram_flag());
case k8KiB:
return wxString::Format(_("%02X (8 KiB)"), g_gbCartData.ram_flag());
case k32KiB:
return wxString::Format(_("%02X (32 KiB)"), g_gbCartData.ram_flag());
case k128KiB:
return wxString::Format(_("%02X (128 KiB)"), g_gbCartData.ram_flag());
case k64KiB:
return wxString::Format(_("%02X (64 KiB)"), g_gbCartData.ram_flag());
default:
return wxString::Format(_("%02X (Unknown)"), g_gbCartData.ram_flag());
}
}
// Returns a localized string indicating the destination code of the loaded GB/GBC cartridge.
wxString GetCartDestinationCode() {
switch (g_gbCartData.destination_code()) {
case gbCartData::DestinationCode::kJapanese:
return wxString::Format(_("%02X (Japan)"), g_gbCartData.destination_code_flag());
case gbCartData::DestinationCode::kWorldwide:
return wxString::Format(_("%02X (World)"), g_gbCartData.destination_code_flag());
case gbCartData::DestinationCode::kUnknown:
return wxString::Format(_("%02X (Unknown)"), g_gbCartData.destination_code_flag());
default:
// Unreachable.
assert(false);
return "";
}
}
} // namespace
// static
GbRomInfo* GbRomInfo::NewInstance(wxWindow* parent) {
assert(parent);
return new GbRomInfo(parent);
}
GbRomInfo::GbRomInfo(wxWindow* parent) : wxDialog(), keep_on_top_styler_(this) {
#if !wxCHECK_VERSION(3, 1, 0)
// This needs to be set before loading any element on the window. This also
// has no effect since wx 3.1.0, where it became the default.
this->SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
#endif
wxXmlResource::Get()->LoadDialog(this, parent, "GBROMInfo");
Bind(wxEVT_SHOW, &GbRomInfo::OnDialogShowEvent, this);
}
void GbRomInfo::OnDialogShowEvent(wxShowEvent& event) {
// Let the event propagate.
event.Skip();
if (!event.IsShown()) {
return;
}
// Populate the dialog.
GetValidatedChild(this, "Title")->SetLabel(g_gbCartData.title());
GetValidatedChild(this, "MakerCode")->SetLabel(g_gbCartData.maker_code());
GetValidatedChild(this, "MakerName")->SetLabel(GetGameMakerName(g_gbCartData.maker_code()));
GetValidatedChild(this, "CartridgeType")->SetLabel(GetCartType());
GetValidatedChild(this, "SGBCode")->SetLabel(GetCartSGBFlag());
GetValidatedChild(this, "CGBCode")->SetLabel(GetCartCGBFlag());
GetValidatedChild(this, "ROMSize")->SetLabel(GetCartRomSize());
GetValidatedChild(this, "RAMSize")->SetLabel(GetCartRamSize());
GetValidatedChild(this, "DestCode")->SetLabel(GetCartDestinationCode());
GetValidatedChild(this, "LicCode")
->SetLabel(wxString::Format("%02X", g_gbCartData.old_licensee_code()));
GetValidatedChild(this, "Version")
->SetLabel(wxString::Format("%02X", g_gbCartData.version_flag()));
GetValidatedChild(this, "HeaderChecksum")
->SetLabel(wxString::Format(_("%02X (Actual: %02X)"), g_gbCartData.header_checksum(),
g_gbCartData.actual_header_checksum()));
GetValidatedChild(this, "CartridgeChecksum")
->SetLabel(wxString::Format(_("%04X (Actual: %04X)"), g_gbCartData.global_checksum(),
g_gbCartData.actual_global_checksum()));
// Re-fit everything.
Fit();
}
} // namespace dialogs

View File

@ -0,0 +1,29 @@
#ifndef VBAM_WX_DIALOGS_GB_ROM_INFO_H_
#define VBAM_WX_DIALOGS_GB_ROM_INFO_H_
#include <wx/dialog.h>
#include "widgets/keep-on-top-styler.h"
namespace dialogs {
class GbRomInfo : public wxDialog {
public:
static GbRomInfo* NewInstance(wxWindow* parent);
~GbRomInfo() override = default;
private:
// The constructor is private so initialization has to be done via the
// static method. This is because this class is destroyed when its
// owner, `parent` is destroyed. This prevents accidental deletion.
GbRomInfo(wxWindow* parent);
// Handler for the wxEVT_SHOW event.
void OnDialogShowEvent(wxShowEvent& event);
const widgets::KeepOnTopStyler keep_on_top_styler_;
};
} // namespace dialogs
#endif // VBAM_WX_DIALOGS_GB_ROM_INFO_H_

View File

@ -42,6 +42,7 @@
#include "dialogs/directories-config.h"
#include "dialogs/display-config.h"
#include "dialogs/game-boy-config.h"
#include "dialogs/gb-rom-info.h"
#include "opts.h"
#include "widgets/option-validator.h"
#include "widgets/user-input-ctrl.h"
@ -2267,22 +2268,7 @@ bool MainFrame::BindControls()
getlab("Version");
getlab("CRC");
d->Fit();
d = LoadXRCDialog("GBROMInfo");
// just verify fields present
getlab("Title");
getlab("MakerCode");
getlab("MakerName");
getlab("UnitCode");
getlab("DeviceType");
getlab("Version");
getlab("CRC");
getlab("Color");
getlab("ROMSize");
getlab("RAMSize");
getlab("DestCode");
getlab("LicCode");
getlab("Checksum");
d->Fit();
dialogs::GbRomInfo::NewInstance(this);
d = LoadXRCDialog("CodeSelect");
// just verify list present
SafeXRCCTRL<wxControlWithItems>(d, "CodeList");

View File

@ -43,18 +43,6 @@
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Unit code:</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="UnitCode"/>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Cartridge type:</label>
@ -63,43 +51,31 @@
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="DeviceType"/>
<object class="wxStaticText" name="CartridgeType"/>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>ROM version:</label>
<label>SGB code:</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="Version"/>
<object class="wxStaticText" name="SGBCode"/>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>CRC:</label>
<label>CGB code:</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="CRC"/>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Color:</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="Color"/>
<object class="wxStaticText" name="CGBCode"/>
<flag>wxALL</flag>
<border>5</border>
</object>
@ -153,13 +129,37 @@
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Checksum:</label>
<label>ROM version:</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="Checksum"/>
<object class="wxStaticText" name="Version"/>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Header checksum:</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="HeaderChecksum"/>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Cartridge checksum:</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText" name="CartridgeChecksum"/>
<flag>wxALL</flag>
<border>5</border>
</object>