Added BG/OBJ display settings for SMS (not accessible yet)

This commit is contained in:
taotao54321 2012-03-11 16:15:20 +00:00
parent 62f80406c4
commit 2f9a5212bc
7 changed files with 73 additions and 64 deletions

View File

@ -88,7 +88,7 @@ namespace BizHawk.Emulation.Consoles.Sega
Cpu.ReadHardware = ReadPort; Cpu.ReadHardware = ReadPort;
Cpu.WriteHardware = WritePort; 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(); PSG = new SN76489();
YM2413 = new YM2413(); YM2413 = new YM2413();
SoundMixer = new SoundMixer(YM2413, PSG); SoundMixer = new SoundMixer(YM2413, PSG);

View File

@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Consoles.Sega
{ {
public partial class VDP public partial class VDP
{ {
internal void RenderBackgroundCurrentLine() internal void RenderBackgroundCurrentLine(bool show)
{ {
if (DisplayOn == false) if (DisplayOn == false)
{ {
@ -58,14 +58,14 @@ namespace BizHawk.Emulation.Consoles.Sega
if (HFlip == false) if (HFlip == false)
{ {
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 0] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 0] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 1] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 1] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 2] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 2] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 3] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 3] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 4] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 4] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 5] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 5] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 6] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 6] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 7] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 7] + PaletteBase] : Palette[BackdropColor];
if (Priority) if (Priority)
{ {
@ -80,14 +80,14 @@ namespace BizHawk.Emulation.Consoles.Sega
} }
else // Flipped Horizontally else // Flipped Horizontally
{ {
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 7] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 7] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 6] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 6] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 5] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 5] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 4] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 4] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 3] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 3] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 2] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 2] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 1] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 1] + PaletteBase] : Palette[BackdropColor];
FrameBuffer[(ScanLine * 256) + horzOffset++] = Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 0] + PaletteBase]; FrameBuffer[(ScanLine * 256) + horzOffset++] = show ? Palette[PatternBuffer[(tileNo * 64) + (yOfs * 8) + 0] + PaletteBase] : Palette[BackdropColor];
if (Priority) if (Priority)
{ {
@ -103,7 +103,7 @@ namespace BizHawk.Emulation.Consoles.Sega
} }
} }
internal void RenderSpritesCurrentLine() internal void RenderSpritesCurrentLine(bool show)
{ {
if (DisplayOn == false) return; if (DisplayOn == false) return;
int SpriteBase = SpriteAttributeTableBase; int SpriteBase = SpriteAttributeTableBase;
@ -149,7 +149,7 @@ namespace BizHawk.Emulation.Consoles.Sega
StatusByte |= 0x20; // Set Collision bit StatusByte |= 0x20; // Set Collision bit
else if (ScanlinePriorityBuffer[x + xs] == 0) 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; 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; if (DisplayOn == false) return;
int SpriteBase = SpriteAttributeTableBase; int SpriteBase = SpriteAttributeTableBase;
@ -204,7 +204,7 @@ namespace BizHawk.Emulation.Consoles.Sega
StatusByte |= 0x20; // Set Collision bit StatusByte |= 0x20; // Set Collision bit
else 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; SpriteCollisionBuffer[x + xs] = 1;
} }
} }

View File

@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Consoles.Sega
unchecked((int)0xFFFFFFFF) unchecked((int)0xFFFFFFFF)
}; };
void RenderBackgroundM0() void RenderBackgroundM0(bool show)
{ {
if (DisplayOn == false) if (DisplayOn == false)
{ {
@ -50,18 +50,18 @@ namespace BizHawk.Emulation.Consoles.Sega
int fgColor = fgIndex == 0 ? ScreenBGColor : PaletteTMS9918[fgIndex]; int fgColor = fgIndex == 0 ? ScreenBGColor : PaletteTMS9918[fgIndex];
int bgColor = bgIndex == 0 ? ScreenBGColor : PaletteTMS9918[bgIndex]; int bgColor = bgIndex == 0 ? ScreenBGColor : PaletteTMS9918[bgIndex];
FrameBuffer[FrameBufferOffset++] = ((pv & 0x80) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x80) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x40) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x40) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x20) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x20) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x10) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x10) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x08) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x08) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x04) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x04) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x02) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x02) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x01) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x01) > 0) ? fgColor : bgColor) : 0;
} }
} }
void RenderBackgroundM2() void RenderBackgroundM2(bool show)
{ {
if (DisplayOn == false) if (DisplayOn == false)
{ {
@ -87,18 +87,18 @@ namespace BizHawk.Emulation.Consoles.Sega
int fgColor = fgIndex == 0 ? ScreenBGColor : PaletteTMS9918[fgIndex]; int fgColor = fgIndex == 0 ? ScreenBGColor : PaletteTMS9918[fgIndex];
int bgColor = bgIndex == 0 ? ScreenBGColor : PaletteTMS9918[bgIndex]; int bgColor = bgIndex == 0 ? ScreenBGColor : PaletteTMS9918[bgIndex];
FrameBuffer[FrameBufferOffset++] = ((pv & 0x80) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x80) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x40) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x40) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x20) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x20) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x10) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x10) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x08) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x08) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x04) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x04) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x02) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x02) > 0) ? fgColor : bgColor) : 0;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x01) > 0) ? fgColor : bgColor; FrameBuffer[FrameBufferOffset++] = show ? (((pv & 0x01) > 0) ? fgColor : bgColor) : 0;
} }
} }
void RenderTmsSprites() void RenderTmsSprites(bool show)
{ {
if (DisplayOn == false) return; if (DisplayOn == false) return;
@ -153,7 +153,7 @@ namespace BizHawk.Emulation.Consoles.Sega
if (Color != 0 && ScanlinePriorityBuffer[x+xp] == 0) if (Color != 0 && ScanlinePriorityBuffer[x+xp] == 0)
{ {
ScanlinePriorityBuffer[x + xp] = 1; ScanlinePriorityBuffer[x + xp] = 1;
FrameBuffer[(ScanLine*256) + x + xp] = PaletteTMS9918[Color & 0x0F]; if (show) FrameBuffer[(ScanLine*256) + x + xp] = PaletteTMS9918[Color & 0x0F];
} }
} }
} }

View File

@ -26,6 +26,7 @@ namespace BizHawk.Emulation.Consoles.Sega
bool VIntPending; bool VIntPending;
bool HIntPending; bool HIntPending;
SMS Sms;
VdpMode mode; VdpMode mode;
DisplayType DisplayType = DisplayType.NTSC; DisplayType DisplayType = DisplayType.NTSC;
Z80A Cpu; Z80A Cpu;
@ -73,8 +74,9 @@ namespace BizHawk.Emulation.Consoles.Sega
static readonly byte[] SMSPalXlatTable = { 0, 85, 170, 255 }; 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 }; 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; Cpu = cpu;
this.mode = mode; this.mode = mode;
if (mode == VdpMode.SMS) CRAM = new byte[32]; if (mode == VdpMode.SMS) CRAM = new byte[32];
@ -370,28 +372,28 @@ namespace BizHawk.Emulation.Consoles.Sega
return; return;
} }
RenderBackgroundCurrentLine(); RenderBackgroundCurrentLine(Sms.CoreInputComm.SMS_ShowBG);
if (EnableDoubledSprites) if (EnableDoubledSprites)
RenderSpritesCurrentLineDoubleSize(); RenderSpritesCurrentLineDoubleSize(Sms.CoreInputComm.SMS_ShowOBJ);
else else
RenderSpritesCurrentLine(); RenderSpritesCurrentLine(Sms.CoreInputComm.SMS_ShowOBJ);
} }
else if (TmsMode == 2) else if (TmsMode == 2)
{ {
if (render == false) if (render == false)
return; return;
RenderBackgroundM2(); RenderBackgroundM2(Sms.CoreInputComm.SMS_ShowBG);
RenderTmsSprites(); RenderTmsSprites(Sms.CoreInputComm.SMS_ShowOBJ);
} }
else if (TmsMode == 0) else if (TmsMode == 0)
{ {
if (render == false) if (render == false)
return; return;
RenderBackgroundM0(); RenderBackgroundM0(Sms.CoreInputComm.SMS_ShowBG);
RenderTmsSprites(); RenderTmsSprites(Sms.CoreInputComm.SMS_ShowOBJ);
} }
} }

View File

@ -6,6 +6,7 @@
public bool NES_UnlimitedSprites; public bool NES_UnlimitedSprites;
public bool NES_ShowBG, NES_ShowOBJ; public bool NES_ShowBG, NES_ShowOBJ;
public bool PCE_ShowBG1, PCE_ShowOBJ1, PCE_ShowBG2, PCE_ShowOBJ2; public bool PCE_ShowBG1, PCE_ShowOBJ1, PCE_ShowBG2, PCE_ShowOBJ2;
public bool SMS_ShowBG, SMS_ShowOBJ;
} }
public class CoreOutputComm public class CoreOutputComm

View File

@ -302,6 +302,10 @@
public bool PCEDispBG2 = true; public bool PCEDispBG2 = true;
public bool PCEDispOBJ2= true; public bool PCEDispOBJ2= true;
// SMS Graphics settings
public bool SMSDispBG = true;
public bool SMSDispOBJ = true;
//GB Debugger settings //GB Debugger settings
public bool AutoloadGBDebugger = false; public bool AutoloadGBDebugger = false;
public bool GBDebuggerSaveWindowPosition = true; public bool GBDebuggerSaveWindowPosition = true;

View File

@ -256,6 +256,8 @@ namespace BizHawk.MultiClient
Global.CoreInputComm.PCE_ShowOBJ1 = Global.Config.PCEDispOBJ1; Global.CoreInputComm.PCE_ShowOBJ1 = Global.Config.PCEDispOBJ1;
Global.CoreInputComm.PCE_ShowBG2 = Global.Config.PCEDispBG2; Global.CoreInputComm.PCE_ShowBG2 = Global.Config.PCEDispBG2;
Global.CoreInputComm.PCE_ShowOBJ2 = Global.Config.PCEDispOBJ2; Global.CoreInputComm.PCE_ShowOBJ2 = Global.Config.PCEDispOBJ2;
Global.CoreInputComm.SMS_ShowBG = Global.Config.SMSDispBG;
Global.CoreInputComm.SMS_ShowOBJ = Global.Config.SMSDispOBJ;
} }
void SyncPresentationMode() void SyncPresentationMode()