36 lines
649 B
C#
36 lines
649 B
C#
namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
|
{
|
|
public static class C64Util
|
|
{
|
|
static public string ToBinary(int n, int charsmin)
|
|
{
|
|
string result = "";
|
|
|
|
while (n > 0 || charsmin > 0)
|
|
{
|
|
result = (((n & 0x1) != 0) ? "1" : "0") + result;
|
|
n >>= 1;
|
|
if (charsmin > 0)
|
|
charsmin--;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
static public string ToHex(int n, int charsmin)
|
|
{
|
|
string result = "";
|
|
|
|
while (n > 0 || charsmin > 0)
|
|
{
|
|
result = "0123456789ABCDEF".Substring((n & 0xF), 1) + result;
|
|
n >>= 4;
|
|
if (charsmin > 0)
|
|
charsmin--;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|