예제 #1
0
파일: Emulator.cs 프로젝트: pema99/LotusNES
        //Save states and rom loading
        private void HandleIO()
        {
            if (queueLoadState)
            {
                queueLoadState = false;
                using (FileStream FS = new FileStream(saveStatePath, FileMode.Open))
                {
                    ReadStateFromStream(FS);
                }
                RewindManager.Reset();
            }

            else if (queueSaveState)
            {
                queueSaveState = false;
                using (FileStream FS = new FileStream(saveStatePath, FileMode.OpenOrCreate))
                {
                    WriteStateToStream(FS);
                }
            }

            else if (queueLoad)
            {
                queueLoad = false;

                GamePak = new GamePak(romPath);
                Mapper  = Mapper.Create(this);
                CPU.Reset();
                PPU.Reset();
                APU.Reset();
                RewindManager.Reset();

                State = EmulatorState.Running;
            }
        }
예제 #2
0
파일: Emulator.cs 프로젝트: pema99/LotusNES
        internal void WriteStateToStream(Stream stream)
        {
            BinaryFormatter BF = new BinaryFormatter();

            object[] data;
            if (GamePak.UsesCharRAM)
            {
                data = new object[] { CPU, PPU, APU, Mapper, GamePak.GetCharRAM() };
            }
            else
            {
                data = new object[] { CPU, PPU, APU, Mapper };
            }
            BF.Serialize(stream, data);
        }
예제 #3
0
파일: Emulator.cs 프로젝트: pema99/LotusNES
        internal void ReadStateFromStream(Stream stream)
        {
            BinaryFormatter BF = new BinaryFormatter();

            object[] data = (object[])BF.Deserialize(stream);
            //Make sure to fix dead references from serialization
            CPU = (CPU)data[0];
            CPU.RefreshEmulatorReference(this);
            CPU.Memory.RefreshEmulatorReference(this);
            PPU = (PPU)data[1];
            PPU.RefreshEmulatorReference(this);
            PPU.Memory.RefreshEmulatorReference(this);
            APU = (APU)data[2];
            APU.RefreshEmulatorReference(this);
            Mapper = (Mapper)data[3];
            Mapper.RefreshEmulatorReference(this);
            if (GamePak.UsesCharRAM)
            {
                GamePak.LoadCharRAM((byte[])data[4]);
            }
        }