Previous 199869 Revisions Next

r33732 Sunday 7th December, 2014 at 12:08:22 UTC by Curt Coder
(MESS) c8050: Floppy WIP. (nw)
[src/emu/bus/ieee488]c2040.c c2040.h c2040fdc.c c2040fdc.h

trunk/src/emu/bus/ieee488/c2040.c
r242243r242244
626626{
627627}
628628
629c2040_device::c2040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
630   : device_t(mconfig, C2040, "C2040", tag, owner, clock, "c2040", __FILE__),
631      device_ieee488_interface(mconfig, *this),
632      m_maincpu(*this, M6502_TAG),
633      m_fdccpu(*this, M6504_TAG),
634      m_riot0(*this, M6532_0_TAG),
635      m_riot1(*this, M6532_1_TAG),
636      m_miot(*this, M6530_TAG),
637      m_via(*this, M6522_TAG),
638      m_floppy0(*this, FDC_TAG":0:525ssqd"),
639      m_floppy1(*this, FDC_TAG":1:525ssqd"),
640      m_fdc(*this, FDC_TAG),
641      m_gcr(*this, "gcr"),
642      m_address(*this, "ADDRESS"),
643      m_rfdo(1),
644      m_daco(1),
645      m_atna(1),
646      m_miot_irq(CLEAR_LINE)
629c2040_device::c2040_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
630   device_t(mconfig, C2040, "C2040", tag, owner, clock, "c2040", __FILE__),
631   device_ieee488_interface(mconfig, *this),
632   m_maincpu(*this, M6502_TAG),
633   m_fdccpu(*this, M6504_TAG),
634   m_riot0(*this, M6532_0_TAG),
635   m_riot1(*this, M6532_1_TAG),
636   m_miot(*this, M6530_TAG),
637   m_via(*this, M6522_TAG),
638   m_floppy0(*this, FDC_TAG":0:525ssqd"),
639   m_floppy1(*this, FDC_TAG":1:525ssqd"),
640   m_fdc(*this, FDC_TAG),
641   m_gcr(*this, "gcr"),
642   m_address(*this, "ADDRESS"),
643   m_rfdo(1),
644   m_daco(1),
645   m_atna(1),
646   m_miot_irq(CLEAR_LINE)
647647{
648648}
649649
trunk/src/emu/bus/ieee488/c2040.h
r242243r242244
1919#include "c2040fdc.h"
2020#include "cpu/m6502/m6502.h"
2121#include "cpu/m6502/m6504.h"
22#include "imagedev/floppy.h"
23#include "formats/d64_dsk.h"
24#include "formats/g64_dsk.h"
25#include "formats/d67_dsk.h"
26#include "formats/d80_dsk.h"
27#include "formats/d82_dsk.h"
2822#include "machine/6522via.h"
2923#include "machine/6532riot.h"
3024#include "machine/mos6530.h"
r242243r242244
8276   };
8377
8478   inline void update_ieee_signals();
85   inline void update_gcr_data();
8679
8780   required_device<m6502_device> m_maincpu;
8881   required_device<m6504_device> m_fdccpu;
trunk/src/emu/bus/ieee488/c2040fdc.c
r242243r242244
119119}
120120
121121c8050_fdc_t::c8050_fdc_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
122   c2040_fdc_t(mconfig, C2040_FDC, "C2040 FDC", tag, owner, clock, "c2040fdc", __FILE__) { }
122   c2040_fdc_t(mconfig, C8050_FDC, "C8050 FDC", tag, owner, clock, "c8050fdc", __FILE__) { }
123123
124124
125125
r242243r242244
567567   }
568568}
569569
570WRITE_LINE_MEMBER( c2040_fdc_t::odd_hd_w )
571{
572   if (m_odd_hd != state)
573   {
574      live_sync();
575      m_odd_hd = cur_live.odd_hd = state;
576      if (LOG) logerror("%s ODD HD %u\n", machine().time().as_string(), state);
577      m_floppy0->ss_w(!state);
578      if (m_floppy1) m_floppy1->ss_w(!state);
579      checkpoint();
580      live_run();
581   }
582}
583
584WRITE_LINE_MEMBER( c2040_fdc_t::pull_sync_w )
585{
586   // TODO
587   if (LOG) logerror("%s PULL SYNC %u\n", machine().time().as_string(), state);
588}
589
590570void c2040_fdc_t::stp_w(floppy_image_device *floppy, int mtr, int &old_stp, int stp)
591571{
592572   if (mtr) return;
r242243r242244
617597   old_stp = stp;
618598}
619599
600void c2040_fdc_t::stp0_w(int stp)
601{
602   if (m_stp0 != stp)
603   {
604      live_sync();
605      this->stp_w(m_floppy0, m_mtr0, m_stp0, stp);
606      checkpoint();
607      live_run();
608   }
609}
610
611void c2040_fdc_t::stp1_w(int stp)
612{
613   if (m_stp1 != stp)
614   {
615      live_sync();
616      if (m_floppy1) this->stp_w(m_floppy1, m_mtr1, m_stp1, stp);
617      checkpoint();
618      live_run();
619   }
620}
621
622void c2040_fdc_t::ds_w(int ds)
623{
624   if (m_ds != ds)
625   {
626      live_sync();
627      m_ds = cur_live.ds = ds;
628      checkpoint();
629      live_run();
630   }
631}
632
633void c2040_fdc_t::set_floppy(floppy_image_device *floppy0, floppy_image_device *floppy1)
634{
635   m_floppy0 = floppy0;
636   m_floppy1 = floppy1;
637}
638
639void c8050_fdc_t::live_start()
640{
641   cur_live.tm = machine().time();
642   cur_live.state = RUNNING;
643   cur_live.next_state = -1;
644
645   cur_live.shift_reg = 0;
646   cur_live.shift_reg_write = 0;
647   cur_live.cycle_counter = 0;
648   cur_live.cell_counter = 0;
649   cur_live.bit_counter = 0;
650   cur_live.ds = m_ds;
651   cur_live.drv_sel = m_drv_sel;
652   cur_live.mode_sel = m_mode_sel;
653   cur_live.rw_sel = m_rw_sel;
654   cur_live.pi = m_pi;
655
656   pll_reset(cur_live.tm, attotime::from_hz(0));
657   checkpoint_live = cur_live;
658   pll_save_checkpoint();
659
660   live_run();
661}
662
663void c8050_fdc_t::pll_reset(const attotime &when, const attotime clock)
664{
665   cur_pll.reset(when);
666   cur_pll.set_clock(clock);
667}
668
669void c8050_fdc_t::pll_save_checkpoint()
670{
671   checkpoint_pll = cur_pll;
672}
673
674void c8050_fdc_t::pll_retrieve_checkpoint()
675{
676   cur_pll = checkpoint_pll;
677}
678
679void c8050_fdc_t::checkpoint()
680{
681   checkpoint_live = cur_live;
682   pll_save_checkpoint();
683}
684
685void c8050_fdc_t::rollback()
686{
687   cur_live = checkpoint_live;
688   pll_retrieve_checkpoint();
689}
690
691void c8050_fdc_t::live_run(const attotime &limit)
692{
693   if(cur_live.state == IDLE || cur_live.next_state != -1)
694      return;
695
696   for(;;) {
697      switch(cur_live.state) {
698      case RUNNING: {
699         bool syncpoint = false;
700
701         if (cur_live.tm > limit)
702            return;
703
704         int bit = get_next_bit(cur_live.tm, limit);
705         if(bit < 0)
706            return;
707
708         if (syncpoint) {
709            commit(cur_live.tm);
710
711            cur_live.tm += m_period;
712            live_delay(RUNNING_SYNCPOINT);
713            return;
714         }
715
716         cur_live.tm += m_period;
717         break;
718      }
719
720      case RUNNING_SYNCPOINT: {
721         m_write_ready(cur_live.ready);
722         m_write_sync(cur_live.sync);
723         m_write_error(cur_live.error);
724
725         cur_live.state = RUNNING;
726         checkpoint();
727         break;
728      }
729      }
730   }
731}
732
733int c8050_fdc_t::get_next_bit(attotime &tm, const attotime &limit)
734{
735   return cur_pll.get_next_bit(tm, get_floppy(), limit);
736}
737
620738void c8050_fdc_t::stp_w(floppy_image_device *floppy, int mtr, int &old_stp, int stp)
621739{
622740   if (mtr) return;
r242243r242244
647765   old_stp = stp;
648766}
649767
650void c2040_fdc_t::stp0_w(int stp)
768WRITE_LINE_MEMBER( c8050_fdc_t::odd_hd_w )
651769{
652   if (m_stp0 != stp)
770   if (m_odd_hd != state)
653771   {
654772      live_sync();
655      this->stp_w(m_floppy0, m_mtr0, m_stp0, stp);
773      m_odd_hd = cur_live.odd_hd = state;
774      if (LOG) logerror("%s ODD HD %u\n", machine().time().as_string(), state);
775      m_floppy0->ss_w(!state);
776      if (m_floppy1) m_floppy1->ss_w(!state);
656777      checkpoint();
657778      live_run();
658779   }
659780}
660781
661void c2040_fdc_t::stp1_w(int stp)
782WRITE_LINE_MEMBER( c8050_fdc_t::pull_sync_w )
662783{
663   if (m_stp1 != stp)
664   {
665      live_sync();
666      if (m_floppy1) this->stp_w(m_floppy1, m_mtr1, m_stp1, stp);
667      checkpoint();
668      live_run();
669   }
784   // TODO
785   if (LOG) logerror("%s PULL SYNC %u\n", machine().time().as_string(), state);
670786}
671
672void c2040_fdc_t::ds_w(int ds)
673{
674   if (m_ds != ds)
675   {
676      live_sync();
677      m_ds = cur_live.ds = ds;
678      checkpoint();
679      live_run();
680   }
681}
682
683void c2040_fdc_t::set_floppy(floppy_image_device *floppy0, floppy_image_device *floppy1)
684{
685   m_floppy0 = floppy0;
686   m_floppy1 = floppy1;
687}
trunk/src/emu/bus/ieee488/c2040fdc.h
r242243r242244
1515#define __C2040_FLOPPY__
1616
1717#include "emu.h"
18#include "imagedev/floppy.h"
1918#include "formats/d64_dsk.h"
2019#include "formats/d67_dsk.h"
2120#include "formats/g64_dsk.h"
21#include "formats/d80_dsk.h"
22#include "formats/d82_dsk.h"
23#include "imagedev/floppy.h"
24#include "machine/fdc_pll.h"
2225
2326
2427
r242243r242244
4750{
4851public:
4952   // construction/destruction
53   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);
5054   c2040_fdc_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
51   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);
5255
5356   template<class _Object> static devcb_base &set_sync_wr_callback(device_t &device, _Object object) { return downcast<c2040_fdc_t &>(device).m_write_sync.set_callback(object); }
5457   template<class _Object> static devcb_base &set_ready_wr_callback(device_t &device, _Object object) { return downcast<c2040_fdc_t &>(device).m_write_ready.set_callback(object); }
r242243r242244
6265   DECLARE_WRITE_LINE_MEMBER( rw_sel_w );
6366   DECLARE_WRITE_LINE_MEMBER( mtr0_w );
6467   DECLARE_WRITE_LINE_MEMBER( mtr1_w );
65   DECLARE_WRITE_LINE_MEMBER( odd_hd_w );
66   DECLARE_WRITE_LINE_MEMBER( pull_sync_w );
6768
6869   DECLARE_READ_LINE_MEMBER( wps_r ) { return checkpoint_live.drv_sel ? m_floppy1->wpt_r() : m_floppy0->wpt_r(); }
6970   DECLARE_READ_LINE_MEMBER( sync_r ) { return checkpoint_live.sync; }
r242243r242244
146147   emu_timer *t_gen;
147148
148149   floppy_image_device* get_floppy();
149   void live_start();
150   void checkpoint();
151   void rollback();
150   virtual void live_start();
151   virtual void checkpoint();
152   virtual void rollback();
152153   bool write_next_bit(bool bit, const attotime &limit);
153154   void start_writing(const attotime &tm);
154155   void commit(const attotime &tm);
r242243r242244
156157   void live_delay(int state);
157158   void live_sync();
158159   void live_abort();
159   void live_run(const attotime &limit = attotime::never);
160   virtual void live_run(const attotime &limit = attotime::never);
160161   void get_next_edge(const attotime &when);
161   int get_next_bit(attotime &tm, const attotime &limit);
162   virtual int get_next_bit(attotime &tm, const attotime &limit);
162163};
163164
164165
r242243r242244
170171   // construction/destruction
171172   c8050_fdc_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
172173
174   DECLARE_WRITE_LINE_MEMBER( odd_hd_w );
175   DECLARE_WRITE_LINE_MEMBER( pull_sync_w );
176
173177protected:
178   fdc_pll_t cur_pll, checkpoint_pll;
179
174180   void stp_w(floppy_image_device *floppy, int mtr, int &old_stp, int stp);
181
182   virtual void live_start();
183   virtual void checkpoint();
184   virtual void rollback();
185   void pll_reset(const attotime &when, const attotime clock);
186   void pll_save_checkpoint();
187   void pll_retrieve_checkpoint();
188   virtual void live_run(const attotime &limit = attotime::never);
189   virtual int get_next_bit(attotime &tm, const attotime &limit);
175190};
176191
177192
r242243r242244
179194// device type definition
180195extern const device_type C2040_FDC;
181196extern const device_type C8050_FDC;
182//extern const device_type C8250_FDC;
183//extern const device_type SFD1001_FDC;
184197
185198
186199


Previous 199869 Revisions Next


© 1997-2024 The MAME Team