mirror of
https://github.com/SourMesen/Mesen2.git
synced 2025-04-02 10:21:44 -04:00
357 lines
15 KiB
C#
357 lines
15 KiB
C#
using ReactiveUI.Fody.Helpers;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Mesen.GUI.Config
|
|
{
|
|
public class NesConfig : BaseConfig<NesConfig>
|
|
{
|
|
//Input
|
|
[Reactive] public List<ControllerConfig> Controllers { get; set; } = new List<ControllerConfig> { new ControllerConfig(), new ControllerConfig(), new ControllerConfig(), new ControllerConfig(), new ControllerConfig() };
|
|
[Reactive] public UInt32 ZapperDetectionRadius { get; set; } = 0;
|
|
|
|
//Video
|
|
[Reactive] public bool EnableHdPacks { get; set; } = true;
|
|
[Reactive] public bool DisableGameDatabase { get; set; } = false;
|
|
[Reactive] public bool FdsAutoLoadDisk { get; set; } = true;
|
|
[Reactive] public bool FdsFastForwardOnLoad { get; set; } = false;
|
|
[Reactive] public bool FdsAutoInsertDisk { get; set; } = false;
|
|
[Reactive] public VsDualOutputOption VsDualVideoOutput { get; set; } = VsDualOutputOption.Both;
|
|
[Reactive] public VsDualOutputOption VsDualAudioOutput { get; set; } = VsDualOutputOption.Both;
|
|
[Reactive] public bool NsfMoveToNextTrackAfterTime { get; set; } = true;
|
|
[Reactive] public UInt32 NsfMoveToNextTrackTime { get; set; } = 120;
|
|
[Reactive] public bool NsfAutoDetectSilence { get; set; } = true;
|
|
[Reactive] public UInt32 NsfAutoDetectSilenceDelay { get; set; } = 3000;
|
|
|
|
[Reactive] public bool DisableSprites { get; set; } = false;
|
|
[Reactive] public bool DisableBackground { get; set; } = false;
|
|
[Reactive] public bool ForceBackgroundFirstColumn { get; set; } = false;
|
|
[Reactive] public bool ForceSpritesFirstColumn { get; set; } = false;
|
|
[Reactive] public bool RemoveSpriteLimit { get; set; } = false;
|
|
[Reactive] public bool AdaptiveSpriteLimit { get; set; } = false;
|
|
|
|
[Reactive] public bool UseCustomVsPalette { get; set; } = false;
|
|
|
|
[Reactive] [MinMax(0, 100)] public UInt32 OverscanLeft { get; set; } = 0;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 OverscanRight { get; set; } = 0;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 OverscanTop { get; set; } = 0;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 OverscanBottom { get; set; } = 0;
|
|
|
|
//Emulation
|
|
[Reactive] public bool EnableOamDecay { get; set; } = false;
|
|
[Reactive] public bool EnablePpuOamRowCorruption { get; set; } = false;
|
|
[Reactive] public bool DisableOamAddrBug { get; set; } = false;
|
|
[Reactive] public bool DisablePaletteRead { get; set; } = false;
|
|
[Reactive] public bool DisablePpu2004Reads { get; set; } = false;
|
|
[Reactive] public bool EnablePpu2000ScrollGlitch { get; set; } = false;
|
|
[Reactive] public bool EnablePpu2006ScrollGlitch { get; set; } = false;
|
|
|
|
[Reactive] public bool UseNes101Hvc101Behavior { get; set; } = false;
|
|
[Reactive] public bool DisablePpuReset { get; set; } = false;
|
|
[Reactive] public bool AllowInvalidInput { get; set; } = false;
|
|
|
|
[Reactive] public bool RandomizeMapperPowerOnState { get; set; } = false;
|
|
[Reactive] public bool RandomizeCpuPpuAlignment { get; set; } = false;
|
|
[Reactive] public RamState RamPowerOnState { get; set; } = RamState.AllZeros;
|
|
|
|
[Reactive] public UInt32 PpuExtraScanlinesBeforeNmi { get; set; } = 0;
|
|
[Reactive] public UInt32 PpuExtraScanlinesAfterNmi { get; set; } = 0;
|
|
|
|
//Audio
|
|
[Reactive] public bool DisableNoiseModeFlag { get; set; } = false;
|
|
[Reactive] public bool ReduceDmcPopping { get; set; } = false;
|
|
[Reactive] public bool SilenceTriangleHighFreq { get; set; } = false;
|
|
[Reactive] public bool SwapDutyCycles { get; set; } = false;
|
|
|
|
[Reactive] [MinMax(0, 100)] public UInt32 Square1Volume { get; set; } = 100;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 Square2Volume { get; set; } = 100;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 TriangleVolume { get; set; } = 100;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 NoiseVolume { get; set; } = 100;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 DmcVolume { get; set; } = 100;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 FdsVolume { get; set; } = 100;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 Mmc5Volume { get; set; } = 100;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 Vrc6Volume { get; set; } = 100;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 Vrc7Volume { get; set; } = 100;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 Namco163Volume { get; set; } = 100;
|
|
[Reactive] [MinMax(0, 100)] public UInt32 Sunsoft5bVolume { get; set; } = 100;
|
|
|
|
[Reactive] [MinMax(-100, 100)] public Int32 Square1Panning { get; set; } = 0;
|
|
[Reactive] [MinMax(-100, 100)] public Int32 Square2Panning { get; set; } = 0;
|
|
[Reactive] [MinMax(-100, 100)] public Int32 TrianglePanning { get; set; } = 0;
|
|
[Reactive] [MinMax(-100, 100)] public Int32 NoisePanning { get; set; } = 0;
|
|
[Reactive] [MinMax(-100, 100)] public Int32 DmcPanning { get; set; } = 0;
|
|
[Reactive] [MinMax(-100, 100)] public Int32 FdsPanning { get; set; } = 0;
|
|
[Reactive] [MinMax(-100, 100)] public Int32 Mmc5Panning { get; set; } = 0;
|
|
[Reactive] [MinMax(-100, 100)] public Int32 Vrc6Panning { get; set; } = 0;
|
|
[Reactive] [MinMax(-100, 100)] public Int32 Vrc7Panning { get; set; } = 0;
|
|
[Reactive] [MinMax(-100, 100)] public Int32 Namco163Panning { get; set; } = 0;
|
|
[Reactive] [MinMax(-100, 100)] public Int32 Sunsoft5bPanning { get; set; } = 0;
|
|
|
|
[Reactive] public StereoFilter StereoFilter { get; set; } = StereoFilter.None;
|
|
[Reactive] [MinMax(0, 100)] public Int32 StereoDelay { get; set; } = 15;
|
|
[Reactive] [MinMax(-180, 180)] public Int32 StereoPanningAngle { get; set; } = 15;
|
|
[Reactive] [MinMax(1, 100)] public Int32 StereoCombFilterDelay { get; set; } = 5;
|
|
[Reactive] [MinMax(1, 200)] public Int32 StereoCombFilterStrength { get; set; } = 100;
|
|
|
|
//Misc
|
|
[Reactive] public bool BreakOnCrash { get; set; } = false;
|
|
[Reactive] public UInt32 DipSwitches { get; set; } = 0;
|
|
|
|
[Reactive] public Int32 InputScanline { get; set; } = 241;
|
|
[Reactive] public UInt32[] UserPalette { get; set; } = new UInt32[64] { 0xFF666666, 0xFF002A88, 0xFF1412A7, 0xFF3B00A4, 0xFF5C007E, 0xFF6E0040, 0xFF6C0600, 0xFF561D00, 0xFF333500, 0xFF0B4800, 0xFF005200, 0xFF004F08, 0xFF00404D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFADADAD, 0xFF155FD9, 0xFF4240FF, 0xFF7527FE, 0xFFA01ACC, 0xFFB71E7B, 0xFFB53120, 0xFF994E00, 0xFF6B6D00, 0xFF388700, 0xFF0C9300, 0xFF008F32, 0xFF007C8D, 0xFF000000, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFF64B0FF, 0xFF9290FF, 0xFFC676FF, 0xFFF36AFF, 0xFFFE6ECC, 0xFFFE8170, 0xFFEA9E22, 0xFFBCBE00, 0xFF88D800, 0xFF5CE430, 0xFF45E082, 0xFF48CDDE, 0xFF4F4F4F, 0xFF000000, 0xFF000000, 0xFFFFFEFF, 0xFFC0DFFF, 0xFFD3D2FF, 0xFFE8C8FF, 0xFFFBC2FF, 0xFFFEC4EA, 0xFFFECCC5, 0xFFF7D8A5, 0xFFE4E594, 0xFFCFEF96, 0xFFBDF4AB, 0xFFB3F3CC, 0xFFB5EBF2, 0xFFB8B8B8, 0xFF000000, 0xFF000000 };
|
|
|
|
public void ApplyConfig()
|
|
{
|
|
UInt32[] palette = new UInt32[512];
|
|
Array.Copy(UserPalette, palette, UserPalette.Length);
|
|
bool isFullPalette = UserPalette.Length == 512;
|
|
|
|
ConfigApi.SetNesConfig(new InteropNesConfig() {
|
|
Controllers = new InteropControllerConfig[5] {
|
|
this.Controllers[0].ToInterop(),
|
|
this.Controllers[1].ToInterop(),
|
|
this.Controllers[2].ToInterop(),
|
|
this.Controllers[3].ToInterop(),
|
|
this.Controllers[4].ToInterop()
|
|
},
|
|
ZapperDetectionRadius = ZapperDetectionRadius,
|
|
|
|
EnableHdPacks = EnableHdPacks,
|
|
DisableGameDatabase = DisableGameDatabase,
|
|
FdsAutoLoadDisk = FdsAutoLoadDisk,
|
|
FdsFastForwardOnLoad = FdsFastForwardOnLoad,
|
|
FdsAutoInsertDisk = FdsAutoInsertDisk,
|
|
VsDualVideoOutput = VsDualVideoOutput,
|
|
VsDualAudioOutput = VsDualAudioOutput,
|
|
NsfMoveToNextTrackAfterTime = NsfMoveToNextTrackAfterTime,
|
|
NsfMoveToNextTrackTime = NsfMoveToNextTrackTime,
|
|
NsfAutoDetectSilence = NsfAutoDetectSilence,
|
|
NsfAutoDetectSilenceDelay = NsfAutoDetectSilenceDelay,
|
|
|
|
SpritesEnabled = !DisableSprites,
|
|
BackgroundEnabled = !DisableBackground,
|
|
ForceBackgroundFirstColumn = ForceBackgroundFirstColumn,
|
|
ForceSpritesFirstColumn = ForceSpritesFirstColumn,
|
|
RemoveSpriteLimit = RemoveSpriteLimit,
|
|
AdaptiveSpriteLimit = AdaptiveSpriteLimit,
|
|
|
|
UseCustomVsPalette = UseCustomVsPalette,
|
|
|
|
OverscanLeft = OverscanLeft,
|
|
OverscanRight = OverscanRight,
|
|
OverscanTop = OverscanTop,
|
|
OverscanBottom = OverscanBottom,
|
|
|
|
UseNes101Hvc101Behavior = UseNes101Hvc101Behavior,
|
|
DisablePpuReset = DisablePpuReset,
|
|
AllowInvalidInput = AllowInvalidInput,
|
|
|
|
EnableOamDecay = EnableOamDecay,
|
|
EnablePpuOamRowCorruption = EnablePpuOamRowCorruption,
|
|
DisableOamAddrBug = DisableOamAddrBug,
|
|
DisablePaletteRead = DisablePaletteRead,
|
|
DisablePpu2004Reads = DisablePpu2004Reads,
|
|
EnablePpu2000ScrollGlitch = EnablePpu2000ScrollGlitch,
|
|
EnablePpu2006ScrollGlitch = EnablePpu2006ScrollGlitch,
|
|
|
|
RandomizeMapperPowerOnState = RandomizeMapperPowerOnState,
|
|
RandomizeCpuPpuAlignment = RandomizeCpuPpuAlignment,
|
|
RamPowerOnState = RamPowerOnState,
|
|
|
|
PpuExtraScanlinesAfterNmi = PpuExtraScanlinesAfterNmi,
|
|
PpuExtraScanlinesBeforeNmi = PpuExtraScanlinesBeforeNmi,
|
|
|
|
DisableNoiseModeFlag = DisableNoiseModeFlag,
|
|
ReduceDmcPopping = ReduceDmcPopping,
|
|
SilenceTriangleHighFreq = SilenceTriangleHighFreq,
|
|
SwapDutyCycles = SwapDutyCycles,
|
|
|
|
Square1Volume = Square1Volume,
|
|
Square2Volume = Square2Volume,
|
|
TriangleVolume = TriangleVolume,
|
|
NoiseVolume = NoiseVolume,
|
|
DmcVolume = DmcVolume,
|
|
FdsVolume = FdsVolume,
|
|
Mmc5Volume = Mmc5Volume,
|
|
Vrc6Volume = Vrc6Volume,
|
|
Vrc7Volume = Vrc7Volume,
|
|
Namco163Volume = Namco163Volume,
|
|
Sunsoft5bVolume = Sunsoft5bVolume,
|
|
Square1Panning = Square1Panning,
|
|
Square2Panning = Square2Panning,
|
|
TrianglePanning = TrianglePanning,
|
|
NoisePanning = NoisePanning,
|
|
DmcPanning = DmcPanning,
|
|
FdsPanning = FdsPanning,
|
|
Mmc5Panning = Mmc5Panning,
|
|
Vrc6Panning = Vrc6Panning,
|
|
Vrc7Panning = Vrc7Panning,
|
|
Namco163Panning = Namco163Panning,
|
|
Sunsoft5bPanning = Sunsoft5bPanning,
|
|
|
|
StereoFilter = StereoFilter,
|
|
StereoDelay = StereoDelay,
|
|
StereoPanningAngle = StereoPanningAngle,
|
|
StereoCombFilterDelay = StereoCombFilterDelay,
|
|
StereoCombFilterStrength = StereoCombFilterStrength,
|
|
|
|
BreakOnCrash = BreakOnCrash,
|
|
DipSwitches = DipSwitches,
|
|
|
|
InputScanline = InputScanline,
|
|
|
|
IsFullColorPalette = isFullPalette,
|
|
UserPalette = palette,
|
|
});
|
|
}
|
|
|
|
public void InitializeDefaults(DefaultKeyMappingType defaultMappings)
|
|
{
|
|
KeyPresets presets = new KeyPresets();
|
|
List<KeyMapping> mappings = new List<KeyMapping>();
|
|
if(defaultMappings.HasFlag(DefaultKeyMappingType.Xbox)) {
|
|
mappings.Add(presets.XboxLayout1);
|
|
}
|
|
if(defaultMappings.HasFlag(DefaultKeyMappingType.Ps4)) {
|
|
mappings.Add(presets.Ps4Layout1);
|
|
}
|
|
if(defaultMappings.HasFlag(DefaultKeyMappingType.WasdKeys)) {
|
|
mappings.Add(presets.WasdLayout);
|
|
}
|
|
if(defaultMappings.HasFlag(DefaultKeyMappingType.ArrowKeys)) {
|
|
mappings.Add(presets.ArrowLayout);
|
|
}
|
|
|
|
Controllers[0].Type = ControllerType.NesController;
|
|
Controllers[0].TurboSpeed = 2;
|
|
if(mappings.Count > 0) {
|
|
Controllers[0].Mapping1 = mappings[0];
|
|
if(mappings.Count > 1) {
|
|
Controllers[0].Mapping2 = mappings[1];
|
|
if(mappings.Count > 2) {
|
|
Controllers[0].Mapping3 = mappings[2];
|
|
if(mappings.Count > 3) {
|
|
Controllers[0].Mapping4 = mappings[3];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct InteropNesConfig
|
|
{
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
|
|
public InteropControllerConfig[] Controllers;
|
|
public UInt32 ZapperDetectionRadius;
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool EnableHdPacks;
|
|
[MarshalAs(UnmanagedType.I1)] public bool DisableGameDatabase;
|
|
[MarshalAs(UnmanagedType.I1)] public bool FdsAutoLoadDisk;
|
|
[MarshalAs(UnmanagedType.I1)] public bool FdsFastForwardOnLoad;
|
|
[MarshalAs(UnmanagedType.I1)] public bool FdsAutoInsertDisk;
|
|
public VsDualOutputOption VsDualVideoOutput;
|
|
public VsDualOutputOption VsDualAudioOutput;
|
|
[MarshalAs(UnmanagedType.I1)] public bool NsfMoveToNextTrackAfterTime;
|
|
public UInt32 NsfMoveToNextTrackTime;
|
|
[MarshalAs(UnmanagedType.I1)] public bool NsfAutoDetectSilence;
|
|
public UInt32 NsfAutoDetectSilenceDelay;
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool SpritesEnabled;
|
|
[MarshalAs(UnmanagedType.I1)] public bool BackgroundEnabled;
|
|
[MarshalAs(UnmanagedType.I1)] public bool ForceBackgroundFirstColumn;
|
|
[MarshalAs(UnmanagedType.I1)] public bool ForceSpritesFirstColumn;
|
|
[MarshalAs(UnmanagedType.I1)] public bool RemoveSpriteLimit;
|
|
[MarshalAs(UnmanagedType.I1)] public bool AdaptiveSpriteLimit;
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool UseCustomVsPalette;
|
|
|
|
public UInt32 OverscanLeft;
|
|
public UInt32 OverscanRight;
|
|
public UInt32 OverscanTop;
|
|
public UInt32 OverscanBottom;
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool UseNes101Hvc101Behavior;
|
|
[MarshalAs(UnmanagedType.I1)] public bool DisablePpuReset;
|
|
[MarshalAs(UnmanagedType.I1)] public bool AllowInvalidInput;
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool EnableOamDecay;
|
|
[MarshalAs(UnmanagedType.I1)] public bool EnablePpuOamRowCorruption;
|
|
[MarshalAs(UnmanagedType.I1)] public bool DisableOamAddrBug;
|
|
[MarshalAs(UnmanagedType.I1)] public bool DisablePaletteRead;
|
|
[MarshalAs(UnmanagedType.I1)] public bool DisablePpu2004Reads;
|
|
[MarshalAs(UnmanagedType.I1)] public bool EnablePpu2000ScrollGlitch;
|
|
[MarshalAs(UnmanagedType.I1)] public bool EnablePpu2006ScrollGlitch;
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool RandomizeMapperPowerOnState;
|
|
[MarshalAs(UnmanagedType.I1)] public bool RandomizeCpuPpuAlignment;
|
|
public RamState RamPowerOnState;
|
|
|
|
public UInt32 PpuExtraScanlinesBeforeNmi;
|
|
public UInt32 PpuExtraScanlinesAfterNmi;
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool DisableNoiseModeFlag;
|
|
[MarshalAs(UnmanagedType.I1)] public bool ReduceDmcPopping;
|
|
[MarshalAs(UnmanagedType.I1)] public bool SilenceTriangleHighFreq;
|
|
[MarshalAs(UnmanagedType.I1)] public bool SwapDutyCycles;
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool BreakOnCrash;
|
|
public UInt32 DipSwitches;
|
|
|
|
public Int32 InputScanline;
|
|
|
|
[MarshalAs(UnmanagedType.I1)] public bool IsFullColorPalette;
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
|
|
public UInt32[] UserPalette;
|
|
|
|
public UInt32 Square1Volume;
|
|
public UInt32 Square2Volume;
|
|
public UInt32 TriangleVolume;
|
|
public UInt32 NoiseVolume;
|
|
public UInt32 DmcVolume;
|
|
public UInt32 FdsVolume;
|
|
public UInt32 Mmc5Volume;
|
|
public UInt32 Vrc6Volume;
|
|
public UInt32 Vrc7Volume;
|
|
public UInt32 Namco163Volume;
|
|
public UInt32 Sunsoft5bVolume;
|
|
|
|
public Int32 Square1Panning;
|
|
public Int32 Square2Panning;
|
|
public Int32 TrianglePanning;
|
|
public Int32 NoisePanning;
|
|
public Int32 DmcPanning;
|
|
public Int32 FdsPanning;
|
|
public Int32 Mmc5Panning;
|
|
public Int32 Vrc6Panning;
|
|
public Int32 Vrc7Panning;
|
|
public Int32 Namco163Panning;
|
|
public Int32 Sunsoft5bPanning;
|
|
|
|
public StereoFilter StereoFilter;
|
|
public Int32 StereoDelay;
|
|
public Int32 StereoPanningAngle;
|
|
public Int32 StereoCombFilterDelay;
|
|
public Int32 StereoCombFilterStrength;
|
|
}
|
|
|
|
public enum StereoFilter
|
|
{
|
|
None = 0,
|
|
Delay = 1,
|
|
Panning = 2,
|
|
CombFilter = 3,
|
|
}
|
|
|
|
public enum VsDualOutputOption
|
|
{
|
|
Both = 0,
|
|
MainSystemOnly = 1,
|
|
SubSystemOnly = 2
|
|
}
|
|
}
|