swan: factor out some stuff into seperate files
This commit is contained in:
parent
fbdb29b64c
commit
8b60e74b87
|
@ -577,7 +577,13 @@
|
|||
<Compile Include="Consoles\WonderSwan\WonderSwan.Controller.cs">
|
||||
<DependentUpon>WonderSwan.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\WonderSwan\WonderSwan.ISettable.cs">
|
||||
<Compile Include="Consoles\WonderSwan\WonderSwan.IMemoryDomains.cs">
|
||||
<DependentUpon>WonderSwan.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Consoles\WonderSwan\WonderSwan.ISaveRam.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">
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
|
||||
namespace BizHawk.Emulation.Cores.WonderSwan
|
||||
{
|
||||
partial class WonderSwan
|
||||
{
|
||||
void InitIMemoryDomains()
|
||||
{
|
||||
var mmd = new List<MemoryDomain>();
|
||||
for (int i = 0; ; i++)
|
||||
{
|
||||
IntPtr name;
|
||||
int size;
|
||||
IntPtr data;
|
||||
if (!BizSwan.bizswan_getmemoryarea(Core, i, out name, out size, out data))
|
||||
break;
|
||||
if (size == 0)
|
||||
continue;
|
||||
string sname = Marshal.PtrToStringAnsi(name);
|
||||
mmd.Add(MemoryDomain.FromIntPtr(sname, size, MemoryDomain.Endian.Little, data));
|
||||
}
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(new MemoryDomainList(mmd, 0));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
|
||||
namespace BizHawk.Emulation.Cores.WonderSwan
|
||||
{
|
||||
partial class WonderSwan : ISaveRam
|
||||
{
|
||||
byte[] saverambuff;
|
||||
|
||||
void InitISaveRam()
|
||||
{
|
||||
saverambuff = new byte[BizSwan.bizswan_saveramsize(Core)];
|
||||
}
|
||||
|
||||
public byte[] CloneSaveRam()
|
||||
{
|
||||
if (!BizSwan.bizswan_saveramsave(Core, saverambuff, saverambuff.Length))
|
||||
throw new InvalidOperationException("bizswan_saveramsave() returned false!");
|
||||
return (byte[])saverambuff.Clone();
|
||||
}
|
||||
|
||||
public void StoreSaveRam(byte[] data)
|
||||
{
|
||||
if (!BizSwan.bizswan_saveramload(Core, data, data.Length))
|
||||
throw new InvalidOperationException("bizswan_saveramload() returned false!");
|
||||
}
|
||||
|
||||
public bool SaveRamModified
|
||||
{
|
||||
get { return BizSwan.bizswan_saveramsize(Core) > 0; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,6 +12,12 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
{
|
||||
partial class WonderSwan: IStatable
|
||||
{
|
||||
void InitIStatable()
|
||||
{
|
||||
savebuff = new byte[BizSwan.bizswan_binstatesize(Core)];
|
||||
savebuff2 = new byte[savebuff.Length + 13];
|
||||
}
|
||||
|
||||
JsonSerializer ser = new JsonSerializer() { Formatting = Formatting.Indented };
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
{
|
||||
[CoreAttributes("Cygne/Mednafen", "Dox", true, true, "0.9.36.5", "http://mednafen.sourceforge.net/")]
|
||||
[ServiceNotApplicable(typeof(IDriveLight))]
|
||||
public partial class WonderSwan : IEmulator, IVideoProvider, ISyncSoundProvider, ISaveRam,
|
||||
public partial class WonderSwan : IEmulator, IVideoProvider, ISyncSoundProvider,
|
||||
IInputPollable, IDebuggable
|
||||
{
|
||||
[CoreConstructor("WSWAN")]
|
||||
|
@ -41,15 +41,13 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
CoreComm.VsyncNum = 3072000; // master CPU clock, also pixel clock
|
||||
CoreComm.VsyncDen = (144 + 15) * (224 + 32); // 144 vislines, 15 vblank lines; 224 vispixels, 32 hblank pixels
|
||||
|
||||
saverambuff = new byte[BizSwan.bizswan_saveramsize(Core)];
|
||||
InitISaveRam();
|
||||
|
||||
InitVideo(rotate);
|
||||
PutSettings(_Settings);
|
||||
SetMemoryDomains();
|
||||
|
||||
savebuff = new byte[BizSwan.bizswan_binstatesize(Core)];
|
||||
savebuff2 = new byte[savebuff.Length + 13];
|
||||
InitIMemoryDomains();
|
||||
|
||||
InitIStatable();
|
||||
InitDebugCallbacks();
|
||||
}
|
||||
catch
|
||||
|
@ -109,60 +107,14 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
public bool DeterministicEmulation { get; private set; }
|
||||
public string BoardName { get { return null; } }
|
||||
|
||||
#region SaveRam
|
||||
|
||||
byte[] saverambuff;
|
||||
|
||||
public byte[] CloneSaveRam()
|
||||
{
|
||||
if (!BizSwan.bizswan_saveramsave(Core, saverambuff, saverambuff.Length))
|
||||
throw new InvalidOperationException("bizswan_saveramsave() returned false!");
|
||||
return (byte[])saverambuff.Clone();
|
||||
}
|
||||
|
||||
public void StoreSaveRam(byte[] data)
|
||||
{
|
||||
if (!BizSwan.bizswan_saveramload(Core, data, data.Length))
|
||||
throw new InvalidOperationException("bizswan_saveramload() returned false!");
|
||||
}
|
||||
|
||||
public bool SaveRamModified
|
||||
{
|
||||
get { return BizSwan.bizswan_saveramsize(Core) > 0; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Debugging
|
||||
|
||||
void SetMemoryDomains()
|
||||
{
|
||||
var mmd = new List<MemoryDomain>();
|
||||
for (int i = 0; ; i++)
|
||||
{
|
||||
IntPtr name;
|
||||
int size;
|
||||
IntPtr data;
|
||||
if (!BizSwan.bizswan_getmemoryarea(Core, i, out name, out size, out data))
|
||||
break;
|
||||
if (size == 0)
|
||||
continue;
|
||||
string sname = Marshal.PtrToStringAnsi(name);
|
||||
mmd.Add(MemoryDomain.FromIntPtr(sname, size, MemoryDomain.Endian.Little, data));
|
||||
}
|
||||
|
||||
MemoryDomains = new MemoryDomainList(mmd, 0);
|
||||
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
|
||||
}
|
||||
|
||||
private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem();
|
||||
public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } }
|
||||
|
||||
private readonly MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem();
|
||||
public IMemoryCallbackSystem MemoryCallbacks { get { return _memorycallbacks; } }
|
||||
|
||||
private IMemoryDomains MemoryDomains;
|
||||
|
||||
public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
|
||||
{
|
||||
var ret = new Dictionary<string, RegisterValue>();
|
||||
|
|
Loading…
Reference in New Issue