Modernized mc6854 device.(nw)

Superficial testing shows no breakage, but in-depth testing from someone familiar with the machines would be appreciated.
This commit is contained in:
Ivan Vangelista 2013-11-04 18:06:29 +00:00
parent aae15c6fe6
commit b7627dda18
9 changed files with 535 additions and 537 deletions

View File

@ -276,7 +276,7 @@ static ADDRESS_MAP_START( e01_mem, AS_PROGRAM, 8, e01_device )
AM_RANGE(0xfc08, 0xfc08) AM_MIRROR(0x00c0) AM_READ(ram_select_r) AM_WRITE(floppy_w)
AM_RANGE(0xfc0c, 0xfc0f) AM_MIRROR(0x00c0) AM_DEVREADWRITE(WD2793_TAG, wd2793_t, read, write)
AM_RANGE(0xfc10, 0xfc1f) AM_MIRROR(0x00c0) AM_DEVREADWRITE(R6522_TAG, via6522_device, read, write)
AM_RANGE(0xfc20, 0xfc23) AM_MIRROR(0x00c0) AM_DEVREADWRITE_LEGACY(MC6854_TAG, mc6854_r, mc6854_w)
AM_RANGE(0xfc20, 0xfc23) AM_MIRROR(0x00c0) AM_DEVREADWRITE(MC6854_TAG, mc6854_device, read, write)
AM_RANGE(0xfc24, 0xfc24) AM_MIRROR(0x00c3) AM_READWRITE(network_irq_disable_r, network_irq_disable_w)
AM_RANGE(0xfc28, 0xfc28) AM_MIRROR(0x00c3) AM_READWRITE(network_irq_enable_r, network_irq_enable_w)
AM_RANGE(0xfc2c, 0xfc2c) AM_MIRROR(0x00c3) AM_READ_PORT("FLAP")
@ -769,6 +769,6 @@ WRITE8_MEMBER( e01_device::rtc_data_w )
void e01_device::econet_clk(int state)
{
mc6854_rxc_w(m_adlc, state);
mc6854_txc_w(m_adlc, state);
m_adlc->rxc_w(state);
m_adlc->txc_w(state);
}

File diff suppressed because it is too large Load Diff

View File

@ -9,22 +9,118 @@
#ifndef MC6854_H
#define MC6854_H
class mc6854_device : public device_t
#define MAX_FRAME_LENGTH 65536
/* arbitrary value, you may need to enlarge it if you get truncated frames */
#define MC6854_FIFO_SIZE 3
/* hardcoded size of the 6854 FIFO (this is a hardware limit) */
/* ---------- configuration ------------ */
struct mc6854_interface
{
devcb_write_line m_out_irq_cb; /* interrupt request */
/* low-level, bit-based interface */
devcb_read_line m_in_rxd_cb; /* receive bit */
devcb_write_line m_out_txd_cb; /* transmit bit */
/* high-level, frame-based interface */
void ( * m_out_frame ) ( device_t *device, UINT8* data, int length );
/* control lines */
devcb_write_line m_out_rts_cb; /* 1 = transmitting, 0 = idle */
devcb_write_line m_out_dtr_cb; /* 1 = data transmit ready, 0 = busy */
};
class mc6854_device : public device_t,
public mc6854_interface
{
public:
mc6854_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~mc6854_device() { global_free(m_token); }
~mc6854_device() {}
/* interface to CPU via address/data bus*/
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
/* low-level, bit-based interface */
DECLARE_WRITE_LINE_MEMBER( set_rx );
/* high-level, frame-based interface */
int send_frame( UINT8* data, int length ); /* ret -1 if busy */
/* control lines */
DECLARE_WRITE_LINE_MEMBER( set_cts ); /* 1 = clear-to-send, 0 = busy */
DECLARE_WRITE_LINE_MEMBER( set_dcd ); /* 1 = carrier, 0 = no carrier */
/* clock */
DECLARE_WRITE_LINE_MEMBER( rxc_w );
DECLARE_WRITE_LINE_MEMBER( txc_w );
// access to legacy token
void *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
private:
// internal state
void *m_token;
devcb_resolved_write_line m_out_irq_func;
devcb_resolved_read_line m_in_rxd_func;
devcb_resolved_write_line m_out_txd_func;
devcb_resolved_write_line m_out_rts_func;
devcb_resolved_write_line m_out_dtr_func;
/* registers */
UINT8 m_cr1, m_cr2, m_cr3, m_cr4; /* control registers */
UINT8 m_sr1, m_sr2; /* status registers */
UINT8 m_cts, m_dcd;
/* transmit state */
UINT8 m_tstate;
UINT16 m_tfifo[MC6854_FIFO_SIZE]; /* X x 8-bit FIFO + full & last marker bits */
UINT8 m_tones; /* counter for zero-insertion */
emu_timer *m_ttimer; /* when to ask for more data */
/* receive state */
UINT8 m_rstate;
UINT32 m_rreg; /* shift register */
UINT8 m_rones; /* count '1 bits */
UINT8 m_rsize; /* bits in the shift register */
UINT16 m_rfifo[MC6854_FIFO_SIZE]; /* X x 8-bit FIFO + full & addr marker bits */
/* frame-based interface*/
UINT8 m_frame[MAX_FRAME_LENGTH];
UINT32 m_flen, m_fpos;
/* meaning of tstate / rtate:
0 = idle / waiting for frame flag
1 = flag sync
2 = 8-bit address field(s)
3-4 = 8-bit control field(s)
5 = 8-bit logical control field(s)
6 = variable-length data field(s)
*/
void send_bits( UINT32 data, int len, int zi );
void tfifo_push( UINT8 data );
void tfifo_terminate( );
TIMER_CALLBACK_MEMBER(tfifo_cb);
void tfifo_clear( );
void rfifo_push( UINT8 d );
void rfifo_terminate( );
UINT8 rfifo_pop( );
void rfifo_clear( );
void update_sr2( );
void update_sr1( );
};
extern const device_type MC6854;
@ -51,25 +147,6 @@ extern const device_type MC6854;
*/
/* ---------- configuration ------------ */
struct mc6854_interface
{
devcb_write_line out_irq_func; /* interrupt request */
/* low-level, bit-based interface */
devcb_read_line in_rxd_func; /* receive bit */
devcb_write_line out_txd_func; /* transmit bit */
/* high-level, frame-based interface */
void ( * out_frame ) ( device_t *device, UINT8* data, int length );
/* control lines */
devcb_write_line out_rts_func; /* 1 = transmitting, 0 = idle */
devcb_write_line out_dtr_func; /* 1 = data transmit ready, 0 = busy */
};
#define MCFG_MC6854_ADD(_tag, _intrf) \
MCFG_DEVICE_ADD(_tag, MC6854, 0) \
MCFG_DEVICE_CONFIG(_intrf)
@ -78,23 +155,4 @@ struct mc6854_interface
MCFG_DEVICE_REMOVE(_tag)
/* ---------- functions ------------ */
/* interface to CPU via address/data bus*/
extern DECLARE_READ8_DEVICE_HANDLER ( mc6854_r );
extern DECLARE_WRITE8_DEVICE_HANDLER ( mc6854_w );
/* low-level, bit-based interface */
WRITE_LINE_DEVICE_HANDLER( mc6854_set_rx );
/* high-level, frame-based interface */
extern int mc6854_send_frame( device_t *device, UINT8* data, int length ); /* ret -1 if busy */
/* control lines */
WRITE_LINE_DEVICE_HANDLER( mc6854_set_cts ); /* 1 = clear-to-send, 0 = busy */
WRITE_LINE_DEVICE_HANDLER( mc6854_set_dcd ); /* 1 = carrier, 0 = no carrier */
/* clock */
WRITE_LINE_DEVICE_HANDLER( mc6854_rxc_w );
WRITE_LINE_DEVICE_HANDLER( mc6854_txc_w );
#endif

View File

@ -46,11 +46,9 @@
#include "cpu/m6502/m65sc02.h"
#include "machine/6522via.h"
#include "machine/mc146818.h" /* RTC & CMOS RAM */
#include "machine/mc6854.h"
#include "machine/upd7002.h"
#include "bus/centronics/ctronics.h"
#include "bus/econet/econet.h"
#include "sound/sn76496.h" /* Sound */
#include "sound/tms5220.h" /* Speech */
#include "video/saa5050.h" /* Teletext */
@ -621,9 +619,8 @@ static const sn76496_config psg_intf =
WRITE_LINE_MEMBER(bbc_state::econet_clk_w)
{
device_t *device = machine().device("mc6854");
mc6854_rxc_w(device, state);
mc6854_txc_w(device, state);
m_adlc->rxc_w(state);
m_adlc->txc_w(state);
}
static ECONET_INTERFACE( econet_intf )

View File

@ -78,7 +78,7 @@ static ADDRESS_MAP_START(poly_mem, AS_PROGRAM, 8, poly_state)
//AM_RANGE(0xe006, 0xe006) // baud rate controller (0=9600,2=4800,4=2400,6=1200,8=600,A=300)
AM_RANGE(0xe00c,0xe00f) AM_DEVREADWRITE("pia1", pia6821_device, read, write) //keyboard PIA 6821
AM_RANGE(0xe020,0xe027) AM_DEVREADWRITE("ptm", ptm6840_device, read, write) //timer 6840
AM_RANGE(0xe030,0xe037) AM_DEVREADWRITE_LEGACY("adlc", mc6854_r, mc6854_w) //Data Link Controller 6854
AM_RANGE(0xe030,0xe037) AM_DEVREADWRITE("adlc", mc6854_device, read, write) //Data Link Controller 6854
AM_RANGE(0xe040,0xe040) AM_NOP //Set protect flip-flop after 1 E-cycle
AM_RANGE(0xe050,0xe05f) AM_RAM //Dynamic Address Translater (arranges memory banks)
// AM_RANGE(0xe060,0xe060) Select Map 1

View File

@ -13,6 +13,7 @@
#include "machine/6522via.h"
#include "machine/6850acia.h"
#include "machine/mc6854.h"
#include "machine/ram.h"
#include "machine/i8271.h"
#include "machine/wd17xx.h"
@ -34,6 +35,7 @@ public:
m_maincpu(*this, "maincpu"),
m_ram(*this, RAM_TAG),
m_mc6845(*this, "mc6845"),
m_adlc(*this, "mc6854"),
m_sn(*this, "sn76489"),
m_trom(*this, "saa5050"),
m_tms(*this, "tms5220"),
@ -59,6 +61,7 @@ public:
required_device<cpu_device> m_maincpu;
required_device<ram_device> m_ram;
required_device<mc6845_device> m_mc6845;
optional_device<mc6854_device> m_adlc;
optional_device<sn76489_device> m_sn;
required_device<saa5050_device> m_trom;
optional_device<tms5220_device> m_tms;

View File

@ -98,6 +98,7 @@ class thomson_state : public driver_device
public:
thomson_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_mc6854(*this, "mc6854"),
m_maincpu(*this, "maincpu"),
m_cassette(*this, "cassette"),
m_buzzer(*this, "buzzer"),
@ -114,7 +115,9 @@ public:
DECLARE_DEVICE_IMAGE_LOAD_MEMBER( to7_cartridge );
DECLARE_DEVICE_IMAGE_LOAD_MEMBER( mo5_cartridge );
optional_device<mc6854_device> m_mc6854;
DECLARE_WRITE8_MEMBER( to7_set_cassette_motor );
DECLARE_WRITE8_MEMBER( mo5_set_cassette_motor );
DECLARE_WRITE_LINE_MEMBER( thom_dev_irq_0 );
@ -319,7 +322,7 @@ protected:
required_device<mea8000_device> m_mea8000;
required_device<ram_device> m_ram;
optional_device<mc6846_device> m_mc6846;
/* bank logging and optimisations */
int m_old_cart_bank;
int m_old_cart_bank_was_read_only;

View File

@ -13,7 +13,6 @@
#include <ctype.h>
#include "emu.h"
#include "cpu/m6502/m6502.h"
#include "sound/sn76496.h"
#include "sound/tms5220.h"
#include "machine/6522via.h"
#include "machine/wd17xx.h"
@ -22,7 +21,6 @@
#include "machine/upd7002.h"
#include "machine/i8271.h"
#include "machine/mc146818.h"
#include "machine/mc6854.h"
#include "bus/centronics/ctronics.h"
#include "imagedev/cassette.h"
@ -576,8 +574,7 @@ READ8_MEMBER(bbc_state::bbcm_r)
{
via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
via6522_device *via_1 = machine().device<via6522_device>("via6522_1");
device_t *adlc = machine().device("mc6854");
myo = offset-0x200;
if ((myo>=0x00) && (myo<=0x07)) return bbc_6845_r(space, myo-0x00); /* Video Controller */
if ((myo>=0x08) && (myo<=0x0f))
@ -598,7 +595,7 @@ READ8_MEMBER(bbc_state::bbcm_r)
if ((myo>=0x40) && (myo<=0x5f)) return via_0->read(space, myo-0x40);
if ((myo>=0x60) && (myo<=0x7f)) return via_1->read(space, myo-0x60);
if ((myo>=0x80) && (myo<=0x9f)) return 0xfe;
if ((myo>=0xa0) && (myo<=0xbf)) return mc6854_r(adlc, space, myo & 0x03);
if ((myo>=0xa0) && (myo<=0xbf)) return m_adlc->read(space, myo & 0x03);
if ((myo>=0xc0) && (myo<=0xdf)) return 0xfe;
if ((myo>=0xe0) && (myo<=0xff)) return 0xfe;
}
@ -614,8 +611,7 @@ WRITE8_MEMBER(bbc_state::bbcm_w)
{
via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
via6522_device *via_1 = machine().device<via6522_device>("via6522_1");
device_t *adlc = machine().device("mc6854");
myo=offset-0x200;
if ((myo>=0x00) && (myo<=0x07)) bbc_6845_w(space, myo-0x00, data); /* Video Controller */
if ((myo>=0x08) && (myo<=0x0f))
@ -636,7 +632,7 @@ WRITE8_MEMBER(bbc_state::bbcm_w)
if ((myo>=0x40) && (myo<=0x5f)) via_0->write(space, myo-0x40, data);
if ((myo>=0x60) && (myo<=0x7f)) via_1->write(space, myo-0x60, data);
//if ((myo>=0x80) && (myo<=0x9f))
if ((myo>=0xa0) && (myo<=0xbf)) mc6854_w(adlc, space, myo & 0x03, data);
if ((myo>=0xa0) && (myo<=0xbf)) m_adlc->write(space, myo & 0x03, data);
//if ((myo>=0xc0) && (myo<=0xdf))
//if ((myo>=0xe0) && (myo<=0xff))
}

View File

@ -1592,27 +1592,27 @@ void thomson_state::thmfc_floppy_init()
TIMER_CALLBACK_MEMBER( thomson_state::ans4 )
{
LOG(( "%f ans4\n", machine().time().as_double() ));
mc6854_set_cts( machine().device("mc6854"), 0 );
m_mc6854->set_cts( 0 );
}
TIMER_CALLBACK_MEMBER( thomson_state::ans3 )
{
LOG(( "%f ans3\n", machine().time().as_double() ));
mc6854_set_cts( machine().device("mc6854"), 1 );
m_mc6854->set_cts( 1 );
machine().scheduler().timer_set( attotime::from_usec( 100 ), timer_expired_delegate(FUNC(thomson_state::ans4),this));
}
TIMER_CALLBACK_MEMBER( thomson_state::ans2 )
{
LOG(( "%f ans2\n", machine().time().as_double() ));
mc6854_set_cts( machine().device("mc6854"), 0 );
m_mc6854->set_cts( 0 );
machine().scheduler().timer_set( attotime::from_usec( 100 ), timer_expired_delegate(FUNC(thomson_state::ans3),this));
}
TIMER_CALLBACK_MEMBER( thomson_state::ans )
{
LOG(( "%f ans\n", machine().time().as_double() ));
mc6854_set_cts( machine().device("mc6854"), 1 );
m_mc6854->set_cts( 1 );
machine().scheduler().timer_set( attotime::from_usec( 100 ), timer_expired_delegate(FUNC(thomson_state::ans2),this));
}
/* consigne DKBOOT
@ -1657,7 +1657,7 @@ static void to7_network_got_frame( device_t *device, UINT8* data, int length )
thomson_state *state = device->machine().driver_data<thomson_state>();
LOG(( "to7_network_got_frame: %i phones %i\n", data[2], data[0] ));
device->machine().scheduler().timer_set( attotime::from_usec( 100 ), timer_expired_delegate(FUNC(thomson_state::ans),state));
mc6854_set_cts( device, 0 );
state->m_mc6854->set_cts( 0 );
}
else if ( ! data[1] )
{
@ -1673,13 +1673,18 @@ static void to7_network_got_frame( device_t *device, UINT8* data, int length )
(data[10] == 0) ? "TO7" : (data[10] == 1) ? "MO5" :
(data[10] == 2) ? "TO7/70" : "?", name ));
}
}
const mc6854_interface to7_network_iface = { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, to7_network_got_frame, DEVCB_NULL, DEVCB_NULL };
const mc6854_interface to7_network_iface =
{
DEVCB_NULL,
DEVCB_NULL,
DEVCB_NULL,
to7_network_got_frame,
DEVCB_NULL,
DEVCB_NULL
};
void thomson_state::to7_network_init()
@ -1693,8 +1698,8 @@ void thomson_state::to7_network_init()
void thomson_state::to7_network_reset()
{
LOG(( "to7_network_reset: NR 07-005 network extension\n" ));
mc6854_set_cts( machine().device("mc6854"), 0 );
mc6854_set_cts( machine().device("mc6854"), 1 );
m_mc6854->set_cts( 0 );
m_mc6854->set_cts( 1 );
}
@ -1702,7 +1707,7 @@ void thomson_state::to7_network_reset()
READ8_MEMBER( thomson_state::to7_network_r )
{
if ( offset < 4 )
return mc6854_r( machine().device("mc6854"), space, offset );
return m_mc6854->read( space, offset );
if ( offset == 8 )
{
@ -1721,7 +1726,7 @@ READ8_MEMBER( thomson_state::to7_network_r )
WRITE8_MEMBER( thomson_state::to7_network_w )
{
if ( offset < 4 )
mc6854_w( machine().device("mc6854"), space, offset, data );
m_mc6854->write( space, offset, data );
else
{
logerror( "%f $%04x to7_network_w: invalid write offset %i (data=$%02X)\n",