Exemple #1
0
static int DINF(FCEUFILE *fp)
{
	char name[100], method[100];
	uint8 d, m;
	uint16 y;
	int t;

	if(FCEU_fread(name,1,100,fp)!=100)
		return(0);
	if((t=FCEU_fgetc(fp))==EOF) return(0);
	d=t;
	if((t=FCEU_fgetc(fp))==EOF) return(0);
	m=t;
	if((t=FCEU_fgetc(fp))==EOF) return(0);
	y=t;
	if((t=FCEU_fgetc(fp))==EOF) return(0);
	y|=t<<8;
	if(FCEU_fread(method,1,100,fp)!=100)
		return(0);
	name[99]=method[99]=0;
	FCEU_printf(" Dumped by: %s\n",name);
	FCEU_printf(" Dumped with: %s\n",method);
	{
		char *months[12]={"January","February","March","April","May","June","July",
			"August","September","October","November","December"};
		FCEU_printf(" Dumped on: %s %d, %d\n",months[(m-1)%12],d,y);
	}
	return(1);
}
Exemple #2
0
int NSFLoad(int fp)
{
  int x;

  FCEU_fseek(fp,0,SEEK_SET);
  FCEU_fread(&NSFHeader,1,0x80,fp);
  if(memcmp(NSFHeader.ID,"NESM\x1a",5))
                  return 0;
  NSFHeader.SongName[31]=NSFHeader.Artist[31]=NSFHeader.Copyright[31]=0;

  LoadAddr=NSFHeader.LoadAddressLow;
  LoadAddr|=NSFHeader.LoadAddressHigh<<8;

  if(LoadAddr<0x6000)
  {
   FCEUD_PrintError("Invalid load address.");
   return(0);
  }
  InitAddr=NSFHeader.InitAddressLow;
  InitAddr|=NSFHeader.InitAddressHigh<<8;

  PlayAddr=NSFHeader.PlayAddressLow;
  PlayAddr|=NSFHeader.PlayAddressHigh<<8;

  NSFSize=FCEU_fgetsize(fp)-0x80;

  NSFMaxBank=((NSFSize+(LoadAddr&0xfff)+4095)/4096);
  NSFMaxBank=uppow2(NSFMaxBank);

  if(!(NSFDATA=(uint8 *)FCEU_malloc(NSFMaxBank*4096)))
   return 0;

  FCEU_fseek(fp,0x80,SEEK_SET);
  memset(NSFDATA,0x00,NSFMaxBank*4096);
  FCEU_fread(NSFDATA+(LoadAddr&0xfff),1,NSFSize,fp);

  NSFMaxBank--;

  BSon=0;
  for(x=0;x<8;x++)
   BSon|=NSFHeader.BankSwitch[x];

 FCEUGameInfo.type=GIT_NSF;
 FCEUGameInfo.input[0]=FCEUGameInfo.input[1]=SI_GAMEPAD;
 FCEUGameInfo.cspecial=SIS_NSF;

 for(x=0;;x++)
 {
  if(NSFROM[x]==0x20)
  {
   NSFROM[x+1]=InitAddr&0xFF;
   NSFROM[x+2]=InitAddr>>8;
   NSFROM[x+8]=PlayAddr&0xFF;
   NSFROM[x+9]=PlayAddr>>8;
   break;
  }
 }
Exemple #3
0
int LoadUNIFChunks(FCEUFILE *fp)
{
	int x;
	int t;
	for(;;)
	{
		t=FCEU_fread(&uchead,1,4,fp);
		if(t<4)
		{
			if(t>0)
				return 0;
			return 1;
		}
		if(!(FCEU_read32le(&uchead.info,fp)))
			return 0;
		t=0;
		x=0;
		//printf("Funky: %s\n",((uint8 *)&uchead));
		while(bfunc[x].name)
		{
			if(!memcmp(&uchead,bfunc[x].name,strlen(bfunc[x].name)))
			{
				if(!bfunc[x].init(fp))
					return 0;
				t=1;
				break;
			}
			x++;
		}
		if(!t)
			if(FCEU_fseek(fp,uchead.info,SEEK_CUR)<0)
				return(0);
	}
}
Exemple #4
0
static int LoadCHR(FCEUFILE *fp)
{
	int z,t;
	z=uchead.ID[3]-'0';
	if(z<0 || z>15)
		return(0);
	FCEU_printf(" CHR ROM %d size: %d",z,(int) uchead.info);
	if(malloced[16+z])
		free(malloced[16+z]);
	t=FixRomSize(uchead.info,8192);
	if(!(malloced[16+z]=(uint8 *)FCEU_malloc(t)))
		return(0);
	mallocedsizes[16+z]=t;
	memset(malloced[16+z]+uchead.info,0xFF,t-uchead.info);
	if(FCEU_fread(malloced[16+z],1,uchead.info,fp)!=uchead.info)
	{
		FCEU_printf("Read Error!\n");
		return(0);
	}
	else
		FCEU_printf("\n");

	SetupCartCHRMapping(z,malloced[16+z],t,0);
	return(1);
}
Exemple #5
0
int UNIFLoad(const char *name, FCEUFILE *fp)
{
	FCEU_fseek(fp,0,SEEK_SET);
	FCEU_fread(&unhead,1,4,fp);
	if(memcmp(&unhead,"UNIF",4))
		return 0;

	ResetCartMapping();

	ResetExState(0,0);
	ResetUNIF();
	if(!FCEU_read32le(&unhead.info,fp))
		goto aborto;
	if(FCEU_fseek(fp,0x20,SEEK_SET)<0)
		goto aborto;
	if(!LoadUNIFChunks(fp))
		goto aborto;
	{
		int x;
		struct md5_context md5;

		md5_starts(&md5);

		for(x=0;x<32;x++)
			if(malloced[x])
			{
				md5_update(&md5,malloced[x],mallocedsizes[x]);
			}
			md5_finish(&md5,UNIFCart.MD5);
			FCEU_printf(" ROM MD5:  0x");
			for(x=0;x<16;x++)
				FCEU_printf("%02x",UNIFCart.MD5[x]);
			FCEU_printf("\n");
			memcpy(&GameInfo->MD5,&UNIFCart.MD5,sizeof(UNIFCart.MD5));
	}

	if(!InitializeBoard())
		goto aborto;

	#if !defined(GEKKO)|| !defined(_XBOX)
	FCEU_LoadGameSave(&UNIFCart);
	#endif

	strcpy(LoadedRomFName,name); //For the debugger list
	GameInterface=UNIFGI;
	return 1;

aborto:

	FreeUNIF();
	ResetUNIF();


	return 0;
}
Exemple #6
0
static int SetBoardName(FCEUFILE *fp) {
	if (!(boardname = (uint8*)FCEU_malloc(uchead.info + 1)))
		return(0);
	FCEU_fread(boardname, 1, uchead.info, fp);
	boardname[uchead.info] = 0;
	FCEU_printf(" Board name: %s\n", boardname);
	sboardname = boardname;
	if (!memcmp(boardname, "NES-", 4) || !memcmp(boardname, "UNL-", 4) || !memcmp(boardname, "HVC-", 4) || !memcmp(boardname, "BTL-", 4) || !memcmp(boardname, "BMC-", 4))
		sboardname += 4;
	return(1);
}
Exemple #7
0
int UNIFLoad(const char *name, int fp)
{
        FCEU_fseek(fp,0,SEEK_SET);
        FCEU_fread(&unhead,1,4,fp);
        if(memcmp(&unhead,"UNIF",4))
         return 0;

	ResetCartMapping();

        ResetExState(0,0);
        ResetUNIF();
        if(!FCEU_read32(&unhead.info,fp))
	 goto aborto;
        if(FCEU_fseek(fp,0x20,SEEK_SET)<0)
	 goto aborto;
        if(!LoadUNIFChunks(fp))
	 goto aborto;
	{
	 int x;
	 struct md5_context md5;

	 md5_starts(&md5);

	 for(x=0;x<32;x++)
	  if(malloced[x])
	  {
	   md5_update(&md5,malloced[x],mallocedsizes[x]);
	  }
	  md5_finish(&md5,UNIFCart.MD5);
          FCEU_printf(" ROM MD5:  0x");
          for(x=0;x<16;x++)
           FCEU_printf("%02x",UNIFCart.MD5[x]);
          FCEU_printf("\n");
	  memcpy(FCEUGameInfo.MD5,UNIFCart.MD5,sizeof(UNIFCart.MD5));
	}

        if(!InitializeBoard())
	 goto aborto;

	FCEU_LoadGameSave(&UNIFCart);
        GameInterface=UNIFGI;
        return 1;

	aborto:

	FreeUNIF();
	ResetUNIF();


	return 0;
}
Exemple #8
0
int NSFLoad(const char *name, FCEUFILE *fp)
{
	int x;

	fprintf(stderr,"NSFLoad ...\n");

	FCEU_fseek(fp,0,SEEK_SET);
	FCEU_fread(&NSFHeader,1,0x80,fp);
	if(memcmp(NSFHeader.ID,"NESM\x1a",5))
		return 0;
	NSFHeader.SongName[31]=NSFHeader.Artist[31]=NSFHeader.Copyright[31]=0;

	LoadAddr=NSFHeader.LoadAddressLow;
	LoadAddr|=NSFHeader.LoadAddressHigh<<8;

	if(LoadAddr<0x6000)
	{
		FCEUD_PrintError("Invalid load address.");
		return(0);
	}
	InitAddr=NSFHeader.InitAddressLow;
	InitAddr|=NSFHeader.InitAddressHigh<<8;

	PlayAddr=NSFHeader.PlayAddressLow;
	PlayAddr|=NSFHeader.PlayAddressHigh<<8;

	NSFSize=FCEU_fgetsize(fp)-0x80;

	NSFMaxBank=((NSFSize+(LoadAddr&0xfff)+4095)/4096);
	NSFMaxBank=PRGsize[0]=uppow2(NSFMaxBank);

	if(!(NSFDATA=(uint8 *)FCEU_malloc(NSFMaxBank*4096)))
		return 0;

	FCEU_fseek(fp,0x80,SEEK_SET);
	memset(NSFDATA,0x00,NSFMaxBank*4096);
	FCEU_fread(NSFDATA+(LoadAddr&0xfff),1,NSFSize,fp);

	NSFMaxBank--;

	BSon=0;
	for(x=0;x<8;x++)
	{
		BSon|=NSFHeader.BankSwitch[x];
	}

	if(BSon==0)
	{
		BankCounter=0x00;
   
 		if ((NSFHeader.LoadAddressHigh & 0x70) >= 0x70)
		{
			//Ice Climber, and other F000 base address tunes need this
			BSon=0xFF;
		}
		else {
			for(x=(NSFHeader.LoadAddressHigh & 0x70) / 0x10;x<8;x++)
			{
				NSFHeader.BankSwitch[x]=BankCounter;
				BankCounter+=0x01; 
			}
			BSon=0;
			}
	}

	for(x=0;x<8;x++)
		BSon|=NSFHeader.BankSwitch[x];

	GameInfo->type=GIT_NSF;
	GameInfo->input[0]=GameInfo->input[1]=SI_GAMEPAD;
	GameInfo->cspecial=SIS_NSF;

	for(x=0;;x++)
	{
		if(NSFROM[x]==0x20)
		{
			NSFROM[x+1]=InitAddr&0xFF;
			NSFROM[x+2]=InitAddr>>8;
			NSFROM[x+8]=PlayAddr&0xFF;
			NSFROM[x+9]=PlayAddr>>8;
			break;
		}
	}