trunk/src/mess/drivers/px4.c
r241679 | r241680 | |
19 | 19 | #include "machine/ram.h" |
20 | 20 | #include "machine/nvram.h" |
21 | 21 | #include "sound/speaker.h" |
22 | | |
23 | 22 | #include "bus/generic/slot.h" |
24 | 23 | #include "bus/generic/carts.h" |
25 | 24 | #include "px4.lh" |
r241679 | r241680 | |
31 | 30 | |
32 | 31 | #define VERBOSE 1 |
33 | 32 | |
34 | | // interrupt sources |
35 | | #define INT0_7508 0x01 |
36 | | #define INT1_ART 0x02 |
37 | | #define INT2_ICF 0x04 |
38 | | #define INT3_OVF 0x08 |
39 | | #define INT4_EXT 0x10 |
40 | 33 | |
41 | | // 7508 interrupt sources |
42 | | #define UPD7508_INT_ALARM 0x02 |
43 | | #define UPD7508_INT_POWER_FAIL 0x04 |
44 | | #define UPD7508_INT_7508_RESET 0x08 |
45 | | #define UPD7508_INT_Z80_RESET 0x10 |
46 | | #define UPD7508_INT_ONE_SECOND 0x20 |
47 | | |
48 | | // art (asynchronous receiver transmitter) |
49 | | #define ART_TXRDY 0x01 // output buffer empty |
50 | | #define ART_RXRDY 0x02 // data byte received |
51 | | #define ART_TXEMPTY 0x04 // transmit buffer empty |
52 | | #define ART_PE 0x08 // parity error |
53 | | #define ART_OE 0x10 // overrun error |
54 | | #define ART_FE 0x20 // framing error |
55 | | |
56 | | |
57 | 34 | //************************************************************************** |
58 | 35 | // MACROS |
59 | 36 | //************************************************************************** |
r241679 | r241680 | |
67 | 44 | // TYPE DEFINITIONS |
68 | 45 | //************************************************************************** |
69 | 46 | |
70 | | class px4_state : public driver_device, |
71 | | public device_serial_interface |
| 47 | class px4_state : public driver_device, public device_serial_interface |
72 | 48 | { |
73 | 49 | public: |
74 | 50 | px4_state(const machine_config &mconfig, device_type type, const char *tag) : |
r241679 | r241680 | |
82 | 58 | m_speaker(*this, "speaker"), |
83 | 59 | m_sio(*this, "sio"), |
84 | 60 | m_rs232(*this, "rs232"), |
85 | | m_caps1(*this, "capsule1"), |
86 | | m_caps2(*this, "capsule2"), |
87 | | m_rdsocket(*this, "ramdisk_socket"), |
| 61 | m_caps1(*this, "capsule1"), m_caps2(*this, "capsule2"), |
| 62 | m_caps1_rom(NULL), m_caps2_rom(NULL), |
| 63 | m_ctrl1(0), m_icrb(0), m_bankr(0), |
88 | 64 | m_isr(0), m_ier(0), m_str(0), m_sior(0xbf), |
| 65 | m_frc_value(0), m_frc_latch(0), |
| 66 | m_vadr(0), m_yoff(0), |
| 67 | m_receive_timer(NULL), m_transmit_timer(NULL), |
89 | 68 | m_artdir(0xff), m_artdor(0xff), m_artsr(0), m_artcr(0), |
90 | 69 | m_swr(0), |
91 | 70 | m_one_sec_int_enabled(true), m_alarm_int_enabled(true), m_key_int_enabled(true), |
92 | | m_ramdisk_address(0), |
93 | | m_ear_last_state(0) |
| 71 | m_key_status(0), m_interrupt_status(0), |
| 72 | m_ear_last_state(0), |
| 73 | m_sio_pin(0), m_serial_rx(0), m_rs232_dcd(0), m_rs232_cts(0), |
| 74 | m_centronics_busy(0), m_centronics_perror(0) |
94 | 75 | { } |
95 | 76 | |
| 77 | DECLARE_DRIVER_INIT( px4 ); |
| 78 | |
| 79 | DECLARE_PALETTE_INIT( px4 ); |
| 80 | UINT32 screen_update_px4(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 81 | |
| 82 | DECLARE_READ8_MEMBER( icrlc_r ); |
| 83 | DECLARE_WRITE8_MEMBER( ctrl1_w ); |
| 84 | DECLARE_READ8_MEMBER( icrhc_r ); |
| 85 | DECLARE_WRITE8_MEMBER( cmdr_w ); |
| 86 | DECLARE_READ8_MEMBER( icrlb_r ); |
| 87 | DECLARE_WRITE8_MEMBER( ctrl2_w ); |
| 88 | DECLARE_READ8_MEMBER( icrhb_r ); |
| 89 | DECLARE_READ8_MEMBER( isr_r ); |
| 90 | DECLARE_WRITE8_MEMBER( ier_w ); |
| 91 | DECLARE_READ8_MEMBER( str_r ); |
| 92 | DECLARE_WRITE8_MEMBER( bankr_w ); |
| 93 | DECLARE_READ8_MEMBER( sior_r ); |
| 94 | DECLARE_WRITE8_MEMBER( sior_w ); |
| 95 | DECLARE_WRITE8_MEMBER( vadr_w ); |
| 96 | DECLARE_WRITE8_MEMBER( yoff_w ); |
| 97 | DECLARE_WRITE8_MEMBER( fr_w ); |
| 98 | DECLARE_WRITE8_MEMBER( spur_w ); |
| 99 | DECLARE_READ8_MEMBER( ctgif_r ); |
| 100 | DECLARE_WRITE8_MEMBER( ctgif_w ); |
| 101 | DECLARE_READ8_MEMBER( artdir_r ); |
| 102 | DECLARE_WRITE8_MEMBER( artdor_w ); |
| 103 | DECLARE_READ8_MEMBER( artsr_r ); |
| 104 | DECLARE_WRITE8_MEMBER( artmr_w ); |
| 105 | DECLARE_READ8_MEMBER( iostr_r ); |
| 106 | DECLARE_WRITE8_MEMBER( artcr_w ); |
| 107 | DECLARE_WRITE8_MEMBER( swr_w ); |
| 108 | DECLARE_WRITE8_MEMBER( ioctlr_w ); |
| 109 | |
| 110 | DECLARE_INPUT_CHANGED_MEMBER( key_callback ); |
| 111 | |
| 112 | TIMER_DEVICE_CALLBACK_MEMBER( ext_cassette_read ); |
| 113 | TIMER_DEVICE_CALLBACK_MEMBER( frc_tick ); |
| 114 | TIMER_DEVICE_CALLBACK_MEMBER( upd7508_1sec_callback ); |
| 115 | |
| 116 | // serial |
| 117 | DECLARE_WRITE_LINE_MEMBER( sio_rx_w ); |
| 118 | DECLARE_WRITE_LINE_MEMBER( sio_pin_w ); |
| 119 | DECLARE_WRITE_LINE_MEMBER( rs232_rx_w ); |
| 120 | DECLARE_WRITE_LINE_MEMBER( rs232_dcd_w ); |
| 121 | DECLARE_WRITE_LINE_MEMBER( rs232_dsr_w ); |
| 122 | DECLARE_WRITE_LINE_MEMBER( rs232_cts_w ); |
| 123 | TIMER_CALLBACK_MEMBER( transmit_data ); |
| 124 | TIMER_CALLBACK_MEMBER( receive_data ); |
| 125 | |
| 126 | // centronics |
| 127 | DECLARE_WRITE_LINE_MEMBER( centronics_busy_w ) { m_centronics_busy = state; } |
| 128 | DECLARE_WRITE_LINE_MEMBER( centronics_perror_w ) { m_centronics_perror = state; } |
| 129 | |
| 130 | protected: |
| 131 | // driver_device overrides |
| 132 | virtual void machine_start(); |
| 133 | virtual void machine_reset(); |
| 134 | |
| 135 | // device_serial_interface overrides |
| 136 | virtual void tra_callback(); |
| 137 | virtual void tra_complete(); |
| 138 | virtual void rcv_callback(); |
| 139 | virtual void rcv_complete(); |
| 140 | |
| 141 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 142 | |
| 143 | private: |
| 144 | // z80 interrupt sources |
| 145 | enum |
| 146 | { |
| 147 | INT0_7508 = 0x01, |
| 148 | INT1_ART = 0x02, |
| 149 | INT2_ICF = 0x04, |
| 150 | INT3_OVF = 0x08, |
| 151 | INT4_EXT = 0x10 |
| 152 | }; |
| 153 | |
| 154 | // 7508 interrupt sources |
| 155 | enum |
| 156 | { |
| 157 | UPD7508_INT_ALARM = 0x02, |
| 158 | UPD7508_INT_POWER_FAIL = 0x04, |
| 159 | UPD7508_INT_7508_RESET = 0x08, |
| 160 | UPD7508_INT_Z80_RESET = 0x10, |
| 161 | UPD7508_INT_ONE_SECOND = 0x20 |
| 162 | }; |
| 163 | |
| 164 | // art (asynchronous receiver transmitter) |
| 165 | enum |
| 166 | { |
| 167 | ART_TXRDY = 0x01, // output buffer empty |
| 168 | ART_RXRDY = 0x02, // data byte received |
| 169 | ART_TXEMPTY = 0x04, // transmit buffer empty |
| 170 | ART_PE = 0x08, // parity error |
| 171 | ART_OE = 0x10, // overrun error |
| 172 | ART_FE = 0x20 // framing error |
| 173 | }; |
| 174 | |
| 175 | void gapnit_interrupt(); |
| 176 | |
| 177 | DECLARE_WRITE_LINE_MEMBER( serial_rx_w ); |
| 178 | void txd_w(int data); |
| 179 | |
| 180 | void install_rom_capsule(address_space &space, int size, memory_region *mem); |
| 181 | |
96 | 182 | // internal devices |
97 | 183 | required_device<cpu_device> m_z80; |
98 | 184 | required_device<ram_device> m_ram; |
r241679 | r241680 | |
104 | 190 | required_device<rs232_port_device> m_rs232; |
105 | 191 | required_device<generic_slot_device> m_caps1; |
106 | 192 | required_device<generic_slot_device> m_caps2; |
107 | | optional_device<generic_slot_device> m_rdsocket; |
108 | 193 | |
109 | 194 | memory_region *m_caps1_rom; |
110 | 195 | memory_region *m_caps2_rom; |
r241679 | r241680 | |
126 | 211 | UINT8 m_vadr; |
127 | 212 | UINT8 m_yoff; |
128 | 213 | |
129 | | void gapnit_interrupt(); |
130 | | |
131 | 214 | // gapnio |
132 | 215 | emu_timer *m_receive_timer; |
133 | 216 | emu_timer *m_transmit_timer; |
r241679 | r241680 | |
137 | 220 | UINT8 m_artcr; |
138 | 221 | UINT8 m_swr; |
139 | 222 | |
140 | | void txd_w(int data); |
141 | | |
142 | 223 | // 7508 internal |
143 | 224 | bool m_one_sec_int_enabled; |
144 | 225 | bool m_alarm_int_enabled; |
r241679 | r241680 | |
147 | 228 | UINT8 m_key_status; |
148 | 229 | UINT8 m_interrupt_status; |
149 | 230 | |
150 | | // external ramdisk |
151 | | offs_t m_ramdisk_address; |
152 | | UINT8 *m_ramdisk; |
153 | | |
154 | 231 | // external cassette/barcode reader |
155 | 232 | int m_ear_last_state; |
156 | 233 | |
157 | | void install_rom_capsule(address_space &space, int size, memory_region *mem); |
| 234 | // serial |
| 235 | int m_sio_pin; |
| 236 | int m_serial_rx; |
| 237 | int m_rs232_dcd; |
| 238 | int m_rs232_cts; |
158 | 239 | |
159 | | // device_serial_interface overrides |
160 | | virtual void tra_callback(); |
161 | | virtual void tra_complete(); |
162 | | virtual void rcv_callback(); |
163 | | virtual void rcv_complete(); |
| 240 | // centronics |
| 241 | int m_centronics_busy; |
| 242 | int m_centronics_perror; |
| 243 | }; |
164 | 244 | |
165 | | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 245 | class px4p_state : public px4_state |
| 246 | { |
| 247 | public: |
| 248 | px4p_state(const machine_config &mconfig, device_type type, const char *tag) : |
| 249 | px4_state(mconfig, type, tag), |
| 250 | m_rdnvram(*this, "rdnvram"), |
| 251 | m_rdsocket(*this, "ramdisk_socket"), |
| 252 | m_ramdisk_address(0), |
| 253 | m_ramdisk(NULL) |
| 254 | { } |
166 | 255 | |
167 | | DECLARE_WRITE_LINE_MEMBER( sio_rx_w ); |
168 | | DECLARE_WRITE_LINE_MEMBER( sio_pin_w ); |
| 256 | DECLARE_DRIVER_INIT( px4p ); |
169 | 257 | |
170 | | DECLARE_WRITE_LINE_MEMBER( rs232_rx_w ); |
171 | | DECLARE_WRITE_LINE_MEMBER( rs232_dcd_w ); |
172 | | DECLARE_WRITE_LINE_MEMBER( rs232_dsr_w ); |
173 | | DECLARE_WRITE_LINE_MEMBER( rs232_cts_w ); |
| 258 | DECLARE_PALETTE_INIT( px4p ); |
174 | 259 | |
175 | | int m_sio_pin; |
| 260 | DECLARE_WRITE8_MEMBER( ramdisk_address_w ); |
| 261 | DECLARE_READ8_MEMBER( ramdisk_data_r ); |
| 262 | DECLARE_WRITE8_MEMBER( ramdisk_data_w ); |
| 263 | DECLARE_READ8_MEMBER( ramdisk_control_r ); |
176 | 264 | |
177 | | int m_serial_rx; |
178 | | int m_rs232_dcd; |
179 | | int m_rs232_cts; |
180 | | |
181 | | DECLARE_READ8_MEMBER(px4_icrlc_r); |
182 | | DECLARE_WRITE8_MEMBER(px4_ctrl1_w); |
183 | | DECLARE_READ8_MEMBER(px4_icrhc_r); |
184 | | DECLARE_WRITE8_MEMBER(px4_cmdr_w); |
185 | | DECLARE_READ8_MEMBER(px4_icrlb_r); |
186 | | DECLARE_WRITE8_MEMBER(px4_ctrl2_w); |
187 | | DECLARE_READ8_MEMBER(px4_icrhb_r); |
188 | | DECLARE_READ8_MEMBER(px4_isr_r); |
189 | | DECLARE_WRITE8_MEMBER(px4_ier_w); |
190 | | DECLARE_READ8_MEMBER(px4_str_r); |
191 | | DECLARE_WRITE8_MEMBER(px4_bankr_w); |
192 | | DECLARE_READ8_MEMBER(px4_sior_r); |
193 | | DECLARE_WRITE8_MEMBER(px4_sior_w); |
194 | | DECLARE_WRITE8_MEMBER(px4_vadr_w); |
195 | | DECLARE_WRITE8_MEMBER(px4_yoff_w); |
196 | | DECLARE_WRITE8_MEMBER(px4_fr_w); |
197 | | DECLARE_WRITE8_MEMBER(px4_spur_w); |
198 | | DECLARE_READ8_MEMBER(px4_ctgif_r); |
199 | | DECLARE_WRITE8_MEMBER(px4_ctgif_w); |
200 | | DECLARE_READ8_MEMBER(px4_artdir_r); |
201 | | DECLARE_WRITE8_MEMBER(px4_artdor_w); |
202 | | DECLARE_READ8_MEMBER(px4_artsr_r); |
203 | | DECLARE_WRITE8_MEMBER(px4_artmr_w); |
204 | | DECLARE_READ8_MEMBER(px4_iostr_r); |
205 | | DECLARE_WRITE8_MEMBER(px4_artcr_w); |
206 | | DECLARE_WRITE8_MEMBER(px4_swr_w); |
207 | | DECLARE_WRITE8_MEMBER(px4_ioctlr_w); |
208 | | DECLARE_WRITE8_MEMBER(px4_ramdisk_address_w); |
209 | | DECLARE_READ8_MEMBER(px4_ramdisk_data_r); |
210 | | DECLARE_WRITE8_MEMBER(px4_ramdisk_data_w); |
211 | | DECLARE_READ8_MEMBER(px4_ramdisk_control_r); |
212 | | DECLARE_DRIVER_INIT(px4); |
213 | | DECLARE_DRIVER_INIT(px4p); |
| 265 | protected: |
| 266 | // driver_device overrides |
214 | 267 | virtual void machine_start(); |
215 | | virtual void machine_reset(); |
216 | | DECLARE_PALETTE_INIT(px4); |
217 | | DECLARE_MACHINE_START(px4_ramdisk); |
218 | | DECLARE_PALETTE_INIT(px4p); |
219 | | UINT32 screen_update_px4(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
220 | | DECLARE_INPUT_CHANGED_MEMBER(key_callback); |
221 | | TIMER_DEVICE_CALLBACK_MEMBER( ext_cassette_read ); |
222 | | TIMER_CALLBACK_MEMBER(transmit_data); |
223 | | TIMER_CALLBACK_MEMBER(receive_data); |
224 | | TIMER_DEVICE_CALLBACK_MEMBER(frc_tick); |
225 | | TIMER_DEVICE_CALLBACK_MEMBER(upd7508_1sec_callback); |
226 | 268 | |
227 | | int m_centronics_busy; |
228 | | int m_centronics_perror; |
229 | | DECLARE_WRITE_LINE_MEMBER(write_centronics_busy); |
230 | | DECLARE_WRITE_LINE_MEMBER(write_centronics_perror); |
| 269 | private: |
| 270 | required_device<nvram_device> m_rdnvram; |
| 271 | required_device<generic_slot_device> m_rdsocket; |
231 | 272 | |
232 | | private: |
233 | | DECLARE_WRITE_LINE_MEMBER( serial_rx_w ); |
| 273 | offs_t m_ramdisk_address; |
| 274 | UINT8 *m_ramdisk; |
234 | 275 | }; |
235 | 276 | |
236 | 277 | |
r241679 | r241680 | |
310 | 351 | } |
311 | 352 | |
312 | 353 | // input capture register low command trigger |
313 | | READ8_MEMBER( px4_state::px4_icrlc_r ) |
| 354 | READ8_MEMBER( px4_state::icrlc_r ) |
314 | 355 | { |
315 | 356 | if (VERBOSE) |
316 | | logerror("%s: px4_icrlc_r\n", machine().describe_context()); |
| 357 | logerror("%s: icrlc_r\n", machine().describe_context()); |
317 | 358 | |
318 | 359 | // latch value |
319 | 360 | m_frc_latch = m_frc_value; |
r241679 | r241680 | |
322 | 363 | } |
323 | 364 | |
324 | 365 | // control register 1 |
325 | | WRITE8_MEMBER( px4_state::px4_ctrl1_w ) |
| 366 | WRITE8_MEMBER( px4_state::ctrl1_w ) |
326 | 367 | { |
327 | 368 | const int rcv_rates[] = { 110, 150, 300, 600, 1200, 2400, 4800, 9600, 75, 1200, 19200, 38400, 200 }; |
328 | 369 | const int tra_rates[] = { 110, 150, 300, 600, 1200, 2400, 4800, 9600, 1200, 75, 19200, 38400, 200 }; |
329 | 370 | |
330 | 371 | if (VERBOSE) |
331 | | logerror("%s: px4_ctrl1_w (0x%02x)\n", machine().describe_context(), data); |
| 372 | logerror("%s: ctrl1_w (0x%02x)\n", machine().describe_context(), data); |
332 | 373 | |
333 | 374 | // baudrate generator |
334 | 375 | int baud = data >> 4; |
r241679 | r241680 | |
346 | 387 | } |
347 | 388 | |
348 | 389 | // input capture register high command trigger |
349 | | READ8_MEMBER( px4_state::px4_icrhc_r ) |
| 390 | READ8_MEMBER( px4_state::icrhc_r ) |
350 | 391 | { |
351 | 392 | if (VERBOSE) |
352 | | logerror("%s: px4_icrhc_r\n", machine().describe_context()); |
| 393 | logerror("%s: icrhc_r\n", machine().describe_context()); |
353 | 394 | |
354 | 395 | return (m_frc_latch >> 8) & 0xff; |
355 | 396 | } |
356 | 397 | |
357 | 398 | // command register |
358 | | WRITE8_MEMBER( px4_state::px4_cmdr_w ) |
| 399 | WRITE8_MEMBER( px4_state::cmdr_w ) |
359 | 400 | { |
360 | 401 | if (0) |
361 | | logerror("%s: px4_cmdr_w (0x%02x)\n", machine().describe_context(), data); |
| 402 | logerror("%s: cmdr_w (0x%02x)\n", machine().describe_context(), data); |
362 | 403 | |
363 | 404 | // clear overflow interrupt? |
364 | 405 | if (BIT(data, 2)) |
r241679 | r241680 | |
369 | 410 | } |
370 | 411 | |
371 | 412 | // input capture register low barcode trigger |
372 | | READ8_MEMBER( px4_state::px4_icrlb_r ) |
| 413 | READ8_MEMBER( px4_state::icrlb_r ) |
373 | 414 | { |
374 | 415 | if (VERBOSE) |
375 | | logerror("%s: px4_icrlb_r\n", machine().describe_context()); |
| 416 | logerror("%s: icrlb_r\n", machine().describe_context()); |
376 | 417 | |
377 | 418 | return m_icrb & 0xff; |
378 | 419 | } |
379 | 420 | |
380 | 421 | // control register 2 |
381 | | WRITE8_MEMBER( px4_state::px4_ctrl2_w ) |
| 422 | WRITE8_MEMBER( px4_state::ctrl2_w ) |
382 | 423 | { |
383 | 424 | if (VERBOSE) |
384 | | logerror("%s: px4_ctrl2_w (0x%02x)\n", machine().describe_context(), data); |
| 425 | logerror("%s: ctrl2_w (0x%02x)\n", machine().describe_context(), data); |
385 | 426 | |
386 | 427 | // bit 0, MIC, cassette output |
387 | 428 | m_ext_cas->output( BIT(data, 0) ? -1.0 : +1.0); |
r241679 | r241680 | |
400 | 441 | } |
401 | 442 | |
402 | 443 | // input capture register high barcode trigger |
403 | | READ8_MEMBER( px4_state::px4_icrhb_r ) |
| 444 | READ8_MEMBER( px4_state::icrhb_r ) |
404 | 445 | { |
405 | 446 | if (VERBOSE) |
406 | | logerror("%s: px4_icrhb_r\n", machine().describe_context()); |
| 447 | logerror("%s: icrhb_r\n", machine().describe_context()); |
407 | 448 | |
408 | 449 | // clear icf interrupt |
409 | 450 | m_isr &= ~INT2_ICF; |
r241679 | r241680 | |
413 | 454 | } |
414 | 455 | |
415 | 456 | // interrupt status register |
416 | | READ8_MEMBER( px4_state::px4_isr_r ) |
| 457 | READ8_MEMBER( px4_state::isr_r ) |
417 | 458 | { |
418 | 459 | if (VERBOSE) |
419 | | logerror("%s: px4_isr_r\n", machine().describe_context()); |
| 460 | logerror("%s: isr_r\n", machine().describe_context()); |
420 | 461 | |
421 | 462 | return m_isr; |
422 | 463 | } |
423 | 464 | |
424 | 465 | // interrupt enable register |
425 | | WRITE8_MEMBER( px4_state::px4_ier_w ) |
| 466 | WRITE8_MEMBER( px4_state::ier_w ) |
426 | 467 | { |
427 | 468 | if (0) |
428 | | logerror("%s: px4_ier_w (0x%02x)\n", machine().describe_context(), data); |
| 469 | logerror("%s: ier_w (0x%02x)\n", machine().describe_context(), data); |
429 | 470 | |
430 | 471 | m_ier = data; |
431 | 472 | gapnit_interrupt(); |
432 | 473 | } |
433 | 474 | |
434 | 475 | // status register |
435 | | READ8_MEMBER( px4_state::px4_str_r ) |
| 476 | READ8_MEMBER( px4_state::str_r ) |
436 | 477 | { |
437 | 478 | UINT8 data = 0; |
438 | 479 | |
439 | 480 | if (0) |
440 | | logerror("%s: px4_str_r\n", machine().describe_context()); |
| 481 | logerror("%s: str_r\n", machine().describe_context()); |
441 | 482 | |
442 | 483 | data |= (m_ext_cas)->input() > 0 ? 1 : 0; |
443 | 484 | data |= 1 << 1; // BCRD, barcode reader input |
r241679 | r241680 | |
467 | 508 | } |
468 | 509 | |
469 | 510 | // bank register |
470 | | WRITE8_MEMBER( px4_state::px4_bankr_w ) |
| 511 | WRITE8_MEMBER( px4_state::bankr_w ) |
471 | 512 | { |
472 | 513 | address_space &space_program = m_z80->space(AS_PROGRAM); |
473 | 514 | |
474 | 515 | if (0) |
475 | | logerror("%s: px4_bankr_w (0x%02x)\n", machine().describe_context(), data); |
| 516 | logerror("%s: bankr_w (0x%02x)\n", machine().describe_context(), data); |
476 | 517 | |
477 | 518 | m_bankr = data; |
478 | 519 | |
r241679 | r241680 | |
505 | 546 | } |
506 | 547 | |
507 | 548 | // serial io register |
508 | | READ8_MEMBER( px4_state::px4_sior_r ) |
| 549 | READ8_MEMBER( px4_state::sior_r ) |
509 | 550 | { |
510 | 551 | if (0) |
511 | | logerror("%s: px4_sior_r 0x%02x\n", machine().describe_context(), m_sior); |
| 552 | logerror("%s: sior_r 0x%02x\n", machine().describe_context(), m_sior); |
512 | 553 | |
513 | 554 | return m_sior; |
514 | 555 | } |
515 | 556 | |
516 | 557 | // serial io register |
517 | | WRITE8_MEMBER( px4_state::px4_sior_w ) |
| 558 | WRITE8_MEMBER( px4_state::sior_w ) |
518 | 559 | { |
519 | 560 | if (0) |
520 | | logerror("%s: px4_sior_w (0x%02x)\n", machine().describe_context(), data); |
| 561 | logerror("%s: sior_w (0x%02x)\n", machine().describe_context(), data); |
521 | 562 | |
522 | 563 | m_sior = data; |
523 | 564 | |
r241679 | r241680 | |
644 | 685 | //************************************************************************** |
645 | 686 | |
646 | 687 | // vram start address register |
647 | | WRITE8_MEMBER( px4_state::px4_vadr_w ) |
| 688 | WRITE8_MEMBER( px4_state::vadr_w ) |
648 | 689 | { |
649 | 690 | if (VERBOSE) |
650 | | logerror("%s: px4_vadr_w (0x%02x)\n", machine().describe_context(), data); |
| 691 | logerror("%s: vadr_w (0x%02x)\n", machine().describe_context(), data); |
651 | 692 | |
652 | 693 | m_vadr = data; |
653 | 694 | } |
654 | 695 | |
655 | 696 | // y offset register |
656 | | WRITE8_MEMBER( px4_state::px4_yoff_w ) |
| 697 | WRITE8_MEMBER( px4_state::yoff_w ) |
657 | 698 | { |
658 | 699 | if (VERBOSE) |
659 | | logerror("%s: px4_yoff_w (0x%02x)\n", machine().describe_context(), data); |
| 700 | logerror("%s: yoff_w (0x%02x)\n", machine().describe_context(), data); |
660 | 701 | |
661 | 702 | m_yoff = data; |
662 | 703 | } |
663 | 704 | |
664 | 705 | // frame register |
665 | | WRITE8_MEMBER( px4_state::px4_fr_w ) |
| 706 | WRITE8_MEMBER( px4_state::fr_w ) |
666 | 707 | { |
667 | 708 | if (VERBOSE) |
668 | | logerror("%s: px4_fr_w (0x%02x)\n", machine().describe_context(), data); |
| 709 | logerror("%s: fr_w (0x%02x)\n", machine().describe_context(), data); |
669 | 710 | } |
670 | 711 | |
671 | 712 | // speed-up register |
672 | | WRITE8_MEMBER( px4_state::px4_spur_w ) |
| 713 | WRITE8_MEMBER( px4_state::spur_w ) |
673 | 714 | { |
674 | 715 | if (VERBOSE) |
675 | | logerror("%s: px4_spur_w (0x%02x)\n", machine().describe_context(), data); |
| 716 | logerror("%s: spur_w (0x%02x)\n", machine().describe_context(), data); |
676 | 717 | } |
677 | 718 | |
678 | 719 | |
r241679 | r241680 | |
728 | 769 | if (ART_TX_ENABLED) |
729 | 770 | { |
730 | 771 | if (ART_BREAK) |
731 | | { |
732 | | // transmit break |
733 | | txd_w(0); |
734 | | } |
| 772 | txd_w(0); // transmit break |
735 | 773 | else |
736 | | { |
737 | | // transmit data |
738 | | txd_w(transmit_register_get_data_bit()); |
739 | | } |
| 774 | txd_w(transmit_register_get_data_bit()); // transmit data |
740 | 775 | } |
741 | 776 | else |
742 | | { |
743 | | // transmit mark |
744 | | txd_w(1); |
745 | | } |
| 777 | txd_w(1); // transmit mark |
746 | 778 | } |
747 | 779 | |
748 | 780 | void px4_state::tra_complete() |
r241679 | r241680 | |
763 | 795 | void px4_state::rcv_callback() |
764 | 796 | { |
765 | 797 | if (ART_RX_ENABLED) |
766 | | { |
767 | | // receive data |
768 | | receive_register_update_bit(m_serial_rx); |
769 | | } |
| 798 | receive_register_update_bit(m_serial_rx); // receive data |
770 | 799 | } |
771 | 800 | |
772 | 801 | void px4_state::rcv_complete() |
r241679 | r241680 | |
800 | 829 | } |
801 | 830 | |
802 | 831 | // cartridge interface |
803 | | READ8_MEMBER( px4_state::px4_ctgif_r ) |
| 832 | READ8_MEMBER( px4_state::ctgif_r ) |
804 | 833 | { |
805 | 834 | if (VERBOSE) |
806 | | logerror("%s: px4_ctgif_r @ 0x%02x\n", machine().describe_context(), offset); |
| 835 | logerror("%s: ctgif_r @ 0x%02x\n", machine().describe_context(), offset); |
807 | 836 | |
808 | 837 | return 0x00; |
809 | 838 | } |
810 | 839 | |
811 | 840 | // cartridge interface |
812 | | WRITE8_MEMBER( px4_state::px4_ctgif_w ) |
| 841 | WRITE8_MEMBER( px4_state::ctgif_w ) |
813 | 842 | { |
814 | 843 | if (VERBOSE) |
815 | | logerror("%s: px4_ctgif_w (0x%02x @ 0x%02x)\n", machine().describe_context(), data, offset); |
| 844 | logerror("%s: ctgif_w (0x%02x @ 0x%02x)\n", machine().describe_context(), data, offset); |
816 | 845 | } |
817 | 846 | |
818 | 847 | // art data input register |
819 | | READ8_MEMBER( px4_state::px4_artdir_r ) |
| 848 | READ8_MEMBER( px4_state::artdir_r ) |
820 | 849 | { |
821 | 850 | if (VERBOSE) |
822 | | logerror("%s: px4_artdir_r (%02x)\n", machine().describe_context(), m_artdir); |
| 851 | logerror("%s: artdir_r (%02x)\n", machine().describe_context(), m_artdir); |
823 | 852 | |
824 | 853 | // clear ready |
825 | 854 | m_artsr &= ~ART_RXRDY; |
r241679 | r241680 | |
832 | 861 | } |
833 | 862 | |
834 | 863 | // art data output register |
835 | | WRITE8_MEMBER( px4_state::px4_artdor_w ) |
| 864 | WRITE8_MEMBER( px4_state::artdor_w ) |
836 | 865 | { |
837 | 866 | if (VERBOSE) |
838 | | logerror("%s: px4_artdor_w (0x%02x)\n", machine().describe_context(), data); |
| 867 | logerror("%s: artdor_w (0x%02x)\n", machine().describe_context(), data); |
839 | 868 | |
840 | 869 | m_artdor = data; |
841 | 870 | |
r241679 | r241680 | |
853 | 882 | } |
854 | 883 | |
855 | 884 | // art status register |
856 | | READ8_MEMBER( px4_state::px4_artsr_r ) |
| 885 | READ8_MEMBER( px4_state::artsr_r ) |
857 | 886 | { |
858 | 887 | if (0) |
859 | | logerror("%s: px4_artsr_r (%02x)\n", machine().describe_context(), m_artsr); |
| 888 | logerror("%s: artsr_r (%02x)\n", machine().describe_context(), m_artsr); |
860 | 889 | |
861 | 890 | return m_artsr; |
862 | 891 | } |
863 | 892 | |
864 | 893 | // art mode register |
865 | | WRITE8_MEMBER( px4_state::px4_artmr_w ) |
| 894 | WRITE8_MEMBER( px4_state::artmr_w ) |
866 | 895 | { |
867 | 896 | int data_bit_count = BIT(data, 2) ? 8 : 7; |
868 | 897 | parity_t parity = BIT(data, 4) ? (BIT(data, 5) ? PARITY_EVEN : PARITY_ODD) : PARITY_NONE; |
r241679 | r241680 | |
874 | 903 | set_data_frame(1, data_bit_count, parity, stop_bits); |
875 | 904 | } |
876 | 905 | |
877 | | WRITE_LINE_MEMBER( px4_state::write_centronics_busy ) |
878 | | { |
879 | | m_centronics_busy = state; |
880 | | } |
881 | | |
882 | | WRITE_LINE_MEMBER( px4_state::write_centronics_perror ) |
883 | | { |
884 | | m_centronics_perror = state; |
885 | | } |
886 | | |
887 | 906 | // io status register |
888 | | READ8_MEMBER( px4_state::px4_iostr_r ) |
| 907 | READ8_MEMBER( px4_state::iostr_r ) |
889 | 908 | { |
890 | 909 | UINT8 data = 0; |
891 | 910 | |
r241679 | r241680 | |
907 | 926 | data |= 0 << 7; // bit 7, caud - audio input from cartridge |
908 | 927 | |
909 | 928 | if (0) |
910 | | logerror("%s: px4_iostr_r: rx = %d, dcd = %d, cts = %d\n", machine().describe_context(), BIT(data, 3), BIT(data, 4), BIT(data, 5)); |
| 929 | logerror("%s: iostr_r: rx = %d, dcd = %d, cts = %d\n", machine().describe_context(), BIT(data, 3), BIT(data, 4), BIT(data, 5)); |
911 | 930 | |
912 | 931 | return data; |
913 | 932 | } |
914 | 933 | |
915 | 934 | // art command register |
916 | | WRITE8_MEMBER( px4_state::px4_artcr_w ) |
| 935 | WRITE8_MEMBER( px4_state::artcr_w ) |
917 | 936 | { |
918 | 937 | if (VERBOSE) |
919 | | logerror("%s: px4_artcr_w (0x%02x)\n", machine().describe_context(), data); |
| 938 | logerror("%s: artcr_w (0x%02x)\n", machine().describe_context(), data); |
920 | 939 | |
921 | 940 | m_artcr = data; |
922 | 941 | |
r241679 | r241680 | |
930 | 949 | } |
931 | 950 | |
932 | 951 | // switch register |
933 | | WRITE8_MEMBER( px4_state::px4_swr_w ) |
| 952 | WRITE8_MEMBER( px4_state::swr_w ) |
934 | 953 | { |
935 | 954 | if (VERBOSE) |
936 | 955 | { |
r241679 | r241680 | |
944 | 963 | } |
945 | 964 | |
946 | 965 | // io control register |
947 | | WRITE8_MEMBER( px4_state::px4_ioctlr_w ) |
| 966 | WRITE8_MEMBER( px4_state::ioctlr_w ) |
948 | 967 | { |
949 | 968 | if (VERBOSE) |
950 | | logerror("%s: px4_ioctlr_w (0x%02x)\n", machine().describe_context(), data); |
| 969 | logerror("%s: ioctlr_w (0x%02x)\n", machine().describe_context(), data); |
951 | 970 | |
952 | 971 | m_centronics->write_strobe(!BIT(data, 0)); |
953 | 972 | m_centronics->write_init(BIT(data, 1)); |
r241679 | r241680 | |
1025 | 1044 | // EXTERNAL RAM-DISK |
1026 | 1045 | //************************************************************************** |
1027 | 1046 | |
1028 | | WRITE8_MEMBER( px4_state::px4_ramdisk_address_w ) |
| 1047 | WRITE8_MEMBER( px4p_state::ramdisk_address_w ) |
1029 | 1048 | { |
1030 | 1049 | switch (offset) |
1031 | 1050 | { |
r241679 | r241680 | |
1035 | 1054 | } |
1036 | 1055 | } |
1037 | 1056 | |
1038 | | READ8_MEMBER( px4_state::px4_ramdisk_data_r ) |
| 1057 | READ8_MEMBER( px4p_state::ramdisk_data_r ) |
1039 | 1058 | { |
1040 | 1059 | UINT8 ret = 0xff; |
1041 | 1060 | |
r241679 | r241680 | |
1055 | 1074 | return ret; |
1056 | 1075 | } |
1057 | 1076 | |
1058 | | WRITE8_MEMBER( px4_state::px4_ramdisk_data_w ) |
| 1077 | WRITE8_MEMBER( px4p_state::ramdisk_data_w ) |
1059 | 1078 | { |
1060 | 1079 | if (m_ramdisk_address < 0x20000) |
1061 | 1080 | m_ramdisk[m_ramdisk_address] = data; |
r241679 | r241680 | |
1063 | 1082 | m_ramdisk_address = (m_ramdisk_address & 0xffff00) | ((m_ramdisk_address & 0xff) + 1); |
1064 | 1083 | } |
1065 | 1084 | |
1066 | | READ8_MEMBER( px4_state::px4_ramdisk_control_r ) |
| 1085 | READ8_MEMBER( px4p_state::ramdisk_control_r ) |
1067 | 1086 | { |
1068 | 1087 | // bit 7 determines the presence of a ram-disk |
1069 | 1088 | return 0x7f; |
r241679 | r241680 | |
1127 | 1146 | membank("bank2")->set_base(m_ram->pointer() + 0x8000); |
1128 | 1147 | } |
1129 | 1148 | |
1130 | | DRIVER_INIT_MEMBER( px4_state, px4p ) |
| 1149 | DRIVER_INIT_MEMBER( px4p_state, px4p ) |
1131 | 1150 | { |
1132 | 1151 | DRIVER_INIT_CALL(px4); |
1133 | 1152 | |
r241679 | r241680 | |
1149 | 1168 | transmit_register_reset(); |
1150 | 1169 | } |
1151 | 1170 | |
1152 | | MACHINE_START_MEMBER( px4_state, px4_ramdisk ) |
| 1171 | void px4p_state::machine_start() |
1153 | 1172 | { |
1154 | 1173 | px4_state::machine_start(); |
1155 | | machine().device<nvram_device>("nvram")->set_base(m_ramdisk, 0x20000); |
| 1174 | m_rdnvram->set_base(m_ramdisk, 0x20000); |
1156 | 1175 | } |
1157 | 1176 | |
1158 | 1177 | |
r241679 | r241680 | |
1169 | 1188 | ADDRESS_MAP_UNMAP_HIGH |
1170 | 1189 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
1171 | 1190 | // gapnit, 0x00-0x07 |
1172 | | AM_RANGE(0x00, 0x00) AM_READWRITE(px4_icrlc_r, px4_ctrl1_w) |
1173 | | AM_RANGE(0x01, 0x01) AM_READWRITE(px4_icrhc_r, px4_cmdr_w) |
1174 | | AM_RANGE(0x02, 0x02) AM_READWRITE(px4_icrlb_r, px4_ctrl2_w) |
1175 | | AM_RANGE(0x03, 0x03) AM_READ(px4_icrhb_r) |
1176 | | AM_RANGE(0x04, 0x04) AM_READWRITE(px4_isr_r, px4_ier_w) |
1177 | | AM_RANGE(0x05, 0x05) AM_READWRITE(px4_str_r, px4_bankr_w) |
1178 | | AM_RANGE(0x06, 0x06) AM_READWRITE(px4_sior_r, px4_sior_w) |
| 1191 | AM_RANGE(0x00, 0x00) AM_READWRITE( icrlc_r, ctrl1_w ) |
| 1192 | AM_RANGE(0x01, 0x01) AM_READWRITE( icrhc_r, cmdr_w ) |
| 1193 | AM_RANGE(0x02, 0x02) AM_READWRITE( icrlb_r, ctrl2_w ) |
| 1194 | AM_RANGE(0x03, 0x03) AM_READ( icrhb_r ) |
| 1195 | AM_RANGE(0x04, 0x04) AM_READWRITE( isr_r, ier_w ) |
| 1196 | AM_RANGE(0x05, 0x05) AM_READWRITE( str_r, bankr_w ) |
| 1197 | AM_RANGE(0x06, 0x06) AM_READWRITE( sior_r, sior_w ) |
1179 | 1198 | AM_RANGE(0x07, 0x07) AM_NOP |
1180 | 1199 | // gapndl, 0x08-0x0f |
1181 | | AM_RANGE(0x08, 0x08) AM_WRITE(px4_vadr_w) |
1182 | | AM_RANGE(0x09, 0x09) AM_WRITE(px4_yoff_w) |
1183 | | AM_RANGE(0x0a, 0x0a) AM_WRITE(px4_fr_w) |
1184 | | AM_RANGE(0x0b, 0x0b) AM_WRITE(px4_spur_w) |
| 1200 | AM_RANGE(0x08, 0x08) AM_WRITE( vadr_w ) |
| 1201 | AM_RANGE(0x09, 0x09) AM_WRITE( yoff_w ) |
| 1202 | AM_RANGE(0x0a, 0x0a) AM_WRITE( fr_w ) |
| 1203 | AM_RANGE(0x0b, 0x0b) AM_WRITE( spur_w ) |
1185 | 1204 | AM_RANGE(0x0c, 0x0f) AM_NOP |
1186 | 1205 | // gapnio, 0x10-0x1f |
1187 | | AM_RANGE(0x10, 0x13) AM_READWRITE(px4_ctgif_r, px4_ctgif_w) |
1188 | | AM_RANGE(0x14, 0x14) AM_READWRITE(px4_artdir_r, px4_artdor_w) |
1189 | | AM_RANGE(0x15, 0x15) AM_READWRITE(px4_artsr_r, px4_artmr_w) |
1190 | | AM_RANGE(0x16, 0x16) AM_READWRITE(px4_iostr_r, px4_artcr_w) |
| 1206 | AM_RANGE(0x10, 0x13) AM_READWRITE( ctgif_r, ctgif_w ) |
| 1207 | AM_RANGE(0x14, 0x14) AM_READWRITE( artdir_r, artdor_w ) |
| 1208 | AM_RANGE(0x15, 0x15) AM_READWRITE( artsr_r, artmr_w ) |
| 1209 | AM_RANGE(0x16, 0x16) AM_READWRITE( iostr_r, artcr_w ) |
1191 | 1210 | AM_RANGE(0x17, 0x17) AM_DEVWRITE("cent_data_out", output_latch_device, write) |
1192 | | AM_RANGE(0x18, 0x18) AM_WRITE(px4_swr_w) |
1193 | | AM_RANGE(0x19, 0x19) AM_WRITE(px4_ioctlr_w) |
| 1211 | AM_RANGE(0x18, 0x18) AM_WRITE( swr_w ) |
| 1212 | AM_RANGE(0x19, 0x19) AM_WRITE( ioctlr_w ) |
1194 | 1213 | AM_RANGE(0x1a, 0x1f) AM_NOP |
1195 | 1214 | ADDRESS_MAP_END |
1196 | 1215 | |
1197 | | static ADDRESS_MAP_START( px4p_io, AS_IO, 8, px4_state ) |
| 1216 | static ADDRESS_MAP_START( px4p_io, AS_IO, 8, px4p_state ) |
1198 | 1217 | AM_IMPORT_FROM(px4_io) |
1199 | | AM_RANGE(0x90, 0x92) AM_WRITE(px4_ramdisk_address_w) |
1200 | | AM_RANGE(0x93, 0x93) AM_READWRITE(px4_ramdisk_data_r, px4_ramdisk_data_w) |
1201 | | AM_RANGE(0x94, 0x94) AM_READ(px4_ramdisk_control_r) |
| 1218 | AM_RANGE(0x90, 0x92) AM_WRITE(ramdisk_address_w ) |
| 1219 | AM_RANGE(0x93, 0x93) AM_READWRITE(ramdisk_data_r, ramdisk_data_w ) |
| 1220 | AM_RANGE(0x94, 0x94) AM_READ(ramdisk_control_r) |
1202 | 1221 | ADDRESS_MAP_END |
1203 | 1222 | |
1204 | 1223 | |
r241679 | r241680 | |
1361 | 1380 | // PALETTE |
1362 | 1381 | //************************************************************************** |
1363 | 1382 | |
1364 | | PALETTE_INIT_MEMBER(px4_state, px4) |
| 1383 | PALETTE_INIT_MEMBER( px4_state, px4 ) |
1365 | 1384 | { |
1366 | 1385 | palette.set_pen_color(0, rgb_t(138, 146, 148)); |
1367 | 1386 | palette.set_pen_color(1, rgb_t(92, 83, 88)); |
1368 | 1387 | } |
1369 | 1388 | |
1370 | | PALETTE_INIT_MEMBER(px4_state, px4p) |
| 1389 | PALETTE_INIT_MEMBER( px4p_state, px4p ) |
1371 | 1390 | { |
1372 | 1391 | palette.set_pen_color(0, rgb_t(149, 157, 130)); |
1373 | 1392 | palette.set_pen_color(1, rgb_t(92, 83, 88)); |
r241679 | r241680 | |
1411 | 1430 | |
1412 | 1431 | // centronics printer |
1413 | 1432 | MCFG_CENTRONICS_ADD("centronics", centronics_devices, "printer") |
1414 | | MCFG_CENTRONICS_BUSY_HANDLER(WRITELINE(px4_state, write_centronics_busy)) |
1415 | | MCFG_CENTRONICS_PERROR_HANDLER(WRITELINE(px4_state, write_centronics_perror)) |
| 1433 | MCFG_CENTRONICS_BUSY_HANDLER(WRITELINE(px4_state, centronics_busy_w)) |
| 1434 | MCFG_CENTRONICS_PERROR_HANDLER(WRITELINE(px4_state, centronics_perror_w)) |
1416 | 1435 | |
1417 | 1436 | MCFG_CENTRONICS_OUTPUT_LATCH_ADD("cent_data_out", "centronics") |
1418 | 1437 | |
r241679 | r241680 | |
1443 | 1462 | MCFG_SOFTWARE_LIST_ADD("epson_cpm_list", "epson_cpm") |
1444 | 1463 | MACHINE_CONFIG_END |
1445 | 1464 | |
1446 | | static MACHINE_CONFIG_DERIVED( px4p, px4 ) |
| 1465 | static MACHINE_CONFIG_DERIVED_CLASS( px4p, px4, px4p_state ) |
1447 | 1466 | MCFG_CPU_MODIFY("maincpu") |
1448 | 1467 | MCFG_CPU_IO_MAP(px4p_io) |
1449 | 1468 | |
1450 | | MCFG_MACHINE_START_OVERRIDE(px4_state, px4_ramdisk) |
1451 | | MCFG_NVRAM_ADD_0FILL("nvram") |
| 1469 | MCFG_NVRAM_ADD_0FILL("rdnvram") |
1452 | 1470 | |
1453 | 1471 | MCFG_PALETTE_MODIFY("palette") |
1454 | | MCFG_PALETTE_INIT_OWNER(px4_state, px4p) |
| 1472 | MCFG_PALETTE_INIT_OWNER(px4p_state, px4p) |
1455 | 1473 | |
1456 | 1474 | MCFG_GENERIC_CARTSLOT_ADD("ramdisk_socket", generic_plain_slot, "px4_cart") |
1457 | 1475 | MACHINE_CONFIG_END |
r241679 | r241680 | |
1484 | 1502 | // GAME DRIVERS |
1485 | 1503 | //************************************************************************** |
1486 | 1504 | |
1487 | | // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS |
1488 | | COMP( 1985, px4, 0, 0, px4, px4_h450a, px4_state, px4, "Epson", "PX-4", 0 ) |
1489 | | COMP( 1985, px4p, px4, 0, px4p, px4_h450a, px4_state, px4p, "Epson", "PX-4+", 0 ) |
| 1505 | // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS |
| 1506 | COMP( 1985, px4, 0, 0, px4, px4_h450a, px4_state, px4, "Epson", "PX-4", 0 ) |
| 1507 | COMP( 1985, px4p, px4, 0, px4p, px4_h450a, px4p_state, px4p, "Epson", "PX-4+", 0 ) |