diff options
author | Dirk Best <mail@dirk-best.de> | 2017-08-27 13:35:53 +0200 |
---|---|---|
committer | Dirk Best <mail@dirk-best.de> | 2017-08-27 13:37:00 +0200 |
commit | 369b255b8ef93320d07d830836d435aaccb98f0a (patch) | |
tree | 151cde4c48f1a6f764350aa68ac14e2ffdf08c19 | |
parent | 49a7303d0f4369830b092dee990570e2ca0731c8 (diff) |
floppy: Add drive LED callback
This currently only works if you set the drive select lines correctly,
which the upd765 does now. Hook it up to the psi98 driver and use the
TEAC FD-55F drive instead of the generic one.
This is some basic first work to better model the real hardware and
floppy drive setups in the future.
-rw-r--r-- | src/devices/imagedev/floppy.cpp | 54 | ||||
-rw-r--r-- | src/devices/imagedev/floppy.h | 9 | ||||
-rw-r--r-- | src/devices/machine/upd765.cpp | 16 | ||||
-rw-r--r-- | src/devices/machine/upd765.h | 1 | ||||
-rw-r--r-- | src/mame/drivers/kdt6.cpp | 23 |
5 files changed, 79 insertions, 24 deletions
diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index e1b7361a597..483d303bd38 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -185,7 +185,7 @@ floppy_image_device::floppy_image_device(const machine_config &mconfig, device_t motor_always_on(false), dskchg_writable(false), has_trk00_sensor(true), - dir(0), stp(0), wtg(0), mon(0), ss(0), idx(0), wpt(0), rdy(0), dskchg(0), + dir(0), stp(0), wtg(0), mon(0), ss(0), ds(-1), idx(0), wpt(0), rdy(0), dskchg(0), ready(false), rpm(0), floppy_ratio_1(0), @@ -240,6 +240,11 @@ void floppy_image_device::setup_wpt_cb(wpt_cb cb) cur_wpt_cb = cb; } +void floppy_image_device::setup_led_cb(led_cb cb) +{ + cur_led_cb = cb; +} + void floppy_image_device::set_formats(const floppy_format_type *formats) { extension_list[0] = '\0'; @@ -314,6 +319,9 @@ void floppy_image_device::device_start() dskchg_writable = false; has_trk00_sensor = true; + // better would be an extra parameter in the MCFG macro + drive_index = atoi(owner()->basetag()); + idx = 0; /* motor off */ @@ -322,6 +330,7 @@ void floppy_image_device::device_start() cyl = 0; subcyl = 0; ss = 0; + ds = -1; stp = 1; wpt = 0; dskchg = exists() ? 1 : 0; @@ -349,11 +358,7 @@ void floppy_image_device::device_reset() revolution_start_time = attotime::never; revolution_count = 0; mon = 1; - if(!ready) { - ready = true; - if(!cur_ready_cb.isnull()) - cur_ready_cb(this, ready); - } + set_ready(true); if(motor_always_on) mon_w(0); } @@ -480,11 +485,9 @@ void floppy_image_device::call_unload() if (motor_always_on) { // When disk is removed, stop motor mon_w(1); - } else if(!ready) { - ready = true; - if(!cur_ready_cb.isnull()) - cur_ready_cb(this, ready); } + + set_ready(true); } image_init_result floppy_image_device::call_create(int format_type, util::option_resolution *format_options) @@ -535,9 +538,7 @@ void floppy_image_device::mon_w(int state) if (motor_always_on) { // Drives with motor that is always spinning are immediately ready when a disk is loaded // because there is no spin-up time - ready = false; - if(!cur_ready_cb.isnull()) - cur_ready_cb(this, ready); + set_ready(false); } else { ready_counter = 2; } @@ -550,11 +551,7 @@ void floppy_image_device::mon_w(int state) commit_image(); revolution_start_time = attotime::never; index_timer->adjust(attotime::zero); - if(!ready) { - ready = true; - if(!cur_ready_cb.isnull()) - cur_ready_cb(this, ready); - } + set_ready(true); } // Create a motor sound (loaded or empty) @@ -602,9 +599,7 @@ void floppy_image_device::index_resync() ready_counter--; if(!ready_counter) { // logerror("Drive spun up\n"); - ready = false; - if(!cur_ready_cb.isnull()) - cur_ready_cb(this, ready); + set_ready(false); } } if (!cur_index_pulse_cb.isnull()) @@ -617,6 +612,23 @@ bool floppy_image_device::ready_r() return ready; } +void floppy_image_device::set_ready(bool state) +{ + if (state != ready) + { + ready = state; + check_led(); + if (!cur_ready_cb.isnull()) + cur_ready_cb(this, ready); + } +} + +void floppy_image_device::check_led() +{ + if(!cur_led_cb.isnull()) + cur_led_cb(this, (ds == drive_index) && !ready ? 1 : 0); +} + double floppy_image_device::get_pos() { return index_timer->elapsed().as_double(); diff --git a/src/devices/imagedev/floppy.h b/src/devices/imagedev/floppy.h index 9f2d494fb7f..5954e72883f 100644 --- a/src/devices/imagedev/floppy.h +++ b/src/devices/imagedev/floppy.h @@ -76,6 +76,7 @@ public: typedef delegate<void (floppy_image_device *, int)> index_pulse_cb; typedef delegate<void (floppy_image_device *, int)> ready_cb; typedef delegate<void (floppy_image_device *, int)> wpt_cb; + typedef delegate<void (floppy_image_device *, int)> led_cb; // construction/destruction virtual ~floppy_image_device(); @@ -109,12 +110,14 @@ public: void setup_index_pulse_cb(index_pulse_cb cb); void setup_ready_cb(ready_cb cb); void setup_wpt_cb(wpt_cb cb); + void setup_led_cb(led_cb cb); std::vector<uint32_t> &get_buffer() { return image->get_buffer(cyl, ss, subcyl); } int get_cyl() { return cyl; } void mon_w(int state); bool ready_r(); + void set_ready(bool state); double get_pos(); bool wpt_r() { return wpt; } @@ -131,6 +134,7 @@ public: void ss_w(int state) { ss = state; } void inuse_w(int state) { } void dskchg_w(int state) { if (dskchg_writable) dskchg = state; } + void ds_w(int state) { ds = state; check_led(); } void index_resync(); attotime time_next_index(); @@ -173,12 +177,15 @@ protected: bool dskchg_writable; bool has_trk00_sensor; + int drive_index; + /* state of input lines */ int dir; /* direction */ int stp; /* step */ int wtg; /* write gate */ int mon; /* motor on */ int ss; /* side select */ + int ds; /* drive select */ /* state of output lines */ int idx; /* index pulse */ @@ -203,7 +210,9 @@ protected: index_pulse_cb cur_index_pulse_cb; ready_cb cur_ready_cb; wpt_cb cur_wpt_cb; + led_cb cur_led_cb; + void check_led(); uint32_t find_position(attotime &base, const attotime &when); int find_index(uint32_t position, const std::vector<uint32_t> &buf); void write_zone(uint32_t *buf, int &cells, int &index, uint32_t spos, uint32_t epos, uint32_t mg); diff --git a/src/devices/machine/upd765.cpp b/src/devices/machine/upd765.cpp index da34165100d..adc9f5790fe 100644 --- a/src/devices/machine/upd765.cpp +++ b/src/devices/machine/upd765.cpp @@ -261,6 +261,16 @@ bool upd765_family_device::get_ready(int fid) return !external_ready; } +void upd765_family_device::set_ds(int state) +{ + for(int i = 0; i < 4; i++) + { + floppy_info &fi = flopi[i]; + if (fi.dev) + fi.dev->ds_w(state); + } +} + void upd765_family_device::set_floppy(floppy_image_device *flop) { for(auto & elem : flopi) { @@ -1518,6 +1528,7 @@ void upd765_family_device::read_data_start(floppy_info &fi) st1 = ST1_MA; st2 = 0x00; hdl_cb(1); + set_ds(command[1] & 3); fi.ready = get_ready(command[1] & 3); if(!fi.ready) @@ -1563,6 +1574,7 @@ void upd765_family_device::scan_start(floppy_info &fi) st2 = 0x00; scan_done = false; hdl_cb(1); + set_ds(command[1] & 3); fi.ready = get_ready(command[1] & 3); if(!fi.ready) @@ -1752,6 +1764,7 @@ void upd765_family_device::write_data_start(floppy_info &fi) st1 = ST1_MA; st2 = 0x00; hdl_cb(1); + set_ds(command[1] & 3); fi.ready = get_ready(command[1] & 3); if(!fi.ready) @@ -1873,6 +1886,7 @@ void upd765_family_device::read_track_start(floppy_info &fi) st1 = ST1_MA; st2 = 0x00; hdl_cb(1); + set_ds(command[1] & 3); fi.ready = get_ready(command[1] & 3); if(!fi.ready) @@ -2034,6 +2048,7 @@ void upd765_family_device::format_track_start(floppy_info &fi) command[1], command[2], command[3], command[4], command[5]); hdl_cb(1); + set_ds(command[1] & 3); fi.ready = get_ready(command[1] & 3); if(!fi.ready) @@ -2111,6 +2126,7 @@ void upd765_family_device::read_id_start(floppy_info &fi) cur_live.idbuf[i] = 0x00; hdl_cb(1); + set_ds(command[1] & 3); fi.ready = get_ready(command[1] & 3); if(!fi.ready) diff --git a/src/devices/machine/upd765.h b/src/devices/machine/upd765.h index 52b545c2be7..c1b9e428dda 100644 --- a/src/devices/machine/upd765.h +++ b/src/devices/machine/upd765.h @@ -369,6 +369,7 @@ protected: uint8_t fifo_pop(bool internal); void set_drq(bool state); bool get_ready(int fid); + void set_ds(int state); void enable_transfer(); void disable_transfer(); diff --git a/src/mame/drivers/kdt6.cpp b/src/mame/drivers/kdt6.cpp index f864b1f6834..5e5622578b7 100644 --- a/src/mame/drivers/kdt6.cpp +++ b/src/mame/drivers/kdt6.cpp @@ -92,6 +92,8 @@ public: DECLARE_WRITE8_MEMBER(fdc_tc_w); DECLARE_WRITE_LINE_MEMBER(fdc_drq_w); + void drive0_led_cb(floppy_image_device *floppy, int state); + void drive1_led_cb(floppy_image_device *floppy, int state); MC6845_UPDATE_ROW(crtc_update_row); uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); @@ -214,7 +216,7 @@ INPUT_PORTS_END //************************************************************************** static SLOT_INTERFACE_START( kdt6_floppies ) - SLOT_INTERFACE("525qd", FLOPPY_525_QD) + SLOT_INTERFACE("fd55f", TEAC_FD_55F) SLOT_INTERFACE_END WRITE8_MEMBER( kdt6_state::fdc_tc_w ) @@ -229,6 +231,16 @@ WRITE_LINE_MEMBER( kdt6_state::fdc_drq_w ) m_dma->rdy_w(state); } +void kdt6_state::drive0_led_cb(floppy_image_device *floppy, int state) +{ + machine().output().set_value("drive0_led", state); +} + +void kdt6_state::drive1_led_cb(floppy_image_device *floppy, int state) +{ + machine().output().set_value("drive1_led", state); +} + //************************************************************************** // VIDEO @@ -556,6 +568,11 @@ void kdt6_state::machine_start() m_fdc->set_rate(250000); + if (m_floppy0->get_device()) + m_floppy0->get_device()->setup_led_cb(floppy_image_device::led_cb(&kdt6_state::drive0_led_cb, this)); + if (m_floppy1->get_device()) + m_floppy1->get_device()->setup_led_cb(floppy_image_device::led_cb(&kdt6_state::drive1_led_cb, this)); + // register for save states save_pointer(NAME(m_ram.get()), 0x40000); save_pointer(NAME(m_vram.get()), 0x10000); @@ -683,8 +700,8 @@ static MACHINE_CONFIG_START( psi98 ) MCFG_UPD765A_ADD("fdc", true, true) MCFG_UPD765_INTRQ_CALLBACK(DEVWRITELINE("ctc1", z80ctc_device, trg0)) MCFG_UPD765_DRQ_CALLBACK(WRITELINE(kdt6_state, fdc_drq_w)) - MCFG_FLOPPY_DRIVE_ADD("fdc:0", kdt6_floppies, "525qd", floppy_image_device::default_floppy_formats) - MCFG_FLOPPY_DRIVE_ADD("fdc:1", kdt6_floppies, "525qd", floppy_image_device::default_floppy_formats) + MCFG_FLOPPY_DRIVE_ADD("fdc:0", kdt6_floppies, "fd55f", floppy_image_device::default_floppy_formats) + MCFG_FLOPPY_DRIVE_ADD("fdc:1", kdt6_floppies, "fd55f", floppy_image_device::default_floppy_formats) MCFG_SOFTWARE_LIST_ADD("floppy_list", "psi98") |