summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/wd2010.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/wd2010.cpp')
-rw-r--r--src/devices/machine/wd2010.cpp163
1 files changed, 68 insertions, 95 deletions
diff --git a/src/devices/machine/wd2010.cpp b/src/devices/machine/wd2010.cpp
index 486d22b47f0..28f7b8ebbc3 100644
--- a/src/devices/machine/wd2010.cpp
+++ b/src/devices/machine/wd2010.cpp
@@ -36,7 +36,7 @@ UNIMPLEMENTED FEATURES :
**********************************************************************/
#include "emu.h"
-#include "machine/wd2010.h"
+#include "wd2010.h"
#define VERBOSE 1
#include "logmacro.h"
@@ -158,18 +158,18 @@ wd2010_device::wd2010_device(const machine_config &mconfig, const char *tag, dev
, m_out_intrq_cb(*this)
, m_out_bdrq_cb(*this)
, m_out_bcr_cb(*this)
- , m_in_bcs_cb(*this)
- , m_in_brdy_cb(*this)
+ , m_in_bcs_cb(*this, 0)
+ , m_in_brdy_cb(*this, 0)
, m_out_bcs_cb(*this)
, m_out_dirin_cb(*this)
, m_out_step_cb(*this)
, m_out_rwc_cb(*this)
, m_out_wg_cb(*this)
- , m_in_drdy_cb(*this)
- , m_in_index_cb(*this)
- , m_in_wf_cb(*this)
- , m_in_tk000_cb(*this)
- , m_in_sc_cb(*this)
+ , m_in_drdy_cb(*this, 0)
+ , m_in_index_cb(*this, 0)
+ , m_in_wf_cb(*this, 0)
+ , m_in_tk000_cb(*this, 0)
+ , m_in_sc_cb(*this, 0)
, m_status(0)
, m_error(0)
{
@@ -182,38 +182,13 @@ wd2010_device::wd2010_device(const machine_config &mconfig, const char *tag, dev
void wd2010_device::device_start()
{
- // resolve callbacks
- m_out_intrq_cb.resolve_safe();
- m_out_bdrq_cb.resolve_safe();
- m_out_bcr_cb.resolve_safe();
- m_in_bcs_cb.resolve_safe(0);
-
- m_in_brdy_cb.resolve_safe(0);
-
- m_out_bcs_cb.resolve_safe();
- m_out_dirin_cb.resolve_safe();
- m_out_step_cb.resolve_safe();
- m_out_rwc_cb.resolve_safe();
- m_out_wg_cb.resolve_safe();
- m_in_drdy_cb.resolve_safe(0);
- m_in_index_cb.resolve_safe(0);
- m_in_wf_cb.resolve_safe(0);
- m_in_tk000_cb.resolve_safe(0);
- m_in_sc_cb.resolve_safe(0);
-
- /* allocate a timer for commands */
- cmd_timer = timer_alloc(0);
- complete_write_when_buffer_ready_high = timer_alloc(1);
- deassert_write_when_buffer_ready_low = timer_alloc(2);
- deassert_read_when_buffer_ready_high = timer_alloc(3);
+ // allocate a timer for commands
+ m_cmd_timer = timer_alloc(FUNC(wd2010_device::command_complete), this);
+ m_complete_write_timer = timer_alloc(FUNC(wd2010_device::complete_write), this);
+ m_deassert_write_timer = timer_alloc(FUNC(wd2010_device::deassert_write), this);
+ m_deassert_read_timer = timer_alloc(FUNC(wd2010_device::deassert_read), this);
}
-// timers
-#define COMMAND_TIMER 0
-#define COMPLETE_WRITE_SECTOR 1
-#define DE_ASSERT_WRITE 2
-#define DE_ASSERT_READ 3
-
//-------------------------------------------------
// device_reset - device-specific reset
@@ -430,7 +405,7 @@ void wd2010_device::restore(uint8_t data)
// NOTE: calculation needs 'data' (extracted from command register)
float step_ms = SETTLING_MS + LATENCY_MS + ( (float)sqrt(1.0 * step_pulses) * STEP_RATE_MS );
- cmd_timer->adjust(attotime::from_usec(1000 * step_ms), newstatus);
+ m_cmd_timer->adjust(attotime::from_usec(1000 * step_ms), newstatus);
return;
}
@@ -532,7 +507,7 @@ void wd2010_device::seek(uint8_t data)
m_task_file[TASK_FILE_CYLINDER_LOW] = (m_present_cylinder - ((m_task_file[TASK_FILE_CYLINDER_HIGH] << 8) )) & 0xff;
//LOGERROR("SEEK (END) - m_present_cylinder = %u SDH CYL L/H %02x / %02x\n", m_present_cylinder,m_task_file[TASK_FILE_CYLINDER_LOW],m_task_file[TASK_FILE_CYLINDER_HIGH]);
- cmd_timer->adjust(attotime::from_usec(1000 * step_ms), newstatus);
+ m_cmd_timer->adjust(attotime::from_usec(1000 * step_ms), newstatus);
}
//-------------------------------------------------
@@ -644,7 +619,7 @@ void wd2010_device::read_sector(uint8_t data)
// NOTE : (intrq_at_end = 0) - INTRQ occurs when the command is completed
newstatus |= (m_status & ~(STATUS_CIP | STATUS_DRQ)) | intrq_at_end; // de-assert CIP + DRQ (BSY already reset)
- deassert_read_when_buffer_ready_high->adjust(attotime::from_usec(1), newstatus); // complete command ON *RISING EDGE * OF BUFFER_READY
+ m_deassert_read_timer->adjust(attotime::from_usec(1), newstatus); // complete command ON *RISING EDGE * OF BUFFER_READY
}
@@ -671,7 +646,7 @@ void wd2010_device::write_sector(uint8_t data)
m_out_bdrq_cb(1);
// WAIT UNTIL BRDY ASSERTED (-> timer):
- complete_write_when_buffer_ready_high->adjust(attotime::from_usec(1), data); // 1 usec
+ m_complete_write_timer->adjust(attotime::from_usec(1), data); // 1 usec
}
@@ -728,7 +703,7 @@ void wd2010_device::complete_write_sector(uint8_t data)
} // --------------------------------------------------------
// 'complete_cmd' ON THE FALLING EDGE OF _BUFFER_READY_ ( set by WRITE_SECTOR ) !
- deassert_write_when_buffer_ready_low->adjust(attotime::from_usec(1), newstatus);
+ m_deassert_write_timer->adjust(attotime::from_usec(1), newstatus);
}
// ******************************************************
@@ -862,7 +837,7 @@ void wd2010_device::format(uint8_t data)
m_out_wg_cb(0); // (transition from WG 1 -> 0). Actual write.
// ** DELAY INTRQ UNTIL WRITE IS COMPLETE :
- complete_write_when_buffer_ready_high->adjust(attotime::from_usec(1), newstatus | STATUS_DRQ); // 1 USECs
+ m_complete_write_timer->adjust(attotime::from_usec(1), newstatus | STATUS_DRQ); // 1 USECs
}
@@ -875,65 +850,63 @@ void wd2010_device::buffer_ready(bool state)
}
-void wd2010_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(wd2010_device::command_complete)
{
- switch (tid)
- {
- case COMMAND_TIMER:
- cmd_timer->adjust(attotime::never);
- complete_immediate(param);
- break;
-
- case COMPLETE_WRITE_SECTOR: // when BUFFER_READY -> HIGH
- if (is_buffer_ready)
- {
- complete_write_when_buffer_ready_high->adjust(attotime::never);
- complete_write_sector(param);
- }
- else
- {
- complete_write_when_buffer_ready_high->reset();
- complete_write_when_buffer_ready_high->adjust(attotime::from_usec(1), param); // DELAY ANOTHER 1 USEC (!)
- }
- break;
+ m_cmd_timer->adjust(attotime::never);
+ complete_immediate(param);
+}
- case DE_ASSERT_WRITE: // waiting for BUFFER_READY -> LOW
- if (!(is_buffer_ready))
- {
- deassert_write_when_buffer_ready_low->adjust(attotime::never);
- complete_immediate(param);
- }
- else
- {
- deassert_write_when_buffer_ready_low->reset();
- deassert_write_when_buffer_ready_low->adjust(attotime::from_usec(1), param); // DELAY ANOTHER 1 USEC (!)
- }
- break;
+TIMER_CALLBACK_MEMBER(wd2010_device::complete_write)
+{
+ // when BUFFER_READY -> HIGH
+ if (is_buffer_ready)
+ {
+ m_complete_write_timer->adjust(attotime::never);
+ complete_write_sector(param);
+ }
+ else
+ {
+ m_complete_write_timer->reset();
+ m_complete_write_timer->adjust(attotime::from_usec(1), param); // DELAY ANOTHER 1 USEC (!)
+ }
+}
- case DE_ASSERT_READ: // when BUFFER_READY -> HIGH
- if (is_buffer_ready)
- {
- deassert_read_when_buffer_ready_high->adjust(attotime::never);
+TIMER_CALLBACK_MEMBER(wd2010_device::deassert_write)
+{
+ // waiting for BUFFER_READY -> LOW
+ if (!(is_buffer_ready))
+ {
+ m_deassert_write_timer->adjust(attotime::never);
+ complete_immediate(param);
+ }
+ else
+ {
+ m_deassert_write_timer->reset();
+ m_deassert_write_timer->adjust(attotime::from_usec(1), param); // DELAY ANOTHER 1 USEC (!)
+ }
+}
- m_error &= ~ERROR_ID;
- param &= ~STATUS_ERR;
+TIMER_CALLBACK_MEMBER(wd2010_device::deassert_read)
+{
+ // when BUFFER_READY -> HIGH
+ if (is_buffer_ready)
+ {
+ m_deassert_read_timer->adjust(attotime::never);
- m_out_bdrq_cb(0);
- complete_immediate(param);
- }
- else
- {
- deassert_read_when_buffer_ready_high->reset();
- deassert_read_when_buffer_ready_high->adjust(attotime::from_usec(1), param); // DELAY ANOTHER 1 USEC (!)
- }
- break;
+ m_error &= ~ERROR_ID;
+ param &= ~STATUS_ERR;
- default:
- break;
+ m_out_bdrq_cb(0);
+ complete_immediate(param);
+ }
+ else
+ {
+ m_deassert_read_timer->reset();
+ m_deassert_read_timer->adjust(attotime::from_usec(1), param); // DELAY ANOTHER 1 USEC (!)
}
}
-// Called by 'device_timer' -
+// Called by timer callbacks -
void wd2010_device::complete_immediate(uint8_t status)
{
// re-evaluate external signals at end of command
@@ -964,5 +937,5 @@ void wd2010_device::complete_immediate(uint8_t status)
void wd2010_device::complete_cmd(uint8_t status)
{
- cmd_timer->adjust(attotime::from_msec(1), status);
+ m_cmd_timer->adjust(attotime::from_msec(1), status);
}