From e2f9eb08bf15ed439ceef2d86307f12d4fef6f72 Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Sun, 7 Dec 2014 14:08:22 +0200 Subject: (MESS) c8050: Floppy WIP. (nw) --- src/emu/bus/ieee488/c2040.c | 36 ++++---- src/emu/bus/ieee488/c2040.h | 7 -- src/emu/bus/ieee488/c2040fdc.c | 197 +++++++++++++++++++++++++++++++---------- src/emu/bus/ieee488/c2040fdc.h | 35 +++++--- 4 files changed, 190 insertions(+), 85 deletions(-) diff --git a/src/emu/bus/ieee488/c2040.c b/src/emu/bus/ieee488/c2040.c index 868b066a9ab..d12be0795a3 100644 --- a/src/emu/bus/ieee488/c2040.c +++ b/src/emu/bus/ieee488/c2040.c @@ -626,24 +626,24 @@ c2040_device::c2040_device(const machine_config &mconfig, device_type type, cons { } -c2040_device::c2040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, C2040, "C2040", tag, owner, clock, "c2040", __FILE__), - device_ieee488_interface(mconfig, *this), - m_maincpu(*this, M6502_TAG), - m_fdccpu(*this, M6504_TAG), - m_riot0(*this, M6532_0_TAG), - m_riot1(*this, M6532_1_TAG), - m_miot(*this, M6530_TAG), - m_via(*this, M6522_TAG), - m_floppy0(*this, FDC_TAG":0:525ssqd"), - m_floppy1(*this, FDC_TAG":1:525ssqd"), - m_fdc(*this, FDC_TAG), - m_gcr(*this, "gcr"), - m_address(*this, "ADDRESS"), - m_rfdo(1), - m_daco(1), - m_atna(1), - m_miot_irq(CLEAR_LINE) +c2040_device::c2040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, C2040, "C2040", tag, owner, clock, "c2040", __FILE__), + device_ieee488_interface(mconfig, *this), + m_maincpu(*this, M6502_TAG), + m_fdccpu(*this, M6504_TAG), + m_riot0(*this, M6532_0_TAG), + m_riot1(*this, M6532_1_TAG), + m_miot(*this, M6530_TAG), + m_via(*this, M6522_TAG), + m_floppy0(*this, FDC_TAG":0:525ssqd"), + m_floppy1(*this, FDC_TAG":1:525ssqd"), + m_fdc(*this, FDC_TAG), + m_gcr(*this, "gcr"), + m_address(*this, "ADDRESS"), + m_rfdo(1), + m_daco(1), + m_atna(1), + m_miot_irq(CLEAR_LINE) { } diff --git a/src/emu/bus/ieee488/c2040.h b/src/emu/bus/ieee488/c2040.h index 706183cad99..c99731d27d9 100644 --- a/src/emu/bus/ieee488/c2040.h +++ b/src/emu/bus/ieee488/c2040.h @@ -19,12 +19,6 @@ #include "c2040fdc.h" #include "cpu/m6502/m6502.h" #include "cpu/m6502/m6504.h" -#include "imagedev/floppy.h" -#include "formats/d64_dsk.h" -#include "formats/g64_dsk.h" -#include "formats/d67_dsk.h" -#include "formats/d80_dsk.h" -#include "formats/d82_dsk.h" #include "machine/6522via.h" #include "machine/6532riot.h" #include "machine/mos6530.h" @@ -82,7 +76,6 @@ protected: }; inline void update_ieee_signals(); - inline void update_gcr_data(); required_device m_maincpu; required_device m_fdccpu; diff --git a/src/emu/bus/ieee488/c2040fdc.c b/src/emu/bus/ieee488/c2040fdc.c index 29a8432b0a3..7ed050b2bcf 100644 --- a/src/emu/bus/ieee488/c2040fdc.c +++ b/src/emu/bus/ieee488/c2040fdc.c @@ -119,7 +119,7 @@ c2040_fdc_t::c2040_fdc_t(const machine_config &mconfig, const char *tag, device_ } c8050_fdc_t::c8050_fdc_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - c2040_fdc_t(mconfig, C2040_FDC, "C2040 FDC", tag, owner, clock, "c2040fdc", __FILE__) { } + c2040_fdc_t(mconfig, C8050_FDC, "C8050 FDC", tag, owner, clock, "c8050fdc", __FILE__) { } @@ -567,26 +567,6 @@ WRITE_LINE_MEMBER( c2040_fdc_t::mtr1_w ) } } -WRITE_LINE_MEMBER( c2040_fdc_t::odd_hd_w ) -{ - if (m_odd_hd != state) - { - live_sync(); - m_odd_hd = cur_live.odd_hd = state; - if (LOG) logerror("%s ODD HD %u\n", machine().time().as_string(), state); - m_floppy0->ss_w(!state); - if (m_floppy1) m_floppy1->ss_w(!state); - checkpoint(); - live_run(); - } -} - -WRITE_LINE_MEMBER( c2040_fdc_t::pull_sync_w ) -{ - // TODO - if (LOG) logerror("%s PULL SYNC %u\n", machine().time().as_string(), state); -} - void c2040_fdc_t::stp_w(floppy_image_device *floppy, int mtr, int &old_stp, int stp) { if (mtr) return; @@ -617,6 +597,144 @@ void c2040_fdc_t::stp_w(floppy_image_device *floppy, int mtr, int &old_stp, int old_stp = stp; } +void c2040_fdc_t::stp0_w(int stp) +{ + if (m_stp0 != stp) + { + live_sync(); + this->stp_w(m_floppy0, m_mtr0, m_stp0, stp); + checkpoint(); + live_run(); + } +} + +void c2040_fdc_t::stp1_w(int stp) +{ + if (m_stp1 != stp) + { + live_sync(); + if (m_floppy1) this->stp_w(m_floppy1, m_mtr1, m_stp1, stp); + checkpoint(); + live_run(); + } +} + +void c2040_fdc_t::ds_w(int ds) +{ + if (m_ds != ds) + { + live_sync(); + m_ds = cur_live.ds = ds; + checkpoint(); + live_run(); + } +} + +void c2040_fdc_t::set_floppy(floppy_image_device *floppy0, floppy_image_device *floppy1) +{ + m_floppy0 = floppy0; + m_floppy1 = floppy1; +} + +void c8050_fdc_t::live_start() +{ + cur_live.tm = machine().time(); + cur_live.state = RUNNING; + cur_live.next_state = -1; + + cur_live.shift_reg = 0; + cur_live.shift_reg_write = 0; + cur_live.cycle_counter = 0; + cur_live.cell_counter = 0; + cur_live.bit_counter = 0; + cur_live.ds = m_ds; + cur_live.drv_sel = m_drv_sel; + cur_live.mode_sel = m_mode_sel; + cur_live.rw_sel = m_rw_sel; + cur_live.pi = m_pi; + + pll_reset(cur_live.tm, attotime::from_hz(0)); + checkpoint_live = cur_live; + pll_save_checkpoint(); + + live_run(); +} + +void c8050_fdc_t::pll_reset(const attotime &when, const attotime clock) +{ + cur_pll.reset(when); + cur_pll.set_clock(clock); +} + +void c8050_fdc_t::pll_save_checkpoint() +{ + checkpoint_pll = cur_pll; +} + +void c8050_fdc_t::pll_retrieve_checkpoint() +{ + cur_pll = checkpoint_pll; +} + +void c8050_fdc_t::checkpoint() +{ + checkpoint_live = cur_live; + pll_save_checkpoint(); +} + +void c8050_fdc_t::rollback() +{ + cur_live = checkpoint_live; + pll_retrieve_checkpoint(); +} + +void c8050_fdc_t::live_run(const attotime &limit) +{ + if(cur_live.state == IDLE || cur_live.next_state != -1) + return; + + for(;;) { + switch(cur_live.state) { + case RUNNING: { + bool syncpoint = false; + + if (cur_live.tm > limit) + return; + + int bit = get_next_bit(cur_live.tm, limit); + if(bit < 0) + return; + + if (syncpoint) { + commit(cur_live.tm); + + cur_live.tm += m_period; + live_delay(RUNNING_SYNCPOINT); + return; + } + + cur_live.tm += m_period; + break; + } + + case RUNNING_SYNCPOINT: { + m_write_ready(cur_live.ready); + m_write_sync(cur_live.sync); + m_write_error(cur_live.error); + + cur_live.state = RUNNING; + checkpoint(); + break; + } + } + } +} + +int c8050_fdc_t::get_next_bit(attotime &tm, const attotime &limit) +{ + return cur_pll.get_next_bit(tm, get_floppy(), limit); +} + void c8050_fdc_t::stp_w(floppy_image_device *floppy, int mtr, int &old_stp, int stp) { if (mtr) return; @@ -647,41 +765,22 @@ void c8050_fdc_t::stp_w(floppy_image_device *floppy, int mtr, int &old_stp, int old_stp = stp; } -void c2040_fdc_t::stp0_w(int stp) -{ - if (m_stp0 != stp) - { - live_sync(); - this->stp_w(m_floppy0, m_mtr0, m_stp0, stp); - checkpoint(); - live_run(); - } -} - -void c2040_fdc_t::stp1_w(int stp) +WRITE_LINE_MEMBER( c8050_fdc_t::odd_hd_w ) { - if (m_stp1 != stp) - { - live_sync(); - if (m_floppy1) this->stp_w(m_floppy1, m_mtr1, m_stp1, stp); - checkpoint(); - live_run(); - } -} - -void c2040_fdc_t::ds_w(int ds) -{ - if (m_ds != ds) + if (m_odd_hd != state) { live_sync(); - m_ds = cur_live.ds = ds; + m_odd_hd = cur_live.odd_hd = state; + if (LOG) logerror("%s ODD HD %u\n", machine().time().as_string(), state); + m_floppy0->ss_w(!state); + if (m_floppy1) m_floppy1->ss_w(!state); checkpoint(); live_run(); } } -void c2040_fdc_t::set_floppy(floppy_image_device *floppy0, floppy_image_device *floppy1) +WRITE_LINE_MEMBER( c8050_fdc_t::pull_sync_w ) { - m_floppy0 = floppy0; - m_floppy1 = floppy1; + // TODO + if (LOG) logerror("%s PULL SYNC %u\n", machine().time().as_string(), state); } diff --git a/src/emu/bus/ieee488/c2040fdc.h b/src/emu/bus/ieee488/c2040fdc.h index d06fb7bd827..e9d43bc1e1c 100644 --- a/src/emu/bus/ieee488/c2040fdc.h +++ b/src/emu/bus/ieee488/c2040fdc.h @@ -15,10 +15,13 @@ #define __C2040_FLOPPY__ #include "emu.h" -#include "imagedev/floppy.h" #include "formats/d64_dsk.h" #include "formats/d67_dsk.h" #include "formats/g64_dsk.h" +#include "formats/d80_dsk.h" +#include "formats/d82_dsk.h" +#include "imagedev/floppy.h" +#include "machine/fdc_pll.h" @@ -47,8 +50,8 @@ class c2040_fdc_t : public device_t { public: // construction/destruction - c2040_fdc_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); c2040_fdc_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); + c2040_fdc_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); template static devcb_base &set_sync_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_sync.set_callback(object); } template static devcb_base &set_ready_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_ready.set_callback(object); } @@ -62,8 +65,6 @@ public: DECLARE_WRITE_LINE_MEMBER( rw_sel_w ); DECLARE_WRITE_LINE_MEMBER( mtr0_w ); DECLARE_WRITE_LINE_MEMBER( mtr1_w ); - DECLARE_WRITE_LINE_MEMBER( odd_hd_w ); - DECLARE_WRITE_LINE_MEMBER( pull_sync_w ); DECLARE_READ_LINE_MEMBER( wps_r ) { return checkpoint_live.drv_sel ? m_floppy1->wpt_r() : m_floppy0->wpt_r(); } DECLARE_READ_LINE_MEMBER( sync_r ) { return checkpoint_live.sync; } @@ -146,9 +147,9 @@ protected: emu_timer *t_gen; floppy_image_device* get_floppy(); - void live_start(); - void checkpoint(); - void rollback(); + virtual void live_start(); + virtual void checkpoint(); + virtual void rollback(); bool write_next_bit(bool bit, const attotime &limit); void start_writing(const attotime &tm); void commit(const attotime &tm); @@ -156,9 +157,9 @@ protected: void live_delay(int state); void live_sync(); void live_abort(); - void live_run(const attotime &limit = attotime::never); + virtual void live_run(const attotime &limit = attotime::never); void get_next_edge(const attotime &when); - int get_next_bit(attotime &tm, const attotime &limit); + virtual int get_next_bit(attotime &tm, const attotime &limit); }; @@ -170,8 +171,22 @@ public: // construction/destruction c8050_fdc_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + DECLARE_WRITE_LINE_MEMBER( odd_hd_w ); + DECLARE_WRITE_LINE_MEMBER( pull_sync_w ); + protected: + fdc_pll_t cur_pll, checkpoint_pll; + void stp_w(floppy_image_device *floppy, int mtr, int &old_stp, int stp); + + virtual void live_start(); + virtual void checkpoint(); + virtual void rollback(); + void pll_reset(const attotime &when, const attotime clock); + void pll_save_checkpoint(); + void pll_retrieve_checkpoint(); + virtual void live_run(const attotime &limit = attotime::never); + virtual int get_next_bit(attotime &tm, const attotime &limit); }; @@ -179,8 +194,6 @@ protected: // device type definition extern const device_type C2040_FDC; extern const device_type C8050_FDC; -//extern const device_type C8250_FDC; -//extern const device_type SFD1001_FDC; -- cgit v1.2.3