summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/imagedev
diff options
context:
space:
mode:
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
commit369b255b8ef93320d07d830836d435aaccb98f0a (patch)
tree151cde4c48f1a6f764350aa68ac14e2ffdf08c19 /src/devices/imagedev
parent49a7303d0f4369830b092dee990570e2ca0731c8 (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.
Diffstat (limited to 'src/devices/imagedev')
-rw-r--r--src/devices/imagedev/floppy.cpp54
-rw-r--r--src/devices/imagedev/floppy.h9
2 files changed, 42 insertions, 21 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);