int detect(void) { #ifdef linux FILE *infile; char buffer[512], *p; p = (char *) NULL ; infile = fopen("/proc/cpuinfo", "r"); while (fgets(buffer, sizeof(buffer), infile)) { if (!strncmp("model name", buffer, 10)) { p = strchr(buffer, ':') + 2; break; } } fclose(infile); if(p != NULL) { if (strstr(p, "ARMv7")) { if ( get_feature("vfpv4")) return CPU_ARMV7; if ( get_feature("vfpv3")) return CPU_ARMV7; if ( get_feature("vfp")) return CPU_ARMV6; } if (strstr(p, "ARMv6")) { if ( get_feature("vfp")) return CPU_ARMV6; } } #endif return CPU_UNKNOWN; }
//--------------------4.evaluate--------------------------- void debug_pretraining_evaluate(REAL* scores,HashMap* maps,HashMap* wl) { //evaluate the exact train file --- same order... cout << "---debug training data and evaluate." << endl; CONLLReader* reader = new CONLLReader(); reader->startReading(CONF_train_file.c_str()); DependencyInstance* x = reader->getNext(); int miss_count = 0,sentence_count=0; while(x != NULL){ if(++sentence_count % 3000 == 0) cout << "--Finish sentence " << sentence_count << "miss:" << miss_count << endl; int length = x->forms->size(); double *tmp_scores = new double[length*length*2]; int *word_index = get_word_index(length,x,wl,0); for(int ii=0;ii<length;ii++){ for(int j=ii+1;j<length;j++){ for(int lr=0;lr<2;lr++){ int index = get_index2(length,ii,j,lr); string *tmp_str = 0; if(lr==E_LEFT) tmp_str = get_feature(length,j,ii,word_index); else tmp_str = get_feature(length,ii,j,word_index); //add it or already there HashMap::iterator iter = maps->find(tmp_str); int which = iter->second; tmp_scores[index] = scores[which]; delete tmp_str; } } } //- decode and write vector<int> *ret = decodeProjective(length,tmp_scores); for(int i2=1;i2<length;i2++){ //ignore root if((*ret)[i2] != (*(x->heads))[i2]) miss_count ++; } delete ret; delete x; delete []tmp_scores; delete []word_index; x = reader->getNext(); } reader->finishReading(); delete reader; cout << "---Done with debug training data and evaluate and miss is " << miss_count << endl; }
image_init_result o2_cart_slot_device::call_load() { if (m_cart) { UINT32 size = (software_entry() == nullptr) ? length() : get_software_region_length("rom"); m_cart->rom_alloc(size, tag()); if (software_entry() == nullptr) fread(m_cart->get_rom_base(), size); else memcpy(m_cart->get_rom_base(), get_software_region("rom"), size); if (software_entry() == nullptr) { m_type = O2_STD; if (size == 12288) m_type = O2_ROM12; if (size == 16384) m_type = O2_ROM16; } else { const char *pcb_name = get_feature("slot"); if (pcb_name) m_type = o2_get_pcb_id(pcb_name); } //printf("Type: %s\n", o2_get_slot(m_type)); return image_init_result::PASS; } return image_init_result::PASS; }
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; }
void ofono_modem_remove_interface(struct ofono_modem *modem, const char *interface) { GSList *found; const char *feature; found = g_slist_find_custom(modem->interface_list, interface, (GCompareFunc) strcmp); if (found == NULL) { ofono_error("Interface %s not found on the interface_list", interface); return; } g_free(found->data); modem->interface_list = g_slist_remove(modem->interface_list, found->data); feature = get_feature(interface); if (feature) { found = g_slist_find_custom(modem->feature_list, feature, (GCompareFunc) strcmp); if (found) { g_free(found->data); modem->feature_list = g_slist_remove(modem->feature_list, found->data); } } if (modem->interface_update != 0) return; modem->interface_update = g_idle_add(trigger_interface_update, modem); }
bool astrocade_cart_slot_device::call_load() { if (m_cart) { UINT32 size = (software_entry() == nullptr) ? length() : get_software_region_length("rom"); m_cart->rom_alloc(size, tag()); if (software_entry() == nullptr) fread(m_cart->get_rom_base(), size); else memcpy(m_cart->get_rom_base(), get_software_region("rom"), size); if (software_entry() == nullptr) { m_type = ASTROCADE_STD; if (size == 0x40000) m_type = ASTROCADE_256K; if (size == 0x80000) m_type = ASTROCADE_512K; } else { const char *pcb_name = get_feature("slot"); if (pcb_name) m_type = astrocade_get_pcb_id(pcb_name); } //printf("Type: %s\n", astrocade_get_slot(m_type)); return IMAGE_INIT_PASS; } return IMAGE_INIT_PASS; }
int SimpleHandDetector::detect_hand(IplImage *img,CvRect* area) { FeatureData f; CvRect rect = get_feature(img,&f); if(rect.x == -1) return -1; *area = rect; return find_nearest_hand(&f); }
image_init_result a800_cart_slot_device::call_load() { if (m_cart) { uint32_t len; if (software_entry() != nullptr) { const char *pcb_name; len = get_software_region_length("rom"); m_cart->rom_alloc(len, tag()); memcpy(m_cart->get_rom_base(), get_software_region("rom"), len); if ((pcb_name = get_feature("slot")) != nullptr) m_type = a800_get_pcb_id(pcb_name); else m_type = A800_8K; } else { len = length(); // check whether there is an header, to identify the cart type if ((len % 0x1000) == 0x10) { uint8_t header[16]; fread(header, 0x10); m_type = identify_cart_type(header); len -= 0x10; // in identify_cart_type the first 0x10 bytes are read, so we need to adjust here } else // otherwise try to guess based on size { if (len == 0x8000) m_type = A5200_32K; if (len == 0x4000) m_type = A800_16K; if (len == 0x2000) m_type = A800_8K; if (len == 0x1000) m_type = A5200_4K; // also make a try with .hsi file (for .a52 files) std::string info; if (hashfile_extrainfo(*this, info) && info.compare("A13MIRRORING")==0) m_type = A5200_16K_2CHIPS; } m_cart->rom_alloc(len, tag()); fread(m_cart->get_rom_base(), len); } if (m_type == A800_TELELINK2) m_cart->nvram_alloc(0x100); logerror("%s loaded cartridge '%s' size %dK\n", machine().system().name, filename(), len/1024); } return image_init_result::PASS; }
image_init_result hp_optrom_slot_device::call_load() { logerror("hp_optrom: call_load\n"); if (m_cart == nullptr || !loaded_through_softlist()) { logerror("hp_optrom: must be loaded from sw list\n"); return image_init_result::FAIL; } const char *base_feature = get_feature("base"); if (base_feature == nullptr) { logerror("hp_optrom: no 'base' feature\n"); return image_init_result::FAIL; } offs_t base_addr; if (base_feature[ 0 ] != '0' || base_feature[ 1 ] != 'x' || sscanf(&base_feature[ 2 ] , "%x" , &base_addr) != 1) { logerror("hp_optrom: can't parse 'base' feature\n"); return image_init_result::FAIL; } // Valid BSC values for ROMs on LPU drawer: 0x07 0x0b .... 0x3b // Valid BSC values for ROMs on PPU drawer: 0x09 0x0d .... 0x3d // (BSC is field in bits 16..21 of base address) // Bit 15 of base address must be 0 // Base address must be multiple of 0x1000 if ((base_addr & ~0x3f7000UL) != 0 || ((base_addr & 0x30000) != 0x10000 && (base_addr & 0x30000) != 0x30000) || base_addr < 0x70000) { logerror("hp_optrom: illegal base address (%x)\n" , base_addr); return image_init_result::FAIL; } auto length = get_software_region_length("rom") / 2; if (length < 0x1000 || length > 0x8000 || (length & 0xfff) != 0 || ((base_addr & 0x7000) + length) > 0x8000) { logerror("hp_optrom: illegal region length (%x)\n" , length); return image_init_result::FAIL; } offs_t end_addr = base_addr + length - 1; logerror("hp_optrom: base_addr = %06x end_addr = %06x\n" , base_addr , end_addr); m_content.resize(length * 2); uint8_t *buffer = m_content.data(); memcpy(buffer , get_software_region("rom") , length * 2); // Install ROM in address space of every CPU for (hp_hybrid_cpu_device& cpu : device_interface_iterator<hp_hybrid_cpu_device>(machine().root_device())) { logerror("hp_optrom: install in %s AS\n" , cpu.tag()); cpu.space(AS_PROGRAM).install_rom(base_addr , end_addr , buffer); } m_base_addr = base_addr; m_end_addr = end_addr; return image_init_result::PASS; }
bool a800_cart_slot_device::call_load() { if (m_cart) { UINT32 len; if (software_entry() != nullptr) { const char *pcb_name; len = get_software_region_length("rom"); m_cart->rom_alloc(len, tag()); memcpy(m_cart->get_rom_base(), get_software_region("rom"), len); if ((pcb_name = get_feature("slot")) != nullptr) m_type = a800_get_pcb_id(pcb_name); else m_type = A800_8K; } else { len = length(); // check whether there is an header, to identify the cart type if ((len % 0x1000) == 0x10) { UINT8 header[16]; fread(header, 0x10); m_type = identify_cart_type(header); len -= 0x10; // in identify_cart_type the first 0x10 bytes are read, so we need to adjust here } else // otherwise try to guess based on size { if (len == 0x8000) m_type = A5200_32K; if (len == 0x4000) m_type = A800_16K; if (len == 0x2000) m_type = A800_8K; if (len == 0x1000) m_type = A5200_4K; } m_cart->rom_alloc(len, tag()); fread(m_cart->get_rom_base(), len); } if (m_type == A800_TELELINK2) m_cart->nvram_alloc(0x100); printf("%s loaded cartridge '%s' size %dK\n", machine().system().name, filename(), len/1024); } return IMAGE_INIT_PASS; }
void get_cpuconfig(void) { int d = detect(); switch (d) { case CPU_ARMV7: printf("#define ARMV7\n"); printf("#define HAVE_VFP\n"); printf("#define HAVE_VFPV3\n"); if ( get_feature("neon")) printf("#define HAVE_NEON\n"); if ( get_feature("vfpv4")) printf("#define HAVE_VFPV4\n"); printf("#define L1_DATA_SIZE 65536\n"); printf("#define L1_DATA_LINESIZE 32\n"); printf("#define L2_SIZE 512488\n"); printf("#define L2_LINESIZE 32\n"); printf("#define DTB_DEFAULT_ENTRIES 64\n"); printf("#define DTB_SIZE 4096\n"); printf("#define L2_ASSOCIATIVE 4\n"); break; case CPU_ARMV6: printf("#define ARMV6\n"); printf("#define HAVE_VFP\n"); printf("#define L1_DATA_SIZE 65536\n"); printf("#define L1_DATA_LINESIZE 32\n"); printf("#define L2_SIZE 512488\n"); printf("#define L2_LINESIZE 32\n"); printf("#define DTB_DEFAULT_ENTRIES 64\n"); printf("#define DTB_SIZE 4096\n"); printf("#define L2_ASSOCIATIVE 4\n"); break; } }
bool apf_cart_slot_device::call_load() { if (m_cart) { UINT32 size = (software_entry() == NULL) ? length() : get_software_region_length("rom"); if (size > 0x3800) { seterror(IMAGE_ERROR_UNSPECIFIED, "Image extends beyond the expected size for an APF cart"); return IMAGE_INIT_FAIL; } m_cart->rom_alloc(size, tag()); if (software_entry() == NULL) fread(m_cart->get_rom_base(), size); else memcpy(m_cart->get_rom_base(), get_software_region("rom"), size); if (software_entry() == NULL) { m_type = APF_STD; // attempt to identify Space Destroyer, which needs 1K of additional RAM if (size == 0x1800) { m_type = APF_SPACEDST; m_cart->ram_alloc(0x400); } if (size > 0x2000) m_type = APF_BASIC; } else { const char *pcb_name = get_feature("slot"); if (pcb_name) m_type = apf_get_pcb_id(pcb_name); if (get_software_region("ram")) m_cart->ram_alloc(get_software_region_length("ram")); } //printf("Type: %s\n", apf_get_slot(m_type)); return IMAGE_INIT_PASS; } return IMAGE_INIT_PASS; }
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; }
bool vc4000_cart_slot_device::call_load() { if (m_cart) { UINT32 size = (software_entry() == NULL) ? length() : get_software_region_length("rom"); if (size > 0x1800) { seterror(IMAGE_ERROR_UNSPECIFIED, "Image extends beyond the expected size for a VC4000 cart"); return IMAGE_INIT_FAIL; } m_cart->rom_alloc(size, tag()); if (software_entry() == NULL) fread(m_cart->get_rom_base(), size); else memcpy(m_cart->get_rom_base(), get_software_region("rom"), size); if (software_entry() == NULL) { m_type = VC4000_STD; // attempt to identify the non-standard types if (size > 0x1000) // 6k rom + 1k ram - Chess2 only m_type = VC4000_CHESS2; else if (size > 0x0800) // some 4k roms have 1k of mirrored ram (those who don't still work with RAM emulated luckily) m_type = VC4000_RAM1K; if (m_type == VC4000_RAM1K || m_type == VC4000_CHESS2) m_cart->ram_alloc(0x400); } else { const char *pcb_name = get_feature("slot"); if (pcb_name) m_type = vc4000_get_pcb_id(pcb_name); if (get_software_region("ram")) m_cart->ram_alloc(get_software_region_length("ram")); } //printf("Type: %s\n", vc4000_get_slot(m_type)); return IMAGE_INIT_PASS; } return IMAGE_INIT_PASS; }
bool vboy_cart_slot_device::call_load() { if (m_cart) { UINT8 *ROM; UINT32 len = (software_entry() == NULL) ? length() : get_software_region_length("rom"); bool has_eeprom = (software_entry() != NULL) && get_software_region("eeprom"); if (len > 0x200000) { seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); return IMAGE_INIT_FAIL; } // always alloc 0x200000 so to be able to directly map the region // to the address map (speeding up emulation a bit) m_cart->rom_alloc(0x200000, tag()); if (has_eeprom) m_cart->eeprom_alloc(get_software_region_length("eeprom")); ROM = (UINT8 *)m_cart->get_rom_base(); if (software_entry() == NULL) fread(ROM, len); else memcpy(ROM, get_software_region("rom"), len); if (len < 0x080000) { memcpy(ROM + 0x040000, ROM, 0x040000); } if (len < 0x100000) { memcpy(ROM + 0x080000, ROM, 0x080000); } if (len < 0x200000) { memcpy(ROM + 0x100000, ROM, 0x100000); } if (software_entry() == NULL) m_type = vboy_get_pcb_id("vb_rom"); else { const char *pcb_name = get_feature("slot"); if (pcb_name) m_type = vboy_get_pcb_id(pcb_name); } //printf("Type: %s\n", vboy_get_slot(m_type)); return IMAGE_INIT_PASS; } return IMAGE_INIT_PASS; }
image_init_result vsmile_cart_slot_device::call_load() { if (m_cart) { uint32_t size = loaded_through_softlist() ? get_software_region_length("rom") : length(); if (size > 0x1000000) { seterror(IMAGE_ERROR_UNSPECIFIED, "Attempted loading a cart larger than 16MB"); return image_init_result::FAIL; } m_cart->rom_alloc(size, tag()); uint8_t *rom = (uint8_t *)m_cart->get_rom_base(); if (!loaded_through_softlist()) { fread(rom, size); m_type = VSMILE_STD; } else { const char *pcb_name = get_feature("slot"); memcpy(rom, get_software_region("rom"), size); if (pcb_name) m_type = vsmile_get_pcb_id(pcb_name); osd_printf_info("V.Smile: Detected (XML) %s\n", pcb_name ? pcb_name : "NONE"); } if (m_type == VSMILE_NVRAM) { m_cart->nvram_alloc(0x200000); } 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; }
void ofono_modem_add_interface(struct ofono_modem *modem, const char *interface) { const char *feature; modem->interface_list = g_slist_prepend(modem->interface_list, g_strdup(interface)); feature = get_feature(interface); if (feature) modem->feature_list = g_slist_prepend(modem->feature_list, g_strdup(feature)); if (modem->interface_update != 0) return; modem->interface_update = g_idle_add(trigger_interface_update, modem); }
bool channelf_cart_slot_device::call_load() { if (m_cart) { UINT32 len = (software_entry() == NULL) ? length() : get_software_region_length("rom"); m_cart->rom_alloc(len, tag()); if (software_entry() == NULL) fread(m_cart->get_rom_base(), len); else memcpy(m_cart->get_rom_base(), get_software_region("rom"), len); if (software_entry() == NULL) { // we default to "chess" slot because some homebrew programs have been written to run // on PCBs with RAM at $2000-$2800 as Saba Schach! if (len == 0x40000) m_type = CF_MULTI; // TODO1: differentiate multicart final and earlier from fullpath else m_type = CF_CHESS; // TODO2: is there any way to detect Maze and Hangman from fullpath? m_cart->ram_alloc(0x800); } else { const char *pcb_name = get_feature("slot"); if (pcb_name) m_type = chanf_get_pcb_id(pcb_name); if (get_software_region("ram")) m_cart->ram_alloc(get_software_region_length("ram")); } //printf("Type: %s\n", chanf_get_slot(m_type)); return IMAGE_INIT_PASS; } return IMAGE_INIT_PASS; }
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; }
bool crvision_cart_slot_device::call_load() { if (m_cart) { UINT32 size = (software_entry() == nullptr) ? length() : get_software_region_length("rom"); if (size > 0x4800) { seterror(IMAGE_ERROR_UNSPECIFIED, "Image extends beyond the expected size for an APF cart"); return IMAGE_INIT_FAIL; } m_cart->rom_alloc(size, tag()); if (software_entry() == nullptr) fread(m_cart->get_rom_base(), size); else memcpy(m_cart->get_rom_base(), get_software_region("rom"), size); if (software_entry() == nullptr) { m_type = CRV_4K; switch (size) { case 0x4800: m_type = CRV_18K; break; case 0x4000: m_type = CRV_16K; break; case 0x3000: m_type = CRV_12K; break; case 0x2800: m_type = CRV_10K; break; case 0x2000: m_type = CRV_8K; break; case 0x1800: m_type = CRV_6K; break; case 0x1000: default: break; } } else { const char *pcb_name = get_feature("slot"); if (pcb_name) m_type = crvision_get_pcb_id(pcb_name); } printf("Type: %s\n", crvision_get_slot(m_type)); return IMAGE_INIT_PASS; } return IMAGE_INIT_PASS; }
image_init_result c64_expansion_slot_device::call_load() { if (m_card) { size_t size; if (software_entry() == nullptr) { size = length(); if (is_filetype("80")) { fread(m_card->m_roml, size); m_card->m_exrom = (0); if (size == 0x4000) { m_card->m_game = 0; } } else if (is_filetype("a0")) { fread(m_card->m_romh, 0x2000); m_card->m_exrom = 0; m_card->m_game = 0; } else if (is_filetype("e0")) { fread(m_card->m_romh, 0x2000); m_card->m_game = 0; } else if (is_filetype("crt")) { size_t roml_size = 0; size_t romh_size = 0; int exrom = 1; int game = 1; if (cbm_crt_read_header(*m_file, &roml_size, &romh_size, &exrom, &game)) { uint8_t *roml = nullptr; uint8_t *romh = nullptr; m_card->m_roml.allocate(roml_size); m_card->m_romh.allocate(romh_size); if (roml_size) roml = m_card->m_roml; if (romh_size) romh = m_card->m_roml; cbm_crt_read_data(*m_file, roml, romh); } m_card->m_exrom = exrom; m_card->m_game = game; } } else { size = get_software_region_length("uprom"); if (size) { // Ultimax (VIC-10) cartridge load_software_region("lorom", m_card->m_roml); load_software_region("uprom", m_card->m_romh); m_card->m_exrom = 1; m_card->m_game = 0; } else { // Commodore 64/128 cartridge load_software_region("roml", m_card->m_roml); load_software_region("romh", m_card->m_romh); load_software_region("nvram", m_card->m_nvram); if (get_feature("exrom") != nullptr) m_card->m_exrom = atol(get_feature("exrom")); if (get_feature("game") != nullptr) m_card->m_game = atol(get_feature("game")); } } } return image_init_result::PASS; }
void nes_cart_slot_device::call_load_pcb() { UINT32 vram_size = 0, prgram_size = 0, battery_size = 0, mapper_sram_size = 0; // SETUP step 1: getting PRG, VROM, VRAM sizes UINT32 prg_size = get_software_region_length("prg"); UINT32 vrom_size = get_software_region_length("chr"); vram_size = get_software_region_length("vram"); vram_size += get_software_region_length("vram2"); // validate the xml fields if (!prg_size) fatalerror("No PRG entry for this software! Please check if the xml list got corrupted\n"); if (prg_size < 0x8000) fatalerror("PRG entry is too small! Please check if the xml list got corrupted\n"); // SETUP step 2: getting PCB and other settings if (get_feature("slot")) m_pcb_id = nes_get_pcb_id(get_feature("slot")); else m_pcb_id = NO_BOARD; // SETUP step 3: storing the info needed for emulation if (get_software_region("bwram") != NULL) battery_size = get_software_region_length("bwram"); if (m_pcb_id == BANDAI_LZ93EX1 || m_pcb_id == BANDAI_LZ93EX2) { // allocate the 24C01 or 24C02 EEPROM battery_size += 0x2000; } if (m_pcb_id == BANDAI_DATACH) { // allocate the 24C01 and 24C02 EEPROM battery_size += 0x4000; } if (get_software_region("wram") != NULL) prgram_size = get_software_region_length("wram"); if (get_feature("mirroring")) { const char *mirroring = get_feature("mirroring"); if (!strcmp(mirroring, "horizontal")) m_cart->set_mirroring(PPU_MIRROR_HORZ); if (!strcmp(mirroring, "vertical")) m_cart->set_mirroring(PPU_MIRROR_VERT); if (!strcmp(mirroring, "high")) m_cart->set_mirroring(PPU_MIRROR_HIGH); if (!strcmp(mirroring, "low")) m_cart->set_mirroring(PPU_MIRROR_LOW); if (!strcmp(mirroring, "4screen")) { // A few boards uses 4-screen mirroring: Gauntlet (DDROM or TRR1ROM or Tengen 800004), // Rad Racer II (TVROM), and Napoleon Senki (IREM LROG017 with 74*161/161/21/138) m_cart->set_four_screen_vram(TRUE); m_cart->set_mirroring(PPU_MIRROR_4SCREEN); } if (!strcmp(mirroring, "pcb_controlled")) { // A few boards have variants with hardcoded mirroring and variants with mapper // controlled mirroring. We use a variable to avoid the need of dupe devices. // See e.g. HES 6-in-1 vs other HES games, Irem Major League vs other G-101 games, // Sunsoft-2 Shanghai vs Mito Koumon, Camerica BF9093 games vs BF9097 games, etc. // Boards where all games control mirroring do not make real use of this. m_cart->set_pcb_ctrl_mirror(TRUE); } } /* Check for pins in specific boards which require them */ if (m_pcb_id == STD_CNROM) { int mask = 0, state = 0; if (get_feature("chr-pin26") != NULL) { mask |= 0x01; state |= !strcmp(get_feature("chr-pin26"), "CE") ? 0x01 : 0; } if (get_feature("chr-pin27") != NULL) { mask |= 0x02; state |= !strcmp(get_feature("chr-pin27"), "CE") ? 0x02 : 0; } m_cart->set_ce(mask, state); } if (m_pcb_id == TAITO_X1_005 && get_feature("x1-pin17") != NULL && get_feature("x1-pin31") != NULL) { if (!strcmp(get_feature("x1-pin17"), "CIRAM A10") && !strcmp(get_feature("x1-pin31"), "NC")) m_cart->set_x1_005_alt(TRUE); } if (m_pcb_id == KONAMI_VRC2) { m_cart->set_vrc_lines(nes_cart_get_line(get_feature("vrc2-pin3")), nes_cart_get_line(get_feature("vrc2-pin4")), (nes_cart_get_line(get_feature("vrc2-pin21")) != 10) ? 1 : 0); // mame_printf_error("VRC-2, pin3: A%d, pin4: A%d, pin21: %d\n", nes_cart_get_line(get_feature("vrc2-pin3")), nes_cart_get_line(get_feature("vrc2-pin4")), // nes_cart_get_line(get_feature("vrc2-pin21"))); } if (m_pcb_id == KONAMI_VRC4) { m_cart->set_vrc_lines(nes_cart_get_line(get_feature("vrc4-pin3")), nes_cart_get_line(get_feature("vrc4-pin4")), 0); // mame_printf_error("VRC-4, pin3: A%d, pin4: A%d\n", nes_cart_get_line(get_feature("vrc4-pin3"), nes_cart_get_line(get_feature("vrc4-pin4")); } if (m_pcb_id == KONAMI_VRC6) { m_cart->set_vrc_lines(nes_cart_get_line(get_feature("vrc6-pin9")), nes_cart_get_line(get_feature("vrc6-pin10")), 0); // mame_printf_error("VRC-6, pin9: A%d, pin10: A%d\n", nes_cart_get_line(get_feature("vrc6-pin9"), nes_cart_get_line(get_feature("vrc6-pin10")); } if (m_pcb_id == STD_HKROM || m_pcb_id == TAITO_X1_017) mapper_sram_size = m_cart->get_mapper_sram_size(); if (m_pcb_id == TAITO_X1_005 || m_pcb_id == NAMCOT_163) { if (get_feature("batt")) mapper_sram_size = m_cart->get_mapper_sram_size(); } // pirate variants of boards with bus conflict are often not suffering from it // and actually games glitch if bus conflict is emulated... if (get_feature("bus_conflict") && !strcmp(get_feature("bus_conflict"), "no")) m_cart->set_bus_conflict(FALSE); // SETUP step 4: logging what we have found logerror("Loaded game from softlist:\n"); logerror("-- PCB: %s", get_feature("pcb")); if (m_pcb_id == UNSUPPORTED_BOARD) logerror(" (currently not supported by MESS)"); logerror("\n-- PRG 0x%x (%d x 16k chunks)\n", prg_size, prg_size / 0x4000); logerror("-- VROM 0x%x (%d x 8k chunks)\n", vrom_size, vrom_size / 0x2000); logerror("-- VRAM 0x%x (%d x 8k chunks)\n", vram_size, vram_size / 0x2000); logerror("-- PRG NVWRAM: %d\n", m_cart->get_battery_size()); logerror("-- PRG WRAM: %d\n", m_cart->get_prgram_size()); // SETUP steps 5/6: allocate pointers for PRG/VROM and load the data! m_cart->prg_alloc(machine(), prg_size); memcpy(m_cart->get_prg_base(), get_software_region("prg"), prg_size); if (vrom_size) { m_cart->vrom_alloc(machine(), vrom_size); memcpy(m_cart->get_vrom_base(), get_software_region("chr"), vrom_size); } // SETUP steps 7: allocate the remaining pointer, when needed if (vram_size) m_cart->vram_alloc(machine(), vram_size); if (prgram_size) m_cart->prgram_alloc(machine(), prgram_size); // also nes_smb2j_device needs WRAM initialized to 0xff? check! if (m_pcb_id == UNL_SMB2J) memset(m_cart->get_prgram_base(), 0xff, prgram_size); // Attempt to load a battery file for this ROM // A few boards have internal RAM with a battery (MMC6, Taito X1-005 & X1-017, etc.) if (battery_size || mapper_sram_size) { UINT32 tot_size = battery_size + mapper_sram_size; UINT8 *temp_nvram = auto_alloc_array(machine(), UINT8, tot_size); battery_load(temp_nvram, tot_size, 0x00); if (battery_size) { m_cart->battery_alloc(machine(), battery_size); memcpy(m_cart->get_battery_base(), temp_nvram, battery_size); } if (mapper_sram_size) memcpy(m_cart->get_mapper_sram_base(), temp_nvram + battery_size, mapper_sram_size); if (temp_nvram) auto_free(machine(), temp_nvram); } }
image_init_result vcs_cart_slot_device::call_load() { if (m_cart) { uint8_t *ROM; uint32_t len; if (loaded_through_softlist()) len = get_software_region_length("rom"); else len = length(); //printf("Size: 0x%X\n", len); // check that filesize is among the supported ones switch (len) { case 0x00800: case 0x01000: case 0x02000: case 0x028ff: case 0x02900: case 0x03000: case 0x04000: case 0x08000: case 0x10000: case 0x80000: break; default: seterror(IMAGE_ERROR_UNSUPPORTED, "Invalid rom file size" ); return image_init_result::FAIL; } m_cart->rom_alloc(len, tag()); ROM = m_cart->get_rom_base(); if (loaded_through_softlist()) { const char *pcb_name; bool has_ram = get_software_region("ram") ? true : false; memcpy(ROM, get_software_region("rom"), len); if ((pcb_name = get_feature("slot")) != nullptr) m_type = vcs_get_pcb_id(pcb_name); else { // identify type based on size switch (len) { case 0x800: m_type = A26_2K; break; case 0x1000: m_type = A26_4K; break; case 0x2000: m_type = A26_F8; break; case 0x28ff: case 0x2900: m_type = A26_DPC; break; case 0x3000: m_type = A26_FA; break; case 0x4000: m_type = A26_F6; break; case 0x8000: m_type = A26_F4; break; case 0x10000: m_type = A26_32IN1; break; case 0x80000: m_type = A26_3F; break; default: m_type = A26_4K; printf("Unrecognized cart type!\n"); break; } } if (has_ram) m_cart->ram_alloc(get_software_region_length("ram")); } else { fread(ROM, len); m_type = identify_cart_type(ROM, len); // check for Special Chip (128bytes of RAM) if (len == 0x2000 || len == 0x4000 || len == 0x8000) if (detect_super_chip(ROM, len)) { m_cart->ram_alloc(0x80); //printf("Super Chip detected!\n"); } // Super chip games: // dig dig, crystal castles, millipede, stargate, defender ii, jr. Pac Man, // desert falcon, dark chambers, super football, sprintmaster, fatal run, // off the wall, shooting arcade, secret quest, radar lock, save mary, klax // add CBS RAM+ (256bytes of RAM) if (m_type == A26_FA) m_cart->ram_alloc(0x100); // add M Network RAM else if (m_type == A26_E7) m_cart->ram_alloc(0x800); // add Commavid RAM else if (m_type == A26_CV) m_cart->ram_alloc(0x400); // add Starpath Superchager RAM else if (m_type == A26_SS) m_cart->ram_alloc(0x1800); // add Boulder Dash RAM else if (m_type == A26_3E) m_cart->ram_alloc(0x8000); } //printf("Type: %s\n", vcs_get_slot(m_type)); // pass a pointer to the now allocated ROM for the DPC chip if (m_type == A26_DPC) m_cart->setup_addon_ptr((uint8_t *)m_cart->get_rom_base() + 0x2000); return image_init_result::PASS; } return image_init_result::PASS; }
void sega8_cart_slot_device::setup_ram() { if (software_entry() == nullptr) { if (m_type == SEGA8_CASTLE) { m_cart->ram_alloc(0x2000); m_cart->set_has_battery(FALSE); } else if (m_type == SEGA8_OTHELLO) { m_cart->ram_alloc(0x800); m_cart->set_has_battery(FALSE); } else if (m_type == SEGA8_BASIC_L3) { m_cart->ram_alloc(0x8000); m_cart->set_has_battery(FALSE); } else if (m_type == SEGA8_MUSIC_EDITOR) { m_cart->ram_alloc(0x2800); m_cart->set_has_battery(FALSE); } else if (m_type == SEGA8_DAHJEE_TYPEA) { m_cart->ram_alloc(0x2400); m_cart->set_has_battery(FALSE); } else if (m_type == SEGA8_DAHJEE_TYPEB) { m_cart->ram_alloc(0x2000); m_cart->set_has_battery(FALSE); } else if (m_type == SEGA8_CODEMASTERS) { // Codemasters cart can have 64KB of RAM (Ernie Els Golf? or 8KB?) and no battery m_cart->ram_alloc(0x10000); m_cart->set_has_battery(FALSE); } else { // for generic carts loaded from fullpath we have no way to know exactly if there was RAM, // how much RAM was in the cart and if there was a battery so we always alloc 32KB and // we save its content only if the game enable the RAM m_cart->set_late_battery(TRUE); m_cart->ram_alloc(0x08000); } } else { // from softlist we rely on the xml to only allocate the correct amount of RAM and to save it only if a battery was present const char *battery = get_feature("battery"); m_cart->set_late_battery(FALSE); if (get_software_region_length("ram")) m_cart->ram_alloc(get_software_region_length("ram")); if (battery && !strcmp(battery, "yes")) m_cart->set_has_battery(TRUE); } }
bool a78_cart_slot_device::call_load() { if (m_cart) { UINT32 len; if (software_entry() != nullptr) { const char *pcb_name; bool has_ram = get_software_region("ram") ? TRUE : FALSE; bool has_nvram = get_software_region("nvram") ? TRUE : FALSE; len = get_software_region_length("rom"); m_cart->rom_alloc(len, tag()); memcpy(m_cart->get_rom_base(), get_software_region("rom"), len); if ((pcb_name = get_feature("slot")) != nullptr) m_type = a78_get_pcb_id(pcb_name); else m_type = A78_TYPE0; if (has_ram) m_cart->ram_alloc(get_software_region_length("ram")); if (has_nvram) { m_cart->nvram_alloc(get_software_region_length("nvram")); battery_load(m_cart->get_nvram_base(), get_software_region_length("nvram"), 0xff); } } else { // Load and check the header int mapper; char head[128]; fread(head, 128); if (verify_header((char *)head) == IMAGE_VERIFY_FAIL) return IMAGE_INIT_FAIL; len = (head[49] << 24) | (head[50] << 16) | (head[51] << 8) | head[52]; if (len + 128 > length()) { logerror("Invalid length in the header. The game might be corrupted.\n"); len = length() - 128; } // let's try to auto-fix some common errors in the header mapper = validate_header((head[53] << 8) | head[54], TRUE); switch (mapper & 0x2e) { case 0x0000: m_type = BIT(mapper, 0) ? A78_TYPE1 : A78_TYPE0; break; case 0x0002: m_type = BIT(mapper, 0) ? A78_TYPE3 : A78_TYPE2; break; case 0x0006: m_type = A78_TYPE6; break; case 0x000a: m_type = A78_TYPEA; break; case 0x0022: case 0x0026: if (len > 0x40000) m_type = A78_MEGACART; else m_type = A78_VERSABOARD; break; } // check if cart has a POKEY at $0450 (typically a VersaBoard variant) if (mapper & 0x40) { if (m_type != A78_TYPE2) { m_type &= ~0x02; m_type += A78_POKEY0450; } } // check special bits, which override the previous if ((mapper & 0xff00) == 0x0100) m_type = A78_ACTIVISION; else if ((mapper & 0xff00) == 0x0200) m_type = A78_ABSOLUTE; logerror("Cart type: 0x%x\n", m_type); if (head[58] == 1) { osd_printf_info("This cart supports external NVRAM using HSC.\n"); osd_printf_info("Run it with the High Score Cart mounted to exploit this feature.\n"); } else if (head[58] == 2) { osd_printf_info("This cart supports external NVRAM using SaveKey.\n"); osd_printf_info("This is not supported in MAME currently.\n"); } if (head[63]) { osd_printf_info("This cart requires XBoarD / XM expansion\n"); osd_printf_info("Run it through the expansion to exploit this feature.\n"); } internal_header_logging((UINT8 *)head, length()); m_cart->rom_alloc(len, tag()); fread(m_cart->get_rom_base(), len); if (m_type == A78_TYPE6) m_cart->ram_alloc(0x4000); if (m_type == A78_MEGACART || (m_type >= A78_VERSABOARD && m_type <= A78_VERSA_POK450)) m_cart->ram_alloc(0x8000); if (m_type == A78_XB_BOARD || m_type == A78_XM_BOARD) m_cart->ram_alloc(0x20000); if (m_type == A78_HSC || m_type == A78_XM_BOARD) { m_cart->nvram_alloc(0x800); battery_load(m_cart->get_nvram_base(), 0x800, 0xff); } } //printf("Type: %s\n", a78_get_slot(m_type)); } return IMAGE_INIT_PASS; }
bool device_image_interface::load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args, bool just_load) { UINT32 open_plan[4]; int i; bool softload = FALSE; m_from_swlist = FALSE; // if the path contains no period, we are using softlists, so we won't create an image astring pathstr(path); bool filename_has_period = (pathstr.rchr(0, '.') != -1) ? TRUE : FALSE; /* first unload the image */ unload(); /* clear any possible error messages */ clear_error(); /* we are now loading */ m_is_loading = TRUE; /* record the filename */ m_err = set_image_filename(path); if (m_err) goto done; if (core_opens_image_file()) { /* Check if there's a software list defined for this device and use that if we're not creating an image */ if (!filename_has_period && !just_load) { softload = load_software_part(path, m_software_part_ptr); if (softload) { m_software_info_ptr = &m_software_part_ptr->info(); m_software_list_name.cpy(m_software_info_ptr->list().list_name()); m_full_software_name.cpy(m_software_part_ptr->info().shortname()); // if we had launched from softlist with a specified part, e.g. "shortname:part" // we would have recorded the wrong name, so record it again based on software_info if (m_software_info_ptr && m_full_software_name) m_err = set_image_filename(m_full_software_name); // check if image should be read-only const char *read_only = get_feature("read_only"); if (read_only && !strcmp(read_only, "true")) { make_readonly(); } m_from_swlist = TRUE; } } if (is_create || filename_has_period) { /* determine open plan */ determine_open_plan(is_create, open_plan); /* attempt to open the file in various ways */ for (i = 0; !m_file && open_plan[i]; i++) { /* open the file */ m_err = load_image_by_path(open_plan[i], path); if (m_err && (m_err != IMAGE_ERROR_FILENOTFOUND)) goto done; } } /* Copy some image information when we have been loaded through a software list */ if ( m_software_info_ptr ) { // sanitize if (m_software_info_ptr->longname() == NULL || m_software_info_ptr->publisher() == NULL || m_software_info_ptr->year() == NULL) fatalerror("Each entry in an XML list must have all of the following fields: description, publisher, year!\n"); // store m_longname = m_software_info_ptr->longname(); m_manufacturer = m_software_info_ptr->publisher(); m_year = m_software_info_ptr->year(); //m_playable = m_software_info_ptr->supported(); } /* did we fail to find the file? */ if (!is_loaded() && !softload) { m_err = IMAGE_ERROR_FILENOTFOUND; goto done; } } /* call device load or create */ m_create_format = create_format; m_create_args = create_args; if (m_init_phase==FALSE) { m_err = (image_error_t)finish_load(); if (m_err) goto done; } /* success! */ done: if (just_load) { if(m_err) clear(); return m_err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS; } if (m_err!=0) { if (!m_init_phase) { if (device().machine().phase() == MACHINE_PHASE_RUNNING) popmessage("Error: Unable to %s image '%s': %s", is_create ? "create" : "load", path, error()); else osd_printf_error("Error: Unable to %s image '%s': %s\n", is_create ? "create" : "load", path, error()); } clear(); } else { /* do we need to reset the CPU? only schedule it if load/create is successful */ if (device().machine().time() > attotime::zero && is_reset_on_load()) device().machine().schedule_hard_reset(); else { if (!m_init_phase) { if (device().machine().phase() == MACHINE_PHASE_RUNNING) popmessage("Image '%s' was successfully %s.", path, is_create ? "created" : "loaded"); else osd_printf_info("Image '%s' was successfully %s.\n", path, is_create ? "created" : "loaded"); } } } return m_err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS; }
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; }
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; }
bool c64_expansion_slot_device::call_load() { if (m_card) { size_t size = 0; if (software_entry() == NULL) { size = length(); if (!mame_stricmp(filetype(), "80")) { fread(m_card->m_roml, size); m_card->m_exrom = (0); if (size == 0x4000) { m_card->m_game = 0; } } else if (!mame_stricmp(filetype(), "a0")) { fread(m_card->m_romh, 0x2000); m_card->m_exrom = 0; m_card->m_game = 0; } else if (!mame_stricmp(filetype(), "e0")) { fread(m_card->m_romh, 0x2000); m_card->m_game = 0; } else if (!mame_stricmp(filetype(), "crt")) { size_t roml_size = 0; size_t romh_size = 0; int exrom = 1; int game = 1; if (cbm_crt_read_header(m_file, &roml_size, &romh_size, &exrom, &game)) { UINT8 *roml = NULL; UINT8 *romh = NULL; m_card->m_roml.allocate(roml_size); m_card->m_romh.allocate(romh_size); if (roml_size) roml = m_card->m_roml; if (romh_size) romh = m_card->m_roml; cbm_crt_read_data(m_file, roml, romh); } m_card->m_exrom = exrom; m_card->m_game = game; } } else { size = get_software_region_length("uprom"); if (size) { // Ultimax (VIC-10) cartridge load_software_region("lorom", m_card->m_roml); load_software_region("uprom", m_card->m_romh); m_card->m_exrom = 1; m_card->m_game = 0; } else { // Commodore 64/128 cartridge load_software_region("roml", m_card->m_roml); load_software_region("romh", m_card->m_romh); load_software_region("nvram", m_card->m_nvram); if (get_feature("exrom") != NULL) m_card->m_exrom = atol(get_feature("exrom")); if (get_feature("game") != NULL) m_card->m_game = atol(get_feature("game")); } } } return IMAGE_INIT_PASS; }
image_init_result device_image_interface::load_software(const std::string &software_identifier) { // Prepare to load unload(); clear_error(); m_is_loading = true; // Check if there's a software list defined for this device and use that if we're not creating an image std::string list_name; bool softload = load_software_part(software_identifier, m_software_part_ptr, &list_name); if (!softload) { m_is_loading = false; return image_init_result::FAIL; } // set up softlist stuff m_software_info_ptr = &m_software_part_ptr->info(); m_software_list_name = std::move(list_name); m_full_software_name = m_software_part_ptr->info().shortname(); // specify image name with softlist-derived names m_image_name = m_full_software_name; m_basename = m_full_software_name; m_basename_noext = m_full_software_name; m_filetype = use_software_list_file_extension_for_filetype() && m_mame_file != nullptr ? core_filename_extract_extension(m_mame_file->filename(), true) : ""; // check if image should be read-only const char *read_only = get_feature("read_only"); if (read_only && !strcmp(read_only, "true")) { // Copy some image information when we have been loaded through a software list if (m_software_info_ptr) { // sanitize if (m_software_info_ptr->longname().empty() || m_software_info_ptr->publisher().empty() || m_software_info_ptr->year().empty()) fatalerror("Each entry in an XML list must have all of the following fields: description, publisher, year!\n"); // store m_longname = m_software_info_ptr->longname(); m_manufacturer = m_software_info_ptr->publisher(); m_year = m_software_info_ptr->year(); // set file type std::string filename = (m_mame_file != nullptr) && (m_mame_file->filename() != nullptr) ? m_mame_file->filename() : ""; m_filetype = core_filename_extract_extension(filename, true); } } // call finish_load if necessary if (m_init_phase == false && (finish_load() != image_init_result::PASS)) return image_init_result::FAIL; // do we need to reset the CPU? only schedule it if load is successful if (!schedule_postload_hard_reset_if_needed()) { if (!m_init_phase) { if (device().machine().phase() == MACHINE_PHASE_RUNNING) device().popmessage("Image '%s' was successfully loaded.", software_identifier); else osd_printf_info("Image '%s' was successfully loaded.\n", software_identifier.c_str()); } } return image_init_result::PASS; }