src/mess/machine/tms9901.c
| r15460 | r15461 | |
| 99 | 99 | |
| 100 | 100 | #include "tms9901.h" |
| 101 | 101 | |
| 102 | #define VERBOSE 1 |
| 103 | #define LOG logerror |
| 104 | |
| 102 | 105 | /* |
| 103 | 106 | Constructor |
| 104 | 107 | */ |
| r15460 | r15461 | |
| 120 | 123 | { /* if timer is enabled, INT3 pin is overriden by timer */ |
| 121 | 124 | if (m_timer_int_pending) |
| 122 | 125 | { |
| 126 | if (VERBOSE>8) LOG("tms9901: timer fires\n"); |
| 123 | 127 | current_ints |= TMS9901_INT3; |
| 124 | 128 | } |
| 125 | | else |
| 129 | else |
| 130 | { |
| 131 | if (VERBOSE>8) LOG("tms9901: timer clear\n"); |
| 126 | 132 | current_ints &= ~TMS9901_INT3; |
| 133 | } |
| 127 | 134 | } |
| 128 | 135 | |
| 129 | 136 | /* enabled_ints: enabled interrupts */ |
| r15460 | r15461 | |
| 315 | 322 | { |
| 316 | 323 | /* we are quitting clock mode */ |
| 317 | 324 | m_clock_mode = false; |
| 325 | if (VERBOSE>5) LOG("tms9901: int mode\n"); |
| 318 | 326 | } |
| 319 | 327 | else |
| 320 | 328 | { |
| 321 | 329 | m_clock_mode = true; |
| 330 | if (VERBOSE>5) LOG("tms9901: clock mode\n"); |
| 322 | 331 | // we are switching to clock mode: latch the current value of |
| 323 | 332 | // the decrementer register |
| 324 | 333 | if (m_clock_register != 0) |
| r15460 | r15461 | |
| 357 | 366 | m_clock_register &= ~mask; /* clear bit */ |
| 358 | 367 | |
| 359 | 368 | /* reset clock timer (page 8) */ |
| 369 | if (VERBOSE>6) LOG("tms9901: clock register = %04x\n", m_clock_register); |
| 360 | 370 | timer_reload(); |
| 361 | 371 | } |
| 362 | 372 | else |
| r15460 | r15461 | |
| 371 | 381 | if (offset == 3) |
| 372 | 382 | m_timer_int_pending = false; /* SBO 3 clears pending timer interrupt (??) */ |
| 373 | 383 | |
| 384 | if (VERBOSE>6) LOG("tms9901: interrupts = %04x\n", m_enabled_ints); |
| 374 | 385 | field_interrupts(); /* changed interrupt state */ |
| 375 | 386 | } |
| 376 | 387 | break; |
| r15460 | r15461 | |
| 388 | 399 | // Spec is not clear on whether the mask bits are also reset by RST2* |
| 389 | 400 | // TODO: Check on a real machine. (I'd guess from the text they are not touched) |
| 390 | 401 | m_enabled_ints = 0; |
| 402 | if (VERBOSE>5) LOG("tms9901: Soft reset (RST2*)\n"); |
| 391 | 403 | } |
| 392 | 404 | } |
| 393 | 405 | else |
| r15460 | r15461 | |
| 397 | 409 | else |
| 398 | 410 | m_enabled_ints &= ~0x4000; /* unset bit */ |
| 399 | 411 | |
| 412 | if (VERBOSE>6) LOG("tms9901: interrupts = %04x\n", m_enabled_ints); |
| 400 | 413 | field_interrupts(); /* changed interrupt state */ |
| 401 | 414 | } |
| 402 | 415 | break; |
| r15460 | r15461 | |
| 417 | 430 | case 0x1E: |
| 418 | 431 | case 0x1F: |
| 419 | 432 | int pin = offset & 0x0F; |
| 433 | if (VERBOSE>6) LOG("tms9901: output on P%d = %d\n", pin, data); |
| 420 | 434 | int mask = (1 << pin); |
| 421 | 435 | |
| 422 | 436 | // MZ: see above - I think this is wrong |
| r15460 | r15461 | |
| 460 | 474 | if (id==DECREMENTER) // we have only that one |
| 461 | 475 | { |
| 462 | 476 | m_decrementer_value--; |
| 477 | if (VERBOSE>6) LOG("tms9901: decrementer = %d\n", m_decrementer_value); |
| 463 | 478 | if (m_decrementer_value<=0) |
| 464 | 479 | { |
| 465 | 480 | m_timer_int_pending = true; // decrementer interrupt requested |