trunk/src/emu/machine/pit8253.c
| r31679 | r31680 | |
| 703 | 703 | |
| 704 | 704 | |
| 705 | 705 | /* This emulates timer "timer" for "elapsed_cycles" cycles, broken down into |
| 706 | | sections punctuated by callbacks. |
| 707 | | |
| 708 | | The loop technically should never execute even once. It's here to eliminate |
| 709 | | the following potential bug: |
| 710 | | |
| 711 | | 1) The mame timer isn't perfectly accurate. |
| 712 | | 2) The output callback is executed too late, after an update which |
| 713 | | brings the timer's local time past the callback time. |
| 714 | | 3) A short pulse is skipped. |
| 715 | | 4) That short pulse would have triggered an interrupt. The interrupt is |
| 716 | | skipped. |
| 717 | | |
| 718 | | This is a loop instead of an "if" statement in case the mame timer is |
| 719 | | inaccurate by more than one cycle, and the output changed multiple |
| 720 | | times during the discrepancy. In practice updates should still be O(1). |
| 721 | | */ |
| 706 | sections punctuated by callbacks. */ |
| 722 | 707 | void pit8253_device::simulate(pit8253_timer *timer, INT64 elapsed_cycles) |
| 723 | 708 | { |
| 724 | 709 | if (elapsed_cycles > 0) |
| r31679 | r31680 | |
| 1061 | 1046 | void pit8253_device::gate_w(int gate, int state) |
| 1062 | 1047 | { |
| 1063 | 1048 | pit8253_timer *timer = get_timer(gate); |
| 1064 | | assert(timer != 0); |
| 1065 | 1049 | |
| 1066 | | LOG2(("pit8253 : gate_w(): gate=%d state=%d\n", gate, state)); |
| 1067 | | |
| 1068 | 1050 | if (timer == NULL) |
| 1069 | 1051 | return; |
| 1070 | 1052 | |
| 1053 | LOG2(("pit8253 : gate_w(): gate=%d state=%d\n", gate, state)); |
| 1054 | |
| 1071 | 1055 | if (state != timer->gate) |
| 1072 | 1056 | { |
| 1073 | 1057 | int mode = CTRL_MODE(timer->control); |
| r31679 | r31680 | |
| 1103 | 1087 | void pit8253_device::set_clockin(int timerno, double new_clockin) |
| 1104 | 1088 | { |
| 1105 | 1089 | pit8253_timer *timer = get_timer(timerno); |
| 1106 | | assert(timer != 0); |
| 1090 | assert(timer != NULL); |
| 1107 | 1091 | |
| 1108 | 1092 | LOG2(("pit8253_set_clockin(): PIT timer=%d, clockin = %lf\n", timerno, new_clockin)); |
| 1109 | 1093 | |
| r31679 | r31680 | |
| 1116 | 1100 | void pit8253_device::set_clock_signal(int timerno, int state) |
| 1117 | 1101 | { |
| 1118 | 1102 | pit8253_timer *timer = get_timer(timerno); |
| 1119 | | assert(timer != 0); |
| 1103 | assert(timer != NULL); |
| 1120 | 1104 | |
| 1121 | 1105 | LOG2(("pit8253_set_clock_signal(): PIT timer=%d, state = %d\n", timerno, state)); |
| 1122 | 1106 | |