home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / packery / xpk_source / xpkmaster / progress.c < prev    next >
C/C++ Source or Header  |  1996-10-28  |  1KB  |  57 lines

  1. #ifndef XPKMASTER_PROGRESS_C
  2. #define XPKMASTER_PROGRESS_C
  3.  
  4. /* Routinesheader
  5.  
  6.     Name:        progress.c
  7.     Main:        xpkmaster
  8.     Versionstring:    $VER: progress.c 1.0 (06.10.96)
  9.     Author:        SDI
  10.     Distribution:    PD
  11.     Description:    Progress report handler
  12.  
  13.  1.0   06.10.96 : first real version
  14. */
  15.  
  16. #include <exec/types.h>
  17. #include <pragma/intuition_lib.h>
  18. #include "xpkmaster.h"
  19.  
  20. LONG callprogress(struct XpkBuffer *xbuf)
  21. {
  22.   struct XpkProgress *prog = &xbuf->xb_Prog;
  23.  
  24.   if(!xbuf->xb_ChunkHook)
  25.     return 0;
  26.  
  27.   if(prog->xp_ULen)
  28.   {
  29.     ULONG secs, mics, time, freq;
  30.  
  31.     /* ToDo: Test for >=V36 and use ReadEClock */
  32.     CurrentTime(&secs, &mics);
  33.     freq = 128;
  34. /*  time = (secs - xbuf->xb_Secs)*freq + mics/(1000000/freq) - xbuf->xb_Mics/(1000000/freq); */
  35.     time = (secs - xbuf->xb_Secs)*freq + (mics+1000000-xbuf->xb_Mics)/(1000000/freq) - freq;
  36.  
  37.     if (prog->xp_UCur < 30000000)
  38.       prog->xp_Speed = (freq * prog->xp_UCur) / (time + 1);
  39.     else
  40.       prog->xp_Speed = prog->xp_UCur / (time/freq + 1);
  41.  
  42.     prog->xp_Done = prog->xp_ULen ? 100 * prog->xp_UCur/prog->xp_ULen : 100;
  43.     if(prog->xp_UCur > 20)
  44.       if((prog->xp_CF = 100 - 100 * prog->xp_CCur / prog->xp_UCur) < 0)
  45.     prog->xp_CF = 0;
  46.   }
  47.   else
  48.     prog->xp_Speed = 0;
  49.  
  50.   if(MyCallHookPkt(xbuf->xb_ChunkHook, prog A4SUPP2))
  51.     xbuf->xb_Result = XPKERR_ABORTED;
  52.  
  53.   return xbuf->xb_Result;
  54. }
  55.  
  56. #endif /* XPKMASTER_PROGRESS_C */
  57.