From 2f9a5212bc74ee8dd02abdf1e494865f3065dd66 Mon Sep 17 00:00:00 2001 From: taotao54321 Date: Sun, 11 Mar 2012 16:15:20 +0000 Subject: [PATCH] Added BG/OBJ display settings for SMS (not accessible yet) --- BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs | 4 +- .../Consoles/Sega/SMS/VDP.Mode4.cs | 44 ++++++++--------- .../Consoles/Sega/SMS/VDP.ModeTMS.cs | 48 +++++++++---------- BizHawk.Emulation/Consoles/Sega/SMS/VDP.cs | 34 ++++++------- BizHawk.Emulation/Interfaces/CoreComms.cs | 1 + BizHawk.MultiClient/Config.cs | 4 ++ BizHawk.MultiClient/MainForm.cs | 2 + 7 files changed, 73 insertions(+), 64 deletions(-) diff --git a/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs index 7026d7f9d6..22719ac3ce 100644 --- a/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs @@ -88,7 +88,7 @@ namespace BizHawk.Emulation.Consoles.Sega Cpu.ReadHardware = ReadPort; Cpu.WriteHardware = WritePort; - Vdp = new VDP(Cpu, IsGameGear ? VdpMode.GameGear : VdpMode.SMS, DisplayType); + Vdp = new VDP(this, Cpu, IsGameGear ? VdpMode.GameGear : VdpMode.SMS, DisplayType); PSG = new SN76489(); YM2413 = new YM2413(); SoundMixer = new SoundMixer(YM2413, PSG); @@ -378,4 +378,4 @@ namespace BizHawk.Emulation.Consoles.Sega public void Dispose() { } } -} \ No newline at end of file +} diff --git a/BizHawk.Emulation/Consoles/Sega/SMS/VDP.Mode4.cs b/BizHawk.Emulation/Consoles/Sega/SMS/VDP.Mode4.cs index b920994c2b..b5d3adfcd5 100644 --- a/BizHawk.Emulation/Consoles/Sega/SMS/VDP.Mode4.cs +++ b/BizHawk.Emulation/Consoles/Sega/SMS/VDP.Mode4.cs @@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Consoles.Sega { public partial class VDP { - internal void RenderBackgroundCurrentLine() + internal void RenderBackgroundCurrentLine(bool show) { if (DisplayOn == false) { @@ -58,14 +58,14 @@ namespace BizHawk.Emulation.Consoles.Sega if (HFlip == false) { - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 0] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 1] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 2] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 3] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 4] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 5] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 6] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 7] + PaletteBase]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 0] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 1] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 2] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 3] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 4] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 5] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 6] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 7] + PaletteBase] : Palette[BackdropColor]; if (Priority) { @@ -80,14 +80,14 @@ namespace BizHawk.Emulation.Consoles.Sega } else // Flipped Horizontally { - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 7] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 6] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 5] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 4] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 3] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 2] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 1] + PaletteBase]; - FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 0] + PaletteBase]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 7] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 6] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 5] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 4] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 3] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 2] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 1] + PaletteBase] : Palette[BackdropColor]; + FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 0] + PaletteBase] : Palette[BackdropColor]; if (Priority) { @@ -103,7 +103,7 @@ namespace BizHawk.Emulation.Consoles.Sega } } - internal void RenderSpritesCurrentLine() + internal void RenderSpritesCurrentLine(bool show) { if (DisplayOn == false) return; int SpriteBase = SpriteAttributeTableBase; @@ -149,7 +149,7 @@ namespace BizHawk.Emulation.Consoles.Sega StatusByte |= 0x20; // Set Collision bit else if (ScanlinePriorityBuffer[x + xs] == 0) { - FrameBuffer[(ys + y) * 256 + x + xs] = Palette[(color + 16)]; + if (show) FrameBuffer[(ys + y) * 256 + x + xs] = Palette[(color + 16)]; SpriteCollisionBuffer[x + xs] = 1; } } @@ -158,7 +158,7 @@ namespace BizHawk.Emulation.Consoles.Sega } } - internal void RenderSpritesCurrentLineDoubleSize() + internal void RenderSpritesCurrentLineDoubleSize(bool show) { if (DisplayOn == false) return; int SpriteBase = SpriteAttributeTableBase; @@ -204,7 +204,7 @@ namespace BizHawk.Emulation.Consoles.Sega StatusByte |= 0x20; // Set Collision bit else { - FrameBuffer[(ys + y) * 256 + x + xs] = Palette[(color + 16)]; + if (show) FrameBuffer[(ys + y) * 256 + x + xs] = Palette[(color + 16)]; SpriteCollisionBuffer[x + xs] = 1; } } @@ -296,4 +296,4 @@ namespace BizHawk.Emulation.Consoles.Sega } } } -} \ No newline at end of file +} diff --git a/BizHawk.Emulation/Consoles/Sega/SMS/VDP.ModeTMS.cs b/BizHawk.Emulation/Consoles/Sega/SMS/VDP.ModeTMS.cs index ae58f7588f..5b2619705e 100644 --- a/BizHawk.Emulation/Consoles/Sega/SMS/VDP.ModeTMS.cs +++ b/BizHawk.Emulation/Consoles/Sega/SMS/VDP.ModeTMS.cs @@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Consoles.Sega unchecked((int)0xFFFFFFFF) }; - void RenderBackgroundM0() + void RenderBackgroundM0(bool show) { if (DisplayOn == false) { @@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Consoles.Sega int FrameBufferOffset = ScanLine*256; int PatternNameOffset = TmsPatternNameTableBase + (yc*32); int ScreenBGColor = PaletteTMS9918[Registers[7] & 0x0F]; - + for (int xc=0; xc<32; xc++) { int pn = VRAM[PatternNameOffset++]; @@ -49,19 +49,19 @@ namespace BizHawk.Emulation.Consoles.Sega int bgIndex = colorEntry & 0x0F; int fgColor = fgIndex == 0 ? ScreenBGColor : PaletteTMS9918[fgIndex]; int bgColor = bgIndex == 0 ? ScreenBGColor : PaletteTMS9918[bgIndex]; - - FrameBuffer[FrameBufferOffset++] = ((pv & 0x80) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x40) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x20) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x10) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x08) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x04) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x02) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x01) > 0) ? fgColor : bgColor; + + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x80) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x40) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x20) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x10) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x08) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x04) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x02) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x01) > 0) ? fgColor : bgColor) : 0; } } - void RenderBackgroundM2() + void RenderBackgroundM2(bool show) { if (DisplayOn == false) { @@ -86,19 +86,19 @@ namespace BizHawk.Emulation.Consoles.Sega int bgIndex = colorEntry & 0x0F; int fgColor = fgIndex == 0 ? ScreenBGColor : PaletteTMS9918[fgIndex]; int bgColor = bgIndex == 0 ? ScreenBGColor : PaletteTMS9918[bgIndex]; - - FrameBuffer[FrameBufferOffset++] = ((pv & 0x80) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x40) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x20) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x10) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x08) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x04) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x02) > 0) ? fgColor : bgColor; - FrameBuffer[FrameBufferOffset++] = ((pv & 0x01) > 0) ? fgColor : bgColor; + + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x80) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x40) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x20) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x10) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x08) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x04) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x02) > 0) ? fgColor : bgColor) : 0; + FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x01) > 0) ? fgColor : bgColor) : 0; } } - void RenderTmsSprites() + void RenderTmsSprites(bool show) { if (DisplayOn == false) return; @@ -153,11 +153,11 @@ namespace BizHawk.Emulation.Consoles.Sega if (Color != 0 && ScanlinePriorityBuffer[x+xp] == 0) { ScanlinePriorityBuffer[x + xp] = 1; - FrameBuffer[(ScanLine*256) + x + xp] = PaletteTMS9918[Color & 0x0F]; + if (show) FrameBuffer[(ScanLine*256) + x + xp] = PaletteTMS9918[Color & 0x0F]; } } } } } } -} \ No newline at end of file +} diff --git a/BizHawk.Emulation/Consoles/Sega/SMS/VDP.cs b/BizHawk.Emulation/Consoles/Sega/SMS/VDP.cs index 471cdd317d..00e9e834a2 100644 --- a/BizHawk.Emulation/Consoles/Sega/SMS/VDP.cs +++ b/BizHawk.Emulation/Consoles/Sega/SMS/VDP.cs @@ -26,6 +26,7 @@ namespace BizHawk.Emulation.Consoles.Sega bool VIntPending; bool HIntPending; + SMS Sms; VdpMode mode; DisplayType DisplayType = DisplayType.NTSC; Z80A Cpu; @@ -73,8 +74,9 @@ namespace BizHawk.Emulation.Consoles.Sega static readonly byte[] SMSPalXlatTable = { 0, 85, 170, 255 }; static readonly byte[] GGPalXlatTable = { 0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255 }; - public VDP(Z80A cpu, VdpMode mode, DisplayType displayType) + public VDP(SMS sms, Z80A cpu, VdpMode mode, DisplayType displayType) { + Sms = sms; Cpu = cpu; this.mode = mode; if (mode == VdpMode.SMS) CRAM = new byte[32]; @@ -370,28 +372,28 @@ namespace BizHawk.Emulation.Consoles.Sega return; } - RenderBackgroundCurrentLine(); + RenderBackgroundCurrentLine(Sms.CoreInputComm.SMS_ShowBG); if (EnableDoubledSprites) - RenderSpritesCurrentLineDoubleSize(); + RenderSpritesCurrentLineDoubleSize(Sms.CoreInputComm.SMS_ShowOBJ); else - RenderSpritesCurrentLine(); + RenderSpritesCurrentLine(Sms.CoreInputComm.SMS_ShowOBJ); } - else if (TmsMode == 2) - { - if (render == false) - return; - - RenderBackgroundM2(); - RenderTmsSprites(); - } - else if (TmsMode == 0) + else if (TmsMode == 2) { if (render == false) return; - RenderBackgroundM0(); - RenderTmsSprites(); + RenderBackgroundM2(Sms.CoreInputComm.SMS_ShowBG); + RenderTmsSprites(Sms.CoreInputComm.SMS_ShowOBJ); + } + else if (TmsMode == 0) + { + if (render == false) + return; + + RenderBackgroundM0(Sms.CoreInputComm.SMS_ShowBG); + RenderTmsSprites(Sms.CoreInputComm.SMS_ShowOBJ); } } @@ -515,4 +517,4 @@ namespace BizHawk.Emulation.Consoles.Sega CramWrite } } -} \ No newline at end of file +} diff --git a/BizHawk.Emulation/Interfaces/CoreComms.cs b/BizHawk.Emulation/Interfaces/CoreComms.cs index bb563c4948..a043535428 100644 --- a/BizHawk.Emulation/Interfaces/CoreComms.cs +++ b/BizHawk.Emulation/Interfaces/CoreComms.cs @@ -6,6 +6,7 @@ public bool NES_UnlimitedSprites; public bool NES_ShowBG, NES_ShowOBJ; public bool PCE_ShowBG1, PCE_ShowOBJ1, PCE_ShowBG2, PCE_ShowOBJ2; + public bool SMS_ShowBG, SMS_ShowOBJ; } public class CoreOutputComm diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs index 0c1c8fb0ce..0612086063 100644 --- a/BizHawk.MultiClient/Config.cs +++ b/BizHawk.MultiClient/Config.cs @@ -302,6 +302,10 @@ public bool PCEDispBG2 = true; public bool PCEDispOBJ2= true; + // SMS Graphics settings + public bool SMSDispBG = true; + public bool SMSDispOBJ = true; + //GB Debugger settings public bool AutoloadGBDebugger = false; public bool GBDebuggerSaveWindowPosition = true; diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index f53d3b1658..67f8472673 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -256,6 +256,8 @@ namespace BizHawk.MultiClient Global.CoreInputComm.PCE_ShowOBJ1 = Global.Config.PCEDispOBJ1; Global.CoreInputComm.PCE_ShowBG2 = Global.Config.PCEDispBG2; Global.CoreInputComm.PCE_ShowOBJ2 = Global.Config.PCEDispOBJ2; + Global.CoreInputComm.SMS_ShowBG = Global.Config.SMSDispBG; + Global.CoreInputComm.SMS_ShowOBJ = Global.Config.SMSDispOBJ; } void SyncPresentationMode()