mirror of
https://github.com/holub/mame
synced 2025-04-24 09:20:02 +03:00
Modernized the e05a03 device. Basic testing has been done, but regression testing by someone who knows the driver/system would be appreciated. (nw)
This commit is contained in:
parent
135c03552f
commit
6ed90fc42a
@ -159,7 +159,7 @@ static ADDRESS_MAP_START( lx800_mem, AS_PROGRAM, 8, lx800_state )
|
||||
AM_RANGE(0x0000, 0x7fff) AM_ROM /* 32k firmware */
|
||||
AM_RANGE(0x8000, 0x9fff) AM_RAM /* 8k external RAM */
|
||||
AM_RANGE(0xa000, 0xbfff) AM_NOP /* not used */
|
||||
AM_RANGE(0xc000, 0xdfff) AM_MIRROR(0x1ff8) AM_DEVREADWRITE_LEGACY("ic3b", e05a03_r, e05a03_w)
|
||||
AM_RANGE(0xc000, 0xdfff) AM_MIRROR(0x1ff8) AM_DEVREADWRITE("ic3b", e05a03_device, read, write)
|
||||
AM_RANGE(0xe000, 0xfeff) AM_NOP /* not used */
|
||||
AM_RANGE(0xff00, 0xffff) AM_RAM /* internal CPU RAM */
|
||||
ADDRESS_MAP_END
|
||||
|
@ -6,156 +6,147 @@
|
||||
|
||||
#include "emu.h"
|
||||
#include "e05a03.h"
|
||||
#include "devlegcy.h"
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
|
||||
struct e05a03_state
|
||||
{
|
||||
/* 24-bit shift register, port 0x00, 0x01 and 0x02 */
|
||||
UINT32 shift;
|
||||
|
||||
/* port 0x03 */
|
||||
int busy_leading;
|
||||
int busy_software;
|
||||
int nlqlp;
|
||||
int cndlp;
|
||||
|
||||
#if 0
|
||||
int pe;
|
||||
int pelp;
|
||||
#endif
|
||||
|
||||
/* port 0x04 and 0x05 (9-bit) */
|
||||
UINT16 printhead;
|
||||
|
||||
/* port 0x06 (4-bit) */
|
||||
UINT8 pf_motor;
|
||||
|
||||
/* port 0x07 (4-bit) */
|
||||
UINT8 cr_motor;
|
||||
|
||||
/* callbacks */
|
||||
devcb_resolved_write_line out_nlq_lp_func; /* pin 2, nlq lamp output */
|
||||
devcb_resolved_write_line out_pe_lp_func; /* pin 3, paper empty lamp output */
|
||||
devcb_resolved_write_line out_reso_func; /* pin 25, reset output */
|
||||
devcb_resolved_write_line out_pe_func; /* pin 35, centronics pe output */
|
||||
devcb_resolved_read8 in_data_func; /* pin 47-54, centronics data input */
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
INLINE FUNCTIONS
|
||||
*****************************************************************************/
|
||||
|
||||
INLINE e05a03_state *get_safe_token(device_t *device)
|
||||
{
|
||||
assert(device != NULL);
|
||||
assert(device->type() == E05A03);
|
||||
|
||||
return (e05a03_state *)downcast<e05a03_device *>(device)->token();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
DEVICE INTERFACE
|
||||
*****************************************************************************/
|
||||
|
||||
static DEVICE_START( e05a03 )
|
||||
const device_type E05A03 = &device_creator<e05a03_device>;
|
||||
|
||||
e05a03_device::e05a03_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, E05A03, "E05A03", tag, owner, clock, "e05a03", __FILE__),
|
||||
m_shift(0),
|
||||
m_busy_leading(0),
|
||||
m_busy_software(0),
|
||||
m_nlqlp(0),
|
||||
m_cndlp(0),
|
||||
#if 0
|
||||
m_pe(0),
|
||||
m_pelp(0),
|
||||
#endif
|
||||
m_printhead(0),
|
||||
m_pf_motor(0),
|
||||
m_cr_motor(0)
|
||||
{
|
||||
e05a03_state *e05a03 = get_safe_token(device);
|
||||
const e05a03_interface *intf = (const e05a03_interface *)device->static_config();
|
||||
|
||||
}
|
||||
|
||||
/* validate some basic stuff */
|
||||
assert(device->static_config() != NULL);
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void e05a03_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const e05a03_interface *intf = reinterpret_cast<const e05a03_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<e05a03_interface *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_in_data_cb, 0 , sizeof(m_in_data_cb));
|
||||
memset(&m_out_nlq_lp_cb, 0 , sizeof(m_out_nlq_lp_cb));
|
||||
memset(&m_out_pe_lp_cb, 0 , sizeof(m_out_pe_lp_cb));
|
||||
memset(&m_out_pe_cb, 0 , sizeof(m_out_pe_cb));
|
||||
memset(&m_out_reso_cb, 0 , sizeof(m_out_reso_cb));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void e05a03_device::device_start()
|
||||
{
|
||||
/* resolve callbacks */
|
||||
e05a03->out_nlq_lp_func.resolve(intf->out_nlq_lp_func, *device);
|
||||
e05a03->out_pe_lp_func.resolve(intf->out_pe_lp_func, *device);
|
||||
e05a03->out_reso_func.resolve(intf->out_reso_func, *device);
|
||||
e05a03->out_pe_func.resolve(intf->out_pe_func, *device);
|
||||
e05a03->in_data_func.resolve(intf->in_data_func, *device);
|
||||
m_out_nlq_lp_func.resolve(m_out_nlq_lp_cb, *this);
|
||||
m_out_pe_lp_func.resolve(m_out_pe_lp_cb, *this);
|
||||
m_out_reso_func.resolve(m_out_reso_cb, *this);
|
||||
m_out_pe_func.resolve(m_out_pe_cb, *this);
|
||||
m_in_data_func.resolve(m_in_data_cb, *this);
|
||||
|
||||
/* register for state saving */
|
||||
device->save_item(NAME(e05a03->shift));
|
||||
device->save_item(NAME(e05a03->busy_leading));
|
||||
device->save_item(NAME(e05a03->busy_software));
|
||||
device->save_item(NAME(e05a03->nlqlp));
|
||||
device->save_item(NAME(e05a03->cndlp));
|
||||
#if 0
|
||||
device->save_item(NAME(e05a03->pe));
|
||||
device->save_item(NAME(e05a03->pelp));
|
||||
#endif
|
||||
device->save_item(NAME(e05a03->printhead));
|
||||
device->save_item(NAME(e05a03->pf_motor));
|
||||
device->save_item(NAME(e05a03->cr_motor));
|
||||
save_item(NAME(m_shift));
|
||||
save_item(NAME(m_busy_leading));
|
||||
save_item(NAME(m_busy_software));
|
||||
save_item(NAME(m_nlqlp));
|
||||
save_item(NAME(m_cndlp));
|
||||
#if 0
|
||||
save_item(NAME(m_pe));
|
||||
save_item(NAME(m_pelp));
|
||||
#endif
|
||||
save_item(NAME(m_printhead));
|
||||
save_item(NAME(m_pf_motor));
|
||||
save_item(NAME(m_cr_motor));
|
||||
}
|
||||
|
||||
static DEVICE_RESET( e05a03 )
|
||||
//-------------------------------------------------
|
||||
// device_reset - device-specific reset
|
||||
//-------------------------------------------------
|
||||
|
||||
void e05a03_device::device_reset()
|
||||
{
|
||||
e05a03_state *e05a03 = get_safe_token(device);
|
||||
m_printhead = 0x00;
|
||||
m_pf_motor = 0x00;
|
||||
m_cr_motor = 0x0f;
|
||||
|
||||
e05a03->printhead = 0x00;
|
||||
e05a03->pf_motor = 0x00;
|
||||
e05a03->cr_motor = 0x0f;
|
||||
m_out_pe_func(0);
|
||||
m_out_pe_lp_func(1);
|
||||
|
||||
e05a03->out_pe_func(0);
|
||||
e05a03->out_pe_lp_func(1);
|
||||
|
||||
e05a03->busy_software = 1;
|
||||
e05a03->nlqlp = 1;
|
||||
e05a03->cndlp = 1;
|
||||
m_busy_software = 1;
|
||||
m_nlqlp = 1;
|
||||
m_cndlp = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
IMPLEMENTATION
|
||||
***************************************************************************/
|
||||
|
||||
WRITE8_DEVICE_HANDLER( e05a03_w )
|
||||
WRITE8_MEMBER( e05a03_device::write )
|
||||
{
|
||||
e05a03_state *e05a03 = get_safe_token(device);
|
||||
|
||||
logerror("%s: e05a03_w(%02x): %02x\n", space.machine().describe_context(), offset, data);
|
||||
|
||||
switch (offset)
|
||||
{
|
||||
/* shift register */
|
||||
case 0x00: e05a03->shift = (e05a03->shift & 0x00ffff) | (data << 16); break;
|
||||
case 0x01: e05a03->shift = (e05a03->shift & 0xff00ff) | (data << 8); break;
|
||||
case 0x02: e05a03->shift = (e05a03->shift & 0xffff00) | (data << 0); break;
|
||||
case 0x00: m_shift = (m_shift & 0x00ffff) | (data << 16); break;
|
||||
case 0x01: m_shift = (m_shift & 0xff00ff) | (data << 8); break;
|
||||
case 0x02: m_shift = (m_shift & 0xffff00) | (data << 0); break;
|
||||
|
||||
case 0x03:
|
||||
e05a03->busy_leading = BIT(data, 7);
|
||||
e05a03->busy_software = BIT(data, 6);
|
||||
e05a03->nlqlp = BIT(data, 4);
|
||||
e05a03->cndlp = BIT(data, 3);
|
||||
m_busy_leading = BIT(data, 7);
|
||||
m_busy_software = BIT(data, 6);
|
||||
m_nlqlp = BIT(data, 4);
|
||||
m_cndlp = BIT(data, 3);
|
||||
|
||||
e05a03->out_pe_func(BIT(data, 2));
|
||||
e05a03->out_pe_lp_func(!BIT(data, 2));
|
||||
m_out_pe_func(BIT(data, 2));
|
||||
m_out_pe_lp_func(!BIT(data, 2));
|
||||
|
||||
#if 0
|
||||
e05a03->pe = BIT(data, 2);
|
||||
e05a03->pelp = !BIT(data, 2);
|
||||
m_pe = BIT(data, 2);
|
||||
m_pelp = !BIT(data, 2);
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
/* printhead */
|
||||
case 0x04: e05a03->printhead = (e05a03->printhead & 0x100) | !data; break;
|
||||
case 0x05: e05a03->printhead = (e05a03->printhead & 0x0ff) | (!(BIT(data, 7) << 8)); break;
|
||||
case 0x04: m_printhead = (m_printhead & 0x100) | !data; break;
|
||||
case 0x05: m_printhead = (m_printhead & 0x0ff) | (!(BIT(data, 7) << 8)); break;
|
||||
|
||||
/* paper feed and carriage motor phase data*/
|
||||
case 0x06: e05a03->pf_motor = (data & 0xf0) >> 4; break;
|
||||
case 0x07: e05a03->cr_motor = (data & 0x0f) >> 0; break;
|
||||
case 0x06: m_pf_motor = (data & 0xf0) >> 4; break;
|
||||
case 0x07: m_cr_motor = (data & 0x0f) >> 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
READ8_DEVICE_HANDLER( e05a03_r )
|
||||
READ8_MEMBER( e05a03_device::read )
|
||||
{
|
||||
e05a03_state *e05a03 = get_safe_token(device);
|
||||
UINT8 result = 0;
|
||||
|
||||
logerror("%s: e05a03_r(%02x)\n", space.machine().describe_context(), offset);
|
||||
@ -169,12 +160,12 @@ READ8_DEVICE_HANDLER( e05a03_r )
|
||||
break;
|
||||
|
||||
case 0x02:
|
||||
result = e05a03->in_data_func(0);
|
||||
result = m_in_data_func(0);
|
||||
break;
|
||||
|
||||
case 0x03:
|
||||
result |= BIT(e05a03->shift, 23) << 7;
|
||||
e05a03->shift <<= 1;
|
||||
result |= BIT(m_shift, 23) << 7;
|
||||
m_shift <<= 1;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -182,72 +173,34 @@ READ8_DEVICE_HANDLER( e05a03_r )
|
||||
}
|
||||
|
||||
/* home position signal */
|
||||
WRITE_LINE_DEVICE_HANDLER( e05a03_home_w )
|
||||
WRITE_LINE_MEMBER( e05a03_device::home_w )
|
||||
{
|
||||
}
|
||||
|
||||
/* printhead solenoids trigger */
|
||||
WRITE_LINE_DEVICE_HANDLER( e05a03_fire_w )
|
||||
WRITE_LINE_MEMBER( e05a03_device::fire_w )
|
||||
{
|
||||
}
|
||||
|
||||
WRITE_LINE_DEVICE_HANDLER( e05a03_strobe_w )
|
||||
WRITE_LINE_MEMBER( e05a03_device::strobe_w )
|
||||
{
|
||||
}
|
||||
|
||||
READ_LINE_DEVICE_HANDLER( e05a03_busy_r )
|
||||
READ_LINE_MEMBER( e05a03_device::busy_r )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
WRITE_LINE_DEVICE_HANDLER( e05a03_resi_w )
|
||||
WRITE_LINE_MEMBER( e05a03_device::resi_w )
|
||||
{
|
||||
e05a03_state *e05a03 = get_safe_token(device);
|
||||
|
||||
if (!state)
|
||||
{
|
||||
DEVICE_RESET_CALL( e05a03 );
|
||||
e05a03->out_reso_func(1);
|
||||
device_reset();
|
||||
m_out_reso_func(1);
|
||||
}
|
||||
}
|
||||
|
||||
WRITE_LINE_DEVICE_HANDLER( e05a03_init_w )
|
||||
WRITE_LINE_MEMBER( e05a03_device::init_w )
|
||||
{
|
||||
e05a03_resi_w(device, state);
|
||||
}
|
||||
|
||||
const device_type E05A03 = &device_creator<e05a03_device>;
|
||||
|
||||
e05a03_device::e05a03_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, E05A03, "E05A03", tag, owner, clock, "e05a03", __FILE__)
|
||||
{
|
||||
m_token = global_alloc_clear(e05a03_state);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void e05a03_device::device_config_complete()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void e05a03_device::device_start()
|
||||
{
|
||||
DEVICE_START_NAME( e05a03 )(this);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_reset - device-specific reset
|
||||
//-------------------------------------------------
|
||||
|
||||
void e05a03_device::device_reset()
|
||||
{
|
||||
DEVICE_RESET_NAME( e05a03 )(this);
|
||||
resi_w(state);
|
||||
}
|
||||
|
@ -14,49 +14,74 @@
|
||||
|
||||
struct e05a03_interface
|
||||
{
|
||||
devcb_read8 in_data_func;
|
||||
devcb_read8 m_in_data_cb;
|
||||
|
||||
devcb_write_line out_nlq_lp_func;
|
||||
devcb_write_line out_pe_lp_func;
|
||||
devcb_write_line out_pe_func;
|
||||
devcb_write_line out_reso_func;
|
||||
devcb_write_line m_out_nlq_lp_cb;
|
||||
devcb_write_line m_out_pe_lp_cb;
|
||||
devcb_write_line m_out_pe_cb;
|
||||
devcb_write_line m_out_reso_cb;
|
||||
};
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
FUNCTION PROTOTYPES
|
||||
***************************************************************************/
|
||||
DECLARE_WRITE8_DEVICE_HANDLER( e05a03_w );
|
||||
DECLARE_READ8_DEVICE_HANDLER( e05a03_r );
|
||||
|
||||
WRITE_LINE_DEVICE_HANDLER( e05a03_home_w ); /* home position signal */
|
||||
WRITE_LINE_DEVICE_HANDLER( e05a03_fire_w ); /* printhead solenoids trigger */
|
||||
WRITE_LINE_DEVICE_HANDLER( e05a03_strobe_w );
|
||||
READ_LINE_DEVICE_HANDLER( e05a03_busy_r );
|
||||
WRITE_LINE_DEVICE_HANDLER( e05a03_resi_w ); /* reset input */
|
||||
WRITE_LINE_DEVICE_HANDLER( e05a03_init_w ); /* centronics init */
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
DEVICE CONFIGURATION MACROS
|
||||
***************************************************************************/
|
||||
|
||||
class e05a03_device : public device_t
|
||||
class e05a03_device : public device_t,
|
||||
public e05a03_interface
|
||||
{
|
||||
public:
|
||||
e05a03_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
~e05a03_device() { global_free(m_token); }
|
||||
~e05a03_device() {}
|
||||
|
||||
DECLARE_WRITE8_MEMBER( write );
|
||||
DECLARE_READ8_MEMBER( read );
|
||||
|
||||
WRITE_LINE_MEMBER( home_w ); /* home position signal */
|
||||
WRITE_LINE_MEMBER( fire_w ); /* printhead solenoids trigger */
|
||||
WRITE_LINE_MEMBER( strobe_w );
|
||||
READ_LINE_MEMBER( busy_r );
|
||||
WRITE_LINE_MEMBER( resi_w ); /* reset input */
|
||||
WRITE_LINE_MEMBER( init_w ); /* centronics init */
|
||||
|
||||
// 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;
|
||||
|
||||
/* 24-bit shift register, port 0x00, 0x01 and 0x02 */
|
||||
UINT32 m_shift;
|
||||
|
||||
/* port 0x03 */
|
||||
int m_busy_leading;
|
||||
int m_busy_software;
|
||||
int m_nlqlp;
|
||||
int m_cndlp;
|
||||
|
||||
#if 0
|
||||
int m_pe;
|
||||
int m_pelp;
|
||||
#endif
|
||||
|
||||
/* port 0x04 and 0x05 (9-bit) */
|
||||
UINT16 m_printhead;
|
||||
|
||||
/* port 0x06 (4-bit) */
|
||||
UINT8 m_pf_motor;
|
||||
|
||||
/* port 0x07 (4-bit) */
|
||||
UINT8 m_cr_motor;
|
||||
|
||||
/* callbacks */
|
||||
devcb_resolved_write_line m_out_nlq_lp_func; /* pin 2, nlq lamp output */
|
||||
devcb_resolved_write_line m_out_pe_lp_func; /* pin 3, paper empty lamp output */
|
||||
devcb_resolved_write_line m_out_reso_func; /* pin 25, reset output */
|
||||
devcb_resolved_write_line m_out_pe_func; /* pin 35, centronics pe output */
|
||||
devcb_resolved_read8 m_in_data_func; /* pin 47-54, centronics data input */
|
||||
};
|
||||
|
||||
extern const device_type E05A03;
|
||||
|
Loading…
Reference in New Issue
Block a user