trunk/src/emu/cpu/tms7000/tms7000.c
| r31334 | r31335 | |
| 318 | 318 | // interrupts |
| 319 | 319 | //------------------------------------------------- |
| 320 | 320 | |
| 321 | | void tms7000_device::execute_set_input(int irqline, int state) |
| 321 | void tms7000_device::execute_set_input(int extline, int state) |
| 322 | 322 | { |
| 323 | | assert(irqline == TMS7000_INT1_LINE || irqline == TMS7000_INT3_LINE); |
| 323 | if (extline != TMS7000_INT1_LINE && extline != TMS7000_INT3_LINE) |
| 324 | return; |
| 325 | |
| 324 | 326 | bool irqstate = (state == CLEAR_LINE) ? false : true; |
| 325 | 327 | |
| 326 | 328 | // reverse polarity (70cx2-only) |
| 327 | | if (m_io_control[2] & (0x01 << (4 * irqline))) |
| 329 | if (m_io_control[2] & (0x01 << (4 * extline))) |
| 328 | 330 | irqstate = !irqstate; |
| 329 | 331 | |
| 330 | | if (m_irq_state[irqline] != irqstate) |
| 332 | if (m_irq_state[extline] != irqstate) |
| 331 | 333 | { |
| 332 | | m_irq_state[irqline] = irqstate; |
| 334 | m_irq_state[extline] = irqstate; |
| 333 | 335 | |
| 334 | 336 | // set/clear internal irq flag |
| 335 | | flag_ext_interrupt(irqline); |
| 337 | flag_ext_interrupt(extline); |
| 336 | 338 | |
| 337 | | if (m_irq_state[irqline]) |
| 339 | if (m_irq_state[extline]) |
| 338 | 340 | { |
| 339 | 341 | // latch timer 1 on INT3 |
| 340 | | if (irqline == TMS7000_INT3_LINE) |
| 342 | if (extline == TMS7000_INT3_LINE) |
| 341 | 343 | m_timer_capture_latch[0] = m_timer_decrementer[0]; |
| 342 | 344 | |
| 343 | 345 | // on 70cx2, latch timer 2 on INT1 |
| 344 | | if (irqline == TMS7000_INT1_LINE && chip_is_family_70cx2()) |
| 346 | if (extline == TMS7000_INT1_LINE && chip_is_family_70cx2()) |
| 345 | 347 | m_timer_capture_latch[1] = m_timer_decrementer[1]; |
| 346 | 348 | |
| 347 | 349 | // clear external if it's edge-triggered (70cx2-only) |
| 348 | | if (m_io_control[2] & (0x02 << (4 * irqline))) |
| 349 | | m_irq_state[irqline] = false; |
| 350 | if (m_io_control[2] & (0x02 << (4 * extline))) |
| 351 | m_irq_state[extline] = false; |
| 350 | 352 | |
| 351 | 353 | check_interrupts(); |
| 352 | 354 | } |
| 353 | 355 | } |
| 354 | 356 | } |
| 355 | 357 | |
| 356 | | void tms7000_device::flag_ext_interrupt(int irqline) |
| 358 | void tms7000_device::flag_ext_interrupt(int extline) |
| 357 | 359 | { |
| 358 | | if (irqline != TMS7000_INT1_LINE && irqline != TMS7000_INT3_LINE) |
| 360 | if (extline != TMS7000_INT1_LINE && extline != TMS7000_INT3_LINE) |
| 359 | 361 | return; |
| 360 | 362 | |
| 361 | 363 | // set/clear for pending external interrupt |
| 362 | | if (m_irq_state[irqline]) |
| 363 | | m_io_control[0] |= (0x02 << (4 * irqline)); |
| 364 | if (m_irq_state[extline]) |
| 365 | m_io_control[0] |= (0x02 << (4 * extline)); |
| 364 | 366 | else |
| 365 | | m_io_control[0] &= ~(0x02 << (4 * irqline)); |
| 367 | m_io_control[0] &= ~(0x02 << (4 * extline)); |
| 366 | 368 | } |
| 367 | 369 | |
| 368 | 370 | void tms7000_device::check_interrupts() |
| r31334 | r31335 | |
| 381 | 383 | { |
| 382 | 384 | // ack |
| 383 | 385 | m_io_control[irqline > 2] &= ~(0x02 << shift); |
| 384 | | |
| 385 | | flag_ext_interrupt(irqline); |
| 386 | if (irqline == 0 || irqline == 2) |
| 387 | flag_ext_interrupt(irqline / 2); |
| 388 | |
| 386 | 389 | do_interrupt(irqline); |
| 387 | 390 | return; |
| 388 | 391 | } |
| r31334 | r31335 | |
| 509 | 512 | return m_port_ddr[offset / 2 - 2]; |
| 510 | 513 | |
| 511 | 514 | default: |
| 512 | | logerror("%s: tms7000_pf_r @ $%04x\n", tag(), offset); |
| 515 | logerror("'%s' (%04X): tms7000_pf_r @ $%04x\n", tag(), m_pc, offset); |
| 513 | 516 | break; |
| 514 | 517 | } |
| 515 | 518 | |
| r31334 | r31335 | |
| 593 | 596 | break; |
| 594 | 597 | |
| 595 | 598 | default: |
| 596 | | logerror("%s: tms7000_pf_w @ $%04x = $%02x\n", tag(), offset, data); |
| 599 | logerror("'%s' (%04X): tms7000_pf_w @ $%04x = $%02x\n", tag(), m_pc, offset, data); |
| 597 | 600 | break; |
| 598 | 601 | } |
| 599 | 602 | } |
trunk/src/emu/cpu/tms7000/tms7000.h
| r31334 | r31335 | |
| 57 | 57 | tms7000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 58 | 58 | tms7000_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, address_map_constructor internal, UINT32 info_flags, const char *shortname, const char *source); |
| 59 | 59 | |
| 60 | | DECLARE_READ8_MEMBER(tms7000_unmapped_rf_r) { logerror("%s: unmapped_rf_r @ $%04x\n", tag(), offset + 0x80); return 0; }; |
| 61 | | DECLARE_WRITE8_MEMBER(tms7000_unmapped_rf_w) { logerror("%s: unmapped_rf_w @ $%04x = $%02x\n", tag(), offset + 0x80, data); }; |
| 60 | DECLARE_READ8_MEMBER(tms7000_unmapped_rf_r) { logerror("'%s' (%04X): unmapped_rf_r @ $%04x\n", tag(), m_pc, offset + 0x80); return 0; }; |
| 61 | DECLARE_WRITE8_MEMBER(tms7000_unmapped_rf_w) { logerror("'%s' (%04X): unmapped_rf_w @ $%04x = $%02x\n", tag(), m_pc, offset + 0x80, data); }; |
| 62 | 62 | |
| 63 | 63 | DECLARE_READ8_MEMBER(tms7000_pf_r); |
| 64 | 64 | DECLARE_WRITE8_MEMBER(tms7000_pf_w); |
| r31334 | r31335 | |
| 83 | 83 | virtual UINT32 execute_max_cycles() const { return 49; } |
| 84 | 84 | virtual UINT32 execute_input_lines() const { return 2; } |
| 85 | 85 | virtual void execute_run(); |
| 86 | | virtual void execute_set_input(int irqline, int state); |
| 86 | virtual void execute_set_input(int extline, int state); |
| 87 | 87 | |
| 88 | 88 | // device_memory_interface overrides |
| 89 | 89 | virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_PROGRAM) ? &m_program_config : ( (spacenum == AS_IO) ? &m_io_config : NULL ); } |
| r31334 | r31335 | |
| 128 | 128 | UINT8 m_port_latch[4]; |
| 129 | 129 | UINT8 m_port_ddr[4]; |
| 130 | 130 | |
| 131 | | void flag_ext_interrupt(int irqline); |
| 131 | void flag_ext_interrupt(int extline); |
| 132 | 132 | void check_interrupts(); |
| 133 | 133 | void do_interrupt(int irqline); |
| 134 | 134 | |