Fix RCTrack sector reads

It appears rcheevos expects user data, not raw sector data
This commit is contained in:
CasualPokePlayer 2024-10-15 16:47:03 -07:00
parent 6582431d4c
commit b7e57db84f
1 changed files with 7 additions and 5 deletions

View File

@ -103,7 +103,7 @@ namespace BizHawk.Client.EmuHawk
private readonly Disc _disc;
private readonly DiscSectorReader _dsr;
private readonly DiscTrack _track;
private readonly byte[] _buf2448;
private readonly byte[] _buf2352;
public bool IsAvailable => _disc != null;
public int LBA => _track.LBA;
@ -194,8 +194,8 @@ namespace BizHawk.Client.EmuHawk
return;
}
_dsr = new(_disc);
_buf2448 = new byte[2448];
_dsr = new(_disc) { Policy = { ThrowExceptions2048 = false } };
_buf2352 = new byte[2352];
}
public int ReadSector(int lba, IntPtr buffer, nuint requestedBytes)
@ -205,9 +205,11 @@ namespace BizHawk.Client.EmuHawk
return 0;
}
var numRead = _dsr.ReadLBA_2448(lba, _buf2448, 0);
var numRead = _track.IsAudio
? _dsr.ReadLBA_2352(lba, _buf2352, 0)
: _dsr.ReadLBA_2048(lba, _buf2352, 0);
var numCopied = (int)Math.Min((ulong)numRead, requestedBytes);
Marshal.Copy(_buf2448, 0, buffer, numCopied);
Marshal.Copy(_buf2352, 0, buffer, numCopied);
return numCopied;
}