From 9fdeb9f5eb5639bd73907986a4d3dd5c72df9c2b Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Sat, 12 Jan 2019 08:12:21 -0600 Subject: [PATCH] SubNESHawk: fix gambatte frameadvancepost, allow ppuviewer and nametableviewer --- .../Consoles/Nintendo/Gameboy/Gambatte.cs | 4 +- .../Consoles/Nintendo/NES/NES.Core.cs | 2 +- .../Nintendo/SubNESHawk/SubNESHawk.cs | 106 +++++++++++++++++- 3 files changed, 107 insertions(+), 5 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index b0bdd405d9..1f1891e1a5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -344,7 +344,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy LibGambatte.gambatte_setlayers(GambatteState, (_settings.DisplayBG ? 1 : 0) | (_settings.DisplayOBJ ? 2 : 0) | (_settings.DisplayWindow ? 4 : 0)); } - internal bool FrameAdvancePost() + internal void FrameAdvancePost() { if (IsLagFrame) { @@ -352,8 +352,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy } endofframecallback?.Invoke(LibGambatte.gambatte_cpuread(GambatteState, 0xff40)); - - return true; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs index 851291e2a1..6ff0282779 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs @@ -31,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public int cpuclockrate { get; private set; } //user configuration - int[] palette_compiled = new int[64 * 8]; + public int[] palette_compiled = new int[64 * 8]; //variable set when VS system games are running internal bool _isVS = false; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs index a04a68f7f8..91d590f508 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs @@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk isReleased: false)] [ServiceNotApplicable(typeof(IDriveLight))] public partial class SubNESHawk : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, - ISettable + ISettable, INESPPUViewable { public NES.NES subnes; @@ -76,5 +76,109 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk { MemoryCallbacks.CallExecutes(addr, "System Bus"); } + + #region PPU Viewable + + public int[] GetPalette() + { + return subnes.palette_compiled; + } + + public bool BGBaseHigh + { + get { return subnes.ppu.reg_2000.bg_pattern_hi; } + } + + public bool SPBaseHigh + { + get { return subnes.ppu.reg_2000.obj_pattern_hi; } + } + + public bool SPTall + { + get { return subnes.ppu.reg_2000.obj_size_16; } + } + + public byte[] GetPPUBus() + { + byte[] ret = new byte[0x3000]; + for (int i = 0; i < 0x3000; i++) + { + ret[i] = subnes.ppu.ppubus_peek(i); + } + return ret; + } + + public byte[] GetPalRam() + { + return subnes.ppu.PALRAM; + } + + public byte[] GetOam() + { + return subnes.ppu.OAM; + } + + public byte PeekPPU(int addr) + { + return subnes.Board.PeekPPU(addr); + } + + public byte[] GetExTiles() + { + if (subnes.Board is ExROM) + { + return subnes.Board.VROM ?? subnes.Board.VRAM; + } + else + { + throw new InvalidOperationException(); + } + } + + public bool ExActive + { + get { return subnes.Board is ExROM && (subnes.Board as ExROM).ExAttrActive; } + } + + public byte[] GetExRam() + { + if (subnes.Board is ExROM) + { + return (subnes.Board as ExROM).GetExRAMArray(); + } + else + { + throw new InvalidOperationException(); + } + } + + public MemoryDomain GetCHRROM() + { + return _memoryDomains["CHR VROM"]; + } + + + public void InstallCallback1(Action cb, int sl) + { + subnes.ppu.NTViewCallback = new PPU.DebugCallback { Callback = cb, Scanline = sl }; + } + + public void InstallCallback2(Action cb, int sl) + { + subnes.ppu.PPUViewCallback = new PPU.DebugCallback { Callback = cb, Scanline = sl }; + } + + public void RemoveCallback1() + { + subnes.ppu.NTViewCallback = null; + } + + public void RemoveCallback2() + { + subnes.ppu.PPUViewCallback = null; + } + + #endregion } }