Previous 199869 Revisions Next

r19785 Monday 24th December, 2012 at 23:31:24 UTC by Robbbert
(MESS) Pencil2 : added printer [Robbbert]
[src/mess/drivers]pencil2.c

trunk/src/mess/drivers/pencil2.c
r19784r19785
7676#include "cpu/z80/z80.h"
7777#include "video/tms9928a.h"
7878#include "sound/sn76496.h"
79#include "machine/ctronics.h"
7980//#include "imagedev/cartslot.h"
8081//#include "imagedev/cassette.h"
8182//#include "sound/wave.h"
r19784r19785
8687public:
8788   pencil2_state(const machine_config &mconfig, device_type type, const char *tag)
8889      : driver_device(mconfig, type, tag),
89   m_maincpu(*this, "maincpu")
90   m_maincpu(*this, "maincpu"),
91   m_printer(*this, "centronics")
9092   { }
9193
92   required_device<cpu_device> m_maincpu;
94   DECLARE_WRITE8_MEMBER(port10_w);
9395   DECLARE_WRITE8_MEMBER(port80_w);
96   DECLARE_WRITE8_MEMBER(portc0_w);
9497   DECLARE_READ8_MEMBER(porte0_r);
98   DECLARE_CUSTOM_INPUT_MEMBER(printer_ready_r);
99   DECLARE_CUSTOM_INPUT_MEMBER(printer_ack_r);
95100   virtual void machine_reset();
101   required_device<cpu_device> m_maincpu;
102   required_device<centronics_device> m_printer;
96103};
97104
98105static ADDRESS_MAP_START(pencil2_mem, AS_PROGRAM, 8, pencil2_state)
r19784r19785
106113static ADDRESS_MAP_START(pencil2_io, AS_IO, 8, pencil2_state)
107114   ADDRESS_MAP_UNMAP_HIGH
108115   ADDRESS_MAP_GLOBAL_MASK(0xff)
116   AM_RANGE(0x00, 0x0f) AM_DEVWRITE("centronics", centronics_device, write)
117   AM_RANGE(0x10, 0x1f) AM_WRITE(port10_w)
118   //AM_RANGE(0x30, 0x3f) AM_WRITE(port30_w) cass out
109119   AM_RANGE(0x80, 0x9f) AM_WRITE(port80_w)
110120   AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x1e) AM_DEVREADWRITE("tms9928a", tms9928a_device, vram_read, vram_write)
111121   AM_RANGE(0xa1, 0xa1) AM_MIRROR(0x1e) AM_DEVREADWRITE("tms9928a", tms9928a_device, register_read, register_write)
122   AM_RANGE(0xc0, 0xdf) AM_WRITE(portc0_w)
112123   AM_RANGE(0xe0, 0xff) AM_READ(porte0_r) AM_DEVWRITE("sn76489a", sn76489a_device, write)
113124ADDRESS_MAP_END
114125
r19784r19785
119130   return ioport( kbdrow )->read();
120131}
121132
133WRITE8_MEMBER( pencil2_state::port10_w )
134{
135   m_printer->strobe_w(BIT(data, 0));
136}
137
122138WRITE8_MEMBER( pencil2_state::port80_w )
123139{
124140}
125141
142WRITE8_MEMBER( pencil2_state::portc0_w )
143{
144}
126145
146CUSTOM_INPUT_MEMBER( pencil2_state::printer_ready_r )
147{
148   return m_printer->busy_r();
149}
150
151CUSTOM_INPUT_MEMBER( pencil2_state::printer_ack_r )
152{
153   return m_printer->ack_r();
154}
155
156
127157/* Input ports */
128158static INPUT_PORTS_START( pencil2 )
129159   PORT_START("X0")
160   // port_custom MUST be ACTIVE_HIGH to work
130161   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP)
131162   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT)
132163   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN)
133164   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT)
134   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7_PAD)
165   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, pencil2_state, printer_ready_r, " ")
135166   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD)
136167   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Stop") PORT_CODE(KEYCODE_END)
137   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
168   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, pencil2_state, printer_ack_r, " ")
138169
139170   PORT_START("X1")
140171   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J')
r19784r19785
262293//   MCFG_CARTSLOT_NOT_MANDATORY
263294//   MCFG_CARTSLOT_LOAD(pencil2_cart)
264295//   MCFG_CARTSLOT_INTERFACE("pencil2_cart")
296
297   /* printer */
298   MCFG_CENTRONICS_PRINTER_ADD("centronics", standard_centronics)
265299MACHINE_CONFIG_END
266300
267301/* ROM definition */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team