fix Jaguar CD homebrew hashing wrt retroachievements
This commit is contained in:
parent
a46c47d271
commit
955139454a
|
@ -163,16 +163,18 @@ namespace BizHawk.Client.EmuHawk
|
||||||
case ConsoleID.JaguarCD:
|
case ConsoleID.JaguarCD:
|
||||||
// we want to hash the second session of the disc
|
// we want to hash the second session of the disc
|
||||||
if (disc.Sessions.Count > 2)
|
if (disc.Sessions.Count > 2)
|
||||||
|
{
|
||||||
|
static string HashJaguar(DiscTrack bootTrack, DiscSectorReader dsr)
|
||||||
{
|
{
|
||||||
const string _jaguarHeader = "ATARI APPROVED DATA HEADER ATRI";
|
const string _jaguarHeader = "ATARI APPROVED DATA HEADER ATRI";
|
||||||
const string _jaguarBSHeader = "TARA IPARPVODED TA AEHDAREA RT";
|
const string _jaguarBSHeader = "TARA IPARPVODED TA AEHDAREA RT";
|
||||||
var bootSession = disc.Sessions[2];
|
var buffer = new List<byte>();
|
||||||
var buf2352 = new byte[2352];
|
var buf2352 = new byte[2352];
|
||||||
|
|
||||||
// find the boot track header
|
// find the boot track header
|
||||||
// see https://github.com/TASEmulators/BizHawk/blob/f29113287e88c6a644dbff30f92a9833307aad20/waterbox/virtualjaguar/src/cdhle.cpp#L109-L145
|
// see https://github.com/TASEmulators/BizHawk/blob/f29113287e88c6a644dbff30f92a9833307aad20/waterbox/virtualjaguar/src/cdhle.cpp#L109-L145
|
||||||
var startLba = bootSession.FirstInformationTrack.LBA;
|
var startLba = bootTrack.LBA;
|
||||||
var numLbas = bootSession.FirstInformationTrack.NextTrack.LBA - bootSession.FirstInformationTrack.LBA;
|
var numLbas = bootTrack.NextTrack.LBA - bootTrack.LBA;
|
||||||
int bootLen = 0, bootLba = 0, bootOff = 0;
|
int bootLen = 0, bootLba = 0, bootOff = 0;
|
||||||
bool byteswapped = false, foundHeader = false;
|
bool byteswapped = false, foundHeader = false;
|
||||||
for (var i = 0; i < numLbas; i++)
|
for (var i = 0; i < numLbas; i++)
|
||||||
|
@ -215,7 +217,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
if (!foundHeader)
|
if (!foundHeader)
|
||||||
{
|
{
|
||||||
return 0;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
dsr.ReadLBA_2352(bootLba++, buf2352, 0);
|
dsr.ReadLBA_2352(bootLba++, buf2352, 0);
|
||||||
|
@ -241,8 +243,28 @@ namespace BizHawk.Client.EmuHawk
|
||||||
bootLen -= 2352;
|
bootLen -= 2352;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return MD5Checksum.ComputeDigestHex(buffer.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
var jaguarHash = HashJaguar(disc.Sessions[2].Tracks[1], dsr);
|
||||||
|
switch (jaguarHash)
|
||||||
|
{
|
||||||
|
case null:
|
||||||
|
return 0;
|
||||||
|
case "254487B59AB21BC005338E85CBF9FD2F": // see https://github.com/RetroAchievements/rcheevos/pull/234
|
||||||
|
{
|
||||||
|
jaguarHash = HashJaguar(disc.Sessions[2].Tracks[2], dsr);
|
||||||
|
if (jaguarHash is null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return IdentifyHash(jaguarHash);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue