mirror of
https://github.com/holub/mame
synced 2025-07-05 09:57:47 +03:00
made cdrom_image_device & harddisk_image_device responsible for accessing driver based chd's (nw)
This commit is contained in:
parent
1277cbbddd
commit
f5a8f929ff
@ -83,9 +83,24 @@ const option_guide *cdrom_image_device::create_option_guide() const
|
|||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void cdrom_image_device::device_start()
|
void cdrom_image_device::device_start()
|
||||||
|
{
|
||||||
|
// 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;
|
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()
|
bool cdrom_image_device::call_load()
|
||||||
{
|
{
|
||||||
@ -93,6 +108,9 @@ bool cdrom_image_device::call_load()
|
|||||||
chd_file *chd = NULL;
|
chd_file *chd = NULL;
|
||||||
astring tempstring;
|
astring tempstring;
|
||||||
|
|
||||||
|
if (m_cdrom_handle)
|
||||||
|
cdrom_close(m_cdrom_handle);
|
||||||
|
|
||||||
if (software_entry() == NULL)
|
if (software_entry() == NULL)
|
||||||
{
|
{
|
||||||
if (strstr(m_image_name,".chd") && is_loaded()) {
|
if (strstr(m_image_name,".chd") && is_loaded()) {
|
||||||
|
@ -56,6 +56,7 @@ protected:
|
|||||||
// device-level overrides
|
// device-level overrides
|
||||||
virtual void device_config_complete();
|
virtual void device_config_complete();
|
||||||
virtual void device_start();
|
virtual void device_start();
|
||||||
|
virtual void device_stop();
|
||||||
|
|
||||||
chd_file m_self_chd;
|
chd_file m_self_chd;
|
||||||
cdrom_file *m_cdrom_handle;
|
cdrom_file *m_cdrom_handle;
|
||||||
|
@ -101,8 +101,24 @@ const option_guide *harddisk_image_device::create_option_guide() const
|
|||||||
void harddisk_image_device::device_start()
|
void harddisk_image_device::device_start()
|
||||||
{
|
{
|
||||||
m_chd = NULL;
|
m_chd = 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;
|
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()
|
bool harddisk_image_device::call_load()
|
||||||
{
|
{
|
||||||
@ -224,6 +240,9 @@ int harddisk_image_device::internal_load_hd()
|
|||||||
|
|
||||||
m_chd = NULL;
|
m_chd = NULL;
|
||||||
|
|
||||||
|
if (m_hard_disk_handle)
|
||||||
|
hard_disk_close(m_hard_disk_handle);
|
||||||
|
|
||||||
/* open the CHD file */
|
/* open the CHD file */
|
||||||
if (software_entry() != NULL)
|
if (software_entry() != NULL)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +63,7 @@ protected:
|
|||||||
// device-level overrides
|
// device-level overrides
|
||||||
virtual void device_config_complete();
|
virtual void device_config_complete();
|
||||||
virtual void device_start();
|
virtual void device_start();
|
||||||
|
virtual void device_stop();
|
||||||
|
|
||||||
int internal_load_hd();
|
int internal_load_hd();
|
||||||
|
|
||||||
|
@ -49,19 +49,7 @@ void scsicd_device::device_reset()
|
|||||||
{
|
{
|
||||||
scsihle_device::device_reset();
|
scsihle_device::device_reset();
|
||||||
|
|
||||||
is_file = TRUE;
|
|
||||||
cdrom = subdevice<cdrom_image_device>("image")->get_cdrom_file();
|
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 )
|
if( !cdrom )
|
||||||
{
|
{
|
||||||
logerror( "SCSICD %s: no CD found!\n", tag() );
|
logerror( "SCSICD %s: no CD found!\n", tag() );
|
||||||
@ -76,17 +64,6 @@ void scsicd_device::device_reset()
|
|||||||
play_err_flag = 0;
|
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 };
|
cdrom_interface scsicd_device::cd_intf = { 0, 0 };
|
||||||
|
|
||||||
static MACHINE_CONFIG_FRAGMENT(scsi_cdrom)
|
static MACHINE_CONFIG_FRAGMENT(scsi_cdrom)
|
||||||
|
@ -31,7 +31,6 @@ protected:
|
|||||||
// device-level overrides
|
// device-level overrides
|
||||||
virtual void device_start();
|
virtual void device_start();
|
||||||
virtual void device_reset();
|
virtual void device_reset();
|
||||||
virtual void device_stop();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UINT32 lba;
|
UINT32 lba;
|
||||||
@ -42,7 +41,6 @@ private:
|
|||||||
UINT32 cur_subblock;
|
UINT32 cur_subblock;
|
||||||
UINT32 play_err_flag;
|
UINT32 play_err_flag;
|
||||||
cdrom_file *cdrom;
|
cdrom_file *cdrom;
|
||||||
bool is_file;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// device type definition
|
// device type definition
|
||||||
|
@ -35,23 +35,11 @@ void scsihd_device::device_reset()
|
|||||||
{
|
{
|
||||||
scsihle_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;
|
lba = 0;
|
||||||
blocks = 0;
|
blocks = 0;
|
||||||
sectorbytes = 512;
|
sectorbytes = 512;
|
||||||
|
|
||||||
|
disk = subdevice<harddisk_image_device>("image")->get_hard_disk_file();
|
||||||
if (!disk)
|
if (!disk)
|
||||||
{
|
{
|
||||||
logerror("%s SCSIHD: no HD found!\n", tag());
|
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)
|
static MACHINE_CONFIG_FRAGMENT(scsi_harddisk)
|
||||||
MCFG_HARDDISK_ADD("image")
|
MCFG_HARDDISK_ADD("image")
|
||||||
MACHINE_CONFIG_END
|
MACHINE_CONFIG_END
|
||||||
|
@ -29,14 +29,12 @@ protected:
|
|||||||
// device-level overrides
|
// device-level overrides
|
||||||
virtual void device_start();
|
virtual void device_start();
|
||||||
virtual void device_reset();
|
virtual void device_reset();
|
||||||
virtual void device_stop();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UINT32 lba;
|
UINT32 lba;
|
||||||
UINT32 blocks;
|
UINT32 blocks;
|
||||||
int sectorbytes;
|
int sectorbytes;
|
||||||
hard_disk_file *disk;
|
hard_disk_file *disk;
|
||||||
bool is_image_device;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// device type definition
|
// device type definition
|
||||||
|
Loading…
Reference in New Issue
Block a user