Ejemplo n.º 1
0
	u32	readRom(const u32 pos, const u8 size) 
	{
		if (!fROM) return 0xFFFFFFFF;
		
		fROM->fseek(pos, SEEK_SET);
	
		u32 data = 0xFFFFFFFF;
		u32 readed = fROM->fread(&data, size);
		return data;
	}
Ejemplo n.º 2
0
	u32 readSRAM(const u32 pos, const u8 size) 
	{
		if (!fSRAM)
			return 0xFFFFFFFF;
			
		fSRAM->fseek(pos, SEEK_SET);

		u32 data = 0xFFFFFFFF;
		u32 readed = fSRAM->fread(&data, size);
		return data;
	}
Ejemplo n.º 3
0
static bool formatChunk(EMUFILE &inf)
{
	// seek to just after the RIFF header
	inf.fseek(12,SEEK_SET);

	// search for a format chunk
	for (;;)
	{
		char chunk_id[4];
		u32  chunk_length;

		inf.fread(chunk_id, 4);
		if (!inf.read_32LE(chunk_length)) return false;

		// if we found a format chunk, excellent!
		if (memcmp(chunk_id, "fmt ", 4) == 0 && chunk_length >= 16)
		{

			// read format chunk
			u16 format_tag;
			u16 channel_count;
			u32 samples_per_second;
			//u32 bytes_per_second   = read32_le(chunk + 8);
			//u16 block_align        = read16_le(chunk + 12);
			u16 bits_per_sample;

			if (inf.read_16LE(format_tag) != 1) return false;
			if (inf.read_16LE(channel_count) != 1) return false;
			if (inf.read_32LE(samples_per_second) != 1) return false;
			inf.fseek(6,SEEK_CUR);
			if (inf.read_16LE(bits_per_sample) != 1) return false;

			chunk_length -= 16;

			// format_tag must be 1 (WAVE_FORMAT_PCM)
			// we only support mono 8bit
			if (format_tag != 1 ||
				channel_count != 1 ||
				bits_per_sample != 8)
			{
					MessageBox(0,"not a valid RIFF WAVE file; must be 8bit mono pcm",0,0);
					return false;
			}

			return true;
		}

		inf.fseek(chunk_length,SEEK_CUR);
	}
	return false;
}
Ejemplo n.º 4
0
	u32 scanSaveTypeGBA()
	{
		if (!fROM) return 0xFF;

		fROM->fseek(0, SEEK_SET);
		int size = fROM->size();

		int lastpct=1;

		int len = fROM->size();
		for(;;)
		{
			u32 tmp;
			u32 readed = fROM->fread(&tmp, 4);

			int pos = fROM->ftell();
			int currPct = pos*100/(size-1);
			for(int i=lastpct;i<currPct;i++)
			{
				if(i%10==0)
					printf(" %d%%\n",i/10*10);
				else printf(".");
				lastpct = currPct;
			}

			if (readed < 4) 
				break;

			if(pos >= len)
				break;


			switch (tmp)
			{
				case EEPROM:
					return 1;
				case SRAM_:
					return 2;
				case FLASH:
				{
					u32 tmp = fROM->read32le();
					return ((tmp == FLASH1M_)?3:5);
				}
				case SIIRTC_V:
					return 4;
			}
		}

		return 0xFF;
	}
Ejemplo n.º 5
0
static bool dataChunk(EMUFILE &inf)
{
	bool found = false;

	// seek to just after the RIFF header
	inf.fseek(12,SEEK_SET);

	// search for a format chunk
	for (;;)
	{
		char chunk_id[4];
		u32  chunk_length;

		if (inf.eof()) return found;
		if (inf.fread(chunk_id, 4) != 4) return found;
		if (!inf.read_32LE(chunk_length)) return found;

		// if we found a data chunk, excellent!
      if (memcmp(chunk_id, "data", 4) == 0)
	  {
		  found = true;
		  u8 *temp = new u8[chunk_length];
		  if (inf.fread(temp,chunk_length) != chunk_length)
		  {
			  delete[] temp;
			  return false;
		  }
		  newWavData.fwrite(temp,chunk_length);
		  delete[] temp;
		  chunk_length = 0;
	  }

	  inf.fseek(chunk_length,SEEK_CUR);
	}

	return found;
}