summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/emu/imagedev/chd_cd.c20
-rw-r--r--src/emu/imagedev/chd_cd.h1
-rw-r--r--src/emu/imagedev/harddriv.c21
-rw-r--r--src/emu/imagedev/harddriv.h1
-rw-r--r--src/emu/machine/scsicd.c23
-rw-r--r--src/emu/machine/scsicd.h2
-rw-r--r--src/emu/machine/scsihd.c25
-rw-r--r--src/emu/machine/scsihd.h2
8 files changed, 42 insertions, 53 deletions
diff --git a/src/emu/imagedev/chd_cd.c b/src/emu/imagedev/chd_cd.c
index 5a2b5496fb3..b67d485ecd6 100644
--- a/src/emu/imagedev/chd_cd.c
+++ b/src/emu/imagedev/chd_cd.c
@@ -84,7 +84,22 @@ const option_guide *cdrom_image_device::create_option_guide() const
void cdrom_image_device::device_start()
{
- m_cdrom_handle = NULL;
+ // try to locate the CHD from a DISK_REGION
+ chd_file *chd = get_disk_handle( machine(), owner()->tag() );
+ if( chd != NULL )
+ {
+ m_cdrom_handle = cdrom_open( chd );
+ }
+ else
+ {
+ m_cdrom_handle = NULL;
+ }
+}
+
+void cdrom_image_device::device_stop()
+{
+ if (m_cdrom_handle)
+ cdrom_close(m_cdrom_handle);
}
bool cdrom_image_device::call_load()
@@ -93,6 +108,9 @@ bool cdrom_image_device::call_load()
chd_file *chd = NULL;
astring tempstring;
+ if (m_cdrom_handle)
+ cdrom_close(m_cdrom_handle);
+
if (software_entry() == NULL)
{
if (strstr(m_image_name,".chd") && is_loaded()) {
diff --git a/src/emu/imagedev/chd_cd.h b/src/emu/imagedev/chd_cd.h
index f01ec4b1f98..5c9af0ebf6b 100644
--- a/src/emu/imagedev/chd_cd.h
+++ b/src/emu/imagedev/chd_cd.h
@@ -56,6 +56,7 @@ protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
+ virtual void device_stop();
chd_file m_self_chd;
cdrom_file *m_cdrom_handle;
diff --git a/src/emu/imagedev/harddriv.c b/src/emu/imagedev/harddriv.c
index f3c5890c6c4..8f9f80e3a82 100644
--- a/src/emu/imagedev/harddriv.c
+++ b/src/emu/imagedev/harddriv.c
@@ -101,7 +101,23 @@ const option_guide *harddisk_image_device::create_option_guide() const
void harddisk_image_device::device_start()
{
m_chd = NULL;
- m_hard_disk_handle = NULL;
+
+ // try to locate the CHD from a DISK_REGION
+ chd_file *handle = get_disk_handle(machine(), owner()->tag());
+ if (handle != NULL)
+ {
+ m_hard_disk_handle = hard_disk_open(handle);
+ }
+ else
+ {
+ m_hard_disk_handle = NULL;
+ }
+}
+
+void harddisk_image_device::device_stop()
+{
+ if (m_hard_disk_handle)
+ hard_disk_close(m_hard_disk_handle);
}
bool harddisk_image_device::call_load()
@@ -224,6 +240,9 @@ int harddisk_image_device::internal_load_hd()
m_chd = NULL;
+ if (m_hard_disk_handle)
+ hard_disk_close(m_hard_disk_handle);
+
/* open the CHD file */
if (software_entry() != NULL)
{
diff --git a/src/emu/imagedev/harddriv.h b/src/emu/imagedev/harddriv.h
index 374adf6302c..53691049d01 100644
--- a/src/emu/imagedev/harddriv.h
+++ b/src/emu/imagedev/harddriv.h
@@ -63,6 +63,7 @@ protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
+ virtual void device_stop();
int internal_load_hd();
diff --git a/src/emu/machine/scsicd.c b/src/emu/machine/scsicd.c
index 2ca9caa4b38..30e2889eecf 100644
--- a/src/emu/machine/scsicd.c
+++ b/src/emu/machine/scsicd.c
@@ -49,21 +49,9 @@ void scsicd_device::device_reset()
{
scsihle_device::device_reset();
- is_file = TRUE;
cdrom = subdevice<cdrom_image_device>("image")->get_cdrom_file();
if( !cdrom )
{
- // try to locate the CHD from a DISK_REGION
- chd_file *chd = get_disk_handle( machine(), tag() );
- if( chd != NULL )
- {
- is_file = FALSE;
- cdrom = cdrom_open( chd );
- }
- }
-
- if( !cdrom )
- {
logerror( "SCSICD %s: no CD found!\n", tag() );
}
@@ -76,17 +64,6 @@ void scsicd_device::device_reset()
play_err_flag = 0;
}
-void scsicd_device::device_stop()
-{
- if (!is_file)
- {
- if( cdrom )
- {
- cdrom_close( cdrom );
- }
- }
-}
-
cdrom_interface scsicd_device::cd_intf = { 0, 0 };
static MACHINE_CONFIG_FRAGMENT(scsi_cdrom)
diff --git a/src/emu/machine/scsicd.h b/src/emu/machine/scsicd.h
index c5ed9f91ebf..79aa0e53648 100644
--- a/src/emu/machine/scsicd.h
+++ b/src/emu/machine/scsicd.h
@@ -31,7 +31,6 @@ protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
- virtual void device_stop();
private:
UINT32 lba;
@@ -42,7 +41,6 @@ private:
UINT32 cur_subblock;
UINT32 play_err_flag;
cdrom_file *cdrom;
- bool is_file;
};
// device type definition
diff --git a/src/emu/machine/scsihd.c b/src/emu/machine/scsihd.c
index 44a908090bd..1dadc75eaeb 100644
--- a/src/emu/machine/scsihd.c
+++ b/src/emu/machine/scsihd.c
@@ -35,23 +35,11 @@ void scsihd_device::device_reset()
{
scsihle_device::device_reset();
- is_image_device = true;
- disk = subdevice<harddisk_image_device>("image")->get_hard_disk_file();
- if( !disk )
- {
- // try to locate the CHD from a DISK_REGION
- chd_file *handle = get_disk_handle(machine(), tag());
- if (handle != NULL)
- {
- is_image_device = false;
- disk = hard_disk_open(handle);
- }
- }
-
lba = 0;
blocks = 0;
sectorbytes = 512;
+ disk = subdevice<harddisk_image_device>("image")->get_hard_disk_file();
if (!disk)
{
logerror("%s SCSIHD: no HD found!\n", tag());
@@ -64,17 +52,6 @@ void scsihd_device::device_reset()
}
}
-void scsihd_device::device_stop()
-{
- if (!is_image_device)
- {
- if( disk )
- {
- hard_disk_close( disk );
- }
- }
-}
-
static MACHINE_CONFIG_FRAGMENT(scsi_harddisk)
MCFG_HARDDISK_ADD("image")
MACHINE_CONFIG_END
diff --git a/src/emu/machine/scsihd.h b/src/emu/machine/scsihd.h
index 0328764466d..ee48788e807 100644
--- a/src/emu/machine/scsihd.h
+++ b/src/emu/machine/scsihd.h
@@ -29,14 +29,12 @@ protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
- virtual void device_stop();
private:
UINT32 lba;
UINT32 blocks;
int sectorbytes;
hard_disk_file *disk;
- bool is_image_device;
};
// device type definition