create ISmsGpuView and have the Sms VdpViewer tool depend on it

This commit is contained in:
adelikat 2020-06-20 14:03:57 -05:00
parent 8bfe6011bc
commit f1d5ef0f0f
4 changed files with 37 additions and 3 deletions

View File

@ -1550,7 +1550,7 @@ namespace BizHawk.Client.EmuHawk
private void SmsSubMenu_DropDownOpened(object sender, EventArgs e)
{
SmsVdpViewerMenuItem.Visible = Game.System != "SG";
SmsVdpViewerMenuItem.Enabled = Tools.IsAvailable<SmsVdpViewer>();
}
private void SmsBiosMenuItem_Click(object sender, EventArgs e)

View File

@ -12,8 +12,7 @@ namespace BizHawk.Client.EmuHawk
public partial class SmsVdpViewer : ToolFormBase, IToolFormAutoConfig
{
[RequiredService]
private SMS Sms { get; set; }
private VDP Vdp => Sms.Vdp;
private ISmsGpuView Vdp { get; set; }
private int _palIndex;

View File

@ -0,0 +1,14 @@
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Sega.MasterSystem
{
public interface ISmsGpuView : IEmulatorService
{
byte[] PatternBuffer { get; }
int FrameHeight { get; }
byte[] VRAM { get; }
int[] Palette { get; }
int CalcNameTableBase();
}
}

View File

@ -208,6 +208,11 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
// stops a few SMS and GG games from crashing
Cpu.Regs[Cpu.SPl] = 0xF0;
Cpu.Regs[Cpu.SPh] = 0xDF;
if (!IsSG1000)
{
ser.Register<ISmsGpuView>(new SmsGpuView(Vdp));
}
}
public void HardReset()
@ -417,5 +422,21 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
}
private readonly SmsSyncSettings.Regions _region;
public class SmsGpuView : ISmsGpuView
{
private readonly VDP _vdp;
public SmsGpuView(VDP vdp)
{
_vdp = vdp;
}
public byte[] PatternBuffer => _vdp.PatternBuffer;
public int FrameHeight => _vdp.FrameHeight;
public byte[] VRAM => _vdp.VRAM;
public int[] Palette => _vdp.Palette;
public int CalcNameTableBase() => _vdp.CalcNameTableBase();
}
}
}