コード例 #1
0
ファイル: freeze.cpp プロジェクト: feraligatr/snes9xgx
/****************************************************************************
 * NGCFreezeMembuffer
 *
 * Copies a snapshot of Snes9x state into memory
 ***************************************************************************/
static int
NGCFreezeMemBuffer ()
{
    int i;
    char buffer[1024];

    bufoffset = 0;

    S9xUpdateRTC ();
    S9xSRTCPreSaveState ();

    for (i = 0; i < 8; i++)
    {
        SoundData.channels[i].previous16[0] =
        (int16) SoundData.channels[i].previous[0];
        SoundData.channels[i].previous16[1] =
        (int16) SoundData.channels[i].previous[1];
    }

    sprintf (buffer, "%s:%04d\n", SNAPSHOT_MAGIC, SNAPSHOT_VERSION);
    PutMem (buffer, strlen (buffer));
    sprintf (buffer, "NAM:%06d:%s%c", (int) strlen (Memory.ROMFilename) + 1,
    Memory.ROMFilename, 0);

    PutMem (buffer, strlen (buffer) + 1);

    NGCFreezeStruct ();

    return 0;
}
コード例 #2
0
static void Freeze()
{
   char buffer[1024];
   int i;

   S9xSetSoundMute(TRUE);

   S9xSRTCPreSaveState();

   for (i = 0; i < 8; i++)
   {
      SoundData.channels [i].previous16 [0] = (int16) SoundData.channels [i].previous [0];
      SoundData.channels [i].previous16 [1] = (int16) SoundData.channels [i].previous [1];
   }
   sprintf(buffer, "%s:%04d\n", SNAPSHOT_MAGIC, SNAPSHOT_VERSION);
   statef_write(buffer, strlen(buffer));
   sprintf(buffer, "NAM:%06d:%s%c", strlen(Memory.ROMFilename) + 1,
           Memory.ROMFilename, 0);
   statef_write(buffer, strlen(buffer) + 1);
   FreezeStruct("CPU", &CPU, SnapCPU, COUNT(SnapCPU));
   FreezeStruct("REG", &Registers, SnapRegisters, COUNT(SnapRegisters));
   FreezeStruct("PPU", &PPU, SnapPPU, COUNT(SnapPPU));
   FreezeStruct("DMA", DMA, SnapDMA, COUNT(SnapDMA));

   // RAM and VRAM
   FreezeBlock("VRA", Memory.VRAM, 0x10000);
   FreezeBlock("RAM", Memory.RAM, 0x20000);
   FreezeBlock("SRA", SRAM, 0x20000);
   FreezeBlock("FIL", Memory.FillRAM, 0x8000);
   if (Settings.APUEnabled)
   {
      // APU
      FreezeStruct("APU", &APU, SnapAPU, COUNT(SnapAPU));
      // copy all SPC700 regs to savestate compatible struct
      SAPURegisters spcregs;
      spcregs.P  = IAPU.P;
      spcregs.YA.W = IAPU.YA.W;
      spcregs.X  = IAPU.X;
      spcregs.S  = IAPU.S;
      spcregs.PC = IAPU.PC - IAPU.RAM;
      FreezeStruct("ARE", &spcregs, SnapAPURegisters,
                   COUNT(SnapAPURegisters));

      FreezeBlock("ARA", IAPU.RAM, 0x10000);
      FreezeStruct("SOU", &SoundData, SnapSoundData,
                   COUNT(SnapSoundData));
   }
#ifdef USE_SA1
   if (Settings.SA1)
   {
      SA1Registers.PC = SA1.PC - SA1.PCBase;
      S9xSA1PackStatus();
      FreezeStruct("SA1", &SA1, SnapSA1, COUNT(SnapSA1));
      FreezeStruct("SAR", &SA1Registers, SnapSA1Registers,
                   COUNT(SnapSA1Registers));
   }
#endif
   S9xSetSoundMute(FALSE);
}
コード例 #3
0
ファイル: snes.cpp プロジェクト: plasma-apps/emumaster
void SnesEmu::sl() {
	if (emsl.save) {
		S9xSRTCPreSaveState();
	} else {
		S9xReset();
	}
	snesCpuSl();
	snesMemSl();
	snesPpuSl();
	snesDmaSl();
	snesSoundSl();
	snesSpuSl();
	if (!emsl.save) {
		S9xFixSoundAfterSnapshotLoad();
		S9xSetPCBase(ICPU.ShiftedPB + Registers.PC);
		S9xReschedule();
		S9xSRTCPostLoadState();
		if (Settings.SDD1)
			S9xSDD1PostLoadState();
		S9xSetSoundMute(FALSE);
	}
}