BasicServiceProvider - catch any IEmulatorServices that the core implements that aren't defined in the Emulation.Common assembly, and make IGBAGPUViewable an emulator service
This commit is contained in:
parent
7f0229d9e6
commit
d1cc13a9c0
|
@ -10,9 +10,10 @@ using System.Collections.Generic;
|
|||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[RequiredServices(typeof(IGBAGPUViewable))]
|
||||
public partial class GBAGPUView : Form, IToolForm
|
||||
{
|
||||
IGBAGPUViewable gba;
|
||||
IGBAGPUViewable gba { get { return (IGBAGPUViewable)EmulatorServices[typeof(IGBAGPUViewable)]; } }
|
||||
|
||||
public IDictionary<Type, object> EmulatorServices { private get; set; }
|
||||
|
||||
|
@ -683,23 +684,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void Restart()
|
||||
{
|
||||
gba = Global.Emulator as IGBAGPUViewable;
|
||||
if (gba != null)
|
||||
{
|
||||
var mem = gba.GetMemoryAreas();
|
||||
vram = mem.vram;
|
||||
palram = mem.palram;
|
||||
oam = mem.oam;
|
||||
mmio = mem.mmio;
|
||||
var mem = gba.GetMemoryAreas();
|
||||
vram = mem.vram;
|
||||
palram = mem.palram;
|
||||
oam = mem.oam;
|
||||
mmio = mem.mmio;
|
||||
|
||||
_cbscanlineEmu = 500; // force an update
|
||||
UpdateValues();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Visible)
|
||||
Close();
|
||||
}
|
||||
_cbscanlineEmu = 500; // force an update
|
||||
UpdateValues();
|
||||
}
|
||||
|
||||
/// <summary>belongs in ToolsBefore</summary>
|
||||
|
@ -707,19 +699,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (!IsHandleCreated || IsDisposed)
|
||||
return;
|
||||
if (gba != null)
|
||||
|
||||
if (_cbscanlineEmu != _cbscanline)
|
||||
{
|
||||
if (_cbscanlineEmu != _cbscanline)
|
||||
_cbscanlineEmu = _cbscanline;
|
||||
if (!_cbscanline.HasValue) // manual, deactivate callback
|
||||
{
|
||||
_cbscanlineEmu = _cbscanline;
|
||||
if (!_cbscanline.HasValue) // manual, deactivate callback
|
||||
{
|
||||
gba.SetScanlineCallback(null, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gba.SetScanlineCallback(DrawEverything, _cbscanline.Value);
|
||||
}
|
||||
gba.SetScanlineCallback(null, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gba.SetScanlineCallback(DrawEverything, _cbscanline.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -806,11 +796,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void GBAGPUView_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
if (gba != null)
|
||||
{
|
||||
gba.SetScanlineCallback(null, 0);
|
||||
gba = null;
|
||||
}
|
||||
gba.SetScanlineCallback(null, 0);
|
||||
}
|
||||
|
||||
#region copy to clipboard
|
||||
|
|
|
@ -33,6 +33,20 @@ namespace BizHawk.Emulation.Common
|
|||
// Add the core itself since we know a core implements IEmulatorService
|
||||
Services.Add(core.GetType(), core);
|
||||
|
||||
// Any IEmulatorServices the core might have that are core specific (and therefore not in Emulation.Common)
|
||||
var coreSpecificServices = core
|
||||
.GetType()
|
||||
.GetInterfaces()
|
||||
.Where(i => !services.Contains(i))
|
||||
.Where(t => typeof(IEmulatorService).IsAssignableFrom(t))
|
||||
.Where(t => !t.FullName.Contains("ISettable")) // adelikat: TODO: Hack! but I need a way around this, every core implements their own specific ISettable
|
||||
.ToList();
|
||||
|
||||
foreach (var service in coreSpecificServices)
|
||||
{
|
||||
Services.Add(service, core);
|
||||
}
|
||||
|
||||
foreach (var service in core.GetType().GetNestedTypes(BindingFlags.Public)
|
||||
.Where(t => typeof(IEmulatorService).IsAssignableFrom(t))
|
||||
.Where(t => t.IsClass))
|
||||
|
|
Loading…
Reference in New Issue