}
mng_retcode interframe_delay (mng_datap pData){  mng_uint32  iWaitfor;  mng_uint32  iInterval;  mng_uint32  iRuninterval;  mng_retcode iRetcode;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_INTERFRAME_DELAY, MNG_LC_START)#endif  if (!pData->bSearching)              /* we mustn't be searching !!! */  {    if (!pData->bRunning)              /* sanity check for frozen status */      MNG_WARNING (pData, MNG_IMAGEFROZEN)    if (pData->iFramedelay > 0)        /* let the app refresh first */    {      if ((pData->iUpdatetop < pData->iUpdatebottom) && (pData->iUpdateleft < pData->iUpdateright))        if (!pData->fRefresh (((mng_handle)pData),                              pData->iUpdateleft,  pData->iUpdatetop,                              pData->iUpdateright - pData->iUpdateleft,                              pData->iUpdatebottom - pData->iUpdatetop))          MNG_ERROR (pData, MNG_APPMISCERROR)      pData->iUpdateleft   = 0;        /* reset update-region */      pData->iUpdateright  = 0;      pData->iUpdatetop    = 0;      pData->iUpdatebottom = 0;        /* reset refreshneeded indicator */      pData->bNeedrefresh  = MNG_FALSE;    }                                       /* get current tickcount */    pData->iRuntime = pData->fGettickcount ((mng_handle)pData);                                       /* calculate interval since last sync-point */    if (pData->iRuntime < pData->iSynctime)      iRuninterval    = pData->iRuntime + ~pData->iSynctime + 1;    else      iRuninterval    = pData->iRuntime - pData->iSynctime;                                       /* calculate actual run-time */    if (pData->iRuntime < pData->iStarttime)      pData->iRuntime = pData->iRuntime + ~pData->iStarttime + 1;    else      pData->iRuntime = pData->iRuntime - pData->iStarttime;    if (pData->iTicks)                 /* what are we aiming for */    {      switch (pData->iSpeed)           /* honor speed modifier */      {        case mng_st_fast :          {            iWaitfor = (mng_uint32)(( 500 * pData->iFramedelay) / pData->iTicks);            break;          }        case mng_st_slow :          {            iWaitfor = (mng_uint32)((3000 * pData->iFramedelay) / pData->iTicks);            break;          }        case mng_st_slowest :          {            iWaitfor = (mng_uint32)((8000 * pData->iFramedelay) / pData->iTicks);            break;          }        default :          {            iWaitfor = (mng_uint32)((1000 * pData->iFramedelay) / pData->iTicks);          }      }    }    else      iWaitfor = 1000;    if (iWaitfor > iRuninterval)       /* delay necessary ? */      iInterval = iWaitfor - iRuninterval;    else      iInterval = 1;                   /* force app to process messageloop */                                       /* set the timer */    iRetcode = set_delay (pData, iInterval);    if (iRetcode)                      /* on error bail out */      return iRetcode;                                       /* increase frametime in advance */    pData->iFrametime  = pData->iFrametime + iWaitfor;                                       /* setup for next delay */    pData->iFramedelay = pData->iNextdelay;  }#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_INTERFRAME_DELAY, MNG_LC_END)#endif  return MNG_NOERROR;}