Esempio n. 1
0
void HuCClose(void)
{
 if(IsPopulous)
 {
  MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 6, ROMSpace + 0x40 * 8192, 32768);
 }
 else if(IsBRAMUsed())
 {
  MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 0, SaveRAM, 2048);
 }

 if(arcade_card)
 {
  delete arcade_card;
  arcade_card = NULL;
 }

 if(PCE_IsCD)
 {
  PCECD_Close();
 }

 if(HuCROM)
 {
  MDFN_free(HuCROM);
  HuCROM = NULL;
 }
}
Esempio n. 2
0
void MDFN_BackupSavFile(const uint8 max_backup_count, const char* sav_ext)
{
    FileStream cts(MDFN_MakeFName(MDFNMKF_SAVBACK, -1, sav_ext), FileStream::MODE_READ_WRITE, true);
    std::unique_ptr<MemoryStream> tmp;
    uint8 counter = max_backup_count - 1;

    cts.read(&counter, 1, false);
//
//
    try
    {
        tmp.reset(new MemoryStream(new FileStream(MDFN_MakeFName(MDFNMKF_SAV, 0, sav_ext), FileStream::MODE_READ)));
    }
    catch(MDFN_Error& e)
    {
        if(e.GetErrno() == ENOENT)
            return;

        throw;
    }
//
//
//
    {
        try
        {
            MemoryStream oldbks(new GZFileStream(MDFN_MakeFName(MDFNMKF_SAVBACK, counter, sav_ext), GZFileStream::MODE::READ));

            if(oldbks.size() == tmp->size() && !memcmp(oldbks.map(), tmp->map(), oldbks.size()))
            {
                //puts("Skipped backup.");
                return;
            }
        }
        catch(MDFN_Error& e)
        {
            if(e.GetErrno() != ENOENT)
                throw;
        }
        //
        counter = (counter + 1) % max_backup_count;
        //
        GZFileStream bks(MDFN_MakeFName(MDFNMKF_SAVBACK, counter, sav_ext), GZFileStream::MODE::WRITE, 9);

        bks.write(tmp->map(), tmp->size());

        bks.close();
    }

//
//
    cts.rewind();
    cts.write(&counter, 1);
    cts.close();
}
Esempio n. 3
0
void MDFNI_SaveSnapshot(const MDFN_Surface *src, const MDFN_Rect *rect, const MDFN_Rect *LineWidths)
{
#ifndef WII
  FileWrapper *pp = NULL;

  try
  {
    std::string fn;
    int u = 0;

    try
    {
      pp = new FileWrapper(MDFN_MakeFName(MDFNMKF_SNAP_DAT, 0, NULL).c_str(), FileWrapper::MODE_READ);
    }
    catch(std::exception &e)
    {

    }

    if(pp)
    {
      if(pp->scanf("%d", &u) != 1)
        u = 0;

      delete pp;
      pp = NULL;
    }

    pp = new FileWrapper(MDFN_MakeFName(MDFNMKF_SNAP_DAT, 0, NULL).c_str(), FileWrapper::MODE_WRITE);

    pp->seek(0, SEEK_SET);
    pp->printf("%d\n", u + 1);

    delete pp;
    pp = NULL;

    fn = MDFN_MakeFName(MDFNMKF_SNAP, u, "png");

    PNGWrite(fn.c_str(), src, *rect, LineWidths);

    MDFN_DispMessage(_("Screen snapshot %d saved."), u);
  }
  catch(std::exception &e)
  {
    if(pp)
    {
      delete pp;
      pp = NULL;
    }

    MDFN_PrintError(_("Error saving screen snapshot: %s"), e.what());
    MDFN_DispMessage(_("Error saving screen snapshot: %s"), e.what());
  }
#endif
}
Esempio n. 4
0
void HuC_SaveNV(void)
{
 if(IsPopulous)
 {
  MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav"), ROMSpace + 0x40 * 8192, 32768);
 }
 else if(IsBRAMUsed())
 {
  MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav"), SaveRAM, 2048);
 }
}
Esempio n. 5
0
int MDFNSS_Load(const char *fname, const char *suffix)
{
	gzFile st;

	if(!MDFNGameInfo->StateAction)
	{
		MDFN_DispMessage("Module \"%s\" doesn't support save states.", MDFNGameInfo->shortname);
		return(0);
	}

	if(fname)
		st=gzopen(fname, "rb");
	else
	{
		st=gzopen(MDFN_MakeFName(MDFNMKF_STATE,CurrentState,suffix).c_str(),"rb");
	}

	if(st == NULL)
	{
		if(!fname && !suffix)
		{
			MDFN_DispMessage("State %d load error.",CurrentState);
			SaveStateStatus[CurrentState]=0;
		}
		return(0);
	}

	if(MDFNSS_LoadFP(st))
	{
		MDFNI_DisplayState();

		if(!fname && !suffix)
		{
			LoadStateMovie((char*)MDFN_MakeFName(MDFNMKF_STATE,CurrentState,suffix).c_str());
			SaveStateStatus[CurrentState]=1;
			MDFN_DispMessage("State %d loaded.",CurrentState);
			SaveStateStatus[CurrentState]=1;
		}
		gzclose(st);
		return(1);
	}
	else
	{
		SaveStateStatus[CurrentState]=1;
		MDFN_DispMessage("State %d read error!",CurrentState);
		gzclose(st);
		return(0);
	}
}
Esempio n. 6
0
void system_io_flash_write(uint8* buffer, uint32 bufferLength)
{
 FileStream fp(MDFN_MakeFName(MDFNMKF_SAV, 0, "flash"), FileStream::MODE_WRITE);

 fp.write(buffer, bufferLength);
 fp.close();
}
Esempio n. 7
0
static void LoadCPalette(const char *syspalname, uint8 **ptr, uint32 num_entries)
{
 std::string colormap_fn = MDFN_MakeFName(MDFNMKF_PALETTE, 0, syspalname).c_str();

 MDFN_printf(_("Loading custom palette from \"%s\"...\n"),  colormap_fn.c_str());
 MDFN_indent(1);

 try
 {
  FileStream fp(colormap_fn.c_str(), FileStream::MODE_READ);

  *ptr = new uint8[num_entries * 3];

  fp.read(*ptr, num_entries * 3);
 }
 catch(MDFN_Error &e)
 {
  MDFN_printf(_("Error: %s\n"), e.what());
  MDFN_indent(-1);

  if(e.GetErrno() != ENOENT)
   throw;

  return;
 }
 catch(std::exception &e)
 {
  MDFN_printf(_("Error: %s\n"), e.what());
  MDFN_indent(-1);
  throw;
 }

 MDFN_indent(-1);
}
Esempio n. 8
0
void MDFNI_SelectState(int w)
{
 if(w == -1) 
 {  
//  MDFND_SetStateStatus(NULL);
  return; 
 }
// MDFNI_SelectMovie(-1);

 if(w == 666 + 1)
  CurrentState = (CurrentState + 1) % 10;
 else if(w == 666 - 1)
 {
  CurrentState--;

  if(CurrentState < 0 || CurrentState > 9)
   CurrentState = 9;
 }
 else
  CurrentState = w;

// MDFN_ResetMessages();

 StateStatusStruct *status = (StateStatusStruct*)MDFN_calloc(1, sizeof(StateStatusStruct), "Save state status");
 
 memcpy(status->status, SaveStateStatus, 10 * sizeof(int));

 status->current = CurrentState;
 status->recently_saved = RecentlySavedState;

 MDFNSS_GetStateInfo(MDFN_MakeFName(MDFNMKF_STATE,CurrentState,NULL).c_str(), status);
// MDFND_SetStateStatus(status);
}  
Esempio n. 9
0
void MDFNSS_CheckStates(void)
{
	time_t last_time = 0;

        if(!MDFNGameInfo->StateAction) 
         return;


	for(int ssel = 0; ssel < 10; ssel++)
        {
	 struct stat stat_buf;

	 SaveStateStatus[ssel] = false;
	 //printf("%s\n", MDFN_MakeFName(MDFNMKF_STATE, ssel, 0).c_str());
	 if(stat(MDFN_MakeFName(MDFNMKF_STATE, ssel, 0).c_str(), &stat_buf) == 0)
	 {
	  SaveStateStatus[ssel] = true;
	  if(stat_buf.st_mtime > last_time)
	  {
	   RecentlySavedState = ssel;
	   last_time = stat_buf.st_mtime;
 	  }
	 }
        }

	CurrentState = 0;
	MDFND_SetStateStatus(NULL);
}
Esempio n. 10
0
void HuC_DumpSave(void)
{
	if(IsPopulous)
	{
	 MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 6, ROMSpace + 0x40 * 8192, 32768);
	}
	/*else if(IsTsushin && TsushinRAM)
	{
	 MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 6, TsushinRAM, 32768);
	}*/
	else if(IsBRAMUsed())
	{
	 MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 0, SaveRAM, 2048);
	 //MDFN_printf("saving BRAM to %s\n", MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str());
	}
}
Esempio n. 11
0
void MDFNI_SaveMovie(char *fname, uint32 *fb, MDFN_Rect *LineWidths)
{
    gzFile fp;

    if(current < 0)	/* Can't interrupt playback.*/
        return;

    if(current > 0)	/* Stop saving. */
    {
        StopRecording();
        return;
    }

    memset(&RewindBuffer, 0, sizeof(StateMem));
    RewindBuffer.initial_malloc = 16;

    current=CurrentMovie;

    if(fname)
        fp = gzopen(fname, "wb3");
    else
    {
        fp=gzopen(MDFN_MakeFName(MDFNMKF_MOVIE,CurrentMovie,0).c_str(),"wb3");
    }

    if(!fp) return;

    MDFNSS_SaveFP(fp, fb, LineWidths);
    gzseek(fp, 0, SEEK_END);
    gzflush(fp, Z_SYNC_FLUSH); // Flush output so that previews will still work right while
    // the movie is being recorded.  Purely cosmetic. :)
    slots[current] = fp;
    current++;
    MDFN_DispMessage(_("Movie recording started."));
}
Esempio n. 12
0
void HuC_Close(void)
{
 if(mcg)
 {
  for(unsigned i = 0; i < mcg->GetNVPDC(); i++)
  {
   uint32 nvs = mcg->GetNVSize(i);

   if(nvs)
   {
    char buf[32];
    std::vector<uint8> tmp_buf;

    tmp_buf.resize(nvs);

    mcg->ReadNV(i, &tmp_buf[0], 0, tmp_buf.size());

    trio_snprintf(buf, sizeof(buf), "mg%d", i);
    MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, buf).c_str(), 6, &tmp_buf[0], tmp_buf.size());
   }
  }
 }

 if(IsPopulous)
 {
  if(PopRAM)
  {
   MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 6, PopRAM, 32768);
  }
 }
 else if(IsTsushin)
 {
  if(TsushinRAM)
  {
   MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 6, TsushinRAM, 32768);
   MDFN_free(TsushinRAM);
   TsushinRAM = NULL;
  }
 }
 else if(!BRAM_Disabled && IsBRAMUsed())
 {
  MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 0, SaveRAM, 2048);
 }

 Cleanup();
}
Esempio n. 13
0
int MDFNSS_Save(const char *fname, const char *suffix, const MDFN_Surface *surface, const MDFN_Rect *DisplayRect, const MDFN_Rect *LineWidths)
{
	StateMem st;

	memset(&st, 0, sizeof(StateMem));


	if(!MDFNGameInfo->StateAction)
	{
		MDFN_DispMessage("Module \"%s\" doesn't support save states.", MDFNGameInfo->shortname);
		return(0);
	}

	if(!MDFNSS_SaveSM(&st, 1, 0, surface, DisplayRect, LineWidths))
	{
		if(st.data)
			free(st.data);
		if(!fname && !suffix)
			MDFN_DispMessage("State %d save error.", CurrentState);
		return(0);
	}

	if(!MDFN_DumpToFile(fname ? fname : MDFN_MakeFName(MDFNMKF_STATE,CurrentState,suffix).c_str(), 6, st.data, st.len))
	{
		SaveStateStatus[CurrentState] = 0;
		free(st.data);

		if(!fname && !suffix)
			MDFN_DispMessage("State %d save error.",CurrentState);

		return(0);
	}

	std::string bleh = MDFN_MakeFName(MDFNMKF_STATE,CurrentState,suffix);
	SaveStateMovie(bleh);

	free(st.data);

	SaveStateStatus[CurrentState] = 1;
	RecentlySavedState = CurrentState;

	if(!fname && !suffix)
		MDFN_DispMessage("State %d saved.",CurrentState);

	return(1);
}
Esempio n. 14
0
int MDFNSS_Load(const char *fname, const char *suffix)
{
	gzFile st;

	if(fname)
		st=gzopen(fname, "rb");
	else
	{
		st=gzopen(MDFN_MakeFName(MDFNMKF_STATE,CurrentState,suffix).c_str(),"rb");
	}

	if(st == NULL)
	{
		if(!fname && !suffix)
		{
			MDFN_DispMessage(_("State %d load error."),CurrentState);
			SaveStateStatus[CurrentState]=0;
		}
		return(0);
	}

	

	if(MDFNSS_LoadFP(st))
	{
		MDFNI_DisplayState();
		LoadStateMovie((char*)MDFN_MakeFName(MDFNMKF_STATE,CurrentState,suffix).c_str());
		
		if(!fname && !suffix)
		{
			SaveStateStatus[CurrentState]=1;
			MDFN_DispMessage(_("State %d loaded."),CurrentState);
			SaveStateStatus[CurrentState]=1;
		}
		gzclose(st);
		return(1);
	}
	else
	{
		SaveStateStatus[CurrentState]=1;
		MDFN_DispMessage(_("State %d read error!"),CurrentState);
		gzclose(st);
		return(0);
	}
}
Esempio n. 15
0
bool MDFNI_SaveState(const char *fname, const char *suffix, const MDFN_Surface *surface, const MDFN_Rect *DisplayRect, const int32 *LineWidths) noexcept
{
 bool ret = true;

 try
 {
  if(!MDFNGameInfo->StateAction)
  {
   throw MDFN_Error(0, _("Module \"%s\" doesn't support save states."), MDFNGameInfo->shortname);
  }

  if(MDFNnetplay && (MDFNGameInfo->SaveStateAltersState == true))
  {
   throw MDFN_Error(0, _("Module %s is not compatible with manual state saving during netplay."), MDFNGameInfo->shortname);
  }

  //
  //
  {
   MemoryStream st(65536);

   MDFNSS_SaveSM(&st, false, surface, DisplayRect, LineWidths);

   //
   //
   //
   GZFileStream gp(fname ? std::string(fname) : MDFN_MakeFName(MDFNMKF_STATE,CurrentState,suffix),
			GZFileStream::MODE::WRITE, MDFN_GetSettingI("filesys.state_comp_level"));

   gp.write(st.map(), st.size());
   gp.close();
  }

  MDFND_SetStateStatus(NULL);

  if(!fname && !suffix)
  {
   SaveStateStatus[CurrentState] = true;
   RecentlySavedState = CurrentState;
   MDFN_DispMessage(_("State %d saved."), CurrentState);
  }
 }
 catch(std::exception &e)
 {
  if(!fname && !suffix)
   MDFN_DispMessage(_("State %d save error: %s"), CurrentState, e.what());
  else
   MDFN_PrintError("%s", e.what());

  if(MDFNnetplay)
   MDFND_NetplayText(e.what(), false);

  ret = false;
 }

 return(ret);
}
Esempio n. 16
0
void MDCart_SaveNV(void)
{
 if(cart_hardware->GetNVMemorySize())
 {
  uint8 buf[cart_hardware->GetNVMemorySize()];

  cart_hardware->ReadNVMemory(buf);

  MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav"), buf, sizeof(buf), true);
 }
}
Esempio n. 17
0
int MDFNSS_Save(const char *fname, const char *suffix, uint32 *fb, MDFN_Rect *LineWidths)
{
	StateMem st;

	memset(&st, 0, sizeof(StateMem));

	if(!MDFNSS_SaveSM(&st, 1, 0, fb, LineWidths))
	{
		if(st.data)
			free(st.data);
		if(!fname && !suffix)
			MDFN_DispMessage(_("State %d save error."), CurrentState);
		return(0);
	}

	if(!MDFN_DumpToFile(fname ? fname : MDFN_MakeFName(MDFNMKF_STATE,CurrentState,suffix).c_str(), 6, st.data, st.len))
	{
		SaveStateStatus[CurrentState] = 0;
		free(st.data);

		if(!fname && !suffix)
			MDFN_DispMessage(_("State %d save error."),CurrentState);

		return(0);
	}

	SaveStateMovie((const char*)MDFN_MakeFName(MDFNMKF_STATE,CurrentState,suffix).c_str());

	free(st.data);

	SaveStateStatus[CurrentState] = 1;
	RecentlySavedState = CurrentState;

	if(!fname && !suffix)
		MDFN_DispMessage(_("State %d saved."),CurrentState);

	return(1);
}
Esempio n. 18
0
void HuC_SaveNV(void)
{
 if(mcg)
 {
  for(unsigned i = 0; i < mcg->GetNVPDC(); i++)
  {
   uint32 nvs = mcg->GetNVSize(i);

   if(nvs)
   {
    char buf[32];

    trio_snprintf(buf, sizeof(buf), "mg%d", i);
    MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, buf), mcg->ReadNV(i), nvs);
   }
  }
 }

 if(IsPopulous)
 {
  if(PopRAM)
  {
   MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav"), PopRAM, 32768);
  }
 }
 else if(IsTsushin)
 {
  if(TsushinRAM)
  {
   MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav"), TsushinRAM, 32768);
  }
 }
 else if(!BRAM_Disabled && IsBRAMUsed())
 {
  MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav"), SaveRAM, 2048);
 }
}
Esempio n. 19
0
static bool LoadCPalette(const char *syspalname, uint8 **ptr, uint32 num_entries)
{
 std::string colormap_fn = MDFN_MakeFName(MDFNMKF_PALETTE, 0, syspalname).c_str();

 MDFN_printf(_("Loading custom palette from \"%s\"...\n"),  colormap_fn.c_str());
 MDFN_indent(1);

 *ptr = NULL;
 try
 {
  FileStream fp(colormap_fn.c_str(), FileStream::MODE_READ);

  if(!(*ptr = (uint8 *)MDFN_malloc(num_entries * 3, _("custom color map"))))
  {
   MDFN_indent(-1);
   return(false);
  }

  fp.read(*ptr, num_entries * 3);
 }
 catch(MDFN_Error &e)
 {
  if(*ptr)
  {
   MDFN_free(*ptr);
   *ptr = NULL;
  }

  MDFN_printf(_("Error: %s\n"), e.what());
  MDFN_indent(-1);
  return(e.GetErrno() == ENOENT);        // Return fatal error if it's an error other than the file not being found.
 }
 catch(std::exception &e)
 {
  if(*ptr)
  {
   MDFN_free(*ptr);
   *ptr = NULL;
  }

  MDFN_printf(_("Error: %s\n"), e.what());
  MDFN_indent(-1);
  return(false);
 }

 MDFN_indent(-1);

 return(true);
}
Esempio n. 20
0
bool system_io_flash_write(uint8* buffer, uint32 bufferLength)
{
 try
 {
  FileStream fp(MDFN_MakeFName(MDFNMKF_SAV, 0, "flash").c_str(), FileStream::MODE_WRITE);

  fp.write(buffer, bufferLength);
 }
 catch(std::exception &e)
 {
  return(0);
 }

 return(1);
}
Esempio n. 21
0
bool system_io_flash_read(uint8* buffer, uint32 bufferLength)
{
 try
 {
  FileStream fp(MDFN_MakeFName(MDFNMKF_SAV, 0, "flash").c_str(), FileStream::MODE_READ);

  fp.read(buffer, bufferLength);
 }
 catch(std::exception &e)
 {
  //if(ene.Errno() == ENOENT)  . asdf
  return(0);
 }

 return(1);
}
Esempio n. 22
0
void MDFNI_SaveMovie(char *fname, const MDFN_Surface *surface, const MDFN_Rect *DisplayRect, const int32 *LineWidths)
{
 gzFile fp;

 if(!MDFNGameInfo->StateAction)
  return;

 if(MDFNnetplay && (MDFNGameInfo->SaveStateAltersState == true))
 {
  char sb[256];
  trio_snprintf(sb, sizeof(sb), _("Module %s is not compatible with manual movie save starting/stopping during netplay."), MDFNGameInfo->shortname);
  MDFND_NetplayText((const uint8*)sb, false);
  return;
 }

 if(current < 0)	/* Can't interrupt playback.*/
  return;

 if(current > 0)	/* Stop saving. */
 {
  StopRecording();
  return;  
 }

 memset(&RewindBuffer, 0, sizeof(StateMem));
 RewindBuffer.initial_malloc = 16;

 current = CurrentMovie;

 if(fname)
  fp = gzopen(fname, "wb3");
 else
 {
  fp=gzopen(MDFN_MakeFName(MDFNMKF_MOVIE,CurrentMovie,0).c_str(),"wb3");
 }

 if(!fp) return;

 MDFNSS_SaveFP(fp, surface, DisplayRect, LineWidths);
 gzseek(fp, 0, SEEK_END);
 gzflush(fp, Z_SYNC_FLUSH); // Flush output so that previews will still work right while
			    // the movie is being recorded.  Purely cosmetic. :)
 slots[current] = fp;
 current++;
 MDFN_DispMessage(_("Movie recording started."));
}
Esempio n. 23
0
static int LoadCD(std::vector<CDIF *> *CDInterfaces)
{
 std::string bios_path = MDFN_MakeFName(MDFNMKF_FIRMWARE, 0, MDFN_GetSettingS("pce_fast.cdbios").c_str() );

 //IsHES = 0;
 IsSGX = 0;

 LoadCommonPre();

 if(!HuCLoadCD(bios_path.c_str()))
  return(0);

 SCSICD_SetDisc(true, NULL, true);
 SCSICD_SetDisc(false, (*CDInterfaces)[0], true);

 return(LoadCommon());
}
Esempio n. 24
0
bool system_io_flash_read(uint8* buffer, uint32 bufferLength)
{
 try
 {
  FileStream fp(MDFN_MakeFName(MDFNMKF_SAV, 0, "flash"), FileStream::MODE_READ);

  fp.read(buffer, bufferLength);
 }
 catch(MDFN_Error &e)
 {
  if(e.GetErrno() == ENOENT)
   return(false);
  else
   throw;
 }

 return(true);
}
Esempio n. 25
0
void MDCart_LoadNV(void)
{
 if(cart_hardware->GetNVMemorySize())
 {
  try
  {
   uint8 buf[cart_hardware->GetNVMemorySize()];
   std::unique_ptr<Stream> sp = MDFN_AmbigGZOpenHelper(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), std::vector<size_t>({ sizeof(buf) }));

   sp->read(buf, sizeof(buf));
   cart_hardware->WriteNVMemory(buf);
  }
  catch(MDFN_Error &e)
  {
   if(e.GetErrno() != ENOENT)
    throw;
  }
 }
}
Esempio n. 26
0
void MDFNI_LoadMovie(char *fname)
{
    gzFile fp;
//puts("KAO");

    if(current > 0)        /* Can't interrupt recording.*/
        return;
#ifdef NETWORK
    if(MDFNnetplay)	/* Playback is UNPOSSIBLE during netplay. */
    {
        MDFN_DispMessage(_("Can't play movies during netplay."));
        return;
    }
#endif

    if(current < 0)        /* Stop playback. */
    {
        StopPlayback();
        return;
    }

    if(fname)
        fp = gzopen(fname, "rb");
    else
    {
        fp=gzopen(MDFN_MakeFName(MDFNMKF_MOVIE,CurrentMovie,0).c_str(),"rb");
    }

    if(!fp) return;

    if(!MDFNSS_LoadFP(fp))
    {
        MDFN_DispMessage(_("Error loading state portion of the movie."));
        return;
    }
    current = CurrentMovie;
    slots[current] = fp;

    current = -1 - current;
    MovieStatus[CurrentMovie] = 1;
    MDFN_DispMessage(_("Movie playback started."));
}
Esempio n. 27
0
void MDFNI_DisplayState()
{
	gzFile fp;

	fp = gzopen(MDFN_MakeFName(MDFNMKF_STATE,CurrentState,NULL).c_str(),"rb");
	if(fp)
	{
		uint8 header[32];

		gzread(fp, header, 32);
		uint32 width = MDFN_de32lsb(header + 24);
		uint32 height = MDFN_de32lsb(header + 28);

		uint8 *previewbuffer = (uint8*)alloca(3 * width * height);

		gzread(fp, espec.pixels, 17 * width * height);

		gzclose(fp);
	}
}  
Esempio n. 28
0
static MDFN_COLD void LoadCD(std::vector<CDIF *> *CDInterfaces)
{
 try
 {
	 std::string bios_path = MDFN_MakeFName(MDFNMKF_FIRMWARE, 0, MDFN_GetSettingS("pce_fast.cdbios"));

	 //IsHES = 0;
	 IsSGX = 0;

	 LoadCommonPre();

	 HuC_LoadCD(bios_path.c_str());

	 cdifs = CDInterfaces;
	 PCECD_Drive_SetDisc(true, NULL, true);

	 LoadCommon();
 }
 catch(...)
 {
	 Cleanup();
	 throw;
 }
}
Esempio n. 29
0
void HuC_LoadCD(const char *bios_path)
{
 static const FileExtensionSpecStruct KnownBIOSExtensions[] =
 {
  { ".pce", gettext_noop("PC Engine ROM Image") },
  { ".bin", gettext_noop("PC Engine ROM Image") },
  { ".bios", gettext_noop("BIOS Image") },
  { NULL, NULL }
 };

 try
 {
	 MDFNFILE fp(bios_path, KnownBIOSExtensions, _("CD BIOS"));

	 memset(ROMSpace, 0xFF, 262144);

	 memcpy(ROMSpace, fp.Data() + (fp.Size() & 512), ((fp.Size() & ~512) > 262144) ? 262144 : (fp.Size() &~ 512) );

	 fp.Close();

	 PCE_IsCD = 1;
	 PCE_InitCD();

	 md5_context md5;
	 md5.starts();
	 // md5_update(&md5, HuCROM, 262144);

	 #if 0
	 int32 track = CDIF_GetFirstTrack();
	 int32 last_track = CDIF_GetLastTrack();
	 bool DTFound = 0;
	 for(; track <= last_track; track++)
	 {
		CDIF_Track_Format format;

		if(CDIF_GetTrackFormat(track, format) && format == CDIF_FORMAT_MODE1)
		{
		 DTFound = 1;
		 break;
		}
	 }

	 if(DTFound) // Only add the MD5 hash if we were able to find a data track.
	 {
		uint32 start_sector = CDIF_GetTrackStartPositionLBA(track);
		uint8 sector_buffer[2048];

		for(int x = 0; x < 128; x++)
		{
		 memset(sector_buffer, 0, 2048);
		 CDIF_ReadSector(sector_buffer, NULL, start_sector + x, 1);
		 md5.update(sector_buffer, 2048);
		}
	 }
	 md5.finish(MDFNGameInfo->MD5);
	 MDFN_printf(_("CD MD5(first 256KiB):   0x%s\n"), md5_context::asciistr(MDFNGameInfo->MD5, 0).c_str());
	 #endif

	 MDFN_printf(_("Arcade Card Emulation:  %s\n"), PCE_ACEnabled ? _("Enabled") : _("Disabled"));
	 for(int x = 0; x < 0x40; x++)
	 {
		HuCPUFastMap[x] = ROMSpace;
		PCERead[x] = HuCRead;
	 }

	 for(int x = 0x68; x < 0x88; x++)
	 {
		HuCPUFastMap[x] = ROMSpace;
		PCERead[x] = HuCRead;
		PCEWrite[x] = HuCRAMWrite;
	 }
	 PCEWrite[0x80] = HuCRAMWriteCDSpecial; 	// Hyper Dyne Special hack
	 MDFNMP_AddRAM(262144, 0x68 * 8192, ROMSpace + 0x68 * 8192);

	 if(PCE_ACEnabled)
	 {
			arcade_card = new ArcadeCard();

		for(int x = 0x40; x < 0x44; x++)
		{
		 HuCPUFastMap[x] = NULL;
		 PCERead[x] = ACPhysRead;
		 PCEWrite[x] = ACPhysWrite;
		}
	 }

	 gzFile srp;

	 memset(SaveRAM, 0x00, 2048);
	 memcpy(SaveRAM, BRAM_Init_String, 8);	// So users don't have to manually intialize the file cabinet
							// in the CD BIOS screen.

	 if((srp = gzopen(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), "rb")))
	 {
		gzread(srp, SaveRAM, 2048);
		gzclose(srp);
	 }
	 PCEWrite[0xF7] = SaveRAMWrite;
	 PCERead[0xF7] = SaveRAMRead;
	 MDFNMP_AddRAM(2048, 0xF7 * 8192, SaveRAM);
 }
 catch(...)
 {
  Cleanup();
  throw;
 }
}
Esempio n. 30
0
	static int								ModuleLoad				()
	{
		//Load the BIOS
		MDFNFILE biosFile;
		if(biosFile.Open(MDFN_MakeFName(MDFNMKF_FIRMWARE, 0, MDFN_GetSettingS("pcsxr.bios").c_str()).c_str(), 0))
		{
			if(biosFile.size == 512 * 1024)
			{
				memcpy(BiosBuffer, biosFile.data, 512 * 1024);
			}
			else
			{
				MDFN_printf("pcsxr: BIOS file size incorrect\n");
			}
		}
		else
		{
			MDFN_printf("pcsxr: Failed to load bios\n");
			return 0;
		}
	
		//Setup the config structure
		memset(&Config, 0, sizeof(Config));
		Config.PsxAuto = 1;
		Config.Cpu = MDFN_GetSettingB("pcsxr.recompiler") ? CPU_DYNAREC : CPU_INTERPRETER;
		Config.SlowBoot = MDFN_GetSettingB("pcsxr.slowboot");
		strcpy(Config.PluginsDir, "builtin");
		strcpy(Config.Gpu, "builtin");
		strcpy(Config.Spu, "builtin");
		strcpy(Config.Pad1, "builtin");
		strcpy(Config.Pad2, "builtin");
		strcpy(Config.Cdr, "builtin");
		strcpy(Config.Net, "Disabled");
		strncpy(Config.Mcd1, MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), MAXPATHLEN);
		strncpy(Config.Mcd2, MDFN_MakeFName(MDFNMKF_SAV, 0, "sav2").c_str(), MAXPATHLEN);

		//Init psx cpu emulator and memory mapping
		EmuInit();

		//Open and initialize all of the plugins
		OpenPlugins();

		//Load memory cards
		LoadMcds(Config.Mcd1, Config.Mcd2);

		//Get cdrom ID and init PPF support...
		CheckCdrom();

		//Reset the emulated CPU and Memory
		EmuReset();

		//Prepares the game to run, either runs the CPU thru the bios or finds and loads the game EXE if using the emulated bios
		LoadCdrom();

		//TODO: Set the clock if the machine is PAL

		//Just say two 1M pages, for fun not profit
		MDFNMP_Init(1024 * 1024, 2);
		MDFNMP_AddRAM(1024 * 1024 * 2, 0, (uint8_t*)psxM);

		return 1;
	}