Previous 199869 Revisions Next

r31680 Sunday 17th August, 2014 at 15:16:33 UTC by hap
fix an assert
[src/emu/machine]pit8253.c

trunk/src/emu/machine/pit8253.c
r31679r31680
703703
704704
705705/* 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. */
722707void pit8253_device::simulate(pit8253_timer *timer, INT64 elapsed_cycles)
723708{
724709   if (elapsed_cycles > 0)
r31679r31680
10611046void pit8253_device::gate_w(int gate, int state)
10621047{
10631048   pit8253_timer *timer = get_timer(gate);
1064   assert(timer != 0);
10651049
1066   LOG2(("pit8253 : gate_w(): gate=%d state=%d\n", gate, state));
1067
10681050   if (timer == NULL)
10691051      return;
10701052
1053   LOG2(("pit8253 : gate_w(): gate=%d state=%d\n", gate, state));
1054
10711055   if (state != timer->gate)
10721056   {
10731057      int mode = CTRL_MODE(timer->control);
r31679r31680
11031087void pit8253_device::set_clockin(int timerno, double new_clockin)
11041088{
11051089   pit8253_timer *timer = get_timer(timerno);
1106   assert(timer != 0);
1090   assert(timer != NULL);
11071091
11081092   LOG2(("pit8253_set_clockin(): PIT timer=%d, clockin = %lf\n", timerno, new_clockin));
11091093
r31679r31680
11161100void pit8253_device::set_clock_signal(int timerno, int state)
11171101{
11181102   pit8253_timer *timer = get_timer(timerno);
1119   assert(timer != 0);
1103   assert(timer != NULL);
11201104
11211105   LOG2(("pit8253_set_clock_signal(): PIT timer=%d, state = %d\n", timerno, state));
11221106

Previous 199869 Revisions Next


© 1997-2024 The MAME Team