/// <summary> /// Crée une nouvelle instance de SNES /// </summary> public SnesPlatform() { //Taille maximale addressable par la SNES const int mappedMemorySize = 0x7FFFFF+1; memory = new MemoryContainer(mappedMemorySize); cpu = new CPU(this); decoder = new InstructionsDecoder(cpu); encoder = new InstructionsEncoder(cpu); interpreter = new LiveInstructionsDecoder(this); }
/// <summary> /// Charge une ROM en mémoire. /// </summary> /// <param name="romStream"></param> /// <param name="baseOffset">Début du stream à considérer</param> /// <param name="headerOffset">A partir du début du stream, endroit où se trouve le header</param> /// <param name="container"></param> /// <param name="containerOffset"></param> /// <returns></returns> public static MemoryBin LoadInto(Stream romStream, int baseOffset, int headerOffset, MemoryContainer container, int containerOffset) { int romSize, ramSize; GetROMParameters(romStream, baseOffset, headerOffset, out romSize, out ramSize); if (romSize > container.Length - containerOffset) throw new OutOfMemoryException(String.Format("Container est trop petit. \nDisponible : {0}.\nRequis : {1}", container.Length - containerOffset, romSize)); romStream.Position = baseOffset; romStream.Read(container.Data, containerOffset, romSize); return new MemoryBin(container, containerOffset, romSize); }
public MemoryBin(MemoryContainer container, int start, int length) { if (container == null) throw new ArgumentNullException("container"); this.container = container; if (start < 0 || start >= container.Data.Length) throw new ArgumentOutOfRangeException("start"); this.start = start; if (length <= 0 || length + start > container.Data.Length) throw new ArgumentOutOfRangeException("length"); this.length = length; }