VS System: Cleanup config UI (keep DIP switches only) + support for NES 2.0 input type proposal (WIP)

This commit is contained in:
Sour 2018-07-07 17:30:13 -04:00
parent d72d1f3c6d
commit 3ac8cb2018
38 changed files with 428 additions and 492 deletions

View file

@ -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;

View file

@ -67,7 +67,6 @@ std::unordered_map<uint32_t, vector<KeyCombination>> 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<string> ExpansionPortDeviceNames = {
"AsciiTurboFile",
"BattleBox",
};
const vector<string> PpuModelNames = {
"Ppu2C02",
"Ppu2C03",
"Ppu2C04A",
"Ppu2C04B",
"Ppu2C04C",
"Ppu2C04D",
"Ppu2C05A",
"Ppu2C05B",
"Ppu2C05C",
"Ppu2C05D",
"Ppu2C05E"
};

View file

@ -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;

View file

@ -153,7 +153,7 @@ RomData FdsLoader::LoadRom(vector<uint8_t>& romFile, string filename)
//Setup default controllers
if(!_checkOnly && EmulationSettings::CheckFlag(EmulationFlags::AutoConfigureInput)) {
GameDatabase::InitializeInputDevices("", GameSystem::FDS);
GameDatabase::InitializeInputDevices(GameInputType::FamicomControllers, GameSystem::FDS);
}
return romData;

View file

@ -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);
}

View file

@ -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<string> 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);

View file

@ -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();

View file

@ -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()) {

View file

@ -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";
};

View file

@ -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) {

View file

@ -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);

View file

@ -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;

View file

@ -357,7 +357,53 @@ enum class VsSystemType
RaidOnBungelingBayProtection = 6,
};
extern const vector<string> 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,

View file

@ -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);
}

View file

@ -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."

View file

@ -31,8 +31,8 @@ RomData iNesLoader::LoadRom(vector<uint8_t>& 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<uint8_t>& 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;

View file

@ -22,7 +22,6 @@ namespace Mesen.GUI.Config
public InputInfo InputInfo;
public EmulationInfo EmulationInfo;
public List<RecentItem> RecentFiles;
public List<VsConfigInfo> VsConfig;
public List<CheatInfo> Cheats;
public bool DisableAllCheats;
public NesModel Region;
@ -48,7 +47,6 @@ namespace Mesen.GUI.Config
RecentFiles = new List<RecentItem>();
InputInfo = new InputInfo();
Cheats = new List<CheatInfo>();
VsConfig = new List<VsConfigInfo>();
DebugInfo = new DebugInfo();
AviRecordInfo = new AviRecordInfo();
MovieRecordInfo = new MovieRecordInfo();

View file

@ -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<List<string>> DipSwitches;
private static Dictionary<string, VsGameConfig> _gameConfigs = new Dictionary<string, VsGameConfig>();
private static Dictionary<string, GameDipswitchDefinition> _gameConfigs = new Dictionary<string, GameDipswitchDefinition>();
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<string, VsGameConfig> 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<string, VsGameConfig> 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<List<string>>();
gameDipswitches.DipSwitches = new List<List<string>>();
foreach(XmlNode dipSwitch in gameNode.SelectNodes("DipSwitch")) {
if(dipSwitch.Attributes["Localization"] != null) {
var list = new List<string>();
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<string>();
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;
}
}
}

View file

@ -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();

View file

@ -17,7 +17,7 @@
<Control ID="mnuSwitchDiskSide">Canvia la cara del disc</Control>
<Control ID="mnuSelectDisk">Escull el disc</Control>
<Control ID="mnuEjectDisk">Expulsa el disc</Control>
<Control ID="mnuVsGameConfig">Configuració de joc VS</Control>
<Control ID="mnuGameConfig">Configuració de joc</Control>
<Control ID="mnuInsertCoin1">Insereix moneda (1)</Control>
<Control ID="mnuInsertCoin2">Insereix moneda (2)</Control>
<Control ID="mnuInputBarcode">Introdueix un codi de barres</Control>
@ -533,10 +533,7 @@
<Control ID="lblDonate">Si desitgeu col·laborar amb Mesen, si us plau, considereu fer un donatiu.&#xA;Gràcies pel vostre suport.</Control>
<Control ID="okButton">&amp;D'acord</Control>
</Form>
<Form ID="frmVsGameConfig" Title="Configuració de joc VS">
<Control ID="lblGame">Joc</Control>
<Control ID="lblPpuModel">Model de PPU</Control>
<Control ID="lblInputType">Input Type:</Control>
<Form ID="frmGameConfig" Title="Configuració de joc">
<Control ID="grpDipSwitches">Interruptors DIP</Control>
</Form>
<Form ID="frmUpdatePrompt" Title="Mesen - Actualització disponible">

View file

@ -17,7 +17,7 @@
<Control ID="mnuSwitchDiskSide">Switch Disk Side</Control>
<Control ID="mnuSelectDisk">Select Disk</Control>
<Control ID="mnuEjectDisk">Eject Disk</Control>
<Control ID="mnuVsGameConfig">Game Configuration</Control>
<Control ID="mnuGameConfig">Game Configuration</Control>
<Control ID="mnuInsertCoin1">Insert Coin (1)</Control>
<Control ID="mnuInsertCoin2">Insert Coin (2)</Control>
<Control ID="mnuInputBarcode">Input Barcode...</Control>
@ -544,10 +544,7 @@
<Control ID="lblDonate">If you want to support Mesen, please consider donating.&#13;Thank you for your support!</Control>
<Control ID="okButton">&amp;OK</Control>
</Form>
<Form ID="frmVsGameConfig" Title="Game Configuration">
<Control ID="lblGame">Game:</Control>
<Control ID="lblPpuModel">PPU Model:</Control>
<Control ID="lblInputType">Input Type:</Control>
<Form ID="frmGameConfig" Title="Game Configuration">
<Control ID="grpDipSwitches">DIP Switches</Control>
</Form>
<Form ID="frmUpdatePrompt" Title="Mesen - Update Available">

View file

@ -17,7 +17,7 @@
<Control ID="mnuSwitchDiskSide">Cambiar la cara del disco</Control>
<Control ID="mnuSelectDisk">Elegir el disco</Control>
<Control ID="mnuEjectDisk">Expulsar el disco</Control>
<Control ID="mnuVsGameConfig">Configuración de juego VS</Control>
<Control ID="mnuGameConfig">Configuración de juego</Control>
<Control ID="mnuInsertCoin1">Insertar moneda (1)</Control>
<Control ID="mnuInsertCoin2">Insertar moneda (2)</Control>
<Control ID="mnuInputBarcode">Insertar código de barras</Control>
@ -531,10 +531,7 @@
<Control ID="lblDonate">Si deseas colaborar con Mesen, por favor considera hacer una donación.&#xA;¡Gracias por tu colaboración!</Control>
<Control ID="okButton">&amp;OK</Control>
</Form>
<Form ID="frmVsGameConfig" Title="Configuración de juego VS">
<Control ID="lblGame">Juego</Control>
<Control ID="lblPpuModel">Modelo de PPU</Control>
<Control ID="lblInputType">Input Type:</Control>
<Form ID="frmGameConfig" Title="Configuración de juego">
<Control ID="grpDipSwitches">Conmutadores DIP</Control>
</Form>
<Form ID="frmUpdatePrompt" Title="Mesen - Actualización disponible">

View file

@ -17,7 +17,7 @@
<Control ID="mnuSwitchDiskSide">Changer le disque de côté</Control>
<Control ID="mnuSelectDisk">Choisir le disque</Control>
<Control ID="mnuEjectDisk">Éjecter le disque</Control>
<Control ID="mnuVsGameConfig">Configuration du jeu VS</Control>
<Control ID="mnuGameConfig">Configuration du jeu</Control>
<Control ID="mnuInsertCoin1">Insérer une pièce (1)</Control>
<Control ID="mnuInsertCoin2">Insérer une pièce (2)</Control>
<Control ID="mnuInputBarcode">Entrer un code-barres</Control>
@ -543,10 +543,7 @@
<Control ID="lblDonate">Si vous voulez supporter le développement de Mesen, vous pouvez faire une donation. Merci de votre support!</Control>
<Control ID="okButton">&amp;OK</Control>
</Form>
<Form ID="frmVsGameConfig" Title="Configuration du jeu VS">
<Control ID="lblGame">Jeu</Control>
<Control ID="lblPpuModel">Modèle du PPU</Control>
<Control ID="lblInputType">Manettes:</Control>
<Form ID="frmGameConfig" Title="Configuration du jeu">
<Control ID="grpDipSwitches">Commutateurs DIP</Control>
</Form>
<Form ID="frmUpdatePrompt" Title="Mesen - Mise à jour disponible">

View file

@ -17,7 +17,7 @@
<Control ID="mnuSwitchDiskSide">A面B面切り替え</Control>
<Control ID="mnuSelectDisk">ディスク選択</Control>
<Control ID="mnuEjectDisk">ディスクを取り出す</Control>
<Control ID="mnuVsGameConfig">VSゲーム設定</Control>
<Control ID="mnuGameConfig">ゲーム設定</Control>
<Control ID="mnuInsertCoin1">インサートコイン 1</Control>
<Control ID="mnuInsertCoin2">インサートコイン 2</Control>
<Control ID="mnuInputBarcode">バーコードを入力</Control>
@ -533,10 +533,7 @@
<Control ID="lblDonate">応援ありがとうございます!</Control>
<Control ID="okButton">&amp;OK</Control>
</Form>
<Form ID="frmVsGameConfig" Title="ゲーム設定">
<Control ID="lblGame">ゲーム:</Control>
<Control ID="lblPpuModel">PPUモデル:</Control>
<Control ID="lblInputType">コントローラ設定:</Control>
<Form ID="frmGameConfig" Title="ゲーム設定">
<Control ID="grpDipSwitches">ディップスイッチ</Control>
</Form>
<Form ID="frmUpdatePrompt" Title="Mesen ー アップデート可能">

View file

@ -17,7 +17,7 @@
<Control ID="mnuSwitchDiskSide">Trocar o lado do disco</Control>
<Control ID="mnuSelectDisk">Selecionar o disco</Control>
<Control ID="mnuEjectDisk">Ejetar o disco</Control>
<Control ID="mnuVsGameConfig">Configuração de jogo VS</Control>
<Control ID="mnuGameConfig">Configuração de jogo</Control>
<Control ID="mnuInsertCoin1">Inserir moeda (1)</Control>
<Control ID="mnuInsertCoin2">Inserir moeda (2)</Control>
<Control ID="mnuInputBarcode">Entrar código de barra</Control>
@ -529,10 +529,7 @@
<Control ID="lblDonate">Caso queira apoiar o Mesen, por favor, considere fazer uma doação ao projeto.&#xA;Obrigado pelo seu apoio!</Control>
<Control ID="okButton">&amp;OK</Control>
</Form>
<Form ID="frmVsGameConfig" Title="Configuração de jogo VS">
<Control ID="lblGame">Jogo</Control>
<Control ID="lblPpuModel">Modelo da PPU</Control>
<Control ID="lblInputType">Input Type:</Control>
<Form ID="frmGameConfig" Title="Configuração de jogo">
<Control ID="grpDipSwitches">Comutadores DIP</Control>
</Form>
<Form ID="frmUpdatePrompt" Title="Mesen - Atualização disponível">

View file

@ -17,7 +17,7 @@
<Control ID="mnuSwitchDiskSide">Сменить сторону диска</Control>
<Control ID="mnuSelectDisk">Выбрать диск</Control>
<Control ID="mnuEjectDisk">Извлечь диск</Control>
<Control ID="mnuVsGameConfig">Конфигурация VS</Control>
<Control ID="mnuGameConfig">Конфигурация</Control>
<Control ID="mnuInsertCoin1">Вставить монету в слот 1</Control>
<Control ID="mnuInsertCoin2">Вставить монету в слот 2</Control>
<Control ID="mnuInputBarcode">Input Barcode</Control>
@ -531,10 +531,7 @@
<Control ID="lblDonate">If you want to support Mesen, please consider donating.&#xA;Thank you for your support!</Control>
<Control ID="okButton">&amp;OK</Control>
</Form>
<Form ID="frmVsGameConfig" Title="Конфигурация VS">
<Control ID="lblGame">Игра</Control>
<Control ID="lblPpuModel">Модель PPU</Control>
<Control ID="lblInputType">Input Type:</Control>
<Form ID="frmGameConfig" Title="Конфигурация">
<Control ID="grpDipSwitches">DIP Switches</Control>
</Form>
<Form ID="frmUpdatePrompt" Title="Mesen - Доступно обновление">

View file

@ -17,7 +17,7 @@
<Control ID="mnuSwitchDiskSide">Змінити сторону диска</Control>
<Control ID="mnuSelectDisk">Вибрати диск</Control>
<Control ID="mnuEjectDisk">Вилучити диск</Control>
<Control ID="mnuVsGameConfig">Конфігурація VS</Control>
<Control ID="mnuGameConfig">Конфігурація</Control>
<Control ID="mnuInsertCoin1">Вставити монету в слот 1</Control>
<Control ID="mnuInsertCoin2">Вставити монету в слот 2</Control>
<Control ID="mnuInputBarcode">Input Barcode</Control>
@ -531,10 +531,7 @@
<Control ID="lblDonate">Якщо ви хочете підтримати Mesen, будь ласка підтримайте.&#xA;Дякую за вашу підтримку!</Control>
<Control ID="okButton">&amp;OK</Control>
</Form>
<Form ID="frmVsGameConfig" Title="Конфігурація VS">
<Control ID="lblGame">Гра</Control>
<Control ID="lblPpuModel">Модель PPU</Control>
<Control ID="lblInputType">Input Type:</Control>
<Form ID="frmGameConfig" Title="Конфігурація">
<Control ID="grpDipSwitches">Перемикачі DIP</Control>
</Form>
<Form ID="frmUpdatePrompt" Title="Mesen - Доступно оновлення">

View file

@ -0,0 +1,111 @@
namespace Mesen.GUI.Forms.Config
{
partial class frmGameConfig
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View file

@ -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<string, VsGameConfig> 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<List<string>> 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<List<string>>();
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<string> 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();
}
}

View file

@ -1,188 +0,0 @@
namespace Mesen.GUI.Forms.Config
{
partial class frmVsGameConfig
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View file

@ -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;

View file

@ -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)

View file

@ -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<VsConfigInfo>();
}
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<VsConfigInfo>();
}
ConfigManager.Config.MesenVersion = InteropEmu.GetMesenVersion();

View file

@ -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;

View file

@ -259,7 +259,7 @@
<Compile Include="Config\PlayerProfile.cs" />
<Compile Include="Config\ConfigManager.cs" />
<Compile Include="Config\ServerInfo.cs" />
<Compile Include="Config\VsConfigInfo.cs" />
<Compile Include="Config\GameDipswitchDefinition.cs" />
<Compile Include="Controls\BaseControl.cs">
<SubType>UserControl</SubType>
</Compile>
@ -1057,11 +1057,11 @@
<Compile Include="Forms\Cheats\frmCheatList.Designer.cs">
<DependentUpon>frmCheatList.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Config\frmVsGameConfig.cs">
<Compile Include="Forms\Config\frmGameConfig.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Config\frmVsGameConfig.Designer.cs">
<DependentUpon>frmVsGameConfig.cs</DependentUpon>
<Compile Include="Forms\Config\frmGameConfig.Designer.cs">
<DependentUpon>frmGameConfig.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Config\Controllers\ctrlPowerPadConfig.cs">
<SubType>UserControl</SubType>
@ -1640,8 +1640,8 @@
<DependentUpon>frmCheatList.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Config\frmVsGameConfig.resx">
<DependentUpon>frmVsGameConfig.cs</DependentUpon>
<EmbeddedResource Include="Forms\Config\frmGameConfig.resx">
<DependentUpon>frmGameConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Config\Controllers\ctrlPowerPadConfig.resx">
<DependentUpon>ctrlPowerPadConfig.cs</DependentUpon>

View file

@ -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);

View file

@ -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<VsControlManager*>(_console->GetControlManager())) {
EmulationSettings::SetPpuModel(model);
EmulationSettings::SetDipSwitches(dipSwitches);
EmulationSettings::SetVsInputType(inputType);
}
EmulationSettings::SetDipSwitches(dipSwitches);
}
DllExport bool __stdcall IsHdPpu() { return _console->IsHdPpu(); }