public void loadRom(FileStream stream) { rom.data = new byte[stream.Length]; stream.Read(rom.data, 0, (int)(stream.Length)); stream.Dispose(); Boolean headered = rom.data.Length % 1024 == 512; //remove header if (headered) { byte[] temp = new byte[stream.Length - 512]; for (int i = 0; i < temp.Length; i++) { temp[i] = rom.data[i + 512]; } rom.data = temp; } //detect SNES header. rom.hiRom = false; Boolean detected = true; for (int i = 0x7FC0; i <= 0x7FD4; i++) { if (rom.data[i] < 0x20 || rom.data[i] > 0x7E) { detected = false; } } if (!detected) { detected = true; for (int i = 0xFFC0; i <= 0xFFD4; i++) { if (rom.data[i] < 0x20 || rom.data[i] > 0x7E) { detected = false; } } if (detected) { rom.hiRom = true; } else { throw new Exception("Invalid Rom"); } } int SRAMsize = 0x400 << this[0xFFD8]; SRAM = new MemoryLocation(SRAMsize); }
public MemoryMappingResult(MemoryLocation location, int address) { this.location = location; this.address = address; }