Exemplo n.º 1
0
int FCEUSS_SaveFP(MEM_TYPE *st) {
	static uint32 totalsize;
	uint8 header[16] = { 0 };

	header[0] = 'F';
	header[1] = 'C';
	header[2] = 'S';
	header[3] = 0xFF;

	header[3] = 0xFF;
	FCEU_en32lsb(header + 8, FCEU_VERSION_NUMERIC);
	fwrite(header, 1, 16, st);
	FCEUPPU_SaveState();
	FCEUSND_SaveState();
	totalsize = WriteStateChunk(st, 1, SFCPU);
	totalsize += WriteStateChunk(st, 2, SFCPUC);
	totalsize += WriteStateChunk(st, 3, FCEUPPU_STATEINFO);
	totalsize += WriteStateChunk(st, 4, FCEUCTRL_STATEINFO);
	totalsize += WriteStateChunk(st, 5, FCEUSND_STATEINFO);
	if (SPreSave) SPreSave();
	totalsize += WriteStateChunk(st, 0x10, SFMDATA);
	if (SPreSave) SPostSave();

	fseek(st, 4, SEEK_SET);
	write32le(totalsize, st);
	return(1);
}
Exemplo n.º 2
0
void FCEU_Guid::scan(std::string& str)
{
	char* endptr = (char*)str.c_str();
	FCEU_en32lsb(data,strtoul(endptr,&endptr,16));
	FCEU_en16lsb(data+4,strtoul(endptr+1,&endptr,16));
	FCEU_en16lsb(data+6,strtoul(endptr+1,&endptr,16));
	FCEU_en16lsb(data+8,strtoul(endptr+1,&endptr,16));
	endptr++;
	for(int i=0;i<6;i++)
		data[10+i] = hexToByte(&endptr);
}
Exemplo n.º 3
0
int FCEUNET_SendCommand(uint8 cmd, uint32 len)
{
 uint8 buf[numlocal + 1 + 4];

 buf[0] = 0xFF;
 FCEU_en32lsb(&buf[numlocal], len);
 buf[numlocal + 4] = cmd;
 #ifdef NETWORK
 if(!FCEUD_SendData(buf,numlocal + 1 + 4))
 {
  NetError();
  return(0);
 }
 #endif
 return(1);
}
Exemplo n.º 4
0
int FCEUNET_SendCommand(uint8 cmd, uint32 len)
{
	//mbg merge 7/17/06 changed to alloca
	//uint8 buf[numlocal + 1 + 4];
	uint8 *buf = (uint8*)alloca(numlocal+1+4);


	buf[0] = 0xFF;
	FCEU_en32lsb(&buf[numlocal], len);
	buf[numlocal + 4] = cmd;
	if(!FCEUD_SendData(buf,numlocal + 1 + 4))
	{
		NetError();
		return(0);
	}
	return(1);
}
Exemplo n.º 5
0
int FCEUNET_SendFile(uint8 cmd, char *fn)
{
#ifdef NETPLAY_ENABLED
 uint32 len;
 uLongf clen;
 char *buf, *cbuf;
 FILE *fp;
 struct stat sb;

 if(!(fp=FCEUD_UTF8fopen(fn,"rb"))) return(0);

 fstat(fileno(fp),&sb);
 len = sb.st_size;
 buf = malloc(len);
 fread(buf, 1, len, fp);
 fclose(fp);

 cbuf = malloc(4 + len + len / 1000 + 12);
 FCEU_en32lsb(cbuf, len);
 compress2(cbuf + 4, &clen, buf, len, 7);
 free(buf);

 //printf("Sending file: %s, %d, %d\n",fn,len,clen);

 len = clen + 4;

 #ifdef NETWORK
 if(!FCEUNET_SendCommand(cmd,len))
 {
  free(cbuf);
  return(0);
 }
 if(!FCEUD_SendData(cbuf, len))
 {
  NetError();
  free(cbuf);
  return(0);
 }
 #endif
 free(cbuf);
#endif
 return(1);
}
Exemplo n.º 6
0
int FCEUNET_SendFile(uint8 cmd, char *fn)
{
	uint32 len;
	uLongf clen;
	char *buf, *cbuf;
	FILE *fp;
	struct stat sb;

	if(!(fp=FCEUD_UTF8fopen(fn,"rb"))) return(0);

	FCEUX_fstat(fileno(fp),&sb);
	len = sb.st_size;
	buf = (char*)FCEU_dmalloc(len); //mbg merge 7/17/06 added cast
	fread(buf, 1, len, fp);
	fclose(fp);

	cbuf = (char*)FCEU_dmalloc(4 + len + len / 1000 + 12); //mbg merge 7/17/06 added cast
	FCEU_en32lsb((uint8*)cbuf, len); //mbg merge 7/17/06 added cast
	compress2((uint8*)cbuf + 4, &clen, (uint8*)buf, len, 7); //mbg merge 7/17/06 added casts
	free(buf);

	//printf("Sending file: %s, %d, %d\n",fn,len,clen);

	len = clen + 4;

	if(!FCEUNET_SendCommand(cmd,len))
	{
		free(cbuf);
		return(0);
	}
	if(!FCEUD_SendData(cbuf, len))
	{
		NetError();
		free(cbuf);
		return(0);
	}
	free(cbuf);

	return(1);
}
Exemplo n.º 7
0
int FCEUSS_SaveFP(FILE *st)
{
  static uint32 totalsize;
  static uint8 header[16]="FCS";

  memset(header+4,0,13);
  header[3]=0xFF;
  FCEU_en32lsb(header + 8, FCEU_VERSION_NUMERIC);
  fwrite(header,1,16,st);
  FCEUPPU_SaveState();
  FCEUSND_SaveState();
  totalsize=WriteStateChunk(st,1,SFCPU);
  totalsize+=WriteStateChunk(st,2,SFCPUC);
  totalsize+=WriteStateChunk(st,3,FCEUPPU_STATEINFO);
  totalsize+=WriteStateChunk(st,4,FCEUCTRL_STATEINFO);
  totalsize+=WriteStateChunk(st,5,FCEUSND_STATEINFO);
  if(SPreSave) SPreSave();
  totalsize+=WriteStateChunk(st,0x10,SFMDATA);
  if(SPreSave) SPostSave();

  fseek(st,4,SEEK_SET);
  write32le(totalsize,st);
  return(1);
}