some small discsys cleanup

This commit is contained in:
zeromus 2015-07-07 22:43:41 -05:00
parent 3ebdfaaf78
commit 57d76317c8
4 changed files with 25 additions and 22 deletions

View File

@ -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());

View File

@ -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;
}
}

View File

@ -11,6 +11,24 @@ namespace BizHawk.Emulation.DiscSystem
ret += (byte)(16 * (val / 10));
return ret;
}
/// <summary>
/// converts an LBA to AMSF absolute minute:second:frame format.
/// </summary>
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;
}
}
}

View File

@ -25,7 +25,7 @@ namespace BizHawk.Emulation.DiscSystem
/// </summary>
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++)