trunk/src/mess/drivers/pencil2.c
| r19784 | r19785 | |
| 76 | 76 | #include "cpu/z80/z80.h" |
| 77 | 77 | #include "video/tms9928a.h" |
| 78 | 78 | #include "sound/sn76496.h" |
| 79 | #include "machine/ctronics.h" |
| 79 | 80 | //#include "imagedev/cartslot.h" |
| 80 | 81 | //#include "imagedev/cassette.h" |
| 81 | 82 | //#include "sound/wave.h" |
| r19784 | r19785 | |
| 86 | 87 | public: |
| 87 | 88 | pencil2_state(const machine_config &mconfig, device_type type, const char *tag) |
| 88 | 89 | : driver_device(mconfig, type, tag), |
| 89 | | m_maincpu(*this, "maincpu") |
| 90 | m_maincpu(*this, "maincpu"), |
| 91 | m_printer(*this, "centronics") |
| 90 | 92 | { } |
| 91 | 93 | |
| 92 | | required_device<cpu_device> m_maincpu; |
| 94 | DECLARE_WRITE8_MEMBER(port10_w); |
| 93 | 95 | DECLARE_WRITE8_MEMBER(port80_w); |
| 96 | DECLARE_WRITE8_MEMBER(portc0_w); |
| 94 | 97 | DECLARE_READ8_MEMBER(porte0_r); |
| 98 | DECLARE_CUSTOM_INPUT_MEMBER(printer_ready_r); |
| 99 | DECLARE_CUSTOM_INPUT_MEMBER(printer_ack_r); |
| 95 | 100 | virtual void machine_reset(); |
| 101 | required_device<cpu_device> m_maincpu; |
| 102 | required_device<centronics_device> m_printer; |
| 96 | 103 | }; |
| 97 | 104 | |
| 98 | 105 | static ADDRESS_MAP_START(pencil2_mem, AS_PROGRAM, 8, pencil2_state) |
| r19784 | r19785 | |
| 106 | 113 | static ADDRESS_MAP_START(pencil2_io, AS_IO, 8, pencil2_state) |
| 107 | 114 | ADDRESS_MAP_UNMAP_HIGH |
| 108 | 115 | 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 |
| 109 | 119 | AM_RANGE(0x80, 0x9f) AM_WRITE(port80_w) |
| 110 | 120 | AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x1e) AM_DEVREADWRITE("tms9928a", tms9928a_device, vram_read, vram_write) |
| 111 | 121 | 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) |
| 112 | 123 | AM_RANGE(0xe0, 0xff) AM_READ(porte0_r) AM_DEVWRITE("sn76489a", sn76489a_device, write) |
| 113 | 124 | ADDRESS_MAP_END |
| 114 | 125 | |
| r19784 | r19785 | |
| 119 | 130 | return ioport( kbdrow )->read(); |
| 120 | 131 | } |
| 121 | 132 | |
| 133 | WRITE8_MEMBER( pencil2_state::port10_w ) |
| 134 | { |
| 135 | m_printer->strobe_w(BIT(data, 0)); |
| 136 | } |
| 137 | |
| 122 | 138 | WRITE8_MEMBER( pencil2_state::port80_w ) |
| 123 | 139 | { |
| 124 | 140 | } |
| 125 | 141 | |
| 142 | WRITE8_MEMBER( pencil2_state::portc0_w ) |
| 143 | { |
| 144 | } |
| 126 | 145 | |
| 146 | CUSTOM_INPUT_MEMBER( pencil2_state::printer_ready_r ) |
| 147 | { |
| 148 | return m_printer->busy_r(); |
| 149 | } |
| 150 | |
| 151 | CUSTOM_INPUT_MEMBER( pencil2_state::printer_ack_r ) |
| 152 | { |
| 153 | return m_printer->ack_r(); |
| 154 | } |
| 155 | |
| 156 | |
| 127 | 157 | /* Input ports */ |
| 128 | 158 | static INPUT_PORTS_START( pencil2 ) |
| 129 | 159 | PORT_START("X0") |
| 160 | // port_custom MUST be ACTIVE_HIGH to work |
| 130 | 161 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP) |
| 131 | 162 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT) |
| 132 | 163 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) |
| 133 | 164 | 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, " ") |
| 135 | 166 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) |
| 136 | 167 | 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, " ") |
| 138 | 169 | |
| 139 | 170 | PORT_START("X1") |
| 140 | 171 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J') |
| r19784 | r19785 | |
| 262 | 293 | // MCFG_CARTSLOT_NOT_MANDATORY |
| 263 | 294 | // MCFG_CARTSLOT_LOAD(pencil2_cart) |
| 264 | 295 | // MCFG_CARTSLOT_INTERFACE("pencil2_cart") |
| 296 | |
| 297 | /* printer */ |
| 298 | MCFG_CENTRONICS_PRINTER_ADD("centronics", standard_centronics) |
| 265 | 299 | MACHINE_CONFIG_END |
| 266 | 300 | |
| 267 | 301 | /* ROM definition */ |