Previous 15994 Revisions Next

r5617 Monday 7th September, 2009 at 05:44:22 UTC by Roberto Zandonà
[C64] partial cia fix: avoid timer's de-sync in read count operation
[src/emu/machine]6526cia.c

src/emu/machine/6526cia.c
r5616r5617
361361   }
362362}
363363
364/*-------------------------------------------------
365    cia_get_timer - get the count
366    for a given CIA timer
367-------------------------------------------------*/
364368
369static UINT16 cia_get_timer(cia_timer *timer)
370{
371   UINT16 count;
372
373   if (is_timer_active(timer->timer))
374   {
375      UINT16 current_count = attotime_to_double(attotime_mul(timer_timeelapsed(timer->timer), timer->cia->device->clock));
376      count = timer->count - MIN(timer->count, current_count);
377   }
378   else
379      count = timer->count;
380
381   return count;
382}
383
365384/*-------------------------------------------------
366385    cia_timer_bump
367386-------------------------------------------------*/
r5616r5617
684703      case CIA_TALO:
685704      case CIA_TBLO:
686705         timer = &cia->timer[(offset >> 1) & 1];
687         cia_timer_update(timer, -1);
688         data = timer->count >> 0;
706         data = cia_get_timer(timer) >> 0;
689707         break;
690708
691709      /* timer A/B high byte */
692710      case CIA_TAHI:
693711      case CIA_TBHI:
694712         timer = &cia->timer[(offset >> 1) & 1];
695         cia_timer_update(timer, -1);
696         data = timer->count >> 8;
713         data = cia_get_timer(timer) >> 8;
697714         break;
698715
699716      /* TOD counter */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team