static void LoadRom(string fileName, UInt16 memoryAddress)
{
BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open));
int pos = 0;
UInt16 index = memoryAddress;
int length = (int)reader.BaseStream.Length;
try
{
while (pos < length)
{
byte[] word = reader.ReadBytes(2);
if (BitConverter.IsLittleEndian)
Array.Reverse(word);
UInt16 data = BitConverter.ToUInt16(word, 0);
//UInt16 data = reader.ReadUInt16();
Console.Write(data.ToString("X") + ":");
MasterComponent.Instance.MemoryMap.Write16BitsToAddress(index, data);
pos += sizeof(UInt16);
index += 1;
}
Console.WriteLine("Loaded rom " + fileName + " into 0x" + memoryAddress.ToString("X"));
}
catch (Exception ex)
{
Console.WriteLine("Error loading rom " + fileName + " into 0x" + memoryAddress.ToString("X"));
Console.WriteLine(ex);
}
reader.Close();
}