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"); }
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"); }
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"); }
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"); }
void sega8_cart_slot_device::internal_header_logging(UINT8 *ROM, UINT32 len, UINT32 nvram_len) { static const char *const system_region[] = { "", "", "", "Master System Japan", "Master System Export", "Game Gear Japan", "Game Gear Export", "Game Gear International", "", "", "", "", "", "", "", "" }; static int csum_length[] = { 0x40000, 0x80000, 0x100000, 0, 0, 0, 0, 0, 0, 0, 0x1ff0, 0x3ff0, 0x7ff0, 0xcff0, 0x10000, 0x20000, }; char reserved[10]; UINT8 version, csum_size, region, serial[3]; UINT16 checksum, csum = 0; UINT32 csum_end; // LOG FILE DETAILS logerror("FILE DETAILS\n" ); logerror("============\n" ); logerror("Name: %s\n", basename()); logerror("File Size: 0x%08x\n", (software_entry() == nullptr) ? (int)length() : (int)get_software_region_length("rom")); logerror("Detected type: %s\n", sega8_get_slot(m_type)); logerror("ROM (Allocated) Size: 0x%X\n", len); logerror("RAM: %s\n", nvram_len ? "Yes" : "No"); if (nvram_len) logerror("RAM (Allocated) Size: 0x%X - Battery: %s\n", nvram_len, m_cart->get_has_battery() ? "Yes" : "No"); logerror("\n" ); // LOG HEADER DETAILS if (len < 0x8000) return; for (int i = 0; i < 10; i++) reserved[i] = ROM[0x7ff0 + i]; checksum = ROM[0x7ffa] | (ROM[0x7ffb] << 8); for (int i = 0; i < 3; i++) serial[i] = ROM[0x7ffc + i]; serial[2] &= 0x0f; version = (ROM[0x7ffe] & 0xf0) >> 4; csum_size = ROM[0x7fff] & 0x0f; csum_end = csum_length[csum_size]; if (!csum_end || csum_end > len) csum_end = len; region = (ROM[0x7fff] & 0xf0) >> 4; // compute cart checksum to compare with expected one for (int i = 0; i < csum_end; i++) { if (i < 0x7ff0 || i >= 0x8000) { csum += ROM[i]; csum &= 0xffff; } } logerror("INTERNAL HEADER\n" ); logerror("===============\n" ); logerror("Reserved String: %.10s\n", reserved); logerror("Region: %s\n", system_region[region]); logerror("Checksum: (Expected) 0x%x - (Computed) 0x%x\n", checksum, csum); logerror(" [checksum over 0x%X bytes]\n", csum_length[csum_size]); logerror("Serial String: %X\n", serial[0] | (serial[1] << 8) | (serial[2] << 16)); logerror("Software Revision: %x\n", version); logerror("\n" ); if (m_type == SEGA8_CODEMASTERS) { UINT8 day, month, year, hour, minute; csum = 0; day = ROM[0x7fe1]; month = ROM[0x7fe2]; year = ROM[0x7fe3]; hour = ROM[0x7fe4]; minute = ROM[0x7fe5]; checksum = ROM[0x7fe6] | (ROM[0x7fe7] << 8); csum_size = ROM[0x7fe0]; // compute cart checksum to compare with expected one for (int i = 0; i < len; i += 2) { if (i < 0x7ff0 || i >= 0x8000) { csum += (ROM[i] | (ROM[i + 1] << 8)); csum &= 0xffff; } } logerror("CODEMASTERS HEADER\n" ); logerror("==================\n" ); logerror("Build date & time: %x/%x/%x %.2x:%.2x\n", day, month, year, hour, minute); logerror("Checksum: (Expected) 0x%x - (Computed) 0x%x\n", checksum, csum); logerror(" [checksum over 0x%X bytes]\n", csum_size * 0x4000); logerror("\n" ); } }