Пример #1
0
 public void LoadSaveState(Savestate state, int channel)
 {
     Reg0             = state.SoundChannels[channel].Reg0;
     Reg1             = state.SoundChannels[channel].Reg1;
     Reg2             = state.SoundChannels[channel].Reg2;
     Reg3             = state.SoundChannels[channel].Reg3;
     Reg4             = state.SoundChannels[channel].Reg4;
     ChannelEnable    = state.SoundChannels[channel].ChannelEnable;
     SweepPeriod      = state.SoundChannels[channel].SweepPeriod;
     Negate           = state.SoundChannels[channel].Negate;
     Shift            = state.SoundChannels[channel].Shift;
     Duty             = state.SoundChannels[channel].Duty;
     LengthLoad       = state.SoundChannels[channel].LengthLoad;
     StartingVolume   = state.SoundChannels[channel].StartingVolume;
     EnvelopeAddMode  = state.SoundChannels[channel].EnvelopeAddMode;
     EnvelopePeriod   = state.SoundChannels[channel].EnvelopePeriod;
     LengthEnable     = state.SoundChannels[channel].LengthEnable;
     CurrentDuty      = state.SoundChannels[channel].CurrentDuty;
     Sample           = state.SoundChannels[channel].Sample;
     Frequency        = state.SoundChannels[channel].Frequency;
     SweepEnabled     = state.SoundChannels[channel].SweepEnabled;
     ShadowFreq       = state.SoundChannels[channel].ShadowFreq;
     SweepStep        = state.SoundChannels[channel].SweepStep;
     Cycles           = state.SoundChannels[channel].Cycles;
     Envelope_enabled = state.SoundChannels[channel].Envelope_enabled;
 }
Пример #2
0
        public void WriteSaveState(ref Savestate state)
        {
            Array.Copy(oamRam, state.oamRam, oamRam.Length);
            Array.Copy(VRAM, state.VRAM, VRAM.Length);
            Array.Copy(gbcBgPalette, state.gbcBgPalette, gbcBgPalette.Length);
            Array.Copy(gbcObjPalette, state.gbcObjPalette, gbcObjPalette.Length);
            Array.Copy(_framebufferRGB, state._framebufferRGB, _framebufferRGB.Length);

            state.vramBankNo         = vramBankNo;
            state.stat               = stat;
            state.wy                 = wy;
            state.wx                 = wx;
            state.scy                = scy;
            state.scx                = scx;
            state.ly                 = ly;
            state.lyc                = lyc;
            state.lcdc               = lcdc;
            state.bgp                = bgp;
            state.obp0               = obp0;
            state.obp1               = obp1;
            state.bgPaletteIndex     = bgPaletteIndex;
            state.objPaletteIndex    = objPaletteIndex;
            state.hdmaSourceHighByte = hdmaSourceHighByte;
            state.hdmaSourceLowByte  = hdmaSourceLowByte;
            state.hdmaDestHighByte   = hdmaDestHighByte;
            state.hdmaDestLowByte    = hdmaDestLowByte;
            state.hdmaLenghtCounter  = hdmaLenghtCounter;
            state.hdmaDuringHblank   = hdmaDuringHblank;
            state.hdmaSource         = hdmaSource;
            state.hdmaDest           = hdmaDest;
            state.lcd_clockcount     = lcd_clockcount;
            state.InVblank_interrupt = InVblank_interrupt;
            state._frameready        = _frameready;
        }
Пример #3
0
 public void WriteSaveState(ref Savestate state, int channel)
 {
     state.SoundChannels[channel].Reg0             = Reg0;
     state.SoundChannels[channel].Reg1             = Reg1;
     state.SoundChannels[channel].Reg2             = Reg2;
     state.SoundChannels[channel].Reg3             = Reg3;
     state.SoundChannels[channel].Reg4             = Reg4;
     state.SoundChannels[channel].ChannelEnable    = ChannelEnable;
     state.SoundChannels[channel].SweepPeriod      = SweepPeriod;
     state.SoundChannels[channel].Negate           = Negate;
     state.SoundChannels[channel].Shift            = Shift;
     state.SoundChannels[channel].Duty             = Duty;
     state.SoundChannels[channel].LengthLoad       = LengthLoad;
     state.SoundChannels[channel].StartingVolume   = StartingVolume;
     state.SoundChannels[channel].EnvelopeAddMode  = EnvelopeAddMode;
     state.SoundChannels[channel].EnvelopePeriod   = EnvelopePeriod;
     state.SoundChannels[channel].LengthEnable     = LengthEnable;
     state.SoundChannels[channel].CurrentDuty      = CurrentDuty;
     state.SoundChannels[channel].Sample           = Sample;
     state.SoundChannels[channel].Frequency        = Frequency;
     state.SoundChannels[channel].SweepEnabled     = SweepEnabled;
     state.SoundChannels[channel].ShadowFreq       = ShadowFreq;
     state.SoundChannels[channel].SweepStep        = SweepStep;
     state.SoundChannels[channel].Cycles           = Cycles;
     state.SoundChannels[channel].Envelope_enabled = Envelope_enabled;
 }
Пример #4
0
 private void LoadSaveState(Savestate state)
 {
     _cpu.LoadSaveState(state);
     _ppu.LoadSaveState(state);
     _apu.LoadSaveState(state);
     Array.Copy(state.WRAM, WRAM, WRAM.Length);
     Array.Copy(state.ZeroPage, ZeroPage, ZeroPage.Length);
     Array.Copy(state.ioregisters, ioregisters, ioregisters.Length);
     wramBankNo         = state.wramBankNo;
     p1                 = state.p1;
     div                = state.div;
     tima               = state.tima;
     tma                = state.tma;
     tac                = state.tac;
     dma                = state.dma;
     gbcMode            = state.gbcMode;
     doubleSpeed        = state.doubleSpeed;
     prepareSpeedSwitch = state.prepareSpeedSwitch;
     serialdata         = state.serialdata;
     serialreg          = state.serialreg;
     keydata1           = 0xF;
     keydata2           = 0xF;
     ie                 = state.ie;
     iflag              = state.iflag;
     lastCycles         = state.lastcycles;
 }
Пример #5
0
 public Savestate WriteSaveState(ref Savestate state)
 {
     _cpu.WriteSaveState(ref state);
     _ppu.WriteSaveState(ref state);
     _apu.WriteSaveState(ref state);
     Array.Copy(WRAM, state.WRAM, WRAM.Length);
     Array.Copy(ZeroPage, state.ZeroPage, ZeroPage.Length);
     Array.Copy(ioregisters, state.ioregisters, ioregisters.Length);
     state.wramBankNo         = wramBankNo;
     state.p1                 = p1;
     state.div                = div;
     state.tima               = tima;
     state.tma                = tma;
     state.tac                = tac;
     state.dma                = dma;
     state.gbcMode            = gbcMode;
     state.doubleSpeed        = doubleSpeed;
     state.prepareSpeedSwitch = prepareSpeedSwitch;
     state.serialdata         = serialdata;
     state.serialreg          = serialreg;
     state.keydata1           = 0xF;
     state.keydata2           = 0xF;
     state.ie                 = ie;
     state.iflag              = iflag;
     state.lastcycles         = lastCycles;
     return(state);
 }
Пример #6
0
 public void MachineCycle()
 {
     lastCycles = _cpu.Cycles;
     if (prepareSpeedSwitch)
     {
         if (_cpu.Stop)
         {
             doubleSpeed        = !doubleSpeed;
             prepareSpeedSwitch = false;
             _cpu.Stop          = false;
         }
     }
     if (doubleSpeed)
     {
         HandleInterrupt();
         _cpu.Cycle();
         HandleInterrupt();
         _cpu.Cycle();
         for (int i = 0; i < _cpu.Cycles - lastCycles; i++)
         {
             Timer();
         }
         for (int i = 0; i < (_cpu.Cycles - lastCycles) / 2; i++)
         {
             _ppu.LcdTick();
             _apu.ApuTick();
         }
     }
     else
     {
         HandleInterrupt();
         _cpu.Cycle();
         for (int i = 0; i < _cpu.Cycles - lastCycles; i++)
         {
             _ppu.LcdTick();
             Timer();
             _apu.ApuTick();
         }
     }
     if (saveState)
     {
         WriteSaveState(ref _saveState);
         _cart.WriteStateFile(_saveState, selectedSavestate);
         saveState = false;
     }
     if (loadState)
     {
         Savestate tempState = _cart.LoadStateFile(selectedSavestate);
         if (tempState != null)
         {
             LoadSaveState(tempState);
         }
         loadState = false;
     }
 }
Пример #7
0
 public void LoadSaveState(Savestate state)
 {
     Array.Copy(state.Samples, Samples, Samples.Length);
     soundCycles       = state.soundCycles;
     frameSequenceStep = state.frameSequenceStep;
     NumberOfSamples   = state.NumberOfSamples;
     channelCtrlReg    = state.channelCtrlReg;
     soundOutputReg    = state.soundOutputReg;
     soundEnabled      = state.soundEnabled;
     _squareChannel1.LoadSaveState(state, 0);
     _squareChannel2.LoadSaveState(state, 1);
     _waveChannel.LoadSaveState(state, 2);
     _noiseChannel.LoadSaveState(state, 3);
 }
Пример #8
0
 public void WriteSaveState(ref Savestate state)
 {
     Array.Copy(Samples, state.Samples, Samples.Length);
     state.soundCycles       = soundCycles;
     state.frameSequenceStep = frameSequenceStep;
     state.NumberOfSamples   = NumberOfSamples;
     state.channelCtrlReg    = channelCtrlReg;
     state.soundOutputReg    = soundOutputReg;
     state.soundEnabled      = soundEnabled;
     _squareChannel1.WriteSaveState(ref state, 0);
     _squareChannel2.WriteSaveState(ref state, 1);
     _waveChannel.WriteSaveState(ref state, 2);
     _noiseChannel.WriteSaveState(ref state, 3);
 }
Пример #9
0
 public void LoadSaveState(Savestate state, int channel)
 {
     Array.Copy(state.SoundChannels[channel].WaveTable, WaveTable, WaveTable.Length);
     Reg0          = state.SoundChannels[channel].Reg0;
     Reg1          = state.SoundChannels[channel].Reg1;
     Reg2          = state.SoundChannels[channel].Reg2;
     Reg3          = state.SoundChannels[channel].Reg3;
     Reg4          = state.SoundChannels[channel].Reg4;
     ChannelEnable = state.SoundChannels[channel].ChannelEnable;
     LengthLoad    = state.SoundChannels[channel].LengthLoad;
     Sample        = state.SoundChannels[channel].Sample;
     Frequency     = state.SoundChannels[channel].Frequency;
     cycles        = state.SoundChannels[channel].Cycles;
     DacPower      = state.SoundChannels[channel].DacPower;
     wavePos       = state.SoundChannels[channel].wavePos;
     Volume        = (byte)state.SoundChannels[channel].Volume;
 }
Пример #10
0
 public void WriteSaveState(ref Savestate state, int channel)
 {
     Array.Copy(WaveTable, state.SoundChannels[channel].WaveTable, WaveTable.Length);
     state.SoundChannels[channel].Reg0          = Reg0;
     state.SoundChannels[channel].Reg1          = Reg1;
     state.SoundChannels[channel].Reg2          = Reg2;
     state.SoundChannels[channel].Reg3          = Reg3;
     state.SoundChannels[channel].Reg4          = Reg4;
     state.SoundChannels[channel].ChannelEnable = ChannelEnable;
     state.SoundChannels[channel].LengthLoad    = LengthLoad;
     state.SoundChannels[channel].Sample        = Sample;
     state.SoundChannels[channel].Frequency     = Frequency;
     state.SoundChannels[channel].Cycles        = cycles;
     state.SoundChannels[channel].DacPower      = DacPower;
     state.SoundChannels[channel].wavePos       = wavePos;
     state.SoundChannels[channel].Volume        = Volume;
 }
Пример #11
0
 public void LoadSaveState(Savestate state, int channel)
 {
     Reg0             = state.SoundChannels[channel].Reg0;
     Reg1             = state.SoundChannels[channel].Reg1;
     Reg2             = state.SoundChannels[channel].Reg2;
     Reg3             = state.SoundChannels[channel].Reg3;
     Reg4             = state.SoundChannels[channel].Reg4;
     ChannelEnable    = state.SoundChannels[channel].ChannelEnable;
     LengthLoad       = state.SoundChannels[channel].LengthLoad;
     StartingVolume   = state.SoundChannels[channel].StartingVolume;
     EnvelopeAddMode  = state.SoundChannels[channel].EnvelopeAddMode;
     EnvelopePeriod   = state.SoundChannels[channel].EnvelopePeriod;
     LengthEnable     = state.SoundChannels[channel].LengthEnable;
     Sample           = state.SoundChannels[channel].Sample;
     Frequency        = state.SoundChannels[channel].Frequency;
     Envelope_enabled = state.SoundChannels[channel].Envelope_enabled;
     WidthOfLFSR      = state.SoundChannels[channel].WidthOfLFSR;
     DivisorCode      = state.SoundChannels[channel].DivisorCode;
     LFSR             = state.SoundChannels[channel].LFSR;
 }
Пример #12
0
 public void WriteSaveState(ref Savestate state, int channel)
 {
     state.SoundChannels[channel].Reg0             = Reg0;
     state.SoundChannels[channel].Reg1             = Reg1;
     state.SoundChannels[channel].Reg2             = Reg2;
     state.SoundChannels[channel].Reg3             = Reg3;
     state.SoundChannels[channel].Reg4             = Reg4;
     state.SoundChannels[channel].ChannelEnable    = ChannelEnable;
     state.SoundChannels[channel].LengthLoad       = LengthLoad;
     state.SoundChannels[channel].StartingVolume   = StartingVolume;
     state.SoundChannels[channel].EnvelopeAddMode  = EnvelopeAddMode;
     state.SoundChannels[channel].EnvelopePeriod   = EnvelopePeriod;
     state.SoundChannels[channel].LengthEnable     = LengthEnable;
     state.SoundChannels[channel].Sample           = Sample;
     state.SoundChannels[channel].Frequency        = Frequency;
     state.SoundChannels[channel].Envelope_enabled = Envelope_enabled;
     state.SoundChannels[channel].WidthOfLFSR      = WidthOfLFSR;
     state.SoundChannels[channel].DivisorCode      = DivisorCode;
     state.SoundChannels[channel].LFSR             = LFSR;
 }
Пример #13
0
        public bool WriteStateFile(Savestate state, int selectedState)
        {
            selectedState = selectedState > 9 ? 9 : selectedState;
            string extension = "s" + selectedState.ToString();

            stateFilename = Path.ChangeExtension(stateFilename, extension);
            try
            {
                using (Stream stream = File.Open(stateFilename, FileMode.Create))
                {
                    var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    binaryFormatter.Serialize(stream, state);
                }
                return(true);
            }
            catch
            {
                //IOERROR
            }
            return(false);
        }
Пример #14
0
        public void LoadSaveState(Savestate state)
        {
            Array.Copy(state.oamRam, oamRam, oamRam.Length);
            Array.Copy(state.VRAM, VRAM, VRAM.Length);
            Array.Copy(state.gbcBgPalette, gbcBgPalette, gbcBgPalette.Length);
            Array.Copy(state.gbcObjPalette, gbcObjPalette, gbcObjPalette.Length);
            Array.Copy(state._framebufferRGB, _framebufferRGB, _framebufferRGB.Length);

            vramBankNo = state.vramBankNo;
            stat       = state.stat;
            wy         = state.wy;
            wx         = state.wx;
            scy        = state.scy;
            scx        = state.scx;
            ly         = state.ly;
            lyc        = state.lyc;
            lcdc       = state.lcdc;
            bgp        = state.bgp;
            obp0       = state.obp0;
            obp1       = state.obp1;
            UpdatePalette(ref bgPallete, bgp);
            UpdatePalette(ref obj0Pallete, obp0);
            UpdatePalette(ref obj1Pallete, obp1);
            bgPaletteIndex     = state.bgPaletteIndex;
            objPaletteIndex    = state.objPaletteIndex;
            hdmaSourceHighByte = state.hdmaSourceHighByte;
            hdmaSourceLowByte  = state.hdmaSourceLowByte;
            hdmaDestHighByte   = state.hdmaDestHighByte;
            hdmaDestLowByte    = state.hdmaDestLowByte;
            hdmaLenghtCounter  = state.hdmaLenghtCounter;
            hdmaDuringHblank   = state.hdmaDuringHblank;
            hdmaSource         = state.hdmaSource;
            hdmaDest           = state.hdmaDest;
            lcd_clockcount     = state.lcd_clockcount;
            InVblank_interrupt = state.InVblank_interrupt;
            _frameready        = state._frameready;
        }