convert some gb tools to EmulatorServices
This commit is contained in:
parent
b3a47b911b
commit
7925b6f939
|
@ -11,9 +11,11 @@ using System.Collections.Generic;
|
|||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[RequiredServices(typeof(Gameboy))]
|
||||
public partial class GBGPUView : Form, IToolForm
|
||||
{
|
||||
public IDictionary<Type, object> EmulatorServices { private get; set; }
|
||||
private Gameboy Gb { get { return (Gameboy)EmulatorServices[typeof(Gameboy)]; } }
|
||||
|
||||
// TODO: freeze semantics are a bit weird: details for a mouseover or freeze are taken from the current
|
||||
// state, not the state at the last callback (and so can be quite different when update is set to manual).
|
||||
|
@ -30,8 +32,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
// g' = 8.25g
|
||||
// b' = 8.25b
|
||||
|
||||
private Gameboy _gb;
|
||||
|
||||
// gambatte doesn't modify these memory locations unless you reconstruct, so we can store
|
||||
private IntPtr _vram;
|
||||
private IntPtr _bgpal;
|
||||
|
@ -90,40 +90,31 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void Restart()
|
||||
{
|
||||
if (Global.Emulator is Gameboy)
|
||||
{
|
||||
_gb = Global.Emulator as Gameboy;
|
||||
_cgb = _gb.IsCGBMode();
|
||||
_lcdc = 0;
|
||||
if (!_gb.GetGPUMemoryAreas(out _vram, out _bgpal, out _sppal, out _oam))
|
||||
{
|
||||
_gb = null;
|
||||
if (Visible)
|
||||
Close();
|
||||
}
|
||||
tilespal = _bgpal;
|
||||
_cgb = Gb.IsCGBMode();
|
||||
_lcdc = 0;
|
||||
|
||||
if (_cgb)
|
||||
label4.Enabled = true;
|
||||
else
|
||||
label4.Enabled = false;
|
||||
bmpViewBG.Clear();
|
||||
bmpViewWin.Clear();
|
||||
bmpViewTiles1.Clear();
|
||||
bmpViewTiles2.Clear();
|
||||
bmpViewBGPal.Clear();
|
||||
bmpViewSPPal.Clear();
|
||||
bmpViewOAM.Clear();
|
||||
bmpViewDetails.Clear();
|
||||
bmpViewMemory.Clear();
|
||||
cbscanline_emu = -4; // force refresh
|
||||
}
|
||||
else
|
||||
// TODO: can this be a required Emulator Service, and let the tool manage the logic of closing?
|
||||
if (!Gb.GetGPUMemoryAreas(out _vram, out _bgpal, out _sppal, out _oam))
|
||||
{
|
||||
_gb = null;
|
||||
if (Visible)
|
||||
Close();
|
||||
}
|
||||
tilespal = _bgpal;
|
||||
|
||||
if (_cgb)
|
||||
label4.Enabled = true;
|
||||
else
|
||||
label4.Enabled = false;
|
||||
bmpViewBG.Clear();
|
||||
bmpViewWin.Clear();
|
||||
bmpViewTiles1.Clear();
|
||||
bmpViewTiles2.Clear();
|
||||
bmpViewBGPal.Clear();
|
||||
bmpViewSPPal.Clear();
|
||||
bmpViewOAM.Clear();
|
||||
bmpViewDetails.Clear();
|
||||
bmpViewMemory.Clear();
|
||||
cbscanline_emu = -4; // force refresh
|
||||
}
|
||||
|
||||
|
||||
|
@ -484,11 +475,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void GBGPUView_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
if (_gb != null)
|
||||
if (Gb != null)
|
||||
{
|
||||
_gb.SetScanlineCallback(null, 0);
|
||||
_gb = null;
|
||||
Gb.SetScanlineCallback(null, 0);
|
||||
}
|
||||
|
||||
Global.Config.GBGPUSpriteBack = spriteback;
|
||||
}
|
||||
|
||||
|
@ -536,8 +527,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void buttonRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (cbscanline == -2 && _gb != null)
|
||||
_gb.SetScanlineCallback(ScanlineCallback, -2);
|
||||
if (cbscanline == -2 && Gb != null)
|
||||
Gb.SetScanlineCallback(ScanlineCallback, -2);
|
||||
}
|
||||
|
||||
private void hScrollBarScanline_ValueChanged(object sender, EventArgs e)
|
||||
|
@ -564,14 +555,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
return;
|
||||
}
|
||||
else if (_gb != null)
|
||||
else if (Gb != null)
|
||||
{
|
||||
if (!Visible)
|
||||
{
|
||||
if (cbscanline_emu != -2)
|
||||
{
|
||||
cbscanline_emu = -2;
|
||||
_gb.SetScanlineCallback(null, 0);
|
||||
Gb.SetScanlineCallback(null, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -580,9 +571,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
cbscanline_emu = cbscanline;
|
||||
if (cbscanline == -2)
|
||||
_gb.SetScanlineCallback(null, 0);
|
||||
Gb.SetScanlineCallback(null, 0);
|
||||
else
|
||||
_gb.SetScanlineCallback(ScanlineCallback, cbscanline);
|
||||
Gb.SetScanlineCallback(ScanlineCallback, cbscanline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,15 @@ using BizHawk.Client.Common;
|
|||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[RequiredServices(typeof(IEmulator), typeof(IMemoryDomains))]
|
||||
public partial class GBGameGenie : Form, IToolForm
|
||||
{
|
||||
private readonly Dictionary<char, int> _gameGenieTable = new Dictionary<char, int>();
|
||||
private bool _processing;
|
||||
|
||||
public IDictionary<Type, object> EmulatorServices { private get; set; }
|
||||
private IMemoryDomains Emulator { get { return (IMemoryDomains)EmulatorServices[typeof(IMemoryDomains)]; } }
|
||||
private MemoryDomainList MemoryDomains { get { return (EmulatorServices[typeof(IMemoryDomains)] as IMemoryDomains).MemoryDomains; } }
|
||||
|
||||
#region Public
|
||||
|
||||
|
@ -25,7 +28,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void Restart()
|
||||
{
|
||||
if ((Global.Emulator.SystemId != "GB") && (Global.Game.System != "GG"))
|
||||
if ((Emulator.SystemId != "GB") && (Global.Game.System != "GG"))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
@ -33,7 +36,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void UpdateValues()
|
||||
{
|
||||
if ((Global.Emulator.SystemId != "GB") && (Global.Game.System != "GG"))
|
||||
if ((Emulator.SystemId != "GB") && (Global.Game.System != "GG"))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
@ -190,7 +193,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
//"Game Boy/Game Gear Game Genie Encoder / Decoder"
|
||||
if (Global.Emulator.SystemId == "GB")
|
||||
if (Emulator.SystemId == "GB")
|
||||
{
|
||||
Text = "Game Boy Game Genie Encoder/Decoder";
|
||||
}
|
||||
|
@ -256,7 +259,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void AddCheatClick(object sender, EventArgs e)
|
||||
{
|
||||
if ((Global.Emulator.SystemId == "GB") || (Global.Game.System == "GG"))
|
||||
if ((Emulator.SystemId == "GB") || (Global.Game.System == "GG"))
|
||||
{
|
||||
string name;
|
||||
var address = 0;
|
||||
|
@ -299,7 +302,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
var watch = Watch.GenerateWatch(
|
||||
Global.Emulator.AsMemoryDomains().MemoryDomains["System Bus"],
|
||||
MemoryDomains["System Bus"],
|
||||
address,
|
||||
Watch.WatchSize.Byte,
|
||||
Watch.DisplayType.Hex,
|
||||
|
|
Loading…
Reference in New Issue