wonderswan: factor out some stuff into seperate files
This commit is contained in:
parent
d62ba4e2b4
commit
b432069504
|
@ -543,22 +543,22 @@
|
|||
<Compile Include="Consoles\Sega\Saturn\LibYabause.cs" />
|
||||
<Compile Include="Consoles\Sega\Saturn\Yabause.cs" />
|
||||
<Compile Include="Consoles\Sega\Saturn\Yabause.IDriveLight.cs">
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\Saturn\Yabause.IInputPollable.cs">
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\Saturn\Yabause.IMemoryDomains.cs">
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\Saturn\Yabause.ISaveram.cs">
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\Saturn\Yabause.ISettable.cs">
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\Saturn\Yabause.IStatable.cs">
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
<DependentUpon>Yabause.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\Sega\SMS\TerebiOekaki.cs" />
|
||||
<Compile Include="Consoles\Sega\SMS\MemoryMap.Korea.cs" />
|
||||
|
@ -574,6 +574,15 @@
|
|||
<Compile Include="Consoles\Sony\PSX\OctoshockDll.cs" />
|
||||
<Compile Include="Consoles\WonderSwan\BizSwan.cs" />
|
||||
<Compile Include="Consoles\WonderSwan\WonderSwan.cs" />
|
||||
<Compile Include="Consoles\WonderSwan\WonderSwan.Controller.cs">
|
||||
<DependentUpon>WonderSwan.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\WonderSwan\WonderSwan.ISettable.cs">
|
||||
<DependentUpon>WonderSwan.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\WonderSwan\WonderSwan.IStatable.cs">
|
||||
<DependentUpon>WonderSwan.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CoreInventory.cs" />
|
||||
<Compile Include="CPUs\68000\Diassembler.cs" />
|
||||
<Compile Include="CPUs\68000\Instructions\BitArithemetic.cs" />
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.WonderSwan
|
||||
{
|
||||
partial class WonderSwan
|
||||
{
|
||||
public static readonly ControllerDefinition WonderSwanController = new ControllerDefinition
|
||||
{
|
||||
Name = "WonderSwan Controller",
|
||||
BoolButtons =
|
||||
{
|
||||
"P1 X1",
|
||||
"P1 X2",
|
||||
"P1 X3",
|
||||
"P1 X4",
|
||||
"P1 Y1",
|
||||
"P1 Y2",
|
||||
"P1 Y3",
|
||||
"P1 Y4",
|
||||
"P1 Start",
|
||||
"P1 B",
|
||||
"P1 A",
|
||||
|
||||
"P2 X1",
|
||||
"P2 X2",
|
||||
"P2 X3",
|
||||
"P2 X4",
|
||||
"P2 Y1",
|
||||
"P2 Y2",
|
||||
"P2 Y3",
|
||||
"P2 Y4",
|
||||
"P2 Start",
|
||||
"P2 B",
|
||||
"P2 A",
|
||||
|
||||
"Power",
|
||||
"Rotate"
|
||||
}
|
||||
};
|
||||
public ControllerDefinition ControllerDefinition { get { return WonderSwanController; } }
|
||||
public IController Controller { get; set; }
|
||||
|
||||
BizSwan.Buttons GetButtons()
|
||||
{
|
||||
BizSwan.Buttons ret = 0;
|
||||
if (Controller["P1 X1"]) ret |= BizSwan.Buttons.X1;
|
||||
if (Controller["P1 X2"]) ret |= BizSwan.Buttons.X2;
|
||||
if (Controller["P1 X3"]) ret |= BizSwan.Buttons.X3;
|
||||
if (Controller["P1 X4"]) ret |= BizSwan.Buttons.X4;
|
||||
if (Controller["P1 Y1"]) ret |= BizSwan.Buttons.Y1;
|
||||
if (Controller["P1 Y2"]) ret |= BizSwan.Buttons.Y2;
|
||||
if (Controller["P1 Y3"]) ret |= BizSwan.Buttons.Y3;
|
||||
if (Controller["P1 Y4"]) ret |= BizSwan.Buttons.Y4;
|
||||
if (Controller["P1 Start"]) ret |= BizSwan.Buttons.Start;
|
||||
if (Controller["P1 B"]) ret |= BizSwan.Buttons.B;
|
||||
if (Controller["P1 A"]) ret |= BizSwan.Buttons.A;
|
||||
|
||||
if (Controller["P2 X1"]) ret |= BizSwan.Buttons.R_X1;
|
||||
if (Controller["P2 X2"]) ret |= BizSwan.Buttons.R_X2;
|
||||
if (Controller["P2 X3"]) ret |= BizSwan.Buttons.R_X3;
|
||||
if (Controller["P2 X4"]) ret |= BizSwan.Buttons.R_X4;
|
||||
if (Controller["P2 Y1"]) ret |= BizSwan.Buttons.R_Y1;
|
||||
if (Controller["P2 Y2"]) ret |= BizSwan.Buttons.R_Y2;
|
||||
if (Controller["P2 Y3"]) ret |= BizSwan.Buttons.R_Y3;
|
||||
if (Controller["P2 Y4"]) ret |= BizSwan.Buttons.R_Y4;
|
||||
if (Controller["P2 Start"]) ret |= BizSwan.Buttons.R_Start;
|
||||
if (Controller["P2 B"]) ret |= BizSwan.Buttons.R_B;
|
||||
if (Controller["P2 A"]) ret |= BizSwan.Buttons.R_A;
|
||||
|
||||
if (Controller["Rotate"]) ret |= BizSwan.Buttons.Rotate;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BizHawk.Emulation.Common;
|
||||
using System.ComponentModel;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.WonderSwan
|
||||
{
|
||||
partial class WonderSwan : ISettable<WonderSwan.Settings, WonderSwan.SyncSettings>
|
||||
{
|
||||
Settings _Settings;
|
||||
SyncSettings _SyncSettings;
|
||||
|
||||
public class Settings
|
||||
{
|
||||
[DisplayName("Background Layer")]
|
||||
[Description("True to display the selected layer.")]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableBG { get; set; }
|
||||
|
||||
[DisplayName("Foreground Layer")]
|
||||
[Description("True to display the selected layer.")]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableFG { get; set; }
|
||||
|
||||
[DisplayName("Sprites Layer")]
|
||||
[Description("True to display the selected layer.")]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableSprites { get; set; }
|
||||
|
||||
public BizSwan.Settings GetNativeSettings()
|
||||
{
|
||||
var ret = new BizSwan.Settings();
|
||||
if (EnableBG) ret.LayerMask |= BizSwan.LayerFlags.BG;
|
||||
if (EnableFG) ret.LayerMask |= BizSwan.LayerFlags.FG;
|
||||
if (EnableSprites) ret.LayerMask |= BizSwan.LayerFlags.Sprite;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Settings()
|
||||
{
|
||||
SettingsUtil.SetDefaultValues(this);
|
||||
}
|
||||
|
||||
public Settings Clone()
|
||||
{
|
||||
return (Settings)MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
public class SyncSettings
|
||||
{
|
||||
[DisplayName("Initial Time")]
|
||||
[Description("Initial time of emulation. Only relevant when UseRealTime is false.")]
|
||||
[DefaultValue(typeof(DateTime), "2010-01-01")]
|
||||
public DateTime InitialTime { get; set; }
|
||||
|
||||
[Description("Your birthdate. Stored in EEPROM and used by some games.")]
|
||||
[DefaultValue(typeof(DateTime), "1968-05-13")]
|
||||
public DateTime BirthDate { get; set; }
|
||||
|
||||
[Description("True to emulate a color system.")]
|
||||
[DefaultValue(true)]
|
||||
public bool Color { get; set; }
|
||||
|
||||
[DisplayName("Use RealTime")]
|
||||
[Description("If true, RTC clock will be based off of real time instead of emulated time. Ignored (set to false) when recording a movie.")]
|
||||
[DefaultValue(false)]
|
||||
public bool UseRealTime { get; set; }
|
||||
|
||||
[Description("Your gender. Stored in EEPROM and used by some games.")]
|
||||
[DefaultValue(BizSwan.Gender.Female)]
|
||||
public BizSwan.Gender Gender { get; set; }
|
||||
|
||||
[Description("Language to play games in. Most games ignore this.")]
|
||||
[DefaultValue(BizSwan.Language.Japanese)]
|
||||
public BizSwan.Language Language { get; set; }
|
||||
|
||||
[DisplayName("Blood Type")]
|
||||
[Description("Your blood type. Stored in EEPROM and used by some games.")]
|
||||
[DefaultValue(BizSwan.Bloodtype.AB)]
|
||||
public BizSwan.Bloodtype BloodType { get; set; }
|
||||
|
||||
[Description("Your name. Stored in EEPROM and used by some games. Maximum of 16 characters")]
|
||||
[DefaultValue("Lady Ashelia")]
|
||||
public string Name { get; set; }
|
||||
|
||||
public BizSwan.SyncSettings GetNativeSettings()
|
||||
{
|
||||
var ret = new BizSwan.SyncSettings
|
||||
{
|
||||
color = Color,
|
||||
userealtime = UseRealTime,
|
||||
sex = Gender,
|
||||
language = Language,
|
||||
blood = BloodType
|
||||
};
|
||||
ret.SetName(Name);
|
||||
ret.bday = (uint)BirthDate.Day;
|
||||
ret.bmonth = (uint)BirthDate.Month;
|
||||
ret.byear = (uint)BirthDate.Year;
|
||||
ret.initialtime = (ulong)((InitialTime - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public SyncSettings()
|
||||
{
|
||||
SettingsUtil.SetDefaultValues(this);
|
||||
}
|
||||
|
||||
public SyncSettings Clone()
|
||||
{
|
||||
return (SyncSettings)MemberwiseClone();
|
||||
}
|
||||
|
||||
public static bool NeedsReboot(SyncSettings x, SyncSettings y)
|
||||
{
|
||||
return !DeepEquality.DeepEquals(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
public Settings GetSettings()
|
||||
{
|
||||
return _Settings.Clone();
|
||||
}
|
||||
|
||||
public SyncSettings GetSyncSettings()
|
||||
{
|
||||
return _SyncSettings.Clone();
|
||||
}
|
||||
|
||||
public bool PutSettings(Settings o)
|
||||
{
|
||||
_Settings = o;
|
||||
var native = _Settings.GetNativeSettings();
|
||||
BizSwan.bizswan_putsettings(Core, ref native);
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool PutSyncSettings(SyncSettings o)
|
||||
{
|
||||
bool ret = SyncSettings.NeedsReboot(o, _SyncSettings);
|
||||
_SyncSettings = o;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.WonderSwan
|
||||
{
|
||||
partial class WonderSwan: IStatable
|
||||
{
|
||||
JsonSerializer ser = new JsonSerializer() { Formatting = Formatting.Indented };
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
class TextStateData
|
||||
{
|
||||
public bool IsLagFrame;
|
||||
public int LagCount;
|
||||
public int Frame;
|
||||
}
|
||||
|
||||
private void LoadTextStateData(TextStateData d)
|
||||
{
|
||||
IsLagFrame = d.IsLagFrame;
|
||||
LagCount = d.LagCount;
|
||||
Frame = d.Frame;
|
||||
}
|
||||
private void SaveTextStateData(TextStateData d)
|
||||
{
|
||||
d.IsLagFrame = IsLagFrame;
|
||||
d.LagCount = LagCount;
|
||||
d.Frame = Frame;
|
||||
}
|
||||
|
||||
public void SaveStateText(TextWriter writer)
|
||||
{
|
||||
var s = new TextState<TextStateData>();
|
||||
s.Prepare();
|
||||
var ff = s.GetFunctionPointersSave();
|
||||
BizSwan.bizswan_txtstatesave(Core, ref ff);
|
||||
SaveTextStateData(s.ExtraData);
|
||||
ser.Serialize(writer, s);
|
||||
}
|
||||
|
||||
public void LoadStateText(TextReader reader)
|
||||
{
|
||||
var s = (TextState<TextStateData>)ser.Deserialize(reader, typeof(TextState<TextStateData>));
|
||||
s.Prepare();
|
||||
var ff = s.GetFunctionPointersLoad();
|
||||
BizSwan.bizswan_txtstateload(Core, ref ff);
|
||||
LoadTextStateData(s.ExtraData);
|
||||
}
|
||||
|
||||
byte[] savebuff;
|
||||
byte[] savebuff2;
|
||||
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
{
|
||||
if (!BizSwan.bizswan_binstatesave(Core, savebuff, savebuff.Length))
|
||||
throw new InvalidOperationException("bizswan_binstatesave() returned false!");
|
||||
writer.Write(savebuff.Length);
|
||||
writer.Write(savebuff);
|
||||
|
||||
var d = new TextStateData();
|
||||
SaveTextStateData(d);
|
||||
BinaryQuickSerializer.Write(d, writer);
|
||||
}
|
||||
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
{
|
||||
int length = reader.ReadInt32();
|
||||
if (length != savebuff.Length)
|
||||
throw new InvalidOperationException("Save buffer size mismatch!");
|
||||
reader.Read(savebuff, 0, length);
|
||||
if (!BizSwan.bizswan_binstateload(Core, savebuff, savebuff.Length))
|
||||
throw new InvalidOperationException("bizswan_binstateload() returned false!");
|
||||
|
||||
var d = BinaryQuickSerializer.Create<TextStateData>(reader);
|
||||
LoadTextStateData(d);
|
||||
}
|
||||
|
||||
public byte[] SaveStateBinary()
|
||||
{
|
||||
var ms = new MemoryStream(savebuff2, true);
|
||||
var bw = new BinaryWriter(ms);
|
||||
SaveStateBinary(bw);
|
||||
bw.Flush();
|
||||
if (ms.Position != savebuff2.Length)
|
||||
throw new InvalidOperationException();
|
||||
ms.Close();
|
||||
return savebuff2;
|
||||
}
|
||||
|
||||
public bool BinarySaveStatesPreferred
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ using System.Text;
|
|||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
using Newtonsoft.Json;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
@ -13,80 +12,9 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
{
|
||||
[CoreAttributes("Cygne/Mednafen", "Dox", true, true, "0.9.36.5", "http://mednafen.sourceforge.net/")]
|
||||
[ServiceNotApplicable(typeof(IDriveLight))]
|
||||
public class WonderSwan : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, ISaveRam, IStatable,
|
||||
IInputPollable, IDebuggable, ISettable<WonderSwan.Settings, WonderSwan.SyncSettings>
|
||||
public partial class WonderSwan : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains, ISaveRam,
|
||||
IInputPollable, IDebuggable
|
||||
{
|
||||
#region Controller
|
||||
|
||||
public static readonly ControllerDefinition WonderSwanController = new ControllerDefinition
|
||||
{
|
||||
Name = "WonderSwan Controller",
|
||||
BoolButtons =
|
||||
{
|
||||
"P1 X1",
|
||||
"P1 X2",
|
||||
"P1 X3",
|
||||
"P1 X4",
|
||||
"P1 Y1",
|
||||
"P1 Y2",
|
||||
"P1 Y3",
|
||||
"P1 Y4",
|
||||
"P1 Start",
|
||||
"P1 B",
|
||||
"P1 A",
|
||||
|
||||
"P2 X1",
|
||||
"P2 X2",
|
||||
"P2 X3",
|
||||
"P2 X4",
|
||||
"P2 Y1",
|
||||
"P2 Y2",
|
||||
"P2 Y3",
|
||||
"P2 Y4",
|
||||
"P2 Start",
|
||||
"P2 B",
|
||||
"P2 A",
|
||||
|
||||
"Power",
|
||||
"Rotate"
|
||||
}
|
||||
};
|
||||
public ControllerDefinition ControllerDefinition { get { return WonderSwanController; } }
|
||||
public IController Controller { get; set; }
|
||||
|
||||
BizSwan.Buttons GetButtons()
|
||||
{
|
||||
BizSwan.Buttons ret = 0;
|
||||
if (Controller["P1 X1"]) ret |= BizSwan.Buttons.X1;
|
||||
if (Controller["P1 X2"]) ret |= BizSwan.Buttons.X2;
|
||||
if (Controller["P1 X3"]) ret |= BizSwan.Buttons.X3;
|
||||
if (Controller["P1 X4"]) ret |= BizSwan.Buttons.X4;
|
||||
if (Controller["P1 Y1"]) ret |= BizSwan.Buttons.Y1;
|
||||
if (Controller["P1 Y2"]) ret |= BizSwan.Buttons.Y2;
|
||||
if (Controller["P1 Y3"]) ret |= BizSwan.Buttons.Y3;
|
||||
if (Controller["P1 Y4"]) ret |= BizSwan.Buttons.Y4;
|
||||
if (Controller["P1 Start"]) ret |= BizSwan.Buttons.Start;
|
||||
if (Controller["P1 B"]) ret |= BizSwan.Buttons.B;
|
||||
if (Controller["P1 A"]) ret |= BizSwan.Buttons.A;
|
||||
|
||||
if (Controller["P2 X1"]) ret |= BizSwan.Buttons.R_X1;
|
||||
if (Controller["P2 X2"]) ret |= BizSwan.Buttons.R_X2;
|
||||
if (Controller["P2 X3"]) ret |= BizSwan.Buttons.R_X3;
|
||||
if (Controller["P2 X4"]) ret |= BizSwan.Buttons.R_X4;
|
||||
if (Controller["P2 Y1"]) ret |= BizSwan.Buttons.R_Y1;
|
||||
if (Controller["P2 Y2"]) ret |= BizSwan.Buttons.R_Y2;
|
||||
if (Controller["P2 Y3"]) ret |= BizSwan.Buttons.R_Y3;
|
||||
if (Controller["P2 Y4"]) ret |= BizSwan.Buttons.R_Y4;
|
||||
if (Controller["P2 Start"]) ret |= BizSwan.Buttons.R_Start;
|
||||
if (Controller["P2 B"]) ret |= BizSwan.Buttons.R_B;
|
||||
if (Controller["P2 A"]) ret |= BizSwan.Buttons.R_A;
|
||||
|
||||
if (Controller["Rotate"]) ret |= BizSwan.Buttons.Rotate;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
[CoreConstructor("WSWAN")]
|
||||
public WonderSwan(CoreComm comm, byte[] file, bool deterministic, object Settings, object SyncSettings)
|
||||
{
|
||||
|
@ -205,100 +133,9 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
|
||||
#endregion
|
||||
|
||||
#region Savestates
|
||||
|
||||
JsonSerializer ser = new JsonSerializer() { Formatting = Formatting.Indented };
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
class TextStateData
|
||||
{
|
||||
public bool IsLagFrame;
|
||||
public int LagCount;
|
||||
public int Frame;
|
||||
}
|
||||
|
||||
private void LoadTextStateData(TextStateData d)
|
||||
{
|
||||
IsLagFrame = d.IsLagFrame;
|
||||
LagCount = d.LagCount;
|
||||
Frame = d.Frame;
|
||||
}
|
||||
private void SaveTextStateData(TextStateData d)
|
||||
{
|
||||
d.IsLagFrame = IsLagFrame;
|
||||
d.LagCount = LagCount;
|
||||
d.Frame = Frame;
|
||||
}
|
||||
|
||||
public void SaveStateText(TextWriter writer)
|
||||
{
|
||||
var s = new TextState<TextStateData>();
|
||||
s.Prepare();
|
||||
var ff = s.GetFunctionPointersSave();
|
||||
BizSwan.bizswan_txtstatesave(Core, ref ff);
|
||||
SaveTextStateData(s.ExtraData);
|
||||
ser.Serialize(writer, s);
|
||||
}
|
||||
|
||||
public void LoadStateText(TextReader reader)
|
||||
{
|
||||
var s = (TextState<TextStateData>)ser.Deserialize(reader, typeof(TextState<TextStateData>));
|
||||
s.Prepare();
|
||||
var ff = s.GetFunctionPointersLoad();
|
||||
BizSwan.bizswan_txtstateload(Core, ref ff);
|
||||
LoadTextStateData(s.ExtraData);
|
||||
}
|
||||
|
||||
byte[] savebuff;
|
||||
byte[] savebuff2;
|
||||
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
{
|
||||
if (!BizSwan.bizswan_binstatesave(Core, savebuff, savebuff.Length))
|
||||
throw new InvalidOperationException("bizswan_binstatesave() returned false!");
|
||||
writer.Write(savebuff.Length);
|
||||
writer.Write(savebuff);
|
||||
|
||||
var d = new TextStateData();
|
||||
SaveTextStateData(d);
|
||||
BinaryQuickSerializer.Write(d, writer);
|
||||
}
|
||||
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
{
|
||||
int length = reader.ReadInt32();
|
||||
if (length != savebuff.Length)
|
||||
throw new InvalidOperationException("Save buffer size mismatch!");
|
||||
reader.Read(savebuff, 0, length);
|
||||
if (!BizSwan.bizswan_binstateload(Core, savebuff, savebuff.Length))
|
||||
throw new InvalidOperationException("bizswan_binstateload() returned false!");
|
||||
|
||||
var d = BinaryQuickSerializer.Create<TextStateData>(reader);
|
||||
LoadTextStateData(d);
|
||||
}
|
||||
|
||||
public byte[] SaveStateBinary()
|
||||
{
|
||||
var ms = new MemoryStream(savebuff2, true);
|
||||
var bw = new BinaryWriter(ms);
|
||||
SaveStateBinary(bw);
|
||||
bw.Flush();
|
||||
if (ms.Position != savebuff2.Length)
|
||||
throw new InvalidOperationException();
|
||||
ms.Close();
|
||||
return savebuff2;
|
||||
}
|
||||
|
||||
public bool BinarySaveStatesPreferred
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Debugging
|
||||
|
||||
unsafe void SetMemoryDomains()
|
||||
void SetMemoryDomains()
|
||||
{
|
||||
var mmd = new List<MemoryDomain>();
|
||||
for (int i = 0; ; i++)
|
||||
|
@ -394,146 +231,6 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
|
||||
#endregion
|
||||
|
||||
#region Settings
|
||||
|
||||
Settings _Settings;
|
||||
SyncSettings _SyncSettings;
|
||||
|
||||
public class Settings
|
||||
{
|
||||
[DisplayName("Background Layer")]
|
||||
[Description("True to display the selected layer.")]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableBG { get; set; }
|
||||
|
||||
[DisplayName("Foreground Layer")]
|
||||
[Description("True to display the selected layer.")]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableFG { get; set; }
|
||||
|
||||
[DisplayName("Sprites Layer")]
|
||||
[Description("True to display the selected layer.")]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableSprites { get; set; }
|
||||
|
||||
public BizSwan.Settings GetNativeSettings()
|
||||
{
|
||||
var ret = new BizSwan.Settings();
|
||||
if (EnableBG) ret.LayerMask |= BizSwan.LayerFlags.BG;
|
||||
if (EnableFG) ret.LayerMask |= BizSwan.LayerFlags.FG;
|
||||
if (EnableSprites) ret.LayerMask |= BizSwan.LayerFlags.Sprite;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Settings()
|
||||
{
|
||||
SettingsUtil.SetDefaultValues(this);
|
||||
}
|
||||
|
||||
public Settings Clone()
|
||||
{
|
||||
return (Settings)MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
public class SyncSettings
|
||||
{
|
||||
[DisplayName("Initial Time")]
|
||||
[Description("Initial time of emulation. Only relevant when UseRealTime is false.")]
|
||||
[DefaultValue(typeof(DateTime), "2010-01-01")]
|
||||
public DateTime InitialTime { get; set; }
|
||||
|
||||
[Description("Your birthdate. Stored in EEPROM and used by some games.")]
|
||||
[DefaultValue(typeof(DateTime), "1968-05-13")]
|
||||
public DateTime BirthDate { get; set; }
|
||||
|
||||
[Description("True to emulate a color system.")]
|
||||
[DefaultValue(true)]
|
||||
public bool Color { get; set; }
|
||||
|
||||
[DisplayName("Use RealTime")]
|
||||
[Description("If true, RTC clock will be based off of real time instead of emulated time. Ignored (set to false) when recording a movie.")]
|
||||
[DefaultValue(false)]
|
||||
public bool UseRealTime { get; set; }
|
||||
|
||||
[Description("Your gender. Stored in EEPROM and used by some games.")]
|
||||
[DefaultValue(BizSwan.Gender.Female)]
|
||||
public BizSwan.Gender Gender { get; set; }
|
||||
|
||||
[Description("Language to play games in. Most games ignore this.")]
|
||||
[DefaultValue(BizSwan.Language.Japanese)]
|
||||
public BizSwan.Language Language { get; set; }
|
||||
|
||||
[DisplayName("Blood Type")]
|
||||
[Description("Your blood type. Stored in EEPROM and used by some games.")]
|
||||
[DefaultValue(BizSwan.Bloodtype.AB)]
|
||||
public BizSwan.Bloodtype BloodType { get; set; }
|
||||
|
||||
[Description("Your name. Stored in EEPROM and used by some games. Maximum of 16 characters")]
|
||||
[DefaultValue("Lady Ashelia")]
|
||||
public string Name { get; set; }
|
||||
|
||||
public BizSwan.SyncSettings GetNativeSettings()
|
||||
{
|
||||
var ret = new BizSwan.SyncSettings
|
||||
{
|
||||
color = Color,
|
||||
userealtime = UseRealTime,
|
||||
sex = Gender,
|
||||
language = Language,
|
||||
blood = BloodType
|
||||
};
|
||||
ret.SetName(Name);
|
||||
ret.bday = (uint)BirthDate.Day;
|
||||
ret.bmonth = (uint)BirthDate.Month;
|
||||
ret.byear = (uint)BirthDate.Year;
|
||||
ret.initialtime = (ulong)((InitialTime - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public SyncSettings()
|
||||
{
|
||||
SettingsUtil.SetDefaultValues(this);
|
||||
}
|
||||
|
||||
public SyncSettings Clone()
|
||||
{
|
||||
return (SyncSettings)MemberwiseClone();
|
||||
}
|
||||
|
||||
public static bool NeedsReboot(SyncSettings x, SyncSettings y)
|
||||
{
|
||||
return !DeepEquality.DeepEquals(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
public Settings GetSettings()
|
||||
{
|
||||
return _Settings.Clone();
|
||||
}
|
||||
|
||||
public SyncSettings GetSyncSettings()
|
||||
{
|
||||
return _SyncSettings.Clone();
|
||||
}
|
||||
|
||||
public bool PutSettings(Settings o)
|
||||
{
|
||||
_Settings = o;
|
||||
var native = _Settings.GetNativeSettings();
|
||||
BizSwan.bizswan_putsettings(Core, ref native);
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool PutSyncSettings(SyncSettings o)
|
||||
{
|
||||
bool ret = SyncSettings.NeedsReboot(o, _SyncSettings);
|
||||
_SyncSettings = o;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IVideoProvider
|
||||
|
||||
public IVideoProvider VideoProvider { get { return this; } }
|
||||
|
|
Loading…
Reference in New Issue