Fix DSKIdentifier ModChecksum function
This never worked. Will probably fix a whole bunch of core-selection issues (including ones listed here: https://tasvideos.org/HomePages/CloakTheLurker/ZXHawk)
This commit is contained in:
parent
ce3af37b24
commit
7d68a0b017
|
@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Common
|
||||||
private string _possibleIdent = "";
|
private string _possibleIdent = "";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default fallthrough to AppleII
|
/// Default fallthrough to AppleII - the AppleII *.dsk format seems to be very simple with no ident strings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string IdentifiedSystem { get; set; } = VSystemID.Raw.AppleII;
|
public string IdentifiedSystem { get; set; } = VSystemID.Raw.AppleII;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ namespace BizHawk.Emulation.Common
|
||||||
// check for bootable status
|
// check for bootable status
|
||||||
if (trk.Sectors[0].SectorData != null && trk.Sectors[0].SectorData.Length > 0)
|
if (trk.Sectors[0].SectorData != null && trk.Sectors[0].SectorData.Length > 0)
|
||||||
{
|
{
|
||||||
switch (trk.Sectors[0].GetChecksum256())
|
switch (trk.Sectors[0].GetModChecksum256())
|
||||||
{
|
{
|
||||||
case 3:
|
case 3:
|
||||||
IdentifiedSystem = VSystemID.Raw.ZXSpectrum;
|
IdentifiedSystem = VSystemID.Raw.ZXSpectrum;
|
||||||
|
@ -116,13 +116,13 @@ namespace BizHawk.Emulation.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
// at this point the disk is not standard bootable
|
// at this point the disk is not standard bootable
|
||||||
// try format analysis
|
// try format analysis
|
||||||
if (trk.Sectors.Length == 9 && trk.Sectors[0].SectorSize == 2)
|
if (trk.Sectors.Length == 9 && trk.Sectors[0].SectorSize == 2)
|
||||||
{
|
{
|
||||||
switch (trk.GetLowestSectorID())
|
switch (trk.GetLowestSectorID())
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
switch (trk.Sectors[0].GetChecksum256())
|
switch (trk.Sectors[0].GetModChecksum256())
|
||||||
{
|
{
|
||||||
case 3:
|
case 3:
|
||||||
IdentifiedSystem = VSystemID.Raw.ZXSpectrum;
|
IdentifiedSystem = VSystemID.Raw.ZXSpectrum;
|
||||||
|
@ -406,7 +406,15 @@ namespace BizHawk.Emulation.Common
|
||||||
public byte[] SectorData { get; set; }
|
public byte[] SectorData { get; set; }
|
||||||
public bool ContainsMultipleWeakSectors { get; set; }
|
public bool ContainsMultipleWeakSectors { get; set; }
|
||||||
|
|
||||||
public int GetChecksum256() => SectorData.Sum(b => b % 256);
|
public int GetModChecksum256()
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
for (int i = 0; i < ActualDataByteLength; i++)
|
||||||
|
{
|
||||||
|
res = (res + SectorData[i]) % 256;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue