diff options
Diffstat (limited to 'src/devices/imagedev/cdromimg.cpp')
-rw-r--r-- | src/devices/imagedev/cdromimg.cpp | 81 |
1 files changed, 59 insertions, 22 deletions
diff --git a/src/devices/imagedev/cdromimg.cpp b/src/devices/imagedev/cdromimg.cpp index c5e0a7fbad6..b4deb9fc4ad 100644 --- a/src/devices/imagedev/cdromimg.cpp +++ b/src/devices/imagedev/cdromimg.cpp @@ -79,9 +79,9 @@ void cdrom_image_device::setup_current_preset_image() m_dvdrom_handle.reset(); chd_file *chd = current_preset_image_chd(); - if (chd->is_cd() || (m_gd_compat && chd->is_gd())) + if (!chd->check_is_cd() || (m_gd_compat && !chd->check_is_gd())) m_cdrom_handle = std::make_unique<cdrom_file>(chd); - else if(m_dvd_compat && chd->is_dvd()) + else if(m_dvd_compat && !chd->check_is_dvd()) m_dvdrom_handle = std::make_unique<dvdrom_file>(chd); else fatalerror("chd for region %s is not compatible with the cdrom image device\n", preset_images_list()[current_preset_image_id()]); @@ -109,8 +109,10 @@ std::pair<std::error_condition, std::string> cdrom_image_device::call_load() m_cdrom_handle.reset(); m_dvdrom_handle.reset(); - if (!loaded_through_softlist()) { - if (is_filetype("chd") && is_loaded()) { + if (!loaded_through_softlist()) + { + if (is_filetype("chd") && is_loaded()) + { util::core_file::ptr proxy; err = util::core_file::open_proxy(image_core_file(), proxy); if (!err) @@ -119,35 +121,56 @@ std::pair<std::error_condition, std::string> cdrom_image_device::call_load() goto error; chd = &m_self_chd; } - } else { - chd = device().machine().rom_load().get_disk_handle(device().subtag("cdrom").c_str()); + } + else + { + chd = device().machine().rom_load().get_disk_handle(device().subtag("cdrom")); } // open the CHD file if (chd) { - if (chd->is_cd() || (m_gd_compat && chd->is_gd())) - m_cdrom_handle.reset(new cdrom_file(chd)); - else if(m_dvd_compat && chd->is_dvd()) - m_dvdrom_handle.reset(new dvdrom_file(chd)); - else + err = chd->check_is_cd(); + if (err == chd_file::error::METADATA_NOT_FOUND && m_gd_compat) + err = chd->check_is_gd(); + if (!err) { - err = image_error::UNSUPPORTED; + m_cdrom_handle.reset(new cdrom_file(chd)); + return std::make_pair(std::error_condition(), std::string()); + } + if (err != chd_file::error::METADATA_NOT_FOUND) goto error; + + if (m_dvd_compat) + { + err = chd->check_is_dvd(); + if (!err) + { + m_dvdrom_handle.reset(new dvdrom_file(chd)); + return std::make_pair(std::error_condition(), std::string()); + } + if (err != chd_file::error::METADATA_NOT_FOUND) + goto error; } - m_cdrom_handle.reset(new cdrom_file(chd)); + + err = image_error::INVALIDIMAGE; + goto error; } else { - try { - auto *cdrom = new cdrom_file(filename()); - m_cdrom_handle.reset(cdrom); - } catch(void *) { - try { - auto *dvdrom = new dvdrom_file(filename()); - m_dvdrom_handle.reset(dvdrom); - } catch(void *) { - err = image_error::UNSUPPORTED; + try + { + m_cdrom_handle.reset(new cdrom_file(filename())); + } + catch (...) + { + try + { + m_dvdrom_handle.reset(new dvdrom_file(filename())); + } + catch (...) + { + err = image_error::INVALIDIMAGE; goto error; } } @@ -177,6 +200,13 @@ int cdrom_image_device::get_last_track() const return 0; } +int cdrom_image_device::get_last_session() const +{ + if (m_cdrom_handle) + return m_cdrom_handle->get_last_session(); + return 0; +} + uint32_t cdrom_image_device::get_track(uint32_t frame) const { if (m_cdrom_handle) @@ -184,6 +214,13 @@ uint32_t cdrom_image_device::get_track(uint32_t frame) const return 0; } +uint32_t cdrom_image_device::get_track_index(uint32_t frame) const +{ + if (m_cdrom_handle) + return m_cdrom_handle->get_track_index(frame); + return 0; +} + uint32_t cdrom_image_device::get_track_start(uint32_t track) const { if (m_cdrom_handle) |