Exemplo n.º 1
0
void nvram_handler_intelflash(int chip,mame_file *file,int read_or_write)
{
	struct flash_chip *c;
	if( chip >= FLASH_CHIPS_MAX )
	{
		logerror( "intelflash_nvram: invalid chip %d\n", chip );
		return;
	}
	c = &chips[ chip ];

	switch( c->bits )
	{
	case 8:
		if (read_or_write)
		{
			mame_fwrite( file, c->flash_memory, c->size );
		}
		else if (file)
		{
			mame_fread( file, c->flash_memory, c->size );
		}
		break;
	case 16:
		if (read_or_write)
		{
			mame_fwrite_lsbfirst( file, c->flash_memory, c->size );
		}
		else if (file)
		{
			mame_fread_lsbfirst( file, c->flash_memory, c->size );
		}
		break;
	}
}
Exemplo n.º 2
0
static DEVICE_LOAD( kim1_cassette )
{
	const char magic[] = "KIM1";
	char buff[4];
	UINT16 addr, size;
	UINT8 ident, *RAM = memory_region(REGION_CPU1);

	mame_fread(file, buff, sizeof (buff));
	if (memcmp(buff, magic, sizeof (buff)))
	{
		logerror("kim1_rom_load: magic '%s' not found\n", magic);
		return INIT_FAIL;
	}
	mame_fread_lsbfirst(file, &addr, 2);
	mame_fread_lsbfirst(file, &size, 2);
	mame_fread(file, &ident, 1);
	logerror("kim1_rom_load: $%04X $%04X $%02X\n", addr, size, ident);
	while (size-- > 0)
		mame_fread(file, &RAM[addr++], 1);
	return INIT_PASS;
}
Exemplo n.º 3
0
/* and doesn't search the rompath */
static struct GameSample *vc20_read_wav_sample (mame_file *f)
{
	/* NPW 28-Feb-2005 - this code sucks */
	return NULL;
#if 0
	unsigned long offset = 0;
	UINT32 length, rate, filesize, temp32;
	UINT16 bits, temp16;
	char buf[32];
	struct GameSample *result;

	/* read the core header and make sure it's a WAVE file */
	offset += mame_fread (f, buf, 4);
	if (offset < 4)
		return NULL;
	if (memcmp (&buf[0], "RIFF", 4) != 0)
		return NULL;

	/* get the total size */
	offset += mame_fread (f, &filesize, 4);
	if (offset < 8)
		return NULL;
	filesize = LITTLE_ENDIANIZE_INT32 (filesize);

	/* read the RIFF file type and make sure it's a WAVE file */
	offset += mame_fread (f, buf, 4);
	if (offset < 12)
		return NULL;
	if (memcmp (&buf[0], "WAVE", 4) != 0)
		return NULL;

	/* seek until we find a format tag */
	while (1)
	{
		offset += mame_fread (f, buf, 4);
		offset += mame_fread (f, &length, 4);
		length = LITTLE_ENDIANIZE_INT32 (length);
		if (memcmp (&buf[0], "fmt ", 4) == 0)
			break;

		/* seek to the next block */
		mame_fseek (f, length, SEEK_CUR);
		offset += length;
		if (offset >= filesize)
			return NULL;
	}

	/* read the format -- make sure it is PCM */
	offset += mame_fread_lsbfirst (f, &temp16, 2);
	if (temp16 != 1)
		return NULL;

	/* number of channels -- only mono is supported */
	offset += mame_fread_lsbfirst (f, &temp16, 2);
	if (temp16 != 1)
		return NULL;

	/* sample rate */
	offset += mame_fread (f, &rate, 4);
	rate = LITTLE_ENDIANIZE_INT32 (rate);

	/* bytes/second and block alignment are ignored */
	offset += mame_fread (f, buf, 6);

	/* bits/sample */
	offset += mame_fread_lsbfirst (f, &bits, 2);
	if (bits != 8 && bits != 16)
		return NULL;

	/* seek past any extra data */
	mame_fseek (f, length - 16, SEEK_CUR);
	offset += length - 16;

	/* seek until we find a data tag */
	while (1)
	{
		offset += mame_fread (f, buf, 4);
		offset += mame_fread (f, &length, 4);
		length = LITTLE_ENDIANIZE_INT32 (length);
		if (memcmp (&buf[0], "data", 4) == 0)
			break;

		/* seek to the next block */
		mame_fseek (f, length, SEEK_CUR);
		offset += length;
		if (offset >= filesize)
			return NULL;
	}

	/* allocate the game sample */
	result = (struct GameSample *)malloc (sizeof (struct GameSample) + length);

	if (result == NULL)
		return NULL;

	/* fill in the sample data */
	result->length = length;
	result->smpfreq = rate;
	result->resolution = bits;

	/* read the data in */
	if (bits == 8)
	{
		mame_fread (f, result->data, length);

		/* convert 8-bit data to signed samples */
		for (temp32 = 0; temp32 < length; temp32++)
			result->data[temp32] -= 0x80;
	}
	else
	{
		/* 16-bit data is fine as-is */
		mame_fread_lsbfirst (f, result->data, length);
	}
	return result;
#endif
}