PCE: improve video timing... slightly

This commit is contained in:
beirich 2011-02-01 05:25:28 +00:00
parent 27da793b5f
commit 78c7a74a0d
3 changed files with 25 additions and 4 deletions

View File

@ -258,7 +258,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
public byte[] SaveStateBinary()
{
var buf = new byte[SuperGrafx ? 166550 : 75852];
var buf = new byte[SuperGrafx ? 166551 : 75853];
var stream = new MemoryStream(buf);
var writer = new BinaryWriter(stream);
SaveStateBinary(writer);

View File

@ -10,6 +10,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
public ushort VceAddress;
public ushort[] VceData = new ushort[512];
public int[] Palette = new int[512];
public byte DotClock;
public void WriteVCE(int port, byte value)
{
@ -17,6 +18,9 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
switch (port)
{
case 0: // Control Port. Doesn't control anything we care about...
DotClock = (byte) (value & 3);
if (DotClock == 3)
DotClock = 2;
break;
case 2: // Address LSB
VceAddress &= 0xFF00;
@ -72,6 +76,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
{
writer.WriteLine("[VCE]");
writer.WriteLine("VceAddress {0:X4}", VceAddress);
writer.WriteLine("DotClock {0}", DotClock);
writer.Write("VceData ");
VceData.SaveAsHex(writer);
writer.WriteLine("[/VCE]\n");
@ -86,6 +91,8 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
if (args[0] == "[/VCE]") break;
if (args[0] == "VceAddress")
VceAddress = ushort.Parse(args[1], NumberStyles.HexNumber);
else if (args[0] == "DotClock")
DotClock = byte.Parse(args[1]);
else if (args[0] == "VceData")
VceData.ReadFromHex(args[1]);
else
@ -99,6 +106,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
public void SaveStateBinary(BinaryWriter writer)
{
writer.Write(VceAddress);
writer.Write(DotClock);
for (int i = 0; i < VceData.Length; i++)
writer.Write(VceData[i]);
}
@ -106,6 +114,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
public void LoadStateBinary(BinaryReader reader)
{
VceAddress = reader.ReadUInt16();
DotClock = reader.ReadByte();
for (int i = 0; i < VceData.Length; i++)
{
VceData[i] = reader.ReadUInt16();

View File

@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
register at certain sync points and incremented every scanline.
Its values range from 0 - $1FF.
+ RCRCount is the current offset into the RCR register. It is reset to $40
on the first active display line of, and incremented every line. Its effective
on the first active display line, and incremented every line. Its effective
range is $40 - $146.
*/
@ -40,6 +40,18 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
ActiveLine = 0 - latchedDisplayStartLine;
ScanLine = 0;
int HDS = (Registers[HSR] >> 8) & 0x7F;
int HDE = (Registers[HDR] >> 8) & 0x7F;
int hblankCycles = (HDS + HDE + 2) * 8;
//hblankCycles -= 2;
switch (vce.DotClock)
{
case 0: hblankCycles = (hblankCycles * 4) / 3; break;
case 1: break;
case 2: hblankCycles = (hblankCycles*2)/3; break;
}
for (; ScanLine < 262;)
{
//Log.Note("VDC","ScanLine {0} (ActiveLine {1}, RCR {2}, BGY {3})",ScanLine, ActiveLine, RCRCount, BackgroundY);
@ -69,12 +81,12 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
StatusByte |= StatusVerticalBlanking;
cpu.IRQ1Assert = true;
}
cpu.Execute(82);
cpu.Execute(hblankCycles);
if (InActiveDisplay && render)
RenderScanLine();
cpu.Execute(373);
cpu.Execute(455-hblankCycles);
ScanLine++;
ActiveLine++;