From f1d5ef0f0fdc934a225935f47decdc37f3220cbc Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 20 Jun 2020 14:03:57 -0500 Subject: [PATCH] create ISmsGpuView and have the Sms VdpViewer tool depend on it --- src/BizHawk.Client.EmuHawk/MainForm.Events.cs | 2 +- .../tools/SMS/VDPViewer.cs | 3 +-- .../Consoles/Sega/SMS/ISmsGpuView.cs | 14 +++++++++++++ .../Consoles/Sega/SMS/SMS.cs | 21 +++++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/ISmsGpuView.cs 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(); } 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(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(); + } } }