diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2014-03-18 13:31:41 +0000 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2014-03-18 13:31:41 +0000 |
commit | 59674b3fdf7b4c909a054c342fae590f7329445c (patch) | |
tree | 689decb8a5db028decb5589db738b022e570cd16 | |
parent | e1af1a20967b33ee7b320ba451efb752a862c3c4 (diff) |
legacy wd17xx is now also a modern device (nw)
57 files changed, 1234 insertions, 1370 deletions
diff --git a/src/emu/bus/bml3/bml3mp1802.c b/src/emu/bus/bml3/bml3mp1802.c index 3d20f77f122..ff5dd8f53ee 100644 --- a/src/emu/bus/bml3/bml3mp1802.c +++ b/src/emu/bus/bml3/bml3mp1802.c @@ -87,7 +87,7 @@ const rom_entry *bml3bus_mp1802_device::device_rom_region() const READ8_MEMBER( bml3bus_mp1802_device::bml3_mp1802_r) { - return wd17xx_drq_r(m_wd17xx) ? 0x00 : 0x80; + return m_wd17xx->drq_r() ? 0x00 : 0x80; } WRITE8_MEMBER( bml3bus_mp1802_device::bml3_mp1802_w) @@ -111,10 +111,10 @@ WRITE8_MEMBER( bml3bus_mp1802_device::bml3_mp1802_w) break; } device_t *floppy = subdevice(floppy_name); - wd17xx_set_drive(m_wd17xx,drive); + m_wd17xx->set_drive(drive); floppy_mon_w(floppy, !motor); floppy_drive_set_ready_state(floppy, ASSERT_LINE, 0); - wd17xx_set_side(m_wd17xx,side); + m_wd17xx->set_side(side); } @@ -143,8 +143,8 @@ void bml3bus_mp1802_device::device_start() // install into memory address_space &space_prg = machine().firstcpu->space(AS_PROGRAM); - space_prg.install_legacy_readwrite_handler(m_wd17xx, 0xff00, 0xff03, FUNC(wd17xx_r), FUNC(wd17xx_w)); - space_prg.install_readwrite_handler(0xff04, 0xff04, read8_delegate( FUNC(bml3bus_mp1802_device::bml3_mp1802_r), this), write8_delegate(FUNC(bml3bus_mp1802_device::bml3_mp1802_w), this) ); + space_prg.install_readwrite_handler(0xff00, 0xff03, read8_delegate(FUNC(mb8866_device::read),(mb8866_device*)m_wd17xx), write8_delegate(FUNC(mb8866_device::write),(mb8866_device*)m_wd17xx)); + space_prg.install_readwrite_handler(0xff04, 0xff04, read8_delegate(FUNC(bml3bus_mp1802_device::bml3_mp1802_r), this), write8_delegate(FUNC(bml3bus_mp1802_device::bml3_mp1802_w), this) ); // overwriting the main ROM (rather than using e.g. install_rom) should mean that bank switches for RAM expansion still work... UINT8 *mainrom = device().machine().root_device().memregion("maincpu")->base(); memcpy(mainrom + 0xf800, m_rom + 0xf800, 0x800); diff --git a/src/emu/bus/coco/coco_fdc.c b/src/emu/bus/coco/coco_fdc.c index d8e559c371a..50beb87a2e9 100644 --- a/src/emu/bus/coco/coco_fdc.c +++ b/src/emu/bus/coco/coco_fdc.c @@ -70,7 +70,6 @@ #include "coco_fdc.h" #include "imagedev/flopdrv.h" #include "includes/coco.h" -#include "machine/wd17xx.h" #include "imagedev/flopdrv.h" #include "formats/coco_dsk.h" @@ -200,7 +199,7 @@ void coco_fdc_device::device_start() m_drq = 1; m_disto_msm6242 = subdevice<msm6242_device>(DISTO_TAG); m_ds1315 = subdevice<ds1315_device>(CLOUD9_TAG); - m_wd17xx = subdevice(WD_TAG); + m_wd17xx = subdevice<wd2797_device>(WD_TAG); m_dskreg = 0x00; m_intrq = 0; m_msm6242_rtc_address = 0; @@ -312,9 +311,9 @@ void coco_fdc_device::dskreg_w(UINT8 data) update_lines(); - wd17xx_set_drive(m_wd17xx, drive); - wd17xx_set_side(m_wd17xx, head); - wd17xx_dden_w(m_wd17xx, !BIT(m_dskreg, 5)); + m_wd17xx->set_drive(drive); + m_wd17xx->set_side(head); + m_wd17xx->dden_w(!BIT(m_dskreg, 5)); } /*------------------------------------------------- @@ -328,16 +327,16 @@ READ8_MEMBER(coco_fdc_device::read) switch(offset & 0xEF) { case 8: - result = wd17xx_status_r(m_wd17xx, space, 0); + result = m_wd17xx->status_r(space, 0); break; case 9: - result = wd17xx_track_r(m_wd17xx, space, 0); + result = m_wd17xx->track_r(space, 0); break; case 10: - result = wd17xx_sector_r(m_wd17xx, space, 0); + result = m_wd17xx->sector_r(space, 0); break; case 11: - result = wd17xx_data_r(m_wd17xx, space, 0); + result = m_wd17xx->data_r(space, 0); break; } @@ -382,16 +381,16 @@ WRITE8_MEMBER(coco_fdc_device::write) dskreg_w(data); break; case 8: - wd17xx_command_w(m_wd17xx, space, 0, data); + m_wd17xx->command_w(space, 0, data); break; case 9: - wd17xx_track_w(m_wd17xx, space, 0, data); + m_wd17xx->track_w(space, 0, data); break; case 10: - wd17xx_sector_w(m_wd17xx, space, 0, data); + m_wd17xx->sector_w(space, 0, data); break; case 11: - wd17xx_data_w(m_wd17xx, space, 0, data); + m_wd17xx->data_w(space, 0, data); break; }; @@ -448,7 +447,7 @@ void dragon_fdc_device::device_start() { m_owner = dynamic_cast<cococart_slot_device *>(owner()); m_drq = 0; - m_wd17xx = subdevice(WD_TAG); + m_wd17xx = subdevice<wd2797_device>(WD_TAG); m_dskreg = 0x00; m_intrq = 0; m_msm6242_rtc_address = 0; @@ -514,9 +513,9 @@ void dragon_fdc_device::dskreg_w(UINT8 data) } if (data & 0x04) - wd17xx_set_drive(m_wd17xx, data & 0x03); + m_wd17xx->set_drive(data & 0x03); - wd17xx_dden_w(m_wd17xx, BIT(data, 3)); + m_wd17xx->dden_w(BIT(data, 3)); m_dskreg = data; } @@ -532,16 +531,16 @@ READ8_MEMBER(dragon_fdc_device::read) switch(offset & 0xEF) { case 0: - result = wd17xx_status_r(m_wd17xx, space, 0); + result = m_wd17xx->status_r(space, 0); break; case 1: - result = wd17xx_track_r(m_wd17xx, space, 0); + result = m_wd17xx->track_r(space, 0); break; case 2: - result = wd17xx_sector_r(m_wd17xx, space, 0); + result = m_wd17xx->sector_r(space, 0); break; case 3: - result = wd17xx_data_r(m_wd17xx, space, 0); + result = m_wd17xx->data_r(space, 0); break; } return result; @@ -558,21 +557,21 @@ WRITE8_MEMBER(dragon_fdc_device::write) switch(offset & 0xEF) { case 0: - wd17xx_command_w(m_wd17xx, space, 0, data); + m_wd17xx->command_w(space, 0, data); /* disk head is encoded in the command byte */ /* Only for type 3 & 4 commands */ if (data & 0x80) - wd17xx_set_side(m_wd17xx, (data & 0x02) ? 1 : 0); + m_wd17xx->set_side((data & 0x02) ? 1 : 0); break; case 1: - wd17xx_track_w(m_wd17xx, space, 0, data); + m_wd17xx->track_w(space, 0, data); break; case 2: - wd17xx_sector_w(m_wd17xx, space, 0, data); + m_wd17xx->sector_w(space, 0, data); break; case 3: - wd17xx_data_w(m_wd17xx, space, 0, data); + m_wd17xx->data_w(space, 0, data); break; case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: diff --git a/src/emu/bus/coco/coco_fdc.h b/src/emu/bus/coco/coco_fdc.h index 6e82ca4646d..ae4155060db 100644 --- a/src/emu/bus/coco/coco_fdc.h +++ b/src/emu/bus/coco/coco_fdc.h @@ -7,6 +7,8 @@ #include "cococart.h" #include "machine/msm6242.h" #include "machine/ds1315.h" +#include "machine/wd17xx.h" + //************************************************************************** // TYPE DEFINITIONS @@ -62,7 +64,7 @@ protected: UINT8 m_drq : 1; UINT8 m_intrq : 1; - device_t *m_wd17xx; /* WD17xx */ + wd2797_device *m_wd17xx; /* WD17xx */ ds1315_device *m_ds1315; /* DS1315 */ /* Disto RTC */ diff --git a/src/emu/machine/wd17xx.c b/src/emu/machine/wd17xx.c index f639803deb6..9a289a9e16e 100644 --- a/src/emu/machine/wd17xx.c +++ b/src/emu/machine/wd17xx.c @@ -155,7 +155,6 @@ #include "formats/imageutl.h" #include "machine/wd17xx.h" #include "imagedev/flopdrv.h" -#include "devlegcy.h" /*************************************************************************** CONSTANTS @@ -285,94 +284,6 @@ static const UINT8 track_SD[][2] = { /*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -struct wd1770_state -{ - /* callbacks */ - devcb_resolved_read_line in_dden_func; - devcb_resolved_write_line out_intrq_func; - devcb_resolved_write_line out_drq_func; - - /* input lines */ - int mr; /* master reset */ - int rdy; /* ready, enable precomp */ - int tr00; /* track 00 */ - int idx; /* index */ - int wprt; /* write protect */ - int dden; /* double density */ - - /* output lines */ - int mo; /* motor on */ - int dirc; /* direction */ - int drq; /* data request */ - int intrq; /* interrupt request */ - - /* register */ - UINT8 data_shift; - UINT8 data; - UINT8 track; - UINT8 sector; - UINT8 command; - UINT8 status; - UINT8 interrupt; - - int stepping_rate[4]; /* track stepping rate in ms */ - - unsigned short crc; /* Holds the current CRC value for write_track CRC calculation */ - int crc_active; /* Flag indicating that CRC calculation in write_track is active. */ - - UINT8 track_reg; /* value of track register */ - UINT8 command_type; /* last command type */ - UINT8 head; /* current head # */ - - UINT8 read_cmd; /* last read command issued */ - UINT8 write_cmd; /* last write command issued */ - INT8 direction; /* last step direction */ - UINT8 last_command_data; /* last command data */ - - UINT8 status_drq; /* status register data request bit */ - UINT8 busy_count; /* how long to keep busy bit set */ - - UINT8 buffer[6144]; /* I/O buffer (holds up to a whole track) */ - UINT32 data_offset; /* offset into I/O buffer */ - INT32 data_count; /* transfer count from/into I/O buffer */ - - UINT8 *fmt_sector_data[256]; /* pointer to data after formatting a track */ - - UINT8 dam_list[256][4]; /* list of data address marks while formatting */ - int dam_data[256]; /* offset to data inside buffer while formatting */ - int dam_cnt; /* valid number of entries in the dam_list */ - UINT16 sector_length; /* sector length (byte) */ - - UINT8 ddam; /* ddam of sector found - used when reading */ - UINT8 sector_data_id; - int data_direction; - - int hld_count; /* head loaded counter */ - - /* timers to delay execution/completion of commands */ - emu_timer *timer_cmd, *timer_data, *timer_rs, *timer_ws; - - /* this is the drive currently selected */ - device_t *drive; - - /* this is the head currently selected */ - UINT8 hd; - - /* pause time when writing/reading sector */ - int pause_time; - - /* Were we busy when we received a FORCE_INT command */ - UINT8 was_busy; - - /* Pointer to interface */ - const wd17xx_interface *intf; -}; - - -/*************************************************************************** DEFAULT INTERFACES ***************************************************************************/ @@ -387,33 +298,6 @@ const wd17xx_interface default_wd17xx_interface_2_drives = }; -/*************************************************************************** - PROTOTYPES -***************************************************************************/ - -static void wd17xx_complete_command(device_t *device, int delay); -static void wd17xx_timed_data_request(device_t *device); -static int wd17xx_locate_sector(device_t *device); -static void wd17xx_timed_read_sector_request(device_t *device); - - -/***************************************************************************** - INLINE FUNCTIONS -*****************************************************************************/ - -INLINE wd1770_state *get_safe_token(device_t *device) -{ - assert(device != NULL); - assert(device->type() == FD1771 || device->type() == FD1781 || - device->type() == FD1791 || device->type() == FD1792 || device->type() == FD1793 || device->type() == FD1794 || device->type() == FD1795 || device->type() == FD1797 || - device->type() == FD1761 || device->type() == FD1762 || device->type() == FD1763 || device->type() == FD1764 || device->type() == FD1765 || device->type() == FD1767 || - device->type() == WD2791 || device->type() == WD2793 || device->type() == WD2795 || device->type() == WD2797 || - device->type() == WD1770 || device->type() == WD1772 || device->type() == WD1773 || - device->type() == MB8866 || device->type() == MB8876 || device->type() == MB8877); - - return (wd1770_state *)downcast<wd1770_device *>(device)->token(); -} - /*************************************************************************** HELPER FUNCTIONS @@ -440,14 +324,12 @@ static int wd17xx_has_side_select(device_t *device) device->type() == WD2795 || device->type() == WD2797); } -static int wd17xx_dden(device_t *device) +int wd1770_device::wd17xx_dden() { - wd1770_state *w = get_safe_token(device); - - if (!w->in_dden_func.isnull()) - return w->in_dden_func(); + if (!m_in_dden_func.isnull()) + return m_in_dden_func(); else - return w->dden; + return m_dden; } @@ -456,124 +338,110 @@ static int wd17xx_dden(device_t *device) ***************************************************************************/ /* clear a data request */ -static void wd17xx_clear_drq(device_t *device) +void wd1770_device::wd17xx_clear_drq() { - wd1770_state *w = get_safe_token(device); - - w->status &= ~STA_2_DRQ; + m_status &= ~STA_2_DRQ; - w->drq = CLEAR_LINE; - w->out_drq_func(w->drq); + m_drq = CLEAR_LINE; + m_out_drq_func(m_drq); } /* set data request */ -static void wd17xx_set_drq(device_t *device) +void wd1770_device::wd17xx_set_drq() { - wd1770_state *w = get_safe_token(device); + if (m_status & STA_2_DRQ) + m_status |= STA_2_LOST_DAT; - if (w->status & STA_2_DRQ) - w->status |= STA_2_LOST_DAT; + m_status |= STA_2_DRQ; - w->status |= STA_2_DRQ; - - w->drq = ASSERT_LINE; - w->out_drq_func(w->drq); + m_drq = ASSERT_LINE; + m_out_drq_func(m_drq); } /* clear interrupt request */ -static void wd17xx_clear_intrq(device_t *device) +void wd1770_device::wd17xx_clear_intrq() { - wd1770_state *w = get_safe_token(device); - - w->intrq = CLEAR_LINE; - w->out_intrq_func(w->intrq); + m_intrq = CLEAR_LINE; + m_out_intrq_func(m_intrq); } /* set interrupt request */ -static void wd17xx_set_intrq(device_t *device) +void wd1770_device::wd17xx_set_intrq() { - wd1770_state *w = get_safe_token(device); + m_status &= ~STA_2_BUSY; + m_status &= ~STA_2_DRQ; - w->status &= ~STA_2_BUSY; - w->status &= ~STA_2_DRQ; - - w->intrq = ASSERT_LINE; - w->out_intrq_func(w->intrq); + m_intrq = ASSERT_LINE; + m_out_intrq_func(m_intrq); } /* set intrq after delay */ -static TIMER_CALLBACK( wd17xx_command_callback ) -{ - device_t *device = (device_t *)ptr; - wd1770_state *w = get_safe_token(device); - - if (w->last_command_data != FDC_FORCE_INT) +TIMER_CALLBACK_MEMBER( wd1770_device::wd17xx_command_callback ) +{ + if (m_last_command_data != FDC_FORCE_INT) { - wd17xx_set_intrq(device); + wd17xx_set_intrq(); } } /* write next byte to data register and set drq */ -static TIMER_CALLBACK( wd17xx_data_callback ) +TIMER_CALLBACK_MEMBER( wd1770_device::wd17xx_data_callback ) { - device_t *device = (device_t *)ptr; - wd1770_state *w = get_safe_token(device); - /* check if this is a write command */ - if( (w->command_type == TYPE_II && w->command == FDC_WRITE_SEC) || - (w->command_type == TYPE_III && w->command == FDC_WRITE_TRK) ) + if( (m_command_type == TYPE_II && m_command == FDC_WRITE_SEC) || + (m_command_type == TYPE_III && m_command == FDC_WRITE_TRK) ) { /* we are ready for new data */ - wd17xx_set_drq(device); + wd17xx_set_drq(); return; } /* any bytes remaining? */ - if (w->data_count >= 1) + if (m_data_count >= 1) { /* yes */ - w->data = w->buffer[w->data_offset++]; + m_data = m_buffer[m_data_offset++]; if (VERBOSE_DATA) - logerror("wd17xx_data_callback: $%02X (data_count %d)\n", w->data, w->data_count); + logerror("wd17xx_data_callback: $%02X (data_count %d)\n", m_data, m_data_count); - wd17xx_set_drq(device); + wd17xx_set_drq(); /* any bytes remaining? */ - if (--w->data_count < 1) + if (--m_data_count < 1) { /* no */ - w->data_offset = 0; + m_data_offset = 0; /* clear ddam type */ - w->status &=~STA_2_REC_TYPE; + m_status &=~STA_2_REC_TYPE; /* read a sector with ddam set? */ - if (w->command_type == TYPE_II && w->ddam != 0) + if (m_command_type == TYPE_II && m_ddam != 0) { /* set it */ - w->status |= STA_2_REC_TYPE; + m_status |= STA_2_REC_TYPE; } /* check if we should handle the next sector for a multi record read */ - if (w->command_type == TYPE_II && w->command == FDC_READ_SEC && (w->read_cmd & 0x10)) + if (m_command_type == TYPE_II && m_command == FDC_READ_SEC && (m_read_cmd & 0x10)) { if (VERBOSE) logerror("wd17xx_data_callback: multi sector read\n"); - if (w->sector == 0xff) - w->sector = 0x01; + if (m_sector == 0xff) + m_sector = 0x01; else - w->sector++; + m_sector++; - wd17xx_timed_read_sector_request(device); + wd17xx_timed_read_sector_request(); } else { /* Delay the INTRQ 3 byte times because we need to read two CRC bytes and compare them with a calculated CRC */ - wd17xx_complete_command(device, DELAY_DATADONE); + wd17xx_complete_command(DELAY_DATADONE); if (VERBOSE) logerror("wd17xx_data_callback: data read completed\n"); @@ -582,72 +450,69 @@ static TIMER_CALLBACK( wd17xx_data_callback ) else { /* requeue us for more data */ - w->timer_data->adjust(attotime::from_usec(wd17xx_dden(device) ? 128 : 32)); + m_timer_data->adjust(attotime::from_usec(wd17xx_dden() ? 128 : 32)); } } else { - logerror("wd17xx_data_callback: (no new data) $%02X (data_count %d)\n", w->data, w->data_count); + logerror("wd17xx_data_callback: (no new data) $%02X (data_count %d)\n", m_data, m_data_count); } } -static void wd17xx_set_busy(device_t *device, attotime duration) +void wd1770_device::wd17xx_set_busy(attotime duration) { - wd1770_state *w = get_safe_token(device); + m_status |= STA_1_BUSY; - w->status |= STA_1_BUSY; - - w->timer_cmd->adjust(duration); + m_timer_cmd->adjust(duration); } /* BUSY COUNT DOESN'T WORK PROPERLY! */ -static void wd17xx_command_restore(device_t *device) +void wd1770_device::wd17xx_command_restore() { - wd1770_state *w = get_safe_token(device); UINT8 step_counter; - if (w->drive == NULL) + if (m_drive == NULL) return; step_counter = 255; #if 0 - w->status |= STA_1_BUSY; + m_status |= STA_1_BUSY; #endif /* setup step direction */ - w->direction = -1; + m_direction = -1; - w->command_type = TYPE_I; + m_command_type = TYPE_I; /* reset busy count */ - w->busy_count = 0; + m_busy_count = 0; - if (1) // image_slotexists(w->drive) : FIXME + if (1) // image_slotexists(m_drive) : FIXME { /* keep stepping until track 0 is received or 255 steps have been done */ - while (floppy_tk00_r(w->drive) && (step_counter != 0)) + while (floppy_tk00_r(m_drive) && (step_counter != 0)) { /* update time to simulate seek time busy signal */ - w->busy_count++; - floppy_drive_seek(w->drive, w->direction); + m_busy_count++; + floppy_drive_seek(m_drive, m_direction); step_counter--; } } /* update track reg */ - w->track = 0; + m_track = 0; #if 0 /* simulate seek time busy signal */ - w->busy_count = 0; //w->busy_count * ((w->data & FDC_STEP_RATE) + 1); + m_busy_count = 0; //m_busy_count * ((m_data & FDC_STEP_RATE) + 1); /* when command completes set irq */ - wd17xx_set_intrq(device); + wd17xx_set_intrq(); #endif - wd17xx_set_busy(device, attotime::from_usec(100)); + wd17xx_set_busy(attotime::from_usec(100)); } /* @@ -658,25 +523,24 @@ static void wd17xx_command_restore(device_t *device) may directly write the bytes. (The if-part below may thus be removed.) */ -static void write_track(device_t *device) +void wd1770_device::write_track() { - wd1770_state *w = get_safe_token(device); floppy_image_legacy *floppy; #if 0 int i; - for (i=0;i+4<w->data_offset;) + for (i=0;i+4<m_data_offset;) { - if (w->buffer[i]==0xfe) + if (m_buffer[i]==0xfe) { /* got address mark */ - int track = w->buffer[i+1]; - int side = w->buffer[i+2]; - int sector = w->buffer[i+3]; - //int len = w->buffer[i+4]; + int track = m_buffer[i+1]; + int side = m_buffer[i+2]; + int sector = m_buffer[i+3]; + //int len = m_buffer[i+4]; int filler = 0xe5; /* IBM and Thomson */ - int density = w->density; - floppy_drive_format_sector(w->drive,side,sector,track, - w->hd,sector,density?1:0,filler); + int density = m_density; + floppy_drive_format_sector(m_drive,side,sector,track, + m_hd,sector,density?1:0,filler); i += 128; /* at least... */ } else @@ -691,26 +555,26 @@ static void write_track(device_t *device) the track will become. The only object which can tell us is the selected format. */ - w->data_count = 0; - floppy = flopimg_get_image(w->drive); + m_data_count = 0; + floppy = flopimg_get_image(m_drive); if (floppy != NULL) - w->data_count = floppy_get_track_size(floppy, w->hd, w->track); + m_data_count = floppy_get_track_size(floppy, m_hd, m_track); - if (w->data_count==0) + if (m_data_count==0) { - if (wd17xx_is_sd_only(device)) - w->data_count = TRKSIZE_SD; + if (wd17xx_is_sd_only(this)) + m_data_count = TRKSIZE_SD; else - w->data_count = wd17xx_dden(device) ? TRKSIZE_SD : TRKSIZE_DD; + m_data_count = wd17xx_dden() ? TRKSIZE_SD : TRKSIZE_DD; } - floppy_drive_write_track_data_info_buffer( w->drive, w->hd, (char *)w->buffer, &(w->data_count) ); + floppy_drive_write_track_data_info_buffer( m_drive, m_hd, (char *)m_buffer, &(m_data_count) ); - w->data_offset = 0; + m_data_offset = 0; - wd17xx_set_drq(device); - w->status |= STA_2_BUSY; - w->busy_count = 0; + wd17xx_set_drq(); + m_status |= STA_2_BUSY; + m_busy_count = 0; } /* @@ -719,9 +583,8 @@ static void write_track(device_t *device) dumps can directly deliver them. (The if-part below may thus be removed.) */ -static void read_track(device_t *device) +void wd1770_device::read_track() { - wd1770_state *w = get_safe_token(device); floppy_image_legacy *floppy; #if 0 UINT8 *psrc; /* pointer to track format structure */ @@ -729,23 +592,23 @@ static void read_track(device_t *device) int cnt; /* number of bytes to fill in */ UINT16 crc; /* id or data CRC */ UINT8 d; /* data */ - UINT8 t = w->track; /* track of DAM */ - UINT8 h = w->head; /* head of DAM */ - UINT8 s = w->sector_dam; /* sector of DAM */ - UINT16 l = w->sector_length; /* sector length of DAM */ + UINT8 t = m_track; /* track of DAM */ + UINT8 h = m_head; /* head of DAM */ + UINT8 s = m_sector_dam; /* sector of DAM */ + UINT16 l = m_sector_length; /* sector length of DAM */ int i; - for (i = 0; i < w->sec_per_track; i++) + for (i = 0; i < m_sec_per_track; i++) { - w->dam_list[i][0] = t; - w->dam_list[i][1] = h; - w->dam_list[i][2] = i; - w->dam_list[i][3] = l >> 8; + m_dam_list[i][0] = t; + m_dam_list[i][1] = h; + m_dam_list[i][2] = i; + m_dam_list[i][3] = l >> 8; } - pdst = w->buffer; + pdst = m_buffer; - if (w->density) + if (m_density) { psrc = track_DD[0]; /* double density track format */ cnt = TRKSIZE_DD; @@ -760,9 +623,9 @@ static void read_track(device_t *device) { if (psrc[0] == 0) /* no more track format info ? */ { - if (w->dam_cnt < w->sec_per_track) /* but more DAM info ? */ + if (m_dam_cnt < m_sec_per_track) /* but more DAM info ? */ { - if (w->density)/* DD track ? */ + if (m_density)/* DD track ? */ psrc = track_DD[3]; else psrc = track_SD[3]; @@ -797,11 +660,11 @@ static void read_track(device_t *device) else if (d == 0x80)/* sector ID ? */ { pdst--; /* go back one byte */ - t = *pdst++ = w->dam_list[w->dam_cnt][0]; /* track number */ - h = *pdst++ = w->dam_list[w->dam_cnt][1]; /* head number */ - s = *pdst++ = w->dam_list[w->dam_cnt][2]; /* sector number */ - l = *pdst++ = w->dam_list[w->dam_cnt][3]; /* sector length code */ - w->dam_cnt++; + t = *pdst++ = m_dam_list[m_dam_cnt][0]; /* track number */ + h = *pdst++ = m_dam_list[m_dam_cnt][1]; /* head number */ + s = *pdst++ = m_dam_list[m_dam_cnt][2]; /* sector number */ + l = *pdst++ = m_dam_list[m_dam_cnt][3]; /* sector length code */ + m_dam_cnt++; crc = ccitt_crc16_one(crc, t); /* build CRC */ crc = ccitt_crc16_one(crc, h); /* build CRC */ crc = ccitt_crc16_one(crc, s); /* build CRC */ @@ -817,15 +680,15 @@ static void read_track(device_t *device) pdst--; /* go back one byte */ if (seek(w, t, h, s) == 0) { - if (mame_fread(w->image_file, pdst, l) != l) + if (mame_fread(m_image_file, pdst, l) != l) { - w->status = STA_2_CRC_ERR; + m_status = STA_2_CRC_ERR; return; } } else { - w->status = STA_2_REC_N_FND; + m_status = STA_2_REC_N_FND; return; } for (i = 0; i < l; i++) // build CRC of all data @@ -843,44 +706,42 @@ static void read_track(device_t *device) #endif /* Determine the track size. We cannot allow different sizes in this design (see above, write_track). */ - w->data_count = 0; - floppy = flopimg_get_image(w->drive); + m_data_count = 0; + floppy = flopimg_get_image(m_drive); if (floppy != NULL) - w->data_count = floppy_get_track_size(floppy, w->hd, w->track); + m_data_count = floppy_get_track_size(floppy, m_hd, m_track); - if (w->data_count==0) + if (m_data_count==0) { - if (wd17xx_is_sd_only(device)) - w->data_count = TRKSIZE_SD; + if (wd17xx_is_sd_only(this)) + m_data_count = TRKSIZE_SD; else - w->data_count = wd17xx_dden(device) ? TRKSIZE_SD : TRKSIZE_DD; + m_data_count = wd17xx_dden() ? TRKSIZE_SD : TRKSIZE_DD; } - floppy_drive_read_track_data_info_buffer( w->drive, w->hd, (char *)w->buffer, &(w->data_count) ); + floppy_drive_read_track_data_info_buffer( m_drive, m_hd, (char *)m_buffer, &(m_data_count) ); - w->data_offset = 0; + m_data_offset = 0; - wd17xx_set_drq(device); - w->status |= STA_2_BUSY; - w->busy_count = 0; + wd17xx_set_drq(); + m_status |= STA_2_BUSY; + m_busy_count = 0; } /* read the next data address mark */ -static void wd17xx_read_id(device_t *device) +void wd1770_device::wd17xx_read_id() { chrn_id id; - wd1770_state *w = get_safe_token(device); - - w->status &= ~(STA_2_CRC_ERR | STA_2_REC_N_FND); + m_status &= ~(STA_2_CRC_ERR | STA_2_REC_N_FND); /* get next id from disc */ - if (floppy_drive_get_next_id(w->drive, w->hd, &id)) + if (floppy_drive_get_next_id(m_drive, m_hd, &id)) { UINT16 crc = 0xffff; - w->data_offset = 0; - w->data_count = 6; + m_data_offset = 0; + m_data_count = 6; /* for MFM */ /* crc includes 3x0x0a1, and 1x0x0fe (id mark) */ @@ -889,87 +750,83 @@ static void wd17xx_read_id(device_t *device) crc = ccitt_crc16_one(crc,0x0a1); crc = ccitt_crc16_one(crc,0x0fe); - w->buffer[0] = id.C; - w->buffer[1] = id.H; - w->buffer[2] = id.R; - w->buffer[3] = id.N; - crc = ccitt_crc16_one(crc, w->buffer[0]); - crc = ccitt_crc16_one(crc, w->buffer[1]); - crc = ccitt_crc16_one(crc, w->buffer[2]); - crc = ccitt_crc16_one(crc, w->buffer[3]); + m_buffer[0] = id.C; + m_buffer[1] = id.H; + m_buffer[2] = id.R; + m_buffer[3] = id.N; + crc = ccitt_crc16_one(crc, m_buffer[0]); + crc = ccitt_crc16_one(crc, m_buffer[1]); + crc = ccitt_crc16_one(crc, m_buffer[2]); + crc = ccitt_crc16_one(crc, m_buffer[3]); /* crc is stored hi-byte followed by lo-byte */ - w->buffer[4] = crc>>8; - w->buffer[5] = crc & 255; + m_buffer[4] = crc>>8; + m_buffer[5] = crc & 255; - w->sector = id.C; + m_sector = id.C; if (VERBOSE) logerror("wd17xx_read_id: read id succeeded.\n"); - wd17xx_timed_data_request(device); + wd17xx_timed_data_request(); } else { /* record not found */ - w->status |= STA_2_REC_N_FND; - //w->sector = w->track; + m_status |= STA_2_REC_N_FND; + //m_sector = m_track; if (VERBOSE) logerror("wd17xx_read_id: read id failed\n"); - wd17xx_complete_command(device, DELAY_ERROR); + wd17xx_complete_command(DELAY_ERROR); } } -void wd17xx_index_pulse_callback(device_t *controller, device_t *img, int state) +void wd1770_device::index_pulse_callback(device_t *img, int state) { - wd1770_state *w = get_safe_token(controller); - - if (img != w->drive) + if (img != m_drive) return; - w->idx = state; + m_idx = state; - if (!state && w->idx && BIT(w->interrupt, 2)) - wd17xx_set_intrq(controller); + if (!state && m_idx && BIT(m_interrupt, 2)) + wd17xx_set_intrq(); - if (w->hld_count) - w->hld_count--; + if (m_hld_count) + m_hld_count--; } -static int wd17xx_locate_sector(device_t *device) +int wd1770_device::wd17xx_locate_sector() { UINT8 revolution_count; chrn_id id; - wd1770_state *w = get_safe_token(device); - revolution_count = 0; - w->status &= ~STA_2_REC_N_FND; + m_status &= ~STA_2_REC_N_FND; while (revolution_count!=4) { - if (floppy_drive_get_next_id(w->drive, w->hd, &id)) + if (floppy_drive_get_next_id(m_drive, m_hd, &id)) { /* compare track */ - if (id.C == w->track) + if (id.C == m_track) { /* compare head, if we were asked to */ - if (!wd17xx_has_side_select(device) || (id.H == w->head) || (w->head == (UINT8) ~0)) + if (!wd17xx_has_side_select(this) || (id.H == m_head) || (m_head == (UINT8) ~0)) { /* compare id */ - if (id.R == w->sector) + if (id.R == m_sector) { - w->sector_length = 1<<(id.N+7); - w->sector_data_id = id.data_id; + m_sector_length = 1<<(id.N+7); + m_sector_data_id = id.data_id; /* get ddam status */ - w->ddam = id.flags & ID_FLAG_DELETED_DATA; + m_ddam = id.flags & ID_FLAG_DELETED_DATA; /* got record type here */ if (VERBOSE) - logerror("sector found! C:$%02x H:$%02x R:$%02x N:$%02x%s\n", id.C, id.H, id.R, id.N, w->ddam ? " DDAM" : ""); + logerror("sector found! C:$%02x H:$%02x R:$%02x N:$%02x%s\n", id.C, id.H, id.R, id.N, m_ddam ? " DDAM" : ""); return 1; } } @@ -977,7 +834,7 @@ static int wd17xx_locate_sector(device_t *device) } /* index set? */ - if (floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_INDEX)) + if (floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_INDEX)) { /* update revolution count */ revolution_count++; @@ -987,58 +844,54 @@ static int wd17xx_locate_sector(device_t *device) } -static int wd17xx_find_sector(device_t *device) +int wd1770_device::wd17xx_find_sector() { - wd1770_state *w = get_safe_token(device); - if ( wd17xx_locate_sector(device) ) + if ( wd17xx_locate_sector() ) { return 1; } /* record not found */ - w->status |= STA_2_REC_N_FND; + m_status |= STA_2_REC_N_FND; if (VERBOSE) - logerror("track %d sector %d not found!\n", w->track, w->sector); + logerror("track %d sector %d not found!\n", m_track, m_sector); - wd17xx_complete_command(device, DELAY_ERROR); + wd17xx_complete_command(DELAY_ERROR); return 0; } -static void wd17xx_side_compare(device_t *device, UINT8 command) +void wd1770_device::wd17xx_side_compare(UINT8 command) { - wd1770_state *w = get_safe_token(device); - - if (wd17xx_has_side_select(device)) - wd17xx_set_side(device, (command & FDC_SIDE_CMP_T) ? 1 : 0); + if (wd17xx_has_side_select(this)) + set_side((command & FDC_SIDE_CMP_T) ? 1 : 0); if (command & FDC_SIDE_CMP_T) - w->head = (command & FDC_SIDE_CMP_S) ? 1 : 0; + m_head = (command & FDC_SIDE_CMP_S) ? 1 : 0; else - w->head = ~0; + m_head = ~0; } /* read a sector */ -static void wd17xx_read_sector(device_t *device) +void wd1770_device::wd17xx_read_sector() { - wd1770_state *w = get_safe_token(device); - w->data_offset = 0; + m_data_offset = 0; /* side compare? */ - wd17xx_side_compare(device, w->read_cmd); + wd17xx_side_compare(m_read_cmd); - if (wd17xx_find_sector(device)) + if (wd17xx_find_sector()) { - w->data_count = w->sector_length; + m_data_count = m_sector_length; /* read data */ - floppy_drive_read_sector_data(w->drive, w->hd, w->sector_data_id, (char *)w->buffer, w->sector_length); + floppy_drive_read_sector_data(m_drive, m_hd, m_sector_data_id, (char *)m_buffer, m_sector_length); - wd17xx_timed_data_request(device); + wd17xx_timed_data_request(); - w->status |= STA_2_BUSY; - w->busy_count = 0; + m_status |= STA_2_BUSY; + m_busy_count = 0; } } @@ -1050,69 +903,64 @@ when the last byte has been read it causes problems - same byte read again or bytes missed */ /* TJL - I have add a parameter to allow the emulation to specify the delay */ -static void wd17xx_complete_command(device_t *device, int delay) +void wd1770_device::wd17xx_complete_command(int delay) { - wd1770_state *w = get_safe_token(device); - - w->data_count = 0; + m_data_count = 0; - w->hld_count = 2; + m_hld_count = 2; /* set new timer */ - int usecs = wd17xx_dden(device) ? 32 : 16; - w->timer_cmd->adjust(attotime::from_usec(usecs)); + int usecs = wd17xx_dden() ? 32 : 16; + m_timer_cmd->adjust(attotime::from_usec(usecs)); /* Kill onshot read/write sector timers */ - w->timer_rs->adjust(attotime::never); - w->timer_ws->adjust(attotime::never); + m_timer_rs->adjust(attotime::never); + m_timer_ws->adjust(attotime::never); } -static void wd17xx_write_sector(device_t *device) +void wd1770_device::wd17xx_write_sector() { - wd1770_state *w = get_safe_token(device); /* at this point, the disc is write enabled, and data * has been transfered into our buffer - now write it to * the disc image or to the real disc */ /* side compare? */ - wd17xx_side_compare(device, w->write_cmd); + wd17xx_side_compare(m_write_cmd); /* find sector */ - if (wd17xx_find_sector(device)) + if (wd17xx_find_sector()) { - w->data_count = w->sector_length; + m_data_count = m_sector_length; /* write data */ - floppy_drive_write_sector_data(w->drive, w->hd, w->sector_data_id, (char *)w->buffer, w->sector_length, w->write_cmd & 0x01); + floppy_drive_write_sector_data(m_drive, m_hd, m_sector_data_id, (char *)m_buffer, m_sector_length, m_write_cmd & 0x01); } } /* verify the seek operation by looking for a id that has a matching track value */ -static void wd17xx_verify_seek(device_t *device) +void wd1770_device::wd17xx_verify_seek() { UINT8 revolution_count; chrn_id id; - wd1770_state *w = get_safe_token(device); - revolution_count = 0; if (VERBOSE) logerror("doing seek verify\n"); - w->status &= ~STA_1_SEEK_ERR; + m_status &= ~STA_1_SEEK_ERR; /* must be found within 5 revolutions otherwise error */ while (revolution_count!=5) { - if (floppy_drive_get_next_id(w->drive, w->hd, &id)) + if (floppy_drive_get_next_id(m_drive, m_hd, &id)) { /* compare track */ - if (id.C == w->track) + if (id.C == m_track) { if (VERBOSE) logerror("seek verify succeeded!\n"); @@ -1121,14 +969,14 @@ static void wd17xx_verify_seek(device_t *device) } /* index set? */ - if (floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_INDEX)) + if (floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_INDEX)) { /* update revolution count */ revolution_count++; } } - w->status |= STA_1_SEEK_ERR; + m_status |= STA_1_SEEK_ERR; if (VERBOSE) logerror("failed seek verify!\n"); @@ -1137,62 +985,56 @@ static void wd17xx_verify_seek(device_t *device) /* callback to initiate read sector */ -static TIMER_CALLBACK( wd17xx_read_sector_callback ) +TIMER_CALLBACK_MEMBER( wd1770_device::wd17xx_read_sector_callback ) { - device_t *device = (device_t *)ptr; - wd1770_state *w = get_safe_token(device); - /* ok, start that read! */ if (VERBOSE) logerror("wd179x: Read Sector callback.\n"); - if (!floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_READY)) - wd17xx_complete_command(device, DELAY_NOTREADY); + if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY)) + wd17xx_complete_command(DELAY_NOTREADY); else - wd17xx_read_sector(device); + wd17xx_read_sector(); } /* callback to initiate write sector */ -static TIMER_CALLBACK( wd17xx_write_sector_callback ) +TIMER_CALLBACK_MEMBER( wd1770_device::wd17xx_write_sector_callback ) { - device_t *device = (device_t *)ptr; - wd1770_state *w = get_safe_token(device); - /* ok, start that write! */ if (VERBOSE) logerror("wd179x: Write Sector callback.\n"); - if (!floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_READY)) - wd17xx_complete_command(device, DELAY_NOTREADY); + if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY)) + wd17xx_complete_command(DELAY_NOTREADY); else { /* drive write protected? */ - if (floppy_wpt_r(w->drive) == CLEAR_LINE) + if (floppy_wpt_r(m_drive) == CLEAR_LINE) { - w->status |= STA_2_WRITE_PRO; + m_status |= STA_2_WRITE_PRO; - wd17xx_complete_command(device, DELAY_ERROR); + wd17xx_complete_command(DELAY_ERROR); } else { /* side compare? */ - wd17xx_side_compare(device, w->write_cmd); + wd17xx_side_compare(m_write_cmd); /* attempt to find it first before getting data from cpu */ - if (wd17xx_find_sector(device)) + if (wd17xx_find_sector()) { /* request data */ - w->data_offset = 0; - w->data_count = w->sector_length; + m_data_offset = 0; + m_data_count = m_sector_length; - wd17xx_set_drq(device); + wd17xx_set_drq(); - w->status |= STA_2_BUSY; - w->busy_count = 0; + m_status |= STA_2_BUSY; + m_busy_count = 0; } } } @@ -1201,34 +1043,28 @@ static TIMER_CALLBACK( wd17xx_write_sector_callback ) /* setup a timed data request - data request will be triggered in a few usecs time */ -static void wd17xx_timed_data_request(device_t *device) +void wd1770_device::wd17xx_timed_data_request() { - wd1770_state *w = get_safe_token(device); - /* set new timer */ - w->timer_data->adjust(attotime::from_usec(wd17xx_dden(device) ? 128 : 32)); + m_timer_data->adjust(attotime::from_usec(wd17xx_dden() ? 128 : 32)); } /* setup a timed read sector - read sector will be triggered in a few usecs time */ -static void wd17xx_timed_read_sector_request(device_t *device) +void wd1770_device::wd17xx_timed_read_sector_request() { - wd1770_state *w = get_safe_token(device); - /* set new timer */ - w->timer_rs->adjust(attotime::from_usec(w->pause_time)); + m_timer_rs->adjust(attotime::from_usec(m_pause_time)); } /* setup a timed write sector - write sector will be triggered in a few usecs time */ -static void wd17xx_timed_write_sector_request(device_t *device) +void wd1770_device::wd17xx_timed_write_sector_request() { - wd1770_state *w = get_safe_token(device); - /* set new timer */ - w->timer_ws->adjust(attotime::from_usec(w->pause_time)); + m_timer_ws->adjust(attotime::from_usec(m_pause_time)); } @@ -1237,36 +1073,31 @@ static void wd17xx_timed_write_sector_request(device_t *device) ***************************************************************************/ /* use this to determine which drive is controlled by WD */ -void wd17xx_set_drive(device_t *device, UINT8 drive) +void wd1770_device::set_drive(UINT8 drive) { - wd1770_state *w = get_safe_token(device); - if (VERBOSE) logerror("wd17xx_set_drive: $%02x\n", drive); - if (w->intf->floppy_drive_tags[drive] != NULL) + if (m_intf->floppy_drive_tags[drive] != NULL) { - w->drive = device->siblingdevice(w->intf->floppy_drive_tags[drive]); + m_drive = siblingdevice(m_intf->floppy_drive_tags[drive]); } } -void wd17xx_set_side(device_t *device, UINT8 head) +void wd1770_device::set_side(UINT8 head) { - wd1770_state *w = get_safe_token(device); - if (VERBOSE) { - if (head != w->hd) + if (head != m_hd) logerror("wd17xx_set_side: $%02x\n", head); } - w->hd = head; + m_hd = head; } -void wd17xx_set_pause_time(device_t *device, int usec) +void wd1770_device::set_pause_time(int usec) { - wd1770_state *w = get_safe_token(device); - w->pause_time = usec; + m_pause_time = usec; } @@ -1275,278 +1106,259 @@ void wd17xx_set_pause_time(device_t *device, int usec) ***************************************************************************/ /* master reset */ -WRITE_LINE_DEVICE_HANDLER( wd17xx_mr_w ) +WRITE_LINE_MEMBER( wd1770_device::mr_w ) { - wd1770_state *w = get_safe_token(device); - /* reset device when going from high to low */ - if (w->mr && state == CLEAR_LINE) + if (m_mr && state == CLEAR_LINE) { - w->command = 0x03; - w->status &= ~STA_1_NOT_READY; /* ? */ + m_command = 0x03; + m_status &= ~STA_1_NOT_READY; /* ? */ } /* execute restore command when going from low to high */ - if (w->mr == CLEAR_LINE && state) + if (m_mr == CLEAR_LINE && state) { - wd17xx_command_restore(device); - w->sector = 0x01; + wd17xx_command_restore(); + m_sector = 0x01; } - w->mr = state; + m_mr = state; } /* ready and enable precomp (1773 only) */ -WRITE_LINE_DEVICE_HANDLER( wd17xx_rdy_w ) +WRITE_LINE_MEMBER( wd1770_device::rdy_w ) { - wd1770_state *w = get_safe_token(device); - w->rdy = state; + m_rdy = state; } /* motor on, 1770 and 1772 only */ -READ_LINE_DEVICE_HANDLER( wd17xx_mo_r ) +READ_LINE_MEMBER( wd1770_device::mo_r ) { - wd1770_state *w = get_safe_token(device); - return w->mo; + return m_mo; } /* track zero */ -WRITE_LINE_DEVICE_HANDLER( wd17xx_tr00_w ) +WRITE_LINE_MEMBER( wd1770_device::tr00_w ) { - wd1770_state *w = get_safe_token(device); - w->tr00 = state; + m_tr00 = state; } /* index pulse */ -WRITE_LINE_DEVICE_HANDLER( wd17xx_idx_w ) +WRITE_LINE_MEMBER( wd1770_device::idx_w ) { - wd1770_state *w = get_safe_token(device); - w->idx = state; + m_idx = state; - if (!state && w->idx && BIT(w->interrupt, 2)) - wd17xx_set_intrq(device); + if (!state && m_idx && BIT(m_interrupt, 2)) + wd17xx_set_intrq(); } /* write protect status */ -WRITE_LINE_DEVICE_HANDLER( wd17xx_wprt_w ) +WRITE_LINE_MEMBER( wd1770_device::wprt_w ) { - wd1770_state *w = get_safe_token(device); - w->wprt = state; + m_wprt = state; } /* double density enable */ -WRITE_LINE_DEVICE_HANDLER( wd17xx_dden_w ) +WRITE_LINE_MEMBER( wd1770_device::dden_w ) { - wd1770_state *w = get_safe_token(device); - /* not supported on FD1771, FD1792, FD1794, FD1762 and FD1764 */ - if (wd17xx_is_sd_only(device)) + if (wd17xx_is_sd_only(this)) fatalerror("wd17xx_dden_w: double density input not supported on this model!\n"); - else if (!w->in_dden_func.isnull()) + else if (!m_in_dden_func.isnull()) logerror("wd17xx_dden_w: write has no effect because a read handler is already defined!\n"); else - w->dden = state; + m_dden = state; } /* data request */ -READ_LINE_DEVICE_HANDLER( wd17xx_drq_r ) +READ_LINE_MEMBER( wd1770_device::drq_r ) { - wd1770_state *w = get_safe_token(device); - return w->drq; + return m_drq; } /* interrupt request */ -READ_LINE_DEVICE_HANDLER( wd17xx_intrq_r ) +READ_LINE_MEMBER( wd1770_device::intrq_r ) { - wd1770_state *w = get_safe_token(device); - return w->intrq; + return m_intrq; } /* read the FDC status register. This clears IRQ line too */ -READ8_DEVICE_HANDLER( wd17xx_status_r ) +READ8_MEMBER( wd1770_device::status_r ) { - wd1770_state *w = get_safe_token(device); int result; - if (!BIT(w->interrupt, 3)) + if (!BIT(m_interrupt, 3)) { - wd17xx_clear_intrq(device); + wd17xx_clear_intrq(); } /* bit 7, 'not ready' or 'motor on' */ - if (device->type() == WD1770 || device->type() == WD1772) + if (type() == WD1770 || type() == WD1772) { - w->status &= ~STA_1_MOTOR_ON; - w->status |= w->mo << 7; + m_status &= ~STA_1_MOTOR_ON; + m_status |= m_mo << 7; } else { - w->status &= ~STA_1_NOT_READY; - if (!floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_READY)) - w->status |= STA_1_NOT_READY; + m_status &= ~STA_1_NOT_READY; + if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY)) + m_status |= STA_1_NOT_READY; } - result = w->status; + result = m_status; /* type 1 command or force int command? */ - if ((w->command_type==TYPE_I) || (w->command_type==TYPE_IV && ! w->was_busy)) + if ((m_command_type==TYPE_I) || (m_command_type==TYPE_IV && ! m_was_busy)) { result &= ~(STA_1_IPL | STA_1_TRACK0); /* bit 1, index pulse */ - result |= w->idx << 1; + result |= m_idx << 1; /* bit 2, track 0 state, inverted */ - result |= !floppy_tk00_r(w->drive) << 2; + result |= !floppy_tk00_r(m_drive) << 2; - if (w->command_type==TYPE_I) + if (m_command_type==TYPE_I) { - if (w->hld_count) - w->status |= STA_1_HD_LOADED; + if (m_hld_count) + m_status |= STA_1_HD_LOADED; else - w->status &= ~ STA_1_HD_LOADED; + m_status &= ~ STA_1_HD_LOADED; } /* bit 6, write protect, inverted */ - result |= !floppy_wpt_r(w->drive) << 6; + result |= !floppy_wpt_r(m_drive) << 6; } /* eventually set data request bit */ -// w->status |= w->status_drq; +// m_status |= m_status_drq; if (VERBOSE) { - if (w->data_count < 4) - logerror("%s: wd17xx_status_r: $%02X (data_count %d)\n", device->machine().describe_context(), result, w->data_count); + if (m_data_count < 4) + logerror("%s: wd17xx_status_r: $%02X (data_count %d)\n", machine().describe_context(), result, m_data_count); } - return result ^ (wd17xx_has_dal(device) ? 0 : 0xff); + return result ^ (wd17xx_has_dal(this) ? 0 : 0xff); } /* read the FDC track register */ -READ8_DEVICE_HANDLER( wd17xx_track_r ) +READ8_MEMBER( wd1770_device::track_r ) { - wd1770_state *w = get_safe_token(device); - if (VERBOSE) - logerror("%s: wd17xx_track_r: $%02X\n", device->machine().describe_context(), w->track); + logerror("%s: wd17xx_track_r: $%02X\n", machine().describe_context(), m_track); - return w->track ^ (wd17xx_has_dal(device) ? 0 : 0xff); + return m_track ^ (wd17xx_has_dal(this) ? 0 : 0xff); } /* read the FDC sector register */ -READ8_DEVICE_HANDLER( wd17xx_sector_r ) +READ8_MEMBER( wd1770_device::sector_r ) { - wd1770_state *w = get_safe_token(device); - if (VERBOSE) - logerror("%s: wd17xx_sector_r: $%02X\n", device->machine().describe_context(), w->sector); + logerror("%s: wd17xx_sector_r: $%02X\n", machine().describe_context(), m_sector); - return w->sector ^ (wd17xx_has_dal(device) ? 0 : 0xff); + return m_sector ^ (wd17xx_has_dal(this) ? 0 : 0xff); } /* read the FDC data register */ -READ8_DEVICE_HANDLER( wd17xx_data_r ) +READ8_MEMBER( wd1770_device::data_r ) { - wd1770_state *w = get_safe_token(device); - if (VERBOSE_DATA) - logerror("%s: wd17xx_data_r: %02x\n", device->machine().describe_context(), w->data); + logerror("%s: wd17xx_data_r: %02x\n", machine().describe_context(), m_data); /* clear data request */ - wd17xx_clear_drq(device); + wd17xx_clear_drq(); - return w->data ^ (wd17xx_has_dal(device) ? 0 : 0xff); + return m_data ^ (wd17xx_has_dal(this) ? 0 : 0xff); } /* write the FDC command register */ -WRITE8_DEVICE_HANDLER( wd17xx_command_w ) +WRITE8_MEMBER( wd1770_device::command_w ) { - wd1770_state *w = get_safe_token(device); - if (!wd17xx_has_dal(device)) data ^= 0xff; + if (!wd17xx_has_dal(this)) data ^= 0xff; - w->last_command_data = data; + m_last_command_data = data; /* only the WD1770 and WD1772 have a 'motor on' line */ - if (device->type() == WD1770 || device->type() == WD1772) + if (type() == WD1770 || type() == WD1772) { - w->mo = ASSERT_LINE; - floppy_mon_w(w->drive, CLEAR_LINE); + m_mo = ASSERT_LINE; + floppy_mon_w(m_drive, CLEAR_LINE); } - floppy_drive_set_ready_state(w->drive, 1,0); + floppy_drive_set_ready_state(m_drive, 1,0); - if (!BIT(w->interrupt, 3)) + if (!BIT(m_interrupt, 3)) { - wd17xx_clear_intrq(device); + wd17xx_clear_intrq(); } /* clear write protected. On read sector, read track and read dam, write protected bit is clear */ - w->status &= ~((1<<6) | (1<<5) | (1<<4)); + m_status &= ~((1<<6) | (1<<5) | (1<<4)); if ((data & ~FDC_MASK_TYPE_IV) == FDC_FORCE_INT) { if (VERBOSE) - logerror("%s: wd17xx_command_w $%02X FORCE_INT (data_count %d)\n", device->machine().describe_context(), data, w->data_count); + logerror("%s: wd17xx_command_w $%02X FORCE_INT (data_count %d)\n", machine().describe_context(), data, m_data_count); - w->data_count = 0; - w->data_offset = 0; - w->was_busy = w->status & STA_2_BUSY; - w->status &= ~STA_2_BUSY; + m_data_count = 0; + m_data_offset = 0; + m_was_busy = m_status & STA_2_BUSY; + m_status &= ~STA_2_BUSY; - wd17xx_clear_drq(device); + wd17xx_clear_drq(); - if (!BIT(w->interrupt, 3) && BIT(data, 3)) + if (!BIT(m_interrupt, 3) && BIT(data, 3)) { /* set immediate interrupt */ - wd17xx_set_intrq(device); + wd17xx_set_intrq(); } - if (BIT(w->interrupt, 3)) + if (BIT(m_interrupt, 3)) { if (data == FDC_FORCE_INT) { /* clear immediate interrupt */ - w->interrupt = data & 0x0f; + m_interrupt = data & 0x0f; } else { /* keep immediate interrupt */ - w->interrupt = 0x08 | (data & 0x07); + m_interrupt = 0x08 | (data & 0x07); } } else { - w->interrupt = data & 0x0f; + m_interrupt = data & 0x0f; } /* terminate command */ - wd17xx_complete_command(device, DELAY_ERROR); + wd17xx_complete_command(DELAY_ERROR); - w->busy_count = 0; - w->command_type = TYPE_IV; + m_busy_count = 0; + m_command_type = TYPE_IV; return; } if (data & 0x80) { - /*w->status_ipl = 0;*/ + /*m_status_ipl = 0;*/ if ((data & ~FDC_MASK_TYPE_II) == FDC_READ_SEC) { if (VERBOSE) { - logerror("%s: wd17xx_command_w $%02X READ_SEC (", device->machine().describe_context(), data); - logerror("cmd=%02X, trk=%02X, sec=%02X, dat=%02X)\n",w->command,w->track,w->sector,w->data); + logerror("%s: wd17xx_command_w $%02X READ_SEC (", machine().describe_context(), data); + logerror("cmd=%02X, trk=%02X, sec=%02X, dat=%02X)\n",m_command,m_track,m_sector,m_data); } - w->read_cmd = data; - w->command = data & ~FDC_MASK_TYPE_II; - w->command_type = TYPE_II; - w->status &= ~STA_2_LOST_DAT; - w->status |= STA_2_BUSY; - wd17xx_clear_drq(device); + m_read_cmd = data; + m_command = data & ~FDC_MASK_TYPE_II; + m_command_type = TYPE_II; + m_status &= ~STA_2_LOST_DAT; + m_status |= STA_2_BUSY; + wd17xx_clear_drq(); - wd17xx_timed_read_sector_request(device); + wd17xx_timed_read_sector_request(); return; } @@ -1555,18 +1367,18 @@ WRITE8_DEVICE_HANDLER( wd17xx_command_w ) { if (VERBOSE) { - logerror("%s: wd17xx_command_w $%02X WRITE_SEC (", device->machine().describe_context(), data); - logerror("cmd=%02X, trk=%02X, sec=%02X, dat=%02X)\n",w->command,w->track,w->sector,w->data); + logerror("%s: wd17xx_command_w $%02X WRITE_SEC (", machine().describe_context(), data); + logerror("cmd=%02X, trk=%02X, sec=%02X, dat=%02X)\n",m_command,m_track,m_sector,m_data); } - w->write_cmd = data; - w->command = data & ~FDC_MASK_TYPE_II; - w->command_type = TYPE_II; - w->status &= ~STA_2_LOST_DAT; - w->status |= STA_2_BUSY; - wd17xx_clear_drq(device); + m_write_cmd = data; + m_command = data & ~FDC_MASK_TYPE_II; + m_command_type = TYPE_II; + m_status &= ~STA_2_LOST_DAT; + m_status |= STA_2_BUSY; + wd17xx_clear_drq(); - wd17xx_timed_write_sector_request(device); + wd17xx_timed_write_sector_request(); return; } @@ -1574,16 +1386,16 @@ WRITE8_DEVICE_HANDLER( wd17xx_command_w ) if ((data & ~FDC_MASK_TYPE_III) == FDC_READ_TRK) { if (VERBOSE) - logerror("%s: wd17xx_command_w $%02X READ_TRK\n", device->machine().describe_context(), data); + logerror("%s: wd17xx_command_w $%02X READ_TRK\n", machine().describe_context(), data); - w->command = data & ~FDC_MASK_TYPE_III; - w->command_type = TYPE_III; - w->status &= ~STA_2_LOST_DAT; - wd17xx_clear_drq(device); + m_command = data & ~FDC_MASK_TYPE_III; + m_command_type = TYPE_III; + m_status &= ~STA_2_LOST_DAT; + wd17xx_clear_drq(); #if 1 -// w->status = seek(w, w->track, w->head, w->sector); - if (w->status == 0) - read_track(device); +// m_status = seek(w, m_track, m_head, m_sector); + if (m_status == 0) + read_track(); #endif return; } @@ -1591,38 +1403,38 @@ WRITE8_DEVICE_HANDLER( wd17xx_command_w ) if ((data & ~FDC_MASK_TYPE_III) == FDC_WRITE_TRK) { if (VERBOSE) - logerror("%s: wd17xx_command_w $%02X WRITE_TRK\n", device->machine().describe_context(), data); + logerror("%s: wd17xx_command_w $%02X WRITE_TRK\n", machine().describe_context(), data); - w->command_type = TYPE_III; - w->status &= ~STA_2_LOST_DAT; - wd17xx_clear_drq(device); + m_command_type = TYPE_III; + m_status &= ~STA_2_LOST_DAT; + wd17xx_clear_drq(); - if (!floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_READY)) + if (!floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY)) { - wd17xx_complete_command(device, DELAY_NOTREADY); + wd17xx_complete_command(DELAY_NOTREADY); } else { /* drive write protected? */ - if (floppy_wpt_r(w->drive) == CLEAR_LINE) + if (floppy_wpt_r(m_drive) == CLEAR_LINE) { /* yes */ - w->status |= STA_2_WRITE_PRO; + m_status |= STA_2_WRITE_PRO; /* quit command */ - wd17xx_complete_command(device, DELAY_ERROR); + wd17xx_complete_command(DELAY_ERROR); } else { - w->command = data & ~FDC_MASK_TYPE_III; - w->data_offset = 0; - if (wd17xx_is_sd_only(device)) - w->data_count = TRKSIZE_SD; + m_command = data & ~FDC_MASK_TYPE_III; + m_data_offset = 0; + if (wd17xx_is_sd_only(this)) + m_data_count = TRKSIZE_SD; else - w->data_count = wd17xx_dden(device) ? TRKSIZE_SD : TRKSIZE_DD; + m_data_count = wd17xx_dden() ? TRKSIZE_SD : TRKSIZE_DD; - wd17xx_set_drq(device); - w->status |= STA_2_BUSY; - w->busy_count = 0; + wd17xx_set_drq(); + m_status |= STA_2_BUSY; + m_busy_count = 0; } } return; @@ -1631,40 +1443,40 @@ WRITE8_DEVICE_HANDLER( wd17xx_command_w ) if ((data & ~FDC_MASK_TYPE_III) == FDC_READ_DAM) { if (VERBOSE) - logerror("%s: wd17xx_command_w $%02X READ_DAM\n", device->machine().describe_context(), data); + logerror("%s: wd17xx_command_w $%02X READ_DAM\n", machine().describe_context(), data); - w->command_type = TYPE_III; - w->command = data & ~FDC_MASK_TYPE_III; - w->status &= ~STA_2_LOST_DAT; - w->status |= STA_2_BUSY; + m_command_type = TYPE_III; + m_command = data & ~FDC_MASK_TYPE_III; + m_status &= ~STA_2_LOST_DAT; + m_status |= STA_2_BUSY; - wd17xx_clear_drq(device); + wd17xx_clear_drq(); - if (floppy_drive_get_flag_state(w->drive, FLOPPY_DRIVE_READY)) - wd17xx_read_id(device); + if (floppy_drive_get_flag_state(m_drive, FLOPPY_DRIVE_READY)) + wd17xx_read_id(); else - wd17xx_complete_command(device, DELAY_NOTREADY); + wd17xx_complete_command(DELAY_NOTREADY); return; } if (VERBOSE) - logerror("%s: wd17xx_command_w $%02X unknown\n", device->machine().describe_context(), data); + logerror("%s: wd17xx_command_w $%02X unknown\n", machine().describe_context(), data); return; } - w->status |= STA_1_BUSY; + m_status |= STA_1_BUSY; /* clear CRC error */ - w->status &=~STA_1_CRC_ERR; + m_status &=~STA_1_CRC_ERR; if ((data & ~FDC_MASK_TYPE_I) == FDC_RESTORE) { if (VERBOSE) - logerror("%s: wd17xx_command_w $%02X RESTORE\n", device->machine().describe_context(), data); + logerror("%s: wd17xx_command_w $%02X RESTORE\n", machine().describe_context(), data); - wd17xx_command_restore(device); + wd17xx_command_restore(); } if ((data & ~FDC_MASK_TYPE_I) == FDC_SEEK) @@ -1672,72 +1484,72 @@ WRITE8_DEVICE_HANDLER( wd17xx_command_w ) UINT8 newtrack; if (VERBOSE) - logerror("old track: $%02x new track: $%02x\n", w->track, w->data); - w->command_type = TYPE_I; + logerror("old track: $%02x new track: $%02x\n", m_track, m_data); + m_command_type = TYPE_I; /* setup step direction */ - if (w->track < w->data) + if (m_track < m_data) { if (VERBOSE) logerror("direction: +1\n"); - w->direction = 1; + m_direction = 1; } - else if (w->track > w->data) + else if (m_track > m_data) { if (VERBOSE) logerror("direction: -1\n"); - w->direction = -1; + m_direction = -1; } - newtrack = w->data; + newtrack = m_data; if (VERBOSE) - logerror("%s: wd17xx_command_w $%02X SEEK (data_reg is $%02X)\n", device->machine().describe_context(), data, newtrack); + logerror("%s: wd17xx_command_w $%02X SEEK (data_reg is $%02X)\n", machine().describe_context(), data, newtrack); /* reset busy count */ - w->busy_count = 0; + m_busy_count = 0; /* keep stepping until reached track programmed */ - while (w->track != newtrack) + while (m_track != newtrack) { /* update time to simulate seek time busy signal */ - w->busy_count++; + m_busy_count++; /* update track reg */ - w->track += w->direction; + m_track += m_direction; - floppy_drive_seek(w->drive, w->direction); + floppy_drive_seek(m_drive, m_direction); } /* simulate seek time busy signal */ - w->busy_count = 0; //w->busy_count * ((data & FDC_STEP_RATE) + 1); + m_busy_count = 0; //m_busy_count * ((data & FDC_STEP_RATE) + 1); #if 0 - wd17xx_set_intrq(device); + wd17xx_set_intrq(); #endif - wd17xx_set_busy(device, attotime::from_usec(100)); + wd17xx_set_busy(attotime::from_usec(100)); } if ((data & ~(FDC_STEP_UPDATE | FDC_MASK_TYPE_I)) == FDC_STEP) { if (VERBOSE) - logerror("%s: wd17xx_command_w $%02X STEP dir %+d\n", device->machine().describe_context(), data, w->direction); + logerror("%s: wd17xx_command_w $%02X STEP dir %+d\n", machine().describe_context(), data, m_direction); - w->command_type = TYPE_I; + m_command_type = TYPE_I; /* if it is a real floppy, issue a step command */ /* simulate seek time busy signal */ - w->busy_count = 0; //((data & FDC_STEP_RATE) + 1); + m_busy_count = 0; //((data & FDC_STEP_RATE) + 1); - floppy_drive_seek(w->drive, w->direction); + floppy_drive_seek(m_drive, m_direction); if (data & FDC_STEP_UPDATE) - w->track += w->direction; + m_track += m_direction; #if 0 - wd17xx_set_intrq(device); + wd17xx_set_intrq(); #endif - wd17xx_set_busy(device, attotime::from_usec(100)); + wd17xx_set_busy(attotime::from_usec(100)); } @@ -1745,139 +1557,136 @@ WRITE8_DEVICE_HANDLER( wd17xx_command_w ) if ((data & ~(FDC_STEP_UPDATE | FDC_MASK_TYPE_I)) == FDC_STEP_IN) { if (VERBOSE) - logerror("%s: wd17xx_command_w $%02X STEP_IN\n", device->machine().describe_context(), data); + logerror("%s: wd17xx_command_w $%02X STEP_IN\n", machine().describe_context(), data); - w->command_type = TYPE_I; - w->direction = +1; + m_command_type = TYPE_I; + m_direction = +1; /* simulate seek time busy signal */ - w->busy_count = 0; //((data & FDC_STEP_RATE) + 1); + m_busy_count = 0; //((data & FDC_STEP_RATE) + 1); - floppy_drive_seek(w->drive, w->direction); + floppy_drive_seek(m_drive, m_direction); if (data & FDC_STEP_UPDATE) - w->track += w->direction; + m_track += m_direction; #if 0 - wd17xx_set_intrq(device); + wd17xx_set_intrq(); #endif - wd17xx_set_busy(device, attotime::from_usec(100)); + wd17xx_set_busy(attotime::from_usec(100)); } if ((data & ~(FDC_STEP_UPDATE | FDC_MASK_TYPE_I)) == FDC_STEP_OUT) { if (VERBOSE) - logerror("%s: wd17xx_command_w $%02X STEP_OUT\n", device->machine().describe_context(), data); + logerror("%s: wd17xx_command_w $%02X STEP_OUT\n", machine().describe_context(), data); - w->command_type = TYPE_I; - w->direction = -1; + m_command_type = TYPE_I; + m_direction = -1; /* simulate seek time busy signal */ - w->busy_count = 0; //((data & FDC_STEP_RATE) + 1); + m_busy_count = 0; //((data & FDC_STEP_RATE) + 1); /* for now only allows a single drive to be selected */ - floppy_drive_seek(w->drive, w->direction); + floppy_drive_seek(m_drive, m_direction); if (data & FDC_STEP_UPDATE) - w->track += w->direction; + m_track += m_direction; #if 0 - wd17xx_set_intrq(device); + wd17xx_set_intrq(); #endif - wd17xx_set_busy(device, attotime::from_usec(100)); + wd17xx_set_busy(attotime::from_usec(100)); } - if (w->command_type == TYPE_I) + if (m_command_type == TYPE_I) { /* 0 is enable spin up sequence, 1 is disable spin up sequence */ if ((data & FDC_STEP_HDLOAD)==0) { - w->status |= STA_1_HD_LOADED; - w->hld_count = 2; + m_status |= STA_1_HD_LOADED; + m_hld_count = 2; } else - w->status &= ~STA_1_HD_LOADED; + m_status &= ~STA_1_HD_LOADED; if (data & FDC_STEP_VERIFY) { /* verify seek */ - wd17xx_verify_seek(device); + wd17xx_verify_seek(); } } } /* write the FDC track register */ -WRITE8_DEVICE_HANDLER( wd17xx_track_w ) +WRITE8_MEMBER( wd1770_device::track_w ) { - wd1770_state *w = get_safe_token(device); - if (!wd17xx_has_dal(device)) data ^= 0xff; + if (!wd17xx_has_dal(this)) data ^= 0xff; - w->track = data; + m_track = data; if (VERBOSE) - logerror("%s: wd17xx_track_w $%02X\n", device->machine().describe_context(), data); + logerror("%s: wd17xx_track_w $%02X\n", machine().describe_context(), data); } /* write the FDC sector register */ -WRITE8_DEVICE_HANDLER( wd17xx_sector_w ) +WRITE8_MEMBER( wd1770_device::sector_w ) { - wd1770_state *w = get_safe_token(device); - if (!wd17xx_has_dal(device)) data ^= 0xff; + if (!wd17xx_has_dal(this)) data ^= 0xff; - w->sector = data; + m_sector = data; if (VERBOSE) - logerror("%s: wd17xx_sector_w $%02X\n", device->machine().describe_context(), data); + logerror("%s: wd17xx_sector_w $%02X\n", machine().describe_context(), data); } /* write the FDC data register */ -WRITE8_DEVICE_HANDLER( wd17xx_data_w ) +WRITE8_MEMBER( wd1770_device::data_w ) { - wd1770_state *w = get_safe_token(device); - if (!wd17xx_has_dal(device)) data ^= 0xff; + if (!wd17xx_has_dal(this)) data ^= 0xff; - if (w->data_count > 0) + if (m_data_count > 0) { - wd17xx_clear_drq(device); + wd17xx_clear_drq(); /* put byte into buffer */ if (VERBOSE_DATA) - logerror("wd17xx_info buffered data: $%02X at offset %d.\n", data, w->data_offset); + logerror("wd17xx_info buffered data: $%02X at offset %d.\n", data, m_data_offset); - w->buffer[w->data_offset++] = data; + m_buffer[m_data_offset++] = data; - if (--w->data_count < 1) + if (--m_data_count < 1) { - if (w->command == FDC_WRITE_TRK) - write_track(device); + if (m_command == FDC_WRITE_TRK) + write_track(); else - wd17xx_write_sector(device); + wd17xx_write_sector(); - w->data_offset = 0; + m_data_offset = 0; /* Check we should handle the next sector for a multi record write */ - if ( w->command_type == TYPE_II && w->command == FDC_WRITE_SEC && ( w->write_cmd & FDC_MULTI_REC ) ) + if ( m_command_type == TYPE_II && m_command == FDC_WRITE_SEC && ( m_write_cmd & FDC_MULTI_REC ) ) { - w->sector++; - if (wd17xx_locate_sector(device)) + m_sector++; + if (wd17xx_locate_sector()) { - w->data_count = w->sector_length; + m_data_count = m_sector_length; - w->status |= STA_2_BUSY; - w->busy_count = 0; + m_status |= STA_2_BUSY; + m_busy_count = 0; - wd17xx_timed_data_request(device); + wd17xx_timed_data_request(); } } else { - wd17xx_complete_command(device, DELAY_DATADONE); + wd17xx_complete_command(DELAY_DATADONE); if (VERBOSE) logerror("wd17xx_data_w(): multi data write completed\n"); } -// wd17xx_complete_command(device, DELAY_DATADONE); +// wd17xx_complete_command( DELAY_DATADONE); } else { - if (w->command == FDC_WRITE_TRK) + if (m_command == FDC_WRITE_TRK) { /* Process special data values according to WD17xx specification. Note that as CRC values take up two bytes which are written on @@ -1885,7 +1694,7 @@ WRITE8_DEVICE_HANDLER( wd17xx_data_w ) grow larger than what was written from the system. So we need to take the value of data_offset when writing the track. */ - if (wd17xx_dden(device)) + if (wd17xx_dden()) { switch (data) { @@ -1893,15 +1702,15 @@ WRITE8_DEVICE_HANDLER( wd17xx_data_w ) case 0xf6: /* not allowed in FM. */ /* Take back the last write. */ - w->data_offset--; + m_data_offset--; break; case 0xf7: /* Take back the last write. */ - w->data_offset--; + m_data_offset--; /* write two crc bytes */ - w->buffer[w->data_offset++] = (w->crc>>8)&0xff; - w->buffer[w->data_offset++] = (w->crc&0xff); - w->crc_active = FALSE; + m_buffer[m_data_offset++] = (m_crc>>8)&0xff; + m_buffer[m_data_offset++] = (m_crc&0xff); + m_crc_active = FALSE; break; case 0xf8: case 0xf9: @@ -1909,10 +1718,10 @@ WRITE8_DEVICE_HANDLER( wd17xx_data_w ) case 0xfb: case 0xfe: /* Preset crc */ - w->crc = 0xffff; + m_crc = 0xffff; /* AM is included in the CRC */ - w->crc = ccitt_crc16_one(w->crc, data); - w->crc_active = TRUE; + m_crc = ccitt_crc16_one(m_crc, data); + m_crc_active = TRUE; break; case 0xfc: /* Write index mark. No effect here as we do not store clock patterns. @@ -1923,8 +1732,8 @@ WRITE8_DEVICE_HANDLER( wd17xx_data_w ) break; default: /* Byte already written. */ - if (w->crc_active) - w->crc = ccitt_crc16_one(w->crc, data); + if (m_crc_active) + m_crc = ccitt_crc16_one(m_crc, data); } } else /* MFM */ @@ -1933,26 +1742,26 @@ WRITE8_DEVICE_HANDLER( wd17xx_data_w ) { case 0xf5: /* Take back the last write. */ - w->data_offset--; + m_data_offset--; /* Write a1 */ - w->buffer[w->data_offset++] = 0xa1; + m_buffer[m_data_offset++] = 0xa1; /* Preset CRC */ - w->crc = 0xffff; - w->crc_active = TRUE; + m_crc = 0xffff; + m_crc_active = TRUE; break; case 0xf6: /* Take back the last write. */ - w->data_offset--; + m_data_offset--; /* Write c2 */ - w->buffer[w->data_offset++] = 0xc2; + m_buffer[m_data_offset++] = 0xc2; break; case 0xf7: /* Take back the last write. */ - w->data_offset--; + m_data_offset--; /* write two crc bytes */ - w->buffer[w->data_offset++] = (w->crc>>8)&0xff; - w->buffer[w->data_offset++] = (w->crc&0xff); - w->crc_active = FALSE; + m_buffer[m_data_offset++] = (m_crc>>8)&0xff; + m_buffer[m_data_offset++] = (m_crc&0xff); + m_crc_active = FALSE; break; case 0xf8: case 0xf9: @@ -1964,51 +1773,51 @@ WRITE8_DEVICE_HANDLER( wd17xx_data_w ) break; case 0xfe: /* AM is included in the CRC */ - if (w->crc_active) - w->crc = ccitt_crc16_one(w->crc, data); + if (m_crc_active) + m_crc = ccitt_crc16_one(m_crc, data); break; default: /* Byte already written. */ - if (w->crc_active) - w->crc = ccitt_crc16_one(w->crc, data); + if (m_crc_active) + m_crc = ccitt_crc16_one(m_crc, data); } } } /* yes... setup a timed data request */ - wd17xx_timed_data_request(device); + wd17xx_timed_data_request(); } } else { if (VERBOSE) - logerror("%s: wd17xx_data_w $%02X\n", device->machine().describe_context(), data); + logerror("%s: wd17xx_data_w $%02X\n", machine().describe_context(), data); } - w->data = data; + m_data = data; } -READ8_DEVICE_HANDLER( wd17xx_r ) +READ8_MEMBER( wd1770_device::read ) { UINT8 data = 0; switch (offset & 0x03) { - case 0: data = wd17xx_status_r(device, device->machine().driver_data()->generic_space(), 0); break; - case 1: data = wd17xx_track_r(device, device->machine().driver_data()->generic_space(), 0); break; - case 2: data = wd17xx_sector_r(device, device->machine().driver_data()->generic_space(), 0); break; - case 3: data = wd17xx_data_r(device, device->machine().driver_data()->generic_space(), 0); break; + case 0: data = status_r(space, 0); break; + case 1: data = track_r(space, 0); break; + case 2: data = sector_r(space, 0); break; + case 3: data = data_r(space, 0); break; } return data; } -WRITE8_DEVICE_HANDLER( wd17xx_w ) +WRITE8_MEMBER( wd1770_device::write ) { switch (offset & 0x03) { - case 0: wd17xx_command_w(device, device->machine().driver_data()->generic_space(), 0, data); break; - case 1: wd17xx_track_w(device, device->machine().driver_data()->generic_space(), 0, data); break; - case 2: wd17xx_sector_w(device, device->machine().driver_data()->generic_space(), 0, data); break; - case 3: wd17xx_data_w(device, device->machine().driver_data()->generic_space(), 0, data); break; + case 0: command_w(space, 0, data); break; + case 1: track_w(space, 0, data); break; + case 2: sector_w(space, 0, data); break; + case 3: data_w(space, 0, data); break; } } @@ -2017,86 +1826,6 @@ WRITE8_DEVICE_HANDLER( wd17xx_w ) MAME DEVICE INTERFACE ***************************************************************************/ -static DEVICE_START( wd1770 ) -{ - wd1770_state *w = get_safe_token(device); - - assert(device->static_config() != NULL); - - w->intf = (const wd17xx_interface*)device->static_config(); - - w->status = STA_1_TRACK0; - w->pause_time = 1000; - - /* allocate timers */ - w->timer_cmd = device->machine().scheduler().timer_alloc(FUNC(wd17xx_command_callback), (void *)device); - w->timer_data = device->machine().scheduler().timer_alloc(FUNC(wd17xx_data_callback), (void *)device); - w->timer_rs = device->machine().scheduler().timer_alloc(FUNC(wd17xx_read_sector_callback), (void *)device); - w->timer_ws = device->machine().scheduler().timer_alloc(FUNC(wd17xx_write_sector_callback), (void *)device); - - /* resolve callbacks */ - w->in_dden_func.resolve(w->intf->in_dden_func, *device); - w->out_intrq_func.resolve(w->intf->out_intrq_func, *device); - w->out_drq_func.resolve(w->intf->out_drq_func, *device); - - /* stepping rate depends on the clock */ - w->stepping_rate[0] = 6; - w->stepping_rate[1] = 12; - w->stepping_rate[2] = 20; - w->stepping_rate[3] = 30; -} - -static DEVICE_START( wd1772 ) -{ - wd1770_state *w = get_safe_token(device); - - DEVICE_START_CALL(wd1770); - - /* the 1772 has faster track stepping rates */ - w->stepping_rate[0] = 6; - w->stepping_rate[1] = 12; - w->stepping_rate[2] = 2; - w->stepping_rate[3] = 3; -} - -static DEVICE_RESET( wd1770 ) -{ - wd1770_state *w = get_safe_token(device); - int i; - - /* set the default state of some input lines */ - w->mr = ASSERT_LINE; - w->wprt = ASSERT_LINE; - w->dden = ASSERT_LINE; - - for (i = 0; i < 4; i++) - { - if(w->intf->floppy_drive_tags[i]!=NULL) { - device_t *img = NULL; - - img = device->siblingdevice(w->intf->floppy_drive_tags[i]); - - if (img!=NULL) { - floppy_drive_set_controller(img,device); - floppy_drive_set_index_pulse_callback(img, wd17xx_index_pulse_callback); - floppy_drive_set_rpm( img, 300.); - } - } - } - - wd17xx_set_drive(device, 0); - - w->hd = 0; - w->hld_count = 0; - w->sector = 1; - wd17xx_command_restore(device); -} - -void wd17xx_reset(device_t *device) -{ - DEVICE_RESET_CALL( wd1770 ); -} - const device_type FD1771 = &device_creator<fd1771_device>; fd1771_device::fd1771_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) @@ -2246,17 +1975,10 @@ const device_type WD1770 = &device_creator<wd1770_device>; wd1770_device::wd1770_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, WD1770, "WD1770_LEGACY", tag, owner, clock, "wd1770_l", __FILE__) { - m_token = global_alloc_clear(wd1770_state); } wd1770_device::wd1770_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) { - m_token = global_alloc_clear(wd1770_state); -} - -wd1770_device::~wd1770_device() -{ - global_free(m_token); } //------------------------------------------------- @@ -2275,16 +1997,72 @@ void wd1770_device::device_config_complete() void wd1770_device::device_start() { - DEVICE_START_NAME( wd1770 )(this); + assert(static_config() != NULL); + + m_intf = (const wd17xx_interface*)static_config(); + + m_status = STA_1_TRACK0; + m_pause_time = 1000; + + /* allocate timers */ + m_timer_cmd = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(wd1770_device::wd17xx_command_callback),this)); + m_timer_data = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(wd1770_device::wd17xx_data_callback),this)); + m_timer_rs = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(wd1770_device::wd17xx_read_sector_callback),this)); + m_timer_ws = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(wd1770_device::wd17xx_write_sector_callback),this)); + + /* resolve callbacks */ + m_in_dden_func.resolve(m_intf->in_dden_func, *this); + m_out_intrq_func.resolve(m_intf->out_intrq_func, *this); + m_out_drq_func.resolve(m_intf->out_drq_func, *this); + + /* stepping rate depends on the clock */ + m_stepping_rate[0] = 6; + m_stepping_rate[1] = 12; + m_stepping_rate[2] = 20; + m_stepping_rate[3] = 30; + } //------------------------------------------------- // device_reset - device-specific reset //------------------------------------------------- +static void wd17xx_index_pulse_callback(device_t *controller, device_t *img, int state) +{ + wd1770_device *wd = downcast<wd1770_device *>(controller); + wd->index_pulse_callback(img,state); +} + void wd1770_device::device_reset() { - DEVICE_RESET_NAME( wd1770 )(this); + int i; + + /* set the default state of some input lines */ + m_mr = ASSERT_LINE; + m_wprt = ASSERT_LINE; + m_dden = ASSERT_LINE; + + for (i = 0; i < 4; i++) + { + if(m_intf->floppy_drive_tags[i]!=NULL) { + device_t *img = NULL; + + img = siblingdevice(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.); + } + } + } + + set_drive(0); + + m_hd = 0; + m_hld_count = 0; + m_sector = 1; + wd17xx_command_restore(); } @@ -2301,7 +2079,13 @@ wd1772_device::wd1772_device(const machine_config &mconfig, const char *tag, dev void wd1772_device::device_start() { - DEVICE_START_NAME( wd1772 )(this); + wd1770_device::device_start(); + + /* the 1772 has faster track stepping rates */ + m_stepping_rate[0] = 6; + m_stepping_rate[1] = 12; + m_stepping_rate[2] = 2; + m_stepping_rate[3] = 3; } diff --git a/src/emu/machine/wd17xx.h b/src/emu/machine/wd17xx.h index 053a03d4a1f..0362e333193 100644 --- a/src/emu/machine/wd17xx.h +++ b/src/emu/machine/wd17xx.h @@ -12,6 +12,22 @@ /*************************************************************************** + TYPE DEFINITIONS +***************************************************************************/ + +/* Interface */ +struct wd17xx_interface +{ + devcb_read_line in_dden_func; + devcb_write_line out_intrq_func; + devcb_write_line out_drq_func; + const char *floppy_drive_tags[4]; +}; + +extern const wd17xx_interface default_wd17xx_interface; +extern const wd17xx_interface default_wd17xx_interface_2_drives; + +/*************************************************************************** MACROS ***************************************************************************/ @@ -20,18 +36,148 @@ class wd1770_device : public device_t public: wd1770_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); wd1770_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); - virtual ~wd1770_device(); - // access to legacy token - struct wd1770_state *token() const { assert(m_token != NULL); return m_token; } + /* the following are not strictly part of the wd179x hardware/emulation + but will be put here for now until the flopdrv code has been finalised more */ + void set_drive(UINT8); /* set drive wd179x is accessing */ + void set_side(UINT8); /* set side wd179x is accessing */ + + void set_pause_time(int usec); /* default is 40 usec if not set */ + void index_pulse_callback(device_t *img, int state); + + DECLARE_READ8_MEMBER( status_r ); + DECLARE_READ8_MEMBER( track_r ); + DECLARE_READ8_MEMBER( sector_r ); + DECLARE_READ8_MEMBER( data_r ); + + DECLARE_WRITE8_MEMBER( command_w ); + DECLARE_WRITE8_MEMBER( track_w ); + DECLARE_WRITE8_MEMBER( sector_w ); + DECLARE_WRITE8_MEMBER( data_w ); + + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); + + WRITE_LINE_MEMBER( mr_w ); + WRITE_LINE_MEMBER( rdy_w ); + READ_LINE_MEMBER( mo_r ); + WRITE_LINE_MEMBER( tr00_w ); + WRITE_LINE_MEMBER( idx_w ); + WRITE_LINE_MEMBER( wprt_w ); + WRITE_LINE_MEMBER( dden_w ); + READ_LINE_MEMBER( drq_r ); + READ_LINE_MEMBER( intrq_r ); protected: // device-level overrides virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); -private: +protected: + int wd17xx_dden(); + void wd17xx_clear_drq(); + void wd17xx_set_drq(); + void wd17xx_clear_intrq(); + void wd17xx_set_intrq(); + TIMER_CALLBACK_MEMBER( wd17xx_command_callback ); + TIMER_CALLBACK_MEMBER( wd17xx_data_callback ); + void wd17xx_set_busy(attotime duration); + void wd17xx_command_restore(); + void write_track(); + void read_track(); + void wd17xx_read_id(); + int wd17xx_locate_sector(); + int wd17xx_find_sector(); + void wd17xx_side_compare(UINT8 command); + void wd17xx_read_sector(); + void wd17xx_complete_command(int delay); + void wd17xx_write_sector(); + void wd17xx_verify_seek(); + TIMER_CALLBACK_MEMBER( wd17xx_read_sector_callback ); + TIMER_CALLBACK_MEMBER( wd17xx_write_sector_callback ); + void wd17xx_timed_data_request(); + void wd17xx_timed_read_sector_request(); + void wd17xx_timed_write_sector_request(); + // internal state - struct wd1770_state *m_token; + /* callbacks */ + devcb_resolved_read_line m_in_dden_func; + devcb_resolved_write_line m_out_intrq_func; + devcb_resolved_write_line m_out_drq_func; + + /* input lines */ + int m_mr; /* master reset */ + int m_rdy; /* ready, enable precomp */ + int m_tr00; /* track 00 */ + int m_idx; /* index */ + int m_wprt; /* write protect */ + int m_dden; /* double density */ + + /* output lines */ + int m_mo; /* motor on */ + int m_dirc; /* direction */ + int m_drq; /* data request */ + int m_intrq; /* interrupt request */ + + /* register */ + UINT8 m_data_shift; + UINT8 m_data; + UINT8 m_track; + UINT8 m_sector; + UINT8 m_command; + UINT8 m_status; + UINT8 m_interrupt; + + int m_stepping_rate[4]; /* track stepping rate in ms */ + + unsigned short m_crc; /* Holds the current CRC value for write_track CRC calculation */ + int m_crc_active; /* Flag indicating that CRC calculation in write_track is active. */ + + UINT8 m_track_reg; /* value of track register */ + UINT8 m_command_type; /* last command type */ + UINT8 m_head; /* current head # */ + + UINT8 m_read_cmd; /* last read command issued */ + UINT8 m_write_cmd; /* last write command issued */ + INT8 m_direction; /* last step direction */ + UINT8 m_last_command_data; /* last command data */ + + UINT8 m_status_drq; /* status register data request bit */ + UINT8 m_busy_count; /* how long to keep busy bit set */ + + UINT8 m_buffer[6144]; /* I/O buffer (holds up to a whole track) */ + UINT32 m_data_offset; /* offset into I/O buffer */ + INT32 m_data_count; /* transfer count from/into I/O buffer */ + + UINT8 *m_fmt_sector_data[256]; /* pointer to data after formatting a track */ + + UINT8 m_dam_list[256][4]; /* list of data address marks while formatting */ + int m_dam_data[256]; /* offset to data inside buffer while formatting */ + int m_dam_cnt; /* valid number of entries in the dam_list */ + UINT16 m_sector_length; /* sector length (byte) */ + + UINT8 m_ddam; /* ddam of sector found - used when reading */ + UINT8 m_sector_data_id; + int m_data_direction; + + int m_hld_count; /* head loaded counter */ + + /* timers to delay execution/completion of commands */ + emu_timer *m_timer_cmd, *m_timer_data, *m_timer_rs, *m_timer_ws; + + /* this is the drive currently selected */ + device_t *m_drive; + + /* this is the head currently selected */ + UINT8 m_hd; + + /* pause time when writing/reading sector */ + int m_pause_time; + + /* Were we busy when we received a FORCE_INT command */ + UINT8 m_was_busy; + + /* Pointer to interface */ + const wd17xx_interface *m_intf; }; extern ATTR_DEPRECATED const device_type WD1770; @@ -223,63 +369,6 @@ public: extern ATTR_DEPRECATED const device_type MB8877; - - - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -/* Interface */ -struct wd17xx_interface -{ - devcb_read_line in_dden_func; - devcb_write_line out_intrq_func; - devcb_write_line out_drq_func; - const char *floppy_drive_tags[4]; -}; - - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ -void wd17xx_reset(device_t *device); - -/* the following are not strictly part of the wd179x hardware/emulation -but will be put here for now until the flopdrv code has been finalised more */ -void wd17xx_set_drive(device_t *device, UINT8); /* set drive wd179x is accessing */ -void wd17xx_set_side(device_t *device, UINT8); /* set side wd179x is accessing */ - -void wd17xx_set_pause_time(device_t *device, int usec); /* default is 40 usec if not set */ -void wd17xx_index_pulse_callback(device_t *controller, device_t *img, int state); - -DECLARE_READ8_DEVICE_HANDLER( wd17xx_status_r ); -DECLARE_READ8_DEVICE_HANDLER( wd17xx_track_r ); -DECLARE_READ8_DEVICE_HANDLER( wd17xx_sector_r ); -DECLARE_READ8_DEVICE_HANDLER( wd17xx_data_r ); - -DECLARE_WRITE8_DEVICE_HANDLER( wd17xx_command_w ); -DECLARE_WRITE8_DEVICE_HANDLER( wd17xx_track_w ); -DECLARE_WRITE8_DEVICE_HANDLER( wd17xx_sector_w ); -DECLARE_WRITE8_DEVICE_HANDLER( wd17xx_data_w ); - -DECLARE_READ8_DEVICE_HANDLER( wd17xx_r ); -DECLARE_WRITE8_DEVICE_HANDLER( wd17xx_w ); - -WRITE_LINE_DEVICE_HANDLER( wd17xx_mr_w ); -WRITE_LINE_DEVICE_HANDLER( wd17xx_rdy_w ); -READ_LINE_DEVICE_HANDLER( wd17xx_mo_r ); -WRITE_LINE_DEVICE_HANDLER( wd17xx_tr00_w ); -WRITE_LINE_DEVICE_HANDLER( wd17xx_idx_w ); -WRITE_LINE_DEVICE_HANDLER( wd17xx_wprt_w ); -WRITE_LINE_DEVICE_HANDLER( wd17xx_dden_w ); -READ_LINE_DEVICE_HANDLER( wd17xx_drq_r ); -READ_LINE_DEVICE_HANDLER( wd17xx_intrq_r ); - -extern const wd17xx_interface default_wd17xx_interface; -extern const wd17xx_interface default_wd17xx_interface_2_drives; - - /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ diff --git a/src/mame/includes/archimds.h b/src/mame/includes/archimds.h index cb77c9bbfba..a7e668b6d64 100644 --- a/src/mame/includes/archimds.h +++ b/src/mame/includes/archimds.h @@ -91,7 +91,7 @@ public: protected: required_device<cpu_device> m_maincpu; optional_device<i2cmem_device> m_i2cmem; - optional_device<device_t> m_wd1772; + optional_device<wd1772_device> m_wd1772; required_memory_region m_region_maincpu; required_memory_region m_region_vram; required_device<screen_device> m_screen; diff --git a/src/mame/machine/archimds.c b/src/mame/machine/archimds.c index 18374cc53ff..7e93bb2993f 100644 --- a/src/mame/machine/archimds.c +++ b/src/mame/machine/archimds.c @@ -664,7 +664,7 @@ READ32_MEMBER(archimedes_state::archimedes_ioc_r) case 1: if (m_wd1772) { logerror("17XX: R @ addr %x mask %08x\n", offset*4, mem_mask); - return wd17xx_data_r(m_wd1772, space, offset&0xf); + return m_wd1772->data_r(space, offset&0xf); } else { logerror("Read from FDC device?\n"); return 0; @@ -719,7 +719,7 @@ WRITE32_MEMBER(archimedes_state::archimedes_ioc_w) case 1: if (m_wd1772) { logerror("17XX: %x to addr %x mask %08x\n", data, offset*4, mem_mask); - wd17xx_data_w(m_wd1772, space, offset&0xf, data&0xff); + m_wd1772->data_w(space, offset&0xf, data&0xff); } else { logerror("Write to FDC device?\n"); } @@ -738,16 +738,16 @@ WRITE32_MEMBER(archimedes_state::archimedes_ioc_w) switch(ioc_addr & 0xfffc) { case 0x18: // latch B - wd17xx_dden_w(m_wd1772, BIT(data, 1)); + m_wd1772->dden_w(BIT(data, 1)); return; case 0x40: // latch A - if (data & 1) { wd17xx_set_drive(m_wd1772,0); } - if (data & 2) { wd17xx_set_drive(m_wd1772,1); } - if (data & 4) { wd17xx_set_drive(m_wd1772,2); } - if (data & 8) { wd17xx_set_drive(m_wd1772,3); } + if (data & 1) { m_wd1772->set_drive(0); } + if (data & 2) { m_wd1772->set_drive(1); } + if (data & 4) { m_wd1772->set_drive(2); } + if (data & 8) { m_wd1772->set_drive(3); } - wd17xx_set_side(m_wd1772,(data & 0x10)>>4); + m_wd1772->set_side((data & 0x10)>>4); //bit 5 is motor on return; } diff --git a/src/mess/drivers/apf.c b/src/mess/drivers/apf.c index 27f36938fba..f8f7a521b5a 100644 --- a/src/mess/drivers/apf.c +++ b/src/mess/drivers/apf.c @@ -258,7 +258,7 @@ WRITE8_MEMBER( apf_state::apf_dischw_w) /* bit 3 is index of drive to select */ UINT8 drive = BIT(data, 3); - wd17xx_set_drive(m_fdc, drive); + 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); @@ -293,7 +293,7 @@ static ADDRESS_MAP_START( apfimag_map, AS_PROGRAM, 8, apf_state ) AM_RANGE( 0x6000, 0x63ff) AM_MIRROR(0x03fc) AM_DEVREADWRITE("pia1", pia6821_device, read, write) // These need to be confirmed, disk does not work AM_RANGE( 0x6400, 0x64ff) AM_READWRITE(serial_r, serial_w) - AM_RANGE( 0x6500, 0x6503) AM_DEVREADWRITE_LEGACY("fdc", wd17xx_r, wd17xx_w) + AM_RANGE( 0x6500, 0x6503) AM_DEVREADWRITE("fdc", fd1771_device, read, write) AM_RANGE( 0x6600, 0x6600) AM_WRITE(apf_dischw_w) AM_RANGE( 0xa000, 0xbfff) AM_RAM // standard AM_RANGE( 0xc000, 0xdfff) AM_RAM // expansion diff --git a/src/mess/drivers/fm7.c b/src/mess/drivers/fm7.c index ef6b3333304..da5cd0f0a62 100644 --- a/src/mess/drivers/fm7.c +++ b/src/mess/drivers/fm7.c @@ -432,19 +432,19 @@ WRITE_LINE_MEMBER(fm7_state::fm7_fdc_drq_w) READ8_MEMBER(fm7_state::fm7_fdc_r) { - device_t* dev = machine().device("fdc"); + mb8877_device *fdc = machine().device<mb8877_device>("fdc"); UINT8 ret = 0; switch(offset) { case 0: - return wd17xx_status_r(dev,space, offset); + return fdc->status_r(space, offset); case 1: - return wd17xx_track_r(dev,space, offset); + return fdc->track_r(space, offset); case 2: - return wd17xx_sector_r(dev,space, offset); + return fdc->sector_r(space, offset); case 3: - return wd17xx_data_r(dev,space, offset); + return fdc->data_r(space, offset); case 4: return m_fdc_side | 0xfe; case 5: @@ -466,24 +466,24 @@ READ8_MEMBER(fm7_state::fm7_fdc_r) WRITE8_MEMBER(fm7_state::fm7_fdc_w) { - device_t* dev = machine().device("fdc"); + mb8877_device *fdc = machine().device<mb8877_device>("fdc"); switch(offset) { case 0: - wd17xx_command_w(dev,space, offset,data); + fdc->command_w(space, offset,data); break; case 1: - wd17xx_track_w(dev,space, offset,data); + fdc->track_w(space, offset,data); break; case 2: - wd17xx_sector_w(dev,space, offset,data); + fdc->sector_w(space, offset,data); break; case 3: - wd17xx_data_w(dev,space, offset,data); + fdc->data_w(space, offset,data); break; case 4: m_fdc_side = data & 0x01; - wd17xx_set_side(dev,data & 0x01); + fdc->set_side(data & 0x01); logerror("FDC: wrote %02x to 0x%04x (side)\n",data,offset+0xfd18); break; case 5: @@ -494,7 +494,7 @@ WRITE8_MEMBER(fm7_state::fm7_fdc_w) } else { - wd17xx_set_drive(dev,data & 0x03); + 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); logerror("FDC: wrote %02x to 0x%04x (drive)\n",data,offset+0xfd18); diff --git a/src/mess/drivers/fmtowns.c b/src/mess/drivers/fmtowns.c index 629cbd57073..cd7070feb43 100644 --- a/src/mess/drivers/fmtowns.c +++ b/src/mess/drivers/fmtowns.c @@ -499,20 +499,19 @@ WRITE_LINE_MEMBER( towns_state::mb8877a_drq_w ) READ8_MEMBER(towns_state::towns_floppy_r) { - device_t* fdc = m_fdc; device_image_interface* image; UINT8 ret; switch(offset) { case 0x00: - return wd17xx_status_r(fdc,space, offset/2); + return m_fdc->status_r(space, offset/2); case 0x02: - return wd17xx_track_r(fdc,space, offset/2); + return m_fdc->track_r(space, offset/2); case 0x04: - return wd17xx_sector_r(fdc,space, offset/2); + return m_fdc->sector_r(space, offset/2); case 0x06: - return wd17xx_data_r(fdc,space, offset/2); + return m_fdc->data_r(space, offset/2); case 0x08: // selected drive status? //logerror("FDC: read from offset 0x08\n"); ret = 0x80; // always set @@ -548,8 +547,6 @@ READ8_MEMBER(towns_state::towns_floppy_r) WRITE8_MEMBER(towns_state::towns_floppy_w) { - device_t* fdc = m_fdc; - switch(offset) { case 0x00: @@ -558,16 +555,16 @@ WRITE8_MEMBER(towns_state::towns_floppy_w) return; if(data == 0xfe) return; - wd17xx_command_w(fdc,space, offset/2,data); + m_fdc->command_w(space, offset/2,data); break; case 0x02: - wd17xx_track_w(fdc,space, offset/2,data); + m_fdc->track_w(space, offset/2,data); break; case 0x04: - wd17xx_sector_w(fdc,space, offset/2,data); + m_fdc->sector_w(space, offset/2,data); break; case 0x06: - wd17xx_data_w(fdc,space, offset/2,data); + m_fdc->data_w(space, offset/2,data); break; case 0x08: // bit 5 - CLKSEL @@ -576,8 +573,8 @@ WRITE8_MEMBER(towns_state::towns_floppy_w) floppy_mon_w(floppy_get_device(space.machine(), m_towns_selected_drive-1), !BIT(data, 4)); floppy_drive_set_ready_state(floppy_get_device(space.machine(), m_towns_selected_drive-1), data & 0x10,0); } - wd17xx_set_side(fdc,(data & 0x04)>>2); - wd17xx_dden_w(fdc, BIT(~data, 1)); + m_fdc->set_side((data & 0x04)>>2); + m_fdc->dden_w(BIT(~data, 1)); m_towns_fdc_irq6mask = data & 0x01; logerror("FDC: write %02x to offset 0x08\n",data); @@ -590,19 +587,19 @@ WRITE8_MEMBER(towns_state::towns_floppy_w) break; case 0x01: m_towns_selected_drive = 1; - wd17xx_set_drive(fdc,0); + m_fdc->set_drive(0); break; case 0x02: m_towns_selected_drive = 2; - wd17xx_set_drive(fdc,1); + m_fdc->set_drive(1); break; case 0x04: m_towns_selected_drive = 3; - wd17xx_set_drive(fdc,2); + m_fdc->set_drive(2); break; case 0x08: m_towns_selected_drive = 4; - wd17xx_set_drive(fdc,3); + m_fdc->set_drive(3); break; } logerror("FDC: drive select %02x\n",data); @@ -613,15 +610,13 @@ WRITE8_MEMBER(towns_state::towns_floppy_w) } READ16_MEMBER(towns_state::towns_fdc_dma_r) -{ - device_t* fdc = m_fdc; - return wd17xx_data_r(fdc,generic_space(), 0); +{ + return m_fdc->data_r(generic_space(), 0); } WRITE16_MEMBER(towns_state::towns_fdc_dma_w) { - device_t* fdc = m_fdc; - wd17xx_data_w(fdc,generic_space(), 0,data); + m_fdc->data_w(generic_space(), 0,data); } /* @@ -2601,7 +2596,7 @@ void marty_state::driver_start() void towns_state::machine_reset() { address_space &program = m_maincpu->space(AS_PROGRAM); - m_fdc = machine().device("fdc"); + m_fdc = machine().device<mb8877_device>("fdc"); m_messram = m_ram; m_cdrom = machine().device<cdrom_image_device>("cdrom"); m_cdda = machine().device<cdda_device>("cdda"); diff --git a/src/mess/drivers/mbc200.c b/src/mess/drivers/mbc200.c index d1941b0e33f..b541abbd996 100644 --- a/src/mess/drivers/mbc200.c +++ b/src/mess/drivers/mbc200.c @@ -85,7 +85,7 @@ static ADDRESS_MAP_START( mbc200_io , AS_IO, 8, mbc200_state) ADDRESS_MAP_GLOBAL_MASK(0xff) AM_RANGE(0xe0, 0xe0) AM_DEVREADWRITE("i8251_1", i8251_device, data_r, data_w) AM_RANGE(0xe1, 0xe1) AM_DEVREADWRITE("i8251_1", i8251_device, status_r, control_w) - AM_RANGE(0xe4, 0xe7) AM_DEVREADWRITE_LEGACY("fdc", wd17xx_r, wd17xx_w) + AM_RANGE(0xe4, 0xe7) AM_DEVREADWRITE("fdc", mb8876_device, read, write) AM_RANGE(0xea, 0xea) AM_READ(ppi_hs_r) AM_RANGE(0xe8, 0xeb) AM_DEVREADWRITE("ppi8255_2", i8255_device, read, write) AM_RANGE(0xec, 0xec) AM_DEVREADWRITE("i8251_2", i8251_device, data_r, data_w) diff --git a/src/mess/drivers/ms0515.c b/src/mess/drivers/ms0515.c index ef9b8447275..7de11d248f9 100644 --- a/src/mess/drivers/ms0515.c +++ b/src/mess/drivers/ms0515.c @@ -70,10 +70,10 @@ static ADDRESS_MAP_START(ms0515_mem, AS_PROGRAM, 16, ms0515_state) AM_RANGE(0177600, 0177607) AM_DEVREADWRITE8("ppi8255_1", i8255_device, read, write, 0x00ff) - AM_RANGE(0177640, 0177641) AM_DEVREADWRITE8_LEGACY("vg93", wd17xx_status_r, wd17xx_command_w,0x00ff) - AM_RANGE(0177642, 0177643) AM_DEVREADWRITE8_LEGACY("vg93", wd17xx_track_r, wd17xx_track_w,0x00ff) - AM_RANGE(0177644, 0177645) AM_DEVREADWRITE8_LEGACY("vg93", wd17xx_sector_r, wd17xx_sector_w,0x00ff) - AM_RANGE(0177646, 0177647) AM_DEVREADWRITE8_LEGACY("vg93", wd17xx_data_r, wd17xx_data_w,0x00ff) + AM_RANGE(0177640, 0177641) AM_DEVREADWRITE8("vg93", fd1793_device, status_r, command_w,0x00ff) + AM_RANGE(0177642, 0177643) AM_DEVREADWRITE8("vg93", fd1793_device, track_r, track_w,0x00ff) + AM_RANGE(0177644, 0177645) AM_DEVREADWRITE8("vg93", fd1793_device, sector_r, sector_w,0x00ff) + AM_RANGE(0177646, 0177647) AM_DEVREADWRITE8("vg93", fd1793_device, data_r, data_w,0x00ff) //AM_RANGE(0177700, 0177701) // read data //AM_RANGE(0177720, 0177721) // write data // protocol S2 diff --git a/src/mess/drivers/myb3k.c b/src/mess/drivers/myb3k.c index 193e7832cb6..ba169605f98 100644 --- a/src/mess/drivers/myb3k.c +++ b/src/mess/drivers/myb3k.c @@ -126,10 +126,10 @@ WRITE8_MEMBER( myb3k_state::myb3k_video_mode_w ) WRITE8_MEMBER( myb3k_state::myb3k_fdc_output_w ) { /* TODO: complete guesswork! (it just does a 0x24 -> 0x20 in there) */ - wd17xx_set_drive(m_fdc, data & 3); + 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); - //wd17xx_set_side(m_fdc, (data & 0x10)>>4); + //m_fdc->set_side((data & 0x10)>>4); } static ADDRESS_MAP_START(myb3k_map, AS_PROGRAM, 8, myb3k_state) @@ -149,7 +149,7 @@ static ADDRESS_MAP_START(myb3k_io, AS_IO, 8, myb3k_state) AM_RANGE(0x06, 0x06) AM_READ_PORT("DSW2") AM_RANGE(0x1c, 0x1c) AM_WRITE(myb3k_6845_address_w) AM_RANGE(0x1d, 0x1d) AM_WRITE(myb3k_6845_data_w) - AM_RANGE(0x20, 0x23) AM_DEVREADWRITE_LEGACY("fdc",wd17xx_r,wd17xx_w) //FDC, almost likely wd17xx + AM_RANGE(0x20, 0x23) AM_DEVREADWRITE("fdc", mb8877_device, read, write) //FDC, almost likely wd17xx AM_RANGE(0x24, 0x24) AM_WRITE(myb3k_fdc_output_w) // AM_RANGE(0x520,0x524) mirror of above ADDRESS_MAP_END diff --git a/src/mess/drivers/mz2000.c b/src/mess/drivers/mz2000.c index 9bcc5bc9b8d..b9305d6013d 100644 --- a/src/mess/drivers/mz2000.c +++ b/src/mess/drivers/mz2000.c @@ -120,7 +120,7 @@ public: protected: required_device<cpu_device> m_maincpu; - required_device<device_t> m_mb8877a; + required_device<mb8877_device> m_mb8877a; required_device<pit8253_device> m_pit8253; required_device<beep_device> m_beeper; required_memory_region m_region_tvram; @@ -343,7 +343,7 @@ WRITE8_MEMBER(mz2000_state::mz2000_gvram_bank_w) READ8_MEMBER(mz2000_state::mz2000_wd17xx_r) { if(m_has_fdc) - return wd17xx_r(m_mb8877a, space, offset) ^ 0xff; + return m_mb8877a->read(space, offset) ^ 0xff; return 0xff; } @@ -351,7 +351,7 @@ READ8_MEMBER(mz2000_state::mz2000_wd17xx_r) WRITE8_MEMBER(mz2000_state::mz2000_wd17xx_w) { if(m_has_fdc) - wd17xx_w(m_mb8877a, space, offset, data ^ 0xff); + m_mb8877a->write(space, offset, data ^ 0xff); } WRITE8_MEMBER(mz2000_state::mz2000_fdc_w) @@ -359,12 +359,12 @@ WRITE8_MEMBER(mz2000_state::mz2000_fdc_w) switch(offset+0xdc) { case 0xdc: - wd17xx_set_drive(m_mb8877a,data & 3); + 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); break; case 0xdd: - wd17xx_set_side(m_mb8877a,(data & 1)); + m_mb8877a->set_side((data & 1)); break; } } diff --git a/src/mess/drivers/mz2500.c b/src/mess/drivers/mz2500.c index bfbd7fb8ef6..14308101b55 100644 --- a/src/mess/drivers/mz2500.c +++ b/src/mess/drivers/mz2500.c @@ -1184,17 +1184,17 @@ WRITE8_MEMBER(mz2500_state::mz2500_irq_data_w) WRITE8_MEMBER(mz2500_state::mz2500_fdc_w) { - device_t* dev = machine().device("mb8877a"); + mb8877_device *fdc = machine().device<mb8877_device>("mb8877a"); switch(offset+0xdc) { case 0xdc: - wd17xx_set_drive(dev,data & 3); + 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); break; case 0xdd: - wd17xx_set_side(dev,(data & 1)); + fdc->set_side((data & 1)); break; } } @@ -1282,14 +1282,14 @@ WRITE8_MEMBER(mz2500_state::palette4096_io_w) READ8_MEMBER(mz2500_state::mz2500_wd17xx_r) { - device_t *device = machine().device("mb8877a"); - return wd17xx_r(device, space, offset) ^ m_fdc_reverse; + mb8877_device *fdc = machine().device<mb8877_device>("mb8877a"); + return fdc->read(space, offset) ^ m_fdc_reverse; } WRITE8_MEMBER(mz2500_state::mz2500_wd17xx_w) { - device_t *device = machine().device("mb8877a"); - wd17xx_w(device, space, offset, data ^ m_fdc_reverse); + mb8877_device *fdc = machine().device<mb8877_device>("mb8877a"); + fdc->write(space, offset, data ^ m_fdc_reverse); } READ8_MEMBER(mz2500_state::mz2500_bplane_latch_r) diff --git a/src/mess/drivers/nascom1.c b/src/mess/drivers/nascom1.c index a9b74d45e75..14abe9a1e40 100644 --- a/src/mess/drivers/nascom1.c +++ b/src/mess/drivers/nascom1.c @@ -105,7 +105,7 @@ static ADDRESS_MAP_START( nascom2_io, AS_IO, 8, nascom1_state ) AM_RANGE(0x01, 0x01) AM_READWRITE(nascom1_port_01_r, nascom1_port_01_w) AM_RANGE(0x02, 0x02) AM_READ(nascom1_port_02_r) AM_RANGE(0x04, 0x07) AM_DEVREADWRITE("z80pio", z80pio_device, read, write ) - AM_RANGE(0xe0, 0xe3) AM_DEVREADWRITE_LEGACY("wd1793", wd17xx_r, wd17xx_w) + AM_RANGE(0xe0, 0xe3) AM_DEVREADWRITE("wd1793", fd1793_device, read, write) AM_RANGE(0xe4, 0xe4) AM_READWRITE(nascom2_fdc_select_r, nascom2_fdc_select_w) AM_RANGE(0xe5, 0xe5) AM_READ(nascom2_fdc_status_r) ADDRESS_MAP_END diff --git a/src/mess/drivers/osbexec.c b/src/mess/drivers/osbexec.c index 20f3c8e9e39..7d1b09bd542 100644 --- a/src/mess/drivers/osbexec.c +++ b/src/mess/drivers/osbexec.c @@ -213,7 +213,7 @@ static ADDRESS_MAP_START( osbexec_io, AS_IO, 8, osbexec_state ) ADDRESS_MAP_UNMAP_HIGH AM_RANGE( 0x00, 0x03 ) AM_MIRROR( 0xff00 ) AM_DEVREADWRITE( "pia_0", pia6821_device, read, write) /* 6821 PIA @ UD12 */ /* 0x04 - 0x07 - 8253 @UD1 */ - AM_RANGE( 0x08, 0x0B ) AM_MIRROR( 0xff00 ) AM_DEVREADWRITE_LEGACY("mb8877", wd17xx_r, wd17xx_w ) /* MB8877 @ UB17 input clock = 1MHz */ + AM_RANGE( 0x08, 0x0B ) AM_MIRROR( 0xff00 ) AM_DEVREADWRITE("mb8877", mb8877_device, read, write ) /* MB8877 @ UB17 input clock = 1MHz */ AM_RANGE( 0x0C, 0x0F ) AM_MIRROR( 0xff00 ) AM_DEVREADWRITE("sio", z80sio2_device, ba_cd_r, ba_cd_w ) /* SIO @ UD4 */ AM_RANGE( 0x10, 0x13 ) AM_MIRROR( 0xff00 ) AM_DEVREADWRITE( "pia_1", pia6821_device, read, write) /* 6821 PIA @ UD8 */ AM_RANGE( 0x14, 0x17 ) AM_MIRROR( 0xff00 ) AM_MASK( 0xff00 ) AM_READ(osbexec_kbd_r ) /* KBD */ @@ -384,14 +384,14 @@ WRITE8_MEMBER(osbexec_state::osbexec_pia0_b_w) switch ( data & 0x06 ) { case 0x02: - wd17xx_set_drive( m_mb8877, 1 ); + m_mb8877->set_drive( 1 ); break; case 0x04: - wd17xx_set_drive( m_mb8877, 0 ); + m_mb8877->set_drive( 0 ); break; } - wd17xx_dden_w( m_mb8877, ( data & 0x01 ) ? 1 : 0 ); + m_mb8877->dden_w(( data & 0x01 ) ? 1 : 0 ); } diff --git a/src/mess/drivers/pk8020.c b/src/mess/drivers/pk8020.c index e4f9c1b95cc..dabab42bfde 100644 --- a/src/mess/drivers/pk8020.c +++ b/src/mess/drivers/pk8020.c @@ -11,7 +11,6 @@ #include "emu.h" #include "cpu/i8085/i8085.h" #include "machine/i8255.h" -#include "machine/wd17xx.h" #include "imagedev/flopdrv.h" #include "formats/basicdsk.h" #include "includes/pk8020.h" diff --git a/src/mess/drivers/ql.c b/src/mess/drivers/ql.c index 691a8796d4b..435c09d2e92 100644 --- a/src/mess/drivers/ql.c +++ b/src/mess/drivers/ql.c @@ -272,10 +272,10 @@ READ8_MEMBER( ql_state::disk_io_r ) switch (offset) { - case 0x0000 : result=wd17xx_r(m_fdc, space, offset); break; - case 0x0001 : result=wd17xx_r(m_fdc, space, offset); break; - case 0x0002 : result=wd17xx_r(m_fdc, space, offset); break; - case 0x0003 : result=wd17xx_r(m_fdc, space, offset); break; + case 0x0000 : result=m_fdc->read(space, offset); break; + case 0x0001 : result=m_fdc->read(space, offset); break; + case 0x0002 : result=m_fdc->read(space, offset); break; + case 0x0003 : result=m_fdc->read(space, offset); break; default : logerror("%s DiskIO undefined read : from %08X\n",machine().describe_context(),m_disk_io_base+offset); break; } @@ -289,10 +289,10 @@ WRITE8_MEMBER( ql_state::disk_io_w ) switch (offset) { - case 0x0000 : wd17xx_w(m_fdc, space, offset, data); break; - case 0x0001 : wd17xx_w(m_fdc, space, offset, data); break; - case 0x0002 : wd17xx_w(m_fdc, space, offset, data); break; - case 0x0003 : wd17xx_w(m_fdc, space, offset, data); break; + case 0x0000 : m_fdc->write(space, offset, data); break; + case 0x0001 : m_fdc->write(space, offset, data); break; + case 0x0002 : m_fdc->write(space, offset, data); break; + case 0x0003 : m_fdc->write(space, offset, data); break; case 0x0004 : if(m_disk_type==DISK_TYPE_SANDY) sandy_set_control(data);break; case 0x0008 : if(m_disk_type==DISK_TYPE_SANDY) @@ -332,12 +332,12 @@ READ8_MEMBER( ql_state::cart_rom_r ) void ql_state::trump_card_set_control(UINT8 data) { if(data & TRUMP_DRIVE0_MASK) - wd17xx_set_drive(m_fdc,0); + m_fdc->set_drive(0); if(data & TRUMP_DRIVE1_MASK) - wd17xx_set_drive(m_fdc,1); + m_fdc->set_drive(1); - wd17xx_set_side(m_fdc,(data & TRUMP_SIDE_MASK) >> TRUMP_SIDE_SHIFT); + m_fdc->set_side((data & TRUMP_SIDE_MASK) >> TRUMP_SIDE_SHIFT); } void ql_state::sandy_set_control(UINT8 data) @@ -347,12 +347,12 @@ void ql_state::sandy_set_control(UINT8 data) m_disk_io_byte=data; if(data & SANDY_DRIVE0_MASK) - wd17xx_set_drive(m_fdc,0); + m_fdc->set_drive(0); if(data & SANDY_DRIVE1_MASK) - wd17xx_set_drive(m_fdc,1); + m_fdc->set_drive(1); - wd17xx_set_side(m_fdc,(data & SANDY_SIDE_MASK) >> SANDY_SIDE_SHIFT); + m_fdc->set_side((data & SANDY_SIDE_MASK) >> SANDY_SIDE_SHIFT); if ((data & SANDY_SIDE_MASK) & (LOG_DISK_READ | LOG_DISK_WRITE)) { logerror("Accessing side 1\n"); diff --git a/src/mess/drivers/rainbow.c b/src/mess/drivers/rainbow.c index 53be7ae0b95..d31cb9f2635 100644 --- a/src/mess/drivers/rainbow.c +++ b/src/mess/drivers/rainbow.c @@ -459,10 +459,10 @@ static ADDRESS_MAP_START( rainbowz80_io, AS_IO, 8, rainbow_state) AM_RANGE(0x20, 0x20) AM_READWRITE(z80_generalstat_r, z80_diskdiag_read_w) // read to port 0x20 used by MS-DOS 2.x diskette loader. AM_RANGE(0x21, 0x21) AM_READWRITE(z80_generalstat_r, z80_diskdiag_write_w) AM_RANGE(0x40, 0x40) AM_READWRITE(z80_diskstatus_r, z80_diskcontrol_w) - AM_RANGE(0x60, 0x60) AM_DEVREADWRITE_LEGACY("wd1793", wd17xx_status_r, wd17xx_command_w) - AM_RANGE(0x61, 0x61) AM_DEVREADWRITE_LEGACY("wd1793", wd17xx_track_r, wd17xx_track_w) - AM_RANGE(0x62, 0x62) AM_DEVREADWRITE_LEGACY("wd1793", wd17xx_sector_r, wd17xx_sector_w) - AM_RANGE(0x63, 0x63) AM_DEVREADWRITE_LEGACY("wd1793", wd17xx_data_r, wd17xx_data_w) + AM_RANGE(0x60, 0x60) AM_DEVREADWRITE("wd1793", fd1793_device ,status_r, command_w) + AM_RANGE(0x61, 0x61) AM_DEVREADWRITE("wd1793", fd1793_device, track_r, track_w) + AM_RANGE(0x62, 0x62) AM_DEVREADWRITE("wd1793", fd1793_device, sector_r, sector_w) + AM_RANGE(0x63, 0x63) AM_DEVREADWRITE("wd1793", fd1793_device, data_r, data_w) ADDRESS_MAP_END /* Input ports */ @@ -902,39 +902,39 @@ WRITE8_MEMBER(rainbow_state::z80_diskdiag_write_w) // ********************************************************************** READ8_MEMBER(rainbow_state::z80_diskstatus_r) { -static int last_track; -int track = wd17xx_track_r(m_fdc, space, 0); + static int last_track; + int track = m_fdc->track_r( space, 0); -if (track != last_track) - printf("\n%02d",track); -last_track = track; + if (track != last_track) + printf("\n%02d",track); + last_track = track; -// 40H diskette status Register **** READ ONLY *** ( 4-60 of TM100.pdf ) + // 40H diskette status Register **** READ ONLY *** ( 4-60 of TM100.pdf ) -// AND 00111011 - return what was WRITTEN to D5-D3, D1, D0 previously -// (except D7,D6,D2) -int data = m_z80_diskcontrol && 0x3b; + // AND 00111011 - return what was WRITTEN to D5-D3, D1, D0 previously + // (except D7,D6,D2) + int data = m_z80_diskcontrol && 0x3b; -// D7: DRQ: reflects status of DATA REQUEST signal from FDC. -// '1' indicates that FDC has read data OR requires new write data. -data |= wd17xx_drq_r(m_fdc) ? 0x80 : 0x00; + // D7: DRQ: reflects status of DATA REQUEST signal from FDC. + // '1' indicates that FDC has read data OR requires new write data. + data |= m_fdc->drq_r() ? 0x80 : 0x00; -// D6: IRQ: indicates INTERRUPT REQUEST signal from FDC. Indicates that a -// status bit has changed. Set to 1 at the completion of any -// command (.. see page 207 or 5-25). -data |= wd17xx_intrq_r(m_fdc) ? 0x40 : 0x00; + // D6: IRQ: indicates INTERRUPT REQUEST signal from FDC. Indicates that a + // status bit has changed. Set to 1 at the completion of any + // command (.. see page 207 or 5-25). + data |= m_fdc->intrq_r() ? 0x40 : 0x00; -// D5: SIDE 0H: status of side select signal at J2 + J3 of RX50 controller. -// For 1 sided drives, this bit will always read low (0). + // D5: SIDE 0H: status of side select signal at J2 + J3 of RX50 controller. + // For 1 sided drives, this bit will always read low (0). -// D4: MOTOR 1 ON L: 0 = indicates MOTOR 1 ON bit is set in drive control reg. -// D3: MOTOR 0 ON L: 0 = indicates MOTOR 0 ON bit is set in drive " + // D4: MOTOR 1 ON L: 0 = indicates MOTOR 1 ON bit is set in drive control reg. + // D3: MOTOR 0 ON L: 0 = indicates MOTOR 0 ON bit is set in drive " -// D2: TG43 L : 0 = INDICATES TRACK > 43 SIGNAL FROM FDC TO DISK DRIVE. -data |= ( track > 43) ? 0x00 : 0x04; + // D2: TG43 L : 0 = INDICATES TRACK > 43 SIGNAL FROM FDC TO DISK DRIVE. + data |= ( track > 43) ? 0x00 : 0x04; -// D1: DS1 H: reflect status of bits 0 and 1 form disk.control reg. -// D0: DS0 H: " + // D1: DS1 H: reflect status of bits 0 and 1 form disk.control reg. + // D0: DS0 H: " return data; } @@ -960,14 +960,14 @@ WRITE8_MEMBER(rainbow_state::z80_diskcontrol_w) if (flopimg_get_image( floppy_get_device( machine(), drive ) ) != NULL) { selected_drive = drive; - wd17xx_set_drive(m_fdc, selected_drive); + m_fdc->set_drive(selected_drive); } // WD emulation (wd17xx.c) will ignore 'side select' if set to WD1793. // Is it safe to * always assume * single sided 400 K disks? - wd17xx_set_side(m_fdc, (data & 20) ? 1 : 0); + m_fdc->set_side((data & 20) ? 1 : 0); - wd17xx_dden_w(m_fdc, 0); /* SEE 'WRITE_TRACK' : 1 = SD; 0 = DD; enable double density */ + m_fdc->dden_w(0); /* SEE 'WRITE_TRACK' : 1 = SD; 0 = DD; enable double density */ output_set_value("driveled0", (selected_drive == 0) ? 1 : 0 ); output_set_value("driveled1", (selected_drive == 1) ? 1 : 0 ); @@ -1065,7 +1065,7 @@ WRITE8_MEMBER( rainbow_state::diagnostic_w ) // reset device when going from high to low, // restore command when going from low to high : - wd17xx_mr_w(m_fdc, (data & 1) ? 1 : 0); + m_fdc->mr_w((data & 1) ? 1 : 0); m_diagnostic = data; } diff --git a/src/mess/drivers/rm380z.c b/src/mess/drivers/rm380z.c index 332965f6930..df67e513211 100644 --- a/src/mess/drivers/rm380z.c +++ b/src/mess/drivers/rm380z.c @@ -101,10 +101,10 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( rm380z_io , AS_IO, 8, rm380z_state) ADDRESS_MAP_GLOBAL_MASK(0xff) AM_RANGE(0x00, 0xbf) AM_READWRITE(rm380z_portlow_r, rm380z_portlow_w) - AM_RANGE(0xc0, 0xc0) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_status_r, wd17xx_command_w) - AM_RANGE(0xc1, 0xc1) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_track_r, wd17xx_track_w) - AM_RANGE(0xc2, 0xc2) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_sector_r, wd17xx_sector_w) - AM_RANGE(0xc3, 0xc3) AM_DEVREADWRITE_LEGACY("wd1771", wd17xx_data_r, wd17xx_data_w) + AM_RANGE(0xc0, 0xc0) AM_DEVREADWRITE("wd1771", fd1771_device, status_r, command_w) + AM_RANGE(0xc1, 0xc1) AM_DEVREADWRITE("wd1771", fd1771_device, track_r, track_w) + AM_RANGE(0xc2, 0xc2) AM_DEVREADWRITE("wd1771", fd1771_device, sector_r, sector_w) + AM_RANGE(0xc3, 0xc3) AM_DEVREADWRITE("wd1771", fd1771_device, data_r, data_w) AM_RANGE(0xc4, 0xc4) AM_WRITE(disk_0_control) AM_RANGE(0xc5, 0xff) AM_READWRITE(rm380z_porthi_r, rm380z_porthi_w) ADDRESS_MAP_END diff --git a/src/mess/drivers/smc777.c b/src/mess/drivers/smc777.c index 84d636b6573..c59a70b77fc 100644 --- a/src/mess/drivers/smc777.c +++ b/src/mess/drivers/smc777.c @@ -402,13 +402,13 @@ READ8_MEMBER(smc777_state::smc777_fdc1_r) switch(offset) { case 0x00: - return wd17xx_status_r(m_fdc,space, offset) ^ 0xff; + return m_fdc->status_r(space, offset) ^ 0xff; case 0x01: - return wd17xx_track_r(m_fdc,space, offset) ^ 0xff; + return m_fdc->track_r(space, offset) ^ 0xff; case 0x02: - return wd17xx_sector_r(m_fdc,space, offset) ^ 0xff; + return m_fdc->sector_r(space, offset) ^ 0xff; case 0x03: - return wd17xx_data_r(m_fdc,space, offset) ^ 0xff; + return m_fdc->data_r(space, offset) ^ 0xff; case 0x04: //irq / drq status //popmessage("%02x %02x\n",m_fdc_irq_flag,m_fdc_drq_flag); @@ -425,21 +425,21 @@ WRITE8_MEMBER(smc777_state::smc777_fdc1_w) switch(offset) { case 0x00: - wd17xx_command_w(m_fdc,space, offset,data ^ 0xff); + m_fdc->command_w(space, offset,data ^ 0xff); break; case 0x01: - wd17xx_track_w(m_fdc,space, offset,data ^ 0xff); + m_fdc->track_w(space, offset,data ^ 0xff); break; case 0x02: - wd17xx_sector_w(m_fdc,space, offset,data ^ 0xff); + m_fdc->sector_w(space, offset,data ^ 0xff); break; case 0x03: - wd17xx_data_w(m_fdc,space, offset,data ^ 0xff); + m_fdc->data_w(space, offset,data ^ 0xff); break; case 0x04: // ---- xxxx select floppy drive (yes, 15 of them, A to P) - wd17xx_set_drive(m_fdc,data & 0x01); - // wd17xx_set_side(m_fdc,(data & 0x10)>>4); + m_fdc->set_drive(data & 0x01); + // m_fdc->set_side((data & 0x10)>>4); if(data & 0xf0) printf("floppy access %02x\n",data); break; diff --git a/src/mess/drivers/trs80.c b/src/mess/drivers/trs80.c index ec7564a4fae..ee753556302 100644 --- a/src/mess/drivers/trs80.c +++ b/src/mess/drivers/trs80.c @@ -158,10 +158,10 @@ static ADDRESS_MAP_START( model1_map, AS_PROGRAM, 8, trs80_state ) AM_RANGE(0x37e4, 0x37e7) AM_WRITE(trs80_cassunit_w) AM_RANGE(0x37e8, 0x37eb) AM_READWRITE(trs80_printer_r, trs80_printer_w) AM_RANGE(0x37ec, 0x37ec) AM_READ(trs80_wd179x_r) - AM_RANGE(0x37ec, 0x37ec) AM_DEVWRITE_LEGACY("wd179x", wd17xx_command_w) - AM_RANGE(0x37ed, 0x37ed) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_track_r, wd17xx_track_w) - AM_RANGE(0x37ee, 0x37ee) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_sector_r, wd17xx_sector_w) - AM_RANGE(0x37ef, 0x37ef) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_data_r, wd17xx_data_w) + AM_RANGE(0x37ec, 0x37ec) AM_DEVWRITE("wd179x", fd1793_device, command_w) + AM_RANGE(0x37ed, 0x37ed) AM_DEVREADWRITE("wd179x", fd1793_device, track_r, track_w) + AM_RANGE(0x37ee, 0x37ee) AM_DEVREADWRITE("wd179x", fd1793_device, sector_r, sector_w) + AM_RANGE(0x37ef, 0x37ef) AM_DEVREADWRITE("wd179x", fd1793_device, data_r, data_w) AM_RANGE(0x3800, 0x38ff) AM_MIRROR(0x300) AM_READ(trs80_keyboard_r) AM_RANGE(0x3c00, 0x3fff) AM_READWRITE(trs80_videoram_r, trs80_videoram_w) AM_SHARE("p_videoram") AM_RANGE(0x4000, 0xffff) AM_RAM @@ -208,10 +208,10 @@ static ADDRESS_MAP_START( model3_io, AS_IO, 8, trs80_state ) AM_RANGE(0xeb, 0xeb) AM_READWRITE(trs80m4_eb_r, trs80m4_eb_w) AM_RANGE(0xec, 0xef) AM_READWRITE(trs80m4_ec_r, trs80m4_ec_w) AM_RANGE(0xf0, 0xf0) AM_READ(trs80_wd179x_r) - AM_RANGE(0xf0, 0xf0) AM_DEVWRITE_LEGACY("wd179x", wd17xx_command_w) - AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_track_r, wd17xx_track_w) - AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_sector_r, wd17xx_sector_w) - AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_data_r, wd17xx_data_w) + AM_RANGE(0xf0, 0xf0) AM_DEVWRITE("wd179x", fd1793_device, command_w) + AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE("wd179x", fd1793_device, track_r, track_w) + AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE("wd179x", fd1793_device, sector_r, sector_w) + AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE("wd179x", fd1793_device, data_r, data_w) AM_RANGE(0xf4, 0xf4) AM_WRITE(trs80m4_f4_w) AM_RANGE(0xf8, 0xfb) AM_READWRITE(trs80_printer_r, trs80_printer_w) AM_RANGE(0xfc, 0xff) AM_READWRITE(trs80m4_ff_r, trs80m4_ff_w) @@ -230,10 +230,10 @@ static ADDRESS_MAP_START( model4_io, AS_IO, 8, trs80_state ) AM_RANGE(0xeb, 0xeb) AM_READWRITE(trs80m4_eb_r, trs80m4_eb_w) AM_RANGE(0xec, 0xef) AM_READWRITE(trs80m4_ec_r, trs80m4_ec_w) AM_RANGE(0xf0, 0xf0) AM_READ(trs80_wd179x_r) - AM_RANGE(0xf0, 0xf0) AM_DEVWRITE_LEGACY("wd179x", wd17xx_command_w) - AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_track_r, wd17xx_track_w) - AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_sector_r, wd17xx_sector_w) - AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_data_r, wd17xx_data_w) + AM_RANGE(0xf0, 0xf0) AM_DEVWRITE("wd179x", fd1793_device, command_w) + AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE("wd179x", fd1793_device, track_r, track_w) + AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE("wd179x", fd1793_device, sector_r, sector_w) + AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE("wd179x", fd1793_device, data_r, data_w) AM_RANGE(0xf4, 0xf4) AM_WRITE(trs80m4_f4_w) AM_RANGE(0xf8, 0xfb) AM_READWRITE(trs80_printer_r, trs80_printer_w) AM_RANGE(0xfc, 0xff) AM_READWRITE(trs80m4_ff_r, trs80m4_ff_w) @@ -253,10 +253,10 @@ static ADDRESS_MAP_START( model4p_io, AS_IO, 8, trs80_state ) AM_RANGE(0xeb, 0xeb) AM_READWRITE(trs80m4_eb_r, trs80m4_eb_w) AM_RANGE(0xec, 0xef) AM_READWRITE(trs80m4_ec_r, trs80m4_ec_w) AM_RANGE(0xf0, 0xf0) AM_READ(trs80_wd179x_r) - AM_RANGE(0xf0, 0xf0) AM_DEVWRITE_LEGACY("wd179x", wd17xx_command_w) - AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_track_r, wd17xx_track_w) - AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_sector_r, wd17xx_sector_w) - AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_data_r, wd17xx_data_w) + AM_RANGE(0xf0, 0xf0) AM_DEVWRITE("wd179x", fd1793_device, command_w) + AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE("wd179x", fd1793_device, track_r, track_w) + AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE("wd179x", fd1793_device, sector_r, sector_w) + AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE("wd179x", fd1793_device, data_r, data_w) AM_RANGE(0xf4, 0xf4) AM_WRITE(trs80m4_f4_w) AM_RANGE(0xf8, 0xfb) AM_READWRITE(trs80_printer_r, trs80_printer_w) AM_RANGE(0xfc, 0xff) AM_READWRITE(trs80m4_ff_r, trs80m4_ff_w) @@ -277,10 +277,10 @@ static ADDRESS_MAP_START( meritum_io, AS_IO, 8, trs80_state ) // eg. port F0 should be 5, port F2 should have bit 3 set. //AM_RANGE(0x03, 0x03) unknown AM_RANGE(0xf0, 0xf0) AM_READ(trs80_wd179x_r) - AM_RANGE(0xf0, 0xf0) AM_DEVWRITE_LEGACY("wd179x", wd17xx_command_w) - AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_track_r, wd17xx_track_w) - AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_sector_r, wd17xx_sector_w) - AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE_LEGACY("wd179x", wd17xx_data_r, wd17xx_data_w) + AM_RANGE(0xf0, 0xf0) AM_DEVWRITE("wd179x", fd1793_device, command_w) + AM_RANGE(0xf1, 0xf1) AM_DEVREADWRITE("wd179x", fd1793_device, track_r, track_w) + AM_RANGE(0xf2, 0xf2) AM_DEVREADWRITE("wd179x", fd1793_device, sector_r, sector_w) + AM_RANGE(0xf3, 0xf3) AM_DEVREADWRITE("wd179x", fd1793_device, data_r, data_w) AM_RANGE(0xf4, 0xf4) AM_WRITE(trs80m4_f4_w) AM_RANGE(0xf8, 0xfb) AM_READWRITE(trs80_printer_r, trs80_printer_w) //AM_RANGE(0xfc, 0xfd) unknown diff --git a/src/mess/drivers/unixpc.c b/src/mess/drivers/unixpc.c index c0c460a06f0..50467ed9a0e 100644 --- a/src/mess/drivers/unixpc.c +++ b/src/mess/drivers/unixpc.c @@ -91,7 +91,7 @@ READ16_MEMBER( unixpc_state::line_printer_r ) data |= 1; // no dial tone detected data |= 1 << 1; // no parity error data |= 0 << 2; // hdc intrq - data |= wd17xx_intrq_r(m_wd2797) << 3; + data |= m_wd2797->intrq_r() << 3; logerror("line_printer_r: %04x\n", data); @@ -120,7 +120,7 @@ WRITE16_MEMBER( unixpc_state::disk_control_w ) floppy_mon_w(m_floppy, !BIT(data, 5)); // bit 6 = floppy selected / not selected - wd17xx_set_drive(m_wd2797, 0); + m_wd2797->set_drive(0); } WRITE_LINE_MEMBER( unixpc_state::wd2797_intrq_w ) @@ -161,7 +161,7 @@ static ADDRESS_MAP_START( unixpc_mem, AS_PROGRAM, 16, unixpc_state ) AM_RANGE(0x4a0000, 0x4a0001) AM_WRITE(misc_control_w) AM_RANGE(0x4e0000, 0x4e0001) AM_WRITE(disk_control_w) AM_RANGE(0x800000, 0xbfffff) AM_MIRROR(0x7fc000) AM_ROM AM_REGION("bootrom", 0) - AM_RANGE(0xe10000, 0xe10007) AM_DEVREADWRITE8_LEGACY("wd2797", wd17xx_r, wd17xx_w, 0x00ff) + AM_RANGE(0xe10000, 0xe10007) AM_DEVREADWRITE8("wd2797", wd2797_device, read, write, 0x00ff) AM_RANGE(0xe43000, 0xe43001) AM_WRITE(romlmap_w) ADDRESS_MAP_END diff --git a/src/mess/drivers/vector06.c b/src/mess/drivers/vector06.c index 4ada3fcd1b6..9b811e74bc3 100644 --- a/src/mess/drivers/vector06.c +++ b/src/mess/drivers/vector06.c @@ -23,10 +23,10 @@ static ADDRESS_MAP_START(vector06_io, AS_IO, 8, vector06_state) AM_RANGE( 0x00, 0x03) AM_READWRITE(vector06_8255_1_r, vector06_8255_1_w ) AM_RANGE( 0x04, 0x07) AM_READWRITE(vector06_8255_2_r, vector06_8255_2_w ) AM_RANGE( 0x0C, 0x0C) AM_WRITE(vector06_color_set) - AM_RANGE( 0x18, 0x18) AM_DEVREADWRITE_LEGACY("wd1793", wd17xx_data_r,wd17xx_data_w) - AM_RANGE( 0x19, 0x19) AM_DEVREADWRITE_LEGACY("wd1793", wd17xx_sector_r,wd17xx_sector_w) - AM_RANGE( 0x1A, 0x1A) AM_DEVREADWRITE_LEGACY("wd1793", wd17xx_track_r,wd17xx_track_w) - AM_RANGE( 0x1B, 0x1B) AM_DEVREADWRITE_LEGACY("wd1793", wd17xx_status_r,wd17xx_command_w) + AM_RANGE( 0x18, 0x18) AM_DEVREADWRITE("wd1793", fd1793_device, data_r, data_w) + AM_RANGE( 0x19, 0x19) AM_DEVREADWRITE("wd1793", fd1793_device, sector_r, sector_w) + AM_RANGE( 0x1A, 0x1A) AM_DEVREADWRITE("wd1793", fd1793_device, track_r, track_w) + AM_RANGE( 0x1B, 0x1B) AM_DEVREADWRITE("wd1793", fd1793_device, status_r, command_w) AM_RANGE( 0x1C, 0x1C) AM_WRITE(vector06_disc_w) ADDRESS_MAP_END diff --git a/src/mess/drivers/x1.c b/src/mess/drivers/x1.c index 2c57abf38fa..4571a4f32f1 100644 --- a/src/mess/drivers/x1.c +++ b/src/mess/drivers/x1.c @@ -995,13 +995,13 @@ READ8_MEMBER( x1_state::x1_fdc_r ) switch(offset+0xff8) { case 0x0ff8: - return wd17xx_status_r(m_fdc,space, offset); + return m_fdc->status_r(space, offset); case 0x0ff9: - return wd17xx_track_r(m_fdc,space, offset); + return m_fdc->track_r(space, offset); case 0x0ffa: - return wd17xx_sector_r(m_fdc,space, offset); + return m_fdc->sector_r(space, offset); case 0x0ffb: - return wd17xx_data_r(m_fdc,space, offset); + return m_fdc->data_r(space, offset); case 0x0ffc: printf("FDC: read FM type\n"); return 0xff; @@ -1024,22 +1024,22 @@ WRITE8_MEMBER( x1_state::x1_fdc_w ) switch(offset+0xff8) { case 0x0ff8: - wd17xx_command_w(m_fdc,space, offset,data); + m_fdc->command_w(space, offset,data); break; case 0x0ff9: - wd17xx_track_w(m_fdc,space, offset,data); + m_fdc->track_w(space, offset,data); break; case 0x0ffa: - wd17xx_sector_w(m_fdc,space, offset,data); + m_fdc->sector_w(space, offset,data); break; case 0x0ffb: - wd17xx_data_w(m_fdc,space, offset,data); + m_fdc->data_w(space, offset,data); break; case 0x0ffc: - wd17xx_set_drive(m_fdc,data & 3); + 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); - wd17xx_set_side(m_fdc, BIT(data, 4)); + m_fdc->set_side(BIT(data, 4)); break; case 0x0ffd: case 0x0ffe: diff --git a/src/mess/drivers/z100.c b/src/mess/drivers/z100.c index 0ce1dc9dbfa..ed97b353bbd 100644 --- a/src/mess/drivers/z100.c +++ b/src/mess/drivers/z100.c @@ -358,10 +358,10 @@ READ8_MEMBER( z100_state::z207_fdc_r ) switch(offset) { - case 0: res = wd17xx_status_r(m_fdc,space, offset); break; - case 1: res = wd17xx_track_r(m_fdc,space, offset); break; - case 2: res = wd17xx_sector_r(m_fdc,space, offset); break; - case 3: res = wd17xx_data_r(m_fdc,space, offset); break; + case 0: res = m_fdc->status_r(space, offset); break; + case 1: res = m_fdc->track_r(space, offset); break; + case 2: res = m_fdc->sector_r(space, offset); break; + case 3: res = m_fdc->data_r(space, offset); break; } return res; @@ -371,12 +371,12 @@ WRITE8_MEMBER( z100_state::z207_fdc_w ) { switch(offset) { - case 0: wd17xx_command_w(m_fdc,space, offset,data); break; - case 1: wd17xx_track_w(m_fdc,space, offset,data); break; - case 2: wd17xx_sector_w(m_fdc,space, offset,data); break; - case 3: wd17xx_data_w(m_fdc,space, offset,data); break; + case 0: m_fdc->command_w(space, offset,data); break; + case 1: m_fdc->track_w(space, offset,data); break; + case 2: m_fdc->sector_w(space, offset,data); break; + case 3: m_fdc->data_w(space, offset,data); break; case 4: // disk control - wd17xx_set_drive(m_fdc,data & 3); + m_fdc->set_drive(data & 3); m_z207_cur_drive = data & 3; break; case 5: // aux control diff --git a/src/mess/drivers/z80ne.c b/src/mess/drivers/z80ne.c index 42ed4b570a2..bf603b4f6b7 100644 --- a/src/mess/drivers/z80ne.c +++ b/src/mess/drivers/z80ne.c @@ -98,9 +98,6 @@ #include "formats/z80ne_dsk.h" #include "machine/ram.h" -/* peripheral chips */ -#include "machine/wd17xx.h" - /* Layout */ #include "z80ne.lh" #include "z80net.lh" diff --git a/src/mess/includes/fmtowns.h b/src/mess/includes/fmtowns.h index d88e8f43c28..21e1385a595 100644 --- a/src/mess/includes/fmtowns.h +++ b/src/mess/includes/fmtowns.h @@ -119,7 +119,7 @@ class towns_state : public driver_device required_device<upd71071_device> m_dma_2; required_device<palette_device> m_palette; required_device<ram_device> m_ram; - device_t* m_fdc; + mb8877_device* m_fdc; ram_device* m_messram; cdrom_image_device* m_cdrom; cdda_device* m_cdda; diff --git a/src/mess/includes/msx.h b/src/mess/includes/msx.h index d3e46885aae..d8f2ca96b13 100644 --- a/src/mess/includes/msx.h +++ b/src/mess/includes/msx.h @@ -146,7 +146,7 @@ public: optional_device<k051649_device> m_k051649; required_device<dac_device> m_dac; optional_device<rp5c01_device> m_rtc; - optional_device<device_t> m_wd179x; + optional_device<fd1793_device> m_wd179x; DECLARE_READ8_MEMBER(msx_psg_port_a_r); DECLARE_READ8_MEMBER(msx_psg_port_b_r); DECLARE_WRITE8_MEMBER(msx_psg_port_a_w); diff --git a/src/mess/includes/pk8020.h b/src/mess/includes/pk8020.h index 9a9c63960ee..12e1f248dd6 100644 --- a/src/mess/includes/pk8020.h +++ b/src/mess/includes/pk8020.h @@ -11,6 +11,7 @@ #include "machine/pit8253.h" #include "machine/pic8259.h" #include "machine/i8251.h" +#include "machine/wd17xx.h" #include "imagedev/cassette.h" #include "sound/speaker.h" #include "sound/wave.h" @@ -81,7 +82,7 @@ protected: required_device<i8251_device> m_rs232; required_device<i8251_device> m_lan; required_device<ram_device> m_ram; - required_device<device_t> m_wd1793; + required_device<fd1793_device> m_wd1793; required_device<pit8253_device> m_pit8253; required_device<pic8259_device> m_pic8259; required_device<speaker_sound_device> m_speaker; diff --git a/src/mess/includes/z80ne.h b/src/mess/includes/z80ne.h index 155c0116ef7..47d1f22d848 100644 --- a/src/mess/includes/z80ne.h +++ b/src/mess/includes/z80ne.h @@ -15,6 +15,7 @@ #include "imagedev/cassette.h" #include "machine/ay31015.h" #include "machine/kr2376.h" +#include "machine/wd17xx.h" /*************************************************************************** CONSTANTS @@ -147,7 +148,7 @@ protected: required_device<cpu_device> m_maincpu; required_device<cassette_image_device> m_cassette1; required_device<cassette_image_device> m_cassette2; - optional_device<device_t> m_wd1771; + optional_device<fd1771_device> m_wd1771; required_memory_region m_region_z80ne; optional_memory_bank m_bank1; optional_memory_bank m_bank2; diff --git a/src/mess/machine/bbc.c b/src/mess/machine/bbc.c index d64230d5e83..8b12d8402e8 100644 --- a/src/mess/machine/bbc.c +++ b/src/mess/machine/bbc.c @@ -1628,18 +1628,18 @@ const wd17xx_interface bbc_wd17xx_interface = WRITE8_MEMBER(bbc_state::bbc_wd177x_status_w) { - device_t *fdc = machine().device("wd177x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd177x"); m_drive_control = data; /* set drive */ - if ((data>>0) & 0x01) wd17xx_set_drive(fdc,0); - if ((data>>1) & 0x01) wd17xx_set_drive(fdc,1); + if ((data>>0) & 0x01) fdc->set_drive(0); + if ((data>>1) & 0x01) fdc->set_drive(1); /* set side */ - wd17xx_set_side(fdc,(data>>2) & 0x01); + fdc->set_side((data>>2) & 0x01); /* set density */ - wd17xx_dden_w(fdc, BIT(data, 3)); + fdc->dden_w(BIT(data, 3)); m_1770_IntEnabled=(((data>>4) & 0x01)==0); } @@ -1649,20 +1649,20 @@ WRITE8_MEMBER(bbc_state::bbc_wd177x_status_w) READ8_MEMBER(bbc_state::bbc_wd1770_read) { int retval=0xff; - device_t *fdc = machine().device("wd177x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd177x"); switch (offset) { case 4: - retval=wd17xx_status_r(fdc, space, 0); + retval=fdc->status_r(space, 0); break; case 5: - retval=wd17xx_track_r(fdc, space, 0); + retval=fdc->track_r(space, 0); break; case 6: - retval=wd17xx_sector_r(fdc, space, 0); + retval=fdc->sector_r(space, 0); break; case 7: - retval=wd17xx_data_r(fdc, space, 0); + retval=fdc->data_r(space, 0); break; default: break; @@ -1674,7 +1674,7 @@ READ8_MEMBER(bbc_state::bbc_wd1770_read) WRITE8_MEMBER(bbc_state::bbc_wd1770_write) { - device_t *fdc = machine().device("wd177x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd177x"); logerror("wd177x write: $%02X $%02X\n", offset,data); switch (offset) { @@ -1682,16 +1682,16 @@ WRITE8_MEMBER(bbc_state::bbc_wd1770_write) bbc_wd177x_status_w(space, 0, data); break; case 4: - wd17xx_command_w(fdc, space, 0, data); + fdc->command_w(space, 0, data); break; case 5: - wd17xx_track_w(fdc, space, 0, data); + fdc->track_w(space, 0, data); break; case 6: - wd17xx_sector_w(fdc, space, 0, data); + fdc->sector_w(space, 0, data); break; case 7: - wd17xx_data_w(fdc, space, 0, data); + fdc->data_w(space, 0, data); break; default: break; @@ -1737,25 +1737,25 @@ AM_RANGE(0xfc00, 0xfdff) AM_READWRITE(bbc_opus_read , bbc_opus_write ) WRITE8_MEMBER(bbc_state::bbc_opus_status_w) { - device_t *fdc = machine().device("wd177x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd177x"); m_drive_control = data; /* set drive */ - if ((data>>1) & 0x01) wd17xx_set_drive(fdc,0); - if ((data>>2) & 0x01) wd17xx_set_drive(fdc,1); + if ((data>>1) & 0x01) fdc->set_drive(0); + if ((data>>2) & 0x01) fdc->set_drive(1); /* set side */ - wd17xx_set_side(fdc,(data>>0) & 0x01); + fdc->set_side((data>>0) & 0x01); /* set density */ - wd17xx_dden_w(fdc, BIT(data, 5)); + fdc->dden_w(BIT(data, 5)); m_1770_IntEnabled=(data>>4) & 0x01; } READ8_MEMBER(bbc_state::bbc_opus_read) { - device_t *fdc = machine().device("wd177x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd177x"); logerror("wd177x read: $%02X\n", offset); if (m_DFSType==6) @@ -1765,13 +1765,13 @@ READ8_MEMBER(bbc_state::bbc_opus_read) switch (offset) { case 0xf8: - return wd17xx_status_r(fdc, space, 0); + return fdc->status_r(space, 0); case 0xf9: - return wd17xx_track_r(fdc, space, 0); + return fdc->track_r(space, 0); case 0xfa: - return wd17xx_sector_r(fdc, space, 0); + return fdc->sector_r(space, 0); case 0xfb: - return wd17xx_data_r(fdc, space, 0); + return fdc->data_r(space, 0); } } else @@ -1784,7 +1784,7 @@ READ8_MEMBER(bbc_state::bbc_opus_read) WRITE8_MEMBER(bbc_state::bbc_opus_write) { - device_t *fdc = machine().device("wd177x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd177x"); logerror("wd177x write: $%02X $%02X\n", offset,data); if (m_DFSType==6) @@ -1794,16 +1794,16 @@ WRITE8_MEMBER(bbc_state::bbc_opus_write) switch (offset) { case 0xf8: - wd17xx_command_w(fdc, space, 0, data); + fdc->command_w(space, 0, data); break; case 0xf9: - wd17xx_track_w(fdc, space, 0, data); + fdc->track_w(space, 0, data); break; case 0xfa: - wd17xx_sector_w(fdc, space, 0, data); + fdc->sector_w(space, 0, data); break; case 0xfb: - wd17xx_data_w(fdc, space, 0, data); + fdc->data_w(space, 0, data); break; case 0xfc: bbc_opus_status_w(space, 0,data); @@ -1832,20 +1832,20 @@ BBC MASTER DISC SUPPORT READ8_MEMBER(bbc_state::bbcm_wd1770_read) { int retval=0xff; - device_t *fdc = machine().device("wd177x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd177x"); switch (offset) { case 0: - retval=wd17xx_status_r(fdc, space, 0); + retval=fdc->status_r(space, 0); break; case 1: - retval=wd17xx_track_r(fdc, space, 0); + retval=fdc->track_r(space, 0); break; case 2: - retval=wd17xx_sector_r(fdc, space, 0); + retval=fdc->sector_r(space, 0); break; case 3: - retval=wd17xx_data_r(fdc, space, 0); + retval=fdc->data_r(space, 0); break; default: break; @@ -1856,21 +1856,21 @@ READ8_MEMBER(bbc_state::bbcm_wd1770_read) WRITE8_MEMBER(bbc_state::bbcm_wd1770_write) { - device_t *fdc = machine().device("wd177x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd177x"); //logerror("wd177x write: $%02X $%02X\n", offset,data); switch (offset) { case 0: - wd17xx_command_w(fdc, space, 0, data); + fdc->command_w(space, 0, data); break; case 1: - wd17xx_track_w(fdc, space, 0, data); + fdc->track_w(space, 0, data); break; case 2: - wd17xx_sector_w(fdc, space, 0, data); + fdc->sector_w(space, 0, data); break; case 3: - wd17xx_data_w(fdc, space, 0, data); + fdc->data_w(space, 0, data); break; default: break; @@ -1885,18 +1885,18 @@ READ8_MEMBER(bbc_state::bbcm_wd1770l_read) WRITE8_MEMBER(bbc_state::bbcm_wd1770l_write) { - device_t *fdc = machine().device("wd177x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd177x"); m_drive_control = data; /* set drive */ - if ((data>>0) & 0x01) wd17xx_set_drive(fdc,0); - if ((data>>1) & 0x01) wd17xx_set_drive(fdc,1); + if ((data>>0) & 0x01) fdc->set_drive(0); + if ((data>>1) & 0x01) fdc->set_drive(1); /* set side */ - wd17xx_set_side(fdc,(data>>4) & 0x01); + fdc->set_side((data>>4) & 0x01); /* set density */ - wd17xx_dden_w(fdc, BIT(data, 5)); + fdc->dden_w(BIT(data, 5)); // m_1770_IntEnabled=(((data>>4) & 0x01)==0); m_1770_IntEnabled=1; diff --git a/src/mess/machine/beta.c b/src/mess/machine/beta.c index c3e9baf0c6b..385359c4977 100644 --- a/src/mess/machine/beta.c +++ b/src/mess/machine/beta.c @@ -10,7 +10,6 @@ #include "emu.h" #include "imagedev/flopdrv.h" #include "formats/trd_dsk.h" -#include "machine/wd17xx.h" #include "machine/beta.h" @@ -41,7 +40,7 @@ void beta_disk_device::device_start() /* find our WD179x */ tempstring.printf("%s:%s", tag(), "wd179x"); - m_wd179x = machine().device(tempstring); + m_wd179x = machine().device<wd2793_device>(tempstring); } //------------------------------------------------- @@ -99,7 +98,7 @@ static const wd17xx_interface beta_wd17xx_interface = READ8_MEMBER(beta_disk_device::status_r) { if (m_betadisk_active==1) { - return wd17xx_status_r(m_wd179x, space, offset); + return m_wd179x->status_r(space, offset); } else { return 0xff; } @@ -108,7 +107,7 @@ READ8_MEMBER(beta_disk_device::status_r) READ8_MEMBER(beta_disk_device::track_r) { if (m_betadisk_active==1) { - return wd17xx_track_r(m_wd179x, space, offset); + return m_wd179x->track_r(space, offset); } else { return 0xff; } @@ -117,7 +116,7 @@ READ8_MEMBER(beta_disk_device::track_r) READ8_MEMBER(beta_disk_device::sector_r) { if (m_betadisk_active==1) { - return wd17xx_sector_r(m_wd179x, space, offset); + return m_wd179x->sector_r(space, offset); } else { return 0xff; } @@ -126,7 +125,7 @@ READ8_MEMBER(beta_disk_device::sector_r) READ8_MEMBER(beta_disk_device::data_r) { if (m_betadisk_active==1) { - return wd17xx_data_r(m_wd179x, space, offset); + return m_wd179x->data_r(space, offset); } else { return 0xff; } @@ -144,12 +143,12 @@ READ8_MEMBER(beta_disk_device::state_r) WRITE8_MEMBER(beta_disk_device::param_w) { if (m_betadisk_active==1) { - wd17xx_set_drive(m_wd179x, data & 3); - wd17xx_set_side (m_wd179x,(data & 0x10) ? 0 : 1 ); - wd17xx_dden_w(m_wd179x, !BIT(data, 5)); + m_wd179x->set_drive(data & 3); + m_wd179x->set_side ((data & 0x10) ? 0 : 1 ); + m_wd179x->dden_w(!BIT(data, 5)); if ((data & 0x04) == 0) // reset { - wd17xx_reset(m_wd179x); + m_wd179x->reset(); } m_betadisk_status = (data & 0x3f) | m_betadisk_status; } @@ -158,28 +157,28 @@ WRITE8_MEMBER(beta_disk_device::param_w) WRITE8_MEMBER(beta_disk_device::command_w) { if (m_betadisk_active==1) { - wd17xx_command_w(m_wd179x, space, offset, data); + m_wd179x->command_w(space, offset, data); } } WRITE8_MEMBER(beta_disk_device::track_w) { if (m_betadisk_active==1) { - wd17xx_track_w(m_wd179x, space, offset, data); + m_wd179x->track_w(space, offset, data); } } WRITE8_MEMBER(beta_disk_device::sector_w) { if (m_betadisk_active==1) { - wd17xx_sector_w(m_wd179x, space, offset, data); + m_wd179x->sector_w(space, offset, data); } } WRITE8_MEMBER(beta_disk_device::data_w) { if (m_betadisk_active==1) { - wd17xx_data_w(m_wd179x, space, offset, data); + m_wd179x->data_w(space, offset, data); } } diff --git a/src/mess/machine/beta.h b/src/mess/machine/beta.h index b96e3ab2ac1..5ffe06f822d 100644 --- a/src/mess/machine/beta.h +++ b/src/mess/machine/beta.h @@ -10,6 +10,8 @@ #ifndef __BETA_H__ #define __BETA_H__ +#include "machine/wd17xx.h" + #define BETA_DISK_TAG "beta" @@ -51,7 +53,7 @@ protected: private: // internal state - device_t *m_wd179x; + wd2793_device *m_wd179x; }; extern const device_type BETA_DISK; diff --git a/src/mess/machine/cgenie.c b/src/mess/machine/cgenie.c index 8f3cabdd8d6..193754b0cb3 100644 --- a/src/mess/machine/cgenie.c +++ b/src/mess/machine/cgenie.c @@ -323,74 +323,74 @@ WRITE8_MEMBER( cgenie_state::cgenie_psg_port_b_w ) READ8_MEMBER( cgenie_state::cgenie_status_r ) { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); /* If the floppy isn't emulated, return 0 */ if( (ioport("DSW0")->read() & 0x80) == 0 ) return 0; - return wd17xx_status_r(fdc, space, offset); + return fdc->status_r(space, offset); } READ8_MEMBER( cgenie_state::cgenie_track_r ) { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); /* If the floppy isn't emulated, return 0xff */ if( (ioport("DSW0")->read() & 0x80) == 0 ) return 0xff; - return wd17xx_track_r(fdc, space, offset); + return fdc->track_r(space, offset); } READ8_MEMBER( cgenie_state::cgenie_sector_r ) { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); /* If the floppy isn't emulated, return 0xff */ if( (ioport("DSW0")->read() & 0x80) == 0 ) return 0xff; - return wd17xx_sector_r(fdc, space, offset); + return fdc->sector_r(space, offset); } READ8_MEMBER( cgenie_state::cgenie_data_r ) { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); /* If the floppy isn't emulated, return 0xff */ if( (ioport("DSW0")->read() & 0x80) == 0 ) return 0xff; - return wd17xx_data_r(fdc, space, offset); + return fdc->data_r(space, offset); } WRITE8_MEMBER( cgenie_state::cgenie_command_w ) { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); /* If the floppy isn't emulated, return immediately */ if( (ioport("DSW0")->read() & 0x80) == 0 ) return; - wd17xx_command_w(fdc, space, offset, data); + fdc->command_w(space, offset, data); } WRITE8_MEMBER( cgenie_state::cgenie_track_w ) { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); /* If the floppy isn't emulated, ignore the write */ if( (ioport("DSW0")->read() & 0x80) == 0 ) return; - wd17xx_track_w(fdc, space, offset, data); + fdc->track_w(space, offset, data); } WRITE8_MEMBER( cgenie_state::cgenie_sector_w ) { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); /* If the floppy isn't emulated, ignore the write */ if( (ioport("DSW0")->read() & 0x80) == 0 ) return; - wd17xx_sector_w(fdc, space, offset, data); + fdc->sector_w(space, offset, data); } WRITE8_MEMBER( cgenie_state::cgenie_data_w ) { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); /* If the floppy isn't emulated, ignore the write */ if( (ioport("DSW0")->read() & 0x80) == 0 ) return; - wd17xx_data_w(fdc, space, offset, data); + fdc->data_w(space, offset, data); } READ8_MEMBER( cgenie_state::cgenie_irq_status_r ) @@ -440,7 +440,7 @@ const wd17xx_interface cgenie_wd17xx_interface = WRITE8_MEMBER( cgenie_state::cgenie_motor_w ) { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); UINT8 drive = 255; logerror("cgenie motor_w $%02X\n", data); @@ -463,8 +463,8 @@ WRITE8_MEMBER( cgenie_state::cgenie_motor_w ) /* currently selected drive */ m_motor_drive = drive; - wd17xx_set_drive(fdc,drive); - wd17xx_set_side(fdc,m_head); + fdc->set_drive(drive); + fdc->set_side(m_head); } /************************************* diff --git a/src/mess/machine/concept_exp.c b/src/mess/machine/concept_exp.c index cba226ff04d..8b22a61b865 100644 --- a/src/mess/machine/concept_exp.c +++ b/src/mess/machine/concept_exp.c @@ -14,7 +14,6 @@ #include "machine/concept_exp.h" // FDC controller -#include "machine/wd17xx.h" #include "imagedev/flopdrv.h" #include "formats/basicdsk.h" @@ -167,7 +166,7 @@ enum void concept_fdc_device::device_start() { - m_wd179x = subdevice("wd179x"); + m_wd179x = subdevice<fd1793_device>("wd179x"); save_item(NAME(m_fdc_local_status)); save_item(NAME(m_fdc_local_command)); @@ -213,16 +212,16 @@ READ8_MEMBER(concept_fdc_device::reg_r) return m_fdc_local_status; case 8: // FDC STATUS REG - return wd17xx_status_r(m_wd179x, space, offset); + return m_wd179x->status_r(space, offset); case 9: // FDC TRACK REG - return wd17xx_track_r(m_wd179x, space, offset); + return m_wd179x->track_r(space, offset); case 10: // FDC SECTOR REG - return wd17xx_sector_r(m_wd179x, space, offset); + return m_wd179x->sector_r(space, offset); case 11: // FDC DATA REG - return wd17xx_data_r(m_wd179x, space, offset); + return m_wd179x->data_r(space, offset); } return 0; @@ -237,30 +236,30 @@ WRITE8_MEMBER(concept_fdc_device::reg_w) case 0: // LOCAL COMMAND REG m_fdc_local_command = data; - wd17xx_set_side(m_wd179x, (data & LC_FLPSD1_mask) != 0); + m_wd179x->set_side((data & LC_FLPSD1_mask) != 0); current_drive = ((data >> LC_DE0_bit) & 1) | ((data >> (LC_DE1_bit-1)) & 2); - wd17xx_set_drive(m_wd179x, current_drive); + m_wd179x->set_drive(current_drive); /*motor_on = (data & LC_MOTOROF_mask) == 0;*/ // 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;*/ - wd17xx_dden_w(m_wd179x, BIT(data, 7)); + m_wd179x->dden_w(BIT(data, 7)); floppy_drive_set_ready_state(floppy_get_device(machine(), current_drive), 1, 0); break; case 8: // FDC COMMAMD REG - wd17xx_command_w(m_wd179x, space, offset, data); + m_wd179x->command_w(space, offset, data); break; case 9: // FDC TRACK REG - wd17xx_track_w(m_wd179x, space, offset, data); + m_wd179x->track_w(space, offset, data); break; case 10: // FDC SECTOR REG - wd17xx_sector_w(m_wd179x, space, offset, data); + m_wd179x->sector_w(space, offset, data); break; case 11: // FDC DATA REG - wd17xx_data_w(m_wd179x, space, offset, data); + m_wd179x->data_w(space, offset, data); break; } } diff --git a/src/mess/machine/concept_exp.h b/src/mess/machine/concept_exp.h index fc9fab4be13..d4c4d774cf2 100644 --- a/src/mess/machine/concept_exp.h +++ b/src/mess/machine/concept_exp.h @@ -2,6 +2,7 @@ #define __CONCEPT_EXP__ #include "emu.h" +#include "machine/wd17xx.h" class concept_exp_card_device; @@ -84,7 +85,7 @@ public: virtual machine_config_constructor device_mconfig_additions() const; protected: - device_t *m_wd179x; + fd1793_device *m_wd179x; UINT8 m_fdc_local_status; UINT8 m_fdc_local_command; diff --git a/src/mess/machine/dgn_beta.c b/src/mess/machine/dgn_beta.c index ee85794d136..6b2c4e9092b 100644 --- a/src/mess/machine/dgn_beta.c +++ b/src/mess/machine/dgn_beta.c @@ -567,7 +567,7 @@ READ8_MEMBER(dgn_beta_state::d_pia1_pa_r) WRITE8_MEMBER(dgn_beta_state::d_pia1_pa_w) { int HALT_DMA; - device_t *fdc = machine().device(FDC_TAG); + wd2797_device *fdc = machine().device<wd2797_device>(FDC_TAG); /* Only play with halt line if halt bit changed since last write */ if((data & 0x80) != m_d_pia1_pa_last) @@ -589,10 +589,10 @@ WRITE8_MEMBER(dgn_beta_state::d_pia1_pa_w) } /* Drive selects are binary encoded on PA0 & PA1 */ - wd17xx_set_drive(fdc, ~data & DSMask); + fdc->set_drive(~data & DSMask); /* Set density of WD2797 */ - wd17xx_dden_w(fdc, BIT(data, 6)); + fdc->dden_w(BIT(data, 6)); LOG_DISK(("Set density %s\n", BIT(data, 6) ? "low" : "high")); } @@ -813,22 +813,22 @@ const wd17xx_interface dgnbeta_wd17xx_interface = READ8_MEMBER(dgn_beta_state::dgnbeta_wd2797_r) { int result = 0; - device_t *fdc = space.machine().device(FDC_TAG); + wd2797_device *fdc = machine().device<wd2797_device>(FDC_TAG); switch(offset & 0x03) { case 0: - result = wd17xx_status_r(fdc, space, 0); + result = fdc->status_r(space, 0); LOG_DISK(("Disk status=%2.2X\n",result)); break; case 1: - result = wd17xx_track_r(fdc, space, 0); + result = fdc->track_r(space, 0); break; case 2: - result = wd17xx_sector_r(fdc, space, 0); + result = fdc->sector_r(space, 0); break; case 3: - result = wd17xx_data_r(fdc, space, 0); + result = fdc->data_r(space, 0); break; default: break; @@ -839,7 +839,7 @@ READ8_MEMBER(dgn_beta_state::dgnbeta_wd2797_r) WRITE8_MEMBER(dgn_beta_state::dgnbeta_wd2797_w) { - device_t *fdc = space.machine().device(FDC_TAG); + wd2797_device *fdc = machine().device<wd2797_device>(FDC_TAG); m_wd2797_written=1; @@ -849,17 +849,17 @@ WRITE8_MEMBER(dgn_beta_state::dgnbeta_wd2797_w) /* disk head is encoded in the command byte */ /* But only for Type 3/4 commands */ if(data & 0x80) - wd17xx_set_side(fdc,(data & 0x02) ? 1 : 0); - wd17xx_command_w(fdc, space, 0, data); + fdc->set_side((data & 0x02) ? 1 : 0); + fdc->command_w(space, 0, data); break; case 1: - wd17xx_track_w(fdc, space, 0, data); + fdc->track_w(space, 0, data); break; case 2: - wd17xx_sector_w(fdc, space, 0, data); + fdc->sector_w(space, 0, data); break; case 3: - wd17xx_data_w(fdc, space, 0, data); + fdc->data_w(space, 0, data); break; }; } @@ -931,8 +931,8 @@ void dgn_beta_state::dgn_beta_line_interrupt (int data) /********************************* Machine/Driver Initialization ****************************************/ void dgn_beta_state::machine_reset() -{ - device_t *fdc = machine().device(FDC_TAG); +{ + wd2797_device *fdc = machine().device<wd2797_device>(FDC_TAG); pia6821_device *pia_0 = machine().device<pia6821_device>( PIA_0_TAG ); pia6821_device *pia_1 = machine().device<pia6821_device>( PIA_1_TAG ); pia6821_device *pia_2 = machine().device<pia6821_device>( PIA_2_TAG ); @@ -971,12 +971,12 @@ void dgn_beta_state::machine_reset() m_DMA_NMI_LAST = 0x80; /* start with DMA NMI inactive, as pulled up */ // DMA_NMI = CLEAR_LINE; /* start with DMA NMI inactive */ - wd17xx_dden_w(fdc, CLEAR_LINE); - wd17xx_set_drive(fdc, 0); + fdc->dden_w(CLEAR_LINE); + fdc->set_drive(0); m_videoram.set_target(m_ram->pointer(),m_videoram.bytes()); /* Point video ram at the start of physical ram */ - wd17xx_reset(fdc); + fdc->reset(); m_wd2797_written=0; m_maincpu->reset(); diff --git a/src/mess/machine/dgnalpha.c b/src/mess/machine/dgnalpha.c index c1d2a873acc..f27d6a028c9 100644 --- a/src/mess/machine/dgnalpha.c +++ b/src/mess/machine/dgnalpha.c @@ -144,19 +144,19 @@ READ8_MEMBER( dragon_alpha_state::ff20_read ) break; case 12: - result = wd17xx_data_r(m_fdc, space, 0); + result = m_fdc->data_r(space, 0); break; case 13: - result = wd17xx_sector_r(m_fdc, space, 0); + result = m_fdc->sector_r(space, 0); break; case 14: - result = wd17xx_track_r(m_fdc, space, 0); + result = m_fdc->track_r(space, 0); break; case 15: - result = wd17xx_status_r(m_fdc, space, 0); + result = m_fdc->status_r(space, 0); break; } return result; @@ -185,19 +185,19 @@ WRITE8_MEMBER( dragon_alpha_state::ff20_write ) break; case 12: - wd17xx_data_w(m_fdc, space, 0, data); + m_fdc->data_w(space, 0, data); break; case 13: - wd17xx_sector_w(m_fdc, space, 0, data); + m_fdc->sector_w(space, 0, data); break; case 14: - wd17xx_track_w(m_fdc, space, 0, data); + m_fdc->track_w(space, 0, data); break; case 15: - wd17xx_command_w(m_fdc, space, 0, data); + m_fdc->command_w(space, 0, data); /* disk head is encoded in the command byte */ - wd17xx_set_side(m_fdc,(data & 0x02) ? 1 : 0); + m_fdc->set_side((data & 0x02) ? 1 : 0); break; } } @@ -317,16 +317,16 @@ WRITE8_MEMBER( dragon_alpha_state::psg_porta_write ) switch (data & 0xF) { case(0x01) : - wd17xx_set_drive(m_fdc, 0); + m_fdc->set_drive(0); break; case(0x02) : - wd17xx_set_drive(m_fdc, 1); + m_fdc->set_drive(1); break; case(0x04) : - wd17xx_set_drive(m_fdc, 2); + m_fdc->set_drive(2); break; case(0x08) : - wd17xx_set_drive(m_fdc, 3); + m_fdc->set_drive(3); break; } } diff --git a/src/mess/machine/hec2hrp.c b/src/mess/machine/hec2hrp.c index 9c28c5403c9..6af2b4e5d73 100644 --- a/src/mess/machine/hec2hrp.c +++ b/src/mess/machine/hec2hrp.c @@ -102,9 +102,9 @@ TIMER_CALLBACK_MEMBER(hec2hrp_state::Callback_CK) void hec2hrp_state::hector_minidisc_init() { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); //set density - wd17xx_dden_w(fdc, 1);// density select => always 1 (0 ?a plante !) + 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: @@ -118,22 +118,22 @@ void hec2hrp_state::hector_minidisc_init() READ8_MEMBER(hec2hrp_state::hector_179x_register_r) { int data=0; -device_t *fdc = machine().device("wd179x"); +fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); switch (offset & 0x0ff) { /* minidisc floppy disc interface */ case 0x04: - data = wd17xx_status_r(fdc, space, 0); + data = fdc->status_r(space, 0); break; case 0x05: - data = wd17xx_track_r(fdc, space, 0); + data = fdc->track_r(space, 0); break; case 0x06: - data = wd17xx_sector_r(fdc, space, 0); + data = fdc->sector_r(space, 0); break; case 0x07: - data = wd17xx_data_r(fdc, space, 0); + data = fdc->data_r(space, 0); break; default: break; @@ -143,22 +143,22 @@ device_t *fdc = machine().device("wd179x"); } WRITE8_MEMBER(hec2hrp_state::hector_179x_register_w) { -device_t *fdc = machine().device("wd179x"); +fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); switch (offset) { /* minidisc floppy disc interface */ case 0x04: - wd17xx_command_w(fdc, space, 0, data); + fdc->command_w(space, 0, data); break; case 0x05: - wd17xx_track_w(fdc, space, 0, data); + fdc->track_w(space, 0, data); break; case 0x06: - wd17xx_sector_w(fdc, space, 0, data); + fdc->sector_w(space, 0, data); break; case 0x07: /*write into command register*/ - wd17xx_data_w(fdc, space, 0, data); + fdc->data_w(space, 0, data); break; case 0x08: /*General purpose port (0x08) for the minidisk I/O */ @@ -167,11 +167,11 @@ switch (offset) membank("bank2")->set_entry(BIT(data, 5) ? HECTOR_BANK_BASE : HECTOR_BANK_DISC ); // Set drive number - if (BIT(data, 6)) wd17xx_set_drive(fdc, 0); // Set the correct drive number 0 - //if (BIT(data, 7)) wd17xx_set_drive(fdc, 1);// Set the correct drive number 1,never here + if (BIT(data, 6)) fdc->set_drive(0); // Set the correct drive number 0 + //if (BIT(data, 7)) fdc->set_drive(1);// Set the correct drive number 1,never here // Set side - wd17xx_set_side(fdc,BIT(data, 4) ? 1 : 0);// side select + fdc->set_side(BIT(data, 4) ? 1 : 0);// side select } break; @@ -230,6 +230,7 @@ WRITE8_MEMBER(hec2hrp_state::hector_keyboard_w) READ8_MEMBER(hec2hrp_state::hector_keyboard_r) { UINT8 data = 0xff; + static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7", "KEY8" }; if (offset ==7) /* Only when joy reading*/ @@ -254,8 +255,7 @@ READ8_MEMBER(hec2hrp_state::hector_keyboard_r) /* floppy md master reset */ if (isHectorWithMiniDisc()) - wd17xx_mr_w(machine().device("wd179x"), 1); - + machine().device<fd1793_device>("wd179x")->mr_w(1); } else /* aviable for BR machines */ diff --git a/src/mess/machine/mbc55x.c b/src/mess/machine/mbc55x.c index bde0c50d110..47432838614 100644 --- a/src/mess/machine/mbc55x.c +++ b/src/mess/machine/mbc55x.c @@ -82,8 +82,8 @@ WRITE8_MEMBER( mbc55x_state::mbc55x_ppi_portb_w ) WRITE8_MEMBER( mbc55x_state::mbc55x_ppi_portc_w ) { - wd17xx_set_drive(m_fdc,(data & 0x03)); - wd17xx_set_side(m_fdc, BIT(data, 2)); + m_fdc->set_drive((data & 0x03)); + m_fdc->set_side(BIT(data, 2)); } I8255_INTERFACE( mbc55x_ppi8255_interface ) @@ -156,12 +156,12 @@ WRITE8_MEMBER( mbc55x_state::vram_page_w ) READ8_MEMBER(mbc55x_state::mbc55x_disk_r) { - return wd17xx_r(m_fdc, space, offset>>1); + return m_fdc->read(space, offset>>1); } WRITE8_MEMBER(mbc55x_state::mbc55x_disk_w) { - wd17xx_w(m_fdc, space, offset>>1, data); + m_fdc->write(space, offset>>1, data); } WRITE_LINE_MEMBER( mbc55x_state::mbc55x_fdc_intrq_w ) diff --git a/src/mess/machine/msx_slot.c b/src/mess/machine/msx_slot.c index 97604e9d157..3e11bec538c 100644 --- a/src/mess/machine/msx_slot.c +++ b/src/mess/machine/msx_slot.c @@ -1231,7 +1231,7 @@ MSX_SLOT_INIT(diskrom) MSX_SLOT_RESET(diskrom) { msx_state *drvstate = machine.driver_data<msx_state>(); - wd17xx_reset(drvstate->m_wd179x); + drvstate->m_wd179x->reset(); } static READ8_HANDLER (msx_diskrom_page1_r) @@ -1239,10 +1239,10 @@ static READ8_HANDLER (msx_diskrom_page1_r) msx_state *state = space.machine().driver_data<msx_state>(); switch (offset) { - case 0: return wd17xx_status_r (state->m_wd179x, space, 0); - case 1: return wd17xx_track_r (state->m_wd179x, space, 0); - case 2: return wd17xx_sector_r (state->m_wd179x, space, 0); - case 3: return wd17xx_data_r (state->m_wd179x, space, 0); + case 0: return state->m_wd179x->status_r (space, 0); + case 1: return state->m_wd179x->track_r (space, 0); + case 2: return state->m_wd179x->sector_r (space, 0); + case 3: return state->m_wd179x->data_r (space, 0); case 7: return state->m_dsk_stat; default: return state->m_state[1]->m_mem[offset + 0x3ff8]; @@ -1257,13 +1257,13 @@ static READ8_HANDLER (msx_diskrom_page2_r) switch (offset) { case 0x7f8: - return wd17xx_status_r (state->m_wd179x, space, 0); + return state->m_wd179x->status_r (space, 0); case 0x7f9: - return wd17xx_track_r (state->m_wd179x, space, 0); + return state->m_wd179x->track_r (space, 0); case 0x7fa: - return wd17xx_sector_r (state->m_wd179x, space, 0); + return state->m_wd179x->sector_r (space, 0); case 0x7fb: - return wd17xx_data_r (state->m_wd179x, space, 0); + return state->m_wd179x->data_r (space, 0); case 0x7ff: return state->m_dsk_stat; default: @@ -1314,23 +1314,23 @@ MSX_SLOT_WRITE(diskrom) switch (addr) { case 0x7ff8: - wd17xx_command_w (drvstate->m_wd179x, space, 0, val); + drvstate->m_wd179x->command_w (space, 0, val); break; case 0x7ff9: - wd17xx_track_w (drvstate->m_wd179x, space, 0, val); + drvstate->m_wd179x->track_w (space, 0, val); break; case 0x7ffa: - wd17xx_sector_w (drvstate->m_wd179x, space, 0, val); + drvstate->m_wd179x->sector_w (space, 0, val); break; case 0x7ffb: - wd17xx_data_w (drvstate->m_wd179x, space, 0, val); + drvstate->m_wd179x->data_w (space, 0, val); break; case 0x7ffc: - wd17xx_set_side (drvstate->m_wd179x,val & 1); + drvstate->m_wd179x->set_side (val & 1); state->m_mem[0x3ffc] = val | 0xfe; break; case 0x7ffd: - wd17xx_set_drive (drvstate->m_wd179x,val & 1); + drvstate->m_wd179x->set_drive (val & 1); if ((state->m_mem[0x3ffd] ^ val) & 0x40) { set_led_status (machine, 0, !(val & 0x40)); @@ -1358,7 +1358,7 @@ MSX_SLOT_INIT(diskrom2) MSX_SLOT_RESET(diskrom2) { msx_state *drvstate = machine.driver_data<msx_state>(); - wd17xx_reset (drvstate->m_wd179x); + drvstate->m_wd179x->reset(); } static READ8_HANDLER (msx_diskrom2_page1_r) @@ -1366,10 +1366,10 @@ static READ8_HANDLER (msx_diskrom2_page1_r) msx_state *state = space.machine().driver_data<msx_state>(); switch (offset) { - case 0: return wd17xx_status_r(state->m_wd179x, space, 0); - case 1: return wd17xx_track_r(state->m_wd179x, space, 0); - case 2: return wd17xx_sector_r(state->m_wd179x, space, 0); - case 3: return wd17xx_data_r(state->m_wd179x, space, 0); + case 0: return state->m_wd179x->status_r(space, 0); + case 1: return state->m_wd179x->track_r(space, 0); + case 2: return state->m_wd179x->sector_r(space, 0); + case 3: return state->m_wd179x->data_r(space, 0); case 4: return state->m_dsk_stat; default: return state->m_state[1]->m_mem[offset + 0x3ff8]; @@ -1384,13 +1384,13 @@ static READ8_HANDLER (msx_diskrom2_page2_r) switch (offset) { case 0x7b8: - return wd17xx_status_r (state->m_wd179x, space, 0); + return state->m_wd179x->status_r (space, 0); case 0x7b9: - return wd17xx_track_r (state->m_wd179x, space, 0); + return state->m_wd179x->track_r (space, 0); case 0x7ba: - return wd17xx_sector_r (state->m_wd179x, space, 0); + return state->m_wd179x->sector_r (space, 0); case 0x7bb: - return wd17xx_data_r (state->m_wd179x, space, 0); + return state->m_wd179x->data_r (space, 0); case 0x7bc: return state->m_dsk_stat; default: @@ -1440,21 +1440,21 @@ MSX_SLOT_WRITE(diskrom2) switch (addr) { case 0x7fb8: - wd17xx_command_w (drvstate->m_wd179x, space, 0, val); + drvstate->m_wd179x->command_w (space, 0, val); break; case 0x7fb9: - wd17xx_track_w (drvstate->m_wd179x, space, 0, val); + drvstate->m_wd179x->track_w (space, 0, val); break; case 0x7fba: - wd17xx_sector_w (drvstate->m_wd179x, space, 0, val); + drvstate->m_wd179x->sector_w (space, 0, val); break; case 0x7fbb: - wd17xx_data_w (drvstate->m_wd179x, space, 0, val); + drvstate->m_wd179x->data_w (space, 0, val); break; case 0x7fbc: - wd17xx_set_side (drvstate->m_wd179x,val & 1); + drvstate->m_wd179x->set_side (val & 1); state->m_mem[0x3fbc] = val | 0xfe; - wd17xx_set_drive (drvstate->m_wd179x,val & 1); + drvstate->m_wd179x->set_drive (val & 1); if ((state->m_mem[0x3fbc] ^ val) & 0x40) { set_led_status (machine, 0, !(val & 0x40)); diff --git a/src/mess/machine/nascom1.c b/src/mess/machine/nascom1.c index f9f3737050a..e214f544f72 100644 --- a/src/mess/machine/nascom1.c +++ b/src/mess/machine/nascom1.c @@ -54,16 +54,16 @@ READ8_MEMBER(nascom1_state::nascom2_fdc_select_r) WRITE8_MEMBER(nascom1_state::nascom2_fdc_select_w) { - device_t *fdc = machine().device("wd1793"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); m_nascom2_fdc.select = data; logerror("nascom2_fdc_select_w: %02x\n", data); - if (data & 0x01) wd17xx_set_drive(fdc,0); - if (data & 0x02) wd17xx_set_drive(fdc,1); - if (data & 0x04) wd17xx_set_drive(fdc,2); - if (data & 0x08) wd17xx_set_drive(fdc,3); - if (data & 0x10) wd17xx_set_side(fdc,(data & 0x10) >> 4); + if (data & 0x01) fdc->set_drive(0); + if (data & 0x02) fdc->set_drive(1); + if (data & 0x04) fdc->set_drive(2); + if (data & 0x08) fdc->set_drive(3); + if (data & 0x10) fdc->set_side((data & 0x10) >> 4); } diff --git a/src/mess/machine/oric.c b/src/mess/machine/oric.c index e607c9e959a..38d1430de7e 100644 --- a/src/mess/machine/oric.c +++ b/src/mess/machine/oric.c @@ -641,23 +641,23 @@ WRITE_LINE_MEMBER(oric_state::oric_jasmin_wd179x_drq_w) READ8_MEMBER(oric_state::oric_jasmin_r) { - device_t *fdc = machine().device("wd179x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd179x"); unsigned char data = 0x0ff; switch (offset & 0x0f) { /* jasmin floppy disc interface */ case 0x04: - data = wd17xx_status_r(fdc, space, 0); + data = fdc->status_r(space, 0); break; case 0x05: - data =wd17xx_track_r(fdc, space, 0); + data = fdc->track_r(space, 0); break; case 0x06: - data = wd17xx_sector_r(fdc, space, 0); + data = fdc->sector_r(space, 0); break; case 0x07: - data = wd17xx_data_r(fdc, space, 0); + data = fdc->data_r(space, 0); break; default: data = m_via6522_0->read(space,offset & 0x0f); @@ -671,29 +671,29 @@ READ8_MEMBER(oric_state::oric_jasmin_r) WRITE8_MEMBER(oric_state::oric_jasmin_w) { - device_t *fdc = machine().device("wd179x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd179x"); switch (offset & 0x0f) { /* microdisc floppy disc interface */ case 0x04: - wd17xx_command_w(fdc, space, 0, data); + fdc->command_w( space, 0, data); break; case 0x05: - wd17xx_track_w(fdc, space, 0, data); + fdc->track_w(space, 0, data); break; case 0x06: - wd17xx_sector_w(fdc, space, 0, data); + fdc->sector_w(space, 0, data); break; case 0x07: - wd17xx_data_w(fdc, space, 0, data); + fdc->data_w(space, 0, data); break; /* bit 0 = side */ case 0x08: - wd17xx_set_side(fdc,data & 0x01); + fdc->set_side(data & 0x01); break; /* any write will cause wd179x to reset */ case 0x09: - wd17xx_reset(fdc); + fdc->reset(); break; case 0x0a: //logerror("jasmin overlay ram w: %02x PC: %04x\n", data, m_maincpu->pc()); @@ -710,7 +710,7 @@ WRITE8_MEMBER(oric_state::oric_jasmin_w) case 0x0d: case 0x0e: case 0x0f: - wd17xx_set_drive(fdc,offset & 0x03); + fdc->set_drive(offset & 0x03); break; default: @@ -856,22 +856,22 @@ void oric_state::oric_microdisc_set_mem_0x0c000() READ8_MEMBER(oric_state::oric_microdisc_r) { unsigned char data = 0x0ff; - device_t *fdc = machine().device("wd179x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd179x"); switch (offset & 0x0ff) { /* microdisc floppy disc interface */ case 0x00: - data = wd17xx_status_r(fdc, space, 0); + data = fdc->status_r(space, 0); break; case 0x01: - data =wd17xx_track_r(fdc, space, 0); + data = fdc->track_r(space, 0); break; case 0x02: - data = wd17xx_sector_r(fdc, space, 0); + data = fdc->sector_r(space, 0); break; case 0x03: - data = wd17xx_data_r(fdc, space, 0); + data = fdc->data_r(space, 0); break; case 0x04: data = m_port_314_r | 0x07f; @@ -893,21 +893,21 @@ READ8_MEMBER(oric_state::oric_microdisc_r) WRITE8_MEMBER(oric_state::oric_microdisc_w) { - device_t *fdc = machine().device("wd179x"); + wd1770_device *fdc = machine().device<wd1770_device>("wd179x"); switch (offset & 0x0ff) { /* microdisc floppy disc interface */ case 0x00: - wd17xx_command_w(fdc, space, 0, data); + fdc->command_w(space, 0, data); break; case 0x01: - wd17xx_track_w(fdc, space, 0, data); + fdc->track_w(space, 0, data); break; case 0x02: - wd17xx_sector_w(fdc, space, 0, data); + fdc->sector_w(space, 0, data); break; case 0x03: - wd17xx_data_w(fdc, space, 0, data); + fdc->data_w(space, 0, data); break; case 0x04: { @@ -919,9 +919,9 @@ WRITE8_MEMBER(oric_state::oric_microdisc_w) /* bit 4: side */ /* bit 3: double density enable */ /* bit 0: enable FDC IRQ to trigger IRQ on CPU */ - wd17xx_set_drive(fdc,(data>>5) & 0x03); - wd17xx_set_side(fdc,(data>>4) & 0x01); - wd17xx_dden_w(fdc, !BIT(data, 3)); + fdc->set_drive((data>>5) & 0x03); + fdc->set_side((data>>4) & 0x01); + fdc->dden_w(!BIT(data, 3)); oric_microdisc_set_mem_0x0c000(); oric_microdisc_refresh_wd179x_ints(); diff --git a/src/mess/machine/osborne1.c b/src/mess/machine/osborne1.c index 6f22f9b7498..27237a81bbb 100644 --- a/src/mess/machine/osborne1.c +++ b/src/mess/machine/osborne1.c @@ -53,7 +53,7 @@ READ8_MEMBER( osborne1_state::osborne1_2000_r ) switch( offset & 0x0F00 ) { case 0x100: /* Floppy */ - data = wd17xx_r( m_fdc, space, offset ); + data = m_fdc->read( space, offset ); break; case 0x200: /* Keyboard */ /* Row 0 */ @@ -104,7 +104,7 @@ WRITE8_MEMBER( osborne1_state::osborne1_2000_w ) switch( offset & 0x0F00 ) { case 0x100: /* Floppy */ - wd17xx_w( m_fdc, space, offset, data ); + m_fdc->write(space, offset, data ); break; case 0x900: /* IEEE488 PIA */ m_pia0->write(space, offset & 0x03, data ); @@ -260,7 +260,7 @@ WRITE_LINE_MEMBER( osborne1_state::video_pia_out_cb2_dummy ) WRITE8_MEMBER( osborne1_state::video_pia_port_a_w ) { - wd17xx_dden_w(m_fdc, BIT(data, 0)); + m_fdc->dden_w(BIT(data, 0)); data -= 0xea; // remove bias @@ -278,10 +278,10 @@ WRITE8_MEMBER( osborne1_state::video_pia_port_b_w ) m_beep_state = BIT(data, 5); if (BIT(data, 6)) - wd17xx_set_drive( m_fdc, 0 ); + m_fdc->set_drive( 0 ); else if (BIT(data, 7)) - wd17xx_set_drive( m_fdc, 1 ); + m_fdc->set_drive( 1 ); //logerror("Video pia port b write: %02X\n", data ); } @@ -396,19 +396,19 @@ static void osborne1_load_proc(device_image_interface &image) switch( size ) { case 40 * 10 * 256: - wd17xx_dden_w(state->m_fdc, ASSERT_LINE); + state->m_fdc->dden_w(ASSERT_LINE); break; case 40 * 5 * 1024: - wd17xx_dden_w(state->m_fdc, CLEAR_LINE); + state->m_fdc->dden_w(CLEAR_LINE); break; case 40 * 8 * 512: - wd17xx_dden_w(state->m_fdc, ASSERT_LINE); + state->m_fdc->dden_w(ASSERT_LINE); break; case 40 * 18 * 128: - wd17xx_dden_w(state->m_fdc, ASSERT_LINE); + state->m_fdc->dden_w(ASSERT_LINE); break; case 40 * 9 * 512: - wd17xx_dden_w(state->m_fdc, CLEAR_LINE); + state->m_fdc->dden_w(CLEAR_LINE); break; } } diff --git a/src/mess/machine/partner.c b/src/mess/machine/partner.c index 476f2ca96e6..bd520ae5e23 100644 --- a/src/mess/machine/partner.c +++ b/src/mess/machine/partner.c @@ -43,7 +43,7 @@ const wd17xx_interface partner_wd17xx_interface = MACHINE_START_MEMBER(partner_state,partner) { - wd17xx_set_pause_time(m_fdc, 10); + m_fdc->set_pause_time(10); } void partner_state::partner_window_1(UINT8 bank_num, UINT16 offset,UINT8 *rom) @@ -80,11 +80,11 @@ void partner_state::partner_window_2(UINT8 bank_num, UINT16 offset,UINT8 *rom) READ8_MEMBER(partner_state::partner_floppy_r){ if (offset<0x100) { switch(offset & 3) { - case 0x00 : return wd17xx_status_r(m_fdc,space, 0); - case 0x01 : return wd17xx_track_r(m_fdc,space, 0); - case 0x02 : return wd17xx_sector_r(m_fdc,space, 0); + case 0x00 : return m_fdc->status_r(space, 0); + case 0x01 : return m_fdc->track_r(space, 0); + case 0x02 : return m_fdc->sector_r(space, 0); default : - return wd17xx_data_r(m_fdc,space, 0); + return m_fdc->data_r(space, 0); } } else { return 0; @@ -94,25 +94,25 @@ READ8_MEMBER(partner_state::partner_floppy_r){ WRITE8_MEMBER(partner_state::partner_floppy_w){ if (offset<0x100) { switch(offset & 3) { - case 0x00 : wd17xx_command_w(m_fdc,space, 0,data); break; - case 0x01 : wd17xx_track_w(m_fdc,space, 0,data);break; - case 0x02 : wd17xx_sector_w(m_fdc,space, 0,data);break; - default : wd17xx_data_w(m_fdc,space, 0,data);break; + case 0x00 : m_fdc->command_w(space, 0,data); break; + case 0x01 : m_fdc->track_w(space, 0,data);break; + case 0x02 : m_fdc->sector_w(space, 0,data);break; + 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); if (((data >> 6) & 1)==1) { - wd17xx_set_drive(m_fdc,0); + 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); } if (((data >> 3) & 1)==1) { - wd17xx_set_drive(m_fdc,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); } - wd17xx_set_side(m_fdc,data >> 7); + m_fdc->set_side(data >> 7); } } @@ -360,11 +360,11 @@ WRITE_LINE_MEMBER(partner_state::hrq_w) READ8_MEMBER(partner_state::partner_fdc_r) { - return wd17xx_data_r(m_fdc,space,offset); + return m_fdc->data_r(space,offset); } WRITE8_MEMBER(partner_state::partner_fdc_w) { - wd17xx_data_w(m_fdc,space,offset,data); + m_fdc->data_w(space,offset,data); } I8257_INTERFACE( partner_dma ) diff --git a/src/mess/machine/pk8020.c b/src/mess/machine/pk8020.c index f2ebee3e28d..227c18acc69 100644 --- a/src/mess/machine/pk8020.c +++ b/src/mess/machine/pk8020.c @@ -156,10 +156,10 @@ READ8_MEMBER(pk8020_state::devices_r) } break; case 0x18: switch(offset & 3) { - case 0 : return wd17xx_status_r(m_wd1793,space, 0); - case 1 : return wd17xx_track_r(m_wd1793,space, 0); - case 2 : return wd17xx_sector_r(m_wd1793,space, 0); - case 3 : return wd17xx_data_r(m_wd1793,space, 0); + case 0 : return m_wd1793->status_r(space, 0); + case 1 : return m_wd1793->track_r(space, 0); + case 2 : return m_wd1793->sector_r(space, 0); + case 3 : return m_wd1793->data_r(space, 0); } break; case 0x20: switch(offset & 1) { @@ -186,10 +186,10 @@ WRITE8_MEMBER(pk8020_state::devices_w) } break; case 0x18: switch(offset & 3) { - case 0 : wd17xx_command_w(m_wd1793,space, 0,data);break; - case 1 : wd17xx_track_w(m_wd1793,space, 0,data);break; - case 2 : wd17xx_sector_w(m_wd1793,space, 0,data);break; - case 3 : wd17xx_data_w(m_wd1793,space, 0,data);break; + case 0 : m_wd1793->command_w(space, 0,data);break; + case 1 : m_wd1793->track_w(space, 0,data);break; + case 2 : m_wd1793->sector_w(space, 0,data);break; + case 3 : m_wd1793->data_w(space, 0,data);break; } break; case 0x20: switch(offset & 1) { @@ -844,21 +844,21 @@ WRITE8_MEMBER(pk8020_state::pk8020_portb_w) 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); - wd17xx_set_side(m_wd1793,BIT(data,4)); + m_wd1793->set_side(BIT(data,4)); if (BIT(data,0)) { - wd17xx_set_drive(m_wd1793,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); } else if (BIT(data,1)) { - wd17xx_set_drive(m_wd1793,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); } else if (BIT(data,2)) { - wd17xx_set_drive(m_wd1793,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); } else if (BIT(data,3)) { - wd17xx_set_drive(m_wd1793,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); } diff --git a/src/mess/machine/rm380z.c b/src/mess/machine/rm380z.c index d5dc126170d..548fb1749c6 100644 --- a/src/mess/machine/rm380z.c +++ b/src/mess/machine/rm380z.c @@ -208,7 +208,7 @@ WRITE8_MEMBER( rm380z_state::keyboard_put ) WRITE8_MEMBER( rm380z_state::disk_0_control ) { - device_t *fdc = machine().device("wd1771"); + fd1771_device *fdc = machine().device<fd1771_device>("wd1771"); //printf("disk drive port0 write [%x]\n",data); @@ -216,13 +216,13 @@ WRITE8_MEMBER( rm380z_state::disk_0_control ) if (data&0x01) { // drive select bit 0 - wd17xx_set_drive(fdc,0); + fdc->set_drive(0); } if (data&0x02) { // drive select bit 1 - wd17xx_set_drive(fdc,1); + fdc->set_drive(1); } if (data&0x08) @@ -233,11 +233,11 @@ WRITE8_MEMBER( rm380z_state::disk_0_control ) // "MSEL (dir/side select bit)" if (data&0x20) { - wd17xx_set_side(fdc,1); + fdc->set_side(1); } else { - wd17xx_set_side(fdc,0); + fdc->set_side(0); } // set drive en- (?) @@ -274,7 +274,7 @@ void rm380z_state::machine_reset() memset(m_vram,0,RM380Z_SCREENSIZE); config_memory_map(); - wd17xx_reset(machine().device("wd1771")); + machine().device("wd1771")->reset(); init_graphic_chars(); } diff --git a/src/mess/machine/rmnimbus.c b/src/mess/machine/rmnimbus.c index 80f65e5da3e..7a58dbcb506 100644 --- a/src/mess/machine/rmnimbus.c +++ b/src/mess/machine/rmnimbus.c @@ -2202,13 +2202,13 @@ READ16_MEMBER(rmnimbus_state::sio_serial_receive) void rmnimbus_state::fdc_reset() { - device_t *fdc = machine().device(FDC_TAG); + wd2793_device *fdc = machine().device<wd2793_device>(FDC_TAG); m_nimbus_drives.reg400=0; m_nimbus_drives.reg410_in=0; m_nimbus_drives.reg410_out=0; m_nimbus_drives.int_ff=0; - wd17xx_set_pause_time(fdc,FDC_PAUSE); + fdc->set_pause_time(FDC_PAUSE); } void rmnimbus_state::set_disk_int(int state) @@ -2271,7 +2271,7 @@ UINT8 rmnimbus_state::fdc_driveno(UINT8 drivesel) READ8_MEMBER(rmnimbus_state::nimbus_disk_r) { int result = 0; - device_t *fdc = machine().device(FDC_TAG); + 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()]); @@ -2279,17 +2279,17 @@ READ8_MEMBER(rmnimbus_state::nimbus_disk_r) switch(offset*2) { case 0x08 : - result = wd17xx_status_r(fdc, space, 0); + result = fdc->status_r(space, 0); if (LOG_DISK_FDD) logerror("Disk status=%2.2X\n",result); break; case 0x0A : - result = wd17xx_track_r(fdc, space, 0); + result = fdc->track_r(space, 0); break; case 0x0C : - result = wd17xx_sector_r(fdc, space, 0); + result = fdc->sector_r(space, 0); break; case 0x0E : - result = wd17xx_data_r(fdc, space, 0); + result = fdc->data_r(space, 0); break; case 0x10 : m_nimbus_drives.reg410_in &= ~FDC_BITS_410; @@ -2337,7 +2337,7 @@ READ8_MEMBER(rmnimbus_state::nimbus_disk_r) WRITE8_MEMBER(rmnimbus_state::nimbus_disk_w) { - device_t *fdc = machine().device(FDC_TAG); + wd2793_device *fdc = machine().device<wd2793_device>(FDC_TAG); int pc=space.device().safe_pc(); UINT8 reg400_old = m_nimbus_drives.reg400; @@ -2351,11 +2351,11 @@ WRITE8_MEMBER(rmnimbus_state::nimbus_disk_w) { case 0x00 : m_nimbus_drives.reg400=data; - wd17xx_set_drive(fdc,FDC_DRIVE()); - wd17xx_set_side(fdc, FDC_SIDE()); + fdc->set_drive(FDC_DRIVE()); + fdc->set_side(FDC_SIDE()); // Nimbus FDC is hard wired for double density - //wd17xx_set_density(fdc, DEN_MFM_LO); + //fdc->set_density(DEN_MFM_LO); // if we enable hdc drq with a pending condition, act on it if((data & HDC_DRQ_MASK) && (~reg400_old & HDC_DRQ_MASK)) @@ -2363,16 +2363,16 @@ WRITE8_MEMBER(rmnimbus_state::nimbus_disk_w) break; case 0x08 : - wd17xx_command_w(fdc, space, 0, data); + fdc->command_w(space, 0, data); break; case 0x0A : - wd17xx_track_w(fdc, space, 0, data); + fdc->track_w(space, 0, data); break; case 0x0C : - wd17xx_sector_w(fdc, space, 0, data); + fdc->sector_w(space, 0, data); break; case 0x0E : - wd17xx_data_w(fdc, space, 0, data); + fdc->data_w(space, 0, data); break; case 0x10 : hdc_ctrl_write(data); diff --git a/src/mess/machine/svi318.c b/src/mess/machine/svi318.c index 84305b2b26e..a4adfbab7c4 100644 --- a/src/mess/machine/svi318.c +++ b/src/mess/machine/svi318.c @@ -291,15 +291,15 @@ const wd17xx_interface svi_wd17xx_interface = WRITE8_MEMBER(svi318_state::svi318_fdc_drive_motor_w) { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); switch (data & 3) { case 1: - wd17xx_set_drive(fdc,0); + fdc->set_drive(0); m_fdc.driveselect = 0; break; case 2: - wd17xx_set_drive(fdc,1); + fdc->set_drive(1); m_fdc.driveselect = 1; break; } @@ -307,10 +307,10 @@ WRITE8_MEMBER(svi318_state::svi318_fdc_drive_motor_w) WRITE8_MEMBER(svi318_state::svi318_fdc_density_side_w) { - device_t *fdc = machine().device("wd179x"); + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); - wd17xx_dden_w(fdc, BIT(data, 0)); - wd17xx_set_side(fdc, BIT(data, 1)); + fdc->dden_w(BIT(data, 0)); + fdc->set_side(BIT(data, 1)); } READ8_MEMBER(svi318_state::svi318_fdc_irqdrq_r) @@ -741,6 +741,8 @@ READ8_MEMBER(svi318_state::svi318_io_ext_r) { return 0xff; } + + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); switch( offset ) { @@ -771,20 +773,16 @@ READ8_MEMBER(svi318_state::svi318_io_ext_r) break; case 0x30: - device = machine().device("wd179x"); - data = wd17xx_status_r(device, space, 0); + data = fdc->status_r(space, 0); break; case 0x31: - device = machine().device("wd179x"); - data = wd17xx_track_r(device, space, 0); + data = fdc->track_r(space, 0); break; case 0x32: - device = machine().device("wd179x"); - data = wd17xx_sector_r(device, space, 0); + data = fdc->sector_r(space, 0); break; case 0x33: - device = machine().device("wd179x"); - data = wd17xx_data_r(device, space, 0); + data = fdc->data_r(space, 0); break; case 0x34: data = svi318_fdc_irqdrq_r(space, 0); @@ -806,6 +804,8 @@ WRITE8_MEMBER(svi318_state::svi318_io_ext_w) { return; } + + fd1793_device *fdc = machine().device<fd1793_device>("wd179x"); switch( offset ) { @@ -840,20 +840,16 @@ WRITE8_MEMBER(svi318_state::svi318_io_ext_w) break; case 0x30: - device = machine().device("wd179x"); - wd17xx_command_w(device, space, 0, data); + fdc->command_w(space, 0, data); break; case 0x31: - device = machine().device("wd179x"); - wd17xx_track_w(device, space, 0, data); + fdc->track_w(space, 0, data); break; case 0x32: - device = machine().device("wd179x"); - wd17xx_sector_w(device, space, 0, data); + fdc->sector_w(space, 0, data); break; case 0x33: - device = machine().device("wd179x"); - wd17xx_data_w(device, space, 0, data); + fdc->data_w(space, 0, data); break; case 0x34: svi318_fdc_drive_motor_w(space, 0, data); diff --git a/src/mess/machine/thomflop.c b/src/mess/machine/thomflop.c index 52923273185..feb6b4c6ac4 100644 --- a/src/mess/machine/thomflop.c +++ b/src/mess/machine/thomflop.c @@ -273,10 +273,10 @@ static UINT8 to7_5p14_select; READ8_MEMBER( thomson_state::to7_5p14_r ) { - device_t *fdc = machine().device("wd2793"); + wd2793_device *fdc = machine().device<wd2793_device>("wd2793"); if ( offset < 4 ) - return wd17xx_r( fdc, space, offset ); + return fdc->read(space, offset ); else if ( offset == 8 ) return to7_5p14_select; else @@ -288,9 +288,9 @@ READ8_MEMBER( thomson_state::to7_5p14_r ) WRITE8_HANDLER( thomson_state::to7_5p14_w ) { - device_t *fdc = machine().device("wd2793"); + wd2793_device *fdc = machine().device<wd2793_device>("wd2793"); if ( offset < 4 ) - wd17xx_w( fdc, space, offset, data ); + fdc->write(space, offset, data ); else if ( offset == 8 ) { /* drive select */ @@ -307,15 +307,15 @@ WRITE8_HANDLER( thomson_state::to7_5p14_w ) logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", machine().time().as_double(), m_maincpu->pc(), data ); } - wd17xx_dden_w(fdc, BIT(data, 7)); + fdc->dden_w(BIT(data, 7)); to7_5p14_select = data; if ( drive != -1 ) { thom_floppy_active( 0 ); - wd17xx_set_drive( fdc, drive ); - wd17xx_set_side( fdc, side ); + fdc->set_drive( drive ); + fdc->set_side( side ); LOG(( "%f $%04x to7_5p14_w: $%02X set drive=%i side=%i density=%s\n", machine().time().as_double(), m_maincpu->pc(), data, drive, side, (BIT(data, 7) ? "FM" : "MFM"))); @@ -330,9 +330,9 @@ WRITE8_HANDLER( thomson_state::to7_5p14_w ) void thomson_state::to7_5p14_reset() { - device_t *fdc = machine().device("wd2793"); + wd2793_device *fdc = machine().device<wd2793_device>("wd2793"); LOG(( "to7_5p14_reset: CD 90-640 controller\n" )); - wd17xx_reset(fdc); + fdc->reset(); } @@ -1926,7 +1926,7 @@ void thomson_state::thomson_index_callback(device_t *device, int state) break; case 2: - wd17xx_index_pulse_callback(machine().device("wd2793"), device, state); + machine().device<wd2793_device>("wd2793")->index_pulse_callback(device, state); break; case 3: diff --git a/src/mess/machine/ti99/bwg.c b/src/mess/machine/ti99/bwg.c index 9224db0fee5..1bcd1887a51 100644 --- a/src/mess/machine/ti99/bwg.c +++ b/src/mess/machine/ti99/bwg.c @@ -811,7 +811,7 @@ READ8Z_MEMBER(snug_bwg_legacy_device::readz) // .... ..11 1111 0xx0 // Note that the value is inverted again on the board, // so we can drop the inversion - if (!space.debugger_access()) *value = wd17xx_r(m_wd1773, space, (m_address >> 1)&0x03); + if (!space.debugger_access()) *value = m_wd1773->read(space, (m_address >> 1)&0x03); if (TRACE_RW) logerror("bwg: read FDC: %04x -> %02x\n", m_address & 0xffff, *value); if (TRACE_DATA) { @@ -895,7 +895,7 @@ WRITE8_MEMBER(snug_bwg_legacy_device::write) // Note that the value is inverted again on the board, // so we can drop the inversion if (TRACE_RW) logerror("bwg: write FDC: %04x <- %02x\n", m_address & 0xffff, data); - if (!space.debugger_access()) wd17xx_w(m_wd1773, space, (m_address >> 1)&0x03, data); + if (!space.debugger_access()) m_wd1773->write(space, (m_address >> 1)&0x03, data); } else { @@ -998,7 +998,7 @@ WRITE8_MEMBER(snug_bwg_legacy_device::cruwrite) if (m_DSEL != 0) logerror("bwg: Multiple drives selected, %02x\n", m_DSEL); m_DSEL |= drivebit; - wd17xx_set_drive(m_wd1773, drive); + m_wd1773->set_drive(drive); } } else @@ -1009,13 +1009,13 @@ WRITE8_MEMBER(snug_bwg_legacy_device::cruwrite) /* Select side of disk (bit 7) */ m_SIDE = data; if (TRACE_CRU) logerror("bwg: set side (bit 7) = %d\n", data); - wd17xx_set_side(m_wd1773, m_SIDE); + m_wd1773->set_side(m_SIDE); break; case 10: /* double density enable (active low) */ if (TRACE_CRU) logerror("bwg: set double density (bit 10) = %d\n", data); - wd17xx_dden_w(m_wd1773, (data != 0) ? ASSERT_LINE : CLEAR_LINE); + m_wd1773->dden_w((data != 0) ? ASSERT_LINE : CLEAR_LINE); break; case 11: diff --git a/src/mess/machine/ti99/ti_fdc.c b/src/mess/machine/ti99/ti_fdc.c index 04d2d42c503..b719db7bdfa 100644 --- a/src/mess/machine/ti99/ti_fdc.c +++ b/src/mess/machine/ti99/ti_fdc.c @@ -508,7 +508,7 @@ READ8Z_MEMBER(ti_fdc_legacy_device::readz) if (m_WDsel && ((m_address & 9)==0)) { - if (!space.debugger_access()) reply = wd17xx_r(m_fd1771, space, (offset >> 1)&0x03); + if (!space.debugger_access()) reply = m_fd1771->read(space, (offset >> 1)&0x03); if (TRACE_DATA) { if ((m_address & 0xffff)==0x5ff6) logerror("%02x ", ~reply & 0xff); @@ -534,7 +534,7 @@ WRITE8_MEMBER(ti_fdc_legacy_device::write) // 0101 1111 1111 1xx0 if (m_WDsel && ((m_address & 9)==8)) { - if (!space.debugger_access()) wd17xx_w(m_fd1771, space, (offset >> 1)&0x03, data); + if (!space.debugger_access()) m_fd1771->write(space, (offset >> 1)&0x03, data); } } } @@ -626,7 +626,7 @@ WRITE8_MEMBER(ti_fdc_legacy_device::cruwrite) if (m_DSEL != 0) logerror("tifdc: Multiple drives selected, %02x\n", m_DSEL); m_DSEL |= drivebit; - wd17xx_set_drive(m_fd1771, drive); + m_fd1771->set_drive(drive); } } else @@ -637,7 +637,7 @@ WRITE8_MEMBER(ti_fdc_legacy_device::cruwrite) /* Select side of disk (bit 7) */ m_SIDSEL = data; if (TRACE_CRU) logerror("tifdc: set side (bit 7) = %d\n", data); - wd17xx_set_side(m_fd1771, data); + m_fd1771->set_side(data); break; } } diff --git a/src/mess/machine/trs80.c b/src/mess/machine/trs80.c index 94adaaf533f..91e7f423193 100644 --- a/src/mess/machine/trs80.c +++ b/src/mess/machine/trs80.c @@ -520,11 +520,11 @@ WRITE8_MEMBER( trs80_state::trs80m4_f4_w ) if (drive < 4) { - wd17xx_set_drive(m_fdc,drive); - wd17xx_set_side(m_fdc,m_head); + m_fdc->set_drive(drive); + m_fdc->set_side(m_head); } - wd17xx_dden_w(m_fdc, !BIT(data, 7)); + 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); @@ -576,10 +576,10 @@ WRITE8_MEMBER( trs80_state::lnw80_fe_w ) mem.install_readwrite_handler (0x37e0, 0x37e3, read8_delegate(FUNC(trs80_state::trs80_irq_status_r), this), write8_delegate(FUNC(trs80_state::trs80_motor_w), this)); mem.install_readwrite_handler (0x37e8, 0x37eb, read8_delegate(FUNC(trs80_state::trs80_printer_r), this), write8_delegate(FUNC(trs80_state::trs80_printer_w), this)); mem.install_read_handler (0x37ec, 0x37ec, read8_delegate(FUNC(trs80_state::trs80_wd179x_r), this)); - mem.install_legacy_write_handler (*m_fdc, 0x37ec, 0x37ec, FUNC(wd17xx_command_w)); - mem.install_legacy_readwrite_handler (*m_fdc, 0x37ed, 0x37ed, FUNC(wd17xx_track_r), FUNC(wd17xx_track_w)); - mem.install_legacy_readwrite_handler (*m_fdc, 0x37ee, 0x37ee, FUNC(wd17xx_sector_r), FUNC(wd17xx_sector_w)); - mem.install_legacy_readwrite_handler (*m_fdc, 0x37ef, 0x37ef, FUNC(wd17xx_data_r), FUNC(wd17xx_data_w)); + mem.install_write_handler (0x37ec, 0x37ec, write8_delegate(FUNC(fd1793_device::command_w),(fd1793_device*)m_fdc)); + mem.install_readwrite_handler (0x37ed, 0x37ed, read8_delegate(FUNC(fd1793_device::track_r),(fd1793_device*)m_fdc), write8_delegate(FUNC(fd1793_device::track_w),(fd1793_device*)m_fdc)); + mem.install_readwrite_handler (0x37ee, 0x37ee, read8_delegate(FUNC(fd1793_device::sector_r),(fd1793_device*)m_fdc), write8_delegate(FUNC(fd1793_device::sector_w),(fd1793_device*)m_fdc)); + mem.install_readwrite_handler (0x37ef, 0x37ef, read8_delegate(FUNC(fd1793_device::data_r),(fd1793_device*)m_fdc),write8_delegate( FUNC(fd1793_device::data_w),(fd1793_device*)m_fdc)); mem.install_read_handler (0x3800, 0x38ff, 0, 0x0300, read8_delegate(FUNC(trs80_state::trs80_keyboard_r), this)); mem.install_readwrite_handler (0x3c00, 0x3fff, read8_delegate(FUNC(trs80_state::trs80_videoram_r), this), write8_delegate(FUNC(trs80_state::trs80_videoram_w), this)); } @@ -699,7 +699,7 @@ READ8_MEMBER( trs80_state::trs80_wd179x_r ) { UINT8 data = 0xff; if (BIT(m_io_config->read(), 7)) - data = wd17xx_status_r(m_fdc, space, offset); + data = m_fdc->status_r(space, offset); return data; } @@ -788,8 +788,8 @@ WRITE8_MEMBER( trs80_state::trs80_motor_w ) return; } - wd17xx_set_drive(m_fdc,drive); - wd17xx_set_side(m_fdc,m_head); + m_fdc->set_drive(drive); + m_fdc->set_side(m_head); /* Turn motors on */ floppy_mon_w(floppy_get_device(machine(), 0), CLEAR_LINE); diff --git a/src/mess/machine/vector06.c b/src/mess/machine/vector06.c index 9195bcce66f..09496d246fc 100644 --- a/src/mess/machine/vector06.c +++ b/src/mess/machine/vector06.c @@ -157,8 +157,8 @@ WRITE8_MEMBER( vector06_state::vector06_disc_w ) { // something here needs to turn the motor on - wd17xx_set_side (m_fdc,BIT(data, 2) ^ 1); - wd17xx_set_drive(m_fdc,BIT(data, 0)); + m_fdc->set_side (BIT(data, 2) ^ 1); + m_fdc->set_drive(BIT(data, 0)); } void vector06_state::machine_start() diff --git a/src/mess/machine/z80ne.c b/src/mess/machine/z80ne.c index cb935dce0e2..16281bcce1b 100644 --- a/src/mess/machine/z80ne.c +++ b/src/mess/machine/z80ne.c @@ -677,9 +677,9 @@ WRITE8_MEMBER(z80ne_state::lx390_motor_w) if (drive < 4) { LOG(("lx390_motor_w, set drive %1d\n", drive)); - wd17xx_set_drive(m_wd1771,drive); + m_wd1771->set_drive(drive); LOG(("lx390_motor_w, set side %1d\n", m_wd17xx_state.head)); - wd17xx_set_side(m_wd1771, m_wd17xx_state.head); + m_wd1771->set_side(m_wd17xx_state.head); } } @@ -708,19 +708,19 @@ READ8_MEMBER(z80ne_state::lx390_fdc_r) switch(offset) { case 0: - d = wd17xx_status_r(m_wd1771, space, 0) ^ 0xff; + d = m_wd1771->status_r(space, 0) ^ 0xff; LOG(("lx390_fdc_r, WD17xx status: %02x\n", d)); break; case 1: - d = wd17xx_track_r(m_wd1771, space, 0) ^ 0xff; + d = m_wd1771->track_r(space, 0) ^ 0xff; LOG(("lx390_fdc_r, WD17xx track: %02x\n", d)); break; case 2: - d = wd17xx_sector_r(m_wd1771, space, 0) ^ 0xff; + d = m_wd1771->sector_r(space, 0) ^ 0xff; LOG(("lx390_fdc_r, WD17xx sector: %02x\n", d)); break; case 3: - d = wd17xx_data_r(m_wd1771, space, 0) ^ 0xff; + d = m_wd1771->data_r(space, 0) ^ 0xff; LOG(("lx390_fdc_r, WD17xx data3: %02x\n", d)); break; case 6: @@ -728,7 +728,7 @@ READ8_MEMBER(z80ne_state::lx390_fdc_r) lx390_reset_bank(space, 0); break; case 7: - d = wd17xx_data_r(m_wd1771, space, 3) ^ 0xff; + d = m_wd1771->data_r(space, 3) ^ 0xff; LOG(("lx390_fdc_r, WD17xx data7, force: %02x\n", d)); break; default: @@ -746,7 +746,7 @@ WRITE8_MEMBER(z80ne_state::lx390_fdc_w) { case 0: LOG(("lx390_fdc_w, WD17xx command: %02x\n", d)); - wd17xx_command_w(m_wd1771, space, offset, d ^ 0xff); + m_wd1771->command_w(space, offset, d ^ 0xff); if (m_wd17xx_state.drive & 1) output_set_value("drv0", 2); else if (m_wd17xx_state.drive & 2) @@ -754,14 +754,14 @@ WRITE8_MEMBER(z80ne_state::lx390_fdc_w) break; case 1: LOG(("lx390_fdc_w, WD17xx track: %02x\n", d)); - wd17xx_track_w(m_wd1771, space, offset, d ^ 0xff); + m_wd1771->track_w(space, offset, d ^ 0xff); break; case 2: LOG(("lx390_fdc_w, WD17xx sector: %02x\n", d)); - wd17xx_sector_w(m_wd1771, space, offset, d ^ 0xff); + m_wd1771->sector_w(space, offset, d ^ 0xff); break; case 3: - wd17xx_data_w(m_wd1771, space, 0, d ^ 0xff); + m_wd1771->data_w(space, 0, d ^ 0xff); LOG(("lx390_fdc_w, WD17xx data3: %02x\n", d)); break; case 6: @@ -770,7 +770,7 @@ WRITE8_MEMBER(z80ne_state::lx390_fdc_w) break; case 7: LOG(("lx390_fdc_w, WD17xx data7, force: %02x\n", d)); - wd17xx_data_w(m_wd1771, space, 3, d ^ 0xff); + m_wd1771->data_w(space, 3, d ^ 0xff); break; } } |