(MESS) c8050: Floppy WIP. (nw)

This commit is contained in:
Curt Coder 2014-12-07 14:08:22 +02:00
parent a9095f0490
commit e2f9eb08bf
4 changed files with 192 additions and 87 deletions

View File

@ -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)
{
}

View File

@ -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<m6502_device> m_maincpu;
required_device<m6504_device> m_fdccpu;

View File

@ -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,36 +597,6 @@ void c2040_fdc_t::stp_w(floppy_image_device *floppy, int mtr, int &old_stp, int
old_stp = stp;
}
void c8050_fdc_t::stp_w(floppy_image_device *floppy, int mtr, int &old_stp, int stp)
{
if (mtr) return;
int tracks = 0;
switch (old_stp)
{
case 0: if (stp == 1) tracks++; else if (stp == 2) tracks--; break;
case 1: if (stp == 3) tracks++; else if (stp == 0) tracks--; break;
case 2: if (stp == 0) tracks++; else if (stp == 3) tracks--; break;
case 3: if (stp == 2) tracks++; else if (stp == 1) tracks--; break;
}
if (tracks == -1)
{
floppy->dir_w(1);
floppy->stp_w(1);
floppy->stp_w(0);
}
else if (tracks == 1)
{
floppy->dir_w(0);
floppy->stp_w(1);
floppy->stp_w(0);
}
old_stp = stp;
}
void c2040_fdc_t::stp0_w(int stp)
{
if (m_stp0 != stp)
@ -685,3 +635,152 @@ void c2040_fdc_t::set_floppy(floppy_image_device *floppy0, floppy_image_device *
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;
int tracks = 0;
switch (old_stp)
{
case 0: if (stp == 1) tracks++; else if (stp == 2) tracks--; break;
case 1: if (stp == 3) tracks++; else if (stp == 0) tracks--; break;
case 2: if (stp == 0) tracks++; else if (stp == 3) tracks--; break;
case 3: if (stp == 2) tracks++; else if (stp == 1) tracks--; break;
}
if (tracks == -1)
{
floppy->dir_w(1);
floppy->stp_w(1);
floppy->stp_w(0);
}
else if (tracks == 1)
{
floppy->dir_w(0);
floppy->stp_w(1);
floppy->stp_w(0);
}
old_stp = stp;
}
WRITE_LINE_MEMBER( c8050_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( c8050_fdc_t::pull_sync_w )
{
// TODO
if (LOG) logerror("%s PULL SYNC %u\n", machine().time().as_string(), state);
}

View File

@ -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<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); }
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); }
@ -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;