flopdrv: Even legacy devices need some code cleanup (nw)

- Get rid of the hardcoded FLOPPY_n tags as much as practical, mostly adding device finder arrays in their place
- Move remaining functions using FLOPPY_n down into appldriv and sonydriv (both of which may be eliminated once FDC emulation is modernized)
- Replace CLEAR_LINE and ASSERT_LINE with 0 and 1 (these were being inaccurately used to represent active-low control line states)
This commit is contained in:
AJR 2019-11-05 00:30:42 -05:00
parent 5675bdec9c
commit addf59de2f
22 changed files with 165 additions and 271 deletions

View File

@ -53,9 +53,9 @@ static const floppy_interface agat840k_hle_floppy_interface =
void a2bus_agat840k_hle_device::device_add_mconfig(machine_config &config)
{
legacy_floppy_image_device &floppy0(LEGACY_FLOPPY(config, FLOPPY_0, 0, &agat840k_hle_floppy_interface));
legacy_floppy_image_device &floppy0(LEGACY_FLOPPY(config, m_floppy_image[0], 0, &agat840k_hle_floppy_interface));
floppy0.out_idx_cb().set(FUNC(a2bus_agat840k_hle_device::index_0_w));
legacy_floppy_image_device &floppy1(LEGACY_FLOPPY(config, FLOPPY_1, 0, &agat840k_hle_floppy_interface));
legacy_floppy_image_device &floppy1(LEGACY_FLOPPY(config, m_floppy_image[1], 0, &agat840k_hle_floppy_interface));
floppy1.out_idx_cb().set(FUNC(a2bus_agat840k_hle_device::index_1_w));
I8255(config, m_d14);
@ -86,6 +86,7 @@ const tiny_rom_entry *a2bus_agat840k_hle_device::device_rom_region() const
a2bus_agat840k_hle_device::a2bus_agat840k_hle_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock)
, device_a2bus_card_interface(mconfig, *this)
, m_floppy_image(*this, "floppy%u", 0U)
, m_d14(*this, "d14")
, m_d15(*this, "d15")
, m_rom(nullptr)
@ -147,17 +148,16 @@ void a2bus_agat840k_hle_device::device_reset()
{
u8 buf[256];
for (int i = 0; i < 2; i++)
for (auto &img : m_floppy_image)
{
legacy_floppy_image_device *img = floppy_image(i);
if (img)
if (img.found())
{
img->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 0);
img->floppy_drive_set_rpm(300.);
img->floppy_drive_seek(-img->floppy_drive_get_current_track());
}
}
m_floppy = floppy_image(0);
m_floppy = m_floppy_image[0].target();
// generate track images in memory, using default volume ID and gap padding bytes
int t = 0;
@ -324,15 +324,6 @@ uint8_t a2bus_agat840k_hle_device::read_cnxx(uint8_t offset)
return m_rom[offset];
}
legacy_floppy_image_device *a2bus_agat840k_hle_device::floppy_image(int drive)
{
switch(drive) {
case 0 : return subdevice<legacy_floppy_image_device>(FLOPPY_0);
case 1 : return subdevice<legacy_floppy_image_device>(FLOPPY_1);
}
return nullptr;
}
/*
* all signals active low. write support not implemented; WPT is always active.
*
@ -378,11 +369,11 @@ READ8_MEMBER(a2bus_agat840k_hle_device::d14_i_b)
WRITE8_MEMBER(a2bus_agat840k_hle_device::d14_o_c)
{
m_unit = BIT(data, 3);
m_floppy = floppy_image(m_unit);
m_floppy = m_floppy_image[m_unit].target();
if (m_unit)
m_floppy->floppy_ds1_w(m_unit != 1);
m_floppy->floppy_ds_w(m_unit != 1);
else
m_floppy->floppy_ds0_w(m_unit != 0);
m_floppy->floppy_ds_w(m_unit != 0);
m_floppy->floppy_drtn_w(!BIT(data, 2));
m_side = BIT(data, 4);

View File

@ -70,11 +70,11 @@ protected:
TIMER_ID_SEEK
};
required_device_array<legacy_floppy_image_device, 2> m_floppy_image;
required_device<i8255_device> m_d14;
required_device<i8255_device> m_d15;
private:
legacy_floppy_image_device *floppy_image(int drive);
legacy_floppy_image_device *m_floppy;
bool m_side;

View File

@ -59,8 +59,11 @@ ROM_END
void bml3bus_mp1805_device::device_add_mconfig(machine_config &config)
{
MC6843(config, m_mc6843, 0);
m_mc6843->set_floppy_drives(m_floppy[0], m_floppy[1], m_floppy[2], m_floppy[3]);
m_mc6843->irq().set(FUNC(bml3bus_mp1805_device::bml3_mc6843_intrq_w));
legacy_floppy_image_device::add_4drives(config, &bml3_mp1805_floppy_interface);
for (auto &floppy : m_floppy)
LEGACY_FLOPPY(config, floppy, 0, &bml3_mp1805_floppy_interface);
}
//-------------------------------------------------
@ -90,7 +93,6 @@ WRITE8_MEMBER( bml3bus_mp1805_device::bml3_mp1805_w)
// TODO: MESS UI for flipping disk? Note that D88 images are double-sided, but the physical drive is single-sided
int side = 0;
int motor = BIT(data, 7);
const char *floppy_name = nullptr;
switch (drive_select) {
case 1:
drive = 0;
@ -109,24 +111,9 @@ WRITE8_MEMBER( bml3bus_mp1805_device::bml3_mp1805_w)
drive = 0;
break;
}
switch (drive) {
case 0:
floppy_name = FLOPPY_0;
break;
case 1:
floppy_name = FLOPPY_1;
break;
case 2:
floppy_name = FLOPPY_2;
break;
case 3:
floppy_name = FLOPPY_3;
break;
}
legacy_floppy_image_device *floppy = subdevice<legacy_floppy_image_device>(floppy_name);
m_mc6843->set_drive(drive);
floppy->floppy_mon_w(motor);
floppy->floppy_drive_set_ready_state(ASSERT_LINE, 0);
m_floppy[drive]->floppy_mon_w(motor);
m_floppy[drive]->floppy_drive_set_ready_state(ASSERT_LINE, 0);
m_mc6843->set_side(side);
}
@ -138,6 +125,7 @@ WRITE8_MEMBER( bml3bus_mp1805_device::bml3_mp1805_w)
bml3bus_mp1805_device::bml3bus_mp1805_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, BML3BUS_MP1805, tag, owner, clock),
device_bml3bus_card_interface(mconfig, *this),
m_floppy(*this, "floppy%u", 0U),
m_mc6843(*this, "mc6843"), m_rom(nullptr)
{
}

View File

@ -41,6 +41,7 @@ protected:
virtual void device_add_mconfig(machine_config &config) override;
virtual const tiny_rom_entry *device_rom_region() const override;
required_device_array<legacy_floppy_image_device, 4> m_floppy;
required_device<mc6843_device> m_mc6843;
private:

View File

@ -53,7 +53,7 @@ static const floppy_interface nes_floppy_interface =
void nes_disksys_device::device_add_mconfig(machine_config &config)
{
LEGACY_FLOPPY(config, FLOPPY_0, 0, &nes_floppy_interface);
LEGACY_FLOPPY(config, m_disk, 0, &nes_floppy_interface);
}
@ -101,7 +101,7 @@ nes_disksys_device::nes_disksys_device(const machine_config &mconfig, const char
: nes_nrom_device(mconfig, NES_DISKSYS, tag, owner, clock)
, m_2c33_rom(*this, "drive")
, m_fds_data(nullptr)
, m_disk(*this, FLOPPY_0)
, m_disk(*this, "floppy0")
, irq_timer(nullptr)
, m_irq_count(0), m_irq_count_latch(0), m_irq_enable(0), m_irq_transfer(0), m_fds_motor_on(0), m_fds_door_closed(0), m_fds_current_side(0), m_fds_head_position(0), m_fds_status0(0), m_read_mode(0), m_drive_ready(0)
, m_fds_sides(0), m_fds_last_side(0), m_fds_count(0)

View File

@ -24,7 +24,6 @@
CONSTANTS
***************************************************************************/
#define FLOPDRVTAG "flopdrv"
#define LOG_FLOPPY 0
/***************************************************************************
@ -267,11 +266,11 @@ void legacy_floppy_image_device::floppy_drive_seek(signed int signed_tracks)
}
/* set track 0 flag */
m_tk00 = (m_current_track == 0) ? CLEAR_LINE : ASSERT_LINE;
m_tk00 = (m_current_track == 0) ? 0 : 1;
//m_out_tk00_func(m_tk00);
/* clear disk changed flag */
m_dskchg = ASSERT_LINE;
m_dskchg = 1;
//m_out_dskchg_func(m_dskchg);
/* inform disk image of step operation so it can cache information */
@ -471,17 +470,6 @@ TIMER_CALLBACK_MEMBER( legacy_floppy_image_device::set_wpt )
//m_out_wpt_func(param);
}
legacy_floppy_image_device *floppy_get_device(running_machine &machine,int drive)
{
switch(drive) {
case 0 : return machine.device<legacy_floppy_image_device>(FLOPPY_0);
case 1 : return machine.device<legacy_floppy_image_device>(FLOPPY_1);
case 2 : return machine.device<legacy_floppy_image_device>(FLOPPY_2);
case 3 : return machine.device<legacy_floppy_image_device>(FLOPPY_3);
}
return nullptr;
}
int legacy_floppy_image_device::floppy_get_drive_type()
{
return m_floppy_drive_type;
@ -492,83 +480,11 @@ void legacy_floppy_image_device::floppy_set_type(int ftype)
m_floppy_drive_type = ftype;
}
legacy_floppy_image_device *floppy_get_device_by_type(running_machine &machine,int ftype,int drive)
{
int i;
int cnt = 0;
for (i=0;i<4;i++) {
legacy_floppy_image_device *disk = floppy_get_device(machine,i);
if (disk && disk->floppy_get_drive_type()==ftype) {
if (cnt==drive) {
return disk;
}
cnt++;
}
}
return nullptr;
}
static int floppy_get_drive(device_t *image)
/* drive select */
WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds_w )
{
int drive = -1;
if (strcmp(image->tag(), ":" FLOPPY_0) == 0) drive = 0;
if (strcmp(image->tag(), ":" FLOPPY_1) == 0) drive = 1;
if (strcmp(image->tag(), ":" FLOPPY_2) == 0) drive = 2;
if (strcmp(image->tag(), ":" FLOPPY_3) == 0) drive = 3;
return drive;
}
int floppy_get_drive_by_type(legacy_floppy_image_device *image,int ftype)
{
int i,drive =0;
for (i=0;i<4;i++) {
legacy_floppy_image_device *disk = floppy_get_device(image->machine(),i);
if (disk && disk->floppy_get_drive_type()==ftype) {
if (image==disk) {
return drive;
}
drive++;
}
}
return -1;
}
/* drive select 0 */
WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds0_w )
{
if (state == CLEAR_LINE)
m_active = (m_drive_id == 0);
}
/* drive select 1 */
WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds1_w )
{
if (state == CLEAR_LINE)
m_active = (m_drive_id == 1);
}
/* drive select 2 */
WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds2_w )
{
if (state == CLEAR_LINE)
m_active = (m_drive_id == 2);
}
/* drive select 3 */
WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_ds3_w )
{
if (state == CLEAR_LINE)
m_active = (m_drive_id == 3);
}
/* shortcut to write all four ds lines */
WRITE8_MEMBER( legacy_floppy_image_device::floppy_ds_w )
{
floppy_ds0_w(BIT(data, 0));
floppy_ds1_w(BIT(data, 1));
floppy_ds2_w(BIT(data, 2));
floppy_ds3_w(BIT(data, 3));
m_active = (state == 0);
}
/* motor on, active low */
@ -576,10 +492,10 @@ WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_mon_w )
{
/* force off if there is no attached image */
if (!exists())
state = ASSERT_LINE;
state = 1;
/* off -> on */
if (m_mon && state == CLEAR_LINE)
if (m_mon && state == 0)
{
m_idx = 0;
floppy_drive_index_func();
@ -617,7 +533,7 @@ WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_stp_w )
m_current_track--;
/* are we at track 0 now? */
m_tk00 = (m_current_track == 0) ? CLEAR_LINE : ASSERT_LINE;
m_tk00 = (m_current_track == 0) ? 0 : 1;
}
else
{
@ -626,7 +542,7 @@ WRITE_LINE_MEMBER( legacy_floppy_image_device::floppy_stp_w )
m_current_track++;
/* we can't be at track 0 here, so reset the line */
m_tk00 = ASSERT_LINE;
m_tk00 = 1;
}
/* update track 0 line with new status */
@ -668,7 +584,7 @@ READ_LINE_MEMBER( legacy_floppy_image_device::floppy_dskchg_r )
READ_LINE_MEMBER( legacy_floppy_image_device::floppy_twosid_r )
{
if (m_floppy == nullptr)
return ASSERT_LINE;
return 1;
else
return !floppy_get_heads_per_disk(m_floppy);
}
@ -708,7 +624,6 @@ legacy_floppy_image_device::legacy_floppy_image_device(const machine_config &mco
m_wpt(0),
m_rdy(0),
m_dskchg(0),
m_drive_id(-1),
m_active(0),
m_config(nullptr),
m_flags(0),
@ -745,7 +660,6 @@ void legacy_floppy_image_device::device_start()
{
floppy_drive_init();
m_drive_id = floppy_get_drive(this);
m_active = false;
/* resolve callbacks */
@ -757,15 +671,15 @@ void legacy_floppy_image_device::device_start()
// m_out_dskchg_func.resolve(m_config->out_dskchg_func, *this);
/* by default we are not write-protected */
m_wpt = ASSERT_LINE;
m_wpt = 1;
//m_out_wpt_func(m_wpt);
/* not at track 0 */
m_tk00 = ASSERT_LINE;
m_tk00 = 1;
//m_out_tk00_func(m_tk00);
/* motor off */
m_mon = ASSERT_LINE;
m_mon = 1;
/* disk changed */
m_dskchg = CLEAR_LINE;
@ -814,9 +728,9 @@ image_init_result legacy_floppy_image_device::call_load()
int next_wpt;
if (!is_readonly())
next_wpt = ASSERT_LINE;
next_wpt = 1;
else
next_wpt = CLEAR_LINE;
next_wpt = 0;
machine().scheduler().timer_set(attotime::from_msec(250), timer_expired_delegate(FUNC(legacy_floppy_image_device::set_wpt),this), next_wpt);
@ -832,15 +746,15 @@ void legacy_floppy_image_device::call_unload()
m_floppy = nullptr;
/* disk changed */
m_dskchg = CLEAR_LINE;
m_dskchg = 0;
//m_out_dskchg_func(m_dskchg);
/* pull disk halfway out of drive */
m_wpt = CLEAR_LINE;
m_wpt = 0;
//m_out_wpt_func(m_wpt);
/* set timer for disk eject */
machine().scheduler().timer_set(attotime::from_msec(250), timer_expired_delegate(FUNC(legacy_floppy_image_device::set_wpt),this), ASSERT_LINE);
machine().scheduler().timer_set(attotime::from_msec(250), timer_expired_delegate(FUNC(legacy_floppy_image_device::set_wpt),this), 1);
}
bool legacy_floppy_image_device::is_creatable() const

View File

@ -10,11 +10,6 @@
#include "formats/flopimg.h"
#include "softlist_dev.h"
#define FLOPPY_0 "floppy0"
#define FLOPPY_1 "floppy1"
#define FLOPPY_2 "floppy2"
#define FLOPPY_3 "floppy3"
#define FLOPPY_TYPE_REGULAR 0
#define FLOPPY_TYPE_APPLE 1
#define FLOPPY_TYPE_SONY 2
@ -108,20 +103,6 @@ public:
void set_floppy_config(const floppy_interface *config) { m_config = config; }
auto out_idx_cb() { return m_out_idx_func.bind(); }
static void add_4drives(machine_config &mconfig, const floppy_interface *config)
{
LEGACY_FLOPPY(mconfig, FLOPPY_0, 0, config);
LEGACY_FLOPPY(mconfig, FLOPPY_1, 0, config);
LEGACY_FLOPPY(mconfig, FLOPPY_2, 0, config);
LEGACY_FLOPPY(mconfig, FLOPPY_3, 0, config);
}
static void add_2drives(machine_config &mconfig, const floppy_interface *config)
{
LEGACY_FLOPPY(mconfig, FLOPPY_0, 0, config);
LEGACY_FLOPPY(mconfig, FLOPPY_1, 0, config);
}
virtual image_init_result call_load() override;
virtual const software_list_loader &get_software_list_loader() const override { return image_software_list_loader::instance(); }
virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override;
@ -159,11 +140,7 @@ public:
void floppy_drive_set_controller(device_t *controller);
int floppy_get_drive_type();
void floppy_set_type(int ftype);
WRITE_LINE_MEMBER( floppy_ds0_w );
WRITE_LINE_MEMBER( floppy_ds1_w );
WRITE_LINE_MEMBER( floppy_ds2_w );
WRITE_LINE_MEMBER( floppy_ds3_w );
WRITE8_MEMBER( floppy_ds_w );
WRITE_LINE_MEMBER( floppy_ds_w );
WRITE_LINE_MEMBER( floppy_mon_w );
WRITE_LINE_MEMBER( floppy_drtn_w );
WRITE_LINE_MEMBER( floppy_wtd_w );
@ -212,8 +189,7 @@ protected:
int m_dskchg; /* disk changed */
/* drive select logic */
int m_drive_id;
int m_active;
bool m_active;
const floppy_interface *m_config;
@ -247,8 +223,4 @@ protected:
char m_extension_list[256];
};
legacy_floppy_image_device *floppy_get_device(running_machine &machine,int drive);
legacy_floppy_image_device *floppy_get_device_by_type(running_machine &machine,int ftype,int drive);
int floppy_get_drive_by_type(legacy_floppy_image_device *image,int ftype);
#endif // MAME_DEVICES_IMAGEDV_FLOPDRV_H

View File

@ -16,6 +16,11 @@
#include "imagedev/flopdrv.h"
#include "formats/ap2_dsk.h"
#define FLOPPY_0 "floppy0"
#define FLOPPY_1 "floppy1"
#define FLOPPY_2 "floppy2"
#define FLOPPY_3 "floppy3"
void apple525_set_lines(device_t *device, uint8_t lines);
void apple525_set_enable_lines(device_t *device, int enable_mask);

View File

@ -72,6 +72,7 @@ DEFINE_DEVICE_TYPE(MC6843, mc6843_device, "mc5843", "Motorola MC6843 FDC")
mc6843_device::mc6843_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, MC6843, tag, owner, clock),
m_floppy(*this, {finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG}),
m_write_irq(*this),
m_CTAR(0),
m_CMR(0),
@ -131,16 +132,17 @@ void mc6843_device::device_start()
void mc6843_device::device_reset()
{
int i;
LOG (( "mc6843 reset\n" ));
/* setup/reset floppy drive */
for ( i = 0; i < 4; i++ )
for (auto &img : m_floppy)
{
legacy_floppy_image_device * img = floppy_image( i );
img->floppy_mon_w(CLEAR_LINE);
img->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 0 );
img->floppy_drive_set_rpm( 300. );
if (img.found())
{
img->floppy_mon_w(CLEAR_LINE);
img->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 0 );
img->floppy_drive_set_rpm( 300. );
}
}
/* reset registers */
@ -160,35 +162,10 @@ void mc6843_device::device_reset()
legacy_floppy_image_device* mc6843_device::floppy_image( uint8_t drive )
{
legacy_floppy_image_device *img = floppy_get_device( machine(), drive );
if (!img && owner()) {
// For slot devices, drives are typically attached to the slot rather than the machine
const char *floppy_name = nullptr;
switch (drive) {
case 0:
floppy_name = FLOPPY_0;
break;
case 1:
floppy_name = FLOPPY_1;
break;
case 2:
floppy_name = FLOPPY_2;
break;
case 3:
floppy_name = FLOPPY_3;
break;
}
img = owner()->subdevice<legacy_floppy_image_device>(floppy_name);
}
return img;
}
legacy_floppy_image_device* mc6843_device::floppy_image( )
{
return floppy_image( m_drive );
assert(m_floppy[m_drive].found());
return m_floppy[m_drive].target();
}

View File

@ -21,6 +21,15 @@ class mc6843_device : public device_t
public:
mc6843_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
template<int Id, typename T> void set_floppy_drive(T &&tag) { m_floppy[Id].set_tag(std::forward<T>(tag)); }
template<typename T, typename U, typename V, typename W> void set_floppy_drives(T &&tag0, U &&tag1, V &&tag2, W &&tag3)
{
m_floppy[0].set_tag(std::forward<T>(tag0));
m_floppy[1].set_tag(std::forward<U>(tag1));
m_floppy[2].set_tag(std::forward<V>(tag2));
m_floppy[3].set_tag(std::forward<W>(tag3));
}
auto irq() { return m_write_irq.bind(); }
DECLARE_READ8_MEMBER(read);
@ -42,6 +51,8 @@ private:
TIMER_CONT
};
optional_device_array<legacy_floppy_image_device, 4> m_floppy;
devcb_write_line m_write_irq;
/* registers */
@ -68,7 +79,6 @@ private:
/* trigger delayed actions (bottom halves) */
emu_timer* m_timer_cont;
legacy_floppy_image_device* floppy_image(uint8_t drive);
legacy_floppy_image_device* floppy_image();
void status_update();
void cmd_end();

View File

@ -103,6 +103,48 @@ static int sony_enable2(void)
return (sony.lines & SONY_CA1) && (sony.lines & SONY_LSTRB);
}
static legacy_floppy_image_device *floppy_get_device(running_machine &machine,int drive)
{
switch(drive) {
case 0 : return machine.device<legacy_floppy_image_device>(FLOPPY_0);
case 1 : return machine.device<legacy_floppy_image_device>(FLOPPY_1);
case 2 : return machine.device<legacy_floppy_image_device>(FLOPPY_2);
case 3 : return machine.device<legacy_floppy_image_device>(FLOPPY_3);
}
return nullptr;
}
static legacy_floppy_image_device *floppy_get_device_by_type(running_machine &machine,int ftype,int drive)
{
int i;
int cnt = 0;
for (i=0;i<4;i++) {
legacy_floppy_image_device *disk = floppy_get_device(machine,i);
if (disk && disk->floppy_get_drive_type()==ftype) {
if (cnt==drive) {
return disk;
}
cnt++;
}
}
return nullptr;
}
static int floppy_get_drive_by_type(legacy_floppy_image_device *image,int ftype)
{
int i,drive =0;
for (i=0;i<4;i++) {
legacy_floppy_image_device *disk = floppy_get_device(image->machine(),i);
if (disk && disk->floppy_get_drive_type()==ftype) {
if (image==disk) {
return drive;
}
drive++;
}
}
return -1;
}
static void load_track_data(device_t *device,int floppy_select)
{
int track_size;

View File

@ -15,6 +15,11 @@
#include "imagedev/flopdrv.h"
#define FLOPPY_0 "floppy0"
#define FLOPPY_1 "floppy1"
#define FLOPPY_2 "floppy2"
#define FLOPPY_3 "floppy3"
#if 0
enum
{

View File

@ -169,6 +169,11 @@ Exidy Sorcerer Video/Disk Unit:
#include "softlist.h"
#include "speaker.h"
#define FLOPPY_0 "floppy0"
#define FLOPPY_1 "floppy1"
#define FLOPPY_2 "floppy2"
#define FLOPPY_3 "floppy3"
void sorcerer_state::sorcerer_mem(address_map &map)
{
@ -528,8 +533,12 @@ void sorcerer_state::sorcererd(machine_config &config)
MCFG_MACHINE_START_OVERRIDE(sorcerer_state, sorcererd )
MICROPOLIS(config, m_fdc, 0);
m_fdc->set_default_drive_tags();
legacy_floppy_image_device::add_4drives(config, &sorcerer_floppy_interface);
m_fdc->set_drive_tags(FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3);
LEGACY_FLOPPY(config, FLOPPY_0, 0, &sorcerer_floppy_interface);
LEGACY_FLOPPY(config, FLOPPY_1, 0, &sorcerer_floppy_interface);
LEGACY_FLOPPY(config, FLOPPY_2, 0, &sorcerer_floppy_interface);
LEGACY_FLOPPY(config, FLOPPY_3, 0, &sorcerer_floppy_interface);
FD1793(config, m_fdc2, 8_MHz_XTAL / 8); // confirmed clock
m_fdc2->set_force_ready(true); // should be able to get rid of this when fdc issue is fixed

View File

@ -680,6 +680,7 @@ void thomson_state::to7_base(machine_config &config)
m_thmfc->floppy_active_cb().set(FUNC(thomson_state::thom_floppy_active));
MC6843(config, m_mc6843, 16_MHz_XTAL / 16 / 2);
m_mc6843->set_floppy_drives(m_floppy_image[0], m_floppy_image[1], m_floppy_image[2], m_floppy_image[3]);
LEGACY_FLOPPY(config, m_floppy_image[0], 0, &thomson_floppy_interface);
m_floppy_image[0]->out_idx_cb().set(FUNC(thomson_state::fdc_index_0_w));

View File

@ -524,7 +524,7 @@ void vtech2_state::laser350(machine_config &config)
GENERIC_CARTSLOT(config, "cartslot", generic_plain_slot, "vtech_cart", "rom,bin").set_device_load(FUNC(vtech2_state::cart_load));
/* 5.25" Floppy drive */
LEGACY_FLOPPY(config, FLOPPY_0, 0, &vtech2_floppy_interface);
LEGACY_FLOPPY(config, m_laser_file[0], 0, &vtech2_floppy_interface);
}
@ -549,8 +549,8 @@ void vtech2_state::laser700(machine_config &config)
ADDRESS_MAP_BANK(config.replace(), "bankd").set_map(&vtech2_state::m_map700).set_options(ENDIANNESS_LITTLE, 8, 18, 0x4000);
/* Second 5.25" floppy drive */
LEGACY_FLOPPY(config, FLOPPY_1, 0, &vtech2_floppy_interface);
}
LEGACY_FLOPPY(config, m_laser_file[1], 0, &vtech2_floppy_interface);
}
ROM_START(laser350)

View File

@ -30,7 +30,7 @@ public:
, m_speaker(*this, "speaker")
, m_cassette(*this, "cassette")
, m_cart(*this, "cartslot")
, m_laser_file(*this, {FLOPPY_0, FLOPPY_1})
, m_laser_file(*this, "floppy%u", 0U)
, m_gfxdecode(*this, "gfxdecode")
, m_palette(*this, "palette")
, m_videoram(*this, "videoram")

View File

@ -106,20 +106,18 @@ static void _atari_load_proc(device_image_interface &image, bool is_created)
atarifdc->atari_load_proc(image, is_created);
}
static int atari_fdc_get_drive(device_t *image)
{
int drive = -1;
if (strcmp(image->tag(), ":fdc:" FLOPPY_0) == 0) drive = 0;
if (strcmp(image->tag(), ":fdc:" FLOPPY_1) == 0) drive = 1;
if (strcmp(image->tag(), ":fdc:" FLOPPY_2) == 0) drive = 2;
if (strcmp(image->tag(), ":fdc:" FLOPPY_3) == 0) drive = 3;
return drive;
}
void atari_fdc_device::atari_load_proc(device_image_interface &image, bool is_created)
{
int id = atari_fdc_get_drive(&image.device());
int size, i;
int id = -1;
for (int i = 0; i < 4; i++)
{
if (&image.device() == m_floppy[i].target())
{
id = i;
break;
}
}
if (id == -1)
return;
@ -142,7 +140,7 @@ void atari_fdc_device::atari_load_proc(device_image_interface &image, bool is_cr
image.fseek(0, SEEK_SET);
}
size = image.fread(m_drv[id].image.get(), MAXSIZE);
int size = image.fread(m_drv[id].image.get(), MAXSIZE);
if( size <= 0 )
{
@ -198,6 +196,7 @@ void atari_fdc_device::atari_load_proc(device_image_interface &image, bool is_cr
}
int i;
switch (m_drv[id].type)
{
/* XFD or unknown format: find a matching size from the table */
@ -740,21 +739,11 @@ static const floppy_interface atari_floppy_interface =
"floppy_5_25"
};
legacy_floppy_image_device *atari_fdc_device::atari_floppy_get_device_child(int drive)
{
switch(drive) {
case 0 : return subdevice<legacy_floppy_image_device>(FLOPPY_0);
case 1 : return subdevice<legacy_floppy_image_device>(FLOPPY_1);
case 2 : return subdevice<legacy_floppy_image_device>(FLOPPY_2);
case 3 : return subdevice<legacy_floppy_image_device>(FLOPPY_3);
}
return nullptr;
}
DEFINE_DEVICE_TYPE(ATARI_FDC, atari_fdc_device, "atari_fdc", "Atari FDC")
atari_fdc_device::atari_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, ATARI_FDC, tag, owner, clock),
m_floppy(*this, "floppy%u", 0U),
m_pokey(*this, "^pokey"),
m_pia(*this, "^pia"),
m_serout_count(0),
@ -774,16 +763,12 @@ atari_fdc_device::atari_fdc_device(const machine_config &mconfig, const char *ta
void atari_fdc_device::device_start()
{
int id;
memset(m_serout_buff, 0, sizeof(m_serout_buff));
memset(m_serin_buff, 0, sizeof(m_serin_buff));
memset(m_drv, 0, sizeof(m_drv));
for(id=0;id<4;id++)
{
atari_floppy_get_device_child(id)->floppy_install_load_proc(_atari_load_proc);
}
for (auto &floppy : m_floppy)
floppy->floppy_install_load_proc(_atari_load_proc);
}
//-------------------------------------------------
@ -792,5 +777,6 @@ void atari_fdc_device::device_start()
void atari_fdc_device::device_add_mconfig(machine_config &config)
{
legacy_floppy_image_device::add_4drives(config, &atari_floppy_interface);
for (auto &floppy : m_floppy)
LEGACY_FLOPPY(config, floppy, 0, &atari_floppy_interface);
}

View File

@ -34,7 +34,6 @@ private:
void add_serin(uint8_t data, int with_checksum);
void a800_serial_command();
void a800_serial_write();
legacy_floppy_image_device *atari_floppy_get_device_child(int drive);
struct atari_drive
{
@ -51,6 +50,7 @@ private:
int sectors; /* total sectors, ie. tracks x heads x spt */
};
required_device_array<legacy_floppy_image_device, 4> m_floppy;
required_device<pokey_device> m_pokey;
required_device<pia6821_device> m_pia;

View File

@ -70,6 +70,7 @@ micropolis_device::micropolis_device(const machine_config &mconfig, const char *
m_read_dden(*this),
m_write_intrq(*this),
m_write_drq(*this),
m_floppy_drive(*this, {finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG, finder_base::DUMMY_TAG}),
m_data(0),
m_drive_num(0),
m_track(0),
@ -83,7 +84,6 @@ micropolis_device::micropolis_device(const machine_config &mconfig, const char *
m_drive(nullptr)
{
std::fill(std::begin(m_buffer), std::end(m_buffer), 0);
std::fill(std::begin(m_floppy_drive_tags), std::end(m_floppy_drive_tags), nullptr);
}
//-------------------------------------------------
@ -115,18 +115,13 @@ void micropolis_device::device_start()
void micropolis_device::device_reset()
{
for (auto & elem : m_floppy_drive_tags)
for (auto &img : m_floppy_drive)
{
if (elem)
if (img.found())
{
legacy_floppy_image_device *img = siblingdevice<legacy_floppy_image_device>(elem);
if (img)
{
img->floppy_drive_set_controller(this);
//img->floppy_drive_set_index_pulse_callback(wd17xx_index_pulse_callback);
img->floppy_drive_set_rpm(300.);
}
img->floppy_drive_set_controller(this);
//img->floppy_drive_set_index_pulse_callback(wd17xx_index_pulse_callback);
img->floppy_drive_set_rpm(300.);
}
}
@ -185,8 +180,7 @@ void micropolis_device::set_drive(uint8_t drive)
if (VERBOSE)
logerror("micropolis_set_drive: $%02x\n", drive);
if (m_floppy_drive_tags[drive])
m_drive = siblingdevice<legacy_floppy_image_device>(m_floppy_drive_tags[drive]);
m_drive = m_floppy_drive[drive].target();
}

View File

@ -30,16 +30,15 @@ public:
auto intrq_wr_callback() { return m_write_intrq.bind(); }
auto drq_wr_callback() { return m_write_drq.bind(); }
void set_drive_tags(const char *tag1, const char *tag2, const char *tag3, const char *tag4)
template<typename T, typename U, typename V, typename W>
void set_drive_tags(T &&tag1, U &&tag2, V &&tag3, W &&tag4)
{
m_floppy_drive_tags[0] = tag1;
m_floppy_drive_tags[1] = tag2;
m_floppy_drive_tags[2] = tag3;
m_floppy_drive_tags[3] = tag4;
m_floppy_drive[0].set_tag(std::forward<T>(tag1));
m_floppy_drive[1].set_tag(std::forward<U>(tag2));
m_floppy_drive[2].set_tag(std::forward<V>(tag3));
m_floppy_drive[3].set_tag(std::forward<W>(tag4));
}
void set_default_drive_tags() { set_drive_tags(FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3); }
void set_drive(uint8_t drive); // set current drive (0-3)
DECLARE_READ8_MEMBER( status_r );
@ -63,7 +62,7 @@ private:
devcb_write_line m_write_intrq;
devcb_write_line m_write_drq;
const char *m_floppy_drive_tags[4];
optional_device_array<legacy_floppy_image_device, 4> m_floppy_drive;
/* register */
uint8_t m_data;

View File

@ -46,6 +46,7 @@ DEFINE_DEVICE_TYPE(RX01, rx01_device, "rx01", "RX01")
rx01_device::rx01_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, RX01, tag, owner, clock)
, m_image(*this, "floppy%u", 0U)
{
}
@ -55,7 +56,8 @@ rx01_device::rx01_device(const machine_config &mconfig, const char *tag, device_
void rx01_device::device_add_mconfig(machine_config &config)
{
legacy_floppy_image_device::add_2drives(config, &rx01_floppy_interface);
for (auto &floppy : m_image)
LEGACY_FLOPPY(config, floppy, 0, &rx01_floppy_interface);
}
//-------------------------------------------------
@ -64,8 +66,6 @@ void rx01_device::device_add_mconfig(machine_config &config)
void rx01_device::device_start()
{
m_image[0] = subdevice<legacy_floppy_image_device>(FLOPPY_0);
m_image[1] = subdevice<legacy_floppy_image_device>(FLOPPY_1);
}

View File

@ -59,7 +59,7 @@ private:
RX01_INIT
};
legacy_floppy_image_device *m_image[2];
required_device_array<legacy_floppy_image_device, 2> m_image;
uint8_t m_buffer[128];
int m_buf_pos;