[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;
|
int sector = (CommandBuffer[1] & 0x1f) << 16;
|
||||||
sector |= CommandBuffer[2] << 8;
|
sector |= CommandBuffer[2] << 8;
|
||||||
sector |= CommandBuffer[3];
|
sector |= CommandBuffer[3];
|
||||||
sector += 150; // BLEH
|
|
||||||
|
|
||||||
if (CommandBuffer[4] == 0)
|
if (CommandBuffer[4] == 0)
|
||||||
throw new Exception("requesting 0 sectors read.............................");
|
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
|
case 0x80: // Set start offset in track units
|
||||||
byte trackNo = CommandBuffer[2].BCDtoBin();
|
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);
|
Console.WriteLine("Set Start track: {0} lba={1}", trackNo, audioStartLBA);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -454,7 +453,7 @@ throw new Exception("requesting 0 sectors read.............................");
|
||||||
|
|
||||||
case 0x80: // Set end offset in track units
|
case 0x80: // Set end offset in track units
|
||||||
byte trackNo = CommandBuffer[2].BCDtoBin();
|
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);
|
Console.WriteLine("Set End track: {0} lba={1}", trackNo, audioEndLBA);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -496,7 +495,7 @@ throw new Exception("requesting 0 sectors read.............................");
|
||||||
|
|
||||||
private void CommandReadSubcodeQ()
|
private void CommandReadSubcodeQ()
|
||||||
{
|
{
|
||||||
var sectorEntry = disc.ReadLBA_SectorEntry(pce.CDAudio.CurrentSector);
|
var sectorEntry = disc.ReadLBA_SectorEntry(pce.CDAudio.CurrentSector);
|
||||||
|
|
||||||
DataIn.Clear();
|
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");
|
throw new Exception("Request more tracks than exist.... need to do error handling");
|
||||||
// I error handled your mom last night
|
// 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;
|
byte m, s, f;
|
||||||
Disc.ConvertLBAtoMSF(lbaPos, out m, out s, out 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
|
//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)
|
public static void ConvertLBAtoMSF(int lba, out byte m, out byte s, out byte f)
|
||||||
{
|
{
|
||||||
|
lba += 150;
|
||||||
m = (byte) (lba / 75 / 60);
|
m = (byte) (lba / 75 / 60);
|
||||||
s = (byte) ((lba - (m * 75 * 60)) / 75);
|
s = (byte) ((lba - (m * 75 * 60)) / 75);
|
||||||
f = (byte) (lba - (m * 75 * 60) - (s * 75));
|
f = (byte) (lba - (m * 75 * 60) - (s * 75));
|
||||||
|
@ -156,7 +157,7 @@ namespace BizHawk.DiscSystem
|
||||||
// converts MSF to LBA offset
|
// converts MSF to LBA offset
|
||||||
public static int ConvertMSFtoLBA(byte m, byte s, byte f)
|
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
|
// 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)
|
if (track < 1 || track > Disc.TOC.Sessions[0].Tracks.Count)
|
||||||
return;
|
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].aba - 150;
|
||||||
StartLBA = Disc.TOC.Sessions[0].Tracks[track - 1].Indexes[1].LBA;
|
EndLBA = StartLBA + Disc.TOC.Sessions[0].Tracks[track - 1].length_aba;
|
||||||
EndLBA = StartLBA + Disc.TOC.Sessions[0].Tracks[track - 1].length_aba;
|
|
||||||
PlayingTrack = track;
|
PlayingTrack = track;
|
||||||
CurrentSector = StartLBA;
|
CurrentSector = StartLBA;
|
||||||
SectorOffset = 0;
|
SectorOffset = 0;
|
||||||
|
@ -62,31 +61,11 @@ namespace BizHawk.Emulation.Sound
|
||||||
|
|
||||||
public void PlayStartingAtLba(int lba)
|
public void PlayStartingAtLba(int lba)
|
||||||
{
|
{
|
||||||
int track;
|
var point = Disc.TOC.SeekPoint(lba);
|
||||||
var tracks = Disc.TOC.Sessions[0].Tracks;
|
PlayingTrack = point.TrackNum;
|
||||||
bool foundTrack = false;
|
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;
|
CurrentSector = StartLBA;
|
||||||
SectorOffset = 0;
|
SectorOffset = 0;
|
||||||
Mode = CDAudioMode.Playing;
|
Mode = CDAudioMode.Playing;
|
||||||
|
|
|
@ -616,12 +616,12 @@ namespace BizHawk
|
||||||
|
|
||||||
public static byte BinToBCD(this byte v)
|
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)
|
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)
|
public static string FormatFileSize(long filesize)
|
||||||
|
|
Loading…
Reference in New Issue