PCE: Revert aa7cee1
. This looks to resolve the following: #1333 #1303 #1287 #1231 #1203 and *maybe* #1266
This commit is contained in:
parent
c64eff6baa
commit
4a2d9dd0f1
|
@ -22,8 +22,6 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
public int BackgroundY;
|
||||
public int RCRCounter;
|
||||
public int ActiveLine;
|
||||
public bool latch_bgy;
|
||||
public int ActiveDisplayStartLine;
|
||||
|
||||
public int HBlankCycles = 79;
|
||||
public bool PerformSpriteLimit;
|
||||
|
@ -33,28 +31,10 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
public void ExecFrame(bool render)
|
||||
{
|
||||
Array.Clear(FrameBuffer, 0, FrameBuffer.Length);
|
||||
if (MultiResHack > 0 && render)
|
||||
Array.Clear(FrameBuffer, 0, FrameBuffer.Length);
|
||||
|
||||
ActiveDisplayStartLine = DisplayStartLine;
|
||||
|
||||
/*
|
||||
Console.Write("VDS: ");
|
||||
Console.Write((Registers[VPR] >> 8));
|
||||
Console.Write(" VSW: ");
|
||||
Console.Write((Registers[VPR] & 0xFF));
|
||||
Console.Write(" VDR: ");
|
||||
Console.Write((Registers[VDW] & 0xFF));
|
||||
Console.Write(" VCR: ");
|
||||
Console.Write((Registers[VCR] & 0xFF));
|
||||
Console.Write(" HDS: ");
|
||||
Console.Write((Registers[HSR] >> 8));
|
||||
Console.Write(" HSW: ");
|
||||
Console.Write((Registers[HSR] & 0xFF));
|
||||
Console.Write(" HDE: ");
|
||||
Console.Write((Registers[HDR] >> 8));
|
||||
Console.Write(" HDW: ");
|
||||
Console.WriteLine((Registers[HDR] & 0xFF));
|
||||
*/
|
||||
int ActiveDisplayStartLine = DisplayStartLine;
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
@ -79,7 +59,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
cpu.Execute(24);
|
||||
cpu.Execute(HBlankCycles);
|
||||
|
||||
if (InActiveDisplay)
|
||||
{
|
||||
|
@ -87,21 +67,10 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
BackgroundY = Registers[BYR];
|
||||
else
|
||||
{
|
||||
if (latch_bgy)
|
||||
{
|
||||
BackgroundY = Registers[BYR];
|
||||
latch_bgy = false;
|
||||
}
|
||||
BackgroundY++;
|
||||
BackgroundY &= 0x01FF;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
cpu.Execute(HBlankCycles - 24);
|
||||
|
||||
if (InActiveDisplay)
|
||||
{
|
||||
if (render) RenderScanLine();
|
||||
}
|
||||
|
||||
|
@ -138,8 +107,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
public void RenderScanLine()
|
||||
{
|
||||
if ((ScanLine >= pce.Settings.Bottom_Line) ||
|
||||
(ScanLine < pce.Settings.Top_Line))
|
||||
if (((ActiveLine + ViewStartLine) >= pce.Settings.Bottom_Line) ||
|
||||
((ActiveLine + ViewStartLine) < pce.Settings.Top_Line))
|
||||
return;
|
||||
|
||||
RenderBackgroundScanline(pce.Settings.ShowBG1);
|
||||
|
@ -157,7 +126,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
int p = vce.Palette[256];
|
||||
fixed (int* FBptr = FrameBuffer)
|
||||
{
|
||||
int* dst = FBptr + (ScanLine - pce.Settings.Top_Line) * FramePitch;
|
||||
int* dst = FBptr + (ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch;
|
||||
for (int i = 0; i < FrameWidth; i++)
|
||||
*dst++ = p;
|
||||
}
|
||||
|
@ -181,7 +150,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
// pointer to the BAT and the framebuffer for this line
|
||||
ushort* BatRow = VRAMptr + yTile * BatWidth;
|
||||
int* dst = FBptr + (ScanLine - pce.Settings.Top_Line) * FramePitch;
|
||||
int* dst = FBptr + (ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch;
|
||||
|
||||
// parameters that change per tile
|
||||
ushort BatEnt;
|
||||
|
@ -235,7 +204,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
if (BackgroundEnabled == false)
|
||||
{
|
||||
for (int i = 0; i < FrameWidth; i++)
|
||||
FrameBuffer[((ScanLine - pce.Settings.Top_Line) * FramePitch) + i] = vce.Palette[256];
|
||||
FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + i] = vce.Palette[256];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -259,10 +228,10 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
byte c = PatternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs];
|
||||
if (c == 0)
|
||||
FrameBuffer[((ScanLine - pce.Settings.Top_Line) * FramePitch) + x] = vce.Palette[0];
|
||||
FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + x] = vce.Palette[0];
|
||||
else
|
||||
{
|
||||
FrameBuffer[((ScanLine - pce.Settings.Top_Line) * FramePitch) + x] = show ? vce.Palette[paletteBase + c] : vce.Palette[0];
|
||||
FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + x] = show ? vce.Palette[paletteBase + c] : vce.Palette[0];
|
||||
PriorityBuffer[x] = 1;
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +363,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
InterSpritePriorityBuffer[xs] = 1;
|
||||
if ((priority || PriorityBuffer[xs] == 0) && show)
|
||||
FrameBuffer[((ScanLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
|
||||
FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -411,7 +380,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
InterSpritePriorityBuffer[xs] = 1;
|
||||
if ((priority || PriorityBuffer[xs] == 0) && show)
|
||||
FrameBuffer[((ScanLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
|
||||
FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -432,7 +401,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
InterSpritePriorityBuffer[xs] = 1;
|
||||
if ((priority || PriorityBuffer[xs] == 0) && show)
|
||||
FrameBuffer[((ScanLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
|
||||
FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
|
||||
}
|
||||
}
|
||||
if (width == 32)
|
||||
|
@ -448,7 +417,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
InterSpritePriorityBuffer[xs] = 1;
|
||||
if ((priority || PriorityBuffer[xs] == 0) && show)
|
||||
FrameBuffer[((ScanLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
|
||||
FrameBuffer[((ActiveLine + ViewStartLine - pce.Settings.Top_Line) * FramePitch) + xs] = vce.Palette[paletteBase + pixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
public int RequestedFrameWidth => ((Registers[HDR] & 0x3F) + 1) * 8;
|
||||
public int RequestedFrameHeight => (Registers[VDW] & 0x1FF) + 1;
|
||||
public int DisplayStartLine => (Registers[VPR] >> 8) + 3 + (Registers[VPR] & 0x1F);
|
||||
public int DisplayStartLine => (Registers[VPR] >> 8) + (Registers[VPR] & 0x1F);
|
||||
public int ViewStartLine => (Registers[VPR] >> 8) + 2;
|
||||
|
||||
private const int MAWR = 0; // Memory Address Write Register
|
||||
private const int MARR = 1; // Memory Address Read Register
|
||||
|
@ -118,8 +119,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
Registers[RegisterLatch] &= 0xFF00;
|
||||
Registers[RegisterLatch] |= value;
|
||||
|
||||
if (RegisterLatch == BYR) { latch_bgy = true; }
|
||||
//BackgroundY = Registers[BYR] & 0x1FF;
|
||||
if (RegisterLatch == BYR)
|
||||
BackgroundY = Registers[BYR] & 0x1FF;
|
||||
|
||||
RegisterCommit(RegisterLatch, msbComplete: false);
|
||||
}
|
||||
|
@ -154,8 +155,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
break;
|
||||
case BYR:
|
||||
Registers[BYR] &= 0x1FF;
|
||||
latch_bgy = true;
|
||||
//BackgroundY = Registers[BYR];
|
||||
BackgroundY = Registers[BYR];
|
||||
break;
|
||||
case HDR: // Horizontal Display Register - update framebuffer size
|
||||
FrameWidth = RequestedFrameWidth;
|
||||
|
|
|
@ -101,7 +101,6 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
const int DCR = 15;
|
||||
|
||||
int EffectivePriorityMode = 0;
|
||||
int ScanLine;
|
||||
|
||||
int FrameHeight;
|
||||
int FrameWidth;
|
||||
|
@ -123,14 +122,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
EffectivePriorityMode = 0;
|
||||
}
|
||||
|
||||
Array.Clear(FrameBuffer, 0, FrameBuffer.Length);
|
||||
|
||||
// Latch frame dimensions and framebuffer, for purely dumb reasons
|
||||
FrameWidth = VDC1.BufferWidth;
|
||||
FrameHeight = VDC1.BufferHeight;
|
||||
FrameBuffer = VDC1.GetVideoBuffer();
|
||||
|
||||
ScanLine = 0;
|
||||
int ScanLine = 0;
|
||||
int ActiveDisplayStartLine = VDC1.DisplayStartLine;
|
||||
|
||||
while (true)
|
||||
|
@ -186,18 +183,6 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
else
|
||||
{
|
||||
if (VDC1.latch_bgy)
|
||||
{
|
||||
VDC1.BackgroundY = VDC2.Registers[BYR];
|
||||
VDC1.latch_bgy = false;
|
||||
}
|
||||
|
||||
if (VDC2.latch_bgy)
|
||||
{
|
||||
VDC2.BackgroundY = VDC2.Registers[BYR];
|
||||
VDC2.latch_bgy = false;
|
||||
}
|
||||
|
||||
VDC1.BackgroundY++;
|
||||
VDC1.BackgroundY &= 0x01FF;
|
||||
VDC2.BackgroundY++;
|
||||
|
@ -260,12 +245,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
private void RenderScanLine()
|
||||
{
|
||||
if ((ScanLine >= PCE.Settings.Bottom_Line) ||
|
||||
(ScanLine < PCE.Settings.Top_Line))
|
||||
if (((VDC1.ActiveLine + VDC1.ViewStartLine) >= PCE.Settings.Bottom_Line) ||
|
||||
((VDC1.ActiveLine + VDC1.ViewStartLine) < PCE.Settings.Top_Line))
|
||||
{
|
||||
return;
|
||||
}
|
||||
InitializeScanLine(ScanLine);
|
||||
InitializeScanLine(VDC1.ActiveLine);
|
||||
|
||||
switch (EffectivePriorityMode)
|
||||
{
|
||||
|
@ -290,7 +275,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
Array.Clear(PriorityBuffer, 0, FrameWidth);
|
||||
// Initialize scanline to background color
|
||||
for (int i = 0; i < FrameWidth; i++)
|
||||
FrameBuffer[((scanline) * FrameWidth) + i] = VCE.Palette[256];
|
||||
FrameBuffer[((scanline + VDC1.ViewStartLine) * FrameWidth) + i] = VCE.Palette[256];
|
||||
}
|
||||
|
||||
private unsafe void RenderBackgroundScanline(VDC vdc, byte priority, bool show)
|
||||
|
@ -314,7 +299,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
// pointer to the BAT and the framebuffer for this line
|
||||
ushort* BatRow = VRAMptr + yTile * vdc.BatWidth;
|
||||
int* dst = FBptr + (ScanLine - PCE.Settings.Top_Line) * FrameWidth;
|
||||
int* dst = FBptr + (vdc.ActiveLine + vdc.ViewStartLine - PCE.Settings.Top_Line) * FrameWidth;
|
||||
|
||||
// parameters that change per tile
|
||||
ushort BatEnt;
|
||||
|
@ -470,7 +455,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
byte myPriority = priority ? highPriority : lowPriority;
|
||||
if (PriorityBuffer[xs] < myPriority)
|
||||
{
|
||||
if (show) FrameBuffer[((ScanLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
|
||||
if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
|
||||
PriorityBuffer[xs] = myPriority;
|
||||
}
|
||||
}
|
||||
|
@ -489,7 +474,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
byte myPriority = priority ? highPriority : lowPriority;
|
||||
if (PriorityBuffer[xs] < myPriority)
|
||||
{
|
||||
if (show) FrameBuffer[((ScanLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
|
||||
if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
|
||||
PriorityBuffer[xs] = myPriority;
|
||||
}
|
||||
}
|
||||
|
@ -511,7 +496,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
byte myPriority = priority ? highPriority : lowPriority;
|
||||
if (PriorityBuffer[xs] < myPriority)
|
||||
{
|
||||
if (show) FrameBuffer[((ScanLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
|
||||
if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
|
||||
PriorityBuffer[xs] = myPriority;
|
||||
}
|
||||
}
|
||||
|
@ -529,7 +514,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
byte myPriority = priority ? highPriority : lowPriority;
|
||||
if (PriorityBuffer[xs] < myPriority)
|
||||
{
|
||||
if (show) FrameBuffer[((ScanLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
|
||||
if (show) FrameBuffer[((vdc.ActiveLine + vdc.ViewStartLine - PCE.Settings.Top_Line) * FrameWidth) + xs] = VCE.Palette[paletteBase + pixel];
|
||||
PriorityBuffer[xs] = myPriority;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue