2015-01-15 19:19:43 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Common;
|
|
|
|
|
using BizHawk.Emulation.Common;
|
2016-11-03 23:19:23 +00:00
|
|
|
|
using System.ComponentModel;
|
2015-01-15 19:19:43 +00:00
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|
|
|
|
{
|
|
|
|
|
public partial class NES : IStatable
|
|
|
|
|
{
|
|
|
|
|
public NESSettings GetSettings()
|
|
|
|
|
{
|
|
|
|
|
return Settings.Clone();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NESSyncSettings GetSyncSettings()
|
|
|
|
|
{
|
|
|
|
|
return SyncSettings.Clone();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool PutSettings(NESSettings o)
|
|
|
|
|
{
|
|
|
|
|
Settings = o;
|
|
|
|
|
if (Settings.ClipLeftAndRight)
|
|
|
|
|
{
|
|
|
|
|
videoProvider.left = 8;
|
|
|
|
|
videoProvider.right = 247;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
videoProvider.left = 0;
|
|
|
|
|
videoProvider.right = 255;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CoreComm.ScreenLogicalOffsetX = videoProvider.left;
|
2015-08-06 00:12:09 +00:00
|
|
|
|
CoreComm.ScreenLogicalOffsetY = Region == DisplayType.NTSC ? Settings.NTSC_TopLine : Settings.PAL_TopLine;
|
2015-01-15 19:19:43 +00:00
|
|
|
|
|
|
|
|
|
SetPalette(Settings.Palette);
|
|
|
|
|
|
|
|
|
|
apu.Square1V = Settings.Square1;
|
|
|
|
|
apu.Square2V = Settings.Square2;
|
|
|
|
|
apu.TriangleV = Settings.Triangle;
|
|
|
|
|
apu.NoiseV = Settings.Noise;
|
|
|
|
|
apu.DMCV = Settings.DMC;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool PutSyncSettings(NESSyncSettings o)
|
|
|
|
|
{
|
|
|
|
|
bool ret = NESSyncSettings.NeedsReboot(SyncSettings, o);
|
|
|
|
|
SyncSettings = o;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-17 21:09:33 +00:00
|
|
|
|
internal NESSettings Settings = new NESSettings();
|
|
|
|
|
internal NESSyncSettings SyncSettings = new NESSyncSettings();
|
2015-01-15 19:19:43 +00:00
|
|
|
|
|
|
|
|
|
public class NESSyncSettings
|
|
|
|
|
{
|
|
|
|
|
public Dictionary<string, string> BoardProperties = new Dictionary<string, string>();
|
|
|
|
|
|
|
|
|
|
public enum Region
|
|
|
|
|
{
|
|
|
|
|
Default,
|
|
|
|
|
NTSC,
|
|
|
|
|
PAL,
|
|
|
|
|
Dendy
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public Region RegionOverride = Region.Default;
|
|
|
|
|
|
|
|
|
|
public NESControlSettings Controls = new NESControlSettings();
|
|
|
|
|
|
2016-09-27 13:52:21 +00:00
|
|
|
|
public List<byte> InitialWRamStatePattern = null;
|
2016-09-03 15:53:18 +00:00
|
|
|
|
|
2015-01-15 19:19:43 +00:00
|
|
|
|
public NESSyncSettings Clone()
|
|
|
|
|
{
|
|
|
|
|
var ret = (NESSyncSettings)MemberwiseClone();
|
|
|
|
|
ret.BoardProperties = new Dictionary<string, string>(BoardProperties);
|
|
|
|
|
ret.Controls = Controls.Clone();
|
2016-11-05 22:32:58 +00:00
|
|
|
|
ret.VSDipswitches = VSDipswitches.Clone();
|
2015-01-15 19:19:43 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool NeedsReboot(NESSyncSettings x, NESSyncSettings y)
|
|
|
|
|
{
|
2016-11-05 22:32:58 +00:00
|
|
|
|
return !(Util.DictionaryEqual(x.BoardProperties, y.BoardProperties)
|
|
|
|
|
&& x.RegionOverride == y.RegionOverride
|
|
|
|
|
&& !NESControlSettings.NeedsReboot(x.Controls, y.Controls)
|
|
|
|
|
&& ((x.InitialWRamStatePattern ?? new List<byte>()).SequenceEqual(y.InitialWRamStatePattern ?? new List<byte>()))
|
|
|
|
|
&& x.VSDipswitches.Equals(y.VSDipswitches));
|
2015-01-15 19:19:43 +00:00
|
|
|
|
}
|
2016-11-03 23:19:23 +00:00
|
|
|
|
|
|
|
|
|
public class VSDipswitchSettings
|
|
|
|
|
{
|
|
|
|
|
public bool Dip_Switch_1 { get; set; }
|
|
|
|
|
public bool Dip_Switch_2 { get; set; }
|
|
|
|
|
public bool Dip_Switch_3 { get; set; }
|
|
|
|
|
public bool Dip_Switch_4 { get; set; }
|
|
|
|
|
public bool Dip_Switch_5 { get; set; }
|
|
|
|
|
public bool Dip_Switch_6 { get; set; }
|
|
|
|
|
public bool Dip_Switch_7 { get; set; }
|
|
|
|
|
public bool Dip_Switch_8 { get; set; }
|
2016-11-05 22:32:58 +00:00
|
|
|
|
|
|
|
|
|
public VSDipswitchSettings Clone()
|
|
|
|
|
{
|
|
|
|
|
return (VSDipswitchSettings)MemberwiseClone();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
|
|
|
|
if (obj == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (obj is VSDipswitchSettings)
|
|
|
|
|
{
|
|
|
|
|
var settings = obj as VSDipswitchSettings;
|
|
|
|
|
return Dip_Switch_1 == settings.Dip_Switch_1
|
|
|
|
|
&& Dip_Switch_2 == settings.Dip_Switch_2
|
|
|
|
|
&& Dip_Switch_3 == settings.Dip_Switch_3
|
|
|
|
|
&& Dip_Switch_4 == settings.Dip_Switch_4
|
|
|
|
|
&& Dip_Switch_5 == settings.Dip_Switch_5
|
|
|
|
|
&& Dip_Switch_6 == settings.Dip_Switch_6
|
|
|
|
|
&& Dip_Switch_7 == settings.Dip_Switch_7
|
|
|
|
|
&& Dip_Switch_8 == settings.Dip_Switch_8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.Equals(obj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return base.GetHashCode();
|
|
|
|
|
}
|
2016-11-03 23:19:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public VSDipswitchSettings VSDipswitches = new VSDipswitchSettings();
|
2015-01-15 19:19:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class NESSettings
|
|
|
|
|
{
|
|
|
|
|
public bool AllowMoreThanEightSprites = false;
|
|
|
|
|
public bool ClipLeftAndRight = false;
|
|
|
|
|
public bool DispBackground = true;
|
|
|
|
|
public bool DispSprites = true;
|
|
|
|
|
public int BackgroundColor = 0;
|
|
|
|
|
|
|
|
|
|
public int NTSC_TopLine = 8;
|
|
|
|
|
public int NTSC_BottomLine = 231;
|
|
|
|
|
public int PAL_TopLine = 0;
|
|
|
|
|
public int PAL_BottomLine = 239;
|
|
|
|
|
|
2015-09-13 19:09:49 +00:00
|
|
|
|
public byte[,] Palette;
|
2015-01-15 19:19:43 +00:00
|
|
|
|
|
|
|
|
|
public int Square1 = 376;
|
|
|
|
|
public int Square2 = 376;
|
|
|
|
|
public int Triangle = 426;
|
|
|
|
|
public int Noise = 247;
|
|
|
|
|
public int DMC = 167;
|
|
|
|
|
|
|
|
|
|
public NESSettings Clone()
|
|
|
|
|
{
|
|
|
|
|
var ret = (NESSettings)MemberwiseClone();
|
2015-09-13 19:09:49 +00:00
|
|
|
|
ret.Palette = (byte[,])ret.Palette.Clone();
|
2015-01-15 19:19:43 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NESSettings()
|
|
|
|
|
{
|
2015-09-13 19:09:49 +00:00
|
|
|
|
Palette = (byte[,])Palettes.QuickNESPalette.Clone();
|
2015-01-15 19:19:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Newtonsoft.Json.JsonConstructor]
|
2015-09-13 19:09:49 +00:00
|
|
|
|
public NESSettings(byte[,] Palette)
|
2015-01-15 19:19:43 +00:00
|
|
|
|
{
|
|
|
|
|
if (Palette == null)
|
|
|
|
|
// only needed for SVN purposes
|
2015-09-13 19:09:49 +00:00
|
|
|
|
// edit: what does this mean?
|
|
|
|
|
this.Palette = (byte[,])Palettes.QuickNESPalette.Clone();
|
2015-01-15 19:19:43 +00:00
|
|
|
|
else
|
|
|
|
|
this.Palette = Palette;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|