From 3ac8cb2018e3eb498e956c1e538f245fcba415b3 Mon Sep 17 00:00:00 2001 From: Sour Date: Sat, 7 Jul 2018 17:30:13 -0400 Subject: [PATCH] VS System: Cleanup config UI (keep DIP switches only) + support for NES 2.0 input type proposal (WIP) --- Core/Console.cpp | 3 +- Core/EmulationSettings.cpp | 15 -- Core/EmulationSettings.h | 11 - Core/FdsLoader.cpp | 2 +- Core/GameDatabase.cpp | 145 ++++++++++---- Core/GameDatabase.h | 3 +- Core/MesenMovie.cpp | 1 - Core/MovieRecorder.cpp | 1 - Core/MovieRecorder.h | 1 - Core/NESHeader.cpp | 10 + Core/NESHeader.h | 4 +- Core/RomData.h | 5 +- Core/Types.h | 48 ++++- Core/VsControlManager.cpp | 8 +- Core/VsSystem.h | 2 +- Core/iNesLoader.cpp | 6 +- GUI.NET/Config/Configuration.cs | 2 - ...nfigInfo.cs => GameDipswitchDefinition.cs} | 93 ++------- GUI.NET/Config/GameSpecificInfo.cs | 49 +++++ GUI.NET/Dependencies/resources.ca.xml | 7 +- GUI.NET/Dependencies/resources.en.xml | 7 +- GUI.NET/Dependencies/resources.es.xml | 7 +- GUI.NET/Dependencies/resources.fr.xml | 7 +- GUI.NET/Dependencies/resources.ja.xml | 7 +- GUI.NET/Dependencies/resources.pt.xml | 7 +- GUI.NET/Dependencies/resources.ru.xml | 7 +- GUI.NET/Dependencies/resources.uk.xml | 7 +- .../Forms/Config/frmGameConfig.Designer.cs | 111 +++++++++++ .../{frmVsGameConfig.cs => frmGameConfig.cs} | 81 +++----- ...rmVsGameConfig.resx => frmGameConfig.resx} | 0 .../Forms/Config/frmVsGameConfig.Designer.cs | 188 ------------------ GUI.NET/Forms/frmMain.Designer.cs | 18 +- GUI.NET/Forms/frmMain.Game.cs | 19 +- GUI.NET/Forms/frmMain.Help.cs | 9 - GUI.NET/Forms/frmMain.cs | 6 +- GUI.NET/GUI.NET.csproj | 12 +- GUI.NET/InteropEmu.cs | 3 +- InteropDLL/ConsoleWrapper.cpp | 8 +- 38 files changed, 428 insertions(+), 492 deletions(-) rename GUI.NET/Config/{VsConfigInfo.cs => GameDipswitchDefinition.cs} (50%) create mode 100644 GUI.NET/Forms/Config/frmGameConfig.Designer.cs rename GUI.NET/Forms/Config/{frmVsGameConfig.cs => frmGameConfig.cs} (58%) rename GUI.NET/Forms/Config/{frmVsGameConfig.resx => frmGameConfig.resx} (100%) delete mode 100644 GUI.NET/Forms/Config/frmVsGameConfig.Designer.cs diff --git a/Core/Console.cpp b/Core/Console.cpp index ac2d57c9..cd97e9b5 100644 --- a/Core/Console.cpp +++ b/Core/Console.cpp @@ -286,7 +286,7 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile) } RomInfo romInfo = _mapper->GetRomInfo(); - if(!_master && romInfo.VsSystemType == VsSystemType::VsDualSystem) { + if(!_master && romInfo.VsType == VsSystemType::VsDualSystem) { _slave.reset(new Console(shared_from_this())); _slave->Init(); _slave->Initialize(romFile, patchFile); @@ -299,6 +299,7 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile) break; case GameSystem::VsSystem: + EmulationSettings::SetPpuModel(romInfo.VsPpuModel); _systemActionManager.reset(new VsSystemActionManager(shared_from_this())); break; diff --git a/Core/EmulationSettings.cpp b/Core/EmulationSettings.cpp index 2297b4c7..9b2a67b8 100644 --- a/Core/EmulationSettings.cpp +++ b/Core/EmulationSettings.cpp @@ -67,7 +67,6 @@ std::unordered_map> EmulationSettings::_shortcu RamPowerOnState EmulationSettings::_ramPowerOnState = RamPowerOnState::AllZeros; uint32_t EmulationSettings::_dipSwitches = 0; -VsInputType EmulationSettings::_vsInputType = VsInputType::Default; InputDisplaySettings EmulationSettings::_inputDisplaySettings = { 0, InputDisplayPosition::TopLeft, false }; @@ -207,17 +206,3 @@ const vector ExpansionPortDeviceNames = { "AsciiTurboFile", "BattleBox", }; - -const vector PpuModelNames = { - "Ppu2C02", - "Ppu2C03", - "Ppu2C04A", - "Ppu2C04B", - "Ppu2C04C", - "Ppu2C04D", - "Ppu2C05A", - "Ppu2C05B", - "Ppu2C05C", - "Ppu2C05D", - "Ppu2C05E" -}; \ No newline at end of file diff --git a/Core/EmulationSettings.h b/Core/EmulationSettings.h index 00b613d2..77de3bc2 100644 --- a/Core/EmulationSettings.h +++ b/Core/EmulationSettings.h @@ -649,7 +649,6 @@ private: static RamPowerOnState _ramPowerOnState; static uint32_t _dipSwitches; - static VsInputType _vsInputType; static SimpleLock _shortcutLock; static SimpleLock _equalizerLock; @@ -1435,16 +1434,6 @@ public: return _dipSwitches; } - static void SetVsInputType(VsInputType inputType) - { - _vsInputType = inputType; - } - - static VsInputType GetVsInputType() - { - return _vsInputType; - } - static bool IsKeyboardMode() { return _keyboardModeEnabled; diff --git a/Core/FdsLoader.cpp b/Core/FdsLoader.cpp index b5d85559..c7429454 100644 --- a/Core/FdsLoader.cpp +++ b/Core/FdsLoader.cpp @@ -153,7 +153,7 @@ RomData FdsLoader::LoadRom(vector& romFile, string filename) //Setup default controllers if(!_checkOnly && EmulationSettings::CheckFlag(EmulationFlags::AutoConfigureInput)) { - GameDatabase::InitializeInputDevices("", GameSystem::FDS); + GameDatabase::InitializeInputDevices(GameInputType::FamicomControllers, GameSystem::FDS); } return romData; diff --git a/Core/GameDatabase.cpp b/Core/GameDatabase.cpp index 4c636b04..1628556c 100644 --- a/Core/GameDatabase.cpp +++ b/Core/GameDatabase.cpp @@ -157,19 +157,80 @@ PpuModel GameDatabase::GetPpuModel(string model) return PpuModel::Ppu2C02; } +GameInputType GameDatabase::GetInputType(GameSystem system, string inputType) +{ + bool isVsSystem = system == GameSystem::VsSystem; + bool isFamicom = (system == GameSystem::Famicom || system == GameSystem::FDS || system == GameSystem::Dendy); + + if(inputType.compare("Zapper") == 0) { + if(isVsSystem) { + return GameInputType::VsZapper; + } else { + return GameInputType::Zapper; + } + } else if(inputType.compare("FourPlayer") == 0) { + if(isFamicom) { + return GameInputType::FourPlayerAdapter; + } else { + return GameInputType::FourScore; + } + } else if(inputType.compare("Arkanoid") == 0) { + if(isFamicom) { + return GameInputType::ArkanoidControllerFamicom; + } else { + return GameInputType::ArkanoidControllerNes; + } + } else if(inputType.compare("OekaKidsTablet") == 0) { + return GameInputType::OekaKidsTablet; + } else if(inputType.compare("KonamiHypershot") == 0) { + return GameInputType::KonamiHyperShot; + } else if(inputType.compare("FamilyKeyboard") == 0) { + return GameInputType::FamilyBasicKeyboard; + } else if(inputType.compare("PartyTap") == 0) { + return GameInputType::PartyTap; + } else if(inputType.compare("Pachinko") == 0) { + return GameInputType::PachinkoController; + } else if(inputType.compare("ExcitingBoxing") == 0) { + return GameInputType::ExcitingBoxing; + } else if(inputType.compare("SuborKeyboard") == 0) { + return GameInputType::SuborKeyboardMouse1; + } else if(inputType.compare("Mahjong") == 0) { + return GameInputType::JissenMahjong; + } else if(inputType.compare("BarCodeWorld") == 0) { + return GameInputType::BarcodeBattler; + } else if(inputType.compare("BandaiHypershot") == 0) { + return GameInputType::BandaiHypershot; + } else if(inputType.compare("BattleBox") == 0) { + return GameInputType::BattleBox; + } else if(inputType.compare("TurboFile") == 0) { + return GameInputType::TurboFile; + } else if(inputType.compare("FamilyTrainer") == 0) { + return GameInputType::FamilyTrainerSideA; + } else if(inputType.compare("PowerPad") == 0 || inputType.compare("FamilyFunFitness") == 0) { + return GameInputType::PowerPadSideA; + } else if(inputType.compare("VsSwapped") == 0) { + return GameInputType::VsSystemSwapped; + } else if(inputType.compare("VsSwapAB") == 0) { + return GameInputType::VsSystemSwapAB; + } else { + return GameInputType::Default; + } +} + void GameDatabase::InitializeInputDevices(uint32_t romCrc) { InitDatabase(); auto result = _gameDatabase.find(romCrc); if(result != _gameDatabase.end()) { - InitializeInputDevices(result->second.InputType, GetGameSystem(result->second.System), true); + GameSystem system = GetGameSystem(result->second.System); + InitializeInputDevices(GetInputType(system, result->second.InputType), system, true); } else { - InitializeInputDevices("", GameSystem::NesNtsc, true); + InitializeInputDevices(GameInputType::Default, GameSystem::NesNtsc, true); } } -void GameDatabase::InitializeInputDevices(string inputType, GameSystem system, bool silent) +void GameDatabase::InitializeInputDevices(GameInputType inputType, GameSystem system, bool silent) { ControllerType controllers[4] = { ControllerType::StandardController, ControllerType::StandardController, ControllerType::None, ControllerType::None }; ExpansionPortDevice expDevice = ExpansionPortDevice::None; @@ -181,92 +242,89 @@ void GameDatabase::InitializeInputDevices(string inputType, GameSystem system, b } }; - bool isVsSystem = system == GameSystem::VsSystem; bool isFamicom = (system == GameSystem::Famicom || system == GameSystem::FDS || system == GameSystem::Dendy); - if(inputType.compare("Zapper") == 0) { + if(inputType == GameInputType::VsZapper) { + //VS Duck Hunt, etc. need the zapper in the first port + log("[DB] Input: VS Zapper connected"); + controllers[0] = ControllerType::Zapper; + } else if(inputType == GameInputType::Zapper) { log("[DB] Input: Zapper connected"); if(isFamicom) { expDevice = ExpansionPortDevice::Zapper; } else { - if(isVsSystem) { - //VS Duck Hunt, etc. need the zapper in the first port - controllers[0] = ControllerType::Zapper; - } else { - controllers[1] = ControllerType::Zapper; - } + controllers[1] = ControllerType::Zapper; } - } else if(inputType.compare("FourPlayer") == 0) { + } else if(inputType == GameInputType::FourScore) { + log("[DB] Input: Four score connected"); + EmulationSettings::SetFlags(EmulationFlags::HasFourScore); + controllers[2] = controllers[3] = ControllerType::StandardController; + } else if(inputType == GameInputType::FourPlayerAdapter) { log("[DB] Input: Four player adapter connected"); EmulationSettings::SetFlags(EmulationFlags::HasFourScore); - if(isFamicom) { - expDevice = ExpansionPortDevice::FourPlayerAdapter; - controllers[2] = controllers[3] = ControllerType::StandardController; - } else { - controllers[2] = controllers[3] = ControllerType::StandardController; - } - } else if(inputType.compare("Arkanoid") == 0) { - log("[DB] Input: Arkanoid controller connected"); - if(isFamicom) { - expDevice = ExpansionPortDevice::ArkanoidController; - } else { - controllers[1] = ControllerType::ArkanoidController; - } - } else if(inputType.compare("OekaKidsTablet") == 0) { + expDevice = ExpansionPortDevice::FourPlayerAdapter; + controllers[2] = controllers[3] = ControllerType::StandardController; + } else if(inputType == GameInputType::ArkanoidControllerFamicom) { + log("[DB] Input: Arkanoid controller (Famicom) connected"); + expDevice = ExpansionPortDevice::ArkanoidController; + } else if(inputType == GameInputType::ArkanoidControllerNes) { + log("[DB] Input: Arkanoid controller (NES) connected"); + controllers[1] = ControllerType::ArkanoidController; + } else if(inputType == GameInputType::OekaKidsTablet) { log("[DB] Input: Oeka Kids Tablet connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::OekaKidsTablet; - } else if(inputType.compare("KonamiHypershot") == 0) { + } else if(inputType == GameInputType::KonamiHyperShot) { log("[DB] Input: Konami Hyper Shot connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::KonamiHyperShot; - } else if(inputType.compare("FamilyKeyboard") == 0) { + } else if(inputType == GameInputType::FamilyBasicKeyboard) { log("[DB] Input: Family Basic Keyboard connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::FamilyBasicKeyboard; - } else if(inputType.compare("PartyTap") == 0) { + } else if(inputType == GameInputType::PartyTap) { log("[DB] Input: Party Tap connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::PartyTap; - } else if(inputType.compare("Pachinko") == 0) { + } else if(inputType == GameInputType::PachinkoController) { log("[DB] Input: Pachinko controller connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::Pachinko; - } else if(inputType.compare("ExcitingBoxing") == 0) { + } else if(inputType == GameInputType::ExcitingBoxing) { log("[DB] Input: Exciting Boxing controller connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::ExcitingBoxing; - } else if(inputType.compare("SuborKeyboard") == 0) { + } else if(inputType == GameInputType::SuborKeyboardMouse1) { log("[DB] Input: Subor mouse connected"); log("[DB] Input: Subor keyboard connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::SuborKeyboard; controllers[1] = ControllerType::SuborMouse; - } else if(inputType.compare("Mahjong") == 0) { + } else if(inputType == GameInputType::JissenMahjong) { log("[DB] Input: Jissen Mahjong controller connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::JissenMahjong; - } else if(inputType.compare("BarCodeWorld") == 0) { + } else if(inputType == GameInputType::BarcodeBattler) { log("[DB] Input: Barcode Battler barcode reader connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::BarcodeBattler; - } else if(inputType.compare("BandaiHypershot") == 0) { + } else if(inputType == GameInputType::BandaiHypershot) { log("[DB] Input: Bandai Hyper Shot gun connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::BandaiHyperShot; - } else if(inputType.compare("BattleBox") == 0) { + } else if(inputType == GameInputType::BattleBox) { log("[DB] Input: Battle Box connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::BattleBox; - } else if(inputType.compare("TurboFile") == 0) { + } else if(inputType == GameInputType::TurboFile) { log("[DB] Input: Ascii Turbo File connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::AsciiTurboFile; - } else if(inputType.compare("FamilyTrainer") == 0) { + } else if(inputType == GameInputType::FamilyTrainerSideA || inputType == GameInputType::FamilyTrainerSideB) { log("[DB] Input: Family Trainer mat connected"); system = GameSystem::Famicom; expDevice = ExpansionPortDevice::FamilyTrainerMat; - } else if(inputType.compare("PowerPad") == 0 || inputType.compare("FamilyFunFitness") == 0) { + } else if(inputType == GameInputType::PowerPadSideA || inputType == GameInputType::PowerPadSideB) { log("[DB] Input: Power Pad connected"); system = GameSystem::NesNtsc; controllers[1] = ControllerType::PowerPad; @@ -533,7 +591,7 @@ void GameDatabase::SetGameInfo(uint32_t romCrc, RomData &romData, bool updateRom } if(EmulationSettings::CheckFlag(EmulationFlags::AutoConfigureInput)) { - InitializeInputDevices(info.InputType, romData.Info.System); + InitializeInputDevices(GetInputType(romData.Info.System, info.InputType), romData.Info.System); } #ifdef _DEBUG MessageManager::DisplayMessage("DB", "Mapper: " + std::to_string(romData.Info.MapperID) + " Sub: " + std::to_string(romData.Info.SubMapperID) + " System: " + info.System); @@ -554,9 +612,10 @@ void GameDatabase::UpdateRomData(GameInfo &info, RomData &romData) romData.Info.MapperID = info.MapperID; romData.Info.System = GetGameSystem(info.System); if(romData.Info.System == GameSystem::VsSystem) { - romData.Info.VsSystemType = GetVsSystemType(info.VsSystemType); - romData.Info.PpuModel = GetPpuModel(info.PpuModel); + romData.Info.VsType = GetVsSystemType(info.VsSystemType); + romData.Info.VsPpuModel = GetPpuModel(info.PpuModel); } + romData.Info.InputType = GetInputType(romData.Info.System, info.InputType); romData.Info.SubMapperID = GetSubMapper(info); romData.Info.BusConflicts = GetBusConflictType(info.BusConflicts); if(info.ChrRamSize > 0) { @@ -644,7 +703,5 @@ void GameDatabase::SetVsSystemDefaults(uint32_t prgCrc32) break; } - EmulationSettings::SetPpuModel(model); EmulationSettings::SetDipSwitches(defaultDip); - EmulationSettings::SetVsInputType(inputType); } diff --git a/Core/GameDatabase.h b/Core/GameDatabase.h index 7aa737f6..2409cba7 100644 --- a/Core/GameDatabase.h +++ b/Core/GameDatabase.h @@ -14,6 +14,7 @@ private: static GameSystem GetGameSystem(string system); static VsSystemType GetVsSystemType(string system); static PpuModel GetPpuModel(string model); + static GameInputType GetInputType(GameSystem system, string inputType); static uint8_t GetSubMapper(GameInfo &info); static void InitDatabase(); @@ -23,7 +24,7 @@ private: public: static void LoadGameDb(vector data); - static void InitializeInputDevices(string inputType, GameSystem system, bool silent = false); + static void InitializeInputDevices(GameInputType inputType, GameSystem system, bool silent = false); static void InitializeInputDevices(uint32_t romCrc); static void SetGameInfo(uint32_t romCrc, RomData &romData, bool updateRomData, bool forHeaderlessRom); static bool GetiNesHeader(uint32_t romCrc, NESHeader &nesHeader); diff --git a/Core/MesenMovie.cpp b/Core/MesenMovie.cpp index ef4bdf99..90ec37ec 100644 --- a/Core/MesenMovie.cpp +++ b/Core/MesenMovie.cpp @@ -253,7 +253,6 @@ void MesenMovie::ApplySettings() EmulationSettings::SetFlagState(EmulationFlags::DisablePpuReset, LoadBool(_settings, MovieKeys::DisablePpuReset)); //VS System flags - EmulationSettings::SetPpuModel(FromString(LoadString(_settings, MovieKeys::PpuModel), PpuModelNames, PpuModel::Ppu2C02)); EmulationSettings::SetDipSwitches(HexUtilities::FromHex(LoadString(_settings, MovieKeys::DipSwitches))); LoadCheats(); diff --git a/Core/MovieRecorder.cpp b/Core/MovieRecorder.cpp index 7f96a4ef..6b019015 100644 --- a/Core/MovieRecorder.cpp +++ b/Core/MovieRecorder.cpp @@ -130,7 +130,6 @@ void MovieRecorder::GetGameSettings(stringstream &out) //VS System flags if(_console->GetAvailableFeatures() == ConsoleFeatures::VsSystem) { WriteString(out, MovieKeys::DipSwitches, HexUtilities::ToHex(EmulationSettings::GetDipSwitches())); - WriteString(out, MovieKeys::PpuModel, PpuModelNames[(int)EmulationSettings::GetPpuModel()]); } for(CodeInfo &code : _console->GetCheatManager()->GetCheats()) { diff --git a/Core/MovieRecorder.h b/Core/MovieRecorder.h index 80bc71ad..0c54267f 100644 --- a/Core/MovieRecorder.h +++ b/Core/MovieRecorder.h @@ -78,7 +78,6 @@ namespace MovieKeys constexpr const char* DisablePpuReset = "DisablePpuReset"; constexpr const char* ZapperDetectionRadius = "ZapperDetectionRadius"; constexpr const char* RamPowerOnState = "RamPowerOnState"; - constexpr const char* PpuModel = "PpuModel"; constexpr const char* DipSwitches = "DipSwitches"; constexpr const char* InputPollScanline = "InputPollScanline"; }; \ No newline at end of file diff --git a/Core/NESHeader.cpp b/Core/NESHeader.cpp index 00e9d2cf..2513ad62 100644 --- a/Core/NESHeader.cpp +++ b/Core/NESHeader.cpp @@ -170,6 +170,16 @@ MirroringType NESHeader::GetMirroringType() } } +GameInputType NESHeader::GetControllerType() +{ + if(Byte15 <= 0x2A) { + return (GameInputType)Byte15; + } + + MessageManager::Log("[iNES] Unknown controller type."); + return GameInputType::Default; +} + VsSystemType NESHeader::GetVsSystemType() { if(GetRomHeaderVersion() == RomHeaderVersion::Nes2_0) { diff --git a/Core/NESHeader.h b/Core/NESHeader.h index 4bcfa6ad..9273bce8 100644 --- a/Core/NESHeader.h +++ b/Core/NESHeader.h @@ -27,7 +27,8 @@ struct NESHeader uint8_t Byte11; uint8_t Byte12; uint8_t Byte13; - uint8_t Reserved[2]; + uint8_t Byte14; + uint8_t Byte15; uint16_t GetMapperID(); bool HasBattery(); @@ -43,6 +44,7 @@ struct NESHeader uint32_t GetSaveChrRamSize(); uint8_t GetSubMapper(); MirroringType GetMirroringType(); + GameInputType GetControllerType(); VsSystemType GetVsSystemType(); PpuModel GetVsSystemPpuModel(); void SanitizeHeader(size_t romLength); diff --git a/Core/RomData.h b/Core/RomData.h index f4163bc0..0150b4d6 100644 --- a/Core/RomData.h +++ b/Core/RomData.h @@ -71,8 +71,9 @@ struct RomInfo uint8_t SubMapperID = 0; GameSystem System = GameSystem::Unknown; - VsSystemType VsSystemType = VsSystemType::Default; - PpuModel PpuModel = PpuModel::Ppu2C02; + VsSystemType VsType = VsSystemType::Default; + GameInputType InputType = GameInputType::Default; + PpuModel VsPpuModel = PpuModel::Ppu2C02; bool HasChrRam = false; bool HasBattery = false; diff --git a/Core/Types.h b/Core/Types.h index 831a6cba..f9fbe60a 100644 --- a/Core/Types.h +++ b/Core/Types.h @@ -357,7 +357,53 @@ enum class VsSystemType RaidOnBungelingBayProtection = 6, }; -extern const vector PpuModelNames; +enum class GameInputType +{ + Default = 0, + FamicomControllers = 1, + FourScore = 2, + FourPlayerAdapter = 3, + VsSystem = 4, + VsSystemSwapped = 5, + VsSystemSwapAB = 6, + VsZapper = 7, + Zapper = 8, + TwoZappers = 9, + BandaiHypershot = 0x0A, + PowerPadSideA = 0x0B, + PowerPadSideB = 0x0C, + FamilyTrainerSideA = 0x0D, + FamilyTrainerSideB = 0x0E, + ArkanoidControllerNes = 0x0F, + ArkanoidControllerFamicom = 0x10, + //0x11 2x Vaus + KonamiHyperShot = 0x12, + PachinkoController = 0x13, + ExcitingBoxing = 0x14, + JissenMahjong = 0x15, + PartyTap = 0x16, + OekaKidsTablet = 0x17, + BarcodeBattler = 0x18, + //0x19 Miracle Piano + //0x1A Pokkun Moguraa + //0x1B Top Rider + //0x1C Double Fisted + //0x1D Famicom 3D System + //0x1E Doremikko Keyboard + //0x1F ROB + FamicomDataRecorder = 0x20, + TurboFile = 0x21, + BattleBox = 0x22, + FamilyBasicKeyboard = 0x23, + //0x24 PEC 586 keyboard + //0x25 Bit-79 Keyboard + SuborKeyboard = 0x26, + SuborKeyboardMouse1 = 0x27, + SuborKeyboardMouse2 = 0x28, + SnesMouse = 0x29, + //0x30 Generic Multicart +}; + enum class PpuModel { Ppu2C02 = 0, diff --git a/Core/VsControlManager.cpp b/Core/VsControlManager.cpp index 0bde4f8f..f7f0e27f 100644 --- a/Core/VsControlManager.cpp +++ b/Core/VsControlManager.cpp @@ -17,7 +17,7 @@ void VsControlManager::Reset(bool softReset) _protectionCounter = 0; UpdateSlaveMasterBit(_console->IsMaster() ? 0x00 : 0x02); - _vsSystemType = _console->GetRomInfo().VsSystemType; + _vsSystemType = _console->GetRomInfo().VsType; if(!softReset && !_console->IsMaster() && _console->GetDualConsole()) { RegisterInputProvider(this); @@ -54,8 +54,8 @@ void VsControlManager::RemapControllerButtons() return; } - VsInputType inputType = EmulationSettings::GetVsInputType(); - if(inputType == VsInputType::SwapControllers) { + GameInputType inputType = _console->GetRomInfo().InputType; + if(inputType == GameInputType::VsSystemSwapped) { //Swap controllers 1 & 2 ControlDeviceState port1State = controllers[0]->GetRawState(); ControlDeviceState port2State = controllers[1]->GetRawState(); @@ -65,7 +65,7 @@ void VsControlManager::RemapControllerButtons() //But don't swap the start/select buttons BaseControlDevice::SwapButtons(controllers[0], StandardController::Buttons::Start, controllers[1], StandardController::Buttons::Start); BaseControlDevice::SwapButtons(controllers[0], StandardController::Buttons::Select, controllers[1], StandardController::Buttons::Select); - } else if(inputType == VsInputType::SwapAB) { + } else if(inputType == GameInputType::VsSystemSwapAB) { //Swap buttons P1 A & P2 B (Pinball (Japan)) BaseControlDevice::SwapButtons(controllers[0], StandardController::Buttons::B, controllers[1], StandardController::Buttons::A); } diff --git a/Core/VsSystem.h b/Core/VsSystem.h index 05e2d067..5b561295 100644 --- a/Core/VsSystem.h +++ b/Core/VsSystem.h @@ -18,7 +18,7 @@ protected: if(!IsNes20()) { //Force VS system if mapper 99 _romInfo.System = GameSystem::VsSystem; - _romInfo.VsSystemType = VsSystemType::Default; + _romInfo.VsType = VsSystemType::Default; } //"Note: unlike all other mappers, an undersize mapper 99 image implies open bus instead of mirroring." diff --git a/Core/iNesLoader.cpp b/Core/iNesLoader.cpp index 90bbc0e9..64bfcd1d 100644 --- a/Core/iNesLoader.cpp +++ b/Core/iNesLoader.cpp @@ -31,8 +31,8 @@ RomData iNesLoader::LoadRom(vector& romFile, NESHeader *preloadedHeader romData.Info.Mirroring = header.GetMirroringType(); romData.Info.HasBattery = header.HasBattery(); romData.Info.System = header.GetGameSystem(); - romData.Info.VsSystemType = header.GetVsSystemType(); - romData.Info.PpuModel = header.GetVsSystemPpuModel(); + romData.Info.VsType = header.GetVsSystemType(); + romData.Info.VsPpuModel = header.GetVsSystemPpuModel(); romData.Info.HasTrainer = header.HasTrainer(); romData.Info.NesHeader = header; @@ -84,7 +84,7 @@ RomData iNesLoader::LoadRom(vector& romFile, NESHeader *preloadedHeader if(romData.Info.System == GameSystem::VsSystem) { string type = "Vs-UniSystem"; - switch(romData.Info.VsSystemType) { + switch(romData.Info.VsType) { case VsSystemType::IceClimberProtection: type = "VS-UniSystem (Ice Climbers)"; break; case VsSystemType::RaidOnBungelingBayProtection: type = "VS-DualSystem (Raid on Bungeling Bay)"; break; case VsSystemType::RbiBaseballProtection: type = "VS-UniSystem (RBI Baseball)"; break; diff --git a/GUI.NET/Config/Configuration.cs b/GUI.NET/Config/Configuration.cs index e8b53d05..08c2fbee 100644 --- a/GUI.NET/Config/Configuration.cs +++ b/GUI.NET/Config/Configuration.cs @@ -22,7 +22,6 @@ namespace Mesen.GUI.Config public InputInfo InputInfo; public EmulationInfo EmulationInfo; public List RecentFiles; - public List VsConfig; public List Cheats; public bool DisableAllCheats; public NesModel Region; @@ -48,7 +47,6 @@ namespace Mesen.GUI.Config RecentFiles = new List(); InputInfo = new InputInfo(); Cheats = new List(); - VsConfig = new List(); DebugInfo = new DebugInfo(); AviRecordInfo = new AviRecordInfo(); MovieRecordInfo = new MovieRecordInfo(); diff --git a/GUI.NET/Config/VsConfigInfo.cs b/GUI.NET/Config/GameDipswitchDefinition.cs similarity index 50% rename from GUI.NET/Config/VsConfigInfo.cs rename to GUI.NET/Config/GameDipswitchDefinition.cs index dd78d2af..422287f2 100644 --- a/GUI.NET/Config/VsConfigInfo.cs +++ b/GUI.NET/Config/GameDipswitchDefinition.cs @@ -8,60 +8,15 @@ using System.Xml.Serialization; namespace Mesen.GUI.Config { - public class VsConfigInfo - { - public string GameID; - public string GameCrc; - public InteropEmu.PpuModel PpuModel; - public byte DipSwitches; - - [XmlElement("InputScheme")] //Rename node to prevent upgrade issues - public InteropEmu.VsInputType InputType; - - public static VsConfigInfo GetCurrentGameConfig(bool createNew) - { - string crc = InteropEmu.GetRomInfo().GetCrcString(); - foreach(VsConfigInfo config in ConfigManager.Config.VsConfig) { - if(config.GameCrc == crc) { - return config; - } - } - - VsConfigInfo newConfig = new VsConfigInfo(); - newConfig.GameCrc = crc; - newConfig.GameID = VsGameConfig.GetGameID(); - VsGameConfig gameConfig = VsGameConfig.GetGameConfig(newConfig.GameID); - if(gameConfig != null) { - newConfig.PpuModel = gameConfig.PpuModel; - newConfig.DipSwitches = gameConfig.DefaultDipSwitches; - newConfig.InputType = gameConfig.InputType; - } - - if(createNew) { - ConfigManager.Config.VsConfig.Add(newConfig); - } - - return newConfig; - } - - public static void ApplyConfig() - { - VsConfigInfo configInfo = GetCurrentGameConfig(false); - InteropEmu.VsSetGameConfig(configInfo.PpuModel, configInfo.InputType, configInfo.DipSwitches); - } - } - - public class VsGameConfig + public class GameDipswitchDefinition { public string GameName; public string GameID; - public InteropEmu.VsInputType InputType; - public InteropEmu.PpuModel PpuModel; public byte DefaultDipSwitches; public List> DipSwitches; - private static Dictionary _gameConfigs = new Dictionary(); + private static Dictionary _gameConfigs = new Dictionary(); public static string GetGameIdByCrc(UInt32 prgCrc32) { @@ -111,21 +66,14 @@ namespace Mesen.GUI.Config if(gameID != null) { return gameID; - } else { - //Try to guess the game based on filename - string romName = InteropEmu.GetRomInfo().GetRomName().ToLowerInvariant().Replace(" ", ""); - foreach(KeyValuePair kvp in _gameConfigs) { - if(romName.Contains(kvp.Key.ToLowerInvariant().Replace(" ", "")) || romName.Contains(kvp.Value.GameName.ToLowerInvariant().Replace(" ", ""))) { - return kvp.Key; - } - } } return "Unknown"; } - public static VsGameConfig GetGameConfig(string gameID) + public static GameDipswitchDefinition GetDipswitchDefinition() { + string gameID = GetGameID(); if(gameID != null && _gameConfigs.ContainsKey(gameID)) { return _gameConfigs[gameID]; } else { @@ -133,39 +81,24 @@ namespace Mesen.GUI.Config } } - public static Dictionary GetGameConfigs() - { - return _gameConfigs; - } - - static VsGameConfig() + static GameDipswitchDefinition() { XmlDocument config = new XmlDocument(); config.Load(ResourceManager.GetZippedResource("VsSystem.xml")); foreach(XmlNode gameNode in config.SelectNodes("/VsSystemGames/Game")) { - var gameConfig = new VsGameConfig(); - gameConfig.GameID = gameNode.Attributes["ID"].Value; - gameConfig.GameName = gameNode.Attributes["Localization"].Value; + var gameDipswitches = new GameDipswitchDefinition(); + gameDipswitches.GameID = gameNode.Attributes["ID"].Value; + gameDipswitches.GameName = gameNode.Attributes["Localization"].Value; if(gameNode.Attributes["DefaultDip"] != null) { - gameConfig.DefaultDipSwitches = (byte)Int32.Parse(gameNode.Attributes["DefaultDip"].Value); + gameDipswitches.DefaultDipSwitches = (byte)Int32.Parse(gameNode.Attributes["DefaultDip"].Value); } - if(gameNode.Attributes["PpuModel"] != null) { - gameConfig.PpuModel = (InteropEmu.PpuModel)Enum.Parse(typeof(InteropEmu.PpuModel), gameNode.Attributes["PpuModel"].Value); - } else { - gameConfig.PpuModel = InteropEmu.PpuModel.Ppu2C03; - } - if(gameNode.Attributes["InputType"] != null) { - gameConfig.InputType = (InteropEmu.VsInputType)Enum.Parse(typeof(InteropEmu.VsInputType), gameNode.Attributes["InputType"].Value); - } else { - gameConfig.InputType = InteropEmu.VsInputType.Default; - } - gameConfig.DipSwitches = new List>(); + gameDipswitches.DipSwitches = new List>(); foreach(XmlNode dipSwitch in gameNode.SelectNodes("DipSwitch")) { if(dipSwitch.Attributes["Localization"] != null) { var list = new List(); - gameConfig.DipSwitches.Add(list); + gameDipswitches.DipSwitches.Add(list); list.Add(dipSwitch.Attributes["Localization"].Value); foreach(XmlNode option in dipSwitch.SelectNodes("Option")) { @@ -173,14 +106,14 @@ namespace Mesen.GUI.Config } } else { var list = new List(); - gameConfig.DipSwitches.Add(list); + gameDipswitches.DipSwitches.Add(list); list.Add("Unknown"); list.Add("Off"); list.Add("On"); } } - _gameConfigs[gameNode.Attributes["ID"].Value] = gameConfig; + _gameConfigs[gameNode.Attributes["ID"].Value] = gameDipswitches; } } } diff --git a/GUI.NET/Config/GameSpecificInfo.cs b/GUI.NET/Config/GameSpecificInfo.cs index 4fb010ca..7595adf3 100644 --- a/GUI.NET/Config/GameSpecificInfo.cs +++ b/GUI.NET/Config/GameSpecificInfo.cs @@ -18,6 +18,8 @@ namespace Mesen.GUI.Config public UInt32 OverscanTop; public UInt32 OverscanBottom; + public UInt32 DipSwitches = 0; + public static GameSpecificInfo GetGameSpecificInfo() { RomInfo romInfo = InteropEmu.GetRomInfo(); @@ -25,6 +27,53 @@ namespace Mesen.GUI.Config return existingConfig; } + public static void AddGameSpecificConfig(GameSpecificInfo info) + { + if(!ConfigManager.Config.GameSpecificSettings.Contains(info)) { + ConfigManager.Config.GameSpecificSettings.Add(info); + } + } + + public static GameSpecificInfo CreateGameSpecificConfig() + { + RomInfo romInfo = InteropEmu.GetRomInfo(); + GameSpecificInfo info = new GameSpecificInfo(); + info.GameName = romInfo.GetRomName(); + info.GamePrgCrc32 = romInfo.GetPrgCrcString(); + return info; + } + + public static void ApplyGameSpecificConfig() + { + GameSpecificInfo existingConfig = GetGameSpecificInfo(); + if(existingConfig != null) { + InteropEmu.SetDipSwitches(existingConfig.DipSwitches); + } else { + GameDipswitchDefinition dipswitchDefinition = GameDipswitchDefinition.GetDipswitchDefinition(); + if(dipswitchDefinition != null) { + InteropEmu.SetDipSwitches(dipswitchDefinition.DefaultDipSwitches); + } else { + InteropEmu.SetDipSwitches(0); + } + } + } + + public static void SetDipswitches(UInt32 dipswitches) + { + GameSpecificInfo existingConfig = GetGameSpecificInfo(); + + if(existingConfig != null) { + existingConfig.DipSwitches = dipswitches; + } else { + GameSpecificInfo info = new GameSpecificInfo(); + info.DipSwitches = dipswitches; + ConfigManager.Config.GameSpecificSettings.Add(info); + } + ApplyGameSpecificConfig(); + + ConfigManager.ApplyChanges(); + } + public static void SetGameSpecificOverscan(bool overrideOverscan, UInt32 top, UInt32 bottom, UInt32 left, UInt32 right) { RomInfo romInfo = InteropEmu.GetRomInfo(); diff --git a/GUI.NET/Dependencies/resources.ca.xml b/GUI.NET/Dependencies/resources.ca.xml index 34d8ef65..59802f5e 100644 --- a/GUI.NET/Dependencies/resources.ca.xml +++ b/GUI.NET/Dependencies/resources.ca.xml @@ -17,7 +17,7 @@ Canvia la cara del disc Escull el disc Expulsa el disc - Configuració de joc VS + Configuració de joc Insereix moneda (1) Insereix moneda (2) Introdueix un codi de barres @@ -533,10 +533,7 @@ Si desitgeu col·laborar amb Mesen, si us plau, considereu fer un donatiu. Gràcies pel vostre suport. &D'acord -
- Joc - Model de PPU - Input Type: + Interruptors DIP
diff --git a/GUI.NET/Dependencies/resources.en.xml b/GUI.NET/Dependencies/resources.en.xml index d4cc0661..5e041b35 100644 --- a/GUI.NET/Dependencies/resources.en.xml +++ b/GUI.NET/Dependencies/resources.en.xml @@ -17,7 +17,7 @@ Switch Disk Side Select Disk Eject Disk - Game Configuration + Game Configuration Insert Coin (1) Insert Coin (2) Input Barcode... @@ -544,10 +544,7 @@ If you want to support Mesen, please consider donating. Thank you for your support! &OK
-
- Game: - PPU Model: - Input Type: + DIP Switches
diff --git a/GUI.NET/Dependencies/resources.es.xml b/GUI.NET/Dependencies/resources.es.xml index 93f1162b..624626ba 100644 --- a/GUI.NET/Dependencies/resources.es.xml +++ b/GUI.NET/Dependencies/resources.es.xml @@ -17,7 +17,7 @@ Cambiar la cara del disco Elegir el disco Expulsar el disco - Configuración de juego VS + Configuración de juego Insertar moneda (1) Insertar moneda (2) Insertar código de barras @@ -531,10 +531,7 @@ Si deseas colaborar con Mesen, por favor considera hacer una donación. ¡Gracias por tu colaboración! &OK
-
- Juego - Modelo de PPU - Input Type: + Conmutadores DIP
diff --git a/GUI.NET/Dependencies/resources.fr.xml b/GUI.NET/Dependencies/resources.fr.xml index 458fa97a..6709c93a 100644 --- a/GUI.NET/Dependencies/resources.fr.xml +++ b/GUI.NET/Dependencies/resources.fr.xml @@ -17,7 +17,7 @@ Changer le disque de côté Choisir le disque Éjecter le disque - Configuration du jeu VS + Configuration du jeu Insérer une pièce (1) Insérer une pièce (2) Entrer un code-barres @@ -543,10 +543,7 @@ Si vous voulez supporter le développement de Mesen, vous pouvez faire une donation. Merci de votre support! &OK
-
- Jeu - Modèle du PPU - Manettes: + Commutateurs DIP
diff --git a/GUI.NET/Dependencies/resources.ja.xml b/GUI.NET/Dependencies/resources.ja.xml index 67a8fcff..5c2c2073 100644 --- a/GUI.NET/Dependencies/resources.ja.xml +++ b/GUI.NET/Dependencies/resources.ja.xml @@ -17,7 +17,7 @@ A面B面切り替え ディスク選択 ディスクを取り出す - VSゲームの設定 + ゲーム設定 インサートコイン 1 インサートコイン 2 バーコードを入力 @@ -533,10 +533,7 @@ 応援ありがとうございます! &OK
-
- ゲーム: - PPUモデル: - コントローラ設定: + ディップスイッチ
diff --git a/GUI.NET/Dependencies/resources.pt.xml b/GUI.NET/Dependencies/resources.pt.xml index 1c29f78d..0adb9a78 100644 --- a/GUI.NET/Dependencies/resources.pt.xml +++ b/GUI.NET/Dependencies/resources.pt.xml @@ -17,7 +17,7 @@ Trocar o lado do disco Selecionar o disco Ejetar o disco - Configuração de jogo VS + Configuração de jogo Inserir moeda (1) Inserir moeda (2) Entrar código de barra @@ -529,10 +529,7 @@ Caso queira apoiar o Mesen, por favor, considere fazer uma doação ao projeto. Obrigado pelo seu apoio! &OK
-
- Jogo - Modelo da PPU - Input Type: + Comutadores DIP
diff --git a/GUI.NET/Dependencies/resources.ru.xml b/GUI.NET/Dependencies/resources.ru.xml index 3d4f69ba..f3b9e350 100644 --- a/GUI.NET/Dependencies/resources.ru.xml +++ b/GUI.NET/Dependencies/resources.ru.xml @@ -17,7 +17,7 @@ Сменить сторону диска Выбрать диск Извлечь диск - Конфигурация VS + Конфигурация Вставить монету в слот 1 Вставить монету в слот 2 Input Barcode @@ -531,10 +531,7 @@ If you want to support Mesen, please consider donating. Thank you for your support! &OK
-
- Игра - Модель PPU - Input Type: + DIP Switches
diff --git a/GUI.NET/Dependencies/resources.uk.xml b/GUI.NET/Dependencies/resources.uk.xml index 6ef4e504..434b178f 100644 --- a/GUI.NET/Dependencies/resources.uk.xml +++ b/GUI.NET/Dependencies/resources.uk.xml @@ -17,7 +17,7 @@ Змінити сторону диска Вибрати диск Вилучити диск - Конфігурація VS + Конфігурація Вставити монету в слот 1 Вставити монету в слот 2 Input Barcode @@ -531,10 +531,7 @@ Якщо ви хочете підтримати Mesen, будь ласка підтримайте. Дякую за вашу підтримку! &OK
-
- Гра - Модель PPU - Input Type: + Перемикачі DIP
diff --git a/GUI.NET/Forms/Config/frmGameConfig.Designer.cs b/GUI.NET/Forms/Config/frmGameConfig.Designer.cs new file mode 100644 index 00000000..c5bc1ff4 --- /dev/null +++ b/GUI.NET/Forms/Config/frmGameConfig.Designer.cs @@ -0,0 +1,111 @@ +namespace Mesen.GUI.Forms.Config +{ + partial class frmGameConfig + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tlpMain = new System.Windows.Forms.TableLayoutPanel(); + this.grpDipSwitches = new System.Windows.Forms.GroupBox(); + this.btnReset = new System.Windows.Forms.Button(); + this.baseConfigPanel.SuspendLayout(); + this.tlpMain.SuspendLayout(); + this.SuspendLayout(); + // + // baseConfigPanel + // + this.baseConfigPanel.Controls.Add(this.btnReset); + this.baseConfigPanel.Location = new System.Drawing.Point(0, 246); + this.baseConfigPanel.Size = new System.Drawing.Size(305, 29); + this.baseConfigPanel.Controls.SetChildIndex(this.btnReset, 0); + // + // tlpMain + // + this.tlpMain.ColumnCount = 2; + this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tlpMain.Controls.Add(this.grpDipSwitches, 0, 0); + this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.tlpMain.Location = new System.Drawing.Point(0, 0); + this.tlpMain.Name = "tlpMain"; + this.tlpMain.RowCount = 1; + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tlpMain.Size = new System.Drawing.Size(305, 275); + this.tlpMain.TabIndex = 0; + // + // grpDipSwitches + // + this.tlpMain.SetColumnSpan(this.grpDipSwitches, 2); + this.grpDipSwitches.Dock = System.Windows.Forms.DockStyle.Fill; + this.grpDipSwitches.Location = new System.Drawing.Point(3, 3); + this.grpDipSwitches.Margin = new System.Windows.Forms.Padding(3, 3, 3, 30); + this.grpDipSwitches.Name = "grpDipSwitches"; + this.grpDipSwitches.Size = new System.Drawing.Size(299, 242); + this.grpDipSwitches.TabIndex = 3; + this.grpDipSwitches.TabStop = false; + this.grpDipSwitches.Text = "DIP Switches"; + // + // btnReset + // + this.btnReset.AutoSize = true; + this.btnReset.Location = new System.Drawing.Point(6, 3); + this.btnReset.Name = "btnReset"; + this.btnReset.Size = new System.Drawing.Size(94, 23); + this.btnReset.TabIndex = 3; + this.btnReset.Text = "Reset to Default"; + this.btnReset.UseVisualStyleBackColor = true; + this.btnReset.Click += new System.EventHandler(this.btnReset_Click); + // + // frmGameConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(305, 275); + this.Controls.Add(this.tlpMain); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "frmGameConfig"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Game Configuration"; + this.Controls.SetChildIndex(this.tlpMain, 0); + this.Controls.SetChildIndex(this.baseConfigPanel, 0); + this.baseConfigPanel.ResumeLayout(false); + this.baseConfigPanel.PerformLayout(); + this.tlpMain.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tlpMain; + private System.Windows.Forms.GroupBox grpDipSwitches; + private System.Windows.Forms.Button btnReset; + } +} \ No newline at end of file diff --git a/GUI.NET/Forms/Config/frmVsGameConfig.cs b/GUI.NET/Forms/Config/frmGameConfig.cs similarity index 58% rename from GUI.NET/Forms/Config/frmVsGameConfig.cs rename to GUI.NET/Forms/Config/frmGameConfig.cs index 3850b501..bd9bd877 100644 --- a/GUI.NET/Forms/Config/frmVsGameConfig.cs +++ b/GUI.NET/Forms/Config/frmGameConfig.cs @@ -11,58 +11,31 @@ using Mesen.GUI.Config; namespace Mesen.GUI.Forms.Config { - public partial class frmVsGameConfig : BaseConfigForm + public partial class frmGameConfig : BaseConfigForm { - private class DropdownElement - { - public string Name; - public string ID; - - public override string ToString() - { - return Name; - } - } - - public frmVsGameConfig(VsConfigInfo configInfo) + public frmGameConfig(GameSpecificInfo configInfo) { InitializeComponent(); + GameSpecificInfo existingConfig = GameSpecificInfo.GetGameSpecificInfo(); + if(existingConfig == null) { + GameDipswitchDefinition dipswitchDefinition = GameDipswitchDefinition.GetDipswitchDefinition(); + configInfo.DipSwitches = dipswitchDefinition.DefaultDipSwitches; + } + Entity = configInfo; - - if(VsGameConfig.GetGameIdByCrc(InteropEmu.GetRomInfo().PrgCrc32) != null) { - cboGame.Enabled = false; - } - - AddBinding("PpuModel", cboPpuModel); - AddBinding("InputType", cboInputType); - - foreach(KeyValuePair kvp in VsGameConfig.GetGameConfigs()) { - cboGame.Items.Add(new DropdownElement { Name = kvp.Value.GameName, ID = kvp.Value.GameID }); - if(kvp.Key == configInfo.GameID) { - cboGame.SelectedIndex = cboGame.Items.Count - 1; - } - } + UpdateDipSwitches(); } - private void cboGame_SelectedIndexChanged(object sender, EventArgs e) + private void UpdateDipSwitches() { - VsGameConfig config = VsGameConfig.GetGameConfig(((DropdownElement)cboGame.SelectedItem).ID); - UpdateDipSwitches(config, false); - } + GameDipswitchDefinition dipswitchDefinition = GameDipswitchDefinition.GetDipswitchDefinition(); - private void UpdateDipSwitches(VsGameConfig config, bool updateDropdown) - { grpDipSwitches.Controls.Clear(); List> dipSwitches; - if(config != null) { - dipSwitches = config.DipSwitches; - if(updateDropdown) { - cboGame.SelectedIndexChanged -= cboGame_SelectedIndexChanged; - cboGame.SelectedItem = config.GameName; - cboGame.SelectedIndexChanged += cboGame_SelectedIndexChanged; - } + if(dipswitchDefinition != null) { + dipSwitches = dipswitchDefinition.DipSwitches; } else { dipSwitches = new List>(); for(int i = 0; i < 8; i++) { @@ -77,7 +50,7 @@ namespace Mesen.GUI.Forms.Config tlpDipSwitches.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); tlpDipSwitches.ColumnCount = 2; - byte value = ((VsConfigInfo)Entity).DipSwitches; + UInt32 value = ((GameSpecificInfo)Entity).DipSwitches; int currentBit = 0; foreach(List setting in dipSwitches) { var optionLabel = new Label(); @@ -94,7 +67,7 @@ namespace Mesen.GUI.Forms.Config int bitCount = (int)Math.Round(Math.Log(optionDropdown.Items.Count) / Math.Log(2)); - int selectedIndex = (value >> currentBit) & ((1 << bitCount) - 1); + int selectedIndex = (int)((value >> currentBit) & ((1 << bitCount) - 1)); optionDropdown.SelectedIndex = selectedIndex; optionDropdown.Dock = DockStyle.Fill; currentBit += bitCount; @@ -111,13 +84,13 @@ namespace Mesen.GUI.Forms.Config tlpDipSwitches.PerformLayout(); } - private byte GetDipSwitchValue() + private UInt32 GetDipSwitchValue() { int value = 0; int currentBit = 0; if(grpDipSwitches.Controls.Count > 0) { foreach(Control control in grpDipSwitches.Controls[0].Controls) { - if(control is ComboBox && control != cboPpuModel) { + if(control is ComboBox) { ComboBox dipSwitch = (ComboBox)control; int bitCount = (int)Math.Round(Math.Log(dipSwitch.Items.Count) / Math.Log(2)); @@ -137,18 +110,24 @@ namespace Mesen.GUI.Forms.Config { base.UpdateConfig(); - ((VsConfigInfo)Entity).DipSwitches = (byte)GetDipSwitchValue(); - ((VsConfigInfo)Entity).GameID = ((DropdownElement)cboGame.SelectedItem).ID; + ((GameSpecificInfo)Entity).DipSwitches = GetDipSwitchValue(); + } + + protected override void OnFormClosed(FormClosedEventArgs e) + { + if(this.DialogResult == DialogResult.OK) { + GameSpecificInfo.AddGameSpecificConfig((GameSpecificInfo)Entity); + GameSpecificInfo.ApplyGameSpecificConfig(); + } + base.OnFormClosed(e); } private void btnReset_Click(object sender, EventArgs e) { - VsGameConfig defaultConfig = VsGameConfig.GetGameConfig(((DropdownElement)cboGame.SelectedItem).ID); - ((VsConfigInfo)Entity).DipSwitches = defaultConfig.DefaultDipSwitches; - ((VsConfigInfo)Entity).PpuModel = defaultConfig.PpuModel; - ((VsConfigInfo)Entity).InputType = defaultConfig.InputType; + GameDipswitchDefinition defaultConfig = GameDipswitchDefinition.GetDipswitchDefinition(); + ((GameSpecificInfo)Entity).DipSwitches = defaultConfig.DefaultDipSwitches; UpdateUI(); - UpdateDipSwitches(defaultConfig, false); + UpdateDipSwitches(); } } diff --git a/GUI.NET/Forms/Config/frmVsGameConfig.resx b/GUI.NET/Forms/Config/frmGameConfig.resx similarity index 100% rename from GUI.NET/Forms/Config/frmVsGameConfig.resx rename to GUI.NET/Forms/Config/frmGameConfig.resx diff --git a/GUI.NET/Forms/Config/frmVsGameConfig.Designer.cs b/GUI.NET/Forms/Config/frmVsGameConfig.Designer.cs deleted file mode 100644 index afce2dec..00000000 --- a/GUI.NET/Forms/Config/frmVsGameConfig.Designer.cs +++ /dev/null @@ -1,188 +0,0 @@ -namespace Mesen.GUI.Forms.Config -{ - partial class frmVsGameConfig - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if(disposing && (components != null)) { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.tlpMain = new System.Windows.Forms.TableLayoutPanel(); - this.cboGame = new System.Windows.Forms.ComboBox(); - this.lblGame = new System.Windows.Forms.Label(); - this.lblPpuModel = new System.Windows.Forms.Label(); - this.cboPpuModel = new System.Windows.Forms.ComboBox(); - this.grpDipSwitches = new System.Windows.Forms.GroupBox(); - this.btnReset = new System.Windows.Forms.Button(); - this.lblInputType = new System.Windows.Forms.Label(); - this.cboInputType = new System.Windows.Forms.ComboBox(); - this.baseConfigPanel.SuspendLayout(); - this.tlpMain.SuspendLayout(); - this.SuspendLayout(); - // - // baseConfigPanel - // - this.baseConfigPanel.Controls.Add(this.btnReset); - this.baseConfigPanel.Location = new System.Drawing.Point(0, 325); - this.baseConfigPanel.Size = new System.Drawing.Size(305, 29); - this.baseConfigPanel.Controls.SetChildIndex(this.btnReset, 0); - // - // tlpMain - // - this.tlpMain.ColumnCount = 2; - this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tlpMain.Controls.Add(this.cboInputType, 0, 2); - this.tlpMain.Controls.Add(this.lblInputType, 0, 2); - this.tlpMain.Controls.Add(this.cboGame, 1, 0); - this.tlpMain.Controls.Add(this.lblGame, 0, 0); - this.tlpMain.Controls.Add(this.lblPpuModel, 0, 1); - this.tlpMain.Controls.Add(this.cboPpuModel, 1, 1); - this.tlpMain.Controls.Add(this.grpDipSwitches, 0, 3); - this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill; - this.tlpMain.Location = new System.Drawing.Point(0, 0); - this.tlpMain.Name = "tlpMain"; - this.tlpMain.RowCount = 4; - this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tlpMain.Size = new System.Drawing.Size(305, 354); - this.tlpMain.TabIndex = 0; - // - // cboGame - // - this.cboGame.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cboGame.FormattingEnabled = true; - this.cboGame.Location = new System.Drawing.Point(73, 3); - this.cboGame.Name = "cboGame"; - this.cboGame.Size = new System.Drawing.Size(194, 21); - this.cboGame.TabIndex = 5; - this.cboGame.SelectedIndexChanged += new System.EventHandler(this.cboGame_SelectedIndexChanged); - // - // lblGame - // - this.lblGame.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.lblGame.AutoSize = true; - this.lblGame.Location = new System.Drawing.Point(3, 7); - this.lblGame.Name = "lblGame"; - this.lblGame.Size = new System.Drawing.Size(38, 13); - this.lblGame.TabIndex = 4; - this.lblGame.Text = "Game:"; - // - // lblPpuModel - // - this.lblPpuModel.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.lblPpuModel.AutoSize = true; - this.lblPpuModel.Location = new System.Drawing.Point(3, 34); - this.lblPpuModel.Name = "lblPpuModel"; - this.lblPpuModel.Size = new System.Drawing.Size(64, 13); - this.lblPpuModel.TabIndex = 1; - this.lblPpuModel.Text = "PPU Model:"; - // - // cboPpuModel - // - this.cboPpuModel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cboPpuModel.FormattingEnabled = true; - this.cboPpuModel.Location = new System.Drawing.Point(73, 30); - this.cboPpuModel.Name = "cboPpuModel"; - this.cboPpuModel.Size = new System.Drawing.Size(194, 21); - this.cboPpuModel.TabIndex = 2; - // - // grpDipSwitches - // - this.tlpMain.SetColumnSpan(this.grpDipSwitches, 2); - this.grpDipSwitches.Dock = System.Windows.Forms.DockStyle.Fill; - this.grpDipSwitches.Location = new System.Drawing.Point(3, 84); - this.grpDipSwitches.Margin = new System.Windows.Forms.Padding(3, 3, 3, 30); - this.grpDipSwitches.Name = "grpDipSwitches"; - this.grpDipSwitches.Size = new System.Drawing.Size(299, 240); - this.grpDipSwitches.TabIndex = 3; - this.grpDipSwitches.TabStop = false; - this.grpDipSwitches.Text = "DIP Switches"; - // - // btnReset - // - this.btnReset.AutoSize = true; - this.btnReset.Location = new System.Drawing.Point(6, 3); - this.btnReset.Name = "btnReset"; - this.btnReset.Size = new System.Drawing.Size(94, 23); - this.btnReset.TabIndex = 3; - this.btnReset.Text = "Reset to Default"; - this.btnReset.UseVisualStyleBackColor = true; - this.btnReset.Click += new System.EventHandler(this.btnReset_Click); - // - // lblInputType - // - this.lblInputType.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.lblInputType.AutoSize = true; - this.lblInputType.Location = new System.Drawing.Point(3, 61); - this.lblInputType.Name = "lblInputType"; - this.lblInputType.Size = new System.Drawing.Size(61, 13); - this.lblInputType.TabIndex = 6; - this.lblInputType.Text = "Input Type:"; - // - // cboInputType - // - this.cboInputType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cboInputType.FormattingEnabled = true; - this.cboInputType.Location = new System.Drawing.Point(73, 57); - this.cboInputType.Name = "cboInputType"; - this.cboInputType.Size = new System.Drawing.Size(194, 21); - this.cboInputType.TabIndex = 7; - // - // frmVsGameConfig - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(305, 354); - this.Controls.Add(this.tlpMain); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "frmVsGameConfig"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Game Configuration"; - this.Controls.SetChildIndex(this.tlpMain, 0); - this.Controls.SetChildIndex(this.baseConfigPanel, 0); - this.baseConfigPanel.ResumeLayout(false); - this.baseConfigPanel.PerformLayout(); - this.tlpMain.ResumeLayout(false); - this.tlpMain.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.TableLayoutPanel tlpMain; - private System.Windows.Forms.Label lblPpuModel; - private System.Windows.Forms.ComboBox cboPpuModel; - private System.Windows.Forms.GroupBox grpDipSwitches; - private System.Windows.Forms.ComboBox cboGame; - private System.Windows.Forms.Label lblGame; - private System.Windows.Forms.Button btnReset; - private System.Windows.Forms.ComboBox cboInputType; - private System.Windows.Forms.Label lblInputType; - } -} \ No newline at end of file diff --git a/GUI.NET/Forms/frmMain.Designer.cs b/GUI.NET/Forms/frmMain.Designer.cs index 79e20103..84dcabc5 100644 --- a/GUI.NET/Forms/frmMain.Designer.cs +++ b/GUI.NET/Forms/frmMain.Designer.cs @@ -63,7 +63,7 @@ namespace Mesen.GUI.Forms this.mnuSelectDisk = new System.Windows.Forms.ToolStripMenuItem(); this.mnuEjectDisk = new System.Windows.Forms.ToolStripMenuItem(); this.sepVsSystem = new System.Windows.Forms.ToolStripSeparator(); - this.mnuVsGameConfig = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuGameConfig = new System.Windows.Forms.ToolStripMenuItem(); this.mnuInsertCoin1 = new System.Windows.Forms.ToolStripMenuItem(); this.mnuInsertCoin2 = new System.Windows.Forms.ToolStripMenuItem(); this.sepBarcode = new System.Windows.Forms.ToolStripSeparator(); @@ -433,7 +433,7 @@ namespace Mesen.GUI.Forms this.mnuSelectDisk, this.mnuEjectDisk, this.sepVsSystem, - this.mnuVsGameConfig, + this.mnuGameConfig, this.mnuInsertCoin1, this.mnuInsertCoin2, this.sepBarcode, @@ -513,13 +513,13 @@ namespace Mesen.GUI.Forms this.sepVsSystem.Size = new System.Drawing.Size(179, 6); this.sepVsSystem.Visible = false; // - // mnuVsGameConfig + // mnuGameConfig // - this.mnuVsGameConfig.Image = global::Mesen.GUI.Properties.Resources.DipSwitches; - this.mnuVsGameConfig.Name = "mnuVsGameConfig"; - this.mnuVsGameConfig.Size = new System.Drawing.Size(182, 22); - this.mnuVsGameConfig.Text = "Game Configuration"; - this.mnuVsGameConfig.Click += new System.EventHandler(this.mnuVsGameConfig_Click); + this.mnuGameConfig.Image = global::Mesen.GUI.Properties.Resources.DipSwitches; + this.mnuGameConfig.Name = "mnuGameConfig"; + this.mnuGameConfig.Size = new System.Drawing.Size(182, 22); + this.mnuGameConfig.Text = "Game Configuration"; + this.mnuGameConfig.Click += new System.EventHandler(this.mnuGameConfig_Click); // // mnuInsertCoin1 // @@ -1813,7 +1813,7 @@ namespace Mesen.GUI.Forms private System.Windows.Forms.ToolStripMenuItem mnuFullscreen; private System.Windows.Forms.ToolStripSeparator sepVsSystem; private System.Windows.Forms.ToolStripMenuItem mnuInsertCoin1; - private System.Windows.Forms.ToolStripMenuItem mnuVsGameConfig; + private System.Windows.Forms.ToolStripMenuItem mnuGameConfig; private System.Windows.Forms.ToolStripMenuItem mnuInsertCoin2; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem15; private System.Windows.Forms.ToolStripMenuItem mnuXBRZ2xFilter; diff --git a/GUI.NET/Forms/frmMain.Game.cs b/GUI.NET/Forms/frmMain.Game.cs index db213012..d3a2c3a2 100644 --- a/GUI.NET/Forms/frmMain.Game.cs +++ b/GUI.NET/Forms/frmMain.Game.cs @@ -56,22 +56,23 @@ namespace Mesen.GUI.Forms sepVsSystem.Visible = InteropEmu.IsVsSystem(); mnuInsertCoin1.Visible = InteropEmu.IsVsSystem(); mnuInsertCoin2.Visible = InteropEmu.IsVsSystem(); - mnuVsGameConfig.Visible = InteropEmu.IsVsSystem(); + mnuGameConfig.Visible = InteropEmu.IsVsSystem(); } - private void ShowVsGameConfig() + private void ShowGameConfig() { - VsConfigInfo configInfo = VsConfigInfo.GetCurrentGameConfig(true); - using(frmVsGameConfig frm = new frmVsGameConfig(configInfo)) { - if(frm.ShowDialog(null, this) == DialogResult.OK) { - VsConfigInfo.ApplyConfig(); - } + GameSpecificInfo configInfo = GameSpecificInfo.GetGameSpecificInfo(); + if(configInfo == null) { + configInfo = GameSpecificInfo.CreateGameSpecificConfig(); + } + using(frmGameConfig frm = new frmGameConfig(configInfo)) { + frm.ShowDialog(null, this); } } - private void mnuVsGameConfig_Click(object sender, EventArgs e) + private void mnuGameConfig_Click(object sender, EventArgs e) { - ShowVsGameConfig(); + ShowGameConfig(); } private void mnuLoadTapeFile_Click(object sender, EventArgs e) diff --git a/GUI.NET/Forms/frmMain.Help.cs b/GUI.NET/Forms/frmMain.Help.cs index 2cc978ef..c8b96daf 100644 --- a/GUI.NET/Forms/frmMain.Help.cs +++ b/GUI.NET/Forms/frmMain.Help.cs @@ -19,12 +19,6 @@ namespace Mesen.GUI.Forms Version oldVersion = new Version(ConfigManager.Config.MesenVersion); if(oldVersion < newVersion) { //Upgrade - if(oldVersion <= new Version("0.3.0")) { - //Version 0.3.0- - //Remove all old VS system config to make sure the new defaults are used - ConfigManager.Config.VsConfig = new List(); - } - if(oldVersion <= new Version("0.4.1")) { //Version 0.4.1- //Remove all old cheats (Game matching/CRC logic has been changed and no longer compatible) @@ -98,9 +92,6 @@ namespace Mesen.GUI.Forms //No reason to keep this disabled by default - enabling it by default makes it easier for new users to install/use HD packs ConfigManager.Config.VideoInfo.UseHdPacks = true; - - //Clear VS game config information due to changes in the data model - ConfigManager.Config.VsConfig = new List(); } ConfigManager.Config.MesenVersion = InteropEmu.GetMesenVersion(); diff --git a/GUI.NET/Forms/frmMain.cs b/GUI.NET/Forms/frmMain.cs index 13932df9..12172633 100644 --- a/GUI.NET/Forms/frmMain.cs +++ b/GUI.NET/Forms/frmMain.cs @@ -593,12 +593,12 @@ namespace Mesen.GUI.Forms InteropEmu.SetNesModel(ConfigManager.Config.Region); InitializeNsfMode(false, true); CheatInfo.ApplyCheats(); - VsConfigInfo.ApplyConfig(); + GameSpecificInfo.ApplyGameSpecificConfig(); UpdateStateMenu(mnuSaveState, true); UpdateStateMenu(mnuLoadState, false); if(ConfigManager.Config.PreferenceInfo.ShowVsConfigOnLoad && InteropEmu.IsVsSystem()) { this.Invoke((MethodInvoker)(() => { - this.ShowVsGameConfig(); + this.ShowGameConfig(); })); } @@ -1079,7 +1079,7 @@ namespace Mesen.GUI.Forms mnuPlayMovie.Enabled = !netPlay && !moviePlaying && !movieRecording; mnuStopMovie.Enabled = running && !netPlay && (moviePlaying || movieRecording); mnuRecordMovie.Enabled = running && !moviePlaying && !movieRecording && !isNetPlayClient; - mnuVsGameConfig.Enabled = !moviePlaying && !movieRecording; + mnuGameConfig.Enabled = !moviePlaying && !movieRecording; bool waveRecording = InteropEmu.WaveIsRecording(); mnuWaveRecord.Enabled = running && !waveRecording; diff --git a/GUI.NET/GUI.NET.csproj b/GUI.NET/GUI.NET.csproj index 43186bfc..440abffe 100644 --- a/GUI.NET/GUI.NET.csproj +++ b/GUI.NET/GUI.NET.csproj @@ -259,7 +259,7 @@ - + UserControl @@ -1057,11 +1057,11 @@ frmCheatList.cs - + Form - - frmVsGameConfig.cs + + frmGameConfig.cs UserControl @@ -1640,8 +1640,8 @@ frmCheatList.cs Designer - - frmVsGameConfig.cs + + frmGameConfig.cs ctrlPowerPadConfig.cs diff --git a/GUI.NET/InteropEmu.cs b/GUI.NET/InteropEmu.cs index 6054bcbd..2d4e53d1 100644 --- a/GUI.NET/InteropEmu.cs +++ b/GUI.NET/InteropEmu.cs @@ -143,7 +143,8 @@ namespace Mesen.GUI [DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool IsVsSystem(); [DllImport(DLLPath)] public static extern void VsInsertCoin(UInt32 port); - [DllImport(DLLPath)] public static extern void VsSetGameConfig(PpuModel model, VsInputType inputType, byte dipSwitches); + + [DllImport(DLLPath)] public static extern void SetDipSwitches(UInt32 dipSwitches); [DllImport(DLLPath)] public static extern void InputBarcode(UInt64 barcode, Int32 digitCount); diff --git a/InteropDLL/ConsoleWrapper.cpp b/InteropDLL/ConsoleWrapper.cpp index 05d17805..9f20cbba 100644 --- a/InteropDLL/ConsoleWrapper.cpp +++ b/InteropDLL/ConsoleWrapper.cpp @@ -625,13 +625,9 @@ namespace InteropEmu { } } - DllExport void __stdcall VsSetGameConfig(PpuModel model, VsInputType inputType, uint8_t dipSwitches) + DllExport void __stdcall SetDipSwitches(uint32_t dipSwitches) { - if(dynamic_cast(_console->GetControlManager())) { - EmulationSettings::SetPpuModel(model); - EmulationSettings::SetDipSwitches(dipSwitches); - EmulationSettings::SetVsInputType(inputType); - } + EmulationSettings::SetDipSwitches(dipSwitches); } DllExport bool __stdcall IsHdPpu() { return _console->IsHdPpu(); }