diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs index 698eb2714f..ae55e4f951 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -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) diff --git a/src/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs b/src/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs index c4425ac41d..c8144c73d1 100644 --- a/src/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs +++ b/src/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs @@ -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; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/ISmsGpuView.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/ISmsGpuView.cs new file mode 100644 index 0000000000..aaeab7dcf8 --- /dev/null +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/ISmsGpuView.cs @@ -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(); + } +} diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs index f74bba6fdb..7812b079ee 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs @@ -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(); + } } }