trunk/src/mess/drivers/z88.c
| r28715 | r28716 | |
| 621 | 621 | { |
| 622 | 622 | z88_screen_update, // callback for update the LCD |
| 623 | 623 | z88_bankswitch_update, // callback for update the bankswitch |
| 624 | | DEVCB_DRIVER_MEMBER(z88_state, kb_r), // kb read input |
| 625 | | DEVCB_CPU_INPUT_LINE("maincpu", 0), // INT line out |
| 626 | | DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_NMI), // NMI line out |
| 627 | | DEVCB_DEVICE_LINE_MEMBER("speaker", speaker_sound_device, level_w) // Speaker line out |
| 628 | 624 | }; |
| 629 | 625 | |
| 630 | 626 | static const z88cart_interface z88_cart_interface = |
| r28715 | r28716 | |
| 664 | 660 | MCFG_DEFAULT_LAYOUT(layout_lcd) |
| 665 | 661 | |
| 666 | 662 | MCFG_UPD65031_ADD("blink", XTAL_9_8304MHz, z88_blink_intf) |
| 663 | MCFG_UPD65031_KB_CALLBACK(READ8(z88_state, kb_r)) |
| 664 | MCFG_UPD65031_INT_CALLBACK(INPUTLINE("maincpu", INPUT_LINE_IRQ0)) |
| 665 | MCFG_UPD65031_NMI_CALLBACK(INPUTLINE("maincpu", INPUT_LINE_NMI)) |
| 666 | MCFG_UPD65031_SPKR_CALLBACK(DEVWRITELINE("speaker", speaker_sound_device, level_w)) |
| 667 | 667 | |
| 668 | 668 | /* sound hardware */ |
| 669 | 669 | MCFG_SPEAKER_STANDARD_MONO("mono") |
trunk/src/mess/machine/upd65031.c
| r28715 | r28716 | |
| 142 | 142 | { |
| 143 | 143 | if (LOG) logerror("uPD65031 '%s': set int\n", tag()); |
| 144 | 144 | |
| 145 | | m_out_int_func(ASSERT_LINE); |
| 145 | m_write_int(ASSERT_LINE); |
| 146 | 146 | } |
| 147 | 147 | else |
| 148 | 148 | { |
| 149 | 149 | if (LOG) logerror("uPD65031 '%s': clear int\n", tag()); |
| 150 | 150 | |
| 151 | | m_out_int_func(CLEAR_LINE); |
| 151 | m_write_int(CLEAR_LINE); |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
| r28715 | r28716 | |
| 194 | 194 | //------------------------------------------------- |
| 195 | 195 | |
| 196 | 196 | upd65031_device::upd65031_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 197 | | : device_t(mconfig, UPD65031, "NEC uPD65031", tag, owner, clock, "upd65031", __FILE__) |
| 197 | : device_t(mconfig, UPD65031, "NEC uPD65031", tag, owner, clock, "upd65031", __FILE__), |
| 198 | m_read_kb(*this), |
| 199 | m_write_int(*this), |
| 200 | m_write_nmi(*this), |
| 201 | m_write_spkr(*this) |
| 198 | 202 | { |
| 199 | 203 | } |
| 200 | 204 | |
| r28715 | r28716 | |
| 218 | 222 | { |
| 219 | 223 | m_screen_update_cb = NULL; |
| 220 | 224 | m_out_mem_cb = NULL; |
| 221 | | memset(&m_in_kb_cb, 0, sizeof(m_in_kb_cb)); |
| 222 | | memset(&m_out_int_cb, 0, sizeof(m_out_int_cb)); |
| 223 | | memset(&m_out_nmi_cb, 0, sizeof(m_out_nmi_cb)); |
| 224 | | memset(&m_out_spkr_cb, 0, sizeof(m_out_spkr_cb)); |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
| r28715 | r28716 | |
| 233 | 233 | void upd65031_device::device_start() |
| 234 | 234 | { |
| 235 | 235 | // resolve callbacks |
| 236 | | m_out_int_func.resolve(m_out_int_cb, *this); |
| 237 | | m_out_nmi_func.resolve(m_out_nmi_cb, *this); |
| 238 | | m_out_spkr_func.resolve(m_out_spkr_cb, *this); |
| 239 | | m_int_kb_func.resolve(m_in_kb_cb, *this); |
| 236 | m_read_kb.resolve_safe(0); |
| 237 | m_write_int.resolve_safe(); |
| 238 | m_write_nmi.resolve_safe(); |
| 239 | m_write_spkr.resolve_safe(); |
| 240 | 240 | |
| 241 | 241 | // allocate timers |
| 242 | 242 | m_rtc_timer = timer_alloc(TIMER_RTC); |
| r28715 | r28716 | |
| 304 | 304 | case TIMER_RTC: |
| 305 | 305 | |
| 306 | 306 | // if a key is pressed sets the interrupt |
| 307 | | if ((m_int & INT_GINT) && (m_int & INT_KEY) && m_int_kb_func(0) != 0xff) |
| 307 | if ((m_int & INT_GINT) && (m_int & INT_KEY) && m_read_kb(0) != 0xff) |
| 308 | 308 | { |
| 309 | 309 | if (LOG) logerror("uPD65031 '%s': Keyboard interrupt!\n", tag()); |
| 310 | 310 | |
| r28715 | r28716 | |
| 393 | 393 | break; |
| 394 | 394 | case TIMER_SPEAKER: |
| 395 | 395 | m_speaker_state = !m_speaker_state; |
| 396 | | m_out_spkr_func(m_speaker_state ? 1 : 0); |
| 396 | m_write_spkr(m_speaker_state ? 1 : 0); |
| 397 | 397 | break; |
| 398 | 398 | } |
| 399 | 399 | } |
| r28715 | r28716 | |
| 436 | 436 | if (LOG) logerror("uPD65031 '%s': entering snooze!\n", tag()); |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | | UINT8 data = m_int_kb_func(offset>>8); |
| 439 | UINT8 data = m_read_kb(offset>>8); |
| 440 | 440 | |
| 441 | 441 | if (LOG) logerror("uPD65031 '%s': key r %02x: %02x\n", tag(), offset>>8, data); |
| 442 | 442 | |
| r28715 | r28716 | |
| 516 | 516 | { |
| 517 | 517 | // speaker controlled by SBIT |
| 518 | 518 | m_speaker_state = BIT(data, 6); |
| 519 | | m_out_spkr_func(m_speaker_state); |
| 519 | m_write_spkr(m_speaker_state); |
| 520 | 520 | } |
| 521 | 521 | else |
| 522 | 522 | { |
trunk/src/mess/machine/upd65031.h
| r28715 | r28716 | |
| 24 | 24 | #define UPD65031_INTERFACE(name) \ |
| 25 | 25 | const upd65031_interface (name) = |
| 26 | 26 | |
| 27 | #define MCFG_UPD65031_KB_CALLBACK(_read) \ |
| 28 | devcb = &upd65031_device::set_kb_rd_callback(*device, DEVCB2_##_read); |
| 27 | 29 | |
| 30 | #define MCFG_UPD65031_INT_CALLBACK(_write) \ |
| 31 | devcb = &upd65031_device::set_int_wr_callback(*device, DEVCB2_##_write); |
| 32 | |
| 33 | #define MCFG_UPD65031_NMI_CALLBACK(_write) \ |
| 34 | devcb = &upd65031_device::set_nmi_wr_callback(*device, DEVCB2_##_write); |
| 35 | |
| 36 | #define MCFG_UPD65031_SPKR_CALLBACK(_write) \ |
| 37 | devcb = &upd65031_device::set_spkr_wr_callback(*device, DEVCB2_##_write); |
| 38 | |
| 39 | |
| 28 | 40 | //************************************************************************** |
| 29 | 41 | // TYPE DEFINITIONS |
| 30 | 42 | //************************************************************************** |
| r28715 | r28716 | |
| 42 | 54 | { |
| 43 | 55 | upd65031_screen_update_func m_screen_update_cb; // callback for update the LCD |
| 44 | 56 | upd65031_memory_update_func m_out_mem_cb; // callback for update bankswitch |
| 45 | | devcb_read8 m_in_kb_cb; // kb read input |
| 46 | | devcb_write_line m_out_int_cb; // INT line out |
| 47 | | devcb_write_line m_out_nmi_cb; // NMI line out |
| 48 | | devcb_write_line m_out_spkr_cb; // Speaker line out |
| 49 | 57 | }; |
| 50 | 58 | |
| 51 | 59 | |
| r28715 | r28716 | |
| 58 | 66 | // construction/destruction |
| 59 | 67 | upd65031_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 60 | 68 | |
| 69 | template<class _Object> static devcb2_base &set_kb_rd_callback(device_t &device, _Object object) { return downcast<upd65031_device &>(device).m_read_kb.set_callback(object); } |
| 70 | template<class _Object> static devcb2_base &set_int_wr_callback(device_t &device, _Object object) { return downcast<upd65031_device &>(device).m_write_int.set_callback(object); } |
| 71 | template<class _Object> static devcb2_base &set_nmi_wr_callback(device_t &device, _Object object) { return downcast<upd65031_device &>(device).m_write_nmi.set_callback(object); } |
| 72 | template<class _Object> static devcb2_base &set_spkr_wr_callback(device_t &device, _Object object) { return downcast<upd65031_device &>(device).m_write_spkr.set_callback(object); } |
| 73 | |
| 61 | 74 | DECLARE_READ8_MEMBER( read ); |
| 62 | 75 | DECLARE_WRITE8_MEMBER( write ); |
| 63 | 76 | DECLARE_WRITE_LINE_MEMBER( flp_w ); |
| r28715 | r28716 | |
| 79 | 92 | static const device_timer_id TIMER_FLASH = 1; |
| 80 | 93 | static const device_timer_id TIMER_SPEAKER = 2; |
| 81 | 94 | |
| 82 | | devcb_resolved_write_line m_out_int_func; |
| 83 | | devcb_resolved_write_line m_out_nmi_func; |
| 84 | | devcb_resolved_write_line m_out_spkr_func; |
| 85 | | devcb_resolved_read8 m_int_kb_func; |
| 95 | devcb2_read8 m_read_kb; |
| 96 | devcb2_write_line m_write_int; |
| 97 | devcb2_write_line m_write_nmi; |
| 98 | devcb2_write_line m_write_spkr; |
| 86 | 99 | |
| 87 | 100 | int m_mode; |
| 88 | 101 | UINT16 m_lcd_regs[5]; // LCD registers |