image: Fix initialisation order, fix file menu enable, refine gdrom support

This commit is contained in:
Olivier Galibert 2023-05-08 20:40:19 +02:00
parent b2cbad36f2
commit 73ec0c4c68
6 changed files with 23 additions and 18 deletions

View file

@ -65,11 +65,7 @@ void cdrom_image_device::device_config_complete()
void cdrom_image_device::device_start()
{
if (has_preset_images())
{
set_image_tag();
set_user_loadable(false);
setup_current_preset_image();
}
else
{
m_cdrom_handle.reset();
@ -83,7 +79,7 @@ void cdrom_image_device::setup_current_preset_image()
m_dvdrom_handle.reset();
chd_file *chd = current_preset_image_chd();
if (chd->is_cd() || chd->is_gd())
if (chd->is_cd() || (m_gd_compat && chd->is_gd()))
m_cdrom_handle = std::make_unique<cdrom_file>(chd);
else if(m_dvd_compat && chd->is_dvd())
m_dvdrom_handle = std::make_unique<dvdrom_file>(chd);
@ -101,6 +97,7 @@ void cdrom_image_device::device_stop()
std::pair<std::error_condition, std::string> cdrom_image_device::call_load()
{
fprintf(stderr, "HERE B\n");
if (has_preset_images())
{
setup_current_preset_image();
@ -130,7 +127,7 @@ std::pair<std::error_condition, std::string> cdrom_image_device::call_load()
// open the CHD file
if (chd)
{
if (chd->is_cd() || chd->is_gd())
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));

View file

@ -107,11 +107,9 @@ void harddisk_image_device::device_start()
m_chd = nullptr;
if (has_preset_images()) {
set_image_tag();
set_user_loadable(false);
if (has_preset_images())
setup_current_preset_image();
} else
else
m_hard_disk_handle.reset();
}

View file

@ -116,10 +116,11 @@ void device_image_interface::interface_config_complete()
}
//-------------------------------------------------
// interface_pre_start - lookup the chds, if any
// check_preset_images - lookup the chds from the
// region(s), if any
//-------------------------------------------------
void device_image_interface::interface_pre_start()
void device_image_interface::check_preset_images()
{
if (!m_possible_preset_regions.empty())
{
@ -133,6 +134,8 @@ void device_image_interface::interface_pre_start()
if (m_current_region == int(m_preset_images.size()))
fatalerror("%s: No configured region has an image\n", device().tag());
}
set_image_tag();
set_user_loadable(false);
}
else
{
@ -143,6 +146,8 @@ void device_image_interface::interface_pre_start()
m_possible_preset_regions.push_back(tag);
m_preset_images.push_back(chd);
m_current_region = 0;
set_image_tag();
set_user_loadable(false);
}
}
}

View file

@ -102,6 +102,7 @@ public:
int current_preset_image_id() const;
void switch_preset_image(int id);
chd_file *current_preset_image_chd() const;
void check_preset_images();
const image_device_format *device_get_indexed_creatable_format(int index) const noexcept { return (index < m_formatlist.size()) ? m_formatlist.at(index).get() : nullptr; }
const image_device_format *device_get_named_creatable_format(std::string_view format_name) const noexcept;
@ -221,7 +222,6 @@ public:
protected:
// interface-level overrides
virtual void interface_config_complete() override;
virtual void interface_pre_start() override;
virtual const software_list_loader &get_software_list_loader() const;
virtual bool use_software_list_file_extension_for_filetype() const noexcept { return false; }

View file

@ -40,6 +40,9 @@ image_manager::image_manager(running_machine &machine)
// make sure that any required devices have been allocated
for (device_image_interface &image : image_interface_enumerator(machine.root_device()))
{
// see if region-based chds are available
image.check_preset_images();
// ignore things not user loadable
if (!image.user_loadable())
continue;

View file

@ -127,16 +127,18 @@ void menu_main::populate()
item_append(_("menu-main", "Warning Information"), 0, (void *)WARN_INFO);
for (device_image_interface &image : image_interface_enumerator(machine().root_device()))
{
if (image.user_loadable())
{
item_append(_("menu-main", "Media Image Information"), 0, (void *)IMAGE_MENU_IMAGE_INFO);
item_append(_("menu-main", "File Manager"), 0, (void *)IMAGE_MENU_FILE_MANAGER);
break;
}
}
for (device_image_interface &image : image_interface_enumerator(machine().root_device()))
if (image.user_loadable() || image.has_preset_images_selection())
{
item_append(_("menu-main", "File Manager"), 0, (void *)IMAGE_MENU_FILE_MANAGER);
break;
}
if (cassette_device_enumerator(machine().root_device()).first() != nullptr)
item_append(_("menu-main", "Tape Control"), 0, (void *)TAPE_CONTROL);