diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs index 2ddd89f8cf..1fb67b8043 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs @@ -413,11 +413,11 @@ namespace BizHawk.Emulation.Cores.PCEngine audioStartLBA = (CommandBuffer[3] << 16) | (CommandBuffer[4] << 8) | CommandBuffer[5]; break; - case 0x40: // Set start offset in MSF units + case 0x40: // Set start offset in absolute MSF units byte m = CommandBuffer[2].BCDtoBin(); byte s = CommandBuffer[3].BCDtoBin(); byte f = CommandBuffer[4].BCDtoBin(); - audioStartLBA = Disc.ConvertMSFtoLBA(m, s, f); + audioStartLBA = DiscUtils.Convert_AMSF_To_LBA(m, s, f); break; case 0x80: // Set start offset in track units @@ -448,11 +448,11 @@ namespace BizHawk.Emulation.Cores.PCEngine audioEndLBA = (CommandBuffer[3] << 16) | (CommandBuffer[4] << 8) | CommandBuffer[5]; break; - case 0x40: // Set end offset in MSF units + case 0x40: // Set end offset in absolute MSF units byte m = CommandBuffer[2].BCDtoBin(); byte s = CommandBuffer[3].BCDtoBin(); byte f = CommandBuffer[4].BCDtoBin(); - audioEndLBA = Disc.ConvertMSFtoLBA(m, s, f); + audioEndLBA = DiscUtils.Convert_AMSF_To_LBA(m, s, f); break; case 0x80: // Set end offset in track units @@ -540,7 +540,7 @@ namespace BizHawk.Emulation.Cores.PCEngine int totalLbaLength = disc.Session1.LeadoutLBA; byte m, s, f; - Disc.ConvertLBAtoMSF(totalLbaLength, out m, out s, out f); + DiscUtils.Convert_LBA_To_AMSF(totalLbaLength + 150, out m, out s, out f); DataIn.Clear(); DataIn.Enqueue(m.BinToBCD()); @@ -565,7 +565,7 @@ namespace BizHawk.Emulation.Cores.PCEngine lbaPos = tracks[track].LBA; byte m, s, f; - Disc.ConvertLBAtoMSF(lbaPos, out m, out s, out f); + DiscUtils.Convert_LBA_To_AMSF(lbaPos, out m, out s, out f); DataIn.Clear(); DataIn.Enqueue(m.BinToBCD()); diff --git a/BizHawk.Emulation.DiscSystem/API/Disc.API.cs b/BizHawk.Emulation.DiscSystem/API/Disc.API.cs index 6e2de04f3b..7f5da1006c 100644 --- a/BizHawk.Emulation.DiscSystem/API/Disc.API.cs +++ b/BizHawk.Emulation.DiscSystem/API/Disc.API.cs @@ -12,21 +12,6 @@ namespace BizHawk.Emulation.DiscSystem - // converts LBA to minute:second:frame format. - //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)); - } - - // converts MSF to LBA offset - public static int ConvertMSFtoLBA(byte m, byte s, byte f) - { - return f + (s * 75) + (m * 75 * 60) - 150; - } } diff --git a/BizHawk.Emulation.DiscSystem/DiscUtils.cs b/BizHawk.Emulation.DiscSystem/DiscUtils.cs index 5750fc7fec..bbb650578b 100644 --- a/BizHawk.Emulation.DiscSystem/DiscUtils.cs +++ b/BizHawk.Emulation.DiscSystem/DiscUtils.cs @@ -11,6 +11,24 @@ namespace BizHawk.Emulation.DiscSystem ret += (byte)(16 * (val / 10)); return ret; } + + /// + /// converts an LBA to AMSF absolute minute:second:frame format. + /// + public static void Convert_LBA_To_AMSF(int lba, out byte m, out byte s, out byte f) + { + lba += 150; //dont do this anymore + m = (byte)(lba / 75 / 60); + s = (byte)((lba - (m * 75 * 60)) / 75); + f = (byte)(lba - (m * 75 * 60) - (s * 75)); + } + + // converts MSF to LBA offset + public static int Convert_AMSF_To_LBA(byte m, byte s, byte f) + { + return f + (s * 75) + (m * 75 * 60) - 150; + } + } } \ No newline at end of file diff --git a/BizHawk.Emulation.DiscSystem/TOC/DiscStructure.cs b/BizHawk.Emulation.DiscSystem/TOC/DiscStructure.cs index 24b1cc4517..ead82b203d 100644 --- a/BizHawk.Emulation.DiscSystem/TOC/DiscStructure.cs +++ b/BizHawk.Emulation.DiscSystem/TOC/DiscStructure.cs @@ -25,7 +25,7 @@ namespace BizHawk.Emulation.DiscSystem /// public Track SeekTrack(int lba) { - var ses = Sessions[0]; + var ses = Sessions[1]; //take care with this loop bounds: for (int i = 1; i <= ses.InformationTrackCount; i++)