From a13f2dd3a83299c1facbd9b2ce6c7769b6001188 Mon Sep 17 00:00:00 2001 From: Sour Date: Sun, 22 Jul 2018 15:21:48 -0400 Subject: [PATCH] VS System: Updated dipswitch DB with dual system games (+some refactoring) --- Core/GameDatabase.cpp | 65 --- Core/GameDatabase.h | 1 - GUI.NET/Config/GameDipswitchDefinition.cs | 119 ++---- ...{VsSystem.xml => DipswitchDefinitions.xml} | 381 +++++++++++------- GUI.NET/GUI.NET.csproj | 2 +- Libretro/libretro.cpp | 7 + 6 files changed, 281 insertions(+), 294 deletions(-) rename GUI.NET/Dependencies/{VsSystem.xml => DipswitchDefinitions.xml} (78%) diff --git a/Core/GameDatabase.cpp b/Core/GameDatabase.cpp index 6e1aaf54..ab997c69 100644 --- a/Core/GameDatabase.cpp +++ b/Core/GameDatabase.cpp @@ -487,10 +487,6 @@ void GameDatabase::SetGameInfo(uint32_t romCrc, RomData &romData, bool updateRom MessageManager::Log("[DB] Game not found in database"); } -#ifdef LIBRETRO - SetVsSystemDefaults(romData.Info.Hash.PrgCrc32); -#endif - romData.Info.DatabaseInfo = info; } @@ -525,64 +521,3 @@ void GameDatabase::UpdateRomData(GameInfo &info, RomData &romData) } } } - -void GameDatabase::SetVsSystemDefaults(uint32_t prgCrc32) -{ - //TODO: CLEANUP - switch(prgCrc32) { - case 0x8850924B: - //Tetris - //defaultDip = 32; //???? - break; - - - case 0xCF36261E: - //SuperSkyKid - //inputType = VsInputType::SwapControllers; - //model = PpuModel::Ppu2C04A; - break; - - case 0xE1AA8214: - //StarLuster - //defaultDip = 32; //???? - break; - - case 0x43A357EF: - //IceClimber - //inputType = VsInputType::SwapControllers; - //model = PpuModel::Ppu2C04D; - break; - - case 0xD4EB5923: - //IceClimberB - //inputType = VsInputType::SwapControllers; - //model = PpuModel::Ppu2C04D; - break; - - case 0x737DD1BF: case 0x4BF3972D: - //SuperMarioBros - //model = PpuModel::Ppu2C04D; - break; - - case 0xAE8063EF: - //MachRiderFightingCourse, defaults - //model = PpuModel::Ppu2C03; - break; - - case 0x8A6A9848: //1 crc left - //MachRider - //model = PpuModel::Ppu2C04B; - break; - - case 0xC99EC059: - //RaidBungelingBay - //inputType = VsInputType::SwapControllers; - //model = PpuModel::Ppu2C04B; - break; - - case 0xF9D3B0A3: case 0x66BB838F: case 0x9924980A: - //SuperXevious - //model = PpuModel::Ppu2C04A; - break; - } -} diff --git a/Core/GameDatabase.h b/Core/GameDatabase.h index ab20c202..f1fdcf2f 100644 --- a/Core/GameDatabase.h +++ b/Core/GameDatabase.h @@ -20,7 +20,6 @@ private: static void InitDatabase(); static void UpdateRomData(GameInfo &info, RomData &romData); - static void SetVsSystemDefaults(uint32_t prgCrc32); public: static void LoadGameDb(vector data); diff --git a/GUI.NET/Config/GameDipswitchDefinition.cs b/GUI.NET/Config/GameDipswitchDefinition.cs index 4e2a596f..92c8b391 100644 --- a/GUI.NET/Config/GameDipswitchDefinition.cs +++ b/GUI.NET/Config/GameDipswitchDefinition.cs @@ -10,72 +10,16 @@ namespace Mesen.GUI.Config { public class GameDipswitchDefinition { - public string GameID; public byte DefaultDipSwitches; - public List> DipSwitches; - private static Dictionary _gameConfigs = new Dictionary(); - - public static string GetGameIdByCrc(UInt32 prgCrc32) - { - switch(prgCrc32) { - case 0x9213A19E: return "BalloonFight"; - case 0xEB2DBA63: case 0x98CFE016: return "TKOBoxing"; - case 0x135ADF7C: return "RBIBaseball"; - case 0xED588F00: return "DuckHunt"; - case 0x16D3F469: return "NinjaJajamaruKun"; - case 0x8850924B: return "Tetris"; - case 0x8C0C2DF5: return "TopGun"; - case 0x70901B25: return "Slalom"; - case 0xCF36261E: return "SuperSkyKid"; - case 0xE1AA8214: return "StarLuster"; - case 0xD5D7EAC4: return "DrMario"; - case 0xFFBEF374: return "Castlevania"; - case 0xE2C0A2BE: return "Platoon"; - case 0x29155E0C: return "ExciteBike"; - case 0xCBE85490: return "ExciteBikeB"; - case 0x07138C06: return "CluCluLand"; - case 0x43A357EF: return "IceClimber"; - case 0xD4EB5923: return "IceClimberB"; - case 0x737DD1BF: case 0x4BF3972D: case 0x8B60CC58: case 0x8192C804: return "SuperMarioBros"; - case 0xE528F651: return "Pinball"; - case 0xEC461DB9: return "PinballB"; - case 0xAE8063EF: return "MachRiderFightingCourse"; - case 0x0B65A917: case 0x8A6A9848: return "MachRider"; - case 0x46914E3E: return "Soccer"; - case 0x70433F2C: return "BattleCity"; - case 0xD99A2087: return "Gradius"; - case 0x1E438D52: return "Goonies"; - case 0xFF5135A3: return "HoganAlley"; - case 0x17AE56BE: return "FreedomForce"; - case 0xC99EC059: return "RaidBungelingBay"; - case 0xF9D3B0A3: case 0x66BB838F: case 0x9924980A: return "SuperXevious"; - case 0xA93A5AEE: return "Golf"; - case 0xCC2C4B5D: case 0x86167220: return "GolfB"; - case 0xCA85E56D: return "MightyBombJack"; - case 0xFE446787: return "Gumshoe"; - } - - return null; - } - - public static string GetGameID() - { - string gameID = GetGameIdByCrc(InteropEmu.GetRomInfo().PrgCrc32); - - if(gameID != null) { - return gameID; - } - - return "Unknown"; - } + private static Dictionary _gameConfigs = new Dictionary(); public static GameDipswitchDefinition GetDipswitchDefinition() { - string gameID = GetGameID(); - if(gameID != null && _gameConfigs.ContainsKey(gameID)) { - return _gameConfigs[gameID]; + int prgCrc32 = (int)InteropEmu.GetRomInfo().PrgCrc32; + if(_gameConfigs.ContainsKey(prgCrc32)) { + return _gameConfigs[prgCrc32]; } else { return null; } @@ -84,39 +28,38 @@ namespace Mesen.GUI.Config static GameDipswitchDefinition() { XmlDocument config = new XmlDocument(); - config.Load(ResourceManager.GetZippedResource("VsSystem.xml")); + config.Load(ResourceManager.GetZippedResource("DipswitchDefinitions.xml")); - foreach(XmlNode gameNode in config.SelectNodes("/VsSystemGames/Game")) { + foreach(XmlNode gameNode in config.SelectNodes("/DipswitchDefinitions/Game")) { var gameDipswitches = new GameDipswitchDefinition(); - gameDipswitches.GameID = gameNode.Attributes["ID"].Value; - if(gameNode.Attributes["DefaultDip"] != null) { - gameDipswitches.DefaultDipSwitches = (byte)Int32.Parse(gameNode.Attributes["DefaultDip"].Value); - } - gameDipswitches.DipSwitches = new List>(); - - foreach(XmlNode dipSwitch in gameNode.SelectNodes("DipSwitch")) { - if(dipSwitch.Attributes["Localization"] != null) { - var list = new List(); - gameDipswitches.DipSwitches.Add(list); - - list.Add(dipSwitch.Attributes["Localization"].Value); - foreach(XmlNode option in dipSwitch.SelectNodes("Option")) { - list.Add(option.InnerText); - } - } else { - var list = new List(); - gameDipswitches.DipSwitches.Add(list); - - list.Add("Unknown"); - list.Add("Off"); - list.Add("On"); + string crcValues = gameNode.Attributes["PrgCrc32"].Value; + foreach(string crc in crcValues.Split(',')) { + if(gameNode.Attributes["DefaultDip"] != null) { + gameDipswitches.DefaultDipSwitches = (byte)Int32.Parse(gameNode.Attributes["DefaultDip"].Value); } + gameDipswitches.DipSwitches = new List>(); + + foreach(XmlNode dipSwitch in gameNode.SelectNodes("DipSwitch")) { + if(dipSwitch.Attributes["Localization"] != null) { + var list = new List(); + gameDipswitches.DipSwitches.Add(list); + + list.Add(dipSwitch.Attributes["Localization"].Value); + foreach(XmlNode option in dipSwitch.SelectNodes("Option")) { + list.Add(option.InnerText); + } + } else { + var list = new List(); + gameDipswitches.DipSwitches.Add(list); + + list.Add("Unknown"); + list.Add("Off"); + list.Add("On"); + } + } + _gameConfigs[int.Parse(crc, System.Globalization.NumberStyles.HexNumber)] = gameDipswitches; } - _gameConfigs[gameNode.Attributes["ID"].Value] = gameDipswitches; } } } - - - } diff --git a/GUI.NET/Dependencies/VsSystem.xml b/GUI.NET/Dependencies/DipswitchDefinitions.xml similarity index 78% rename from GUI.NET/Dependencies/VsSystem.xml rename to GUI.NET/Dependencies/DipswitchDefinitions.xml index 6c606917..71c26292 100644 --- a/GUI.NET/Dependencies/VsSystem.xml +++ b/GUI.NET/Dependencies/DipswitchDefinitions.xml @@ -1,6 +1,6 @@  - - + + @@ -39,7 +39,216 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -62,7 +271,7 @@ - + @@ -88,7 +297,7 @@ - + @@ -109,7 +318,7 @@ - + @@ -137,7 +346,7 @@ - + @@ -165,7 +374,7 @@ - + @@ -191,33 +400,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -234,7 +417,7 @@ - + @@ -264,37 +447,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -320,7 +473,7 @@ - + @@ -350,7 +503,7 @@ - + @@ -380,7 +533,7 @@ - + @@ -408,7 +561,7 @@ - + @@ -434,33 +587,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -481,7 +608,7 @@ - + @@ -500,7 +627,7 @@ - + @@ -521,7 +648,7 @@ - + @@ -545,7 +672,7 @@ - + @@ -569,31 +696,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -613,7 +716,7 @@ - + @@ -640,7 +743,7 @@ - + @@ -660,7 +763,7 @@ - + @@ -690,7 +793,7 @@ - + @@ -714,7 +817,7 @@ - + @@ -732,7 +835,7 @@ - + @@ -762,7 +865,7 @@ - + @@ -786,7 +889,7 @@ - + @@ -804,7 +907,7 @@ - + @@ -822,7 +925,7 @@ - + @@ -839,7 +942,7 @@ - + @@ -869,4 +972,4 @@ - + diff --git a/GUI.NET/GUI.NET.csproj b/GUI.NET/GUI.NET.csproj index d8e57bb3..84120c16 100644 --- a/GUI.NET/GUI.NET.csproj +++ b/GUI.NET/GUI.NET.csproj @@ -1802,7 +1802,7 @@ Always Designer - + Always Designer diff --git a/Libretro/libretro.cpp b/Libretro/libretro.cpp index e36b5861..8ae92b3c 100644 --- a/Libretro/libretro.cpp +++ b/Libretro/libretro.cpp @@ -978,6 +978,13 @@ extern "C" { bool result = _console->Initialize(game->path); if(result) { + //Set default dipswitches for some VS System games + switch(_console->GetRomInfo().Hash.PrgCrc32) { + case 0x8850924B: _console->GetSettings()->SetDipSwitches(32); break; //VS Tetris + case 0xE1AA8214: _console->GetSettings()->SetDipSwitches(32); break; //StarLuster + default: _console->GetSettings()->SetDipSwitches(0); break; + } + update_core_controllers(); update_input_descriptors();