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.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() { }
}
}
}

View File

@ -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
}
}
}
}
}

View File

@ -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];
}
}
}
}
}
}
}
}

View File

@ -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
}
}
}
}

View File

@ -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

View File

@ -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;

View File

@ -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()