std::string sega8_cart_slot_device::get_default_card_software()
{
	if (open_image_file(mconfig().options()))
	{
		const char *slot_string;
		UINT32 len = m_file->size(), offset = 0;
		dynamic_buffer rom(len);
		int type;

		m_file->read(&rom[0], len);

		if ((len % 0x4000) == 512)
			offset = 512;

		type = get_cart_type(&rom[offset], len - offset);
		slot_string = sega8_get_slot(type);

		//printf("type: %s\n", slot_string);
		clear();

		return std::string(slot_string);
	}

	return software_get_default_slot("rom");
}
Exemple #2
0
void sega8_cart_slot_device::get_default_card_software(std::string &result)
{
	if (open_image_file(mconfig().options()))
	{
		const char *slot_string = "rom";
		UINT32 len = core_fsize(m_file), offset = 0;
		dynamic_buffer rom(len);
		int type;

		core_fread(m_file, &rom[0], len);

		if ((len % 0x4000) == 512)
			offset = 512;

		type = get_cart_type(&rom[offset], len - offset);
		slot_string = sega8_get_slot(type);

		//printf("type: %s\n", slot_string);
		clear();

		result.assign(slot_string);
		return;
	}

	software_get_default_slot(result, "rom");
}
const char * sega8_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
{
	if (open_image_file(options))
	{
		const char *slot_string = "rom";
		UINT32 len = core_fsize(m_file), offset = 0;
		UINT8 *ROM = global_alloc_array(UINT8, len);
		int type;

		core_fread(m_file, ROM, len);

		if ((len % 0x4000) == 512)
			offset = 512;

		type = get_cart_type(ROM + offset, len - offset);
		slot_string = sega8_get_slot(type);

		//printf("type: %s\n", slot_string);
		global_free(ROM);
		clear();

		return slot_string;
	}

	return software_get_default_slot(config, options, this, "rom");
}
Exemple #4
0
image_init_result ekara_cart_slot_device::call_load()
{
	if (m_cart)
	{
		uint8_t *ROM;
		uint32_t len = !loaded_through_softlist() ? length() : get_software_region_length("rom");

		m_cart->rom_alloc(len, tag());

		ROM = m_cart->get_rom_base();

		if (!loaded_through_softlist())
			fread(ROM, len);
		else
			memcpy(ROM, get_software_region("rom"), len);

		if (!loaded_through_softlist())
		{
			// attempt to detect cart type without softlist assistance
			m_type = get_cart_type(ROM, len);
		}
		else
		{
			// or for softlist loading, use the type specified
			const char *pcb_name = get_feature("slot");
			if (pcb_name)
				m_type = ekara_get_pcb_id(pcb_name);
		}

		return image_init_result::PASS;
	}

	return image_init_result::PASS;
}
Exemple #5
0
image_init_result scv_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT8 *ROM;
		UINT32 len = (software_entry() == nullptr) ? length() : get_software_region_length("rom");
		bool has_ram = (software_entry() != nullptr) && get_software_region("ram");

		if (len > 0x20000)
		{
			seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
			return image_init_result::FAIL;
		}

		m_cart->rom_alloc(len, tag());
		if (has_ram)
			m_cart->ram_alloc(get_software_region_length("ram"));

		ROM = m_cart->get_rom_base();

		if (software_entry() == nullptr)
			fread(ROM, len);
		else
			memcpy(ROM, get_software_region("rom"), len);

		if (software_entry() == nullptr)
			m_type = get_cart_type(ROM, len);
		else
		{
			const char *pcb_name = get_feature("slot");
			if (pcb_name)
				m_type = scv_get_pcb_id(pcb_name);
		}

		// for the moment we only support RAM from softlist and in the following configurations
		// 1) 32K ROM + 8K RAM; 2) 128K ROM + 4K RAM
		if (m_type == SCV_32K && has_ram)
			m_type = SCV_32K_RAM;
		if (m_type == SCV_128K && has_ram)
			m_type = SCV_128K_RAM;

		//printf("Type: %s\n", scv_get_slot(m_type));

		return image_init_result::PASS;
	}

	return image_init_result::PASS;
}
Exemple #6
0
std::string gba_cart_slot_device::get_default_card_software(get_default_card_software_hook &hook) const
{
	if (hook.image_file())
	{
		const char *slot_string;
		uint32_t len = hook.image_file()->size();
		std::vector<uint8_t> rom(len);
		int type;

		hook.image_file()->read(&rom[0], len);

		type = get_cart_type(&rom[0], len);
		slot_string = gba_get_slot(type);

		//printf("type: %s\n", slot_string);

		return std::string(slot_string);
	}

	return software_get_default_slot("gba_rom");
}
Exemple #7
0
std::string scv_cart_slot_device::get_default_card_software()
{
	if (open_image_file(mconfig().options()))
	{
		const char *slot_string;
		UINT32 len = m_file->size();
		dynamic_buffer rom(len);
		int type;

		m_file->read(&rom[0], len);

		type = get_cart_type(&rom[0], len);
		slot_string = scv_get_slot(type);

		//printf("type: %s\n", slot_string);
		clear();

		return std::string(slot_string);
	}

	return software_get_default_slot("rom8k");
}
Exemple #8
0
const char * gba_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
{
	if (open_image_file(options))
	{
		const char *slot_string = "gba_rom";
		UINT32 len = core_fsize(m_file);
		UINT8 *ROM = global_alloc_array(UINT8, len);
		int type;

		core_fread(m_file, ROM, len);

		type = get_cart_type(ROM, len);
		slot_string = gba_get_slot(type);

		//printf("type: %s\n", slot_string);
		global_free(ROM);
		clear();

		return slot_string;
	}

	return software_get_default_slot(config, options, this, "gba_rom");
}
Exemple #9
0
void gba_cart_slot_device::get_default_card_software(std::string &result)
{
	if (open_image_file(mconfig().options()))
	{
		const char *slot_string = "gba_rom";
		UINT32 len = core_fsize(m_file);
		dynamic_buffer rom(len);
		int type;

		core_fread(m_file, &rom[0], len);

		type = get_cart_type(&rom[0], len);
		slot_string = gba_get_slot(type);

		//printf("type: %s\n", slot_string);
		clear();

		result.assign(slot_string);
		return;
	}

	software_get_default_slot(result, "gba_rom");
}
Exemple #10
0
std::string sega8_cart_slot_device::get_default_card_software(get_default_card_software_hook &hook) const
{
	if (hook.image_file())
	{
		const char *slot_string;
		uint32_t len = hook.image_file()->size(), offset = 0;
		std::vector<uint8_t> rom(len);
		int type;

		hook.image_file()->read(&rom[0], len);

		if ((len % 0x4000) == 512)
			offset = 512;

		type = get_cart_type(&rom[offset], len - offset);
		slot_string = sega8_get_slot(type);

		//printf("type: %s\n", slot_string);

		return std::string(slot_string);
	}

	return software_get_default_slot("rom");
}
image_init_result sega8_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT32 len = (software_entry() == nullptr) ? length() : get_software_region_length("rom");
		UINT32 offset = 0;
		UINT8 *ROM;

		if (m_is_card && len > 0x8000)
		{
			seterror(IMAGE_ERROR_UNSPECIFIED, "Attempted loading a card larger than 32KB");
			return image_init_result::FAIL;
		}

		// check for header
		if ((len % 0x4000) == 512)
		{
			offset = 512;
			len -= 512;
		}

		// make sure that we only get complete (0x4000) rom banks
		if (len & 0x3fff)
			len = ((len >> 14) + 1) << 14;

		m_cart->rom_alloc(len, tag());
		ROM = m_cart->get_rom_base();

		if (software_entry() == nullptr)
		{
			fseek(offset, SEEK_SET);
			fread(ROM, len);
		}
		else
			memcpy(ROM, get_software_region("rom"), get_software_region_length("rom"));

		/* check the image */
		if (verify_cart(ROM, len) != image_verify_result::PASS)
			logerror("Warning loading image: verify_cart failed\n");

		if (software_entry() != nullptr)
			m_type = sega8_get_pcb_id(get_feature("slot") ? get_feature("slot") : "rom");
		else
			m_type = get_cart_type(ROM, len);

		set_lphaser_xoffset(ROM, len);

		setup_ram();

		// Check for gamegear cartridges with PIN 42 set to SMS mode
		if (software_entry() != nullptr)
		{
			const char *pin_42 = get_feature("pin_42");
			if (pin_42 && !strcmp(pin_42, "sms_mode"))
				m_cart->set_sms_mode(1);
		}

		// when loading from fullpath m_late_battery_enable can be TRUE and in that case
		// we attempt to load a battery because the game might have it!
		if (m_cart->get_ram_size() && (m_cart->get_has_battery() || m_cart->get_late_battery()))
			battery_load(m_cart->get_ram_base(), m_cart->get_ram_size(), 0x00);

		//printf("Type: %s\n", sega8_get_slot(type));

		internal_header_logging(ROM + offset, len, m_cart->get_ram_size());

		return image_init_result::PASS;
	}

	return image_init_result::PASS;
}
Exemple #12
0
void msx_slot_cartridge_device::get_default_card_software(std::string &result)
{
	if (open_image_file(mconfig().options()))
	{
		const char *slot_string = "nomapper";
		UINT32 length = core_fsize(m_file);
		dynamic_buffer rom(length);
		int type = NOMAPPER;

		// Check if there's some mapper related information in the hashfiles
		std::string extrainfo;
		if (hashfile_extrainfo(*this, extrainfo))
		{
			int extrainfo_type = -1;
			if (1 == sscanf(extrainfo.c_str(), "%d", &extrainfo_type))
			{
				static const struct { int extrainfo; int mapper; } extrainfo_map[] = {
					//{ 0, NOMAPPER },
					{ 1, MSXDOS2 },
					{ 2, KONAMI_SCC },
					{ 3, KONAMI },
					{ 4, ASCII8 },
					{ 5, ASCII16 },
					{ 6, GAMEMASTER2 },
					{ 7, ASCII8_SRAM },
					{ 8, ASCII16_SRAM },
					{ 9, RTYPE },
					{ 10, MAJUTSUSHI },
					{ 11, FMPAC },
					{ 12, SUPERLODERUNNER },
					{ 13, SYNTHESIZER },
					{ 14, CROSSBLAIM },
					{ 15, DISK_ROM },
					{ 16, KOREAN_80IN1 },
					{ 17, KOREAN_126IN1 }
				};

				for (int i = 0; i < ARRAY_LENGTH(extrainfo_map); i++)
				{
					if (extrainfo_map[i].extrainfo == extrainfo_type)
					{
						type = extrainfo_map[i].mapper;
					}
				}
			}
		}

		if (type == NOMAPPER)
		{
			// Not identified through hashfile, try automatic detection
			type = get_cart_type(&rom[0], length);
		}

		if (type > NOMAPPER)
		{
			slot_string = msx_cart_get_slot_option(type);
		}

		result.assign(slot_string);
		return;
	}
	software_get_default_slot(result, "nomapper");
}
Exemple #13
0
image_init_result gba_cart_slot_device::call_load()
{
	if (m_cart)
	{
		uint8_t *ROM;
		uint32_t size = loaded_through_softlist() ? get_software_region_length("rom") : length();
		if (size > 0x4000000)
		{
			seterror(IMAGE_ERROR_UNSPECIFIED, "Attempted loading a cart larger than 64MB");
			return image_init_result::FAIL;
		}

		m_cart->rom_alloc(size, tag());
		ROM = (uint8_t *)m_cart->get_rom_base();

		if (!loaded_through_softlist())
		{
			fread(ROM, size);
			m_type = get_cart_type(ROM, size);
		}
		else
		{
			const char *pcb_name = get_feature("slot");

			memcpy(ROM, get_software_region("rom"), size);

			if (pcb_name)
				m_type = gba_get_pcb_id(pcb_name);

			//printf("Type: %s\n", gba_get_slot(m_type));

			osd_printf_info("GBA: Detected (XML) %s\n", pcb_name ? pcb_name : "NONE");
		}

		if (m_type == GBA_SRAM || m_type == GBA_DRILLDOZ || m_type == GBA_WARIOTWS)
			m_cart->nvram_alloc(0x10000);

		// mirror the ROM
		switch (size)
		{
			case 2 * 1024 * 1024:
				memcpy(ROM + 0x200000, ROM, 0x200000);
				// intentional fall-through
			case 4 * 1024 * 1024:
				memcpy(ROM + 0x400000, ROM, 0x400000);
				// intentional fall-through
			case 8 * 1024 * 1024:
				memcpy(ROM + 0x800000, ROM, 0x800000);
				// intentional fall-through
			case 16 * 1024 * 1024:
				memcpy(ROM + 0x1000000, ROM, 0x1000000);
				break;
		}
		if (size == 0x4000000)
		{
			memcpy((uint8_t *)m_cart->get_romhlp_base(), ROM, 0x2000000);
			for (uint32_t i = 0; i < 16; i++)
			{
				memcpy((uint8_t *)m_cart->get_romhlp_base() + i * 0x1000, ROM + 0x200, 0x1000);
			}
			memcpy((uint8_t *)m_cart->get_romhlp_base(), ROM, 0x180);
		}

		if (m_cart->get_nvram_size())
			battery_load(m_cart->get_nvram_base(), m_cart->get_nvram_size(), 0x00);

		return image_init_result::PASS;
	}

	return image_init_result::PASS;
}
Exemple #14
0
bool gba_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT8 *ROM = (UINT8 *)m_cart->get_rom_base();
		UINT32 cart_size;

		if (software_entry() == NULL)
		{
			cart_size = length();
			if (cart_size > 0x2000000)
			{
				seterror(IMAGE_ERROR_UNSPECIFIED, "Attempted loading a cart larger than 32MB");
				return IMAGE_INIT_FAIL;
			}
			fread(ROM, cart_size);
			m_cart->set_rom_size(cart_size);    // we store the actual game size...

			m_type = get_cart_type(ROM, cart_size);
		}
		else
		{
			const char *pcb_name = get_feature("slot");

			cart_size = get_software_region_length("rom");
			if (cart_size > 0x2000000)
			{
				seterror(IMAGE_ERROR_UNSPECIFIED, "Attempted loading a cart larger than 32MB");
				return IMAGE_INIT_FAIL;
			}
			memcpy(ROM, get_software_region("rom"), cart_size);
			m_cart->set_rom_size(cart_size);    // we store the actual game size...

			if (pcb_name)
				m_type = gba_get_pcb_id(pcb_name);

			//printf("Type: %s\n", gba_get_slot(m_type));

			mame_printf_info("GBA: Detected (XML) %s\n", pcb_name ? pcb_name : "NONE");
		}

		if (m_type == GBA_SRAM)
			m_cart->nvram_alloc(machine(), 0x10000);

		// mirror the ROM
		switch (cart_size)
		{
			case 2 * 1024 * 1024:
				memcpy(ROM + 0x200000, ROM, 0x200000);
				// intentional fall-through
			case 4 * 1024 * 1024:
				memcpy(ROM + 0x400000, ROM, 0x400000);
				// intentional fall-through
			case 8 * 1024 * 1024:
				memcpy(ROM + 0x800000, ROM, 0x800000);
				// intentional fall-through
			case 16 * 1024 * 1024:
				memcpy(ROM + 0x1000000, ROM, 0x1000000);
				break;
		}

		if (m_cart->get_nvram_size())
			battery_load(m_cart->get_nvram_base(), m_cart->get_nvram_size(), 0x00);

		return IMAGE_INIT_PASS;
	}

	return IMAGE_INIT_PASS;
}