コード例 #1
0
void savestates_save()
{
   char *filename, buf[1024];
   gzFile f;
   int len, i;
   
   if (*autoinc_save_slot)
     {
	if (++slot == 10)
	  {
	     slot = 0;
	  }
     }
   
   if (slot <= 9)
     {
	filename = malloc(strlen(get_savespath())+
			  strlen(ROM_SETTINGS.goodname)+4+1);
	strcpy(filename, get_savespath());
	strcat(filename, ROM_SETTINGS.goodname);
	strcat(filename, ".st");
	sprintf(buf, "%d", slot);
	strcat(filename, buf);
     }
   else
     {
	filename = malloc(strlen(fname)+1);
	strcpy(filename, fname);
	slot -= 10;
     }
   	
   f = gzopen(filename, "wb");
   free(filename);
   
   gzwrite(f, ROM_SETTINGS.MD5, 32);
   
   gzwrite(f, &rdram_register, sizeof(RDRAM_register));
   gzwrite(f, &MI_register, sizeof(mips_register));
   gzwrite(f, &pi_register, sizeof(PI_register));
   gzwrite(f, &sp_register, sizeof(SP_register));
   gzwrite(f, &rsp_register, sizeof(RSP_register));
   gzwrite(f, &si_register, sizeof(SI_register));
   gzwrite(f, &vi_register, sizeof(VI_register));
   gzwrite(f, &ri_register, sizeof(RI_register));
   gzwrite(f, &ai_register, sizeof(AI_register));
   gzwrite(f, &dpc_register, sizeof(DPC_register));
   gzwrite(f, &dps_register, sizeof(DPS_register));
   
   gzwrite(f, rdram, 0x800000);
   gzwrite(f, SP_DMEM, 0x1000);
   gzwrite(f, SP_IMEM, 0x1000);
   gzwrite(f, PIF_RAM, 0x40);

   save_flashram_infos(buf);
   gzwrite(f, buf, 24);
   
   gzwrite(f, tlb_LUT_r, 0x100000);
   gzwrite(f, tlb_LUT_w, 0x100000);
   
   gzwrite(f, &llbit, 4);
   gzwrite(f, reg, 32*8);
   for (i=0; i<32; i++) gzwrite(f, reg_cop0+i, 8); // *8 for compatibility with old versions purpose
   gzwrite(f, &lo, 8);
   gzwrite(f, &hi, 8);
   gzwrite(f, reg_cop1_fgr_64, 32*8);
   gzwrite(f, &FCR0, 4);
   gzwrite(f, &FCR31, 4);
   gzwrite(f, tlb_e, 32*sizeof(tlb));
   if (!dynacore && interpcore) gzwrite(f, &interp_addr, 4);
   else gzwrite(f, &PC->addr, 4);
   
   gzwrite(f, &next_interupt, 4);
   gzwrite(f, &next_vi, 4);
   gzwrite(f, &vi_field, 4);
   
   len = save_eventqueue_infos(buf);
   gzwrite(f, buf, len);
   
   gzclose(f);
}
コード例 #2
0
ファイル: savestates.c プロジェクト: anta-/mupen64-rr-lua-
void savestates_save()
{
	char *filename, buf[1024];
	gzFile f;
	int len, i, filename_f = 0;
   
	savestates_job_success = TRUE;
   
	if (*autoinc_save_slot)
	{
		if (++slot == 10)
		{
			slot = 0;
		}
	}
   
	if (slot <= 9)
	{
		filename = (char*)malloc(strlen(get_savespath())+
		strlen(ROM_SETTINGS.goodname)+4+1);
		strcpy(filename, get_savespath());
		strcat(filename, ROM_SETTINGS.goodname);
		strcat(filename, ".st");
		sprintf(buf, "%d", slot);
		strcat(filename, buf);
	}
	else
	{
		filename = (char*)malloc(strlen(fname)+1);
		strcpy(filename, fname);
		slot -= 10;
		filename_f = 1;
	}

	{
		char str [256];
		if(filename_f)
			sprintf(str, "saving %-200s", filename);
		else
			sprintf(str, "saving slot %d", slot);
		display_status(str);
	}
   	
	f = gzopen(filename, "wb");
	free(filename);
   
	gzwrite(f, ROM_SETTINGS.MD5, 32);
   
	gzwrite(f, &rdram_register, sizeof(RDRAM_register));
	gzwrite(f, &MI_register, sizeof(mips_register));
	gzwrite(f, &pi_register, sizeof(PI_register));
	gzwrite(f, &sp_register, sizeof(SP_register));
	gzwrite(f, &rsp_register, sizeof(RSP_register));
	gzwrite(f, &si_register, sizeof(SI_register));
	gzwrite(f, &vi_register, sizeof(VI_register));
	gzwrite(f, &ri_register, sizeof(RI_register));
	gzwrite(f, &ai_register, sizeof(AI_register));
	gzwrite(f, &dpc_register, sizeof(DPC_register));
	gzwrite(f, &dps_register, sizeof(DPS_register));
	gzwrite(f, rdram, 0x800000);
	gzwrite(f, SP_DMEM, 0x1000);
	gzwrite(f, SP_IMEM, 0x1000);
	gzwrite(f, PIF_RAM, 0x40);

	save_flashram_infos(buf);
	gzwrite(f, buf, 24);
   
	gzwrite(f, tlb_LUT_r, 0x400000);
	gzwrite(f, tlb_LUT_w, 0x400000);
   
	gzwrite(f, &llbit, 4);
	gzwrite(f, reg, 32*8);
	for (i=0; i<32; i++)
		gzwrite(f, reg_cop0+i, 8); // *8 for compatibility with old versions purpose
	gzwrite(f, &lo, 8);
	gzwrite(f, &hi, 8);
	gzwrite(f, reg_cop1_fgr_64, 32*8);
	gzwrite(f, &FCR0, 4);
	gzwrite(f, &FCR31, 4);
	gzwrite(f, tlb_e, 32*sizeof(tlb));
	if (!dynacore && interpcore) 
		gzwrite(f, &interp_addr, 4);
	else 
		gzwrite(f, &PC->addr, 4);
   
	gzwrite(f, &next_interupt, 4);
	gzwrite(f, &next_vi, 4);
	gzwrite(f, &vi_field, 4);
   
	len = save_eventqueue_infos(buf);
	gzwrite(f, buf, len);

	// re-recording
	BOOL movieActive = VCR_isActive();
	gzwrite(f, &movieActive, sizeof(movieActive));
	if(movieActive)
	{
		char* movie_freeze_buf = NULL;
		unsigned long movie_freeze_size = 0;

		VCR_movieFreeze(&movie_freeze_buf, &movie_freeze_size);
		if(movie_freeze_buf)
		{
			gzwrite(f, &movie_freeze_size, sizeof(movie_freeze_size));
			gzwrite(f, movie_freeze_buf, movie_freeze_size);
			free(movie_freeze_buf);
		}
		else
		{
			fprintf(stderr, "Failed to save movie snapshot.\n");
			savestates_job_success = FALSE;
		}
	}
	// /re-recording

	gzclose(f);
}
コード例 #3
0
ファイル: savestates_gc.c プロジェクト: RDCH106/Not64
void savestates_save()
{ 
  gzFile f;
	char *filename, buf[1024];
  int len, i;
	
  /* fix the filename to %s.st%d format */
  filename = malloc(1024);
  sprintf(filename, "%s%s%s%s.st%d",(saveStateDevice==SAVESTATEDEVICE_USB)?"usb:":"sd:",
                           statespath, ROM_SETTINGS.goodname, saveregionstr(),savestates_slot);

	f = gzopen(filename, "wb");
  free(filename);
   	
  if(!f) {
  	return;
	}
  if(stop) {
	  pauseRemovalThread();
  }
  else {
    pauseAudio();
  }  
  gzwrite(f, &rdram_register, sizeof(RDRAM_register));
	gzwrite(f, &MI_register, sizeof(mips_register));
	gzwrite(f, &pi_register, sizeof(PI_register));
	gzwrite(f, &sp_register, sizeof(SP_register));
	gzwrite(f, &rsp_register, sizeof(RSP_register));
	gzwrite(f, &si_register, sizeof(SI_register));
	gzwrite(f, &vi_register, sizeof(VI_register));
	gzwrite(f, &ri_register, sizeof(RI_register));
	gzwrite(f, &ai_register, sizeof(AI_register));
	gzwrite(f, &dpc_register, sizeof(DPC_register));
	gzwrite(f, &dps_register, sizeof(DPS_register));
#ifdef USE_EXPANSION
	gzwrite(f, rdram, 0x800000);
#else
  gzwrite(f, rdram, 0x400000);
#endif
	gzwrite(f, SP_DMEM, 0x1000);
	gzwrite(f, SP_IMEM, 0x1000);
	gzwrite(f, PIF_RAM, 0x40);
	
	save_flashram_infos(buf);
	gzwrite(f, buf, 24);
#ifndef USE_TLB_CACHE
	gzwrite(f, tlb_LUT_r, 0x100000);		
	gzwrite(f, tlb_LUT_w, 0x100000);
#else
	//Traverse the TLB cache hash	and dump it
  TLBCache_dump_r(f);
	TLBCache_dump_w(f);
#endif

	gzwrite(f, &llbit, 4);
	gzwrite(f, reg, 32*8);
	for (i=0; i<32; i++) gzwrite(f, reg_cop0+i, 8); // *8 for compatibility with old versions purpose
	gzwrite(f, &lo, 8);
	gzwrite(f, &hi, 8);

	if ((Status & 0x04000000) == 0)
	{   // FR bit == 0 means 32-bit (MIPS I) FGR mode
		shuffle_fpr_data(0, 0x04000000);  // shuffle data into 64-bit register format for storage
		gzwrite(f, reg_cop1_fgr_64, 32*8);
		shuffle_fpr_data(0x04000000, 0);  // put it back in 32-bit mode
	}
	else
	{
		gzwrite(f, reg_cop1_fgr_64, 32*8);
	}

	gzwrite(f, &FCR0, 4);
	gzwrite(f, &FCR31, 4);
	gzwrite(f, tlb_e, 32*sizeof(tlb));
	gzwrite(f, &interp_addr, 4);    //Dynarec should be ok with just this

	gzwrite(f, &next_interupt, 4);
	gzwrite(f, &next_vi, 4);
	gzwrite(f, &vi_field, 4);
	
	len = save_eventqueue_infos(buf);
	gzwrite(f, buf, len);
	
	gzclose(f);
	if(stop) {
	  continueRemovalThread();
  }
  else {
    resumeAudio();
  }
}