Do some cleanups with Stella, mark as experimental
This commit is contained in:
parent
32a66a955c
commit
1b92d1080f
|
@ -2,11 +2,10 @@
|
|||
|
||||
using BizHawk.BizInvoke;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Atari.Stella
|
||||
namespace BizHawk.Emulation.Cores.Atari.Stella
|
||||
{
|
||||
public abstract class CInterface
|
||||
{
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate int load_archive_cb(string filename, IntPtr buffer, int maxsize);
|
||||
|
||||
|
@ -26,7 +25,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Atari.Stella
|
|||
public abstract bool stella_init(
|
||||
string fileName,
|
||||
load_archive_cb feload_archive_cb,
|
||||
[In]InitSettings settings);
|
||||
[In] InitSettings settings);
|
||||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract void stella_frame_advance(int port1, int port2, bool reset, bool power, bool leftDiffToggled, bool rightDiffToggled);
|
||||
|
@ -75,6 +74,5 @@ namespace BizHawk.Emulation.Cores.Consoles.Atari.Stella
|
|||
|
||||
[BizImport(CallingConvention.Cdecl)]
|
||||
public abstract IntPtr stella_get_cart_type();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
using BizHawk.Emulation.Cores.Components.M6502;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Atari.Stella
|
||||
{
|
||||
public partial class Stella
|
||||
{
|
||||
internal struct CpuLink : IMOS6502XLink
|
||||
{
|
||||
public byte DummyReadMemory(ushort address) { return 0; }
|
||||
|
||||
public void OnExecFetch(ushort address) { }
|
||||
|
||||
public byte PeekMemory(ushort address) { return 0; }
|
||||
|
||||
public byte ReadMemory(ushort address) { return 0; }
|
||||
|
||||
public void WriteMemory(ushort address, byte value) { }
|
||||
}
|
||||
|
||||
internal byte BaseReadMemory(ushort addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal byte BasePeekMemory(ushort addr)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal void BaseWriteMemory(ushort addr, byte value)
|
||||
{
|
||||
}
|
||||
|
||||
internal void BasePokeMemory(ushort addr, byte value)
|
||||
{
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private byte ReadMemory(ushort addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void WriteMemory(ushort addr, byte value)
|
||||
{
|
||||
}
|
||||
|
||||
internal void PokeMemory(ushort addr, byte value)
|
||||
{
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void ExecFetch(ushort addr)
|
||||
{
|
||||
}
|
||||
|
||||
private void RebootCore()
|
||||
{
|
||||
}
|
||||
|
||||
private void HardReset()
|
||||
{
|
||||
}
|
||||
|
||||
private void Cycle()
|
||||
{
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal byte ReadControls1(bool peek)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal byte ReadControls2(bool peek)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal int ReadPot1(int pot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal int ReadPot2(int pot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal byte ReadConsoleSwitches(bool peek)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,12 +8,11 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
|
||||
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
|
||||
|
||||
private bool _leftDifficultyToggled = false;
|
||||
private bool _rightDifficultyToggled = false;
|
||||
private bool _leftDifficultyToggled;
|
||||
private bool _rightDifficultyToggled;
|
||||
|
||||
public bool FrameAdvance(IController controller, bool render, bool renderSound)
|
||||
{
|
||||
|
||||
int port1 = _controllerDeck.ReadPort1(controller);
|
||||
int port2 = _controllerDeck.ReadPort2(controller);
|
||||
|
||||
|
@ -36,16 +35,14 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
UpdateVideo();
|
||||
|
||||
if (renderSound)
|
||||
update_audio();
|
||||
UpdateAudio();
|
||||
|
||||
_frame++;
|
||||
Frame++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int _frame;
|
||||
|
||||
public int Frame => _frame;
|
||||
public int Frame { get; private set; }
|
||||
|
||||
public string SystemId => VSystemID.Raw.A26;
|
||||
|
||||
|
@ -53,13 +50,14 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
|
||||
public void ResetCounters()
|
||||
{
|
||||
_frame = 0;
|
||||
Frame = 0;
|
||||
LagCount = 0;
|
||||
IsLagFrame = false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_elf.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Consoles.Atari.Stella;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Atari.Stella
|
||||
{
|
||||
|
@ -13,9 +12,9 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
|
||||
private readonly CInterface.input_cb _inputCallback;
|
||||
|
||||
private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem();
|
||||
private readonly InputCallbackSystem _inputCallbacks = [ ];
|
||||
|
||||
private void input_callback()
|
||||
private void InputCallback()
|
||||
{
|
||||
InputCallbacks.Call();
|
||||
IsLagFrame = false;
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
{
|
||||
_cartMemSize = Core.stella_get_cartram_size();
|
||||
var mainRamAddress = IntPtr.Zero;
|
||||
var cartDPCRamAddress = IntPtr.Zero;
|
||||
Core.stella_get_mainram_ptr(ref mainRamAddress);
|
||||
|
||||
var domains = new List<MemoryDomain>
|
||||
|
|
|
@ -5,38 +5,33 @@ using Newtonsoft.Json;
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Cores.Consoles.Atari.Stella;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Atari.Stella
|
||||
{
|
||||
public partial class Stella : ISettable<Stella.A2600Settings, Stella.A2600SyncSettings>
|
||||
{
|
||||
private A2600Settings _settings;
|
||||
private A2600SyncSettings _syncSettings;
|
||||
|
||||
public A2600Settings GetSettings()
|
||||
{
|
||||
return Settings.Clone();
|
||||
}
|
||||
=> _settings.Clone();
|
||||
|
||||
public A2600SyncSettings GetSyncSettings()
|
||||
{
|
||||
return SyncSettings.Clone();
|
||||
}
|
||||
=> _syncSettings.Clone();
|
||||
|
||||
public PutSettingsDirtyBits PutSettings(A2600Settings o)
|
||||
{
|
||||
Settings = o;
|
||||
_settings = o;
|
||||
return PutSettingsDirtyBits.None;
|
||||
}
|
||||
|
||||
public PutSettingsDirtyBits PutSyncSettings(A2600SyncSettings o)
|
||||
{
|
||||
bool ret = A2600SyncSettings.NeedsReboot(SyncSettings, o);
|
||||
SyncSettings = o;
|
||||
var ret = A2600SyncSettings.NeedsReboot(_syncSettings, o);
|
||||
_syncSettings = o;
|
||||
return ret ? PutSettingsDirtyBits.RebootCore : PutSettingsDirtyBits.None;
|
||||
}
|
||||
|
||||
internal A2600Settings Settings { get; private set; }
|
||||
internal A2600SyncSettings SyncSettings { get; private set; }
|
||||
|
||||
[CoreSettings]
|
||||
public class A2600Settings
|
||||
{
|
||||
|
@ -133,9 +128,7 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
public Color BackgroundColor { get; set; }
|
||||
|
||||
public A2600Settings Clone()
|
||||
{
|
||||
return (A2600Settings)MemberwiseClone();
|
||||
}
|
||||
=> (A2600Settings)MemberwiseClone();
|
||||
|
||||
public A2600Settings()
|
||||
{
|
||||
|
@ -178,7 +171,6 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
[DefaultValue(false)]
|
||||
public bool FastScBios { get; set; }
|
||||
|
||||
|
||||
public CInterface.InitSettings GetNativeSettings(GameInfo game)
|
||||
{
|
||||
return new CInterface.InitSettings
|
||||
|
@ -188,9 +180,7 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
}
|
||||
|
||||
public A2600SyncSettings Clone()
|
||||
{
|
||||
return (A2600SyncSettings)MemberwiseClone();
|
||||
}
|
||||
=> (A2600SyncSettings)MemberwiseClone();
|
||||
|
||||
public A2600SyncSettings()
|
||||
{
|
||||
|
@ -198,9 +188,7 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
}
|
||||
|
||||
public static bool NeedsReboot(A2600SyncSettings x, A2600SyncSettings y)
|
||||
{
|
||||
return !DeepEquality.DeepEquals(x, y);
|
||||
}
|
||||
=> !DeepEquality.DeepEquals(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Atari.Stella
|
||||
|
@ -38,15 +39,17 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
throw new InvalidOperationException("Async mode is not supported.");
|
||||
}
|
||||
|
||||
private void update_audio()
|
||||
private void UpdateAudio()
|
||||
{
|
||||
IntPtr src = IntPtr.Zero;
|
||||
var src = IntPtr.Zero;
|
||||
Core.stella_get_audio(ref _nsamp, ref src);
|
||||
|
||||
if (src != IntPtr.Zero)
|
||||
{
|
||||
using (_elf.EnterExit())
|
||||
{
|
||||
Marshal.Copy(src, _samples, 0, _nsamp * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
{
|
||||
_elf.LoadStateBinary(reader);
|
||||
// other variables
|
||||
_frame = reader.ReadInt32();
|
||||
Frame = reader.ReadInt32();
|
||||
LagCount = reader.ReadInt32();
|
||||
IsLagFrame = reader.ReadBoolean();
|
||||
// any managed pointers that we sent to the core need to be resent now!
|
||||
|
|
|
@ -11,9 +11,9 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
|
||||
public int VirtualHeight => 192;
|
||||
|
||||
public int BufferWidth => _vwidth;
|
||||
public int BufferWidth { get; private set; }
|
||||
|
||||
public int BufferHeight => _vheight;
|
||||
public int BufferHeight { get; private set; }
|
||||
|
||||
public int BackgroundColor => unchecked((int)0xff000000);
|
||||
|
||||
|
@ -21,61 +21,30 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
|
||||
public int VsyncDenominator { get; }
|
||||
|
||||
private int[] _vidBuff = new int[0];
|
||||
private int _vwidth;
|
||||
private int _vheight;
|
||||
|
||||
private void UpdateVideoInitial()
|
||||
{
|
||||
// hack: you should call update_video() here, but that gives you 256x192 on frame 0
|
||||
// and we know that we only use GPGX to emulate genesis games that will always be 320x224 immediately afterwards
|
||||
|
||||
// so instead, just assume a 320x224 size now; if that happens to be wrong, it'll be fixed soon enough.
|
||||
|
||||
_vwidth = 320;
|
||||
_vheight = 224;
|
||||
_vidBuff = new int[_vwidth * _vheight];
|
||||
for (int i = 0; i < _vidBuff.Length; i++)
|
||||
{
|
||||
_vidBuff[i] = unchecked((int)0xff000000);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly byte[] TwoBitToEightBitTable = new byte[] { 0, 85, 171, 255 };
|
||||
private readonly byte[] ThreeBitToEightBitTable = new byte[] { 0, 36, 73, 109, 146, 182, 219, 255 };
|
||||
private readonly int[] _vidPalette;
|
||||
private int[] _vidBuff = [ ];
|
||||
|
||||
private unsafe void UpdateVideo()
|
||||
{
|
||||
if (Frame == 0)
|
||||
{
|
||||
UpdateVideoInitial();
|
||||
return;
|
||||
}
|
||||
|
||||
using (_elf.EnterExit())
|
||||
{
|
||||
IntPtr src = IntPtr.Zero;
|
||||
var src = IntPtr.Zero;
|
||||
Core.stella_get_video(out var width, out var height, out _, ref src);
|
||||
|
||||
Core.stella_get_video(out var width, out var height, out var pitch, ref src);
|
||||
BufferWidth = width;
|
||||
BufferHeight = height;
|
||||
|
||||
_vwidth = width;
|
||||
_vheight = height;
|
||||
|
||||
byte* buffer = (byte*)src.ToPointer();
|
||||
if (_vidBuff.Length < BufferWidth * BufferHeight)
|
||||
{
|
||||
_vidBuff = new int[BufferWidth * BufferHeight];
|
||||
}
|
||||
|
||||
if (_vidBuff.Length < _vwidth * _vheight)
|
||||
_vidBuff = new int[_vwidth * _vheight];
|
||||
|
||||
if (Region == DisplayType.NTSC)
|
||||
for (int i = 0; i < _vidBuff.Length; i++) _vidBuff[i] = NTSCPalette[buffer[i]];
|
||||
|
||||
if (Region == DisplayType.PAL)
|
||||
for (int i = 0; i < _vidBuff.Length; i++) _vidBuff[i] = PALPalette[buffer[i]];
|
||||
|
||||
if (Region == DisplayType.SECAM)
|
||||
for (int i = 0; i < _vidBuff.Length; i++) _vidBuff[i] = SecamPalette[buffer[i]];
|
||||
var buffer = (byte*)src.ToPointer();
|
||||
for (var i = 0; i < _vidBuff.Length; i++)
|
||||
{
|
||||
_vidBuff[i] = _vidPalette[buffer[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
public partial class Stella
|
||||
{
|
||||
private static readonly int[] PALPalette =
|
||||
{
|
||||
[
|
||||
0x000000, 0x000000, 0x2b2b2b, 0x2b2b2b,
|
||||
0x525252, 0x525252, 0x767676, 0x767676,
|
||||
0x979797, 0x979797, 0xb6b6b6, 0xb6b6b6,
|
||||
|
@ -83,10 +83,10 @@
|
|||
0x525252, 0x525252, 0x767676, 0x767676,
|
||||
0x979797, 0x979797, 0xb6b6b6, 0xb6b6b6,
|
||||
0xd2d2d2, 0xd2d2d2, 0xececec, 0xececec
|
||||
};
|
||||
];
|
||||
|
||||
private static readonly int[] NTSCPalette =
|
||||
{
|
||||
[
|
||||
0x000000, 0, 0x4a4a4a, 0, 0x6f6f6f, 0, 0x8e8e8e, 0,
|
||||
0xaaaaaa, 0, 0xc0c0c0, 0, 0xd6d6d6, 0, 0xececec, 0,
|
||||
0x484800, 0, 0x69690f, 0, 0x86861d, 0, 0xa2a22a, 0,
|
||||
|
@ -119,10 +119,10 @@
|
|||
0xa0ab4f, 0, 0xb7c25f, 0, 0xccd86e, 0, 0xe0ec7c, 0,
|
||||
0x482c00, 0, 0x694d14, 0, 0x866a26, 0, 0xa28638, 0,
|
||||
0xbb9f47, 0, 0xd2b656, 0, 0xe8cc63, 0, 0xfce070, 0
|
||||
};
|
||||
];
|
||||
|
||||
private static readonly int[] SecamPalette =
|
||||
{
|
||||
[
|
||||
0x000000, 0x000000, 0x2121FF, 0x2121FF,
|
||||
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
|
||||
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
|
||||
|
@ -202,6 +202,6 @@
|
|||
0xF03C79, 0xF03C79, 0xFF50FF, 0xFF50FF,
|
||||
0x7FFF00, 0x7FFF00, 0x7FFFFF, 0x7FFFFF,
|
||||
0xFFFF3F, 0xFFFF3F, 0xffffff, 0xffffff
|
||||
};
|
||||
];
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.BizInvoke;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Common.PathExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Consoles.Atari.Stella;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Atari.Stella
|
||||
|
@ -13,28 +12,19 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
name: CoreNames.Stella,
|
||||
author: "The Stella Team",
|
||||
// portedVersion: "", //TODO
|
||||
portedUrl: "https://stella-emu.github.io")]
|
||||
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(ISaveRam) })]
|
||||
public partial class Stella : IEmulator, IVideoProvider, IInputPollable, IRomInfo, IRegionable,
|
||||
ICreateGameDBEntries, ISettable<Stella.A2600Settings, Stella.A2600SyncSettings>
|
||||
portedUrl: "https://stella-emu.github.io",
|
||||
isReleased: false)]
|
||||
[ServiceNotApplicable([ typeof(IDriveLight), typeof(ISaveRam) ])]
|
||||
public partial class Stella : IRomInfo, IRegionable
|
||||
{
|
||||
internal static class RomChecksums
|
||||
{
|
||||
public const string CongoBongo = "SHA1:3A77DB43B6583E8689435F0F14AA04B9E57BDDED";
|
||||
|
||||
public const string KangarooNotInGameDB = "SHA1:982B8016B393A9AA7DD110295A53C4612ECF2141";
|
||||
|
||||
public const string Tapper = "SHA1:E986E1818E747BEB9B33CE4DFF1CDC6B55BDB620";
|
||||
}
|
||||
|
||||
[CoreConstructor(VSystemID.Raw.A26)]
|
||||
public Stella(CoreLoadParameters<Stella.A2600Settings, Stella.A2600SyncSettings> lp)
|
||||
public Stella(CoreLoadParameters<A2600Settings, A2600SyncSettings> lp)
|
||||
{
|
||||
var ser = new BasicServiceProvider(this);
|
||||
ServiceProvider = ser;
|
||||
SyncSettings = lp.SyncSettings ?? new A2600SyncSettings();
|
||||
Settings = lp.Settings ?? new A2600Settings();
|
||||
_controllerDeck = new Atari2600ControllerDeck(SyncSettings.Port1, SyncSettings.Port2);
|
||||
_syncSettings = lp.SyncSettings ?? new A2600SyncSettings();
|
||||
_settings = lp.Settings ?? new A2600Settings();
|
||||
_controllerDeck = new Atari2600ControllerDeck(_syncSettings.Port1, _syncSettings.Port2);
|
||||
|
||||
_elf = new WaterboxHost(new WaterboxOptions
|
||||
{
|
||||
|
@ -49,90 +39,90 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
SkipMemoryConsistencyCheck = lp.Comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck),
|
||||
});
|
||||
|
||||
LoadCallback = load_archive;
|
||||
_inputCallback = input_callback;
|
||||
|
||||
var callingConventionAdapter = CallingConventionAdapters.MakeWaterbox(new Delegate[]
|
||||
try
|
||||
{
|
||||
LoadCallback, _inputCallback
|
||||
}, _elf);
|
||||
_loadCallback = LoadCallback;
|
||||
_inputCallback = InputCallback;
|
||||
|
||||
using (_elf.EnterExit())
|
||||
{
|
||||
Core = BizInvoker.GetInvoker<CInterface>(_elf, _elf, callingConventionAdapter);
|
||||
SyncSettings = lp.SyncSettings ?? new A2600SyncSettings();
|
||||
Settings = lp.Settings ?? new A2600Settings();
|
||||
var callingConventionAdapter = CallingConventionAdapters.MakeWaterbox(
|
||||
[
|
||||
_loadCallback, _inputCallback
|
||||
], _elf);
|
||||
|
||||
CoreComm = lp.Comm;
|
||||
using (_elf.EnterExit())
|
||||
{
|
||||
Core = BizInvoker.GetInvoker<CInterface>(_elf, _elf, callingConventionAdapter);
|
||||
_syncSettings = lp.SyncSettings ?? new A2600SyncSettings();
|
||||
_settings = lp.Settings ?? new A2600Settings();
|
||||
|
||||
_romfile = lp.Roms.FirstOrDefault()?.RomData;
|
||||
string romPath = lp.Roms.FirstOrDefault()?.RomPath;
|
||||
_romfile = lp.Roms[0].RomData;
|
||||
var initResult = Core.stella_init("rom.a26", LoadCallback, _syncSettings.GetNativeSettings(lp.Game));
|
||||
|
||||
var initResult = Core.stella_init(romPath, LoadCallback, SyncSettings.GetNativeSettings(lp.Game));
|
||||
if (!initResult) throw new Exception($"{nameof(Core.stella_init)}() failed");
|
||||
|
||||
if (!initResult) throw new Exception($"{nameof(Core.stella_init)}() failed");
|
||||
Core.stella_get_frame_rate(out var fps);
|
||||
|
||||
Core.stella_get_frame_rate(out int fps);
|
||||
var regionId = Core.stella_get_region();
|
||||
Region = regionId switch
|
||||
{
|
||||
0 => DisplayType.NTSC,
|
||||
1 => DisplayType.PAL,
|
||||
2 => DisplayType.SECAM,
|
||||
_ => throw new InvalidOperationException()
|
||||
};
|
||||
|
||||
int regionId = Core.stella_get_region();
|
||||
if (regionId == 0) _region = DisplayType.NTSC;
|
||||
if (regionId == 1) _region = DisplayType.PAL;
|
||||
if (regionId == 2) _region = DisplayType.SECAM;
|
||||
// ReSharper disable once SwitchExpressionHandlesSomeKnownEnumValuesWithExceptionInDefault
|
||||
_vidPalette = Region switch
|
||||
{
|
||||
DisplayType.NTSC => NTSCPalette,
|
||||
DisplayType.PAL => PALPalette,
|
||||
DisplayType.SECAM => SecamPalette,
|
||||
_ => throw new InvalidOperationException()
|
||||
};
|
||||
|
||||
VsyncNumerator = fps;
|
||||
VsyncDenominator = 1;
|
||||
VsyncNumerator = fps;
|
||||
VsyncDenominator = 1;
|
||||
|
||||
Core.stella_set_input_callback(_inputCallback);
|
||||
Core.stella_set_input_callback(_inputCallback);
|
||||
|
||||
// Getting cartridge type
|
||||
var ptr = Core.stella_get_cart_type();
|
||||
string _cartType = Marshal.PtrToStringAnsi(ptr);
|
||||
Console.WriteLine("[Stella] Cart type loaded: {0} (string size: {1}, ptr: {2})", _cartType, _cartType.Length, ptr);
|
||||
// Getting cartridge type
|
||||
var ptr = Core.stella_get_cart_type();
|
||||
var cartType = Marshal.PtrToStringAnsi(ptr);
|
||||
Console.WriteLine($"[Stella] Cart type loaded: {cartType}");
|
||||
|
||||
_elf.Seal();
|
||||
RomDetails = $"{lp.Game.Name}\r\n{SHA1Checksum.ComputePrefixedHex(_romfile)}\r\n{MD5Checksum.ComputePrefixedHex(_romfile)}\r\nMapper Impl \"{cartType}\"";
|
||||
|
||||
_elf.Seal();
|
||||
}
|
||||
|
||||
// pull the default video size from the core
|
||||
UpdateVideo();
|
||||
|
||||
// Registering memory domains
|
||||
SetupMemoryDomains();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Dispose();
|
||||
throw;
|
||||
}
|
||||
|
||||
// pull the default video size from the core
|
||||
UpdateVideo();
|
||||
|
||||
// Registering memory domains
|
||||
SetupMemoryDomains();
|
||||
}
|
||||
|
||||
// IRegionable
|
||||
public DisplayType Region => _region;
|
||||
public DisplayType Region { get; }
|
||||
|
||||
private DisplayType _region;
|
||||
// IRomInfo
|
||||
public string RomDetails { get; }
|
||||
|
||||
private CInterface.load_archive_cb LoadCallback;
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
private readonly CInterface.load_archive_cb _loadCallback;
|
||||
|
||||
private readonly byte[] _romfile;
|
||||
private readonly CInterface Core;
|
||||
private readonly WaterboxHost _elf;
|
||||
private string _cartType { get; }
|
||||
|
||||
private CoreComm CoreComm { get; }
|
||||
|
||||
public string RomDetails { get; private set; }
|
||||
|
||||
private readonly Atari2600ControllerDeck _controllerDeck;
|
||||
|
||||
private ITraceable Tracer { get; }
|
||||
|
||||
// ICreateGameDBEntries
|
||||
public CompactGameInfo GenerateGameDbEntry()
|
||||
{
|
||||
return new CompactGameInfo
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
// IBoardInfo
|
||||
private static bool DetectPal(GameInfo game, byte[] rom)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// core callback for file loading
|
||||
/// </summary>
|
||||
|
@ -140,7 +130,7 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
/// <param name="buffer">buffer to load file to</param>
|
||||
/// <param name="maxsize">maximum length buffer can hold</param>
|
||||
/// <returns>actual size loaded, or 0 on failure</returns>
|
||||
private int load_archive(string filename, IntPtr buffer, int maxsize)
|
||||
private int LoadCallback(string filename, IntPtr buffer, int maxsize)
|
||||
{
|
||||
byte[] srcdata = null;
|
||||
|
||||
|
@ -179,7 +169,6 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
{
|
||||
throw new InvalidOperationException("Unknown error processing firmware");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Atari.Stella
|
||||
{
|
||||
public class Atari2600ControllerDeck
|
||||
{
|
||||
|
||||
public Atari2600ControllerDeck(Atari2600ControllerTypes controller1, Atari2600ControllerTypes controller2)
|
||||
{
|
||||
Port1 = ControllerCtors[controller1](1);
|
||||
|
@ -18,10 +16,10 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
{
|
||||
BoolButtons = Port1.Definition.BoolButtons
|
||||
.Concat(Port2.Definition.BoolButtons)
|
||||
.Concat(new[]
|
||||
{
|
||||
.Concat(
|
||||
[
|
||||
"Reset", "Select", "Power", "Toggle Left Difficulty", "Toggle Right Difficulty"
|
||||
})
|
||||
])
|
||||
.ToList()
|
||||
};
|
||||
|
||||
|
@ -32,38 +30,19 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
}
|
||||
|
||||
public byte ReadPort1(IController c)
|
||||
{
|
||||
return Port1.Read(c);
|
||||
}
|
||||
=> Port1.Read(c);
|
||||
|
||||
public byte ReadPort2(IController c)
|
||||
{
|
||||
return Port2.Read(c);
|
||||
}
|
||||
=> Port2.Read(c);
|
||||
|
||||
public int ReadPot1(IController c, int pot)
|
||||
{
|
||||
return Port1.Read_Pot(c, pot);
|
||||
}
|
||||
=> Port1.Read_Pot(c, pot);
|
||||
|
||||
public int ReadPot2(IController c, int pot)
|
||||
{
|
||||
return Port2.Read_Pot(c, pot);
|
||||
}
|
||||
=> Port2.Read_Pot(c, pot);
|
||||
|
||||
public ControllerDefinition Definition { get; }
|
||||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
ser.BeginSection(nameof(Port1));
|
||||
Port1.SyncState(ser);
|
||||
ser.EndSection();
|
||||
|
||||
ser.BeginSection(nameof(Port2));
|
||||
Port2.SyncState(ser);
|
||||
ser.EndSection();
|
||||
}
|
||||
|
||||
private readonly IPort Port1;
|
||||
private readonly IPort Port2;
|
||||
|
||||
|
|
|
@ -26,8 +26,6 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
|
||||
ControllerDefinition Definition { get; }
|
||||
|
||||
void SyncState(Serializer ser);
|
||||
|
||||
int PortNum { get; }
|
||||
}
|
||||
|
||||
|
@ -51,11 +49,6 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
|
||||
public ControllerDefinition Definition { get; }
|
||||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
}
|
||||
|
||||
|
@ -74,11 +67,6 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
|
||||
public ControllerDefinition Definition { get; }
|
||||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
// Nothing todo, I think
|
||||
}
|
||||
|
||||
public int PortNum { get; }
|
||||
|
||||
public byte Read(IController c)
|
||||
|
@ -100,9 +88,9 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
}
|
||||
|
||||
private static readonly string[] BaseDefinition =
|
||||
{
|
||||
[
|
||||
"Up", "Down", "Left", "Right", "Button"
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
public class PaddleController : IPort
|
||||
|
@ -122,18 +110,13 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
|
||||
public int PortNum { get; }
|
||||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
// Nothing todo, I think
|
||||
}
|
||||
|
||||
public ControllerDefinition Definition { get; }
|
||||
|
||||
private static readonly string[] BaseDefinition =
|
||||
{
|
||||
[
|
||||
"Button 1",
|
||||
"Button 2"
|
||||
};
|
||||
];
|
||||
|
||||
public byte Read(IController c)
|
||||
{
|
||||
|
@ -173,19 +156,14 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
|
||||
public int PortNum { get; }
|
||||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
// Nothing todo, I think
|
||||
}
|
||||
|
||||
public ControllerDefinition Definition { get; }
|
||||
|
||||
private static readonly string[] BaseDefinition =
|
||||
{
|
||||
[
|
||||
"Up", "Down", "Left", "Right", "Button",
|
||||
"Button 1",
|
||||
"Button 2"
|
||||
};
|
||||
];
|
||||
|
||||
public byte Read(IController c)
|
||||
{
|
||||
|
@ -239,17 +217,12 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
|
||||
public int PortNum { get; }
|
||||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
// Nothing todo, I think
|
||||
}
|
||||
|
||||
public ControllerDefinition Definition { get; }
|
||||
|
||||
private static readonly string[] BaseDefinition =
|
||||
{
|
||||
[
|
||||
"Button"
|
||||
};
|
||||
];
|
||||
|
||||
public byte Read(IController c)
|
||||
{
|
||||
|
@ -365,11 +338,11 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
|
|||
}
|
||||
|
||||
private static readonly string[] BaseDefinition =
|
||||
{
|
||||
[
|
||||
"1", "2", "3",
|
||||
"4", "5", "6",
|
||||
"7", "8", "9",
|
||||
"*", "0", "#"
|
||||
};
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue