src/emu/diimage.h
| r8445 | r8446 | |
| 200 | 200 | virtual bool load(const char *path) = 0; |
| 201 | 201 | virtual bool finish_load() = 0; |
| 202 | 202 | virtual void unload() = 0; |
| 203 | virtual bool load_software(char *swlist, char *swname, rom_entry *entry) = 0; |
| 203 | 204 | |
| 204 | 205 | virtual int call_load() = 0; |
| 205 | 206 | virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) = 0; |
| r8445 | r8446 | |
| 293 | 294 | |
| 294 | 295 | /* variables that are only non-zero when an image is mounted */ |
| 295 | 296 | core_file *m_file; |
| 297 | mame_file *m_mame_file; |
| 296 | 298 | astring m_name; |
| 297 | 299 | astring m_basename; |
| 298 | 300 | astring m_basename_noext; |
src/emu/devimage.c
| r8445 | r8446 | |
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | #include "emu.h" |
| 42 | #include "emuopts.h" |
| 42 | 43 | #include "devlegcy.h" |
| 43 | 44 | #include "hashfile.h" |
| 44 | 45 | #include "zippath.h" |
| r8445 | r8446 | |
| 214 | 215 | |
| 215 | 216 | bool legacy_image_device_base::is_loaded() |
| 216 | 217 | { |
| 217 | | return (m_file != NULL) || (m_software_info_ptr != NULL); |
| 218 | return (m_file != NULL); |
| 218 | 219 | } |
| 219 | 220 | |
| 220 | 221 | /*------------------------------------------------- |
| r8445 | r8446 | |
| 295 | 296 | } |
| 296 | 297 | |
| 297 | 298 | /*------------------------------------------------- |
| 299 | load_software - software image loading |
| 300 | -------------------------------------------------*/ |
| 301 | bool legacy_image_device_base::load_software(char *swlist, char *swname, rom_entry *start) |
| 302 | { |
| 303 | const rom_entry *region; |
| 304 | astring regiontag; |
| 305 | bool retVal = FALSE; |
| 306 | for (region = start; region != NULL; region = rom_next_region(region)) |
| 307 | { |
| 308 | /* loop until we hit the end of this region */ |
| 309 | const rom_entry *romp = region + 1; |
| 310 | while (!ROMENTRY_ISREGIONEND(romp)) |
| 311 | { |
| 312 | /* handle files */ |
| 313 | if (ROMENTRY_ISFILE(romp)) |
| 314 | { |
| 315 | UINT32 crc = 0; |
| 316 | UINT8 crcbytes[4]; |
| 317 | file_error filerr; |
| 318 | |
| 319 | bool has_crc = hash_data_extract_binary_checksum(ROM_GETHASHDATA(romp), HASH_CRC, crcbytes); |
| 320 | if (has_crc) |
| 321 | crc = (crcbytes[0] << 24) | (crcbytes[1] << 16) | (crcbytes[2] << 8) | crcbytes[3]; |
| 322 | |
| 323 | astring fname(swlist, PATH_SEPARATOR, swname, PATH_SEPARATOR, ROM_GETNAME(romp)); |
| 324 | if (has_crc) |
| 325 | filerr = mame_fopen_crc(SEARCHPATH_ROM, fname, crc, OPEN_FLAG_READ, &m_mame_file); |
| 326 | else |
| 327 | filerr = mame_fopen(SEARCHPATH_ROM, fname, OPEN_FLAG_READ, &m_mame_file); |
| 328 | |
| 329 | if (filerr == FILERR_NONE) |
| 330 | { |
| 331 | m_file = mame_core_file(m_mame_file); |
| 332 | retVal = TRUE; |
| 333 | } |
| 334 | break; // load first item for start |
| 335 | } |
| 336 | romp++; /* something else; skip */ |
| 337 | } |
| 338 | } |
| 339 | return retVal; |
| 340 | } |
| 341 | |
| 342 | /*------------------------------------------------- |
| 298 | 343 | load_internal - core image loading |
| 299 | 344 | -------------------------------------------------*/ |
| 300 | 345 | |
| r8445 | r8446 | |
| 320 | 365 | goto done; |
| 321 | 366 | |
| 322 | 367 | /* Check if there's a software list defined for this device and use that if we're not creating an image */ |
| 323 | | if (is_create || !(softload=load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name )) ) |
| 368 | softload = load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name ); |
| 369 | if (is_create || (!softload && m_software_info_ptr==NULL)) |
| 324 | 370 | { |
| 325 | 371 | /* determine open plan */ |
| 326 | 372 | determine_open_plan(is_create, open_plan); |
| r8445 | r8446 | |
| 461 | 507 | |
| 462 | 508 | void legacy_image_device_base::clear() |
| 463 | 509 | { |
| 464 | | if (m_file) |
| 510 | if (m_mame_file) |
| 465 | 511 | { |
| 466 | | core_fclose(m_file); |
| 467 | | m_file = NULL; |
| 468 | | } |
| 512 | mame_fclose(m_mame_file); |
| 513 | m_mame_file = NULL; |
| 514 | m_file = NULL; |
| 515 | } else { |
| 516 | if (m_file) |
| 517 | { |
| 518 | core_fclose(m_file); |
| 519 | m_file = NULL; |
| 520 | } |
| 521 | } |
| 469 | 522 | |
| 470 | 523 | m_name.reset(); |
| 471 | 524 | m_writeable = FALSE; |
| r8445 | r8446 | |
| 549 | 602 | void *legacy_image_device_base::get_device_specific_call() |
| 550 | 603 | { |
| 551 | 604 | return (void*) m_config.get_legacy_config_fct(DEVINFO_FCT_DEVICE_SPECIFIC); |
| 552 | | } |
| 605 | } |
| | No newline at end of file |