PCE-CD states are now stable
This commit is contained in:
parent
3e8a7e61c2
commit
7eb2eb0071
|
@ -264,8 +264,6 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
|
||||
public bool SaveRamModified { get; set; }
|
||||
|
||||
// TODO: properly savestate SCSI
|
||||
|
||||
public void SaveStateText(TextWriter writer)
|
||||
{
|
||||
writer.WriteLine("[PCEngine]");
|
||||
|
@ -281,6 +279,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
if (Cpu.ReadMemory21 == ReadMemorySF2)
|
||||
writer.WriteLine("SF2MapperLatch " + SF2MapperLatch);
|
||||
writer.WriteLine("IOBuffer {0:X2}", IOBuffer);
|
||||
writer.Write("CdIoPorts "); CdIoPorts.SaveAsHex(writer);
|
||||
writer.WriteLine();
|
||||
|
||||
if (SuperGrafx)
|
||||
|
@ -301,16 +300,13 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
}
|
||||
if (TurboCD)
|
||||
{
|
||||
CDAudio.SaveStateText(writer);
|
||||
writer.Write("CDRAM ");
|
||||
CDRam.SaveAsHex(writer);
|
||||
writer.Write("CDRAM "); CDRam.SaveAsHex(writer);
|
||||
if (SuperRam != null)
|
||||
{
|
||||
writer.Write("SuperRAM ");
|
||||
SuperRam.SaveAsHex(writer);
|
||||
}
|
||||
{ writer.Write("SuperRAM "); SuperRam.SaveAsHex(writer); }
|
||||
|
||||
writer.WriteLine();
|
||||
SCSI.SaveStateText(writer);
|
||||
CDAudio.SaveStateText(writer);
|
||||
ADPCM.SaveStateText(writer);
|
||||
}
|
||||
writer.WriteLine("[/PCEngine]");
|
||||
|
@ -332,6 +328,8 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
SF2MapperLatch = byte.Parse(args[1]);
|
||||
else if (args[0] == "IOBuffer")
|
||||
IOBuffer = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "CdIoPorts")
|
||||
CdIoPorts.ReadFromHex(args[1]);
|
||||
else if (args[0] == "RAM")
|
||||
Ram.ReadFromHex(args[1]);
|
||||
else if (args[0] == "CDRAM")
|
||||
|
@ -352,6 +350,8 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
VDC1.LoadStateText(reader, 1);
|
||||
else if (args[0] == "[VDC2]")
|
||||
VDC2.LoadStateText(reader, 2);
|
||||
else if (args[0] == "[SCSI]")
|
||||
SCSI.LoadStateText(reader);
|
||||
else if (args[0] == "[CDAudio]")
|
||||
CDAudio.LoadStateText(reader);
|
||||
else if (args[0] == "[ADPCM]")
|
||||
|
@ -378,6 +378,8 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
{
|
||||
writer.Write(CDRam);
|
||||
ADPCM.SaveStateBinary(writer);
|
||||
CDAudio.SaveStateBinary(writer);
|
||||
SCSI.SaveStateBinary(writer);
|
||||
}
|
||||
writer.Write(Frame);
|
||||
writer.Write(_lagcount);
|
||||
|
@ -387,10 +389,6 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
VCE.SaveStateBinary(writer);
|
||||
VDC1.SaveStateBinary(writer);
|
||||
PSG.SaveStateBinary(writer);
|
||||
if (TurboCD)
|
||||
{
|
||||
CDAudio.SaveStateBinary(writer);
|
||||
}
|
||||
} else {
|
||||
writer.Write(Ram);
|
||||
writer.Write(Frame);
|
||||
|
@ -421,6 +419,8 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
{
|
||||
CDRam = reader.ReadBytes(0x10000);
|
||||
ADPCM.LoadStateBinary(reader);
|
||||
CDAudio.LoadStateBinary(reader);
|
||||
SCSI.LoadStateBinary(reader);
|
||||
}
|
||||
Frame = reader.ReadInt32();
|
||||
_lagcount = reader.ReadInt32();
|
||||
|
@ -430,10 +430,6 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
VCE.LoadStateBinary(reader);
|
||||
VDC1.LoadStateBinary(reader);
|
||||
PSG.LoadStateBinary(reader);
|
||||
if (TurboCD)
|
||||
{
|
||||
CDAudio.LoadStateBinary(reader);
|
||||
}
|
||||
} else {
|
||||
Ram = reader.ReadBytes(0x8000);
|
||||
Frame = reader.ReadInt32();
|
||||
|
@ -455,10 +451,10 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
if (BramEnabled) buflen += 2048;
|
||||
if (PopulousRAM != null) buflen += 0x8000;
|
||||
if (SuperRam != null) buflen += 0x30000;
|
||||
if (TurboCD) buflen += 0x20000 + 62;
|
||||
if (TurboCD) buflen += 0x20000 + 2165;
|
||||
//Console.WriteLine("LENGTH1 " + buflen);
|
||||
|
||||
var buf = new byte[buflen];
|
||||
var buf = new byte[buflen];
|
||||
var stream = new MemoryStream(buf);
|
||||
var writer = new BinaryWriter(stream);
|
||||
SaveStateBinary(writer);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using BizHawk.DiscSystem;
|
||||
using BizHawk.Emulation.Sound;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
||||
{
|
||||
|
@ -144,6 +146,8 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
|
||||
PCEngine pce;
|
||||
public Disc disc;
|
||||
int audioStartLBA;
|
||||
int audioEndLBA;
|
||||
|
||||
public ScsiCDBus(PCEngine pce, Disc disc)
|
||||
{
|
||||
|
@ -394,9 +398,6 @@ throw new Exception("requesting 0 sectors read.............................");
|
|||
pce.CDAudio.Stop();
|
||||
}
|
||||
|
||||
int audioStartLBA;
|
||||
int audioEndLBA;
|
||||
|
||||
void CommandAudioStartPos()
|
||||
{
|
||||
switch (CommandBuffer[9] & 0xC0)
|
||||
|
@ -500,7 +501,7 @@ throw new Exception("requesting 0 sectors read.............................");
|
|||
case CDAudio.CDAudioMode.Stopped: DataIn.Enqueue(3); break;
|
||||
}
|
||||
|
||||
DataIn.Enqueue(sectorEntry.q_status); // unused?
|
||||
DataIn.Enqueue(sectorEntry.q_status); // I do not know what status is
|
||||
DataIn.Enqueue(sectorEntry.q_tno.BCDValue); // track
|
||||
DataIn.Enqueue(sectorEntry.q_index.BCDValue); // index
|
||||
DataIn.Enqueue(sectorEntry.q_min.BCDValue); // M(rel)
|
||||
|
@ -547,7 +548,6 @@ throw new Exception("requesting 0 sectors read.............................");
|
|||
track--;
|
||||
if (track > disc.TOC.Sessions[0].Tracks.Count)
|
||||
throw new Exception("Request more tracks than exist.... need to do error handling");
|
||||
// I error handled your mom last night
|
||||
|
||||
int lbaPos = disc.TOC.Sessions[0].Tracks[track].Indexes[1].aba - 150;
|
||||
byte m, s, f;
|
||||
|
@ -641,5 +641,195 @@ throw new Exception("requesting 0 sectors read.............................");
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
public void SaveStateBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(BSY);
|
||||
writer.Write(SEL);
|
||||
writer.Write(CD);
|
||||
writer.Write(IO);
|
||||
writer.Write(MSG);
|
||||
writer.Write(REQ);
|
||||
writer.Write(ACK);
|
||||
writer.Write(ATN);
|
||||
writer.Write(RST);
|
||||
writer.Write(DataBits);
|
||||
writer.Write((byte)Phase);
|
||||
|
||||
writer.Write(MessageCompleted);
|
||||
writer.Write(StatusCompleted);
|
||||
writer.Write(MessageValue);
|
||||
|
||||
writer.Write(DataReadWaitTimer);
|
||||
writer.Write(DataReadInProgress);
|
||||
writer.Write(DataTransferWasDone);
|
||||
writer.Write(DataTransferInProgress);
|
||||
writer.Write(CurrentReadingSector);
|
||||
writer.Write((byte)SectorsLeftToRead);
|
||||
|
||||
writer.Write(CommandBuffer.buffer);
|
||||
writer.Write((byte)CommandBuffer.Position);
|
||||
|
||||
writer.Write(DataIn.buffer);
|
||||
writer.Write((short)DataIn.head);
|
||||
writer.Write((short)DataIn.tail);
|
||||
writer.Write((short)DataIn.size);
|
||||
|
||||
writer.Write(audioStartLBA);
|
||||
writer.Write(audioEndLBA);
|
||||
}
|
||||
|
||||
public void LoadStateBinary(BinaryReader reader)
|
||||
{
|
||||
BSY = reader.ReadBoolean();
|
||||
SEL = reader.ReadBoolean();
|
||||
CD = reader.ReadBoolean();
|
||||
IO = reader.ReadBoolean();
|
||||
MSG = reader.ReadBoolean();
|
||||
REQ = reader.ReadBoolean();
|
||||
ACK = reader.ReadBoolean();
|
||||
ATN = reader.ReadBoolean();
|
||||
RST = reader.ReadBoolean();
|
||||
DataBits = reader.ReadByte();
|
||||
Phase = (BusPhase) Enum.ToObject(typeof(BusPhase), reader.ReadByte());
|
||||
|
||||
MessageCompleted = reader.ReadBoolean();
|
||||
StatusCompleted = reader.ReadBoolean();
|
||||
MessageValue = reader.ReadByte();
|
||||
|
||||
DataReadWaitTimer = reader.ReadInt64();
|
||||
DataReadInProgress = reader.ReadBoolean();
|
||||
DataTransferWasDone = reader.ReadBoolean();
|
||||
DataTransferInProgress = reader.ReadBoolean();
|
||||
CurrentReadingSector = reader.ReadInt32();
|
||||
SectorsLeftToRead = reader.ReadByte();
|
||||
|
||||
CommandBuffer.buffer = reader.ReadBytes(10);
|
||||
CommandBuffer.Position = reader.ReadByte();
|
||||
|
||||
DataIn.buffer = reader.ReadBytes(2048);
|
||||
DataIn.head = reader.ReadInt16();
|
||||
DataIn.tail = reader.ReadInt16();
|
||||
DataIn.size = reader.ReadInt16();
|
||||
|
||||
audioStartLBA = reader.ReadInt32();
|
||||
audioEndLBA = reader.ReadInt32();
|
||||
}
|
||||
|
||||
public void SaveStateText(TextWriter writer)
|
||||
{
|
||||
writer.WriteLine("[SCSI]");
|
||||
writer.WriteLine("BSY {0}",BSY);
|
||||
writer.WriteLine("SEL {0}", SEL);
|
||||
writer.WriteLine("CD {0}", CD);
|
||||
writer.WriteLine("IO {0}", IO);
|
||||
writer.WriteLine("MSG {0}", MSG);
|
||||
writer.WriteLine("REQ {0}", REQ);
|
||||
writer.WriteLine("ACK {0}", ACK);
|
||||
writer.WriteLine("ATN {0}", ATN);
|
||||
writer.WriteLine("RST {0}", RST);
|
||||
writer.WriteLine("DataBits {0:X2}", DataBits);
|
||||
writer.WriteLine("BusPhase "+Enum.GetName(typeof(BusPhase), Phase));
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("MessageCompleted {0}", MessageCompleted);
|
||||
writer.WriteLine("StatusCompleted {0}", StatusCompleted);
|
||||
writer.WriteLine("MessageValue {0}", MessageValue);
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("DataReadWaitTimer {0}", DataReadWaitTimer);
|
||||
writer.WriteLine("DataReadInProgress {0}", DataReadInProgress);
|
||||
writer.WriteLine("DataTransferWasDone {0}", DataTransferWasDone);
|
||||
writer.WriteLine("DataTransferInProgress {0}", DataTransferInProgress);
|
||||
writer.WriteLine("CurrentReadingSector {0}", CurrentReadingSector);
|
||||
writer.WriteLine("SectorsLeftToRead {0}", SectorsLeftToRead);
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("AudioStartLBA {0}", audioStartLBA);
|
||||
writer.WriteLine("AudioEndLBA {0}", audioEndLBA);
|
||||
writer.WriteLine();
|
||||
writer.Write("CommandBuffer "); CommandBuffer.buffer.SaveAsHex(writer);
|
||||
writer.WriteLine("CommandBufferPosition {0}", CommandBuffer.Position);
|
||||
writer.WriteLine();
|
||||
writer.Write("DataInBuffer "); DataIn.buffer.SaveAsHex(writer);
|
||||
writer.WriteLine("DataInHead {0}", DataIn.head);
|
||||
writer.WriteLine("DataInTail {0}", DataIn.tail);
|
||||
writer.WriteLine("DataInSize {0}", DataIn.size);
|
||||
writer.WriteLine("[/SCSI]\n");
|
||||
}
|
||||
|
||||
public void LoadStateText(TextReader reader)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
string[] args = reader.ReadLine().Split(' ');
|
||||
if (args[0].Trim() == "") continue;
|
||||
if (args[0] == "[/SCSI]") break;
|
||||
if (args[0] == "BSY")
|
||||
BSY = bool.Parse(args[1]);
|
||||
else if (args[0] == "SEL")
|
||||
SEL = bool.Parse(args[1]);
|
||||
else if (args[0] == "CD")
|
||||
CD = bool.Parse(args[1]);
|
||||
else if (args[0] == "IO")
|
||||
IO = bool.Parse(args[1]);
|
||||
else if (args[0] == "MSG")
|
||||
MSG = bool.Parse(args[1]);
|
||||
else if (args[0] == "REQ")
|
||||
REQ = bool.Parse(args[1]);
|
||||
else if (args[0] == "ACK")
|
||||
ACK = bool.Parse(args[1]);
|
||||
else if (args[0] == "ATN")
|
||||
ATN = bool.Parse(args[1]);
|
||||
else if (args[0] == "RST")
|
||||
RST = bool.Parse(args[1]);
|
||||
else if (args[0] == "DataBits")
|
||||
DataBits = byte.Parse(args[1], NumberStyles.HexNumber);
|
||||
else if (args[0] == "BusPhase")
|
||||
Phase = (BusPhase)Enum.Parse(typeof(BusPhase), args[1]);
|
||||
|
||||
else if (args[0] == "MessageCompleted")
|
||||
MessageCompleted = bool.Parse(args[1]);
|
||||
else if (args[0] == "StatusCompleted")
|
||||
StatusCompleted = bool.Parse(args[1]);
|
||||
else if (args[0] == "MessageValue")
|
||||
MessageValue = byte.Parse(args[1]);
|
||||
|
||||
else if (args[0] == "DataReadWaitTimer")
|
||||
DataReadWaitTimer = long.Parse(args[1]);
|
||||
else if (args[0] == "DataReadInProgress")
|
||||
DataReadInProgress = bool.Parse(args[1]);
|
||||
else if (args[0] == "DataTransferWasDone")
|
||||
DataTransferWasDone = bool.Parse(args[1]);
|
||||
else if (args[0] == "DataTransferInProgress")
|
||||
DataTransferInProgress = bool.Parse(args[1]);
|
||||
else if (args[0] == "CurrentReadingSector")
|
||||
CurrentReadingSector = int.Parse(args[1]);
|
||||
else if (args[0] == "SectorsLeftToRead")
|
||||
SectorsLeftToRead = int.Parse(args[1]);
|
||||
|
||||
else if (args[0] == "AudioStartLBA")
|
||||
audioStartLBA = int.Parse(args[1]);
|
||||
else if (args[0] == "AudioEndLBA")
|
||||
audioEndLBA = int.Parse(args[1]);
|
||||
|
||||
else if (args[0] == "CommandBuffer")
|
||||
CommandBuffer.buffer.ReadFromHex(args[1]);
|
||||
else if (args[0] == "CommandBufferPosition")
|
||||
CommandBuffer.Position = int.Parse(args[1]);
|
||||
|
||||
else if (args[0] == "DataInBuffer")
|
||||
DataIn.buffer.ReadFromHex(args[1]);
|
||||
else if (args[0] == "DataInHead")
|
||||
DataIn.head = int.Parse(args[1]);
|
||||
else if (args[0] == "DataInTail")
|
||||
DataIn.tail = int.Parse(args[1]);
|
||||
else if (args[0] == "DataInSize")
|
||||
DataIn.size = int.Parse(args[1]);
|
||||
|
||||
else
|
||||
Console.WriteLine("Skipping unrecognized identifier " + args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ namespace BizHawk
|
|||
// There is less overhead by not being dynamically resizable and stuff.
|
||||
public sealed class QuickList<T> where T : struct
|
||||
{
|
||||
T[] buffer;
|
||||
public T[] buffer;
|
||||
public int Position;
|
||||
|
||||
public QuickList(int capacity)
|
||||
|
@ -41,12 +41,12 @@ namespace BizHawk
|
|||
|
||||
// and the point of this one is to be easier to serialize quickly. AND fast to clear.
|
||||
// only intended to be used with value types. If used on references you may get GC issues.
|
||||
public class QuickQueue<T> where T : struct
|
||||
public sealed class QuickQueue<T> where T : struct
|
||||
{
|
||||
T[] buffer;
|
||||
int head;
|
||||
int tail;
|
||||
int size;
|
||||
public T[] buffer;
|
||||
public int head;
|
||||
public int tail;
|
||||
public int size;
|
||||
|
||||
public QuickQueue(int capacity)
|
||||
{
|
||||
|
@ -94,12 +94,10 @@ namespace BizHawk
|
|||
tail = count;
|
||||
size = count;
|
||||
}
|
||||
|
||||
// TODO serialization functions
|
||||
}
|
||||
|
||||
// .net has no built-in read only dictionary
|
||||
public class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey,TValue>
|
||||
public sealed class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey,TValue>
|
||||
{
|
||||
IDictionary<TKey, TValue> dict;
|
||||
|
||||
|
|
Loading…
Reference in New Issue