示例#1
0
 public bool SaveState(string FilePath, NES nes)
 {
     try
     {
         nes.PAUSE = true;
         byte[][] chr = new byte[0][];
         while (!nes.paused)
         {
         }
         //If not vram, no need to serialize CHR
         if (!nes.Memory.Cartridge.IsVRAM)
         {
             chr = nes.Memory.Cartridge.CHR;
             nes.Memory.Cartridge.CHR = new byte[0][];//nothing
         }
         FileStream fs = new FileStream(FilePath, FileMode.Create);
         //BinaryFormatter formatter = new BinaryFormatter();
         //formatter.Serialize(fs, nes);
         if (!nes.Memory.Cartridge.IsVRAM)
         {
             nes.Memory.Cartridge.CHR = chr;//load it back
         }
         fs.Close();
         nes.PAUSE = false;
         return(true);
     }
     catch { return(false); }
 }
示例#2
0
 public APU(NES NesEmu, IAudioDevice SoundDevice)
 {
     _Nes = NesEmu;
     //_Control = SoundDevice.SoundDevice;
     STEREO = SoundDevice.Stereo;
     InitDirectSound(/*SoundDevice.SoundDevice*/);
 }
示例#3
0
        public bool LoadState(string FilePath, NES nes)
        {
            try
            {
                if (File.Exists(FilePath))
                {
                    nes.PAUSE = true;
                    while (!nes.paused)
                    {
                    }

                    //Backups
                    byte[][]       prg   = nes.Memory.Cartridge.PRG;
                    byte[][]       chr   = nes.Memory.Cartridge.CHR;
                    IGraphicDevice video = nes.PPU.VIDEO;

                    /*Control _Control = nes.APU._Control;
                     * DirectSound _SoundDevice = nes.APU._SoundDevice;
                     * SecondarySoundBuffer buffer = nes.APU.buffer;*/
                    byte[]       DATA         = nes.APU.DATA;
                    InputManager InputManager = nes.Memory.InputManager;
                    Joypad       Joypad1      = nes.Memory.Joypad1;
                    Joypad       Joypad2      = nes.Memory.Joypad2;
                    string       RomPath      = nes.Memory.Cartridge.RomPath;
                    //Do it

                    /*FileStream fs = new FileStream(FilePath, FileMode.Open);
                     * BinaryFormatter formatter = new BinaryFormatter();
                     * NES _Nes = (NES)formatter.Deserialize(fs);
                     * fs.Close();*/

                    /*nes.APU = _Nes.APU;
                     * nes.APU._Control = _Control;
                     * nes.APU._SoundDevice = _SoundDevice;
                     * nes.APU.DATA = DATA;
                     * nes.APU.buffer = buffer;
                     * nes.CPU = _Nes.CPU;
                     * nes.Memory = _Nes.Memory;
                     * nes.Memory.Cartridge.PRG = prg;*/
                    //If not vram, simply load back CHRs
                    if (!nes.Memory.Cartridge.IsVRAM)
                    {
                        nes.Memory.Cartridge.CHR = chr;
                    }
                    nes.Memory.Cartridge.RomPath = RomPath;
                    nes.Memory.InputManager      = InputManager;
                    nes.Memory.Joypad1           = Joypad1;
                    nes.Memory.Joypad2           = Joypad2;
                    //nes.PPU = _Nes.PPU;
                    nes.PPU.Timer = new TIMER();
                    nes.PPU.VIDEO = video;
                    nes.PAUSE     = false;
                    return(true);
                }
                nes.PAUSE = false;
                return(false);
            }
            catch { nes.PAUSE = false; return(false); };
        }
 /// <summary>
 /// The ppu memory
 /// </summary>
 /// <param name="NES">The nes</param>
 public PPUMemory(NES nes)
 {
     ppu  = nes.PPU;
     CART = nes.Memory.Cartridge;
     MEM  = nes.Memory;
     for (int i = 0; i < 4; i++)
     {
         NameTables[i] = new byte[0x400];
     }
 }
示例#5
0
 /// <summary>
 /// The memory of the nes
 /// </summary>
 public CPUMemory(NES nes)
 {
     ppu       = nes.PPU;
     apu       = nes.APU;
     cpu       = nes.CPU;
     Cartridge = new Cartridge(this);
     for (uint i = 0; i < 8; i++)
     {
         CRAM_PAGE[i] = i;
     }
 }
示例#6
0
 /// <summary>
 /// Picture Processing Unit class
 /// </summary>
 /// <param name="nes">The nes</param>
 public PPU(NES nes)
 {
     MEM_PPU        = new PPUMemory(nes);
     nes.Memory.ppu = this;
     MyNesDEBUGGER.WriteLine(this, "PPU Initialized ok.", DebugStatus.Cool);
 }
示例#7
0
 public Chn_DMC(NES NesEmu)
 {
     _Nes = NesEmu;
 }