summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/emu/bus/bml3/bml3mp1802.c6
-rw-r--r--src/emu/bus/bml3/bml3mp1805.c6
-rw-r--r--src/emu/bus/coco/coco_fdc.c12
-rw-r--r--src/emu/bus/ieee488/c8050.c14
-rw-r--r--src/emu/bus/ieee488/c8050.h2
-rw-r--r--src/emu/bus/ti99_peb/bwg.c10
-rw-r--r--src/emu/bus/ti99_peb/bwg.h2
-rw-r--r--src/emu/bus/ti99_peb/hfdc.c31
-rw-r--r--src/emu/bus/ti99_peb/hfdc.h4
-rw-r--r--src/emu/bus/ti99_peb/peribox.c8
-rw-r--r--src/emu/bus/ti99_peb/ti_fdc.c10
-rw-r--r--src/emu/bus/ti99_peb/ti_fdc.h2
-rw-r--r--src/emu/imagedev/flopdrv.c630
-rw-r--r--src/emu/imagedev/flopdrv.h206
-rw-r--r--src/emu/machine/i8271.c59
-rw-r--r--src/emu/machine/i8271.h4
-rw-r--r--src/emu/machine/mc6843.c68
-rw-r--r--src/emu/machine/mc6843.h4
-rw-r--r--src/emu/machine/smc92x4.c64
-rw-r--r--src/emu/machine/smc92x4.h6
-rw-r--r--src/emu/machine/wd17xx.c71
-rw-r--r--src/emu/machine/wd17xx.h4
-rw-r--r--src/mess/drivers/apf.c6
-rw-r--r--src/mess/drivers/fm7.c4
-rw-r--r--src/mess/drivers/mbc200.c8
-rw-r--r--src/mess/drivers/ms0515.c2
-rw-r--r--src/mess/drivers/myb3k.c4
-rw-r--r--src/mess/drivers/mz2000.c4
-rw-r--r--src/mess/drivers/mz2500.c4
-rw-r--r--src/mess/drivers/rainbow.c20
-rw-r--r--src/mess/drivers/smc777.c6
-rw-r--r--src/mess/drivers/thomson.c8
-rw-r--r--src/mess/drivers/unixpc.c2
-rw-r--r--src/mess/drivers/vtech1.c2
-rw-r--r--src/mess/drivers/x1.c4
-rw-r--r--src/mess/drivers/z100.c4
-rw-r--r--src/mess/includes/thomson.h22
-rw-r--r--src/mess/machine/appldriv.c44
-rw-r--r--src/mess/machine/atarifdc.c13
-rw-r--r--src/mess/machine/atarifdc.h4
-rw-r--r--src/mess/machine/beta.c6
-rw-r--r--src/mess/machine/concept_exp.c2
-rw-r--r--src/mess/machine/hec2hrp.c6
-rw-r--r--src/mess/machine/micropolis.c25
-rw-r--r--src/mess/machine/micropolis.h3
-rw-r--r--src/mess/machine/nes.c4
-rw-r--r--src/mess/machine/osborne1.c2
-rw-r--r--src/mess/machine/partner.c12
-rw-r--r--src/mess/machine/pk8020.c24
-rw-r--r--src/mess/machine/rmnimbus.c6
-rw-r--r--src/mess/machine/rx01.c25
-rw-r--r--src/mess/machine/rx01.h4
-rw-r--r--src/mess/machine/sonydriv.c55
-rw-r--r--src/mess/machine/svi318.c2
-rw-r--r--src/mess/machine/swtpc09.c24
-rw-r--r--src/mess/machine/thomflop.c122
-rw-r--r--src/mess/machine/ti99/990_dk.c19
-rw-r--r--src/mess/machine/ti99/990_dk.h4
-rw-r--r--src/mess/machine/trs80.c24
59 files changed, 812 insertions, 941 deletions
diff --git a/src/emu/bus/bml3/bml3mp1802.c b/src/emu/bus/bml3/bml3mp1802.c
index ff5dd8f53ee..be953016fc4 100644
--- a/src/emu/bus/bml3/bml3mp1802.c
+++ b/src/emu/bus/bml3/bml3mp1802.c
@@ -110,10 +110,10 @@ WRITE8_MEMBER( bml3bus_mp1802_device::bml3_mp1802_w)
floppy_name = FLOPPY_3;
break;
}
- device_t *floppy = subdevice(floppy_name);
+ legacy_floppy_image_device *floppy = subdevice<legacy_floppy_image_device>(floppy_name);
m_wd17xx->set_drive(drive);
- floppy_mon_w(floppy, !motor);
- floppy_drive_set_ready_state(floppy, ASSERT_LINE, 0);
+ floppy->floppy_mon_w(!motor);
+ floppy->floppy_drive_set_ready_state(ASSERT_LINE, 0);
m_wd17xx->set_side(side);
}
diff --git a/src/emu/bus/bml3/bml3mp1805.c b/src/emu/bus/bml3/bml3mp1805.c
index b971007c054..7b679d4881c 100644
--- a/src/emu/bus/bml3/bml3mp1805.c
+++ b/src/emu/bus/bml3/bml3mp1805.c
@@ -128,10 +128,10 @@ WRITE8_MEMBER( bml3bus_mp1805_device::bml3_mp1805_w)
floppy_name = FLOPPY_3;
break;
}
- device_t *floppy = subdevice(floppy_name);
+ legacy_floppy_image_device *floppy = subdevice<legacy_floppy_image_device>(floppy_name);
m_mc6843->set_drive(drive);
- floppy_mon_w(floppy, motor);
- floppy_drive_set_ready_state(floppy, ASSERT_LINE, 0);
+ floppy->floppy_mon_w(motor);
+ floppy->floppy_drive_set_ready_state(ASSERT_LINE, 0);
m_mc6843->set_side(side);
}
diff --git a/src/emu/bus/coco/coco_fdc.c b/src/emu/bus/coco/coco_fdc.c
index 684bdc73380..29b60b23a7c 100644
--- a/src/emu/bus/coco/coco_fdc.c
+++ b/src/emu/bus/coco/coco_fdc.c
@@ -299,16 +299,16 @@ void coco_fdc_device::dskreg_w(UINT8 data)
else if (data & 0x40)
drive = 3;
- device_t *floppy[4];
+ legacy_floppy_image_device *floppy[4];
- floppy[0] = subdevice(FLOPPY_0);
- floppy[1] = subdevice(FLOPPY_1);
- floppy[2] = subdevice(FLOPPY_2);
- floppy[3] = subdevice(FLOPPY_3);
+ floppy[0] = subdevice<legacy_floppy_image_device>(FLOPPY_0);
+ floppy[1] = subdevice<legacy_floppy_image_device>(FLOPPY_1);
+ floppy[2] = subdevice<legacy_floppy_image_device>(FLOPPY_2);
+ floppy[3] = subdevice<legacy_floppy_image_device>(FLOPPY_3);
for (int i = 0; i < 4; i++)
{
- floppy_mon_w(floppy[i], i == drive ? CLEAR_LINE : ASSERT_LINE);
+ floppy[i]->floppy_mon_w(i == drive ? CLEAR_LINE : ASSERT_LINE);
}
head = ((data & 0x40) && (drive != 3)) ? 1 : 0;
diff --git a/src/emu/bus/ieee488/c8050.c b/src/emu/bus/ieee488/c8050.c
index 9c14c39767e..c7aeff38c0d 100644
--- a/src/emu/bus/ieee488/c8050.c
+++ b/src/emu/bus/ieee488/c8050.c
@@ -618,7 +618,7 @@ READ8_MEMBER( c8050_device::miot_pb_r )
UINT8 data = 0;
// write protect sense
- data |= floppy_wpt_r(m_unit[m_drive].m_image) << 3;
+ data |= m_unit[m_drive].m_image->floppy_wpt_r() << 3;
// drive type
data |= 0x10;
@@ -1017,10 +1017,10 @@ inline void c8050_device::read_current_track(int unit)
m_bit_count = 0;
// read track data
- floppy_drive_read_track_data_info_buffer(m_unit[unit].m_image, m_side, m_unit[unit].m_track_buffer, &m_unit[unit].m_track_len);
+ m_unit[unit].m_image->floppy_drive_read_track_data_info_buffer(m_side, m_unit[unit].m_track_buffer, &m_unit[unit].m_track_len);
// extract track length
- m_unit[unit].m_track_len = floppy_drive_get_current_track_size(m_unit[unit].m_image, m_side);
+ m_unit[unit].m_track_len = m_unit[unit].m_image->floppy_drive_get_current_track_size(m_side);
}
@@ -1038,7 +1038,7 @@ inline void c8050_device::spindle_motor(int unit, int mtr)
read_current_track(unit);
}
- floppy_mon_w(m_unit[unit].m_image, mtr);
+ m_unit[unit].m_image->floppy_mon_w(mtr);
m_unit[unit].m_mtr = mtr;
}
@@ -1066,7 +1066,7 @@ inline void c8050_device::mpi_step_motor(int unit, int stp)
if (tracks != 0)
{
// step read/write head
- floppy_drive_seek(m_unit[unit].m_image, tracks);
+ m_unit[unit].m_image->floppy_drive_seek(tracks);
// read new track data
read_current_track(unit);
@@ -1199,13 +1199,13 @@ void c8050_device::device_start()
// install image callbacks
m_unit[0].m_image = m_image0;
- floppy_install_load_proc(m_image0, c8050_device::on_disk0_change);
+ m_image0->floppy_install_load_proc(c8050_device::on_disk0_change);
if (m_image1)
{
m_unit[1].m_image = m_image1;
- floppy_install_load_proc(m_image1, c8050_device::on_disk1_change);
+ m_image1->floppy_install_load_proc(c8050_device::on_disk1_change);
}
// register for state saving
diff --git a/src/emu/bus/ieee488/c8050.h b/src/emu/bus/ieee488/c8050.h
index 2c44c6dc0e3..7f603788bb0 100644
--- a/src/emu/bus/ieee488/c8050.h
+++ b/src/emu/bus/ieee488/c8050.h
@@ -125,7 +125,7 @@ protected:
int m_bit_pos; // bit position within track buffer byte
// devices
- device_t *m_image;
+ legacy_floppy_image_device *m_image;
} m_unit[2];
int m_drive; // selected drive
diff --git a/src/emu/bus/ti99_peb/bwg.c b/src/emu/bus/ti99_peb/bwg.c
index 530c9fa1b09..8aabbedd5f5 100644
--- a/src/emu/bus/ti99_peb/bwg.c
+++ b/src/emu/bus/ti99_peb/bwg.c
@@ -839,20 +839,20 @@ READ8Z_MEMBER(snug_bwg_legacy_device::readz)
the default implementation sets the drive geometry to the geometry
of the medium.
*/
-void snug_bwg_legacy_device::set_geometry(device_t *drive, floppy_type_t type)
+void snug_bwg_legacy_device::set_geometry(legacy_floppy_image_device *drive, floppy_type_t type)
{
// This assertion may fail when the names of the floppy devices change.
// Unfortunately, the wd17xx device assumes the floppy drives at root
// level, so we use an explicitly qualified tag. See peribox.h.
assert(drive != NULL);
- floppy_drive_set_geometry(drive, type);
+ drive->floppy_drive_set_geometry(type);
}
void snug_bwg_legacy_device::set_all_geometries(floppy_type_t type)
{
- set_geometry(machine().device(PFLOPPY_0), type);
- set_geometry(machine().device(PFLOPPY_1), type);
- set_geometry(machine().device(PFLOPPY_2), type);
+ set_geometry(machine().device<legacy_floppy_image_device>(PFLOPPY_0), type);
+ set_geometry(machine().device<legacy_floppy_image_device>(PFLOPPY_1), type);
+ set_geometry(machine().device<legacy_floppy_image_device>(PFLOPPY_2), type);
}
/*
diff --git a/src/emu/bus/ti99_peb/bwg.h b/src/emu/bus/ti99_peb/bwg.h
index d534acbc280..2e4c8246ea2 100644
--- a/src/emu/bus/ti99_peb/bwg.h
+++ b/src/emu/bus/ti99_peb/bwg.h
@@ -173,7 +173,7 @@ protected:
private:
void set_ready_line();
void set_all_geometries(floppy_type_t type);
- void set_geometry(device_t *drive, floppy_type_t type);
+ void set_geometry(legacy_floppy_image_device *drive, floppy_type_t type);
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
// Holds the status of the DRQ and IRQ lines.
diff --git a/src/emu/bus/ti99_peb/hfdc.c b/src/emu/bus/ti99_peb/hfdc.c
index ff1dbd7958f..305d8064ff7 100644
--- a/src/emu/bus/ti99_peb/hfdc.c
+++ b/src/emu/bus/ti99_peb/hfdc.c
@@ -304,11 +304,11 @@ READ8_MEMBER( myarc_hfdc_device::auxbus_in )
if (index==-1) return 0;
/* Get floppy status. */
- if (floppy_drive_get_flag_state(m_floppy_unit[index], FLOPPY_DRIVE_INDEX) == FLOPPY_DRIVE_INDEX)
+ if (m_floppy_unit[index]->floppy_drive_get_flag_state(FLOPPY_DRIVE_INDEX) == FLOPPY_DRIVE_INDEX)
reply |= DS_INDEX;
- if (floppy_tk00_r(m_floppy_unit[index]) == CLEAR_LINE)
+ if (m_floppy_unit[index]->floppy_tk00_r() == CLEAR_LINE)
reply |= DS_TRK00;
- if (floppy_wpt_r(m_floppy_unit[index]) == CLEAR_LINE)
+ if (m_floppy_unit[index]->floppy_wpt_r() == CLEAR_LINE)
reply |= DS_WRPROT;
/* if (image_exists(disk_img)) */
@@ -321,7 +321,7 @@ READ8_MEMBER( myarc_hfdc_device::auxbus_in )
{
UINT8 state;
index = slog2((m_output1_latch>>4) & 0x0f)-1;
- mfm_harddisk_device *hd = static_cast<mfm_harddisk_device *>(m_harddisk_unit[index]);
+ mfm_harddisk_device *hd = m_harddisk_unit[index];
state = hd->get_status();
if (state & MFMHD_TRACK00) reply |= DS_TRK00;
@@ -338,8 +338,6 @@ READ8_MEMBER( myarc_hfdc_device::auxbus_in )
WRITE8_MEMBER( myarc_hfdc_device::auxbus_out )
{
int index;
- device_t* selected_drive = NULL;
-
switch (offset)
{
case INPUT_STATUS:
@@ -363,16 +361,15 @@ WRITE8_MEMBER( myarc_hfdc_device::auxbus_out )
{
// Floppy selected
index = slog2(data & 0x0f);
- if (index>=0) selected_drive = m_floppy_unit[index];
+ if (index>=0) m_hdc9234->connect_floppy_drive(m_floppy_unit[index]);
}
else
{
// HD selected
index = slog2((data>>4) & 0x0f);
- if (index>=0) selected_drive = m_harddisk_unit[index-1];
+ if (index>=0) m_hdc9234->connect_hard_drive(m_harddisk_unit[index-1]);
}
- m_hdc9234->connect_drive(selected_drive);
m_output1_latch = data;
break;
@@ -536,14 +533,14 @@ void myarc_hfdc_device::device_reset()
m_selected = false;
// Find the floppies and hard disks
- m_floppy_unit[0] = m_slot->get_drive(FLOPPY_0);
- m_floppy_unit[1] = m_slot->get_drive(FLOPPY_1);
- m_floppy_unit[2] = m_slot->get_drive(FLOPPY_2);
- m_floppy_unit[3] = m_slot->get_drive(FLOPPY_3);
+ m_floppy_unit[0] = static_cast<legacy_floppy_image_device *>(m_slot->get_drive(FLOPPY_0));
+ m_floppy_unit[1] = static_cast<legacy_floppy_image_device *>(m_slot->get_drive(FLOPPY_1));
+ m_floppy_unit[2] = static_cast<legacy_floppy_image_device *>(m_slot->get_drive(FLOPPY_2));
+ m_floppy_unit[3] = static_cast<legacy_floppy_image_device *>(m_slot->get_drive(FLOPPY_3));
- m_harddisk_unit[0] = m_slot->get_drive(MFMHD_0);
- m_harddisk_unit[1] = m_slot->get_drive(MFMHD_1);
- m_harddisk_unit[2] = m_slot->get_drive(MFMHD_2);
+ m_harddisk_unit[0] = static_cast<mfm_harddisk_device *>(m_slot->get_drive(MFMHD_0));
+ m_harddisk_unit[1] = static_cast<mfm_harddisk_device *>(m_slot->get_drive(MFMHD_1));
+ m_harddisk_unit[2] = static_cast<mfm_harddisk_device *>(m_slot->get_drive(MFMHD_2));
if (ioport("HFDCDIP")->read()&0x55)
ti99_set_80_track_drives(TRUE);
@@ -560,7 +557,7 @@ void myarc_hfdc_device::device_reset()
{
// floppy_drive_set_controller(card->floppy_unit[i], device);
// floppy_drive_set_index_pulse_callback(floppy_unit[i], smc92x4_index_pulse_callback);
- floppy_drive_set_geometry(m_floppy_unit[i], floptype);
+ m_floppy_unit[i]->floppy_drive_set_geometry(floptype);
}
}
diff --git a/src/emu/bus/ti99_peb/hfdc.h b/src/emu/bus/ti99_peb/hfdc.h
index 9b3973af3a9..4f295d5144f 100644
--- a/src/emu/bus/ti99_peb/hfdc.h
+++ b/src/emu/bus/ti99_peb/hfdc.h
@@ -93,10 +93,10 @@ private:
UINT8 m_output2_latch;
/* Connected floppy drives. */
- device_t* m_floppy_unit[HFDC_MAX_FLOPPY];
+ legacy_floppy_image_device* m_floppy_unit[HFDC_MAX_FLOPPY];
/* Connected harddisk drives. */
- device_t* m_harddisk_unit[HFDC_MAX_HARD];
+ mfm_harddisk_device* m_harddisk_unit[HFDC_MAX_HARD];
/* DMA address latch */
UINT32 m_dma_address;
diff --git a/src/emu/bus/ti99_peb/peribox.c b/src/emu/bus/ti99_peb/peribox.c
index cfd8399d711..32434090b19 100644
--- a/src/emu/bus/ti99_peb/peribox.c
+++ b/src/emu/bus/ti99_peb/peribox.c
@@ -394,10 +394,10 @@ void peribox_device::device_start(void)
{
if (TRACE_EMU) logerror("Peribox started\n");
- floppy_drive_set_rpm(subdevice(FLOPPY_0), 300.);
- floppy_drive_set_rpm(subdevice(FLOPPY_1), 300.);
- floppy_drive_set_rpm(subdevice(FLOPPY_2), 300.);
- floppy_drive_set_rpm(subdevice(FLOPPY_3), 300.);
+ subdevice<legacy_floppy_image_device>(FLOPPY_0)->floppy_drive_set_rpm(300.);
+ subdevice<legacy_floppy_image_device>(FLOPPY_1)->floppy_drive_set_rpm(300.);
+ subdevice<legacy_floppy_image_device>(FLOPPY_2)->floppy_drive_set_rpm(300.);
+ subdevice<legacy_floppy_image_device>(FLOPPY_3)->floppy_drive_set_rpm(300.);
// Resolve the callback lines to the console
m_console_inta.resolve();
diff --git a/src/emu/bus/ti99_peb/ti_fdc.c b/src/emu/bus/ti99_peb/ti_fdc.c
index ea7d7bf8e3f..b675ef887d2 100644
--- a/src/emu/bus/ti99_peb/ti_fdc.c
+++ b/src/emu/bus/ti99_peb/ti_fdc.c
@@ -648,20 +648,20 @@ WRITE8_MEMBER(ti_fdc_legacy_device::cruwrite)
the default implementation sets the drive geometry to the geometry
of the medium.
*/
-void ti_fdc_legacy_device::set_geometry(device_t *drive, floppy_type_t type)
+void ti_fdc_legacy_device::set_geometry(legacy_floppy_image_device *drive, floppy_type_t type)
{
// This assertion may fail when the names of the floppy devices change.
// Unfortunately, the wd17xx device assumes the floppy drives at root
// level, so we use an explicitly qualified tag. See peribox.h.
assert (drive!=NULL);
- floppy_drive_set_geometry(drive, type);
+ drive->floppy_drive_set_geometry(type);
}
void ti_fdc_legacy_device::set_all_geometries(floppy_type_t type)
{
- set_geometry(machine().device(PFLOPPY_0), type);
- set_geometry(machine().device(PFLOPPY_1), type);
- set_geometry(machine().device(PFLOPPY_2), type);
+ set_geometry(machine().device<legacy_floppy_image_device>(PFLOPPY_0), type);
+ set_geometry(machine().device<legacy_floppy_image_device>(PFLOPPY_1), type);
+ set_geometry(machine().device<legacy_floppy_image_device>(PFLOPPY_2), type);
}
/*
diff --git a/src/emu/bus/ti99_peb/ti_fdc.h b/src/emu/bus/ti99_peb/ti_fdc.h
index 03e75361155..24e5164acb2 100644
--- a/src/emu/bus/ti99_peb/ti_fdc.h
+++ b/src/emu/bus/ti99_peb/ti_fdc.h
@@ -146,7 +146,7 @@ protected:
private:
void set_ready_line();
void set_all_geometries(floppy_type_t type);
- void set_geometry(device_t *drive, floppy_type_t type);
+ void set_geometry(legacy_floppy_image_device *drive, floppy_type_t type);
// Recent address
int m_address;
diff --git a/src/emu/imagedev/flopdrv.c b/src/emu/imagedev/flopdrv.c
index 69b883f585a..064f70b574b 100644
--- a/src/emu/imagedev/flopdrv.c
+++ b/src/emu/imagedev/flopdrv.c
@@ -29,66 +29,6 @@
TYPE DEFINITIONS
***************************************************************************/
-struct floppy_drive
-{
- /* callbacks */
- devcb_resolved_write_line out_idx_func;
- devcb_resolved_read_line in_mon_func;
- devcb_resolved_write_line out_tk00_func;
- devcb_resolved_write_line out_wpt_func;
- devcb_resolved_write_line out_rdy_func;
- devcb_resolved_write_line out_dskchg_func;
-
- /* state of input lines */
- int drtn; /* direction */
- int stp; /* step */
- int wtg; /* write gate */
- int mon; /* motor on */
-
- /* state of output lines */
- int idx; /* index pulse */
- int tk00; /* track 00 */
- int wpt; /* write protect */
- int rdy; /* ready */
- int dskchg; /* disk changed */
-
- /* drive select logic */
- int drive_id;
- int active;
-
- const floppy_interface *config;
-
- /* flags */
- int flags;
- /* maximum track allowed */
- int max_track;
- /* num sides */
- int num_sides;
- /* current track - this may or may not relate to the present cylinder number
- stored by the fdc */
- int current_track;
-
- /* index pulse timer */
- emu_timer *index_timer;
- /* index pulse callback */
- void (*index_pulse_callback)(device_t *controller,device_t *image, int state);
- /* rotation per minute => gives index pulse frequency */
- float rpm;
-
- void (*ready_state_change_callback)(device_t *controller,device_t *img, int state);
-
- int id_index;
-
- device_t *controller;
-
- floppy_image_legacy *floppy;
- int track;
- void (*load_proc)(device_image_interface &image);
- void (*unload_proc)(device_image_interface &image);
- int floppy_drive_type;
-};
-
-
struct floppy_error_map
{
floperr_t ferr;
@@ -115,44 +55,36 @@ static const floppy_error_map errmap[] =
IMPLEMENTATION
***************************************************************************/
-INLINE floppy_drive *get_safe_token(device_t *device)
-{
- assert( device != NULL );
- return (floppy_drive *) downcast<legacy_floppy_image_device *>(device)->token();
-}
-floppy_image_legacy *flopimg_get_image(device_t *image)
+floppy_image_legacy *legacy_floppy_image_device::flopimg_get_image()
{
- return get_safe_token(image)->floppy;
+ return m_floppy;
}
-static int flopimg_get_sectors_per_track(device_t *image, int side)
+int legacy_floppy_image_device::flopimg_get_sectors_per_track(int side)
{
floperr_t err;
int sector_count;
- floppy_drive *flopimg = get_safe_token( image );
- if (!flopimg || !flopimg->floppy)
+ if (!m_floppy)
return 0;
- err = floppy_get_sector_count(flopimg->floppy, side, flopimg->track, &sector_count);
+ err = floppy_get_sector_count(m_floppy, side, m_track, &sector_count);
if (err)
return 0;
return sector_count;
}
-static void flopimg_get_id_callback(device_t *image, chrn_id *id, int id_index, int side)
+void legacy_floppy_image_device::flopimg_get_id_callback(chrn_id *id, int id_index, int side)
{
- floppy_drive *flopimg;
int cylinder, sector, N;
unsigned long flags;
UINT32 sector_length;
- flopimg = get_safe_token( image );
- if (!flopimg || !flopimg->floppy)
+ if (!m_floppy)
return;
- floppy_get_indexed_sector_info(flopimg->floppy, side, flopimg->track, id_index, &cylinder, &side, &sector, &sector_length, &flags);
+ floppy_get_indexed_sector_info(m_floppy, side, m_track, id_index, &cylinder, &side, &sector, &sector_length, &flags);
N = compute_log2(sector_length);
@@ -164,7 +96,7 @@ static void flopimg_get_id_callback(device_t *image, chrn_id *id, int id_index,
id->N = ((N >= 7) && (N <= 10)) ? N - 7 : 0;
}
-static void log_readwrite(const char *name, int head, int track, int sector, const char *buf, int length)
+void legacy_floppy_image_device::log_readwrite(const char *name, int head, int track, int sector, const char *buf, int length)
{
char membuf[1024];
int i;
@@ -173,97 +105,88 @@ static void log_readwrite(const char *name, int head, int track, int sector, con
logerror("%s: head=%i track=%i sector=%i buffer='%s'\n", name, head, track, sector, membuf);
}
-static void floppy_drive_set_geometry_absolute(device_t *img, int tracks, int sides)
+void legacy_floppy_image_device::floppy_drive_set_geometry_absolute(int tracks, int sides)
{
- floppy_drive *pDrive = get_safe_token( img );
- pDrive->max_track = tracks;
- pDrive->num_sides = sides;
+ m_max_track = tracks;
+ m_num_sides = sides;
}
-void floppy_drive_set_geometry(device_t *img, floppy_type_t type)
+void legacy_floppy_image_device::floppy_drive_set_geometry(floppy_type_t type)
{
- floppy_drive_set_geometry_absolute(img, type.max_track_number, type.head_number);
+ floppy_drive_set_geometry_absolute(type.max_track_number, type.head_number);
}
-static TIMER_CALLBACK(floppy_drive_index_callback);
-
/* this is called on device init */
-static void floppy_drive_init(device_t *img)
+void legacy_floppy_image_device::floppy_drive_init()
{
- floppy_drive *pDrive = get_safe_token( img );
-
/* initialise flags */
- pDrive->flags = 0;
- pDrive->index_pulse_callback = NULL;
- pDrive->ready_state_change_callback = NULL;
- pDrive->index_timer = img->machine().scheduler().timer_alloc(FUNC(floppy_drive_index_callback), (void *) img);
- pDrive->idx = 0;
+ m_flags = 0;
+ m_index_pulse_callback = NULL;
+ m_ready_state_change_callback = NULL;
+ m_index_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(legacy_floppy_image_device::floppy_drive_index_callback),this));
+ m_idx = 0;
- floppy_drive_set_geometry(img, ((floppy_interface*)img->static_config())->floppy_type);
+ floppy_drive_set_geometry(((floppy_interface*)static_config())->floppy_type);
/* initialise id index - not so important */
- pDrive->id_index = 0;
+ m_id_index = 0;
/* initialise track */
- pDrive->current_track = 0;
+ m_current_track = 0;
/* default RPM */
- pDrive->rpm = 300;
+ m_rpm = 300;
- pDrive->controller = NULL;
+ m_controller = NULL;
- pDrive->floppy_drive_type = FLOPPY_TYPE_REGULAR;
+ m_floppy_drive_type = FLOPPY_TYPE_REGULAR;
}
/* index pulses at rpm/60 Hz, and stays high 1/20th of time */
-static void floppy_drive_index_func(device_t *img)
+void legacy_floppy_image_device::floppy_drive_index_func()
{
- floppy_drive *drive = get_safe_token( img );
-
- double ms = 1000.0 / (drive->rpm / 60.0);
+ double ms = 1000.0 / (m_rpm / 60.0);
- if (drive->idx)
+ if (m_idx)
{
- drive->idx = 0;
- drive->index_timer->adjust(attotime::from_double(ms*19/20/1000.0));
+ m_idx = 0;
+ m_index_timer->adjust(attotime::from_double(ms*19/20/1000.0));
}
else
{
- drive->idx = 1;
- drive->index_timer->adjust(attotime::from_double(ms/20/1000.0));
+ m_idx = 1;
+ m_index_timer->adjust(attotime::from_double(ms/20/1000.0));
}
- drive->out_idx_func(drive->idx);
+ m_out_idx_func(m_idx);
- if (drive->index_pulse_callback)
- drive->index_pulse_callback(drive->controller, img, drive->idx);
+ if (m_index_pulse_callback)
+ m_index_pulse_callback(m_controller, this, m_idx);
}
-static TIMER_CALLBACK(floppy_drive_index_callback)
+TIMER_CALLBACK_MEMBER(legacy_floppy_image_device::floppy_drive_index_callback)
{
- device_t *image = (device_t *) ptr;
- floppy_drive_index_func(image);
+ floppy_drive_index_func();
}
/*************************************************************************/
/* IO_FLOPPY device functions */
/* set flag state */
-void floppy_drive_set_flag_state(device_t *img, int flag, int state)
+void legacy_floppy_image_device::floppy_drive_set_flag_state(int flag, int state)
{
- floppy_drive *drv = get_safe_token( img );
int prev_state;
int new_state;
/* get old state */
- prev_state = drv->flags & flag;
+ prev_state = m_flags & flag;
/* set new state */
- drv->flags &= ~flag;
+ m_flags &= ~flag;
if (state)
- drv->flags |= flag;
+ m_flags |= flag;
/* get new state */
- new_state = drv->flags & flag;
+ new_state = m_flags & flag;
/* changed state? */
if (prev_state ^ new_state)
@@ -271,10 +194,10 @@ void floppy_drive_set_flag_state(device_t *img, int flag, int state)
if (flag & FLOPPY_DRIVE_READY)
{
/* trigger state change callback */
- drv->out_rdy_func(new_state ? ASSERT_LINE : CLEAR_LINE);
+ m_out_rdy_func(new_state ? ASSERT_LINE : CLEAR_LINE);
- if (drv->ready_state_change_callback)
- drv->ready_state_change_callback(drv->controller, img, new_state);
+ if (m_ready_state_change_callback)
+ m_ready_state_change_callback(m_controller, this, new_state);
}
}
}
@@ -282,10 +205,8 @@ void floppy_drive_set_flag_state(device_t *img, int flag, int state)
/* for pc, drive is always ready, for amstrad,pcw,spectrum it is only ready under
a fixed set of circumstances */
/* use this to set ready state of drive */
-void floppy_drive_set_ready_state(device_t *img, int state, int flag)
-{
- floppy_drive *drive = get_safe_token(img);
- device_image_interface *image = dynamic_cast<device_image_interface *>(img);
+void legacy_floppy_image_device::floppy_drive_set_ready_state(int state, int flag)
+{
if (flag)
{
/* set ready only if drive is present, disk is in the drive,
@@ -293,34 +214,33 @@ void floppy_drive_set_ready_state(device_t *img, int state, int flag)
/* drive present? */
/* disk inserted? */
- if (image->exists())
+ if (exists())
{
- if (drive->mon == CLEAR_LINE)
+ if (m_mon == CLEAR_LINE)
{
/* set state */
- floppy_drive_set_flag_state(img, FLOPPY_DRIVE_READY, state);
+ floppy_drive_set_flag_state(FLOPPY_DRIVE_READY, state);
return;
}
}
- floppy_drive_set_flag_state(img, FLOPPY_DRIVE_READY, 0);
+ floppy_drive_set_flag_state(FLOPPY_DRIVE_READY, 0);
}
else
{
/* force ready state - for PC driver */
- floppy_drive_set_flag_state(img, FLOPPY_DRIVE_READY, state);
+ floppy_drive_set_flag_state(FLOPPY_DRIVE_READY, state);
}
}
/* get flag state */
-int floppy_drive_get_flag_state(device_t *img, int flag)
+int legacy_floppy_image_device::floppy_drive_get_flag_state(int flag)
{
- floppy_drive *drv = get_safe_token( img );
int drive_flags;
int flags;
flags = 0;
- drive_flags = drv->flags;
+ drive_flags = m_flags;
/* these flags are independent of a real drive/disk image */
flags |= drive_flags & (FLOPPY_DRIVE_READY | FLOPPY_DRIVE_INDEX);
@@ -331,255 +251,213 @@ int floppy_drive_get_flag_state(device_t *img, int flag)
}
-void floppy_drive_seek(device_t *img, signed int signed_tracks)
-{
- device_image_interface *image = dynamic_cast<device_image_interface *>(img);
- floppy_drive *pDrive;
-
- pDrive = get_safe_token( img );
-
- LOG(("seek from: %d delta: %d\n",pDrive->current_track, signed_tracks));
+void legacy_floppy_image_device::floppy_drive_seek(signed int signed_tracks)
+{
+ LOG(("seek from: %d delta: %d\n",m_current_track, signed_tracks));
/* update position */
- pDrive->current_track+=signed_tracks;
+ m_current_track+=signed_tracks;
- if (pDrive->current_track<0)
+ if (m_current_track<0)
{
- pDrive->current_track = 0;
+ m_current_track = 0;
}
else
- if (pDrive->current_track>=pDrive->max_track)
+ if (m_current_track>=m_max_track)
{
- pDrive->current_track = pDrive->max_track-1;
+ m_current_track = m_max_track-1;
}
/* set track 0 flag */
- pDrive->tk00 = (pDrive->current_track == 0) ? CLEAR_LINE : ASSERT_LINE;
- pDrive->out_tk00_func(pDrive->tk00);
+ m_tk00 = (m_current_track == 0) ? CLEAR_LINE : ASSERT_LINE;
+ m_out_tk00_func(m_tk00);
/* clear disk changed flag */
- pDrive->dskchg = ASSERT_LINE;
- //flopimg->out_dskchg_func(flopimg->dskchg);
+ m_dskchg = ASSERT_LINE;
+ //m_out_dskchg_func(m_dskchg);
/* inform disk image of step operation so it can cache information */
- if (image->exists())
- pDrive->track = pDrive->current_track;
+ if (exists())
+ m_track = m_current_track;
- pDrive->id_index = 0;
+ m_id_index = 0;
}
/* this is not accurate. But it will do for now */
-int floppy_drive_get_next_id(device_t *img, int side, chrn_id *id)
+int legacy_floppy_image_device::floppy_drive_get_next_id(int side, chrn_id *id)
{
- floppy_drive *pDrive;
int spt;
- pDrive = get_safe_token( img );
-
/* get sectors per track */
- spt = flopimg_get_sectors_per_track(img, side);
+ spt = flopimg_get_sectors_per_track(side);
/* set index */
- if ((pDrive->id_index==(spt-1)) || (spt==0))
+ if ((m_id_index==(spt-1)) || (spt==0))
{
- floppy_drive_set_flag_state(img, FLOPPY_DRIVE_INDEX, 1);
+ floppy_drive_set_flag_state(FLOPPY_DRIVE_INDEX, 1);
}
else
{
- floppy_drive_set_flag_state(img, FLOPPY_DRIVE_INDEX, 0);
+ floppy_drive_set_flag_state(FLOPPY_DRIVE_INDEX, 0);
}
/* get id */
if (spt!=0)
{
- flopimg_get_id_callback(img, id, pDrive->id_index, side);
+ flopimg_get_id_callback(id, m_id_index, side);
}
- pDrive->id_index++;
+ m_id_index++;
if (spt!=0)
- pDrive->id_index %= spt;
+ m_id_index %= spt;
else
- pDrive->id_index = 0;
+ m_id_index = 0;
return (spt == 0) ? 0 : 1;
}
-void floppy_drive_read_track_data_info_buffer(device_t *img, int side, void *ptr, int *length )
+void legacy_floppy_image_device::floppy_drive_read_track_data_info_buffer(int side, void *ptr, int *length )
{
- floppy_drive *flopimg;
- device_image_interface *image = dynamic_cast<device_image_interface *>(img);
-
- if (image->exists())
+ if (exists())
{
- flopimg = get_safe_token( img );
- if (!flopimg || !flopimg->floppy)
+ if (!m_floppy)
return;
- floppy_read_track_data(flopimg->floppy, side, flopimg->track, ptr, *length);
+ floppy_read_track_data(m_floppy, side, m_track, ptr, *length);
}
}
-void floppy_drive_write_track_data_info_buffer(device_t *img, int side, const void *ptr, int *length )
+void legacy_floppy_image_device::floppy_drive_write_track_data_info_buffer(int side, const void *ptr, int *length )
{
- floppy_drive *flopimg;
- device_image_interface *image = dynamic_cast<device_image_interface *>(img);
-
- if (image->exists())
+ if (exists())
{
- flopimg = get_safe_token( img );
- if (!flopimg || !flopimg->floppy)
+ if (!m_floppy)
return;
- floppy_write_track_data(flopimg->floppy, side, flopimg->track, ptr, *length);
+ floppy_write_track_data(m_floppy, side, m_track, ptr, *length);
}
}
-void floppy_drive_format_sector(device_t *img, int side, int sector_index,int c,int h, int r, int n, int filler)
+void legacy_floppy_image_device::floppy_drive_format_sector(int side, int sector_index,int c,int h, int r, int n, int filler)
{
- device_image_interface *image = dynamic_cast<device_image_interface *>(img);
-
- if (image->exists())
+ if (exists())
{
-/* if (drv->interface_.format_sector)
- drv->interface_.format_sector(img, side, sector_index,c, h, r, n, filler);*/
+/* if (m_interface_.format_sector)
+ m_interface_.format_sector(img, side, sector_index,c, h, r, n, filler);*/
}
}
-void floppy_drive_read_sector_data(device_t *img, int side, int index1, void *ptr, int length)
+void legacy_floppy_image_device::floppy_drive_read_sector_data(int side, int index1, void *ptr, int length)
{
- floppy_drive *flopimg;
- device_image_interface *image = dynamic_cast<device_image_interface *>(img);
-
- if (image->exists())
+ if (exists())
{
- flopimg = get_safe_token( img );
- if (!flopimg || !flopimg->floppy)
+ if (!m_floppy)
return;
- floppy_read_indexed_sector(flopimg->floppy, side, flopimg->track, index1, 0, ptr, length);
+ floppy_read_indexed_sector(m_floppy, side, m_track, index1, 0, ptr, length);
if (LOG_FLOPPY)
- log_readwrite("sector_read", side, flopimg->track, index1, (const char *)ptr, length);
+ log_readwrite("sector_read", side, m_track, index1, (const char *)ptr, length);
}
}
-void floppy_drive_write_sector_data(device_t *img, int side, int index1, const void *ptr,int length, int ddam)
+void legacy_floppy_image_device::floppy_drive_write_sector_data(int side, int index1, const void *ptr,int length, int ddam)
{
- floppy_drive *flopimg;
- device_image_interface *image = dynamic_cast<device_image_interface *>(img);
-
- if (image->exists())
+ if (exists())
{
- flopimg = get_safe_token( img );
- if (!flopimg || !flopimg->floppy)
+ if (!m_floppy)
return;
if (LOG_FLOPPY)
- log_readwrite("sector_write", side, flopimg->track, index1, (const char *)ptr, length);
+ log_readwrite("sector_write", side, m_track, index1, (const char *)ptr, length);
- floppy_write_indexed_sector(flopimg->floppy, side, flopimg->track, index1, 0, ptr, length, ddam);
+ floppy_write_indexed_sector(m_floppy, side, m_track, index1, 0, ptr, length, ddam);
}
}
-void floppy_install_load_proc(device_t *image, void (*proc)(device_image_interface &image))
+void legacy_floppy_image_device::floppy_install_load_proc(void (*proc)(device_image_interface &image))
{
- floppy_drive *flopimg = get_safe_token( image );
- flopimg->load_proc = proc;
+ m_load_proc = proc;
}
-void floppy_install_unload_proc(device_t *image, void (*proc)(device_image_interface &image))
+void legacy_floppy_image_device::floppy_install_unload_proc(void (*proc)(device_image_interface &image))
{
- floppy_drive *flopimg = get_safe_token( image );
- flopimg->unload_proc = proc;
+ m_unload_proc = proc;
}
/* set the callback for the index pulse */
-void floppy_drive_set_index_pulse_callback(device_t *img, void (*callback)(device_t *controller,device_t *image, int state))
+void legacy_floppy_image_device::floppy_drive_set_index_pulse_callback(void (*callback)(device_t *controller, device_t *img, int state))
{
- floppy_drive *pDrive = get_safe_token( img );
- pDrive->index_pulse_callback = callback;
+ m_index_pulse_callback = callback;
}
-
-void floppy_drive_set_ready_state_change_callback(device_t *img, void (*callback)(device_t *controller,device_t *img, int state))
+void legacy_floppy_image_device::floppy_drive_set_ready_state_change_callback(void (*callback)(device_t *controller,device_t *img, int state))
{
- floppy_drive *pDrive = get_safe_token( img );
- pDrive->ready_state_change_callback = callback;
+ m_ready_state_change_callback = callback;
}
-int floppy_drive_get_current_track(device_t *img)
+int legacy_floppy_image_device::floppy_drive_get_current_track()
{
- floppy_drive *drv = get_safe_token( img );
- return drv->current_track;
+ return m_current_track;
}
-UINT64 floppy_drive_get_current_track_size(device_t *img, int head)
+UINT64 legacy_floppy_image_device::floppy_drive_get_current_track_size(int head)
{
- floppy_drive *drv = get_safe_token( img );
int size = 0;
- device_image_interface *image = dynamic_cast<device_image_interface *>(img);
-
- if (image->exists())
+ if (exists())
{
- size = floppy_get_track_size(drv->floppy, head, drv->current_track);
+ size = floppy_get_track_size(m_floppy, head, m_current_track);
}
return size;
}
-void floppy_drive_set_rpm(device_t *img, float rpm)
+void legacy_floppy_image_device::floppy_drive_set_rpm(float rpm)
{
- floppy_drive *drv = get_safe_token( img );
- drv->rpm = rpm;
+ m_rpm = rpm;
}
-void floppy_drive_set_controller(device_t *img, device_t *controller)
+void legacy_floppy_image_device::floppy_drive_set_controller(device_t *controller)
{
- floppy_drive *drv = get_safe_token( img );
- drv->controller = controller;
+ m_controller = controller;
}
-static int internal_floppy_device_load(device_image_interface *image, int create_format, option_resolution *create_args)
+int legacy_floppy_image_device::internal_floppy_device_load(int create_format, option_resolution *create_args)
{
floperr_t err;
- floppy_drive *flopimg;
const struct FloppyFormat *floppy_options;
int floppy_flags, i;
const char *extension;
- /* look up instance data */
- flopimg = get_safe_token( &image->device() );
+ device_image_interface *image = NULL;
+ interface(image); /* figure out the floppy options */
+ floppy_options = ((floppy_interface*)static_config())->formats;
- /* figure out the floppy options */
- floppy_options = ((floppy_interface*)image->device().static_config())->formats;
-
- if (image->has_been_created())
+ if (has_been_created())
{
/* creating an image */
assert(create_format >= 0);
- err = floppy_create((void *) image, &image_ioprocs, &floppy_options[create_format], create_args, &flopimg->floppy);
+ err = floppy_create((void *) image, &image_ioprocs, &floppy_options[create_format], create_args, &m_floppy);
if (err)
goto error;
}
else
{
/* opening an image */
- floppy_flags = !image->is_readonly() ? FLOPPY_FLAGS_READWRITE : FLOPPY_FLAGS_READONLY;
- extension = image->filetype();
- err = floppy_open_choices((void *) image, &image_ioprocs, extension, floppy_options, floppy_flags, &flopimg->floppy);
+ floppy_flags = !is_readonly() ? FLOPPY_FLAGS_READWRITE : FLOPPY_FLAGS_READONLY;
+ extension = filetype();
+ err = floppy_open_choices((void *) image, &image_ioprocs, extension, floppy_options, floppy_flags, &m_floppy);
if (err)
goto error;
}
- if (floppy_callbacks(flopimg->floppy)->get_heads_per_disk && floppy_callbacks(flopimg->floppy)->get_tracks_per_disk)
+ if (floppy_callbacks(m_floppy)->get_heads_per_disk && floppy_callbacks(m_floppy)->get_tracks_per_disk)
{
- floppy_drive_set_geometry_absolute(&image->device(),
- floppy_get_tracks_per_disk(flopimg->floppy),
- floppy_get_heads_per_disk(flopimg->floppy));
+ floppy_drive_set_geometry_absolute(floppy_get_tracks_per_disk(m_floppy),floppy_get_heads_per_disk(m_floppy));
}
/* disk changed */
- flopimg->dskchg = CLEAR_LINE;
+ m_dskchg = CLEAR_LINE;
return IMAGE_INIT_PASS;
@@ -587,49 +465,45 @@ error:
for (i = 0; i < ARRAY_LENGTH(errmap); i++)
{
if (err == errmap[i].ferr)
- image->seterror(errmap[i].ierr, errmap[i].message);
+ seterror(errmap[i].ierr, errmap[i].message);
}
return IMAGE_INIT_FAIL;
}
-static TIMER_CALLBACK( set_wpt )
+TIMER_CALLBACK_MEMBER( legacy_floppy_image_device::set_wpt )
{
- floppy_drive *flopimg = (floppy_drive *)ptr;
-
- flopimg->wpt = param;
- flopimg->out_wpt_func(param);
+ m_wpt = param;
+ m_out_wpt_func(param);
}
-device_t *floppy_get_device(running_machine &machine,int drive)
+legacy_floppy_image_device *floppy_get_device(running_machine &machine,int drive)
{
switch(drive) {
- case 0 : return machine.device(FLOPPY_0);
- case 1 : return machine.device(FLOPPY_1);
- case 2 : return machine.device(FLOPPY_2);
- case 3 : return machine.device(FLOPPY_3);
+ case 0 : return machine.device<legacy_floppy_image_device>(FLOPPY_0);
+ case 1 : return machine.device<legacy_floppy_image_device>(FLOPPY_1);
+ case 2 : return machine.device<legacy_floppy_image_device>(FLOPPY_2);
+ case 3 : return machine.device<legacy_floppy_image_device>(FLOPPY_3);
}
return NULL;
}
-int floppy_get_drive_type(device_t *image)
+int legacy_floppy_image_device::floppy_get_drive_type()
{
- floppy_drive *flopimg = get_safe_token( image );
- return flopimg->floppy_drive_type;
+ return m_floppy_drive_type;
}
-void floppy_set_type(device_t *image,int ftype)
+void legacy_floppy_image_device::floppy_set_type(int ftype)
{
- floppy_drive *flopimg = get_safe_token( image );
- flopimg->floppy_drive_type = ftype;
+ m_floppy_drive_type = ftype;
}
-device_t *floppy_get_device_by_type(running_machine &machine,int ftype,int drive)
+legacy_floppy_image_device *floppy_get_device_by_type(running_machine &machine,int ftype,int drive)
{
int i;
int cnt = 0;
for (i=0;i<4;i++) {
- device_t *disk = floppy_get_device(machine,i);
- if (floppy_get_drive_type(disk)==ftype) {
+ legacy_floppy_image_device *disk = floppy_get_device(machine,i);
+ if (disk->floppy_get_drive_type()==ftype) {
if (cnt==drive) {
return disk;
}
@@ -649,12 +523,12 @@ int floppy_get_drive(device_t *image)
return drive;
}
-int floppy_get_drive_by_type(device_t *image,int ftype)
+int floppy_get_drive_by_type(legacy_floppy_image_device *image,int ftype)
{
int i,drive =0;
for (i=0;i<4;i++) {
- device_t *disk = floppy_get_device(image->machine(),i);
- if (floppy_get_drive_type(disk)==ftype) {
+ legacy_floppy_image_device *disk = floppy_get_device(image->machine(),i);
+ if (disk->floppy_get_drive_type()==ftype) {
if (image==disk) {
return drive;
}
@@ -667,177 +541,158 @@ int floppy_get_drive_by_type(device_t *image,int ftype)
int floppy_get_count(running_machine &machine)
{
int cnt = 0;
- if (machine.device(FLOPPY_0)) cnt++;
- if (machine.device(FLOPPY_1)) cnt++;
- if (machine.device(FLOPPY_2)) cnt++;
- if (machine.device(FLOPPY_3)) cnt++;
+ if (machine.device<legacy_floppy_image_device>(FLOPPY_0)) cnt++;
+ if (machine.device<legacy_floppy_image_device>(FLOPPY_1)) cnt++;
+ if (machine.device<legacy_floppy_image_device>(FLOPPY_2)) cnt++;
+ if (machine.device<legacy_floppy_image_device>(FLOPPY_3)) cnt++;
return cnt;
}
/* drive select 0 */
-WRITE_LINE_DEVICE_HANDLER( floppy_ds0_w )
+WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds0_w )
{
- floppy_drive *drive = get_safe_token(device);
-
if (state == CLEAR_LINE)
- drive->active = (drive->drive_id == 0);
+ m_active = (m_drive_id == 0);
}
/* drive select 1 */
-WRITE_LINE_DEVICE_HANDLER( floppy_ds1_w )
+WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds1_w )
{
- floppy_drive *drive = get_safe_token(device);
-
if (state == CLEAR_LINE)
- drive->active = (drive->drive_id == 1);
+ m_active = (m_drive_id == 1);
}
/* drive select 2 */
-WRITE_LINE_DEVICE_HANDLER( floppy_ds2_w )
+WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds2_w )
{
- floppy_drive *drive = get_safe_token(device);
-
if (state == CLEAR_LINE)
- drive->active = (drive->drive_id == 2);
+ m_active = (m_drive_id == 2);
}
/* drive select 3 */
-WRITE_LINE_DEVICE_HANDLER( floppy_ds3_w )
+WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds3_w )
{
- floppy_drive *drive = get_safe_token(device);
-
if (state == CLEAR_LINE)
- drive->active = (drive->drive_id == 3);
+ m_active = (m_drive_id == 3);
}
/* shortcut to write all four ds lines */
-WRITE8_DEVICE_HANDLER( floppy_ds_w )
+WRITE8_MEMBER( legacy_floppy_image_device::floppy_ds_w )
{
- floppy_ds0_w(device, BIT(data, 0));
- floppy_ds1_w(device, BIT(data, 1));
- floppy_ds2_w(device, BIT(data, 2));
- floppy_ds3_w(device, BIT(data, 3));
+ floppy_ds0_w(BIT(data, 0));
+ floppy_ds1_w(BIT(data, 1));
+ floppy_ds2_w(BIT(data, 2));
+ floppy_ds3_w(BIT(data, 3));
}
/* motor on, active low */
-WRITE_LINE_DEVICE_HANDLER( floppy_mon_w )
+WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_mon_w )
{
- floppy_drive *drive = get_safe_token(device);
- device_image_interface *image = dynamic_cast<device_image_interface *>(device);
/* force off if there is no attached image */
- if (!image->exists())
+ if (!exists())
state = ASSERT_LINE;
/* off -> on */
- if (drive->mon && state == CLEAR_LINE)
+ if (m_mon && state == CLEAR_LINE)
{
- drive->idx = 0;
- floppy_drive_index_func(device);
+ m_idx = 0;
+ floppy_drive_index_func();
}
/* on -> off */
- else if (drive->mon == CLEAR_LINE && state)
- drive->index_timer->adjust(attotime::zero);
+ else if (m_mon == CLEAR_LINE && state)
+ m_index_timer->adjust(attotime::zero);
- drive->mon = state;
+ m_mon = state;
}
/* direction */
-WRITE_LINE_DEVICE_HANDLER( floppy_drtn_w )
+WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_drtn_w )
{
- floppy_drive *drive = get_safe_token(device);
- drive->drtn = state;
+ m_drtn = state;
}
/* write data */
-WRITE_LINE_DEVICE_HANDLER( floppy_wtd_w )
+WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_wtd_w )
{
}
/* step */
-WRITE_LINE_DEVICE_HANDLER( floppy_stp_w )
+WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_stp_w )
{
- floppy_drive *drive = get_safe_token(device);
/* move head one track when going from high to low and write gate is high */
- if (drive->active && drive->stp && state == CLEAR_LINE && drive->wtg)
+ if (m_active && m_stp && state == CLEAR_LINE && m_wtg)
{
/* move head according to the direction line */
- if (drive->drtn)
+ if (m_drtn)
{
/* move head outward */
- if (drive->current_track > 0)
- drive->current_track--;
+ if (m_current_track > 0)
+ m_current_track--;
/* are we at track 0 now? */
- drive->tk00 = (drive->current_track == 0) ? CLEAR_LINE : ASSERT_LINE;
+ m_tk00 = (m_current_track == 0) ? CLEAR_LINE : ASSERT_LINE;
}
else
{
/* move head inward */
- if (drive->current_track < drive->max_track)
- drive->current_track++;
+ if (m_current_track < m_max_track)
+ m_current_track++;
/* we can't be at track 0 here, so reset the line */
- drive->tk00 = ASSERT_LINE;
+ m_tk00 = ASSERT_LINE;
}
/* update track 0 line with new status */
- drive->out_tk00_func(drive->tk00);
+ m_out_tk00_func(m_tk00);
}
- drive->stp = state;
+ m_stp = state;
}
/* write gate */
-WRITE_LINE_DEVICE_HANDLER( floppy_wtg_w )
+WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_wtg_w )
{
- floppy_drive *drive = get_safe_token(device);
- drive->wtg = state;
+ m_wtg = state;
}
/* write protect signal, active low */
-READ_LINE_DEVICE_HANDLER( floppy_wpt_r )
+READ_LINE_MEMBER( legacy_floppy_image_device::floppy_wpt_r )
{
- floppy_drive *drive = get_safe_token(device);
- return drive->wpt;
+ return m_wpt;
}
/* track 0 detect */
-READ_LINE_DEVICE_HANDLER( floppy_tk00_r )
+READ_LINE_MEMBER( legacy_floppy_image_device::floppy_tk00_r )
{
- floppy_drive *drive = get_safe_token(device);
- return drive->tk00;
+ return m_tk00;
}
/* disk changed */
-READ_LINE_DEVICE_HANDLER( floppy_dskchg_r )
+READ_LINE_MEMBER( legacy_floppy_image_device::floppy_dskchg_r )
{
- floppy_drive *drive = get_safe_token(device);
- return drive->dskchg;
+ return m_dskchg;
}
/* 2-sided disk */
-READ_LINE_DEVICE_HANDLER( floppy_twosid_r )
+READ_LINE_MEMBER( legacy_floppy_image_device::floppy_twosid_r )
{
- floppy_drive *drive = get_safe_token(device);
-
- if (drive->floppy == NULL)
+ if (m_floppy == NULL)
return ASSERT_LINE;
else
- return !floppy_get_heads_per_disk(drive->floppy);
+ return !floppy_get_heads_per_disk(m_floppy);
}
-READ_LINE_DEVICE_HANDLER( floppy_index_r )
+READ_LINE_MEMBER( legacy_floppy_image_device::floppy_index_r )
{
- floppy_drive *drive = get_safe_token(device);
- return drive->idx;
+ return m_idx;
}
-READ_LINE_DEVICE_HANDLER( floppy_ready_r )
+READ_LINE_MEMBER( legacy_floppy_image_device::floppy_ready_r )
{
- return !(floppy_drive_get_flag_state(device, FLOPPY_DRIVE_READY) == FLOPPY_DRIVE_READY);
+ return !(floppy_drive_get_flag_state(FLOPPY_DRIVE_READY) == FLOPPY_DRIVE_READY);
}
// device type definition
@@ -849,18 +704,14 @@ const device_type LEGACY_FLOPPY = &device_creator<legacy_floppy_image_device>;
legacy_floppy_image_device::legacy_floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, LEGACY_FLOPPY, "Floppy Disk", tag, owner, clock, "legacy_floppy_image", __FILE__),
- device_image_interface(mconfig, *this),
- m_token(NULL)
+ device_image_interface(mconfig, *this)
{
- m_token = global_alloc_clear(floppy_drive);
}
legacy_floppy_image_device::legacy_floppy_image_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
- device_image_interface(mconfig, *this),
- m_token(NULL)
+ device_image_interface(mconfig, *this)
{
- m_token = global_alloc_clear(floppy_drive);
}
//-------------------------------------------------
@@ -869,7 +720,6 @@ legacy_floppy_image_device::legacy_floppy_image_device(const machine_config &mco
legacy_floppy_image_device::~legacy_floppy_image_device()
{
- global_free(m_token);
}
//-------------------------------------------------
@@ -878,35 +728,34 @@ legacy_floppy_image_device::~legacy_floppy_image_device()
void legacy_floppy_image_device::device_start()
{
- floppy_drive *floppy = get_safe_token( this );
- floppy->config = (const floppy_interface*)static_config();
- floppy_drive_init(this);
+ m_config = (const floppy_interface*)static_config();
+ floppy_drive_init();
- floppy->drive_id = floppy_get_drive(this);
- floppy->active = FALSE;
+ m_drive_id = floppy_get_drive(this);
+ m_active = FALSE;
/* resolve callbacks */
- floppy->out_idx_func.resolve(floppy->config->out_idx_func, *this);
- floppy->in_mon_func.resolve(floppy->config->in_mon_func, *this);
- floppy->out_tk00_func.resolve(floppy->config->out_tk00_func, *this);
- floppy->out_wpt_func.resolve(floppy->config->out_wpt_func, *this);
- floppy->out_rdy_func.resolve(floppy->config->out_rdy_func, *this);
-// floppy->out_dskchg_func.resolve(floppy->config->out_dskchg_func, *this);
+ m_out_idx_func.resolve(m_config->out_idx_func, *this);
+ m_in_mon_func.resolve(m_config->in_mon_func, *this);
+ m_out_tk00_func.resolve(m_config->out_tk00_func, *this);
+ m_out_wpt_func.resolve(m_config->out_wpt_func, *this);
+ m_out_rdy_func.resolve(m_config->out_rdy_func, *this);
+// m_out_dskchg_func.resolve(m_config->out_dskchg_func, *this);
/* by default we are not write-protected */
- floppy->wpt = ASSERT_LINE;
- floppy->out_wpt_func(floppy->wpt);
+ m_wpt = ASSERT_LINE;
+ m_out_wpt_func(m_wpt);
/* not at track 0 */
- floppy->tk00 = ASSERT_LINE;
- floppy->out_tk00_func(floppy->tk00);
+ m_tk00 = ASSERT_LINE;
+ m_out_tk00_func(m_tk00);
/* motor off */
- floppy->mon = ASSERT_LINE;
+ m_mon = ASSERT_LINE;
/* disk changed */
- floppy->dskchg = CLEAR_LINE;
-// floppy->out_dskchg_func(floppy->dskchg);
+ m_dskchg = CLEAR_LINE;
+// m_out_dskchg_func(m_dskchg);
}
@@ -936,23 +785,21 @@ void legacy_floppy_image_device::device_config_complete()
bool legacy_floppy_image_device::call_create(int format_type, option_resolution *format_options)
{
- return internal_floppy_device_load(this, format_type, format_options);
+ return internal_floppy_device_load(format_type, format_options);
}
bool legacy_floppy_image_device::call_load()
{
- floppy_drive *flopimg;
- int retVal = internal_floppy_device_load(this, -1, NULL);
- flopimg = get_safe_token( this);
+ int retVal = internal_floppy_device_load(-1, NULL);
if (retVal==IMAGE_INIT_PASS) {
/* if we have one of our hacky unload procs, call it */
- if (flopimg->load_proc)
- flopimg->load_proc(*this);
+ if (m_load_proc)
+ m_load_proc(*this);
}
/* push disk halfway into drive */
- flopimg->wpt = CLEAR_LINE;
- flopimg->out_wpt_func(flopimg->wpt);
+ m_wpt = CLEAR_LINE;
+ m_out_wpt_func(m_wpt);
/* set timer for disk load */
int next_wpt;
@@ -962,30 +809,29 @@ bool legacy_floppy_image_device::call_load()
else
next_wpt = CLEAR_LINE;
- machine().scheduler().timer_set(attotime::from_msec(250), FUNC(set_wpt), next_wpt, flopimg);
+ machine().scheduler().timer_set(attotime::from_msec(250), timer_expired_delegate(FUNC(legacy_floppy_image_device::set_wpt),this), next_wpt);
return retVal;
}
void legacy_floppy_image_device::call_unload()
{
- floppy_drive *flopimg = get_safe_token( this);
- if (flopimg->unload_proc)
- flopimg->unload_proc(*this);
+ if (m_unload_proc)
+ m_unload_proc(*this);
- floppy_close(flopimg->floppy);
- flopimg->floppy = NULL;
+ floppy_close(m_floppy);
+ m_floppy = NULL;
/* disk changed */
- flopimg->dskchg = CLEAR_LINE;
- //flopimg->out_dskchg_func(flopimg->dskchg);
+ m_dskchg = CLEAR_LINE;
+ //m_out_dskchg_func(m_dskchg);
/* pull disk halfway out of drive */
- flopimg->wpt = CLEAR_LINE;
- flopimg->out_wpt_func(flopimg->wpt);
+ m_wpt = CLEAR_LINE;
+ m_out_wpt_func(m_wpt);
/* set timer for disk eject */
- machine().scheduler().timer_set(attotime::from_msec(250), FUNC(set_wpt), ASSERT_LINE, flopimg);
+ machine().scheduler().timer_set(attotime::from_msec(250), timer_expired_delegate(FUNC(legacy_floppy_image_device::set_wpt),this), ASSERT_LINE);
}
void legacy_floppy_image_device::call_display_info()
diff --git a/src/emu/imagedev/flopdrv.h b/src/emu/imagedev/flopdrv.h
index a5146168d3c..94a3520d5bb 100644
--- a/src/emu/imagedev/flopdrv.h
+++ b/src/emu/imagedev/flopdrv.h
@@ -90,92 +90,6 @@ struct chrn_id
/* set if index has just occurred */
#define FLOPPY_DRIVE_INDEX 0x0020
-/* a callback which will be executed if the ready state of the drive changes e.g. not ready->ready, ready->not ready */
-void floppy_drive_set_ready_state_change_callback(device_t *img, void (*callback)(device_t *controller,device_t *img, int state));
-
-void floppy_drive_set_index_pulse_callback(device_t *img, void (*callback)(device_t *controller,device_t *image, int state));
-
-/* set flag state */
-int floppy_drive_get_flag_state(device_t *img, int flag);
-/* get flag state */
-void floppy_drive_set_flag_state(device_t *img, int flag, int state);
-/* get current physical track drive is on */
-int floppy_drive_get_current_track(device_t *img);
-/* get current physical track size */
-UINT64 floppy_drive_get_current_track_size(device_t *img, int head);
-
-/* get next id from track, 1 if got a id, 0 if no id was got */
-int floppy_drive_get_next_id(device_t *img, int side, chrn_id *);
-/* set ready state of drive. If flag == 1, set ready state only if drive present,
-disk is in drive, and motor is on. Otherwise set ready state to the state passed */
-void floppy_drive_set_ready_state(device_t *img, int state, int flag);
-
-/* seek up or down */
-void floppy_drive_seek(device_t *img, signed int signed_tracks);
-
-void floppy_drive_read_track_data_info_buffer(device_t *img, int side, void *ptr, int *length );
-void floppy_drive_write_track_data_info_buffer(device_t *img, int side, const void *ptr, int *length );
-void floppy_drive_format_sector(device_t *img, int side, int sector_index, int c, int h, int r, int n, int filler);
-void floppy_drive_read_sector_data(device_t *img, int side, int index1, void *pBuffer, int length);
-void floppy_drive_write_sector_data(device_t *img, int side, int index1, const void *pBuffer, int length, int ddam);
-
-/* set motor speed to get correct index pulses
- standard RPM are 300 RPM (common) and 360 RPM
- Note: this actually only works for soft sectored disks: one index pulse per
- track.
-*/
-void floppy_drive_set_rpm(device_t *image, float rpm);
-
-void floppy_drive_set_controller(device_t *img, device_t *controller);
-
-floppy_image_legacy *flopimg_get_image(device_t *image);
-
-/* hack for apple II; replace this when we think of something better */
-void floppy_install_unload_proc(device_t *image, void (*proc)(device_image_interface &image));
-
-void floppy_install_load_proc(device_t *image, void (*proc)(device_image_interface &image));
-
-device_t *floppy_get_device(running_machine &machine,int drive);
-device_t *floppy_get_device_by_type(running_machine &machine,int ftype,int drive);
-int floppy_get_drive_type(device_t *image);
-void floppy_set_type(device_t *image,int ftype);
-int floppy_get_count(running_machine &machine);
-
-int floppy_get_drive(device_t *image);
-int floppy_get_drive_by_type(device_t *image,int ftype);
-
-void floppy_drive_set_geometry(device_t *img, floppy_type_t type);
-
-/* drive select lines */
-WRITE_LINE_DEVICE_HANDLER( floppy_ds0_w );
-WRITE_LINE_DEVICE_HANDLER( floppy_ds1_w );
-WRITE_LINE_DEVICE_HANDLER( floppy_ds2_w );
-WRITE_LINE_DEVICE_HANDLER( floppy_ds3_w );
-DECLARE_WRITE8_DEVICE_HANDLER( floppy_ds_w );
-
-WRITE_LINE_DEVICE_HANDLER( floppy_mon_w );
-WRITE_LINE_DEVICE_HANDLER( floppy_drtn_w );
-WRITE_LINE_DEVICE_HANDLER( floppy_stp_w );
-WRITE_LINE_DEVICE_HANDLER( floppy_wtd_w );
-WRITE_LINE_DEVICE_HANDLER( floppy_wtg_w );
-
-/* write-protect */
-READ_LINE_DEVICE_HANDLER( floppy_wpt_r );
-
-/* track 0 detect */
-READ_LINE_DEVICE_HANDLER( floppy_tk00_r );
-
-/* disk changed */
-READ_LINE_DEVICE_HANDLER( floppy_dskchg_r );
-
-/* 2-sided disk */
-READ_LINE_DEVICE_HANDLER( floppy_twosid_r );
-
-// index pulse
-READ_LINE_DEVICE_HANDLER( floppy_index_r );
-
-// drive ready
-READ_LINE_DEVICE_HANDLER( floppy_ready_r );
class legacy_floppy_image_device : public device_t,
public device_image_interface
@@ -203,20 +117,134 @@ public:
virtual const char *file_extensions() const { return m_extension_list; }
virtual const option_guide *create_option_guide() const { return floppy_option_guide; }
- // access to legacy token
- struct floppy_drive *token() const { assert(m_token != NULL); return m_token; }
+ floppy_image_legacy *flopimg_get_image();
+ void floppy_drive_set_geometry(floppy_type_t type);
+ void floppy_drive_set_flag_state(int flag, int state);
+ void floppy_drive_set_ready_state(int state, int flag);
+ int floppy_drive_get_flag_state(int flag);
+ void floppy_drive_seek(signed int signed_tracks);
+ int floppy_drive_get_next_id(int side, chrn_id *id);
+ void floppy_drive_read_track_data_info_buffer(int side, void *ptr, int *length );
+ void floppy_drive_write_track_data_info_buffer(int side, const void *ptr, int *length );
+ void floppy_drive_format_sector(int side, int sector_index,int c,int h, int r, int n, int filler);
+ void floppy_drive_read_sector_data(int side, int index1, void *ptr, int length);
+ void floppy_drive_write_sector_data(int side, int index1, const void *ptr,int length, int ddam);
+ void floppy_install_load_proc(void (*proc)(device_image_interface &image));
+ void floppy_install_unload_proc(void (*proc)(device_image_interface &image));
+ void floppy_drive_set_index_pulse_callback(void (*callback)(device_t *controller,device_t *image, int state));
+ void floppy_drive_set_ready_state_change_callback(void (*callback)(device_t *controller,device_t *img, int state));
+ int floppy_drive_get_current_track();
+ UINT64 floppy_drive_get_current_track_size(int head);
+ void floppy_drive_set_rpm(float rpm);
+ void floppy_drive_set_controller(device_t *controller);
+ int floppy_get_drive_type();
+ void floppy_set_type(int ftype);
+ WRITE_LINE_MEMBER( floppy_ds0_w );
+ WRITE_LINE_MEMBER( floppy_ds1_w );
+ WRITE_LINE_MEMBER( floppy_ds2_w );
+ WRITE_LINE_MEMBER( floppy_ds3_w );
+ WRITE8_MEMBER( floppy_ds_w );
+ WRITE_LINE_MEMBER( floppy_mon_w );
+ WRITE_LINE_MEMBER( floppy_drtn_w );
+ WRITE_LINE_MEMBER( floppy_wtd_w );
+ WRITE_LINE_MEMBER( floppy_stp_w );
+ WRITE_LINE_MEMBER( floppy_wtg_w );
+ READ_LINE_MEMBER( floppy_wpt_r );
+ READ_LINE_MEMBER( floppy_tk00_r );
+ READ_LINE_MEMBER( floppy_dskchg_r );
+ READ_LINE_MEMBER( floppy_twosid_r );
+ READ_LINE_MEMBER( floppy_index_r );
+ READ_LINE_MEMBER( floppy_ready_r );
+
+
+private:
+ int flopimg_get_sectors_per_track(int side);
+ void flopimg_get_id_callback(chrn_id *id, int id_index, int side);
+ void log_readwrite(const char *name, int head, int track, int sector, const char *buf, int length);
+ void floppy_drive_set_geometry_absolute(int tracks, int sides);
+ TIMER_CALLBACK_MEMBER(floppy_drive_index_callback);
+ void floppy_drive_init();
+ void floppy_drive_index_func();
+ TIMER_CALLBACK(floppy_drive_index_callback);
+ int internal_floppy_device_load(int create_format, option_resolution *create_args);
+ TIMER_CALLBACK_MEMBER( set_wpt );
+
protected:
// device overrides
virtual void device_config_complete();
virtual void device_start();
- struct floppy_drive *m_token;
+ /* callbacks */
+ devcb_resolved_write_line m_out_idx_func;
+ devcb_resolved_read_line m_in_mon_func;
+ devcb_resolved_write_line m_out_tk00_func;
+ devcb_resolved_write_line m_out_wpt_func;
+ devcb_resolved_write_line m_out_rdy_func;
+ devcb_resolved_write_line m_out_dskchg_func;
+
+ /* state of input lines */
+ int m_drtn; /* direction */
+ int m_stp; /* step */
+ int m_wtg; /* write gate */
+ int m_mon; /* motor on */
+
+ /* state of output lines */
+ int m_idx; /* index pulse */
+ int m_tk00; /* track 00 */
+ int m_wpt; /* write protect */
+ int m_rdy; /* ready */
+ int m_dskchg; /* disk changed */
+
+ /* drive select logic */
+ int m_drive_id;
+ int m_active;
+
+ const floppy_interface *m_config;
+
+ /* flags */
+ int m_flags;
+ /* maximum track allowed */
+ int m_max_track;
+ /* num sides */
+ int m_num_sides;
+ /* current track - this may or may not relate to the present cylinder number
+ stored by the fdc */
+ int m_current_track;
+
+ /* index pulse timer */
+ emu_timer *m_index_timer;
+ /* index pulse callback */
+ void (*m_index_pulse_callback)(device_t *controller,device_t *image, int state);
+ /* rotation per minute => gives index pulse frequency */
+ float m_rpm;
+
+ void (*m_ready_state_change_callback)(device_t *controller,device_t *img, int state);
+
+ int m_id_index;
+
+ device_t *m_controller;
+
+ floppy_image_legacy *m_floppy;
+ int m_track;
+ void (*m_load_proc)(device_image_interface &image);
+ void (*m_unload_proc)(device_image_interface &image);
+ int m_floppy_drive_type;
+
char m_extension_list[256];
};
// device type definition
extern const device_type LEGACY_FLOPPY;
+
+
+legacy_floppy_image_device *floppy_get_device(running_machine &machine,int drive);
+legacy_floppy_image_device *floppy_get_device_by_type(running_machine &machine,int ftype,int drive);
+int floppy_get_drive(device_t *image);
+int floppy_get_drive_by_type(legacy_floppy_image_device *image,int ftype);
+int floppy_get_count(running_machine &machine);
+
+
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
diff --git a/src/emu/machine/i8271.c b/src/emu/machine/i8271.c
index 6dcc8dddb0d..f446d87862c 100644
--- a/src/emu/machine/i8271.c
+++ b/src/emu/machine/i8271.c
@@ -14,7 +14,6 @@
#include "emu.h"
#include "i8271.h"
-#include "imagedev/flopdrv.h"
/* data request */
#define I8271_FLAGS_DATA_REQUEST 0x01
@@ -238,10 +237,10 @@ void i8271_device::device_reset()
set_dma_drq();
}
-device_t *i8271_device::current_image()
+legacy_floppy_image_device *i8271_device::current_image()
{
if (m_floppy_drive_tags[m_drive]!=NULL) {
- return machine().device(m_floppy_drive_tags[m_drive]);
+ return machine().device<legacy_floppy_image_device>(m_floppy_drive_tags[m_drive]);
} else {
return NULL;
}
@@ -250,7 +249,7 @@ device_t *i8271_device::current_image()
void i8271_device::seek_to_track(int track)
{
- device_t *img = current_image();
+ legacy_floppy_image_device *img = current_image();
if (track==0)
{
/* seek to track 0 */
@@ -259,11 +258,11 @@ void i8271_device::seek_to_track(int track)
/*logerror("step\n"); */
/* track 0 not set, not seeked more than 255 tracks */
- while (floppy_tk00_r(img) && (StepCount != 0))
+ while (img->floppy_tk00_r() && (StepCount != 0))
{
/* logerror("step\n"); */
StepCount--;
- floppy_drive_seek(img, -1);
+ img->floppy_drive_seek(-1);
}
m_CurrentTrack[m_drive] = 0;
@@ -297,7 +296,7 @@ void i8271_device::seek_to_track(int track)
/* seek to track 0 */
- floppy_drive_seek(img, SignedTracks);
+ img->floppy_drive_seek(SignedTracks);
m_CurrentTrack[m_drive] = track;
}
@@ -610,7 +609,7 @@ void i8271_device::command_continue()
case I8271_COMMAND_WRITE_DATA_SINGLE_RECORD:
{
/* put the buffer to the sector */
- floppy_drive_write_sector_data(current_image(), m_side, m_data_id, m_pExecutionPhaseData, 1<<(m_ID_N+7),0);
+ current_image()->floppy_drive_write_sector_data(m_side, m_data_id, m_pExecutionPhaseData, 1<<(m_ID_N+7),0);
/* completed all sectors? */
m_Counter--;
@@ -653,7 +652,7 @@ void i8271_device::do_read()
if (find_sector())
{
/* get the sector into the buffer */
- floppy_drive_read_sector_data(current_image(), m_side, m_data_id, m_pExecutionPhaseData, 1<<(m_ID_N+7));
+ current_image()->floppy_drive_read_sector_data(m_side, m_data_id, m_pExecutionPhaseData, 1<<(m_ID_N+7));
/* initialise for reading */
initialise_execution_phase_read(1<<(m_ID_N+7));
@@ -672,7 +671,7 @@ void i8271_device::do_read_id()
chrn_id id;
/* get next id from disc */
- floppy_drive_get_next_id(current_image(), m_side,&id);
+ current_image()->floppy_drive_get_next_id(m_side,&id);
m_pExecutionPhaseData[0] = id.C;
m_pExecutionPhaseData[1] = id.H;
@@ -704,7 +703,7 @@ void i8271_device::do_write()
int i8271_device::find_sector()
{
- device_t *img = current_image();
+ legacy_floppy_image_device *img = current_image();
// int track_count_attempt;
// track_count_attempt
@@ -719,7 +718,7 @@ int i8271_device::find_sector()
chrn_id id;
/* get next id from disc */
- if (floppy_drive_get_next_id(img, m_side,&id))
+ if (img->floppy_drive_get_next_id(m_side,&id))
{
/* tested on Amstrad CPC - All bytes must match, otherwise
a NO DATA error is reported */
@@ -742,7 +741,7 @@ int i8271_device::find_sector()
}
/* index set? */
- if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_INDEX))
+ if (img->floppy_drive_get_flag_state(FLOPPY_DRIVE_INDEX))
{
index_count++;
}
@@ -759,7 +758,7 @@ int i8271_device::find_sector()
void i8271_device::command_execute()
{
- device_t *img = current_image();
+ legacy_floppy_image_device *img = current_image();
/* clear it = good completion status */
/* this will be changed if anything bad happens! */
@@ -885,10 +884,10 @@ void i8271_device::command_execute()
m_drive_control_input = (1<<6) | (1<<2);
/* bit 3 = 0 if write protected */
- m_drive_control_input |= floppy_wpt_r(img) << 3;
+ m_drive_control_input |= img->floppy_wpt_r() << 3;
/* bit 1 = 0 if head at track 0 */
- m_drive_control_input |= floppy_tk00_r(img) << 1;
+ m_drive_control_input |= img->floppy_tk00_r() << 1;
/* need to setup this register based on drive selected */
data = m_drive_control_input;
@@ -1021,8 +1020,8 @@ void i8271_device::command_execute()
/* load head - on mini-sized drives this turns on the disc motor,
on standard-sized drives this loads the head and turns the motor on */
- floppy_mon_w(img, !BIT(m_CommandParameters[1], 3));
- floppy_drive_set_ready_state(img, 1, 1);
+ img->floppy_mon_w(!BIT(m_CommandParameters[1], 3));
+ img->floppy_drive_set_ready_state(1, 1);
/* step pin changed? if so perform a step in the direction indicated */
if (((m_drive_control_output^m_CommandParameters[1]) & (1<<1))!=0)
@@ -1042,7 +1041,7 @@ void i8271_device::command_execute()
signed_tracks = -1;
}
- floppy_drive_seek(img, signed_tracks);
+ img->floppy_drive_seek(signed_tracks);
}
}
@@ -1081,24 +1080,24 @@ void i8271_device::command_execute()
/* these two do not appear to be set at all! ?? */
if (m_floppy_drive_tags[0]!=NULL) {
- if (floppy_drive_get_flag_state(machine().device(m_floppy_drive_tags[0]), FLOPPY_DRIVE_READY))
+ if (machine().device<legacy_floppy_image_device>(m_floppy_drive_tags[0])->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
{
status |= (1<<2);
}
}
if (m_floppy_drive_tags[1]!=NULL) {
- if (floppy_drive_get_flag_state(machine().device(m_floppy_drive_tags[1]), FLOPPY_DRIVE_READY))
+ if (machine().device<legacy_floppy_image_device>(m_floppy_drive_tags[1])->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
{
status |= (1<<6);
}
}
/* bit 3 = 1 if write protected */
- status |= !floppy_wpt_r(img) << 3;
+ status |= !img->floppy_wpt_r() << 3;
/* bit 1 = 1 if head at track 0 */
- status |= !floppy_tk00_r(img) << 1;
+ status |= !img->floppy_tk00_r() << 1;
m_ResultRegister = status;
command_complete(1,0);
@@ -1140,7 +1139,7 @@ void i8271_device::command_execute()
get_drive();
- if (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY))
+ if (!img->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
{
/* Completion type: operation intervention probably required for recovery */
/* Completion code: Drive not ready */
@@ -1173,7 +1172,7 @@ void i8271_device::command_execute()
get_drive();
- if (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY))
+ if (!img->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
{
/* Completion type: operation intervention probably required for recovery */
/* Completion code: Drive not ready */
@@ -1212,7 +1211,7 @@ void i8271_device::command_execute()
m_drive_control_output &=~1;
- if (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY))
+ if (!img->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
{
/* Completion type: operation intervention probably required for recovery */
/* Completion code: Drive not ready */
@@ -1221,7 +1220,7 @@ void i8271_device::command_execute()
}
else
{
- if (floppy_wpt_r(img) == CLEAR_LINE)
+ if (img->floppy_wpt_r() == CLEAR_LINE)
{
/* Completion type: operation intervention probably required for recovery */
/* Completion code: Drive write protected */
@@ -1257,7 +1256,7 @@ void i8271_device::command_execute()
m_drive_control_output &=~1;
- if (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY))
+ if (!img->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
{
/* Completion type: operation intervention probably required for recovery */
/* Completion code: Drive not ready */
@@ -1266,7 +1265,7 @@ void i8271_device::command_execute()
}
else
{
- if (floppy_wpt_r(img) == CLEAR_LINE)
+ if (img->floppy_wpt_r() == CLEAR_LINE)
{
/* Completion type: operation intervention probably required for recovery */
/* Completion code: Drive write protected */
@@ -1296,7 +1295,7 @@ void i8271_device::command_execute()
get_drive();
- if (!floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY))
+ if (!img->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
{
/* Completion type: operation intervention probably required for recovery */
/* Completion code: Drive not ready */
diff --git a/src/emu/machine/i8271.h b/src/emu/machine/i8271.h
index 1eee11ef25e..52e5c5ac7fd 100644
--- a/src/emu/machine/i8271.h
+++ b/src/emu/machine/i8271.h
@@ -7,6 +7,8 @@
#ifndef I8271_H_
#define I8271_H_
+#include "imagedev/flopdrv.h"
+
#define MCFG_I8271_IRQ_CALLBACK(_write) \
devcb = &i8271_device::set_irq_wr_callback(*device, DEVCB2_##_write);
@@ -126,7 +128,7 @@ private:
emu_timer *m_data_timer;
emu_timer *m_command_complete_timer;
- device_t *current_image();
+ legacy_floppy_image_device *current_image();
void seek_to_track(int track);
void load_bad_tracks(int surface);
void write_bad_track(int surface, int track, int data);
diff --git a/src/emu/machine/mc6843.c b/src/emu/machine/mc6843.c
index 49e6d8a918d..b7e678603c3 100644
--- a/src/emu/machine/mc6843.c
+++ b/src/emu/machine/mc6843.c
@@ -139,10 +139,10 @@ void mc6843_device::device_reset()
/* setup/reset floppy drive */
for ( i = 0; i < 4; i++ )
{
- device_t * img = floppy_image( i );
- floppy_mon_w(img, CLEAR_LINE);
- floppy_drive_set_ready_state( img, FLOPPY_DRIVE_READY, 0 );
- floppy_drive_set_rpm( img, 300. );
+ legacy_floppy_image_device * img = floppy_image( i );
+ img->floppy_mon_w(CLEAR_LINE);
+ img->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 0 );
+ img->floppy_drive_set_rpm( 300. );
}
/* reset registers */
@@ -162,9 +162,9 @@ void mc6843_device::device_reset()
-device_t* mc6843_device::floppy_image( UINT8 drive )
+legacy_floppy_image_device* mc6843_device::floppy_image( UINT8 drive )
{
- device_t *img = floppy_get_device( machine(), drive );
+ legacy_floppy_image_device *img = floppy_get_device( machine(), drive );
if (!img && owner()) {
// For slot devices, drives are typically attached to the slot rather than the machine
const char *floppy_name = NULL;
@@ -182,13 +182,13 @@ device_t* mc6843_device::floppy_image( UINT8 drive )
floppy_name = FLOPPY_3;
break;
}
- img = owner()->subdevice(floppy_name);
+ img = owner()->subdevice<legacy_floppy_image_device>(floppy_name);
}
return img;
}
-device_t* mc6843_device::floppy_image( )
+legacy_floppy_image_device* mc6843_device::floppy_image( )
{
return floppy_image( m_drive );
}
@@ -262,24 +262,24 @@ void mc6843_device::cmd_end( )
/* Seek Track Zero bottom half */
void mc6843_device::finish_STZ( )
{
- device_t* img = floppy_image( );
+ legacy_floppy_image_device* img = floppy_image( );
int i;
/* seek to track zero */
for ( i=0; i<83; i++ )
{
- if (floppy_tk00_r(img) == CLEAR_LINE)
+ if (img->floppy_tk00_r() == CLEAR_LINE)
break;
- floppy_drive_seek( img, -1 );
+ img->floppy_drive_seek( -1 );
}
- LOG(( "%f mc6843_finish_STZ: actual=%i\n", machine().time().as_double(), floppy_drive_get_current_track( img ) ));
+ LOG(( "%f mc6843_finish_STZ: actual=%i\n", machine().time().as_double(), img->floppy_drive_get_current_track() ));
/* update state */
m_CTAR = 0;
m_GCR = 0;
m_SAR = 0;
- m_STRB |= floppy_tk00_r(img) << 4;
+ m_STRB |= img->floppy_tk00_r() << 4;
cmd_end( );
}
@@ -289,13 +289,13 @@ void mc6843_device::finish_STZ( )
/* Seek bottom half */
void mc6843_device::finish_SEK( )
{
- device_t* img = floppy_image( );
+ legacy_floppy_image_device* img = floppy_image( );
/* seek to track */
// TODO: not sure how CTAR bit 7 is handled here, but this is the safest approach for now
- floppy_drive_seek( img, m_GCR - (m_CTAR & 0x7F) );
+ img->floppy_drive_seek( m_GCR - (m_CTAR & 0x7F) );
- LOG(( "%f mc6843_finish_SEK: from %i to %i (actual=%i)\n", machine().time().as_double(), (m_CTAR & 0x7F), m_GCR, floppy_drive_get_current_track( img ) ));
+ LOG(( "%f mc6843_finish_SEK: from %i to %i (actual=%i)\n", machine().time().as_double(), (m_CTAR & 0x7F), m_GCR, img->floppy_drive_get_current_track() ));
/* update state */
m_CTAR = m_GCR;
@@ -308,12 +308,12 @@ void mc6843_device::finish_SEK( )
/* preamble to all sector read / write commands, returns 1 if found */
int mc6843_device::address_search( chrn_id* id )
{
- device_t* img = floppy_image( );
+ legacy_floppy_image_device* img = floppy_image( );
int r = 0;
while ( 1 )
{
- if ( ( ! floppy_drive_get_next_id( img, m_side, id ) ) || ( id->flags & ID_FLAG_CRC_ERROR_IN_ID_FIELD ) || ( id->N != 0 ) )
+ if ( ( ! img->floppy_drive_get_next_id( m_side, id ) ) || ( id->flags & ID_FLAG_CRC_ERROR_IN_ID_FIELD ) || ( id->N != 0 ) )
{
/* read address error */
LOG(( "%f mc6843_address_search: get_next_id failed\n", machine().time().as_double() ));
@@ -343,7 +343,7 @@ int mc6843_device::address_search( chrn_id* id )
return 1;
}
- if ( floppy_drive_get_flag_state( img, FLOPPY_DRIVE_INDEX ) )
+ if ( img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) )
{
r++;
if ( r >= 4 )
@@ -403,14 +403,14 @@ void mc6843_device::finish_RCR( )
void mc6843_device::cont_SR( )
{
chrn_id id;
- device_t* img = floppy_image( );
+ legacy_floppy_image_device* img = floppy_image( );
/* sector seek */
if ( ! address_search_read( &id ) )
return;
/* sector read */
- floppy_drive_read_sector_data( img, m_side, id.data_id, m_data, 128 );
+ img->floppy_drive_read_sector_data( m_side, id.data_id, m_data, 128 );
m_data_idx = 0;
m_data_size = 128;
m_STRA |= 0x01; /* set Data Transfer Request */
@@ -551,7 +551,7 @@ READ8_MEMBER( mc6843_device::read )
data = m_CTAR;
LOG(( "%f %s mc6843_r: read CTAR %i (actual=%i)\n",
machine().time().as_double(), machine().describe_context(), data,
- floppy_drive_get_current_track( floppy_image( ) ) ));
+ floppy_image()->floppy_drive_get_current_track()));
break;
case 2: /* Interrupt Status Register (ISR) */
@@ -569,14 +569,14 @@ READ8_MEMBER( mc6843_device::read )
case 3: /* Status Register A (STRA) */
{
/* update */
- device_t* img = floppy_image( );
- int flag = floppy_drive_get_flag_state( img, FLOPPY_DRIVE_READY);
+ legacy_floppy_image_device* img = floppy_image( );
+ int flag = img->floppy_drive_get_flag_state( FLOPPY_DRIVE_READY);
m_STRA &= 0xa3;
if ( flag & FLOPPY_DRIVE_READY )
m_STRA |= 0x04;
- m_STRA |= !floppy_tk00_r(img) << 3;
- m_STRA |= !floppy_wpt_r(img) << 4;
+ m_STRA |= !img->floppy_tk00_r() << 3;
+ m_STRA |= !img->floppy_wpt_r() << 4;
if ( m_index_pulse )
m_STRA |= 0x40;
@@ -605,7 +605,7 @@ READ8_MEMBER( mc6843_device::read )
data = m_LTAR;
LOG(( "%f %s mc6843_r: read LTAR %i (actual=%i)\n",
machine().time().as_double(), machine().describe_context(), data,
- floppy_drive_get_current_track( floppy_image( ) ) ));
+ floppy_image()->floppy_drive_get_current_track()));
break;
default:
@@ -639,12 +639,12 @@ WRITE8_MEMBER( mc6843_device::write )
if ( m_data_idx >= m_data_size )
{
/* end of sector write */
- device_t* img = floppy_image( );
+ legacy_floppy_image_device* img = floppy_image( );
LOG(( "%f %s mc6843_w: write sector %i\n", machine().time().as_double(), machine().describe_context(), m_data_id ));
- floppy_drive_write_sector_data(
- img, m_side, m_data_id,
+ img->floppy_drive_write_sector_data(
+ m_side, m_data_id,
m_data, m_data_size,
(cmd == CMD_SWD) ? ID_FLAG_DELETED_DATA : 0 );
@@ -701,12 +701,12 @@ WRITE8_MEMBER( mc6843_device::write )
if ( (m_data[2] == 0) && (m_data[4] == 0) )
{
/* valid address id field */
- device_t* img = floppy_image( );
+ legacy_floppy_image_device* img = floppy_image( );
UINT8 track = m_data[1];
UINT8 sector = m_data[3];
UINT8 filler = 0xe5; /* standard Thomson filler */
LOG(( "%f %s mc6843_w: address id detected track=%i sector=%i\n", machine().time().as_double(), machine().describe_context(), track, sector));
- floppy_drive_format_sector( img, m_side, sector, track, 0, sector, 0, filler );
+ img->floppy_drive_format_sector( m_side, sector, track, 0, sector, 0, filler );
}
else
{
@@ -736,7 +736,7 @@ WRITE8_MEMBER( mc6843_device::write )
m_CTAR = data;
LOG(( "%f %s mc6843_w: set CTAR to %i %02X (actual=%i) \n",
machine().time().as_double(), machine().describe_context(), m_CTAR, data,
- floppy_drive_get_current_track( floppy_image( ) ) ));
+ floppy_image()->floppy_drive_get_current_track()));
break;
case 2: /* Command Register (CMR) */
@@ -816,7 +816,7 @@ WRITE8_MEMBER( mc6843_device::write )
m_LTAR = data & 0x7f;
LOG(( "%f %s mc6843_w: set LTAR to %i %02X (actual=%i)\n",
machine().time().as_double(), machine().describe_context(), m_LTAR, data,
- floppy_drive_get_current_track( floppy_image( ) ) ));
+ floppy_image()->floppy_drive_get_current_track()));
break;
default:
diff --git a/src/emu/machine/mc6843.h b/src/emu/machine/mc6843.h
index 78f2a7f1096..5c66033c1a6 100644
--- a/src/emu/machine/mc6843.h
+++ b/src/emu/machine/mc6843.h
@@ -67,8 +67,8 @@ private:
/* trigger delayed actions (bottom halves) */
emu_timer* m_timer_cont;
- device_t* floppy_image(UINT8 drive);
- device_t* floppy_image();
+ legacy_floppy_image_device* floppy_image(UINT8 drive);
+ legacy_floppy_image_device* floppy_image();
void status_update();
void cmd_end();
void finish_STZ();
diff --git a/src/emu/machine/smc92x4.c b/src/emu/machine/smc92x4.c
index f59288face0..516c6eef019 100644
--- a/src/emu/machine/smc92x4.c
+++ b/src/emu/machine/smc92x4.c
@@ -200,7 +200,7 @@ smc92x4_device::smc92x4_device(const machine_config &mconfig, const char *tag, d
int smc92x4_device::image_is_single_density()
{
- floppy_image_legacy *image = flopimg_get_image(m_drive);
+ floppy_image_legacy *image = m_drive->flopimg_get_image();
return (floppy_get_track_size(image, 0, 0)<4000);
}
@@ -436,7 +436,6 @@ void smc92x4_device::device_timer(emu_timer &timer, device_timer_id id, int para
int redcur;
int precomp;
int write_long;
- mfm_harddisk_device *harddisk;
switch (id)
{
@@ -481,14 +480,13 @@ void smc92x4_device::device_timer(emu_timer &timer, device_timer_id id, int para
else
{
if (VERBOSE>5) LOG("smc92x4 step %s direction %d\n", m_drive->tag(), m_step_direction);
- floppy_drive_seek(m_drive, m_step_direction);
+ m_drive->floppy_drive_seek(m_step_direction);
}
}
else
{
if (VERBOSE>6) LOG("smc92x4 step harddisk direction %d\n", m_step_direction);
- harddisk = static_cast<mfm_harddisk_device *>(m_drive);
- harddisk->seek(m_step_direction);
+ m_harddisk->seek(m_step_direction);
}
sync_status_in();
break;
@@ -566,7 +564,6 @@ void smc92x4_device::read_id_field(int *steps, int *direction, chrn_id_hd *id)
{
int des_cylinder, cur_cylinder;
bool found = false;
- mfm_harddisk_device *harddisk;
sync_latches_out();
sync_status_in();
@@ -579,7 +576,7 @@ void smc92x4_device::read_id_field(int *steps, int *direction, chrn_id_hd *id)
if (m_selected_drive_type & TYPE_FLOPPY)
{
chrn_id idflop;
- if (flopimg_get_image(m_drive) == NULL)
+ if (m_drive->flopimg_get_image() == NULL)
{
if (VERBOSE>2) LOG("smc92x4 warn: No disk in drive\n");
m_register_r[CHIP_STATUS] |= CS_SYNCERR;
@@ -590,7 +587,7 @@ void smc92x4_device::read_id_field(int *steps, int *direction, chrn_id_hd *id)
if ((image_is_single_density() && in_single_density_mode())
|| (!image_is_single_density() && !in_single_density_mode()))
{
- found = floppy_drive_get_next_id(m_drive, m_register_w[DESIRED_HEAD]&0x0f, &idflop);
+ found = m_drive->floppy_drive_get_next_id(m_register_w[DESIRED_HEAD]&0x0f, &idflop);
copyid(idflop, id); /* Need to use bigger values for HD, but we don't use separate variables here */
}
else
@@ -608,9 +605,7 @@ void smc92x4_device::read_id_field(int *steps, int *direction, chrn_id_hd *id)
}
else
{
- harddisk = static_cast<mfm_harddisk_device *>(m_drive);
-
- harddisk->get_next_id(m_register_w[DESIRED_HEAD]&0x0f, id);
+ m_harddisk->get_next_id(m_register_w[DESIRED_HEAD]&0x0f, id);
sync_status_in();
if (!(m_register_r[DRIVE_STATUS]& DS_READY))
{
@@ -670,7 +665,6 @@ int smc92x4_device::verify(chrn_id_hd *id, bool check_sector)
int found = false;
int foundsect = false;
int des_cylinder = 0;
- mfm_harddisk_device *harddisk;
// Set command termination code. The error code is set first, and
// on success, it is cleared.
@@ -683,7 +677,7 @@ int smc92x4_device::verify(chrn_id_hd *id, bool check_sector)
if (m_selected_drive_type & TYPE_FLOPPY)
{
chrn_id idflop;
- found = floppy_drive_get_next_id(m_drive, m_register_w[DESIRED_HEAD]&0x0f, &idflop);
+ found = m_drive->floppy_drive_get_next_id(m_register_w[DESIRED_HEAD]&0x0f, &idflop);
copyid(idflop, id);
if (/* pass==1 && */!found)
{
@@ -694,8 +688,7 @@ int smc92x4_device::verify(chrn_id_hd *id, bool check_sector)
}
else
{
- harddisk = static_cast<mfm_harddisk_device *>(m_drive);
- harddisk->get_next_id(m_register_w[DESIRED_HEAD]&0x0f, id);
+ m_harddisk->get_next_id(m_register_w[DESIRED_HEAD]&0x0f, id);
sync_status_in();
if (!(m_register_r[DRIVE_STATUS]& DS_READY))
{
@@ -742,7 +735,6 @@ int smc92x4_device::verify(chrn_id_hd *id, bool check_sector)
void smc92x4_device::data_transfer_read(chrn_id_hd id, int transfer_enable)
{
int i, retry, sector_len;
- mfm_harddisk_device *harddisk;
int sector_data_id;
dynamic_buffer buf;
@@ -780,13 +772,12 @@ void smc92x4_device::data_transfer_read(chrn_id_hd id, int transfer_enable)
if (m_selected_drive_type & TYPE_FLOPPY)
{
- floppy_drive_read_sector_data(m_drive, id.H, sector_data_id, buf, sector_len);
+ m_drive->floppy_drive_read_sector_data(id.H, sector_data_id, buf, sector_len);
}
else
{
// TODO: Should we get the sector length from the harddisk?
- harddisk = static_cast<mfm_harddisk_device *>(m_drive);
- harddisk->read_sector(id.C, id.H, id.R, buf);
+ m_harddisk->read_sector(id.C, id.H, id.R, buf);
}
sync_status_in();
@@ -837,7 +828,6 @@ void smc92x4_device::data_transfer_write(chrn_id_hd id, int deldata, int redcur,
int retry, i, sector_len;
dynamic_buffer buf;
int sector_data_id;
- mfm_harddisk_device *harddisk;
sync_latches_out();
sync_status_in();
@@ -876,12 +866,11 @@ void smc92x4_device::data_transfer_write(chrn_id_hd id, int deldata, int redcur,
if (m_selected_drive_type & TYPE_FLOPPY)
{
if (VERBOSE>4) LOG("smc92x4 info: write sector CHS=(%d,%d,%d)\n", id.C, id.H, id.R);
- floppy_drive_write_sector_data(m_drive, id.H, sector_data_id, buf, sector_len, false);
+ m_drive->floppy_drive_write_sector_data(id.H, sector_data_id, buf, sector_len, false);
}
else
{
- harddisk = static_cast<mfm_harddisk_device *>(m_drive);
- harddisk->write_sector(id.C, id.H, id.R, buf);
+ m_harddisk->write_sector(id.C, id.H, id.R, buf);
}
sync_status_in();
@@ -1344,7 +1333,7 @@ void smc92x4_device::format_floppy_track(int flags)
sync_status_in();
- floppy = flopimg_get_image(m_drive);
+ floppy = m_drive->flopimg_get_image();
if (floppy != NULL)
data_count = floppy_get_track_size(floppy, 0, 0);
@@ -1486,7 +1475,7 @@ void smc92x4_device::format_floppy_track(int flags)
memset(&buffer[index], gap_byte, gap4);
index += gap4;
- floppy_drive_write_track_data_info_buffer(m_drive, m_register_w[DESIRED_HEAD]&0x0f, buffer, &data_count);
+ m_drive->floppy_drive_write_track_data_info_buffer(m_register_w[DESIRED_HEAD]&0x0f, buffer, &data_count);
sync_status_in();
}
@@ -1506,8 +1495,6 @@ void smc92x4_device::format_harddisk_track(int flags)
int normal_data_mark = flags & 0x10;
int data_count=0;
- mfm_harddisk_device *harddisk = static_cast<mfm_harddisk_device *>(m_drive);
-
dynamic_buffer buffer;
sync_status_in();
@@ -1585,7 +1572,7 @@ void smc92x4_device::format_harddisk_track(int flags)
for (i=0; i < gap4; i++) buffer[index++] = gap_byte;
// Now write the whole track
- harddisk->write_track(m_register_w[DESIRED_HEAD]&0x0f, buffer, data_count);
+ m_harddisk->write_track(m_register_w[DESIRED_HEAD]&0x0f, buffer, data_count);
sync_status_in();
}
@@ -1618,7 +1605,7 @@ void smc92x4_device::read_floppy_track(bool transfer_only_ids)
sync_latches_out();
- floppy = flopimg_get_image(m_drive);
+ floppy = m_drive->flopimg_get_image();
/* Determine the track size. We cannot allow different sizes in this design. */
if (floppy != NULL)
@@ -1634,7 +1621,7 @@ void smc92x4_device::read_floppy_track(bool transfer_only_ids)
buffer = global_alloc_array(UINT8, data_count);
- floppy_drive_read_track_data_info_buffer(m_drive, m_register_w[DESIRED_HEAD]&0x0f, (char *)buffer, &data_count);
+ m_drive->floppy_drive_read_track_data_info_buffer(m_register_w[DESIRED_HEAD]&0x0f, (char *)buffer, &data_count);
sync_status_in();
// Transfer the buffer to the external memory. We assume the memory
@@ -1662,15 +1649,13 @@ void smc92x4_device::read_harddisk_track(bool transfer_only_ids)
int i;
UINT8 *buffer;
int data_count=0;
- mfm_harddisk_device *harddisk = static_cast<mfm_harddisk_device *>(m_drive);
-
sync_latches_out();
- data_count = harddisk->get_track_length();
+ data_count = m_harddisk->get_track_length();
buffer = global_alloc_array(UINT8, data_count);
/* buffer and data_count are allocated and set by the function. */
- harddisk->read_track(m_register_w[DESIRED_HEAD]&0x0f, buffer);
+ m_harddisk->read_track(m_register_w[DESIRED_HEAD]&0x0f, buffer);
sync_status_in();
if (!(m_register_r[DRIVE_STATUS] & DS_READY))
@@ -2004,7 +1989,7 @@ void smc92x4_device::set_timing(bool realistic)
if (VERBOSE>0) LOG("smc92x4: use realistic timing: %02x\n", realistic);
}
-void smc92x4_device::connect_drive(device_t *drive)
+void smc92x4_device::connect_floppy_drive(legacy_floppy_image_device *drive)
{
m_drive = drive;
if (VERBOSE>3)
@@ -2013,6 +1998,15 @@ void smc92x4_device::connect_drive(device_t *drive)
else LOG("smc92x4: Connect drive %s\n", drive->tag());
}
}
+void smc92x4_device::connect_hard_drive(mfm_harddisk_device *drive)
+{
+ m_harddisk = drive;
+ if (VERBOSE>3)
+ {
+ if (drive==NULL) LOG("smc92x4: Unselect all drives\n");
+ else LOG("smc92x4: Connect drive %s\n", drive->tag());
+ }
+}
void smc92x4_device::reset()
{
diff --git a/src/emu/machine/smc92x4.h b/src/emu/machine/smc92x4.h
index bc4368cec68..4b06c14dd1d 100644
--- a/src/emu/machine/smc92x4.h
+++ b/src/emu/machine/smc92x4.h
@@ -98,7 +98,8 @@ public:
// Used to reconfigure the drive connections. Drive selection is done
// using the select lines and maybe also the user-programmable outputs.
- void connect_drive(device_t *drive);
+ void connect_floppy_drive(legacy_floppy_image_device *drive);
+ void connect_hard_drive(mfm_harddisk_device *drive);
void reset();
@@ -221,7 +222,8 @@ private:
// Hard disks must be instances of mfmhd_device; floppy disks are the common drives.
// We expect the embedding board to replace the drive according to the
// select lines.
- device_t *m_drive;
+ legacy_floppy_image_device *m_drive;
+ mfm_harddisk_device *m_harddisk;
};
#define MCFG_SMC92X4_ADD(_tag, _intrf) \
diff --git a/src/emu/machine/wd17xx.c b/src/emu/machine/wd17xx.c
index 9a289a9e16e..57352f7ab87 100644
--- a/src/emu/machine/wd17xx.c
+++ b/src/emu/machine/wd17xx.c
@@ -154,7 +154,6 @@
#include "emu.h"
#include "formats/imageutl.h"
#include "machine/wd17xx.h"
-#include "imagedev/flopdrv.h"
/***************************************************************************
CONSTANTS
@@ -494,11 +493,11 @@ void wd1770_device::wd17xx_command_restore()
if (1) // image_slotexists(m_drive) : FIXME
{
/* keep stepping until track 0 is received or 255 steps have been done */
- while (floppy_tk00_r(m_drive) && (step_counter != 0))
+ while (m_drive->floppy_tk00_r() && (step_counter != 0))
{
/* update time to simulate seek time busy signal */
m_busy_count++;
- floppy_drive_seek(m_drive, m_direction);
+ m_drive->floppy_drive_seek(m_direction);
step_counter--;
}
}
@@ -539,7 +538,7 @@ void wd1770_device::write_track()
//int len = m_buffer[i+4];
int filler = 0xe5; /* IBM and Thomson */
int density = m_density;
- floppy_drive_format_sector(m_drive,side,sector,track,
+ m_drive->floppy_drive_format_sector(side,sector,track,
m_hd,sector,density?1:0,filler);
i += 128; /* at least... */
}
@@ -556,7 +555,7 @@ void wd1770_device::write_track()
selected format.
*/
m_data_count = 0;
- floppy = flopimg_get_image(m_drive);
+ floppy = m_drive->flopimg_get_image();
if (floppy != NULL)
m_data_count = floppy_get_track_size(floppy, m_hd, m_track);
@@ -568,7 +567,7 @@ void wd1770_device::write_track()
m_data_count = wd17xx_dden() ? TRKSIZE_SD : TRKSIZE_DD;
}
- floppy_drive_write_track_data_info_buffer( m_drive, m_hd, (char *)m_buffer, &(m_data_count) );
+ m_drive->floppy_drive_write_track_data_info_buffer( m_hd, (char *)m_buffer, &(m_data_count) );
m_data_offset = 0;
@@ -707,7 +706,7 @@ void wd1770_device::read_track()
/* Determine the track size. We cannot allow different sizes in this
design (see above, write_track). */
m_data_count = 0;
- floppy = flopimg_get_image(m_drive);
+ floppy = m_drive->flopimg_get_image();
if (floppy != NULL)
m_data_count = floppy_get_track_size(floppy, m_hd, m_track);
@@ -719,7 +718,7 @@ void wd1770_device::read_track()
m_data_count = wd17xx_dden() ? TRKSIZE_SD : TRKSIZE_DD;
}
- floppy_drive_read_track_data_info_buffer( m_drive, m_hd, (char *)m_buffer, &(m_data_count) );
+ m_drive->floppy_drive_read_track_data_info_buffer( m_hd, (char *)m_buffer, &(m_data_count) );
m_data_offset = 0;
@@ -736,7 +735,7 @@ void wd1770_device::wd17xx_read_id()
m_status &= ~(STA_2_CRC_ERR | STA_2_REC_N_FND);
/* get next id from disc */
- if (floppy_drive_get_next_id(m_drive, m_hd, &id))
+ if (m_drive->floppy_drive_get_next_id(m_hd, &id))
{
UINT16 crc = 0xffff;
@@ -809,7 +808,7 @@ int wd1770_device::wd17xx_locate_sector()
while (revolution_count!=4)
{
- if (floppy_drive_get_next_id(m_drive, m_hd, &id))
+ if (m_drive->floppy_drive_get_next_id(m_hd, &id))
{
/* compare track */
if (id.C == m_track)
@@ -834,7 +833,7 @@ int wd1770_device::wd17xx_locate_sector()
}
/* index set? */
- if (floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_INDEX))
+ if (m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_INDEX))
{
/* update revolution count */
revolution_count++;
@@ -886,7 +885,7 @@ void wd1770_device::wd17xx_read_sector()
m_data_count = m_sector_length;
/* read data */
- floppy_drive_read_sector_data(m_drive, m_hd, m_sector_data_id, (char *)m_buffer, m_sector_length);
+ m_drive->floppy_drive_read_sector_data(m_hd, m_sector_data_id, (char *)m_buffer, m_sector_length);
wd17xx_timed_data_request();
@@ -936,7 +935,7 @@ void wd1770_device::wd17xx_write_sector()
m_data_count = m_sector_length;
/* write data */
- floppy_drive_write_sector_data(m_drive, m_hd, m_sector_data_id, (char *)m_buffer, m_sector_length, m_write_cmd & 0x01);
+ m_drive->floppy_drive_write_sector_data(m_hd, m_sector_data_id, (char *)m_buffer, m_sector_length, m_write_cmd & 0x01);
}
}
@@ -957,7 +956,7 @@ void wd1770_device::wd17xx_verify_seek()
/* must be found within 5 revolutions otherwise error */
while (revolution_count!=5)
{
- if (floppy_drive_get_next_id(m_drive, m_hd, &id))
+ if (m_drive->floppy_drive_get_next_id( m_hd, &id))
{
/* compare track */
if (id.C == m_track)
@@ -969,7 +968,7 @@ void wd1770_device::wd17xx_verify_seek()
}
/* index set? */
- if (floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_INDEX))
+ if (m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_INDEX))
{
/* update revolution count */
revolution_count++;
@@ -992,7 +991,7 @@ TIMER_CALLBACK_MEMBER( wd1770_device::wd17xx_read_sector_callback )
if (VERBOSE)
logerror("wd179x: Read Sector callback.\n");
- if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY))
+ if (!m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
wd17xx_complete_command(DELAY_NOTREADY);
else
wd17xx_read_sector();
@@ -1008,12 +1007,12 @@ TIMER_CALLBACK_MEMBER( wd1770_device::wd17xx_write_sector_callback )
if (VERBOSE)
logerror("wd179x: Write Sector callback.\n");
- if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY))
+ if (!m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
wd17xx_complete_command(DELAY_NOTREADY);
else
{
/* drive write protected? */
- if (floppy_wpt_r(m_drive) == CLEAR_LINE)
+ if (m_drive->floppy_wpt_r() == CLEAR_LINE)
{
m_status |= STA_2_WRITE_PRO;
@@ -1080,7 +1079,7 @@ void wd1770_device::set_drive(UINT8 drive)
if (m_intf->floppy_drive_tags[drive] != NULL)
{
- m_drive = siblingdevice(m_intf->floppy_drive_tags[drive]);
+ m_drive = siblingdevice<legacy_floppy_image_device>(m_intf->floppy_drive_tags[drive]);
}
}
@@ -1201,7 +1200,7 @@ READ8_MEMBER( wd1770_device::status_r )
else
{
m_status &= ~STA_1_NOT_READY;
- if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY))
+ if (!m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
m_status |= STA_1_NOT_READY;
}
@@ -1216,7 +1215,7 @@ READ8_MEMBER( wd1770_device::status_r )
result |= m_idx << 1;
/* bit 2, track 0 state, inverted */
- result |= !floppy_tk00_r(m_drive) << 2;
+ result |= !m_drive->floppy_tk00_r() << 2;
if (m_command_type==TYPE_I)
{
@@ -1227,7 +1226,7 @@ READ8_MEMBER( wd1770_device::status_r )
}
/* bit 6, write protect, inverted */
- result |= !floppy_wpt_r(m_drive) << 6;
+ result |= !m_drive->floppy_wpt_r() << 6;
}
/* eventually set data request bit */
@@ -1283,10 +1282,10 @@ WRITE8_MEMBER( wd1770_device::command_w )
if (type() == WD1770 || type() == WD1772)
{
m_mo = ASSERT_LINE;
- floppy_mon_w(m_drive, CLEAR_LINE);
+ m_drive->floppy_mon_w(CLEAR_LINE);
}
- floppy_drive_set_ready_state(m_drive, 1,0);
+ m_drive->floppy_drive_set_ready_state(1,0);
if (!BIT(m_interrupt, 3))
{
@@ -1409,14 +1408,14 @@ WRITE8_MEMBER( wd1770_device::command_w )
m_status &= ~STA_2_LOST_DAT;
wd17xx_clear_drq();
- if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY))
+ if (!m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
{
wd17xx_complete_command(DELAY_NOTREADY);
}
else
{
/* drive write protected? */
- if (floppy_wpt_r(m_drive) == CLEAR_LINE)
+ if (m_drive->floppy_wpt_r() == CLEAR_LINE)
{
/* yes */
m_status |= STA_2_WRITE_PRO;
@@ -1452,7 +1451,7 @@ WRITE8_MEMBER( wd1770_device::command_w )
wd17xx_clear_drq();
- if (floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY))
+ if (m_drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY))
wd17xx_read_id();
else
wd17xx_complete_command(DELAY_NOTREADY);
@@ -1519,7 +1518,7 @@ WRITE8_MEMBER( wd1770_device::command_w )
/* update track reg */
m_track += m_direction;
- floppy_drive_seek(m_drive, m_direction);
+ m_drive->floppy_drive_seek(m_direction);
}
/* simulate seek time busy signal */
@@ -1541,7 +1540,7 @@ WRITE8_MEMBER( wd1770_device::command_w )
/* simulate seek time busy signal */
m_busy_count = 0; //((data & FDC_STEP_RATE) + 1);
- floppy_drive_seek(m_drive, m_direction);
+ m_drive->floppy_drive_seek(m_direction);
if (data & FDC_STEP_UPDATE)
m_track += m_direction;
@@ -1564,7 +1563,7 @@ WRITE8_MEMBER( wd1770_device::command_w )
/* simulate seek time busy signal */
m_busy_count = 0; //((data & FDC_STEP_RATE) + 1);
- floppy_drive_seek(m_drive, m_direction);
+ m_drive->floppy_drive_seek(m_direction);
if (data & FDC_STEP_UPDATE)
m_track += m_direction;
@@ -1586,7 +1585,7 @@ WRITE8_MEMBER( wd1770_device::command_w )
m_busy_count = 0; //((data & FDC_STEP_RATE) + 1);
/* for now only allows a single drive to be selected */
- floppy_drive_seek(m_drive, m_direction);
+ m_drive->floppy_drive_seek(m_direction);
if (data & FDC_STEP_UPDATE)
m_track += m_direction;
@@ -2045,14 +2044,14 @@ void wd1770_device::device_reset()
for (i = 0; i < 4; i++)
{
if(m_intf->floppy_drive_tags[i]!=NULL) {
- device_t *img = NULL;
+ legacy_floppy_image_device *img = NULL;
- img = siblingdevice(m_intf->floppy_drive_tags[i]);
+ img = siblingdevice<legacy_floppy_image_device>(m_intf->floppy_drive_tags[i]);
if (img!=NULL) {
- floppy_drive_set_controller(img,this);
- floppy_drive_set_index_pulse_callback(img, wd17xx_index_pulse_callback);
- floppy_drive_set_rpm( img, 300.);
+ img->floppy_drive_set_controller(this);
+ img->floppy_drive_set_index_pulse_callback(wd17xx_index_pulse_callback);
+ img->floppy_drive_set_rpm( 300.);
}
}
}
diff --git a/src/emu/machine/wd17xx.h b/src/emu/machine/wd17xx.h
index 0362e333193..beb2f7a710a 100644
--- a/src/emu/machine/wd17xx.h
+++ b/src/emu/machine/wd17xx.h
@@ -10,6 +10,8 @@
#ifndef __WD17XX_H__
#define __WD17XX_H__
+#include "imagedev/flopdrv.h"
+
/***************************************************************************
TYPE DEFINITIONS
@@ -165,7 +167,7 @@ protected:
emu_timer *m_timer_cmd, *m_timer_data, *m_timer_rs, *m_timer_ws;
/* this is the drive currently selected */
- device_t *m_drive;
+ legacy_floppy_image_device *m_drive;
/* this is the head currently selected */
UINT8 m_hd;
diff --git a/src/mess/drivers/apf.c b/src/mess/drivers/apf.c
index 60d92fdceeb..eecaa789820 100644
--- a/src/mess/drivers/apf.c
+++ b/src/mess/drivers/apf.c
@@ -260,9 +260,9 @@ WRITE8_MEMBER( apf_state::apf_dischw_w)
m_fdc->set_drive(drive);
floppy_image_legacy *floppy;
- floppy = flopimg_get_image(floppy_get_device(machine(), drive));
- floppy_mon_w(floppy_get_device(machine(), drive), (floppy != NULL) ? 0 : 1);
- floppy_drive_set_ready_state(floppy_get_device(machine(), drive), (floppy != NULL) ? 1 : 0,0);
+ floppy = floppy_get_device(machine(), drive)->flopimg_get_image();
+ floppy_get_device(machine(), drive)->floppy_mon_w((floppy != NULL) ? 0 : 1);
+ floppy_get_device(machine(), drive)->floppy_drive_set_ready_state((floppy != NULL) ? 1 : 0,0);
logerror("disc w %04x %04x\n",offset,data);
diff --git a/src/mess/drivers/fm7.c b/src/mess/drivers/fm7.c
index 96ea5e47b79..fd694d2b626 100644
--- a/src/mess/drivers/fm7.c
+++ b/src/mess/drivers/fm7.c
@@ -492,8 +492,8 @@ WRITE8_MEMBER(fm7_state::fm7_fdc_w)
else
{
m_fdc->set_drive(data & 0x03);
- floppy_mon_w(floppy_get_device(machine(), data & 0x03), !BIT(data, 7));
- floppy_drive_set_ready_state(floppy_get_device(machine(), data & 0x03), data & 0x80,0);
+ floppy_get_device(machine(), data & 0x03)->floppy_mon_w(!BIT(data, 7));
+ floppy_get_device(machine(), data & 0x03)->floppy_drive_set_ready_state(data & 0x80,0);
logerror("FDC: wrote %02x to 0x%04x (drive)\n",data,offset+0xfd18);
}
break;
diff --git a/src/mess/drivers/mbc200.c b/src/mess/drivers/mbc200.c
index b541abbd996..707dab8f473 100644
--- a/src/mess/drivers/mbc200.c
+++ b/src/mess/drivers/mbc200.c
@@ -127,10 +127,10 @@ INPUT_PORTS_END
void mbc200_state::machine_start()
{
- floppy_mon_w(m_floppy0, CLEAR_LINE);
- floppy_mon_w(m_floppy1, CLEAR_LINE);
- floppy_drive_set_ready_state(m_floppy0, 1, 1);
- floppy_drive_set_ready_state(m_floppy1, 1, 1);
+ m_floppy0->floppy_mon_w(CLEAR_LINE);
+ m_floppy1->floppy_mon_w(CLEAR_LINE);
+ m_floppy0->floppy_drive_set_ready_state(1, 1);
+ m_floppy1->floppy_drive_set_ready_state(1, 1);
}
MC6845_UPDATE_ROW( mbc200_update_row )
diff --git a/src/mess/drivers/ms0515.c b/src/mess/drivers/ms0515.c
index 7de11d248f9..0317a9e7797 100644
--- a/src/mess/drivers/ms0515.c
+++ b/src/mess/drivers/ms0515.c
@@ -126,7 +126,7 @@ void ms0515_state::machine_reset()
m_video_ram = ram + 0000000 + 0340000;
m_blink = 0;
- floppy_mon_w(machine().device(FLOPPY_0), 0); // turn it on
+ machine().device<legacy_floppy_image_device>(FLOPPY_0)->floppy_mon_w(0); // turn it on
}
/* Input ports */
diff --git a/src/mess/drivers/myb3k.c b/src/mess/drivers/myb3k.c
index ba169605f98..b787756d52b 100644
--- a/src/mess/drivers/myb3k.c
+++ b/src/mess/drivers/myb3k.c
@@ -127,8 +127,8 @@ WRITE8_MEMBER( myb3k_state::myb3k_fdc_output_w )
{
/* TODO: complete guesswork! (it just does a 0x24 -> 0x20 in there) */
m_fdc->set_drive(data & 3);
- floppy_mon_w(floppy_get_device(machine(), data & 3), !(data & 4) ? 1: 0);
- floppy_drive_set_ready_state(floppy_get_device(machine(), data & 3), data & 0x4,0);
+ floppy_get_device(machine(), data & 3)->floppy_mon_w(!(data & 4) ? 1: 0);
+ floppy_get_device(machine(), data & 3)->floppy_drive_set_ready_state(data & 0x4,0);
//m_fdc->set_side((data & 0x10)>>4);
}
diff --git a/src/mess/drivers/mz2000.c b/src/mess/drivers/mz2000.c
index b9305d6013d..dbb7265127c 100644
--- a/src/mess/drivers/mz2000.c
+++ b/src/mess/drivers/mz2000.c
@@ -360,8 +360,8 @@ WRITE8_MEMBER(mz2000_state::mz2000_fdc_w)
{
case 0xdc:
m_mb8877a->set_drive(data & 3);
- floppy_mon_w(floppy_get_device(machine(), data & 3), (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
- floppy_drive_set_ready_state(floppy_get_device(machine(), data & 3), 1,0);
+ floppy_get_device(machine(), data & 3)->floppy_mon_w((data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
+ floppy_get_device(machine(), data & 3)->floppy_drive_set_ready_state(1,0);
break;
case 0xdd:
m_mb8877a->set_side((data & 1));
diff --git a/src/mess/drivers/mz2500.c b/src/mess/drivers/mz2500.c
index 0fcff111998..96168b24fa5 100644
--- a/src/mess/drivers/mz2500.c
+++ b/src/mess/drivers/mz2500.c
@@ -1190,8 +1190,8 @@ WRITE8_MEMBER(mz2500_state::mz2500_fdc_w)
{
case 0xdc:
fdc->set_drive(data & 3);
- floppy_mon_w(floppy_get_device(machine(), data & 3), (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
- floppy_drive_set_ready_state(floppy_get_device(machine(), data & 3), 1,0);
+ floppy_get_device(machine(), data & 3)->floppy_mon_w((data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
+ floppy_get_device(machine(), data & 3)->floppy_drive_set_ready_state(1,0);
break;
case 0xdd:
fdc->set_side((data & 1));
diff --git a/src/mess/drivers/rainbow.c b/src/mess/drivers/rainbow.c
index f2f0d4fc492..a618ec3b545 100644
--- a/src/mess/drivers/rainbow.c
+++ b/src/mess/drivers/rainbow.c
@@ -326,7 +326,7 @@ private:
virtual void machine_reset();
int m_unit;
- device_t *m_image[4];
+ legacy_floppy_image_device *m_image[4];
int m_irq_high;
UINT32 m_irq_mask;
@@ -335,10 +335,10 @@ private:
void rainbow_state::machine_start()
{
- m_image[0] = subdevice(FLOPPY_0);
- m_image[1] = subdevice(FLOPPY_1);
- m_image[2] = subdevice(FLOPPY_2);
- m_image[3] = subdevice(FLOPPY_3);
+ m_image[0] = subdevice<legacy_floppy_image_device>(FLOPPY_0);
+ m_image[1] = subdevice<legacy_floppy_image_device>(FLOPPY_1);
+ m_image[2] = subdevice<legacy_floppy_image_device>(FLOPPY_2);
+ m_image[3] = subdevice<legacy_floppy_image_device>(FLOPPY_3);
COLD_BOOT = 1;
@@ -863,9 +863,9 @@ D0 : ZFLIP L: (read from the diagnostic control register of Z80A)
NOTES: ALL LOW ACTIVE - EXCEPT TR00
*/
// * TRACK 00 * signal for current drive
- int tk00 = ( floppy_tk00_r( m_image[m_unit] ) == CLEAR_LINE ) ? 0x20 : 0x00;
+ int tk00 = ( m_image[m_unit]->floppy_tk00_r() == CLEAR_LINE ) ? 0x20 : 0x00;
- int fdc_ready = floppy_drive_get_flag_state( m_image[m_unit] , FLOPPY_DRIVE_READY);
+ int fdc_ready = m_image[m_unit]->floppy_drive_get_flag_state( FLOPPY_DRIVE_READY);
int data=( 0x80 | // (STEP L)
// ( (fdc_write_gate) ) |
@@ -958,7 +958,7 @@ WRITE8_MEMBER(rainbow_state::z80_diskcontrol_w)
int selected_drive = 255;
- if (flopimg_get_image( floppy_get_device( machine(), drive ) ) != NULL)
+ if (floppy_get_device( machine(), drive )->flopimg_get_image() != NULL)
{ selected_drive = drive;
m_fdc->set_drive(selected_drive);
}
@@ -987,10 +987,10 @@ WRITE8_MEMBER(rainbow_state::z80_diskcontrol_w)
{
// Although 1773 does not feature 'motor on' this statement is required:
// CLEAR_LINE = turn motor on -
- floppy_mon_w(m_image[f_num], (f_num == selected_drive) ? CLEAR_LINE : ASSERT_LINE);
+ m_image[f_num]->floppy_mon_w((f_num == selected_drive) ? CLEAR_LINE : ASSERT_LINE);
// Parameters: DRIVE, STATE, FLAG
- floppy_drive_set_ready_state( m_image[f_num],
+ m_image[f_num]->floppy_drive_set_ready_state(
(f_num == selected_drive) ? 1 : 0,
(f_num == selected_drive) ? force_ready : 0
);
diff --git a/src/mess/drivers/smc777.c b/src/mess/drivers/smc777.c
index 624219c8e08..a2d9cb76558 100644
--- a/src/mess/drivers/smc777.c
+++ b/src/mess/drivers/smc777.c
@@ -389,9 +389,9 @@ void smc777_state::check_floppy_inserted()
/* FIXME: floppy drive 1 doesn't work? */
for(f_num=0;f_num<2;f_num++)
{
- floppy = flopimg_get_image(floppy_get_device(machine(), f_num));
- floppy_mon_w(floppy_get_device(machine(), f_num), (floppy != NULL) ? 0 : 1);
- floppy_drive_set_ready_state(floppy_get_device(machine(), f_num), (floppy != NULL) ? 1 : 0,0);
+ floppy = floppy_get_device(machine(), f_num)->flopimg_get_image();
+ floppy_get_device(machine(), f_num)->floppy_mon_w((floppy != NULL) ? 0 : 1);
+ floppy_get_device(machine(), f_num)->floppy_drive_set_ready_state((floppy != NULL) ? 1 : 0,0);
}
}
diff --git a/src/mess/drivers/thomson.c b/src/mess/drivers/thomson.c
index edaef42e427..2ddad236297 100644
--- a/src/mess/drivers/thomson.c
+++ b/src/mess/drivers/thomson.c
@@ -566,22 +566,22 @@ INPUT_PORTS_END
WRITE_LINE_MEMBER( thomson_state::fdc_index_0_w )
{
- thomson_index_callback(machine().device(FLOPPY_0), state);
+ thomson_index_callback(machine().device<legacy_floppy_image_device>(FLOPPY_0), state);
}
WRITE_LINE_MEMBER( thomson_state::fdc_index_1_w )
{
- thomson_index_callback(machine().device(FLOPPY_1), state);
+ thomson_index_callback(machine().device<legacy_floppy_image_device>(FLOPPY_1), state);
}
WRITE_LINE_MEMBER( thomson_state::fdc_index_2_w )
{
- thomson_index_callback(machine().device(FLOPPY_2), state);
+ thomson_index_callback(machine().device<legacy_floppy_image_device>(FLOPPY_2), state);
}
WRITE_LINE_MEMBER( thomson_state::fdc_index_3_w )
{
- thomson_index_callback(machine().device(FLOPPY_3), state);
+ thomson_index_callback(machine().device<legacy_floppy_image_device>(FLOPPY_3), state);
}
static const floppy_interface thomson_floppy_interface_0 =
diff --git a/src/mess/drivers/unixpc.c b/src/mess/drivers/unixpc.c
index 50467ed9a0e..9e5e8dfb6a5 100644
--- a/src/mess/drivers/unixpc.c
+++ b/src/mess/drivers/unixpc.c
@@ -117,7 +117,7 @@ WRITE16_MEMBER( unixpc_state::disk_control_w )
{
logerror("disk_control_w: %04x\n", data);
- floppy_mon_w(m_floppy, !BIT(data, 5));
+ m_floppy->floppy_mon_w(!BIT(data, 5));
// bit 6 = floppy selected / not selected
m_wd2797->set_drive(0);
diff --git a/src/mess/drivers/vtech1.c b/src/mess/drivers/vtech1.c
index 5bb0f676869..7c0d10b3691 100644
--- a/src/mess/drivers/vtech1.c
+++ b/src/mess/drivers/vtech1.c
@@ -669,7 +669,7 @@ DRIVER_INIT_MEMBER(vtech1_state,vtech1)
for(id=0;id<2;id++)
{
- floppy_install_load_proc(floppy_get_device(machine(), id), vtech1_load_proc);
+ floppy_get_device(machine(), id)->floppy_install_load_proc(vtech1_load_proc);
}
}
diff --git a/src/mess/drivers/x1.c b/src/mess/drivers/x1.c
index d01194ed654..810820f8d3f 100644
--- a/src/mess/drivers/x1.c
+++ b/src/mess/drivers/x1.c
@@ -1037,8 +1037,8 @@ WRITE8_MEMBER( x1_state::x1_fdc_w )
break;
case 0x0ffc:
m_fdc->set_drive(data & 3);
- floppy_mon_w(floppy_get_device(machine(), data & 3), !BIT(data, 7));
- floppy_drive_set_ready_state(floppy_get_device(machine(), data & 3), data & 0x80,0);
+ floppy_get_device(machine(), data & 3)->floppy_mon_w(!BIT(data, 7));
+ floppy_get_device(machine(), data & 3)->floppy_drive_set_ready_state(data & 0x80,0);
m_fdc->set_side(BIT(data, 4));
break;
case 0x0ffd:
diff --git a/src/mess/drivers/z100.c b/src/mess/drivers/z100.c
index ed97b353bbd..706e38c813f 100644
--- a/src/mess/drivers/z100.c
+++ b/src/mess/drivers/z100.c
@@ -380,8 +380,8 @@ WRITE8_MEMBER( z100_state::z207_fdc_w )
m_z207_cur_drive = data & 3;
break;
case 5: // aux control
- floppy_mon_w(floppy_get_device(machine(), m_z207_cur_drive), !BIT(data, 1));
- floppy_drive_set_ready_state(floppy_get_device(machine(), m_z207_cur_drive), data & 2,0);
+ floppy_get_device(machine(), m_z207_cur_drive)->floppy_mon_w(!BIT(data, 1));
+ floppy_get_device(machine(), m_z207_cur_drive)->floppy_drive_set_ready_state(data & 2,0);
break;
}
diff --git a/src/mess/includes/thomson.h b/src/mess/includes/thomson.h
index 17cff65c7ec..92966ae125a 100644
--- a/src/mess/includes/thomson.h
+++ b/src/mess/includes/thomson.h
@@ -304,7 +304,7 @@ public:
WRITE_LINE_MEMBER( fdc_index_1_w );
WRITE_LINE_MEMBER( fdc_index_2_w );
WRITE_LINE_MEMBER( fdc_index_3_w );
- void thomson_index_callback(device_t *device, int state);
+ void thomson_index_callback(legacy_floppy_image_device *device, int state);
DECLARE_PALETTE_INIT(thom);
optional_device<mc6854_device> m_mc6854;
@@ -519,26 +519,26 @@ protected:
unsigned to7_lightpen_gpl( int decx, int decy );
int thom_floppy_make_addr( chrn_id id, UINT8* dst, int sector_size );
- int thom_floppy_make_sector( device_t* img, chrn_id id, UINT8* dst, int sector_size );
- int thom_floppy_make_track( device_t* img, UINT8* dst, int sector_size, int side );
+ int thom_floppy_make_sector( legacy_floppy_image_device* img, chrn_id id, UINT8* dst, int sector_size );
+ int thom_floppy_make_track( legacy_floppy_image_device* img, UINT8* dst, int sector_size, int side );
int thom_qdd_make_addr( int sector, UINT8* dst );
- int thom_qdd_make_sector( device_t* img, int sector, UINT8* dst );
- int thom_qdd_make_disk ( device_t* img, UINT8* dst );
+ int thom_qdd_make_sector( legacy_floppy_image_device* img, int sector, UINT8* dst );
+ int thom_qdd_make_disk ( legacy_floppy_image_device* img, UINT8* dst );
void to7_5p14_reset();
void to7_5p14_init();
- void to7_5p14_index_pulse_callback( device_t *controller,device_t *image, int state );
+ void to7_5p14_index_pulse_callback( device_t *controller,legacy_floppy_image_device *image, int state );
void to7_5p14sd_reset();
void to7_5p14sd_init();
- void to7_qdd_index_pulse_cb( device_t *controller,device_t *image, int state );
- device_t * to7_qdd_image();
+ void to7_qdd_index_pulse_cb( device_t *controller,legacy_floppy_image_device *image, int state );
+ legacy_floppy_image_device * to7_qdd_image();
void to7_qdd_stat_update();
UINT8 to7_qdd_read_byte();
void to7_qdd_write_byte( UINT8 data );
void to7_qdd_reset();
void to7_qdd_init();
- device_t * thmfc_floppy_image();
- int thmfc_floppy_is_qdd( device_image_interface *image );
- void thmfc_floppy_index_pulse_cb( device_t *controller,device_t *image, int state );
+ legacy_floppy_image_device * thmfc_floppy_image();
+ int thmfc_floppy_is_qdd( legacy_floppy_image_device *image );
+ void thmfc_floppy_index_pulse_cb( device_t *controller,legacy_floppy_image_device *image, int state );
int thmfc_floppy_find_sector( chrn_id* dst );
void thmfc_floppy_cmd_complete();
UINT8 thmfc_floppy_read_byte();
diff --git a/src/mess/machine/appldriv.c b/src/mess/machine/appldriv.c
index c326741ade5..16038e61422 100644
--- a/src/mess/machine/appldriv.c
+++ b/src/mess/machine/appldriv.c
@@ -27,13 +27,13 @@ INLINE apple525_floppy_image_device *get_device(device_t *device)
static int apple525_enable_mask = 1;
-device_t *apple525_get_subdevice(device_t *device, int drive)
+legacy_floppy_image_device *apple525_get_subdevice(device_t *device, int drive)
{
switch(drive) {
- case 0 : return device->subdevice(PARENT_FLOPPY_0);
- case 1 : return device->subdevice(PARENT_FLOPPY_1);
- case 2 : return device->subdevice(PARENT_FLOPPY_2);
- case 3 : return device->subdevice(PARENT_FLOPPY_3);
+ case 0 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_0);
+ case 1 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_1);
+ case 2 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_2);
+ case 3 : return device->subdevice<legacy_floppy_image_device>(PARENT_FLOPPY_3);
}
return NULL;
}
@@ -43,8 +43,8 @@ device_t *apple525_get_device_by_type(device_t *device, int ftype, int drive)
int i;
int cnt = 0;
for (i=0;i<4;i++) {
- device_t *disk = apple525_get_subdevice(device, i);
- if (floppy_get_drive_type(disk)==ftype) {
+ legacy_floppy_image_device *disk = apple525_get_subdevice(device, i);
+ if (disk->floppy_get_drive_type()==ftype) {
if (cnt==drive) {
return disk;
}
@@ -69,7 +69,7 @@ static void apple525_load_current_track(device_t *image)
disk = get_device(image);
len = sizeof(disk->track_data);
- floppy_drive_read_track_data_info_buffer(image, 0, disk->track_data, &len);
+ disk->floppy_drive_read_track_data_info_buffer(0, disk->track_data, &len);
disk->track_loaded = 1;
disk->track_dirty = 0;
}
@@ -84,14 +84,14 @@ static void apple525_save_current_track(device_t *image, int unload)
if (disk->track_dirty)
{
len = sizeof(disk->track_data);
- floppy_drive_write_track_data_info_buffer(image, 0, disk->track_data, &len);
+ disk->floppy_drive_write_track_data_info_buffer(0, disk->track_data, &len);
disk->track_dirty = 0;
}
if (unload)
disk->track_loaded = 0;
}
-static void apple525_seek_disk(device_t *img, signed int step)
+static void apple525_seek_disk(apple525_floppy_image_device *img, signed int step)
{
int track;
int pseudo_track;
@@ -101,7 +101,7 @@ static void apple525_seek_disk(device_t *img, signed int step)
apple525_save_current_track(img, FALSE);
- track = floppy_drive_get_current_track(img);
+ track = img->floppy_drive_get_current_track();
pseudo_track = (track * 2) + disk->tween_tracks;
pseudo_track += step;
@@ -112,7 +112,7 @@ static void apple525_seek_disk(device_t *img, signed int step)
if (pseudo_track/2 != track)
{
- floppy_drive_seek(img, pseudo_track/2 - floppy_drive_get_current_track(img));
+ img->floppy_drive_seek(pseudo_track/2 - img->floppy_drive_get_current_track());
disk->track_loaded = 0;
}
@@ -144,7 +144,7 @@ static void apple525_disk_set_lines(device_t *device,device_t *image, UINT8 new_
case 8: phase = 3; break;
}
- phase -= floppy_drive_get_current_track(image) * 2;
+ phase -= cur_disk->floppy_drive_get_current_track() * 2;
if (cur_disk->tween_tracks)
phase--;
phase %= 4;
@@ -152,10 +152,10 @@ static void apple525_disk_set_lines(device_t *device,device_t *image, UINT8 new_
switch(phase)
{
case 1:
- apple525_seek_disk(image, +1);
+ apple525_seek_disk(cur_disk, +1);
break;
case 3:
- apple525_seek_disk(image, -1);
+ apple525_seek_disk(cur_disk, -1);
break;
}
}
@@ -164,10 +164,10 @@ static void apple525_disk_set_lines(device_t *device,device_t *image, UINT8 new_
int apple525_get_count(device_t *device)
{
int cnt = 0;
- if ((device->subdevice("^"FLOPPY_0)!=NULL) && (floppy_get_drive_type(device->subdevice("^"FLOPPY_0)) == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_0))!=NULL)) cnt++;
- if ((device->subdevice("^"FLOPPY_1)!=NULL) && (floppy_get_drive_type(device->subdevice("^"FLOPPY_1)) == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_1))!=NULL)) cnt++;
- if ((device->subdevice("^"FLOPPY_2)!=NULL) && (floppy_get_drive_type(device->subdevice("^"FLOPPY_2)) == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_2))!=NULL)) cnt++;
- if ((device->subdevice("^"FLOPPY_3)!=NULL) && (floppy_get_drive_type(device->subdevice("^"FLOPPY_3)) == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_3))!=NULL)) cnt++;
+ if ((device->subdevice("^"FLOPPY_0)!=NULL) && (device->subdevice<legacy_floppy_image_device>("^"FLOPPY_0)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_0))!=NULL)) cnt++;
+ if ((device->subdevice("^"FLOPPY_1)!=NULL) && (device->subdevice<legacy_floppy_image_device>("^"FLOPPY_1)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_1))!=NULL)) cnt++;
+ if ((device->subdevice("^"FLOPPY_2)!=NULL) && (device->subdevice<legacy_floppy_image_device>("^"FLOPPY_2)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_2))!=NULL)) cnt++;
+ if ((device->subdevice("^"FLOPPY_3)!=NULL) && (device->subdevice<legacy_floppy_image_device>("^"FLOPPY_3)->floppy_get_drive_type() == FLOPPY_TYPE_APPLE) && (get_device(device->subdevice(PARENT_FLOPPY_3))!=NULL)) cnt++;
return cnt;
}
@@ -307,7 +307,7 @@ apple525_floppy_image_device::apple525_floppy_image_device(const machine_config
void apple525_floppy_image_device::device_start()
{
legacy_floppy_image_device::device_start();
- floppy_set_type(this,FLOPPY_TYPE_APPLE);
+ floppy_set_type(FLOPPY_TYPE_APPLE);
state = 0;
tween_tracks = 0;
@@ -321,8 +321,8 @@ void apple525_floppy_image_device::device_start()
bool apple525_floppy_image_device::call_load()
{
int result = legacy_floppy_image_device::call_load();
- floppy_drive_seek(*this, -999);
- floppy_drive_seek(*this, +35/2);
+ floppy_drive_seek(-999);
+ floppy_drive_seek(+35/2);
return result;
}
diff --git a/src/mess/machine/atarifdc.c b/src/mess/machine/atarifdc.c
index 1cdc98e08c4..4e2cee018fb 100644
--- a/src/mess/machine/atarifdc.c
+++ b/src/mess/machine/atarifdc.c
@@ -16,7 +16,6 @@
#include "atarifdc.h"
#include "sound/pokey.h"
#include "machine/6821pia.h"
-#include "imagedev/flopdrv.h"
#include "formats/atari_dsk.h"
#define VERBOSE_SERIAL 0
@@ -746,13 +745,13 @@ static MACHINE_CONFIG_FRAGMENT( atari_fdc )
MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(atari_floppy_interface)
MACHINE_CONFIG_END
-device_t *atari_fdc_device::atari_floppy_get_device_child(int drive)
+legacy_floppy_image_device *atari_fdc_device::atari_floppy_get_device_child(int drive)
{
switch(drive) {
- case 0 : return subdevice(FLOPPY_0);
- case 1 : return subdevice(FLOPPY_1);
- case 2 : return subdevice(FLOPPY_2);
- case 3 : return subdevice(FLOPPY_3);
+ case 0 : return subdevice<legacy_floppy_image_device>(FLOPPY_0);
+ case 1 : return subdevice<legacy_floppy_image_device>(FLOPPY_1);
+ case 2 : return subdevice<legacy_floppy_image_device>(FLOPPY_2);
+ case 3 : return subdevice<legacy_floppy_image_device>(FLOPPY_3);
}
return NULL;
}
@@ -786,7 +785,7 @@ void atari_fdc_device::device_start()
for(id=0;id<4;id++)
{
- floppy_install_load_proc(atari_floppy_get_device_child(id), _atari_load_proc);
+ atari_floppy_get_device_child(id)->floppy_install_load_proc(_atari_load_proc);
}
}
diff --git a/src/mess/machine/atarifdc.h b/src/mess/machine/atarifdc.h
index 6eb132dabbc..a6bb687de25 100644
--- a/src/mess/machine/atarifdc.h
+++ b/src/mess/machine/atarifdc.h
@@ -6,6 +6,8 @@
#ifndef _ATARIFDC_H
#define _ATARIFDC_H
+#include "imagedev/flopdrv.h"
+
class atari_fdc_device : public device_t
{
public:
@@ -28,7 +30,7 @@ private:
void add_serin(UINT8 data, int with_checksum);
void a800_serial_command();
void a800_serial_write();
- device_t *atari_floppy_get_device_child(int drive);
+ legacy_floppy_image_device *atari_floppy_get_device_child(int drive);
struct atari_drive
{
diff --git a/src/mess/machine/beta.c b/src/mess/machine/beta.c
index aa7dd8cf726..7f2beec1194 100644
--- a/src/mess/machine/beta.c
+++ b/src/mess/machine/beta.c
@@ -158,9 +158,9 @@ WRITE8_MEMBER(beta_disk_device::param_w)
}
// bit 3 connected to pin 23 "HRDY" of FDC
// TEMP HACK, FDD motor and RDY FDC pin controlled by HLD pin of FDC
- device_t *flop = subdevice(beta_wd17xx_interface.floppy_drive_tags[data & 3]);
- floppy_mon_w(flop, CLEAR_LINE);
- floppy_drive_set_ready_state(flop, 1, 0);
+ legacy_floppy_image_device *flop = subdevice<legacy_floppy_image_device>(beta_wd17xx_interface.floppy_drive_tags[data & 3]);
+ flop->floppy_mon_w(CLEAR_LINE);
+ flop->floppy_drive_set_ready_state(1, 0);
}
}
diff --git a/src/mess/machine/concept_exp.c b/src/mess/machine/concept_exp.c
index 5c9f506d380..b861bc3ccd0 100644
--- a/src/mess/machine/concept_exp.c
+++ b/src/mess/machine/concept_exp.c
@@ -243,7 +243,7 @@ WRITE8_MEMBER(concept_fdc_device::reg_w)
// floppy_drive_set_motor_state(floppy_get_device(machine(), current_drive), (data & LC_MOTOROF_mask) == 0 ? 1 : 0);
/*flp_8in = (data & LC_FLP8IN_mask) != 0;*/
m_wd179x->dden_w(BIT(data, 7));
- floppy_drive_set_ready_state(floppy_get_device(machine(), current_drive), 1, 0);
+ floppy_get_device(machine(), current_drive)->floppy_drive_set_ready_state(1, 0);
break;
case 8: // FDC COMMAMD REG
diff --git a/src/mess/machine/hec2hrp.c b/src/mess/machine/hec2hrp.c
index 542d43b20a8..cdc22af2ba1 100644
--- a/src/mess/machine/hec2hrp.c
+++ b/src/mess/machine/hec2hrp.c
@@ -107,11 +107,11 @@ void hec2hrp_state::hector_minidisc_init()
fdc->dden_w(1);// density select => always 1 (0 ?a plante !)
/* FDC Motor Control - Bit 0/1 defines the state of the FDD 0/1 motor */
- floppy_mon_w(floppy_get_device(machine(), 0), 0); // Moteur floppy A:
- //floppy_mon_w(floppy_get_device(space.machine(), 1), BIT(data, 7)); // Moteur floppy B:, not implanted on the real machine
+ floppy_get_device(machine(), 0)->floppy_mon_w( 0); // Moteur floppy A:
+ //floppy_get_device(machine(), 1)->floppy_mon_w(BIT(data, 7)); // Moteur floppy B:, not implanted on the real machine
//Set the drive ready !
- floppy_drive_set_ready_state(floppy_get_device(machine(), 0), FLOPPY_DRIVE_READY, 0);// Disc 0 ready !
+ floppy_get_device(machine(), 0)->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 0);// Disc 0 ready !
}
diff --git a/src/mess/machine/micropolis.c b/src/mess/machine/micropolis.c
index c3538bdcab6..93172ad6485 100644
--- a/src/mess/machine/micropolis.c
+++ b/src/mess/machine/micropolis.c
@@ -28,7 +28,6 @@ BE02 and BE03 - read data, write data
#include "emu.h"
-#include "imagedev/flopdrv.h"
#include "machine/micropolis.h"
@@ -162,15 +161,15 @@ void micropolis_device::device_reset()
{
if(m_floppy_drive_tags[i])
{
- device_t *img = NULL;
+ legacy_floppy_image_device *img = NULL;
- img = siblingdevice(m_floppy_drive_tags[i]);
+ img = siblingdevice<legacy_floppy_image_device>(m_floppy_drive_tags[i]);
if (img)
{
- floppy_drive_set_controller(img, this);
- //floppy_drive_set_index_pulse_callback(img, wd17xx_index_pulse_callback);
- floppy_drive_set_rpm( img, 300.);
+ img->floppy_drive_set_controller(this);
+ //img->floppy_drive_set_index_pulse_callback( wd17xx_index_pulse_callback);
+ img->floppy_drive_set_rpm( 300.);
}
}
}
@@ -197,7 +196,7 @@ void micropolis_device::read_sector()
m_data_count = m_sector_length;
/* read data */
- floppy_drive_read_sector_data(m_drive, 0, m_sector, (char *)m_buffer, m_sector_length);
+ m_drive->floppy_drive_read_sector_data(0, m_sector, (char *)m_buffer, m_sector_length);
}
@@ -213,7 +212,7 @@ void micropolis_device::write_sector()
m_data_count = m_sector_length;
/* write data */
- floppy_drive_write_sector_data(m_drive, 0, m_sector, (char *)m_buffer, m_sector_length, m_write_cmd & 0x01);
+ m_drive->floppy_drive_write_sector_data(0, m_sector, (char *)m_buffer, m_sector_length, m_write_cmd & 0x01);
#endif
}
@@ -231,7 +230,7 @@ void micropolis_device::set_drive(UINT8 drive)
logerror("micropolis_set_drive: $%02x\n", drive);
if (m_floppy_drive_tags[drive])
- m_drive = siblingdevice(m_floppy_drive_tags[drive]);
+ m_drive = siblingdevice<legacy_floppy_image_device>(m_floppy_drive_tags[drive]);
}
@@ -287,9 +286,9 @@ Command (bits 5,6,7) Options (bits 0,1,2,3,4)
{
case 1:
m_drive_num = data & 3;
- floppy_mon_w(m_drive, 1); // turn off the old drive
+ m_drive->floppy_mon_w(1); // turn off the old drive
set_drive(m_drive_num); // select new drive
- floppy_mon_w(m_drive, 0); // turn it on
+ m_drive->floppy_mon_w(0); // turn it on
break;
case 2: // not emulated, not used in sorcerer
break;
@@ -323,13 +322,13 @@ Command (bits 5,6,7) Options (bits 0,1,2,3,4)
if (BIT(data, 5))
m_status |= STAT_READY;
- floppy_drive_set_ready_state(m_drive, 1,0);
+ m_drive->floppy_drive_set_ready_state(1,0);
if (!m_track)
m_status |= STAT_TRACK0;
- floppy_drive_seek(m_drive, direction);
+ m_drive->floppy_drive_seek(direction);
}
diff --git a/src/mess/machine/micropolis.h b/src/mess/machine/micropolis.h
index 60b7ede301d..8ac0325280f 100644
--- a/src/mess/machine/micropolis.h
+++ b/src/mess/machine/micropolis.h
@@ -11,6 +11,7 @@
#define __MICROPOLIS_H__
#include "devcb.h"
+#include "imagedev/flopdrv.h"
/***************************************************************************
@@ -88,7 +89,7 @@ private:
UINT32 m_sector_length; /* sector length (byte) */
/* this is the drive currently selected */
- device_t *m_drive;
+ legacy_floppy_image_device *m_drive;
void read_sector();
void write_sector();
diff --git a/src/mess/machine/nes.c b/src/mess/machine/nes.c
index a74c2db4872..eb66a84fc6f 100644
--- a/src/mess/machine/nes.c
+++ b/src/mess/machine/nes.c
@@ -962,8 +962,8 @@ DRIVER_INIT_MEMBER(nes_state,famicom)
m_fds_ram = auto_alloc_array_clear(machine(), UINT8, 0x8000);
save_pointer(NAME(m_fds_ram), 0x8000);
- floppy_install_load_proc(floppy_get_device(machine(), 0), nes_load_proc);
- floppy_install_unload_proc(floppy_get_device(machine(), 0), nes_unload_proc);
+ floppy_get_device(machine(), 0)->floppy_install_load_proc(nes_load_proc);
+ floppy_get_device(machine(), 0)->floppy_install_unload_proc(nes_unload_proc);
// setup alt input handlers for additional FC input devices
address_space &space = machine().device<cpu_device>("maincpu")->space(AS_PROGRAM);
diff --git a/src/mess/machine/osborne1.c b/src/mess/machine/osborne1.c
index 27237a81bbb..999fc900bd2 100644
--- a/src/mess/machine/osborne1.c
+++ b/src/mess/machine/osborne1.c
@@ -429,7 +429,7 @@ void osborne1_state::machine_reset()
memset( m_ram->pointer() + 0x10000, 0xFF, 0x1000 );
for(drive=0;drive<2;drive++)
- floppy_install_load_proc(floppy_get_device(machine(), drive), osborne1_load_proc);
+ floppy_get_device(machine(), drive)->floppy_install_load_proc(osborne1_load_proc);
space.set_direct_update_handler(direct_update_delegate(FUNC(osborne1_state::osborne1_opbase), this));
}
diff --git a/src/mess/machine/partner.c b/src/mess/machine/partner.c
index bd520ae5e23..d61bc9b3bef 100644
--- a/src/mess/machine/partner.c
+++ b/src/mess/machine/partner.c
@@ -100,17 +100,17 @@ WRITE8_MEMBER(partner_state::partner_floppy_w){
default : m_fdc->data_w(space, 0,data);break;
}
} else {
- floppy_mon_w(floppy_get_device(machine(), 0), 1);
- floppy_mon_w(floppy_get_device(machine(), 1), 1);
+ floppy_get_device(machine(), 0)->floppy_mon_w(1);
+ floppy_get_device(machine(), 1)->floppy_mon_w(1);
if (((data >> 6) & 1)==1) {
m_fdc->set_drive(0);
- floppy_mon_w(floppy_get_device(machine(), 0), 0);
- floppy_drive_set_ready_state(floppy_get_device(machine(), 0), 1, 1);
+ floppy_get_device(machine(), 0)->floppy_mon_w(0);
+ floppy_get_device(machine(), 0)->floppy_drive_set_ready_state(1, 1);
}
if (((data >> 3) & 1)==1) {
m_fdc->set_drive(1);
- floppy_mon_w(floppy_get_device(machine(), 1), 0);
- floppy_drive_set_ready_state(floppy_get_device(machine(), 1), 1, 1);
+ floppy_get_device(machine(), 1)->floppy_mon_w(0);
+ floppy_get_device(machine(), 1)->floppy_drive_set_ready_state(1, 1);
}
m_fdc->set_side(data >> 7);
}
diff --git a/src/mess/machine/pk8020.c b/src/mess/machine/pk8020.c
index 227c18acc69..7629fadabef 100644
--- a/src/mess/machine/pk8020.c
+++ b/src/mess/machine/pk8020.c
@@ -840,27 +840,27 @@ WRITE8_MEMBER(pk8020_state::pk8020_portc_w)
WRITE8_MEMBER(pk8020_state::pk8020_portb_w)
{
// Turn all motors off
- floppy_mon_w(floppy_get_device(machine(), 0), 1);
- floppy_mon_w(floppy_get_device(machine(), 1), 1);
- floppy_mon_w(floppy_get_device(machine(), 2), 1);
- floppy_mon_w(floppy_get_device(machine(), 3), 1);
+ floppy_get_device(machine(), 0)->floppy_mon_w(1);
+ floppy_get_device(machine(), 1)->floppy_mon_w(1);
+ floppy_get_device(machine(), 2)->floppy_mon_w(1);
+ floppy_get_device(machine(), 3)->floppy_mon_w(1);
m_wd1793->set_side(BIT(data,4));
if (BIT(data,0)) {
m_wd1793->set_drive(0);
- floppy_mon_w(floppy_get_device(machine(), 0), 0);
- floppy_drive_set_ready_state(floppy_get_device(machine(), 0), 1, 1);
+ floppy_get_device(machine(), 0)->floppy_mon_w(0);
+ floppy_get_device(machine(), 0)->floppy_drive_set_ready_state(1, 1);
} else if (BIT(data,1)) {
m_wd1793->set_drive(1);
- floppy_mon_w(floppy_get_device(machine(), 1), 0);
- floppy_drive_set_ready_state(floppy_get_device(machine(), 1), 1, 1);
+ floppy_get_device(machine(), 1)->floppy_mon_w(0);
+ floppy_get_device(machine(), 1)->floppy_drive_set_ready_state(1, 1);
} else if (BIT(data,2)) {
m_wd1793->set_drive(2);
- floppy_mon_w(floppy_get_device(machine(), 2), 0);
- floppy_drive_set_ready_state(floppy_get_device(machine(), 2), 1, 1);
+ floppy_get_device(machine(), 2)->floppy_mon_w(0);
+ floppy_get_device(machine(), 2)->floppy_drive_set_ready_state(1, 1);
} else if (BIT(data,3)) {
m_wd1793->set_drive(3);
- floppy_mon_w(floppy_get_device(machine(), 3), 0);
- floppy_drive_set_ready_state(floppy_get_device(machine(), 3), 1, 1);
+ floppy_get_device(machine(), 3)->floppy_mon_w(0);
+ floppy_get_device(machine(), 3)->floppy_drive_set_ready_state(1, 1);
}
}
diff --git a/src/mess/machine/rmnimbus.c b/src/mess/machine/rmnimbus.c
index 7a58dbcb506..d9982e8cb4f 100644
--- a/src/mess/machine/rmnimbus.c
+++ b/src/mess/machine/rmnimbus.c
@@ -2274,7 +2274,7 @@ READ8_MEMBER(rmnimbus_state::nimbus_disk_r)
wd2793_device *fdc = machine().device<wd2793_device>(FDC_TAG);
int pc=space.device().safe_pc();
- device_t *drive = machine().device(nimbus_wd17xx_interface.floppy_drive_tags[FDC_DRIVE()]);
+ legacy_floppy_image_device *drive = machine().device<legacy_floppy_image_device>(nimbus_wd17xx_interface.floppy_drive_tags[FDC_DRIVE()]);
switch(offset*2)
{
@@ -2294,8 +2294,8 @@ READ8_MEMBER(rmnimbus_state::nimbus_disk_r)
case 0x10 :
m_nimbus_drives.reg410_in &= ~FDC_BITS_410;
m_nimbus_drives.reg410_in |= (FDC_MOTOR() ? FDC_MOTOR_MASKI : 0x00);
- m_nimbus_drives.reg410_in |= (floppy_drive_get_flag_state(drive, FLOPPY_DRIVE_INDEX) ? 0x00 : FDC_INDEX_MASK);
- m_nimbus_drives.reg410_in |= (floppy_drive_get_flag_state(drive, FLOPPY_DRIVE_READY) ? FDC_READY_MASK : 0x00);
+ m_nimbus_drives.reg410_in |= (drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_INDEX) ? 0x00 : FDC_INDEX_MASK);
+ m_nimbus_drives.reg410_in |= (drive->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY) ? FDC_READY_MASK : 0x00);
// Flip inverted bits
result=m_nimbus_drives.reg410_in ^ INV_BITS_410;
diff --git a/src/mess/machine/rx01.c b/src/mess/machine/rx01.c
index b9b7d66b88b..da72c8f09cb 100644
--- a/src/mess/machine/rx01.c
+++ b/src/mess/machine/rx01.c
@@ -12,7 +12,6 @@
#include "emu.h"
#include "machine/rx01.h"
-#include "imagedev/flopdrv.h"
#include "formats/basicdsk.h"
static LEGACY_FLOPPY_OPTIONS_START( rx01 )
@@ -74,8 +73,8 @@ machine_config_constructor rx01_device::device_mconfig_additions() const
void rx01_device::device_start()
{
- m_image[0] = subdevice(FLOPPY_0);
- m_image[1] = subdevice(FLOPPY_1);
+ m_image[0] = subdevice<legacy_floppy_image_device>(FLOPPY_0);
+ m_image[1] = subdevice<legacy_floppy_image_device>(FLOPPY_1);
}
@@ -87,9 +86,9 @@ void rx01_device::device_reset()
{
for(int i=0;i<2;i++)
{
- floppy_mon_w(m_image[i], 0); // turn it on
- floppy_drive_set_controller(m_image[i], this);
- floppy_drive_set_rpm(m_image[i], 360.);
+ m_image[i]->floppy_mon_w(0); // turn it on
+ m_image[i]->floppy_drive_set_controller(this);
+ m_image[i]->floppy_drive_set_rpm(360.);
}
m_rxes = 0;
m_rxcs = 0;
@@ -128,7 +127,7 @@ void rx01_device::command_write(UINT16 data)
m_unit = BIT(data,4);
m_interrupt = BIT(data,6);
- floppy_drive_set_ready_state(m_image[m_unit], 1,0);
+ m_image[m_unit]->floppy_drive_set_ready_state(1,0);
if (BIT(data,14)) // Initialize
@@ -164,7 +163,7 @@ void rx01_device::command_write(UINT16 data)
case 7: // Read Error Register
m_state = RX01_COMPLETE;
// set ready signal according to current drive status
- m_rxes |= floppy_drive_get_flag_state(m_image[m_unit], FLOPPY_DRIVE_READY) << 7;
+ m_rxes |= m_image[m_unit]->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY) << 7;
break;
}
}
@@ -195,7 +194,7 @@ UINT16 rx01_device::data_read()
void rx01_device::service_command()
{
printf("service_command %d\n",m_state);
- m_rxes |= floppy_drive_get_flag_state(m_image[m_unit], FLOPPY_DRIVE_READY) << 7;
+ m_rxes |= m_image[m_unit]->floppy_drive_get_flag_state(FLOPPY_DRIVE_READY) << 7;
switch(m_state) {
case RX01_FILL :
m_buffer[m_buf_pos] = m_rxdb & 0xff;
@@ -241,25 +240,25 @@ void rx01_device::service_command()
void rx01_device::position_head()
{
- int cur_track = floppy_drive_get_current_track(m_image[m_unit]);
+ int cur_track = m_image[m_unit]->floppy_drive_get_current_track();
int dir = (cur_track < m_rxta) ? +1 : -1;
while (m_rxta != cur_track)
{
cur_track += dir;
- floppy_drive_seek(m_image[m_unit], dir);
+ m_image[m_unit]->floppy_drive_seek(dir);
}
}
void rx01_device::read_sector()
{
/* read data */
- floppy_drive_read_sector_data(m_image[m_unit], 0, m_rxsa, (char *)m_buffer, 128);
+ m_image[m_unit]->floppy_drive_read_sector_data(0, m_rxsa, (char *)m_buffer, 128);
}
void rx01_device::write_sector(int ddam)
{
/* write data */
- floppy_drive_write_sector_data(m_image[m_unit], 0, m_rxsa, (char *)m_buffer, 128, ddam);
+ m_image[m_unit]->floppy_drive_write_sector_data(0, m_rxsa, (char *)m_buffer, 128, ddam);
}
diff --git a/src/mess/machine/rx01.h b/src/mess/machine/rx01.h
index df938876417..9e556f6d732 100644
--- a/src/mess/machine/rx01.h
+++ b/src/mess/machine/rx01.h
@@ -9,6 +9,8 @@
#ifndef __RX01__
#define __RX01__
+#include "imagedev/flopdrv.h"
+
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
@@ -61,7 +63,7 @@ private:
RX01_INIT
};
- device_t *m_image[2];
+ legacy_floppy_image_device *m_image[2];
UINT8 m_buffer[128];
int m_buf_pos;
diff --git a/src/mess/machine/sonydriv.c b/src/mess/machine/sonydriv.c
index 6c31bd6a378..05739d4ad0f 100644
--- a/src/mess/machine/sonydriv.c
+++ b/src/mess/machine/sonydriv.c
@@ -103,21 +103,21 @@ static int sony_enable2(void)
static void load_track_data(device_t *device,int floppy_select)
{
int track_size;
- device_image_interface *cur_image;
+ legacy_floppy_image_device *cur_image;
UINT8 *new_data;
floppy_t *f;
f = &sony.floppy[floppy_select];
- cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, floppy_select));
+ cur_image = floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, floppy_select);
- floppy_image_legacy *fimg = flopimg_get_image(&cur_image->device());
+ floppy_image_legacy *fimg = cur_image->flopimg_get_image();
if (!fimg)
{
return;
}
- track_size = floppy_get_track_size(fimg, f->head, floppy_drive_get_current_track(&cur_image->device()));
+ track_size = floppy_get_track_size(fimg, f->head, cur_image->floppy_drive_get_current_track());
if (f->loadedtrack_data) auto_free(device->machine(),f->loadedtrack_data);
new_data = auto_alloc_array(device->machine(),UINT8,track_size);
if (!new_data)
@@ -125,7 +125,7 @@ static void load_track_data(device_t *device,int floppy_select)
return;
}
- floppy_drive_read_track_data_info_buffer(&cur_image->device(), f->head, new_data, &track_size);
+ cur_image->floppy_drive_read_track_data_info_buffer(f->head, new_data, &track_size);
f->loadedtrack_valid = 1;
f->loadedtrack_dirty = 0;
f->loadedtrack_size = track_size;
@@ -137,17 +137,17 @@ static void load_track_data(device_t *device,int floppy_select)
static void save_track_data(device_t *device, int floppy_select)
{
- device_image_interface *cur_image;
+ legacy_floppy_image_device *cur_image;
floppy_t *f;
int len;
f = &sony.floppy[floppy_select];
- cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, floppy_select));
+ cur_image = floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, floppy_select);
if (f->loadedtrack_dirty)
{
len = f->loadedtrack_size;
- floppy_drive_write_track_data_info_buffer(&cur_image->device(), f->head, f->loadedtrack_data, &len);
+ cur_image->floppy_drive_write_track_data_info_buffer(f->head, f->loadedtrack_data, &len);
f->loadedtrack_dirty = 0;
}
}
@@ -157,14 +157,14 @@ static void save_track_data(device_t *device, int floppy_select)
UINT8 sony_read_data(device_t *device)
{
UINT8 result = 0;
- device_image_interface *cur_image;
+ legacy_floppy_image_device *cur_image;
floppy_t *f;
if (sony_enable2() || (! sony.floppy_enable))
return 0xFF; /* right ??? */
f = &sony.floppy[sony.floppy_select];
- cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, sony.floppy_select));
+ cur_image = floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, sony.floppy_select);
if (!cur_image->exists())
return 0xFF;
@@ -206,10 +206,9 @@ void sony_write_data(device_t *device,UINT8 data)
-static int sony_rpm(floppy_t *f, device_t *cur_image)
+static int sony_rpm(floppy_t *f, legacy_floppy_image_device *cur_image)
{
int result = 0;
- device_image_interface *image =dynamic_cast<device_image_interface *>(cur_image);
/*
* The Mac floppy controller was interesting in that its speed was adjusted
* while the thing was running. On the tracks closer to the rim, it was
@@ -253,8 +252,8 @@ static int sony_rpm(floppy_t *f, device_t *cur_image)
439 /* 64-79: timing value ???? (acceptable range {021E-0222} */
};
#endif
- if (cur_image && image->exists())
- result = speeds[floppy_drive_get_current_track(cur_image) / 16];
+ if (cur_image && cur_image->exists())
+ result = speeds[cur_image->floppy_drive_get_current_track() / 16];
}
return result;
}
@@ -264,7 +263,7 @@ int sony_read_status(device_t *device)
int result = 1;
int action;
floppy_t *f;
- device_image_interface *cur_image;
+ legacy_floppy_image_device *cur_image;
action = ((sony.lines & (SONY_CA1 | SONY_CA0)) << 2) | (sony.sel_line << 1) | ((sony.lines & SONY_CA2) >> 2);
@@ -277,7 +276,7 @@ int sony_read_status(device_t *device)
if ((! sony_enable2()) && sony.floppy_enable)
{
f = &sony.floppy[sony.floppy_select];
- cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, sony.floppy_select));
+ cur_image = floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, sony.floppy_select);
if (!cur_image->exists())
cur_image = NULL;
@@ -314,7 +313,7 @@ int sony_read_status(device_t *device)
break;
case 0x06: /* Disk is locked 0=locked 1=unlocked */
if (cur_image)
- result = floppy_wpt_r(&cur_image->device());
+ result = cur_image->floppy_wpt_r();
else
result = 0;
break;
@@ -324,7 +323,7 @@ int sony_read_status(device_t *device)
case 0x09: /* Number of sides: 0=single sided, 1=double sided */
if (cur_image)
{
- floppy_image_legacy *fimg = flopimg_get_image(&cur_image->device());
+ floppy_image_legacy *fimg = cur_image->flopimg_get_image();
if (fimg)
{
result = floppy_get_heads_per_disk(fimg) - 1;
@@ -335,7 +334,7 @@ int sony_read_status(device_t *device)
case 0x0a: /* At track 0: 0=track zero 1=not track zero */
logerror("%s sony.status(): reading Track 0\n", device->machine().describe_context());
if (cur_image)
- result = floppy_tk00_r(&cur_image->device());
+ result = cur_image->floppy_tk00_r();
else
result = 0;
break;
@@ -346,7 +345,7 @@ int sony_read_status(device_t *device)
{
if (cur_image)
{
- if (!floppy_dskchg_r(&cur_image->device()))
+ if (!cur_image->floppy_dskchg_r())
{
f->disk_switched = 1;
}
@@ -372,7 +371,7 @@ int sony_read_status(device_t *device)
/* (time in seconds) / (60 sec/minute) * (rounds/minute) * (60 pulses) * (2 pulse phases) */
if (cur_image)
{
- result = ((int) (device->machine().time().as_double() / 60.0 * sony_rpm(f, &cur_image->device()) * 60.0 * 2.0)) & 1;
+ result = ((int) (device->machine().time().as_double() / 60.0 * sony_rpm(f, cur_image) * 60.0 * 2.0)) & 1;
}
break;
case 0x0f: /* 400k/800k: Drive installed: 0=drive connected, 1=drive not connected */
@@ -400,7 +399,7 @@ static void sony_doaction(device_t *device)
{
int action;
floppy_t *f;
- device_image_interface *cur_image;
+ legacy_floppy_image_device *cur_image;
action = ((sony.lines & (SONY_CA1 | SONY_CA0)) << 2) | ((sony.lines & SONY_CA2) >> 2) | (sony.sel_line << 1);
@@ -413,7 +412,7 @@ static void sony_doaction(device_t *device)
if (sony.floppy_enable)
{
f = &sony.floppy[sony.floppy_select];
- cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, sony.floppy_select));
+ cur_image = floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, sony.floppy_select);
if (!cur_image->exists())
cur_image = NULL;
@@ -433,21 +432,21 @@ static void sony_doaction(device_t *device)
{
save_track_data(device,sony.floppy_select);
if (f->step)
- floppy_drive_seek(&cur_image->device(), -1);
+ cur_image->floppy_drive_seek(-1);
else
- floppy_drive_seek(&cur_image->device(), +1);
+ cur_image->floppy_drive_seek(+1);
f->loadedtrack_valid = 0;
}
break;
case 0x08: /* Turn motor on */
f->motor_on = CLEAR_LINE;
if (cur_image)
- floppy_mon_w(&cur_image->device(), f->motor_on);
+ cur_image->floppy_mon_w(f->motor_on);
break;
case 0x09: /* Turn motor off */
f->motor_on = ASSERT_LINE;
if (cur_image)
- floppy_mon_w(&cur_image->device(), f->motor_on);
+ cur_image->floppy_mon_w(f->motor_on);
break;
case 0x0d: /* Eject disk */
if (cur_image)
@@ -542,7 +541,7 @@ sonydriv_floppy_image_device::sonydriv_floppy_image_device(const machine_config
void sonydriv_floppy_image_device::device_start()
{
legacy_floppy_image_device::device_start();
- floppy_set_type(this, FLOPPY_TYPE_SONY);
+ floppy_set_type(FLOPPY_TYPE_SONY);
sony.floppy[0].is_fdhd = 0;
sony.floppy[1].is_fdhd = 0;
diff --git a/src/mess/machine/svi318.c b/src/mess/machine/svi318.c
index a4adfbab7c4..d9006355ab7 100644
--- a/src/mess/machine/svi318.c
+++ b/src/mess/machine/svi318.c
@@ -564,7 +564,7 @@ MACHINE_RESET_MEMBER(svi318_state,svi318)
for(drive=0;drive<2;drive++)
{
- floppy_install_load_proc(floppy_get_device(machine(), drive), svi318_load_proc);
+ floppy_get_device(machine(), drive)->floppy_install_load_proc(svi318_load_proc);
}
}
diff --git a/src/mess/machine/swtpc09.c b/src/mess/machine/swtpc09.c
index 05e1cba7895..918c3fa22ce 100644
--- a/src/mess/machine/swtpc09.c
+++ b/src/mess/machine/swtpc09.c
@@ -154,21 +154,21 @@ WRITE8_MEMBER ( swtpc09_state::dmf2_control_reg_w )
case 0x0e:
m_fdc->set_drive(0);
// need to set drive ready as sw checks before doing anything
- floppy_drive_set_ready_state(machine().device("floppy0"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy0")->floppy_drive_set_ready_state(1,0);
break;
case 0x0d:
m_fdc->set_drive(1);
- floppy_drive_set_ready_state(machine().device("floppy1"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy1")->floppy_drive_set_ready_state(1,0);
break;
case 0x0b:
m_fdc->set_drive(2);
- floppy_drive_set_ready_state(machine().device("floppy2"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy2")->floppy_drive_set_ready_state(1,0);
break;
case 0x07:
m_fdc->set_drive(3);
- floppy_drive_set_ready_state(machine().device("floppy3"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy3")->floppy_drive_set_ready_state(1,0);
break;
default:
@@ -422,21 +422,21 @@ WRITE8_MEMBER ( swtpc09_state::dmf3_control_reg_w )
case 0x01:
m_fdc->set_drive(0);
// need to set drive ready as sw checks before doing anything
- floppy_drive_set_ready_state(machine().device("floppy0"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy0")->floppy_drive_set_ready_state(1,0);
break;
case 0x02:
m_fdc->set_drive(1);
- floppy_drive_set_ready_state(machine().device("floppy1"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy1")->floppy_drive_set_ready_state(1,0);
break;
case 0x04:
m_fdc->set_drive(2);
- floppy_drive_set_ready_state(machine().device("floppy2"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy2")->floppy_drive_set_ready_state(1,0);
break;
case 0x08:
m_fdc->set_drive(3);
- floppy_drive_set_ready_state(machine().device("floppy3"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy3")->floppy_drive_set_ready_state(1,0);
break;
default:
@@ -476,21 +476,21 @@ WRITE8_MEMBER ( swtpc09_state::dc4_control_reg_w )
case 0x00:
m_fdc->set_drive(0);
// need to set drive ready as sw checks before doing anything
- floppy_drive_set_ready_state(machine().device("floppy0"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy0")->floppy_drive_set_ready_state(1,0);
break;
case 0x01:
m_fdc->set_drive(1);
- floppy_drive_set_ready_state(machine().device("floppy1"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy1")->floppy_drive_set_ready_state(1,0);
break;
case 0x02:
m_fdc->set_drive(2);
- floppy_drive_set_ready_state(machine().device("floppy2"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy2")->floppy_drive_set_ready_state(1,0);
break;
case 0x03:
m_fdc->set_drive(3);
- floppy_drive_set_ready_state(machine().device("floppy3"), 1,0);
+ machine().device<legacy_floppy_image_device>("floppy3")->floppy_drive_set_ready_state(1,0);
break;
default:
diff --git a/src/mess/machine/thomflop.c b/src/mess/machine/thomflop.c
index aa365a488ea..c8a98d2d97b 100644
--- a/src/mess/machine/thomflop.c
+++ b/src/mess/machine/thomflop.c
@@ -115,15 +115,15 @@ int thomson_state::thom_floppy_make_addr( chrn_id id, UINT8* dst, int sector_siz
/* build a sector, with header & space */
-int thomson_state::thom_floppy_make_sector( device_t* img, chrn_id id, UINT8* dst, int sector_size )
+int thomson_state::thom_floppy_make_sector( legacy_floppy_image_device* img, chrn_id id, UINT8* dst, int sector_size )
{
if ( sector_size == 128 )
{
/* single density */
memset( dst, 0x00, 6 ); /* synchro bytes */
dst[ 6 ] = 0xfb; /* data field mark */
- floppy_drive_read_sector_data
- ( img, id.H, id.data_id, dst + 7, sector_size );
+ img->floppy_drive_read_sector_data
+ ( id.H, id.data_id, dst + 7, sector_size );
dst[ sector_size + 7 ] = 0; /* TODO: CRC */
dst[ sector_size + 8 ] = 0; /* TODO: CRC */
memset( dst + sector_size + 9, 0xff, 22 ); /* end mark */
@@ -134,8 +134,8 @@ int thomson_state::thom_floppy_make_sector( device_t* img, chrn_id id, UINT8* ds
/* double density */
memset( dst, 0xa1, 3 ); /* synchro bytes */
dst[ 3 ] = 0xfb; /* data field mark */
- floppy_drive_read_sector_data
- ( img, id.H, id.data_id, dst + 4, sector_size );
+ img->floppy_drive_read_sector_data
+ ( id.H, id.data_id, dst + 4, sector_size );
dst[ sector_size + 4 ] = 0; /* TODO: CRC */
dst[ sector_size + 5 ] = 0; /* TODO: CRC */
memset( dst + sector_size + 6, 0xF7, 74 ); /* end mark */
@@ -146,7 +146,7 @@ int thomson_state::thom_floppy_make_sector( device_t* img, chrn_id id, UINT8* ds
/* build a whole track */
-int thomson_state::thom_floppy_make_track( device_t* img, UINT8* dst, int sector_size, int side )
+int thomson_state::thom_floppy_make_track( legacy_floppy_image_device* img, UINT8* dst, int sector_size, int side )
{
UINT8 space = ( sector_size == 128 ) ? 0xff : 0;
UINT8* org = dst;
@@ -154,16 +154,16 @@ int thomson_state::thom_floppy_make_track( device_t* img, UINT8* dst, int sector
int nb;
/* go to start of track */
- while ( ! floppy_drive_get_flag_state( img, FLOPPY_DRIVE_INDEX ) )
+ while ( ! img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) )
{
- if ( ! floppy_drive_get_next_id( img, side, &id ) )
+ if ( ! img->floppy_drive_get_next_id( side, &id ) )
return 0;
}
/* for each sector... */
for ( nb = 0; nb < 16; nb++ )
{
- if ( ! floppy_drive_get_next_id( img, side, &id ) )
+ if ( ! img->floppy_drive_get_next_id( side, &id ) )
break;
memset( dst, space, THOM_SIZE_SYNCHRO ); dst += THOM_SIZE_SYNCHRO;
@@ -171,7 +171,7 @@ int thomson_state::thom_floppy_make_track( device_t* img, UINT8* dst, int sector
memset( dst, space, THOM_SIZE_SYNCHRO ); dst += THOM_SIZE_SYNCHRO;
dst += thom_floppy_make_sector( img, id, dst, sector_size );
- if ( floppy_drive_get_flag_state( img, FLOPPY_DRIVE_INDEX ) )
+ if ( img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) )
break;
}
return dst - org;
@@ -222,11 +222,11 @@ int thomson_state::thom_qdd_make_addr( int sector, UINT8* dst )
/* build a sector, with header */
-int thomson_state::thom_qdd_make_sector( device_t* img, int sector, UINT8* dst )
+int thomson_state::thom_qdd_make_sector( legacy_floppy_image_device* img, int sector, UINT8* dst )
{
int i;
dst[ 0 ] = 0x5a;
- floppy_drive_read_sector_data ( img, 0, sector, dst + 1, 128 );
+ img->floppy_drive_read_sector_data ( 0, sector, dst + 1, 128 );
dst[ 129 ] = 0;
for ( i = 0; i < 129; i++ )
dst[ 129 ] += dst[ i ];
@@ -236,7 +236,7 @@ int thomson_state::thom_qdd_make_sector( device_t* img, int sector, UINT8* dst )
/* build a whole disk */
-int thomson_state::thom_qdd_make_disk ( device_t* img, UINT8* dst )
+int thomson_state::thom_qdd_make_disk ( legacy_floppy_image_device* img, UINT8* dst )
{
UINT8* org = dst;
int i;
@@ -418,7 +418,7 @@ WRITE8_MEMBER( thomson_state::to7_5p14sd_w )
machine().time().as_double(), m_maincpu->pc(), offset, data );
}
-void thomson_state::to7_5p14_index_pulse_callback( device_t *controller,device_t *image, int state )
+void thomson_state::to7_5p14_index_pulse_callback( device_t *controller,legacy_floppy_image_device *image, int state )
{
m_mc6843->set_index_pulse( state );
}
@@ -429,11 +429,11 @@ void thomson_state::to7_5p14sd_reset()
LOG(( "to7_5p14sd_reset: CD 90-015 controller\n" ));
for ( i = 0; i < floppy_get_count( machine() ); i++ )
{
- device_t * img = floppy_get_device( machine(), i );
+ legacy_floppy_image_device * img = floppy_get_device( machine(), i );
if (img) {
- floppy_drive_set_ready_state( img, FLOPPY_DRIVE_READY, 0 );
- floppy_drive_set_rpm( img, 300. );
- floppy_drive_seek( img, - floppy_drive_get_current_track( img ) );
+ img->floppy_drive_set_ready_state( FLOPPY_DRIVE_READY, 0 );
+ img->floppy_drive_set_rpm( 300. );
+ img->floppy_drive_seek( - img->floppy_drive_get_current_track() );
}
}
}
@@ -515,7 +515,7 @@ static to7qdd_t * to7qdd;
-void thomson_state::to7_qdd_index_pulse_cb( device_t *controller,device_t *image, int state )
+void thomson_state::to7_qdd_index_pulse_cb( device_t *controller,legacy_floppy_image_device *image, int state )
{
to7qdd->index_pulse = state;
@@ -532,7 +532,7 @@ void thomson_state::to7_qdd_index_pulse_cb( device_t *controller,device_t *image
-device_t * thomson_state::to7_qdd_image()
+legacy_floppy_image_device * thomson_state::to7_qdd_image()
{
return floppy_get_device( machine(), 0 );
}
@@ -548,7 +548,7 @@ void thomson_state::to7_qdd_stat_update()
to7qdd->status |= QDD_S_PE;
/* write-protect */
- if (floppy_wpt_r(to7_qdd_image()) == CLEAR_LINE)
+ if (to7_qdd_image()->floppy_wpt_r() == CLEAR_LINE)
to7qdd->status |= QDD_S_NCTS;
/* sticky reset conditions */
@@ -644,7 +644,7 @@ void thomson_state::to7_qdd_write_byte( UINT8 data )
LOG(( "%f $%04x to7_qdd_write_byte: got id field for sector=%i\n",
machine().time().as_double(), m_maincpu->pc(), sector ));
- floppy_drive_format_sector( to7_qdd_image(),
+ to7_qdd_image()->floppy_drive_format_sector(
0, sector, 0, 0, sector, 128, filler );
thom_floppy_active( 1 );
to7qdd->start_idx = to7qdd->data_idx;
@@ -673,7 +673,7 @@ void thomson_state::to7_qdd_write_byte( UINT8 data )
LOG(( "%f $%04x to7_qdd_write_byte: goto data field for sector=%i\n",
machine().time().as_double(), m_maincpu->pc(), sector ));
- floppy_drive_write_sector_data( to7_qdd_image(), 0, sector, to7qdd->data + to7qdd->start_idx + 1, 128, 0 );
+ to7_qdd_image()->floppy_drive_write_sector_data( 0, sector, to7qdd->data + to7qdd->start_idx + 1, 128, 0 );
thom_floppy_active( 1 );
}
@@ -825,16 +825,16 @@ void thomson_state::to7_qdd_reset()
for ( i = 0; i < floppy_get_count( machine() ); i++ )
{
- device_t * img = floppy_get_device( machine(), i );
+ legacy_floppy_image_device * img = floppy_get_device( machine(), i );
if (img) {
- floppy_drive_set_ready_state( img, FLOPPY_DRIVE_READY, 0 );
+ img->floppy_drive_set_ready_state( FLOPPY_DRIVE_READY, 0 );
motor_on = CLEAR_LINE;
- floppy_mon_w(img, motor_on);
+ img->floppy_mon_w( motor_on);
/* pulse each time the whole-disk spiraling track ends */
/* at 90us per byte read, the disk can be read in 6s */
- floppy_drive_set_rpm( img, 60. / 6. );
+ img->floppy_drive_set_rpm( 60. / 6. );
}
}
@@ -927,14 +927,14 @@ static emu_timer* thmfc_floppy_cmd;
-device_t * thomson_state::thmfc_floppy_image()
+legacy_floppy_image_device * thomson_state::thmfc_floppy_image()
{
return floppy_get_device( machine(), thmfc1->drive );
}
-int thomson_state::thmfc_floppy_is_qdd ( device_image_interface *image )
+int thomson_state::thmfc_floppy_is_qdd ( legacy_floppy_image_device *image )
{
if (image==NULL) return 0;
if (!image->exists()) return 0;
@@ -943,15 +943,15 @@ int thomson_state::thmfc_floppy_is_qdd ( device_image_interface *image )
-void thomson_state::thmfc_floppy_index_pulse_cb ( device_t *controller,device_t *image, int state )
+void thomson_state::thmfc_floppy_index_pulse_cb ( device_t *controller,legacy_floppy_image_device *image, int state )
{
if ( image != thmfc_floppy_image())
return;
- if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(image)))
+ if ( thmfc_floppy_is_qdd(image))
{
/* pulse each time the whole-disk spiraling track ends */
- floppy_drive_set_rpm( image, 16.92f /* 423/25 */ );
+ image->floppy_drive_set_rpm( 16.92f /* 423/25 */ );
thmfc1->ipl = state;
if ( state )
{
@@ -962,7 +962,7 @@ void thomson_state::thmfc_floppy_index_pulse_cb ( device_t *controller,device_t
}
else
{
- floppy_drive_set_rpm( image, 300. );
+ image->floppy_drive_set_rpm( 300. );
thmfc1->ipl = state;
if ( state )
thmfc1->data_raw_idx = 0;
@@ -975,14 +975,14 @@ void thomson_state::thmfc_floppy_index_pulse_cb ( device_t *controller,device_t
int thomson_state::thmfc_floppy_find_sector( chrn_id* dst )
{
- device_t* img = thmfc_floppy_image();
+ legacy_floppy_image_device* img = thmfc_floppy_image();
chrn_id id;
int r = 0;
/* scan track, try 4 revolutions */
while ( r < 4 )
{
- if ( floppy_drive_get_next_id( img, thmfc1->side, &id ) )
+ if ( img->floppy_drive_get_next_id( thmfc1->side, &id ) )
{
if ( id.C == thmfc1->track &&
id.R == thmfc1->sector &&
@@ -997,12 +997,12 @@ int thomson_state::thmfc_floppy_find_sector( chrn_id* dst )
}
}
- if ( floppy_drive_get_flag_state( img, FLOPPY_DRIVE_INDEX ) )
+ if ( img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) )
r++;
}
thmfc1->stat0 = THMFC1_STAT0_CRC_ERROR | THMFC1_STAT0_FINISHED;
- LOG (( "thmfc_floppy_find_sector: sector not found drive=%i track=%i sector=%i\n", floppy_get_drive( img ), thmfc1->track, thmfc1->sector ));
+ LOG (( "thmfc_floppy_find_sector: sector not found drive=%i track=%i sector=%i\n", floppy_get_drive(img), thmfc1->track, thmfc1->sector ));
return 0;
}
@@ -1017,8 +1017,8 @@ void thomson_state::thmfc_floppy_cmd_complete()
if ( thmfc1->op == THMFC1_OP_WRITE_SECT )
{
- device_t * img = thmfc_floppy_image();
- floppy_drive_write_sector_data( img, thmfc1->side, thmfc1->sector_id, thmfc1->data + 3, thmfc1->data_size - 3, 0 );
+ legacy_floppy_image_device * img = thmfc_floppy_image();
+ img->floppy_drive_write_sector_data( thmfc1->side, thmfc1->sector_id, thmfc1->data + 3, thmfc1->data_size - 3, 0 );
thom_floppy_active( 1 );
}
thmfc1->op = THMFC1_OP_RESET;
@@ -1068,7 +1068,7 @@ UINT8 thomson_state::thmfc_floppy_raw_read_byte()
/* rebuild track if needed */
if ( ! thmfc1->data_raw_size )
{
- if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image())))
+ if ( thmfc_floppy_is_qdd(thmfc_floppy_image()))
/* QDD: track = whole disk */
thmfc1->data_raw_size = thom_qdd_make_disk ( thmfc_floppy_image(), thmfc1->data );
else
@@ -1136,7 +1136,7 @@ void thomson_state::thmfc_floppy_qdd_write_byte( UINT8 data )
LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", machine().time().as_double(), m_maincpu->pc(), sector ));
- floppy_drive_format_sector( thmfc_floppy_image(), 0, sector, 0, 0, sector, 128, filler );
+ thmfc_floppy_image()->floppy_drive_format_sector( 0, sector, 0, 0, sector, 128, filler );
thom_floppy_active( 1 );
thmfc1->data_idx = 0;
}
@@ -1158,14 +1158,14 @@ void thomson_state::thmfc_floppy_qdd_write_byte( UINT8 data )
if ( i >= 0 )
{
/* got an id & a data field => write */
- device_t * img = thmfc_floppy_image();
+ legacy_floppy_image_device * img = thmfc_floppy_image();
int sector = (int) thmfc1->data[ i + 1 ] * 256 +
(int) thmfc1->data[ i + 2 ];
LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: data field, sector=%i\n",
machine().time().as_double(), m_maincpu->pc(), sector ));
- floppy_drive_write_sector_data( img, 0, sector, thmfc1->data + thmfc1->data_idx, 128, 0 );
+ img->floppy_drive_write_sector_data( 0, sector, thmfc1->data + thmfc1->data_idx, 128, 0 );
thom_floppy_active( 1 );
}
@@ -1218,7 +1218,7 @@ void thomson_state::thmfc_floppy_format_byte( UINT8 data )
if ( !memcmp ( thmfc1->data, header, sizeof( header ) ) )
{
/* got id field => format */
- device_t * img = thmfc_floppy_image();
+ legacy_floppy_image_device * img = thmfc_floppy_image();
UINT8 track = thmfc1->data[4];
UINT8 side = thmfc1->data[5];
UINT8 sector = thmfc1->data[6];
@@ -1227,7 +1227,7 @@ void thomson_state::thmfc_floppy_format_byte( UINT8 data )
chrn_id id;
if ( thmfc_floppy_find_sector( &id ) )
{
- floppy_drive_format_sector( img, side, thmfc1->sector_id, track, thmfc1->side, sector, length, filler );
+ img->floppy_drive_format_sector( side, thmfc1->sector_id, track, thmfc1->side, sector, length, filler );
thom_floppy_active( 1 );
}
}
@@ -1252,8 +1252,8 @@ READ8_MEMBER( thomson_state::thmfc_floppy_r )
case 1: /* STAT1 */
{
UINT8 data = 0;
- device_image_interface * img = dynamic_cast<device_image_interface *>(thmfc_floppy_image());
- int flags = floppy_drive_get_flag_state( &img->device(), -1 );
+ legacy_floppy_image_device * img = thmfc_floppy_image();
+ int flags = img->floppy_drive_get_flag_state(-1 );
if ( thmfc_floppy_is_qdd(img) )
{
if ( ! img->exists() )
@@ -1269,14 +1269,14 @@ READ8_MEMBER( thomson_state::thmfc_floppy_r )
if ( img->exists() )
data |= 0x20; /* disk change (?) */
- data |= !floppy_tk00_r(&img->device()) << 3;
+ data |= !img->floppy_tk00_r() << 3;
if ( flags & FLOPPY_DRIVE_READY )
data |= 0x02;
}
if (!motor_on)
data |= 0x10;
- if (!floppy_wpt_r(&img->device()))
+ if (!img->floppy_wpt_r())
data |= 0x04;
VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", machine().time().as_double(), m_maincpu->pc(), data ));
return data;
@@ -1314,7 +1314,7 @@ WRITE8_MEMBER( thomson_state::thmfc_floppy_w )
case 0: /* CMD0 */
{
int wsync = (data >> 4) & 1;
- int qdd = thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image()));
+ int qdd = thmfc_floppy_is_qdd(thmfc_floppy_image());
chrn_id id;
thmfc1->formatting = (data >> 2) & 1;
LOG (( "%f $%04x thmfc_floppy_w: CMD0=$%02X dens=%s wsync=%i dsync=%i fmt=%i op=%i\n",
@@ -1415,12 +1415,12 @@ WRITE8_MEMBER( thomson_state::thmfc_floppy_w )
case 2: /* CMD2 */
{
- device_t * img;
+ legacy_floppy_image_device * img;
int seek = 0, motor;
thmfc1->drive = data & 2;
- img = thmfc_floppy_image();
- if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(img)))
+ img = thmfc_floppy_image();
+ if ( thmfc_floppy_is_qdd(img))
{
motor = !(data & 0x40);
/* no side select & no seek for QDD */
@@ -1443,7 +1443,7 @@ WRITE8_MEMBER( thomson_state::thmfc_floppy_w )
if ( seek )
{
thmfc1->data_raw_size = 0;
- floppy_drive_seek( img, seek );
+ img->floppy_drive_seek( seek );
}
/* in real life, to keep the motor running, it is sufficient to
@@ -1451,14 +1451,14 @@ WRITE8_MEMBER( thomson_state::thmfc_floppy_w )
instead of counting, we assume the motor is always running...
*/
motor_on = CLEAR_LINE /* motor */;
- floppy_mon_w(img, motor_on);
+ img->floppy_mon_w(motor_on);
}
break;
case 3: /* WDATA */
thmfc1->wsync = data;
- if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image())))
+ if ( thmfc_floppy_is_qdd(thmfc_floppy_image()))
thmfc_floppy_qdd_write_byte( data );
else if ( thmfc1->op==THMFC1_OP_WRITE_SECT )
thmfc_floppy_write_byte( data );
@@ -1490,7 +1490,7 @@ WRITE8_MEMBER( thomson_state::thmfc_floppy_w )
thmfc1->track = data;
LOG (( "%f $%04x thmfc_floppy_w: WTRCK=%i (real=%i)\n",
machine().time().as_double(), m_maincpu->pc(), data,
- floppy_drive_get_current_track( thmfc_floppy_image() ) ));
+ thmfc_floppy_image()->floppy_drive_get_current_track()));
break;
case 7: /* WCELL */
@@ -1514,10 +1514,10 @@ void thomson_state::thmfc_floppy_reset()
for ( i = 0; i < floppy_get_count( machine() ); i++ )
{
- device_t * img = floppy_get_device( machine(), i );
+ legacy_floppy_image_device * img = floppy_get_device( machine(), i );
if (img) {
- floppy_drive_set_ready_state( img, FLOPPY_DRIVE_READY, 0 );
- floppy_drive_seek( img, - floppy_drive_get_current_track( img ) );
+ img->floppy_drive_set_ready_state( FLOPPY_DRIVE_READY, 0 );
+ img->floppy_drive_seek( - img->floppy_drive_get_current_track() );
}
}
@@ -1912,7 +1912,7 @@ WRITE8_MEMBER( thomson_state::to9_floppy_w )
to7_5p14_w( space, offset, data, mem_mask );
}
-void thomson_state::thomson_index_callback(device_t *device, int state)
+void thomson_state::thomson_index_callback(legacy_floppy_image_device *device, int state)
{
switch ( to7_controller_type )
{
diff --git a/src/mess/machine/ti99/990_dk.c b/src/mess/machine/ti99/990_dk.c
index 05876546eca..85991f392a9 100644
--- a/src/mess/machine/ti99/990_dk.c
+++ b/src/mess/machine/ti99/990_dk.c
@@ -16,7 +16,6 @@
#include "emu.h"
#include "formats/basicdsk.h"
-#include "imagedev/flopdrv.h"
#include "990_dk.h"
/* status bits */
@@ -110,7 +109,7 @@ int fd800_legacy_device::read_id(int unit, int head, int *cylinder_id, int *sect
/*while (revolution_count < 2)*/
/*{*/
- if (floppy_drive_get_next_id(&m_drv[unit].img->device(), head, &id))
+ if (m_drv[unit].img->floppy_drive_get_next_id(head, &id))
{
if (cylinder_id)
*cylinder_id = id.C;
@@ -142,7 +141,7 @@ int fd800_legacy_device::find_sector(int unit, int head, int sector, int *data_i
while (revolution_count < 2)
{
- if (floppy_drive_get_next_id(&m_drv[unit].img->device(), head, &id))
+ if (m_drv[unit].img->floppy_drive_get_next_id(head, &id))
{
/* compare id */
if ((id.R == sector) && (id.N == 0))
@@ -199,7 +198,7 @@ int fd800_legacy_device::do_seek(int unit, int cylinder, int head)
}
for (retries=0; retries<10; retries++)
{ /* seek to requested track */
- floppy_drive_seek(&m_drv[unit].img->device(), cylinder-m_drv[unit].log_cylinder[head]);
+ m_drv[unit].img->floppy_drive_seek(cylinder-m_drv[unit].log_cylinder[head]);
/* update physical track position */
if (m_drv[unit].phys_cylinder != -1)
m_drv[unit].phys_cylinder += cylinder-m_drv[unit].log_cylinder[head];
@@ -241,9 +240,9 @@ int fd800_legacy_device::do_restore(int unit)
}
/* limit iterations to 76 to prevent an endless loop if the disc is locked */
- while (!(seek_complete = !floppy_tk00_r(&m_drv[unit].img->device())) && (seek_count < 76))
+ while (!(seek_complete = !m_drv[unit].img->floppy_tk00_r()) && (seek_count < 76))
{
- floppy_drive_seek(&m_drv[unit].img->device(), -1);
+ m_drv[unit].img->floppy_drive_seek(-1);
seek_count++;
}
if (! seek_complete)
@@ -279,7 +278,7 @@ void fd800_legacy_device::do_read(void)
return;
}
- floppy_drive_read_sector_data(&m_drv[m_unit].img->device(), m_head, data_id, m_buf, 128);
+ m_drv[m_unit].img->floppy_drive_read_sector_data(m_head, data_id, m_buf, 128);
m_buf_pos = 0;
m_buf_mode = bm_read;
m_recv_buf = (m_buf[m_buf_pos<<1] << 8) | m_buf[(m_buf_pos<<1)+1];
@@ -305,7 +304,7 @@ void fd800_legacy_device::do_write(void)
return;
}
- floppy_drive_write_sector_data(&m_drv[m_unit].img->device(), m_head, data_id, m_buf, 128, m_ddam);
+ m_drv[m_unit].img->floppy_drive_write_sector_data(m_head, data_id, m_buf, 128, m_ddam);
m_buf_pos = 0;
m_buf_mode = bm_write;
@@ -587,7 +586,7 @@ void fd800_legacy_device::do_cmd(void)
}
else if ((m_drv[unit].phys_cylinder != -1) || (!do_restore(unit)))
{
- floppy_drive_seek(&m_drv[unit].img->device(), cylinder-m_drv[unit].phys_cylinder);
+ m_drv[unit].img->floppy_drive_seek(cylinder-m_drv[unit].phys_cylinder);
m_stat_reg |= status_OP_complete;
}
@@ -871,7 +870,7 @@ void fd800_legacy_device::device_start(void)
for (int i=0; i<MAX_FLOPPIES; i++)
{
- m_drv[i].img = dynamic_cast<device_image_interface *>(floppy_get_device(machine(), i));
+ m_drv[i].img = floppy_get_device(machine(), i);
m_drv[i].phys_cylinder = -1;
m_drv[i].log_cylinder[0] = m_drv[i].log_cylinder[1] = -1;
m_drv[i].seclen = 64;
diff --git a/src/mess/machine/ti99/990_dk.h b/src/mess/machine/ti99/990_dk.h
index 12421295025..0d0fa4e74e2 100644
--- a/src/mess/machine/ti99/990_dk.h
+++ b/src/mess/machine/ti99/990_dk.h
@@ -5,6 +5,8 @@
#ifndef __990_DK__
#define __990_DK__
+#include "imagedev/flopdrv.h"
+
extern const device_type FD800;
#define MAX_FLOPPIES 4
@@ -57,7 +59,7 @@ private:
struct
{
- device_image_interface *img;
+ legacy_floppy_image_device *img;
int phys_cylinder;
int log_cylinder[2];
int seclen;
diff --git a/src/mess/machine/trs80.c b/src/mess/machine/trs80.c
index 91e7f423193..3b8d1f605bd 100644
--- a/src/mess/machine/trs80.c
+++ b/src/mess/machine/trs80.c
@@ -527,10 +527,10 @@ WRITE8_MEMBER( trs80_state::trs80m4_f4_w )
m_fdc->dden_w(!BIT(data, 7));
/* CLEAR_LINE means to turn motors on */
- floppy_mon_w(floppy_get_device(machine(), 0), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
- floppy_mon_w(floppy_get_device(machine(), 1), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
- floppy_mon_w(floppy_get_device(machine(), 2), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
- floppy_mon_w(floppy_get_device(machine(), 3), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
+ floppy_get_device(machine(), 0)->floppy_mon_w((data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
+ floppy_get_device(machine(), 1)->floppy_mon_w((data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
+ floppy_get_device(machine(), 2)->floppy_mon_w((data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
+ floppy_get_device(machine(), 3)->floppy_mon_w((data & 0x0f) ? CLEAR_LINE : ASSERT_LINE);
}
WRITE8_MEMBER( trs80_state::sys80_f8_w )
@@ -781,10 +781,10 @@ WRITE8_MEMBER( trs80_state::trs80_motor_w )
if (drive > 3)
{ /* Turn motors off */
- floppy_mon_w(floppy_get_device(machine(), 0), ASSERT_LINE);
- floppy_mon_w(floppy_get_device(machine(), 1), ASSERT_LINE);
- floppy_mon_w(floppy_get_device(machine(), 2), ASSERT_LINE);
- floppy_mon_w(floppy_get_device(machine(), 3), ASSERT_LINE);
+ floppy_get_device(machine(), 0)->floppy_mon_w(ASSERT_LINE);
+ floppy_get_device(machine(), 1)->floppy_mon_w(ASSERT_LINE);
+ floppy_get_device(machine(), 2)->floppy_mon_w(ASSERT_LINE);
+ floppy_get_device(machine(), 3)->floppy_mon_w(ASSERT_LINE);
return;
}
@@ -792,10 +792,10 @@ WRITE8_MEMBER( trs80_state::trs80_motor_w )
m_fdc->set_side(m_head);
/* Turn motors on */
- floppy_mon_w(floppy_get_device(machine(), 0), CLEAR_LINE);
- floppy_mon_w(floppy_get_device(machine(), 1), CLEAR_LINE);
- floppy_mon_w(floppy_get_device(machine(), 2), CLEAR_LINE);
- floppy_mon_w(floppy_get_device(machine(), 3), CLEAR_LINE);
+ floppy_get_device(machine(), 0)->floppy_mon_w(CLEAR_LINE);
+ floppy_get_device(machine(), 1)->floppy_mon_w(CLEAR_LINE);
+ floppy_get_device(machine(), 2)->floppy_mon_w(CLEAR_LINE);
+ floppy_get_device(machine(), 3)->floppy_mon_w(CLEAR_LINE);
}
/*************************************