BizHawk/BizHawk.Emulation.DiscSystem/DiscUtils.cs

34 lines
828 B
C#
Raw Normal View History

namespace BizHawk.Emulation.DiscSystem
{
public static class DiscUtils
{
/// <summary>
2015-07-08 03:33:05 +00:00
/// converts the given int to a BCD value
/// </summary>
2015-07-08 03:33:05 +00:00
public static int BCD_Byte(this int val)
{
byte ret = (byte)(val % 10);
ret += (byte)(16 * (val / 10));
return ret;
}
2015-07-08 03:43:41 +00:00
/// <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;
}
}
}