Exemple #1
0
static void load_vizawrite_cartridge(device_image_interface &image)
{
	#define VW64_DECRYPT_ADDRESS(_offset) \
		BITSWAP16(_offset,15,14,13,12,7,8,6,9,5,11,4,3,2,10,1,0)

	#define VW64_DECRYPT_DATA(_data) \
		BITSWAP8(_data,7,6,0,5,1,4,2,3)

	UINT8 *roml = image.get_software_region("roml");
	UINT8 *romh = image.get_software_region("romh");
	UINT8 *decrypted = image.device().machine().root_device().memregion("user1")->base();

	// decrypt ROMs
	for (offs_t offset = 0; offset < 0x2000; offset++)
	{
		offs_t address = VW64_DECRYPT_ADDRESS(offset);
		decrypted[address] = VW64_DECRYPT_DATA(roml[offset]);
		decrypted[address + 0x2000] = VW64_DECRYPT_DATA(roml[offset + 0x2000]);
		decrypted[address + 0x4000] = VW64_DECRYPT_DATA(romh[offset]);
	}

	// map cartridge ROMs
	map_cartridge_roml(image.device().machine(), 0x0000);
	map_cartridge_romh(image.device().machine(), 0x4000);

	// allocate GAME changing timer
	allocate_cartridge_timer(attotime::from_msec(1184), vizawrite_timer);
}
Exemple #2
0
bool hashfile_extrainfo(device_image_interface &image, std::string &result)
{
	return hashfile_extrainfo(
		image.device().mconfig().options().hash_path(),
		image.device().mconfig().gamedrv(),
		image.hash(),
		result);
}
Exemple #3
0
/***************************************************************************
    FLOPPY DRIVE
***************************************************************************/
static void vtech1_load_proc(device_image_interface &image)
{
    vtech1_state *vtech1 = image.device().machine().driver_data<vtech1_state>();
    int id = floppy_get_drive(&image.device());

    if (!image.is_readonly())
        vtech1->m_fdc_wrprot[id] = 0x00;
    else
        vtech1->m_fdc_wrprot[id] = 0x80;
}
Exemple #4
0
static void load_super_explode_cartridge(device_image_interface &image)
{
	load_cartridge_region(image, "roml", 0x0000, 0x4000);

	map_cartridge_roml(image.device().machine(), 0x0000);

	address_space &space = image.device().machine().firstcpu->space(AS_PROGRAM);
	space.install_legacy_read_handler(0xdf00, 0xdfff, FUNC(super_explode_r));

	install_io2_handler(super_explode_bank_w);
}
Exemple #5
0
static void c64_software_list_cartridge_load(device_image_interface &image)
{
	legacy_c64_state *state = image.device().machine().driver_data<legacy_c64_state>();

	// initialize ROML and ROMH pointers
	state->m_roml = state->m_c64_roml;
	state->m_romh = state->m_c64_romh;

	// clear ROML and ROMH areas
	memset(state->m_roml, 0, 0x2000);
	memset(state->m_romh, 0, 0x2000);

	// set GAME and EXROM
	state->m_game = atol(image.get_feature("game"));
	state->m_exrom = atol(image.get_feature("exrom"));

	// determine cartridge type
	const char *cart_type = image.get_feature("cart_type");

	if (cart_type == NULL)
	{
		load_standard_c64_cartridge(image);
	}
	else
	{
		if (!strcmp(cart_type, "vizawrite"))
			load_vizawrite_cartridge(image);

		else if (!strcmp(cart_type, "hugo"))
			load_hugo_cartridge(image);

		else if (!strcmp(cart_type, "easy_calc_result"))
			load_easy_calc_result_cartridge(image);

		else if (!strcmp(cart_type, "pagefox"))
			load_pagefox_cartridge(image);

		else if (!strcmp(cart_type, "multiscreen"))
			/*

                TODO: crashes on protection check after cartridge RAM test

                805A: lda  $01
                805C: and  #$FE
                805E: sta  $01
                8060: m6502_brk#$00 <-- BOOM!

            */
			load_multiscreen_cartridge(image);

		else if (!strcmp(cart_type, "simons_basic"))
			load_simons_basic_cartridge(image);

		else if (!strcmp(cart_type, "super_explode"))
			load_super_explode_cartridge(image);

		else
			load_standard_c64_cartridge(image);
	}
}
Exemple #6
0
void base_c1571_device::on_disk_change(device_image_interface &image)
{
    base_c1571_device *c1571 = static_cast<base_c1571_device *>(image.device().owner());

    int wp = floppy_wpt_r(image);
    c1571->m_ga->on_disk_changed(wp);
}
Exemple #7
0
static void load_pagefox_cartridge(device_image_interface &image)
{
	load_cartridge_region(image, "rom", 0x0000, 0x10000);

	map_cartridge_roml(image.device().machine(), 0x0000);
	map_cartridge_romh(image.device().machine(), 0x2000);

	install_write_handler(0xde80, 0xdeff, pagefox_bank_w);
}
Exemple #8
0
static void load_multiscreen_cartridge(device_image_interface &image)
{
	load_cartridge_region(image, "roml", 0x0000, 0x4000);
	load_cartridge_region(image, "rom", 0x4000, 0x30000);

	map_cartridge_roml(image.device().machine(), 0x0000);
	map_cartridge_romh(image.device().machine(), 0x2000);

	install_write_handler(0xdfff, 0xdfff, multiscreen_bank_w);
}
Exemple #9
0
static void load_simons_basic_cartridge(device_image_interface &image)
{
	load_cartridge_region(image, "roml", 0x0000, 0x2000);
	load_cartridge_region(image, "romh", 0x2000, 0x2000);

	map_cartridge_roml(image.device().machine(), 0x0000);
	map_cartridge_romh(image.device().machine(), 0x2000);

	install_io1_handler(simons_basic_bank_w);
}
Exemple #10
0
static void load_easy_calc_result_cartridge(device_image_interface &image)
{
	load_cartridge_region(image, "roml", 0x0000, 0x2000);
	load_cartridge_region(image, "romh", 0x2000, 0x4000);

	map_cartridge_roml(image.device().machine(), 0x0000);
	map_cartridge_romh(image.device().machine(), 0x2000);

	install_write_handler(0xde00, 0xde01, easy_calc_result_bank_w);
}
Exemple #11
0
static void svi318_load_proc(device_image_interface &image)
{
	svi318_state *state = image.device().machine().driver_data<svi318_state>();
	int size;
	int id = floppy_get_drive(&image.device());

	size = image.length();
	switch (size)
	{
	case 172032:	/* SVI-328 SSDD */
		state->m_fdc.heads[id] = 1;
		break;
	case 346112:	/* SVI-328 DSDD */
		state->m_fdc.heads[id] = 2;
		break;
	case 348160:	/* SVI-728 DSDD CP/M */
		state->m_fdc.heads[id] = 2;
		break;
	}
}
Exemple #12
0
static int plus4_crt_load( device_image_interface &image )
{
	UINT8 *mem = image.device().machine().root_device().memregion("maincpu")->base();
	int size = image.length(), test;
	const char *filetype;
	int address = 0;

	/* magic lowrom at offset 7: $43 $42 $4d */
	/* if at offset 6 stands 1 it will immediatly jumped to offset 0 (0x8000) */
	static const unsigned char magic[] = {0x43, 0x42, 0x4d};
	unsigned char buffer[sizeof (magic)];

	image.fseek(7, SEEK_SET);
	image.fread( buffer, sizeof (magic));
	image.fseek(0, SEEK_SET);

	/* Check if our cart has the magic string, and set its loading address */
	if (!memcmp(buffer, magic, sizeof (magic)))
		address = 0x20000;

	/* Give a loading address to non .bin / non .rom carts as well */
	filetype = image.filetype();

	/* We would support .hi and .lo files, but currently I'm not sure where to load them.
       We simply load them at 0x20000 at this stage, even if it's probably wrong!
       It could also well be that they both need to be loaded at the same time, but this
       is now impossible since I reduced to 1 the number of cart slots.
       More investigations are in order if any .hi, .lo dump would surface!              */
	if (!mame_stricmp(filetype, "hi"))
		address = 0x20000;	/* FIX ME! */

	else if (!mame_stricmp(filetype, "lo"))
		address = 0x20000;	/* FIX ME! */

	/* As a last try, give a reasonable loading address also to .bin/.rom without the magic string */
	else if (!address)
	{
		logerror("Cart %s does not contain the magic string: it may be loaded at the wrong memory address!\n", image.filename());
		address = 0x20000;
	}

	logerror("Loading cart %s at %.5x size:%.4x\n", image.filename(), address, size);

	/* Finally load the cart */
	test = image.fread( mem + address, size);

	if (test != size)
		return IMAGE_INIT_FAIL;

	return IMAGE_INIT_PASS;
}
Exemple #13
0
/* save card data back */
static void nc_card_save(device_image_interface &image)
{
	nc_state *state = image.device().machine().driver_data<nc_state>();
	/* if there is no data to write, quit */
	if (!state->m_card_ram || !state->m_card_size)
		return;

	logerror("attempting card save\n");

	/* write data */
	image.fwrite(state->m_card_ram, state->m_card_size);

	logerror("write succeeded!\r\n");
}
Exemple #14
0
static void load_hugo_cartridge(device_image_interface &image)
{
	#define HUGO_DECRYPT_ADDRESS(_offset) \
		BITSWAP16(_offset,15,14,13,12,7,6,5,4,3,2,1,0,8,9,11,10)

	#define HUGO_DECRYPT_DATA(_data) \
		BITSWAP8(_data,7,6,5,4,0,1,2,3)

	UINT8 *roml = image.get_software_region("roml");
	UINT8 *decrypted = image.device().machine().root_device().memregion("user1")->base();

	// decrypt ROMs
	for (offs_t offset = 0; offset < 0x20000; offset++)
	{
		offs_t address = (offset & 0x10000) | HUGO_DECRYPT_ADDRESS(offset);
		decrypted[address] = HUGO_DECRYPT_DATA(roml[offset]);
	}

	// map cartridge ROMs
	map_cartridge_roml(image.device().machine(), 0x0000);

	// install bankswitch handler
	install_io1_handler(hugo_bank_w);
}
Exemple #15
0
static void plus4_software_list_cartridge_load(device_image_interface &image)
{
	UINT8 *mem = image.device().machine().root_device().memregion("maincpu")->base();

	size_t size = image.get_software_region_length("c1l");
	if (size)
		memcpy(mem + 0x20000, image.get_software_region("c1l"), size);

	size = image.get_software_region_length("c1h");
	if (size)
		memcpy(mem + 0x24000, image.get_software_region("c1h"), size);

	size = image.get_software_region_length("c2l");
	if (size)
		memcpy(mem + 0x28000, image.get_software_region("c2l"), size);

	size = image.get_software_region_length("c2h");
	if (size)
		memcpy(mem + 0x2c000, image.get_software_region("c2h"), size);
}
Exemple #16
0
/* load card image */
static int nc_card_load(device_image_interface &image, unsigned char **ptr)
{
	nc_state *state = image.device().machine().driver_data<nc_state>();
	int datasize;
	unsigned char *data;

	/* get file size */
	datasize = image.length();

	if (datasize!=0)
	{
		/* malloc memory for this data */
		data = (unsigned char *)malloc(datasize);

		if (data!=NULL)
		{
			state->m_card_size = datasize;

			/* read whole file */
			image.fread(data, datasize);

			*ptr = data;

			logerror("File loaded!\r\n");

			state->m_membank_card_ram_mask = nc_card_calculate_mask(datasize);

			logerror("Mask: %02x\n",state->m_membank_card_ram_mask);

			/* ok! */
			return 1;
		}
	}

	return 0;
}
Exemple #17
0
static void osborne1_load_proc(device_image_interface &image)
{
	int size = image.length();
	osborne1_state *state = image.device().machine().driver_data<osborne1_state>();

	switch( size )
	{
	case 40 * 10 * 256:
		wd17xx_dden_w(state->m_fdc, ASSERT_LINE);
		break;
	case 40 * 5 * 1024:
		wd17xx_dden_w(state->m_fdc, CLEAR_LINE);
		break;
	case 40 * 8 * 512:
		wd17xx_dden_w(state->m_fdc, ASSERT_LINE);
		break;
	case 40 * 18 * 128:
		wd17xx_dden_w(state->m_fdc, ASSERT_LINE);
		break;
	case 40 * 9 * 512:
		wd17xx_dden_w(state->m_fdc, CLEAR_LINE);
		break;
	}
}
Exemple #18
0
static void load_standard_c64_cartridge(device_image_interface &image)
{
	legacy_c64_state *state = image.device().machine().driver_data<legacy_c64_state>();
	UINT32 size;

	// is there anything to load at 0x8000?
	size = image.get_software_region_length("roml");

	if (size)
	{
		memcpy(state->m_roml, image.get_software_region("roml"), MIN(0x2000, size));

		if (size == 0x4000)
		{
			// continue loading to ROMH region
			memcpy(state->m_romh, image.get_software_region("roml") + 0x2000, 0x2000);
		}
	}

	// is there anything to load at 0xa000?
	size = image.get_software_region_length("romh");
	if (size)
		memcpy(state->m_romh, image.get_software_region("romh"), size);
}
Exemple #19
0
// handle protected carts
static void install_protection(device_image_interface& image)
{
	neogeo_state *state = image.device().machine().driver_data<neogeo_state>();
	const char *crypt_feature = image.get_feature( "crypt" );

	if(crypt_feature == NULL)
		return;

	if(strcmp(crypt_feature,"fatfury2_prot") == 0)
	{
		fatfury2_install_protection(image.device().machine());
		logerror("Installed Fatal Fury 2 protection\n");
	}
	if(strcmp(crypt_feature,"kof99_crypt") == 0)
	{
		kof99_decrypt_68k(image.device().machine());
		state->m_fixed_layer_bank_type = 1;
		kof99_neogeo_gfx_decrypt(image.device().machine(), 0x00);
		kof99_install_protection(image.device().machine());
		logerror("Decrypted KOF99 code and graphics.\n");
	}
	if(strcmp(crypt_feature,"mslug3_crypt") == 0)
	{
		state->m_fixed_layer_bank_type = 1;
		kof99_neogeo_gfx_decrypt(image.device().machine(), 0xad);
		logerror("Decrypted Metal Slug 3 graphics\n");
	}
	if(strcmp(crypt_feature,"matrim_crypt") == 0)
	{
		matrim_decrypt_68k(image.device().machine());
		neo_pcm2_swap(image.device().machine(), 1);
		state->m_fixed_layer_bank_type = 2;
		neogeo_cmc50_m1_decrypt(image.device().machine());
		kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x6a);
		logerror("Decrypted Matrimelee code, sound and graphics\n");
	}
	if(strcmp(crypt_feature,"svc_crypt") == 0)
	{
		svc_px_decrypt(image.device().machine());
		neo_pcm2_swap(image.device().machine(), 3);
		state->m_fixed_layer_bank_type = 2;
		neogeo_cmc50_m1_decrypt(image.device().machine());
		kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x57);
		install_pvc_protection(image.device().machine());
		logerror("Decrypted SvC code, sound and graphics.\n");
	}
	if(strcmp(crypt_feature,"samsho5_crypt") == 0)
	{
		samsho5_decrypt_68k(image.device().machine());
		neo_pcm2_swap(image.device().machine(), 4);
		state->m_fixed_layer_bank_type = 1;
		neogeo_cmc50_m1_decrypt(image.device().machine());
		kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x0f);
		logerror("Decrypted Samurai Shodown V code, sound and graphics.\n");
	}
	if(strcmp(crypt_feature,"kof2000_crypt") == 0)
	{
		kof2000_decrypt_68k(image.device().machine());
		state->m_fixed_layer_bank_type = 2;
		neogeo_cmc50_m1_decrypt(image.device().machine());
		kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x00);
		kof2000_install_protection(image.device().machine());
		logerror("Decrypted KOF2000 code, sound and graphics.\n");
	}
	if(strcmp(crypt_feature,"kof2001_crypt") == 0)
	{
		state->m_fixed_layer_bank_type = 1;
		kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x1e);
		neogeo_cmc50_m1_decrypt(image.device().machine());
		logerror("Decrypted KOF2001 code and graphics.\n");
	}
	if(strcmp(crypt_feature,"kof2002_crypt") == 0)
	{
		kof2002_decrypt_68k(image.device().machine());
		neo_pcm2_swap(image.device().machine(), 0);
		neogeo_cmc50_m1_decrypt(image.device().machine());
		kof2000_neogeo_gfx_decrypt(image.device().machine(), 0xec);
		logerror("Decrypted KOF2002 code, sound and graphics.\n");
	}
	if(strcmp(crypt_feature,"mslug4_crypt") == 0)
	{
		state->m_fixed_layer_bank_type = 1; /* USA violent content screen is wrong -- not a bug, confirmed on real hardware! */
		neogeo_cmc50_m1_decrypt(image.device().machine());
		kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x31);
		neo_pcm2_snk_1999(image.device().machine(), 8);
		logerror("Decrypted Metal Slug 4 code, sound and graphics.\n");
	}
	if(strcmp(crypt_feature,"mslug5_crypt") == 0)
	{
		mslug5_decrypt_68k(image.device().machine());
		neo_pcm2_swap(image.device().machine(), 2);
		state->m_fixed_layer_bank_type = 1;
		neogeo_cmc50_m1_decrypt(image.device().machine());
		kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x19);
		install_pvc_protection(image.device().machine());
		logerror("Decrypted Metal Slug 5 code and graphics, and installed protection routines.\n");
	}
	if(strcmp(crypt_feature,"kof2003_crypt") == 0)
	{
		kof2003h_decrypt_68k(image.device().machine());
		neo_pcm2_swap(image.device().machine(), 5);
		state->m_fixed_layer_bank_type = 2;
		neogeo_cmc50_m1_decrypt(image.device().machine());
		kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x9d);
		install_pvc_protection(image.device().machine());
		logerror("Decrypted KOF2003 code and graphicss, and installed protection routines.\n");
	}
	if(strcmp(crypt_feature,"samsho5s_crypt") == 0)
	{
		samsh5sp_decrypt_68k(image.device().machine());
		neo_pcm2_swap(image.device().machine(), 6);
		state->m_fixed_layer_bank_type = 1;
		neogeo_cmc50_m1_decrypt(image.device().machine());
		kof2000_neogeo_gfx_decrypt(image.device().machine(), 0x0d);
	}
}
Exemple #20
0
void nes_disksys_device::unload_proc(device_image_interface &image)
{
	nes_disksys_device *disk_sys = static_cast<nes_disksys_device *>(image.device().owner());
	disk_sys->unload_disk(image);
}
Exemple #21
0
void nes_disksys_device::load_proc(device_image_interface &image, bool is_created)
{
	nes_disksys_device *disk_sys = static_cast<nes_disksys_device *>(image.device().owner());
	disk_sys->load_disk(image);
}
Exemple #22
0
void c2040_device::on_disk1_change(device_image_interface &image)
{
	c2040_device *c2040 = static_cast<c2040_device *>(image.device().owner());

	c2040->read_current_track(1);
}
Exemple #23
0
static void _atari_load_proc(device_image_interface &image, bool is_created)
{
    atari_fdc_device *atarifdc = static_cast<atari_fdc_device *>(image.device().owner());
    atarifdc->atari_load_proc(image, is_created);
}
Exemple #24
0
static void image_fread_memory(device_image_interface &image, UINT16 addr, UINT32 count)
{
	void *ptr = image.device().machine().firstcpu->memory().space(AS_PROGRAM)->get_write_ptr(addr);

	image.fread( ptr, count);
}
Exemple #25
0
INLINE void load_cartridge_region(device_image_interface &image, const char *name, offs_t offset, size_t size)
{
	UINT8 *cart = image.device().machine().root_device().memregion("user1")->base();
	UINT8 *rom = image.get_software_region(name);
	memcpy(cart + offset, rom, size);
}
Exemple #26
0
static int c64_crt_load( device_image_interface &image )
{
	legacy_c64_state *state = image.device().machine().driver_data<legacy_c64_state>();
	int size = image.length(), test, i = 0, ii;
	int _80_loaded = 0, _90_loaded = 0, a0_loaded = 0, b0_loaded = 0, e0_loaded = 0, f0_loaded = 0;
	const char *filetype = image.filetype();
	int address = 0, new_start = 0;
	// int lbank_end_addr = 0, hbank_end_addr = 0;
	UINT8 *cart_cpy = state->memregion("user1")->base();

	/* We support .crt files */
	if (!mame_stricmp(filetype, "crt"))
	{
		int j;
		unsigned short c64_cart_type;

		if (i >= C64_MAX_ROMBANK)
			return IMAGE_INIT_FAIL;

		/* Start to parse the .crt header */
		/* 0x16-0x17 is Hardware type */
		image.fseek(0x16, SEEK_SET);
		image.fread(&c64_cart_type, 2);
		state->m_cart.mapper = BIG_ENDIANIZE_INT16(c64_cart_type);

		/* If it is unsupported cart type, warn the user */
		switch (state->m_cart.mapper)
		{
			case SIMONS_BASIC:	/* Type #  4 */
			case OCEAN_1:		/* Type #  5 */
			case FUN_PLAY:		/* Type #  7 */
			case SUPER_GAMES:		/* Type #  8 */
			case EPYX_FASTLOAD:	/* Type # 10 */
			case REX:			/* Type # 12 */
			case C64GS:			/* Type # 15 */
			case DINAMIC:		/* Type # 17 */
			case ZAXXON:		/* Type # 18 */
			case DOMARK:		/* Type # 19 */
			case COMAL_80:		/* Type # 21 */
			case GENERIC_CRT:		/* Type #  0 */
				printf("Currently supported cart type (Type %d)\n", state->m_cart.mapper);
				break;

			default:
			case ACTION_REPLAY:	/* Type #  1 */
			case KCS_PC:		/* Type #  2 */
			case FINAL_CART_III:	/* Type #  3 */
			case EXPERT:		/* Type #  6 */
			case ATOMIC_POWER:	/* Type #  9 */
			case WESTERMANN:		/* Type # 11 */
			case FINAL_CART_I:	/* Type # 13 */
			case MAGIC_FORMEL:	/* Type # 14 */
			case SUPER_SNAP_5:	/* Type # 20 */
				printf("Currently unsupported cart type (Type %d)\n", state->m_cart.mapper);
				break;
		}

		/* 0x18 is EXROM */
		image.fseek(0x18, SEEK_SET);
		image.fread(&state->m_cart.exrom, 1);

		/* 0x19 is GAME */
		image.fread(&state->m_cart.game, 1);

		/* We can pass to the data: it starts from 0x40 */
		image.fseek(0x40, SEEK_SET);
		j = 0x40;

		logerror("Loading cart %s size:%.4x\n", image.filename(), size);
		logerror("Header info: EXROM %d, GAME %d, Cart Type %d \n", state->m_cart.exrom, state->m_cart.game, c64_cart_type);


		/* Data in a .crt image are organized in blocks called 'CHIP':
           each 'CHIP' consists of a 0x10 header, which contains the
           actual size of the block, the loading address and info on
           the bankswitch, followed by the actual data                  */
		while (j < size)
		{
			unsigned short chip_size, chip_bank_index, chip_data_size;
			unsigned char buffer[10];

			/* Start to parse the CHIP header */
			/* First 4 bytes are the string 'CHIP' */
			image.fread(buffer, 6);

			/* 0x06-0x07 is the size of the CHIP block (header + data) */
			image.fread(&chip_size, 2);
			chip_size = BIG_ENDIANIZE_INT16(chip_size);

			/* 0x08-0x09 chip type (ROM, RAM + no ROM, Flash ROM) */
			image.fread(buffer + 6, 2);

			/* 0x0a-0x0b is the bank number of the CHIP block */
			image.fread(&chip_bank_index, 2);
			chip_bank_index = BIG_ENDIANIZE_INT16(chip_bank_index);

			/* 0x0c-0x0d is the loading address of the CHIP block */
			image.fread(&address, 2);
			address = BIG_ENDIANIZE_INT16(address);

			/* 0x0e-0x0f is the data size of the CHIP block (without header) */
			image.fread(&chip_data_size, 2);
			chip_data_size = BIG_ENDIANIZE_INT16(chip_data_size);

			/* Print out the CHIP header! */
			logerror("%.4s %.2x %.2x %.4x %.2x %.2x %.4x %.4x:%.4x\n",
				buffer, buffer[4], buffer[5], chip_size,
				buffer[6], buffer[7], chip_bank_index,
				address, chip_data_size);
			logerror("Loading CHIP data at %.4x size:%.4x\n", address, chip_data_size);

			/* Store data, address & size of the CHIP block */
			state->m_cart.bank[i].addr = address;
			state->m_cart.bank[i].index = chip_bank_index;
			state->m_cart.bank[i].size = chip_data_size;
			state->m_cart.bank[i].start = new_start;

			test = image.fread(cart_cpy + new_start, state->m_cart.bank[i].size);
			new_start += state->m_cart.bank[i].size;

			/* Does CHIP contain any data? */
			if (test != state->m_cart.bank[i].size)
				return IMAGE_INIT_FAIL;

			/* Advance to the next CHIP block */
			i++;
			j += chip_size;
		}
	}
	else /* We also support .80 files for c64 & .e0/.f0 for max */
	{
		/* Assign loading address according to extension */
		if (!mame_stricmp(filetype, "80"))
			address = 0x8000;

		if (!mame_stricmp(filetype, "e0"))
			address = 0xe000;

		if (!mame_stricmp(filetype, "f0"))
			address = 0xf000;

		logerror("loading %s rom at %.4x size:%.4x\n", image.filename(), address, size);

		/* Store data, address & size */
		state->m_cart.bank[0].addr = address;
		state->m_cart.bank[0].size = size;
		state->m_cart.bank[0].start = new_start;

		test = image.fread(cart_cpy + new_start, state->m_cart.bank[0].size);
		new_start += state->m_cart.bank[0].size;

		/* Does cart contain any data? */
		if (test != state->m_cart.bank[0].size)
			return IMAGE_INIT_FAIL;
	}

	state->m_cart.n_banks = i; // this is also needed so that we only set mappers if a cart is present!

	/* If we load a .crt file, use EXROM & GAME from the header! */
	if ((state->m_cart.exrom != -1) && (state->m_cart.game != -1))
	{
		state->m_exrom = state->m_cart.exrom;
		state->m_game  = state->m_cart.game;
	}

	/* Finally load the cart */
	state->m_roml = state->m_c64_roml;
	state->m_romh = state->m_c64_romh;

	memset(state->m_roml, 0, 0x2000);
	memset(state->m_romh, 0, 0x2000);

	switch (state->m_cart.mapper)
	{
	default:
		if (!state->m_game && state->m_exrom && (state->m_cart.n_banks == 1))
		{
			memcpy(state->m_romh, cart_cpy, 0x2000);
		}
		else
		{
			// we first attempt to load the first 'CHIPs' with address 0x8000-0xb000 and 0xe000-0xf000, otherwise we load the first (or first two) 'CHIPs' of the image
			for (ii = 0; ii < state->m_cart.n_banks; ii++)
			{
				if (state->m_cart.bank[ii].addr == 0x8000 && !_80_loaded)
				{
					memcpy(state->m_roml, cart_cpy + state->m_cart.bank[ii].start, state->m_cart.bank[ii].size);
					_80_loaded = 1;
					if (state->m_cart.bank[ii].size > 0x1000)
						_90_loaded = 1;
					if (state->m_cart.bank[ii].size > 0x2000)
						a0_loaded = 1;
					if (state->m_cart.bank[ii].size > 0x3000)
						b0_loaded = 1;
//                  printf("addr 0x8000: 80 %d, 90 %d, a0 %d, b0 %d\n", _80_loaded, _90_loaded, a0_loaded, b0_loaded);
				}

				if (state->m_cart.bank[ii].addr == 0x9000 && !_90_loaded)
				{
					memcpy(state->m_roml + 0x1000, cart_cpy + state->m_cart.bank[ii].start, state->m_cart.bank[ii].size);
					_90_loaded = 1;
					if (state->m_cart.bank[ii].size > 0x1000)
						a0_loaded = 1;
					if (state->m_cart.bank[ii].size > 0x2000)
						b0_loaded = 1;
//                  printf("addr 0x9000: 80 %d, 90 %d, a0 %d, b0 %d\n", _80_loaded, _90_loaded, a0_loaded, b0_loaded);
				}

				if (state->m_cart.bank[ii].addr == 0xa000 && !a0_loaded)
				{
					memcpy(state->m_roml + 0x2000, cart_cpy + state->m_cart.bank[ii].start, state->m_cart.bank[ii].size);
					a0_loaded = 1;
					if (state->m_cart.bank[ii].size > 0x1000)
						b0_loaded = 1;
//                  printf("addr 0xa000: 80 %d, 90 %d, a0 %d, b0 %d\n", _80_loaded, _90_loaded, a0_loaded, b0_loaded);
				}

				if (state->m_cart.bank[ii].addr == 0xb000 && !b0_loaded)
				{
					memcpy(state->m_roml + 0x3000, cart_cpy + state->m_cart.bank[ii].start, state->m_cart.bank[ii].size);
					b0_loaded = 1;
//                  printf("addr 0xb000: 80 %d, 90 %d, a0 %d, b0 %d\n", _80_loaded, _90_loaded, a0_loaded, b0_loaded);
				}

				if (state->m_cart.bank[ii].addr == 0xe000 && !e0_loaded)
				{
					memcpy(state->m_romh, cart_cpy + state->m_cart.bank[ii].start, state->m_cart.bank[ii].size);
					e0_loaded = 1;
					if (state->m_cart.bank[ii].size > 0x1000)
						f0_loaded = 1;
//                  printf("addr 0xe000: e0 %d, f0 %d\n", e0_loaded, f0_loaded);
				}

				if (state->m_cart.bank[ii].addr == 0xf000 && !f0_loaded)
				{
					memcpy(state->m_romh + 0x1000, cart_cpy + state->m_cart.bank[ii].start, state->m_cart.bank[ii].size);
					f0_loaded = 1;
//                  printf("addr 0xe000: e0 %d, f0 %d\n", e0_loaded, f0_loaded);
				}
			}
		}
	}

	return IMAGE_INIT_PASS;
}
Exemple #27
0
static void atari_load_proc(device_image_interface &image)
{
	atari_fdc_t *fdc = get_safe_token(image.device().owner());
	int id = floppy_get_drive(image);
	int size, i;
	const char *ext;

	fdc->drv[id].image = auto_alloc_array(image.device().machine(),UINT8,MAXSIZE);
	if (!fdc->drv[id].image)
		return;

	/* tell whether the image is writable */
	fdc->drv[id].mode = !image.is_readonly();
	/* set up image if it has been created */
	if (image.has_been_created())
	{
		int sector;
		char buff[256];
		memset(buff, 0, sizeof(buff));
		/* default to 720 sectors */
		for( sector = 0; sector < 720; sector++ )
			image.fwrite(buff, 256);
		image.fseek(0, SEEK_SET);
	}

	size = image.fread(fdc->drv[id].image, MAXSIZE);

	if( size <= 0 )
	{
		fdc->drv[id].image = NULL;
		return;
	}


	/* re allocate the buffer; we don't want to be too lazy ;) */
	//fdc->drv[id].image = (UINT8*)image.image_realloc(fdc->drv[id].image, size);

	ext = image.filetype();

	// hack alert, this means we can only load ATR via the softlist at the moment, image.filetype reutrns NULL :/
	if (image.software_entry() != NULL) ext="ATR";

	/* no extension: assume XFD format (no header) */
	if (!ext)
	{
		fdc->drv[id].type = FORMAT_XFD;
		fdc->drv[id].header_skip = 0;
	}
	else
	/* XFD extension */
	if( toupper(ext[0])=='X' && toupper(ext[1])=='F' && toupper(ext[2])=='D' )
	{
		fdc->drv[id].type = FORMAT_XFD;
		fdc->drv[id].header_skip = 0;
	}
	else
	/* ATR extension */
	if( toupper(ext[0])=='A' && toupper(ext[1])=='T' && toupper(ext[2])=='R' )
	{
		fdc->drv[id].type = FORMAT_ATR;
		fdc->drv[id].header_skip = 16;
	}
	else
	/* DSK extension */
	if( toupper(ext[0])=='D' && toupper(ext[1])=='S' && toupper(ext[2])=='K' )
	{
		fdc->drv[id].type = FORMAT_DSK;
		fdc->drv[id].header_skip = sizeof(dsk_format);
	}
	else
	{
		fdc->drv[id].type = FORMAT_XFD;
		fdc->drv[id].header_skip = 0;
	}

	if( fdc->drv[id].type == FORMAT_ATR &&
		(fdc->drv[id].image[0] != 0x96 || fdc->drv[id].image[1] != 0x02) )
	{
		fdc->drv[id].type = FORMAT_XFD;
		fdc->drv[id].header_skip = 0;
	}


	switch (fdc->drv[id].type)
	{
	/* XFD or unknown format: find a matching size from the table */
	case FORMAT_XFD:
		for( i = 0; xfd_formats[i].size; i++ )
		{
			if( size == xfd_formats[i].size )
			{
				fdc->drv[id].density = xfd_formats[i].dsk.density;
				fdc->drv[id].tracks = xfd_formats[i].dsk.tracks;
				fdc->drv[id].spt = xfd_formats[i].dsk.spt;
				fdc->drv[id].heads = (xfd_formats[i].dsk.doublesided) ? 2 : 1;
				fdc->drv[id].bseclen = 128;
				fdc->drv[id].seclen = 256 * xfd_formats[i].dsk.seclen_hi + xfd_formats[i].dsk.seclen_lo;
				fdc->drv[id].sectors = fdc->drv[id].tracks * fdc->drv[id].heads * fdc->drv[id].spt;
				break;
			}
		}
		break;
	/* ATR format: find a size including the 16 bytes header */
	case FORMAT_ATR:
		{
			int s;
			fdc->drv[id].bseclen = 128;
			/* get sectors from ATR header */
			s = (size - 16) / 128;
			/* 3 + odd number of sectors ? */
			if ( fdc->drv[id].image[4] == 128 || (s % 18) == 0 || (s % 26) == 0 || ((s - 3) % 1) != 0 )
			{
				fdc->drv[id].sectors = s;
				fdc->drv[id].seclen = 128;
				/* sector size 128 or count not evenly dividable by 26 ? */
				if( fdc->drv[id].seclen == 128 || (s % 26) != 0 )
				{
					/* yup! single density */
					fdc->drv[id].density = 0;
					fdc->drv[id].spt = 18;
					fdc->drv[id].heads = 1;
					fdc->drv[id].tracks = s / 18;
					if( s % 18 != 0 )
						fdc->drv[id].tracks += 1;
					if( fdc->drv[id].tracks % 2 == 0 && fdc->drv[id].tracks > 80 )
					{
						fdc->drv[id].heads = 2;
						fdc->drv[id].tracks /= 2;
					}
				}
				else
				{
					/* yes: medium density */
					fdc->drv[id].density = 0;
					fdc->drv[id].spt = 26;
					fdc->drv[id].heads = 1;
					fdc->drv[id].tracks = s / 26;
					if( s % 26 != 0 )
						fdc->drv[id].tracks += 1;
					if( fdc->drv[id].tracks % 2 == 0 && fdc->drv[id].tracks > 80 )
					{
						fdc->drv[id].heads = 2;
						fdc->drv[id].tracks /= 2;
					}
				}
			}
			else
			{
				/* it's double density */
				s = (s - 3) / 2 + 3;
				fdc->drv[id].sectors = s;
				fdc->drv[id].density = 2;
				fdc->drv[id].seclen = 256;
				fdc->drv[id].spt = 18;
				fdc->drv[id].heads = 1;
				fdc->drv[id].tracks = s / 18;
				if( s % 18 != 0 )
					fdc->drv[id].tracks += 1;
				if( fdc->drv[id].tracks % 2 == 0 && fdc->drv[id].tracks > 80 )
				{
					fdc->drv[id].heads = 2;
					fdc->drv[id].tracks /= 2;
				}
			}
		}
		break;
	/* DSK format: it's all in the header */
	case FORMAT_DSK:
		{
			dsk_format *dsk = (dsk_format *) fdc->drv[id].image;

			fdc->drv[id].tracks = dsk->tracks;
			fdc->drv[id].spt = dsk->spt;
			fdc->drv[id].heads = (dsk->doublesided) ? 2 : 1;
			fdc->drv[id].seclen = 256 * dsk->seclen_hi + dsk->seclen_lo;
			fdc->drv[id].bseclen = fdc->drv[id].seclen;
			fdc->drv[id].sectors = fdc->drv[id].tracks * fdc->drv[id].heads * fdc->drv[id].spt;
		}
		break;
	}
	logerror("atari opened floppy '%s', %d sectors (%d %s%s) %d bytes/sector\n",
			image.filename(),
			fdc->drv[id].sectors,
			fdc->drv[id].tracks,
			(fdc->drv[id].heads == 1) ? "SS" : "DS",
			(fdc->drv[id].density == 0) ? "SD" : (fdc->drv[id].density == 1) ? "MD" : "DD",
			fdc->drv[id].seclen);
	return;
}
Exemple #28
0
bool rom_software_list_loader::load_software(device_image_interface &image, software_list_device &swlist, const char *swname, const rom_entry *start_entry) const
{
	swlist.machine().rom_load().load_software_part_region(image.device(), swlist, swname, start_entry);
	return true;
}
Exemple #29
0
static void on_disk_change(device_image_interface &image)
{
	c1551_t *c1551 = get_safe_token(image.device().owner());

	read_current_track(c1551);
}
Exemple #30
0
void c1541_device::on_disk_change(device_image_interface &image)
{
    c1541_device *c1541 = static_cast<c1541_device *>(image.device().owner());

	c1541->m_ga->on_disk_changed();
}