[pce] fix R-Type CD audio start bug(s)
This commit is contained in:
parent
2330126b84
commit
e703d3a99f
|
@ -378,7 +378,6 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
int sector = (CommandBuffer[1] & 0x1f) << 16;
|
||||
sector |= CommandBuffer[2] << 8;
|
||||
sector |= CommandBuffer[3];
|
||||
sector += 150; // BLEH
|
||||
|
||||
if (CommandBuffer[4] == 0)
|
||||
throw new Exception("requesting 0 sectors read.............................");
|
||||
|
@ -414,7 +413,7 @@ throw new Exception("requesting 0 sectors read.............................");
|
|||
|
||||
case 0x80: // Set start offset in track units
|
||||
byte trackNo = CommandBuffer[2].BCDtoBin();
|
||||
audioStartLBA = disc.TOC.Sessions[0].Tracks[trackNo - 1].Indexes[1].LBA;
|
||||
audioStartLBA = disc.TOC.Sessions[0].Tracks[trackNo - 1].Indexes[1].aba - 150;
|
||||
Console.WriteLine("Set Start track: {0} lba={1}", trackNo, audioStartLBA);
|
||||
break;
|
||||
}
|
||||
|
@ -454,7 +453,7 @@ throw new Exception("requesting 0 sectors read.............................");
|
|||
|
||||
case 0x80: // Set end offset in track units
|
||||
byte trackNo = CommandBuffer[2].BCDtoBin();
|
||||
audioEndLBA = disc.TOC.Sessions[0].Tracks[trackNo - 1].Indexes[1].LBA;
|
||||
audioEndLBA = disc.TOC.Sessions[0].Tracks[trackNo - 1].Indexes[1].aba - 150;
|
||||
Console.WriteLine("Set End track: {0} lba={1}", trackNo, audioEndLBA);
|
||||
break;
|
||||
}
|
||||
|
@ -496,7 +495,7 @@ throw new Exception("requesting 0 sectors read.............................");
|
|||
|
||||
private void CommandReadSubcodeQ()
|
||||
{
|
||||
var sectorEntry = disc.ReadLBA_SectorEntry(pce.CDAudio.CurrentSector);
|
||||
var sectorEntry = disc.ReadLBA_SectorEntry(pce.CDAudio.CurrentSector);
|
||||
|
||||
DataIn.Clear();
|
||||
|
||||
|
@ -560,7 +559,7 @@ throw new Exception("requesting 0 sectors read.............................");
|
|||
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].LBA;
|
||||
int lbaPos = disc.TOC.Sessions[0].Tracks[track].Indexes[1].aba - 150;
|
||||
byte m, s, f;
|
||||
Disc.ConvertLBAtoMSF(lbaPos, out m, out s, out f);
|
||||
|
||||
|
|
|
@ -148,6 +148,7 @@ namespace BizHawk.DiscSystem
|
|||
//TODO - somewhat redundant with Timestamp, which is due for refactoring into something not cue-related
|
||||
public static void ConvertLBAtoMSF(int lba, out byte m, out byte s, out byte f)
|
||||
{
|
||||
lba += 150;
|
||||
m = (byte) (lba / 75 / 60);
|
||||
s = (byte) ((lba - (m * 75 * 60)) / 75);
|
||||
f = (byte) (lba - (m * 75 * 60) - (s * 75));
|
||||
|
@ -156,7 +157,7 @@ namespace BizHawk.DiscSystem
|
|||
// converts MSF to LBA offset
|
||||
public static int ConvertMSFtoLBA(byte m, byte s, byte f)
|
||||
{
|
||||
return f + (s*75) + (m*75*60);
|
||||
return f + (s*75) + (m*75*60) - 150;
|
||||
}
|
||||
|
||||
// gets an identifying hash. hashes the first 512 sectors of
|
||||
|
|
|
@ -51,9 +51,8 @@ namespace BizHawk.Emulation.Sound
|
|||
if (track < 1 || track > Disc.TOC.Sessions[0].Tracks.Count)
|
||||
return;
|
||||
|
||||
//note for vecna: you may find that the new "Point" and "SeekPoint" concept in the TOC is more useful than this kind of logic. just something to think about
|
||||
StartLBA = Disc.TOC.Sessions[0].Tracks[track - 1].Indexes[1].LBA;
|
||||
EndLBA = StartLBA + Disc.TOC.Sessions[0].Tracks[track - 1].length_aba;
|
||||
StartLBA = Disc.TOC.Sessions[0].Tracks[track - 1].Indexes[1].aba - 150;
|
||||
EndLBA = StartLBA + Disc.TOC.Sessions[0].Tracks[track - 1].length_aba;
|
||||
PlayingTrack = track;
|
||||
CurrentSector = StartLBA;
|
||||
SectorOffset = 0;
|
||||
|
@ -62,31 +61,11 @@ namespace BizHawk.Emulation.Sound
|
|||
|
||||
public void PlayStartingAtLba(int lba)
|
||||
{
|
||||
int track;
|
||||
var tracks = Disc.TOC.Sessions[0].Tracks;
|
||||
bool foundTrack = false;
|
||||
var point = Disc.TOC.SeekPoint(lba);
|
||||
PlayingTrack = point.TrackNum;
|
||||
StartLBA = lba;
|
||||
EndLBA = point.Track.Indexes[1].aba + point.Track.length_aba - 150;
|
||||
|
||||
//note for vecna: you may find that the new "Point" and "SeekPoint" concept in the TOC is more useful than this kind of logic. just something to think about
|
||||
for (track = 0; track < tracks.Count; track++)
|
||||
{
|
||||
int trackStart = tracks[track].Indexes[0].LBA;
|
||||
int trackEnd = trackStart + tracks[track].length_aba;
|
||||
if (lba >= trackStart && lba < trackEnd)
|
||||
{
|
||||
foundTrack = true;
|
||||
StartLBA = lba;
|
||||
EndLBA = trackEnd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundTrack == false)
|
||||
{
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
PlayingTrack = track + 1;
|
||||
CurrentSector = StartLBA;
|
||||
SectorOffset = 0;
|
||||
Mode = CDAudioMode.Playing;
|
||||
|
|
|
@ -616,12 +616,12 @@ namespace BizHawk
|
|||
|
||||
public static byte BinToBCD(this byte v)
|
||||
{
|
||||
return (byte) (((v/10)*16) | (v%10));
|
||||
return (byte) (((v / 10) * 16) + (v % 10));
|
||||
}
|
||||
|
||||
public static byte BCDtoBin(this byte v)
|
||||
{
|
||||
return (byte)(((v / 16) * 10) | (v % 16));
|
||||
return (byte) (((v / 16) * 10) + (v % 16));
|
||||
}
|
||||
|
||||
public static string FormatFileSize(long filesize)
|
||||
|
|
Loading…
Reference in New Issue