ZXHawk: fixed edge-case tzx tape image parsing exceptions (red heat, live and let die, etc.) - #1158
This commit is contained in:
parent
e4275ec777
commit
41f1058469
|
@ -1242,7 +1242,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
t.DataPeriods = new List<int>();
|
t.DataPeriods = new List<int>();
|
||||||
t.BlockDescription = BlockType.Archive_Info;
|
t.BlockDescription = BlockType.Archive_Info;
|
||||||
|
|
||||||
int blockLen = GetWordValue(data, 0);
|
int blockLen = GetWordValue(data, _position);
|
||||||
_position += 2;
|
_position += 2;
|
||||||
int stringCount = data[_position++];
|
int stringCount = data[_position++];
|
||||||
|
|
||||||
|
@ -1591,37 +1591,89 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
// dont get description info for Pure Data Blocks
|
// dont get description info for Pure Data Blocks
|
||||||
if (dataBlockType != DataBlockType.Pure)
|
if (dataBlockType != DataBlockType.Pure)
|
||||||
{
|
{
|
||||||
if (blockdata[0] == 0x00 && blockSize == 19 && (blockdata[1] == 0x00) || (blockdata[1] == 3 && blockdata.Length > 3))
|
if (blockdata[0] == 0x00 && blockSize == 19)
|
||||||
{
|
{
|
||||||
// This is the program header
|
|
||||||
string fileName = Encoding.ASCII.GetString(blockdata.Skip(2).Take(10).ToArray()).Trim();
|
string fileName = Encoding.ASCII.GetString(blockdata.Skip(2).Take(10).ToArray()).Trim();
|
||||||
|
string type = "Unknown Type";
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
string type = "";
|
var param1 = GetWordValue(blockdata, 12);
|
||||||
if (blockdata[0] == 0x00)
|
var param2 = GetWordValue(blockdata, 14);
|
||||||
|
|
||||||
|
// header block - examine first byte of header
|
||||||
|
if (blockdata[1] == 0)
|
||||||
{
|
{
|
||||||
type = "Program";
|
type = "Program";
|
||||||
block.AddMetaData(BlockDescriptorTitle.Program, fileName);
|
sb.Append(type + ": ");
|
||||||
|
sb.Append(fileName + " ");
|
||||||
}
|
}
|
||||||
else
|
else if (blockdata[1] == 1)
|
||||||
{
|
{
|
||||||
type = "Bytes";
|
type = "NumArray";
|
||||||
block.AddMetaData(BlockDescriptorTitle.Bytes, fileName);
|
sb.Append(type + ": ");
|
||||||
|
sb.Append(fileName + " ");
|
||||||
}
|
}
|
||||||
|
else if (blockdata[1] == 2)
|
||||||
|
{
|
||||||
|
type = "CharArray";
|
||||||
|
sb.Append(type + ": ");
|
||||||
|
sb.Append(fileName + " ");
|
||||||
|
}
|
||||||
|
else if (blockdata[1] == 3)
|
||||||
|
{
|
||||||
|
type = "Code";
|
||||||
|
sb.Append(type + ": ");
|
||||||
|
sb.Append(fileName + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (blockdata[0] == 0xff)
|
||||||
|
{
|
||||||
|
// data block
|
||||||
|
description = "Data Block " + (blockSize - 2) + "bytes";
|
||||||
|
block.AddMetaData(BlockDescriptorTitle.Data_Bytes, (blockSize - 2).ToString() + " Bytes");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// some other type (turbo data etc..)
|
||||||
|
description = string.Format("#{0} block, {1} bytes", blockdata[0].ToString("X2"), blockSize);
|
||||||
|
//description += string.Format(", crc {0}", ((crc != 0) ? string.Format("bad (#{0:X2}!=#{1:X2})", crcFile, crcValue) : "ok"));
|
||||||
|
block.AddMetaData(BlockDescriptorTitle.Undefined, description);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (blockdata[0] == 0x00 && blockSize == 19 && (blockdata[1] == 0x00) || (blockdata[1] == 3 && blockdata.Length > 3))
|
||||||
|
{
|
||||||
|
if (dataBlockType != DataBlockType.Turbo)
|
||||||
|
{
|
||||||
|
// This is the program header
|
||||||
|
string fileName = Encoding.ASCII.GetString(blockdata.Skip(2).Take(10).ToArray()).Trim();
|
||||||
|
|
||||||
// now build the description string
|
string type = "";
|
||||||
StringBuilder sb = new StringBuilder();
|
if (blockdata[0] == 0x00)
|
||||||
sb.Append(type + ": ");
|
{
|
||||||
sb.Append(fileName + " ");
|
type = "Program";
|
||||||
sb.Append(GetWordValue(blockdata, 14));
|
block.AddMetaData(BlockDescriptorTitle.Program, fileName);
|
||||||
sb.Append(":");
|
}
|
||||||
sb.Append(GetWordValue(blockdata, 12));
|
else
|
||||||
description = sb.ToString();
|
{
|
||||||
|
type = "Bytes";
|
||||||
|
block.AddMetaData(BlockDescriptorTitle.Bytes, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now build the description string
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.Append(type + ": ");
|
||||||
|
sb.Append(fileName + " ");
|
||||||
|
sb.Append(GetWordValue(blockdata, 14));
|
||||||
|
sb.Append(":");
|
||||||
|
sb.Append(GetWordValue(blockdata, 12));
|
||||||
|
description = sb.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (blockdata[0] == 0xFF)
|
else if (blockdata[0] == 0xFF)
|
||||||
{
|
{
|
||||||
// this is a data block
|
// this is a data block
|
||||||
description = "Data Block " + (blockSize - 2) + "bytes";
|
description = "Data Block " + (blockSize - 2) + "bytes";
|
||||||
block.AddMetaData(BlockDescriptorTitle.Data_Bytes, (blockSize).ToString() + " Bytes");
|
block.AddMetaData(BlockDescriptorTitle.Data_Bytes, (blockSize - 2).ToString() + " Bytes");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1629,7 +1681,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
||||||
description = string.Format("#{0} block, {1} bytes", blockdata[0].ToString("X2"), blockSize);
|
description = string.Format("#{0} block, {1} bytes", blockdata[0].ToString("X2"), blockSize);
|
||||||
//description += string.Format(", crc {0}", ((crc != 0) ? string.Format("bad (#{0:X2}!=#{1:X2})", crcFile, crcValue) : "ok"));
|
//description += string.Format(", crc {0}", ((crc != 0) ? string.Format("bad (#{0:X2}!=#{1:X2})", crcFile, crcValue) : "ok"));
|
||||||
block.AddMetaData(BlockDescriptorTitle.Undefined, description);
|
block.AddMetaData(BlockDescriptorTitle.Undefined, description);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// update metadata
|
// update metadata
|
||||||
|
|
Loading…
Reference in New Issue