trunk/src/emu/diexec.c
| r20627 | r20628 | |
| 79 | 79 | m_timed_interrupt_period(attotime::zero), |
| 80 | 80 | m_is_octal(false), |
| 81 | 81 | m_nextexec(NULL), |
| 82 | | m_driver_irq(0), |
| 82 | m_driver_irq_legacy(0), |
| 83 | 83 | m_timedint_timer(NULL), |
| 84 | 84 | m_profiler(PROFILER_IDLE), |
| 85 | 85 | m_icountptr(NULL), |
| r20627 | r20628 | |
| 263 | 263 | |
| 264 | 264 | void device_execute_interface::set_irq_acknowledge_callback(device_irq_acknowledge_callback callback) |
| 265 | 265 | { |
| 266 | | m_driver_irq = callback; |
| 266 | m_driver_irq_legacy = callback; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | |
| 270 | 270 | //------------------------------------------------- |
| 271 | // set_irq_acknowledge_callback - install a driver-specific |
| 272 | // callback for IRQ acknowledge |
| 273 | //------------------------------------------------- |
| 274 | |
| 275 | void device_execute_interface::set_irq_acknowledge_callback(device_irq_acknowledge_delegate callback) |
| 276 | { |
| 277 | m_driver_irq = callback; |
| 278 | m_driver_irq_legacy = NULL; |
| 279 | } |
| 280 | |
| 281 | //------------------------------------------------- |
| 271 | 282 | // suspend - set a suspend reason for this device |
| 272 | 283 | //------------------------------------------------- |
| 273 | 284 | |
| r20627 | r20628 | |
| 512 | 523 | // bind delegates |
| 513 | 524 | m_vblank_interrupt.bind_relative_to(device()); |
| 514 | 525 | m_timed_interrupt.bind_relative_to(device()); |
| 515 | | // m_driver_irq.bind_relative_to(device()); |
| 526 | m_driver_irq.bind_relative_to(device()); |
| 516 | 527 | |
| 517 | 528 | // fill in the initial states |
| 518 | 529 | execute_interface_iterator iter(device().machine().root_device()); |
| r20627 | r20628 | |
| 653 | 664 | LOG(("static_standard_irq_callback('%s', %d) $%04x\n", device().tag(), irqline, vector)); |
| 654 | 665 | |
| 655 | 666 | // if there's a driver callback, run it to get the vector |
| 656 | | if (m_driver_irq != NULL) |
| 657 | | vector = (*m_driver_irq)(&device(), irqline); |
| 667 | if (m_driver_irq_legacy != NULL) |
| 668 | vector = (*m_driver_irq_legacy)(&device(), irqline); |
| 669 | else if (!m_driver_irq.isnull()) |
| 670 | vector = m_driver_irq(device(),irqline); |
| 658 | 671 | |
| 659 | 672 | // notify the debugger |
| 660 | 673 | debugger_interrupt_hook(&device(), irqline); |
trunk/src/emu/diexec.h
| r20627 | r20628 | |
| 101 | 101 | |
| 102 | 102 | // IRQ callback to be called by device implementations when an IRQ is actually taken |
| 103 | 103 | #define IRQ_CALLBACK(func) int func(device_t *device, int irqline) |
| 104 | #define IRQ_CALLBACK_MEMBER(func) int func(device_t &device, int irqline) |
| 104 | 105 | |
| 105 | 106 | // interrupt generator callback called as a VBLANK or periodic interrupt |
| 106 | 107 | #define INTERRUPT_GEN(func) void func(device_t *device) |
| r20627 | r20628 | |
| 141 | 142 | typedef void (*device_interrupt_func)(device_t *device); |
| 142 | 143 | |
| 143 | 144 | // IRQ callback to be called by executing devices when an IRQ is actually taken |
| 144 | | typedef device_delegate<void (device_t &, int)> device_irq_acknowledge_delegate; |
| 145 | typedef device_delegate<int (device_t &, int)> device_irq_acknowledge_delegate; |
| 145 | 146 | typedef int (*device_irq_acknowledge_callback)(device_t *device, int irqnum); |
| 146 | 147 | |
| 147 | 148 | |
| r20627 | r20628 | |
| 190 | 191 | void set_input_line_and_vector(int linenum, int state, int vector) { m_input[linenum].set_state_synced(state, vector); } |
| 191 | 192 | int input_state(int linenum) { return m_input[linenum].m_curstate; } |
| 192 | 193 | void set_irq_acknowledge_callback(device_irq_acknowledge_callback callback); |
| 194 | void set_irq_acknowledge_callback(device_irq_acknowledge_delegate callback); |
| 193 | 195 | |
| 194 | 196 | // suspend/resume |
| 195 | 197 | void suspend(UINT32 reason, bool eatcycles); |
| r20627 | r20628 | |
| 292 | 294 | device_execute_interface *m_nextexec; // pointer to the next device to execute, in order |
| 293 | 295 | |
| 294 | 296 | // input states and IRQ callbacks |
| 295 | | device_irq_acknowledge_callback m_driver_irq; // driver-specific IRQ callback |
| 297 | device_irq_acknowledge_callback m_driver_irq_legacy;// driver-specific IRQ callback |
| 298 | device_irq_acknowledge_delegate m_driver_irq; // driver-specific IRQ callback |
| 296 | 299 | device_input m_input[MAX_INPUT_LINES]; // data about inputs |
| 297 | 300 | emu_timer * m_timedint_timer; // reference to this device's periodic interrupt timer |
| 298 | 301 | |
trunk/src/mess/machine/vector06.c
| r20627 | r20628 | |
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | | static IRQ_CALLBACK( vector06_irq_callback ) |
| 133 | IRQ_CALLBACK_MEMBER(vector06_state::vector06_irq_callback) |
| 134 | 134 | { |
| 135 | 135 | // Interupt is RST 7 |
| 136 | 136 | return 0xff; |
| r20627 | r20628 | |
| 170 | 170 | { |
| 171 | 171 | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 172 | 172 | |
| 173 | | machine().device("maincpu")->execute().set_irq_acknowledge_callback(vector06_irq_callback); |
| 173 | machine().device("maincpu")->execute().set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(vector06_state::vector06_irq_callback),this)); |
| 174 | 174 | space.install_read_bank (0x0000, 0x7fff, "bank1"); |
| 175 | 175 | space.install_write_bank(0x0000, 0x7fff, "bank2"); |
| 176 | 176 | space.install_read_bank (0x8000, 0xffff, "bank3"); |
trunk/src/mess/drivers/cat.c
| r20627 | r20628 | |
| 205 | 205 | TIMER_CALLBACK_MEMBER(keyboard_callback); |
| 206 | 206 | TIMER_CALLBACK_MEMBER(counter_6ms_callback); |
| 207 | 207 | TIMER_CALLBACK_MEMBER(swyft_reset); |
| 208 | IRQ_CALLBACK_MEMBER(cat_int_ack); |
| 208 | 209 | }; |
| 209 | 210 | |
| 210 | 211 | // TODO: this init doesn't actually work yet! please fix me! |
| r20627 | r20628 | |
| 681 | 682 | m_6ms_counter++; |
| 682 | 683 | } |
| 683 | 684 | |
| 684 | | static IRQ_CALLBACK(cat_int_ack) |
| 685 | IRQ_CALLBACK_MEMBER(cat_state::cat_int_ack) |
| 685 | 686 | { |
| 686 | | device->machine().device("maincpu")->execute().set_input_line(M68K_IRQ_1,CLEAR_LINE); |
| 687 | machine().device("maincpu")->execute().set_input_line(M68K_IRQ_1,CLEAR_LINE); |
| 687 | 688 | return M68K_INT_ACK_AUTOVECTOR; |
| 688 | 689 | } |
| 689 | 690 | |
| r20627 | r20628 | |
| 700 | 701 | |
| 701 | 702 | MACHINE_RESET_MEMBER(cat_state,cat) |
| 702 | 703 | { |
| 703 | | machine().device("maincpu")->execute().set_irq_acknowledge_callback(cat_int_ack); |
| 704 | machine().device("maincpu")->execute().set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(cat_state::cat_int_ack),this)); |
| 704 | 705 | m_6ms_counter = 0; |
| 705 | 706 | m_keyboard_timer->adjust(attotime::zero, 0, attotime::from_hz(120)); |
| 706 | 707 | m_6ms_timer->adjust(attotime::zero, 0, attotime::from_hz((XTAL_19_968MHz/2)/65536)); |
trunk/src/mess/drivers/pc100.c
| r20627 | r20628 | |
| 115 | 115 | TIMER_DEVICE_CALLBACK_MEMBER(pc100_100hz_irq); |
| 116 | 116 | TIMER_DEVICE_CALLBACK_MEMBER(pc100_50hz_irq); |
| 117 | 117 | TIMER_DEVICE_CALLBACK_MEMBER(pc100_10hz_irq); |
| 118 | IRQ_CALLBACK_MEMBER(pc100_irq_callback); |
| 118 | 119 | }; |
| 119 | 120 | |
| 120 | 121 | void pc100_state::video_start() |
| r20627 | r20628 | |
| 399 | 400 | DEVCB_DRIVER_MEMBER(pc100_state, crtc_bank_w) |
| 400 | 401 | }; |
| 401 | 402 | |
| 402 | | static IRQ_CALLBACK(pc100_irq_callback) |
| 403 | IRQ_CALLBACK_MEMBER(pc100_state::pc100_irq_callback) |
| 403 | 404 | { |
| 404 | | return pic8259_acknowledge( device->machine().device( "pic8259" ) ); |
| 405 | return pic8259_acknowledge( device.machine().device( "pic8259" ) ); |
| 405 | 406 | } |
| 406 | 407 | |
| 407 | 408 | WRITE_LINE_MEMBER( pc100_state::pc100_set_int_line ) |
| r20627 | r20628 | |
| 419 | 420 | |
| 420 | 421 | void pc100_state::machine_start() |
| 421 | 422 | { |
| 422 | | machine().device("maincpu")->execute().set_irq_acknowledge_callback(pc100_irq_callback); |
| 423 | machine().device("maincpu")->execute().set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(pc100_state::pc100_irq_callback),this)); |
| 423 | 424 | m_kanji_rom = (UINT16 *)(*machine().root_device().memregion("kanji")); |
| 424 | 425 | m_vram = (UINT16 *)(*memregion("vram")); |
| 425 | 426 | } |