private void ExecuteMAMEThread() { _periodicCallback = MAMEPeriodicCallback; _soundCallback = MAMESoundCallback; _bootCallback = MAMEBootCallback; _logCallback = MAMELogCallback; LibMAME.mame_set_periodic_callback(_periodicCallback); LibMAME.mame_set_sound_callback(_soundCallback); LibMAME.mame_set_boot_callback(_bootCallback); LibMAME.mame_set_log_callback(_logCallback); // https://docs.mamedev.org/commandline/commandline-index.html List <string> args = new List <string> { "mame" // dummy, internally discarded by index, so has to go first , _gameFileName // no dash for rom names , "-noreadconfig" // forbid reading ini files , "-nowriteconfig" // forbid writing ini files , "-norewind" // forbid rewind savestates (captured upon frame advance) , "-skip_gameinfo" // forbid this blocking screen that requires user input , "-nothrottle" // forbid throttling to "real" speed of the device , "-update_in_pause" // ^ including frame-advancing , "-rompath", _gameDirectory // mame doesn't load roms from full paths, only from dirs to scan , "-joystick_contradictory" // allow L+R/U+D on digital joystick , "-nonvram_save" // prevent dumping non-volatile ram to disk , "-artpath", "mame\\artwork" // path to load artowrk from , "-diff_directory", "mame\\diff" // hdd diffs, whenever stuff is written back to an image , "-cfg_directory", "?" // send invalid path to prevent cfg handling , "-volume", "-32" // lowest attenuation means mame osd remains silent , "-output", "console" // print everything to hawk console , "-samplerate", _sampleRate.ToString() // match hawk samplerate , "-video", "none" // forbid mame window altogether , "-keyboardprovider", "none" , "-mouseprovider", "none" , "-lightgunprovider", "none" , "-joystickprovider", "none" // , "-debug" // launch mame debugger (because we can) }; if (_syncSettings.DriverSettings.TryGetValue( MAMELuaCommand.MakeLookupKey(_gameFileName.Split('.')[0], LibMAME.BIOS_LUA_CODE), out string value)) { args.AddRange(new[] { "-bios", value }); } LibMAME.mame_launch(args.Count, args.ToArray()); }
public void FetchDefaultGameSettings() { string DIPSwitchTags = MameGetString(MAMELuaCommand.GetDIPSwitchTags); string[] tags = DIPSwitchTags.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string tag in tags) { string DIPSwitchFields = MameGetString(MAMELuaCommand.GetDIPSwitchFields(tag)); string[] fieldNames = DIPSwitchFields.Split(new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries); foreach (string fieldName in fieldNames) { DriverSetting setting = new DriverSetting() { Name = fieldName, GameName = _gameShortName, LuaCode = MAMELuaCommand.InputField(tag, fieldName), Type = SettingType.DIPSWITCH, DefaultValue = LibMAME.mame_lua_get_int( $"return { MAMELuaCommand.InputField(tag, fieldName) }.defvalue").ToString() }; string DIPSwitchOptions = MameGetString(MAMELuaCommand.GetDIPSwitchOptions(tag, fieldName)); string[] options = DIPSwitchOptions.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries); foreach (string option in options) { string[] opt = option.Split(new char[] { '~' }, StringSplitOptions.RemoveEmptyEntries); setting.Options.Add(opt[0], opt[1]); } CurrentDriverSettings.Add(setting); } } }