home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / util / perfmeter-2.2.lha / PerfMeter / perfmeter.c < prev    next >
C/C++ Source or Header  |  1992-12-03  |  20KB  |  728 lines

  1. ;/*    PerfMeter by Digital Design, Inc.
  2.  
  3. lc -j73 -v -y -ba perfmeter.c
  4. blink lib:cback.o+perfmeter.o to perfmeter lib lib:lc.lib+lib:amiga.lib
  5. quit
  6.  
  7.     Author:        Juha 'Comm' Tuominen / Digital Design
  8.     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9.     Released:    15-Jul-91    v1.10
  10.     Revised:    07-Sep-91    v1.11
  11.     Revised:    08-Sep-91    v1.12
  12.     Revised:    18-Sep-91    v1.2    (needs KS2.0 now)
  13.     Revised:    19-Oct-91    v1.21    (uptime bug fixed)
  14.     Revised:    04-Nov-91    v2.0    (major bug fixing)
  15.     Revised:    25-Nov-92    v2.1    (small bug fix)
  16.     Revices:    03-Dec-92    v2.2    (extented font support)
  17.     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18.     Compiler:    SAS/C v5.10->
  19.     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  20. */
  21.  
  22. #include <exec/types.h>
  23. #include <exec/memory.h>
  24. #include <exec/execbase.h>
  25. #include <exec/tasks.h>
  26. #include <libraries/dos.h>
  27. #include <devices/timer.h>
  28. #include <intuition/intuitionbase.h>
  29. #include <libraries/diskfont.h>
  30. #include <graphics/rastport.h>
  31. #include <graphics/gfx.h>
  32. #include <graphics/gfxbase.h>
  33. #include <graphics/gfxmacros.h>
  34. #include <graphics/text.h>
  35. #include <proto/all.h>
  36. #include <string.h>
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39.  
  40. #define STACK_SIZE 1000L    /* Arska's stack size */
  41.  
  42. #define NAME         "Perfmeter"
  43. #define VERSION        2
  44. #define REVISION    2
  45. #define DATE        "02.12.92"
  46. #define VERS        "Perfmeter 2.2"
  47. #define VSTRING        "PerfMeter 2.2 (03.12.92)\n\0"
  48. #define VERSTAG        "\0$VER: Perfmeter 2.2 (03.12.92)\0"
  49.  
  50. #define FONTSIZE 8
  51. #define FONTNAME "blob.font"
  52.  
  53. #define WINDOWWIDTH        172
  54. #define WINDOWHEIGTH    130
  55.  
  56. long _stack=16384;
  57. char *_procname=VSTRING;
  58. long _priority=5;
  59. long _BackGroundIO=FALSE;
  60.  
  61. void MemCleanup() {}
  62.  
  63. UBYTE    versiontag[]=VERSTAG;    /* for version command */
  64.  
  65. BOOL    task_added=FALSE,zipped=FALSE,oldzipped=FALSE,timeropen=FALSE,timeropen2=FALSE,
  66.         keepgoing=TRUE,time_requested=FALSE,time_requested2=FALSE;
  67. ULONG    maxchip, maxfast, freechip=0, freefast=0,maxpub,freepub,cputime=NULL,
  68.         cputemp=NULL,prevcpu=68,count=0,chipscale=0, fastscale=0, publicscale=0,
  69.         jakaja=0,cputemp2=0,tag1;
  70. char    processor[10]="68000",*taskname="Arska Väijy",itemname[10]="  Idle";
  71. int        cpuload=0,mode=0,oldmode=1,buffer[7][151],load=0,switchcount=0,upsecs=0,
  72.         upmins=0,uphours=0,updays=0,oldi=0,offset;
  73. UBYTE    xc[]={5,5,5,5,5,5,6,6,6,7,7,7,8,8,9,9,10,11,11,12,13,13,14,15,16,17,18,19,20,20,21,23,24,25,26,27,28,29,30,31,33,34,35,36,38,39,40,41,42,44,45,46,48,49,50,51,52,54,55,56,57,59,60,61,62,63,64,65,66,67,69,70,70,71,72,73,74,75,76,77,77,78,79,79,80,81,81,82,82,83,83,83,84,84,84,85,85,85,85,85,85},
  74.         yc[]={45,46,48,49,50,51,52,54,55,56,57,59,60,61,62,63,64,65,66,67,69,70,70,71,72,73,74,75,76,77,77,78,79,79,80,81,81,82,82,83,83,83,84,84,84,85,85,85,85,85,85,85,85,85,85,85,84,84,84,83,83,83,82,82,81,81,80,79,79,78,77,77,76,75,74,73,72,71,70,70,69,67,66,65,64,63,62,61,60,59,57,56,55,54,52,51,50,49,48,46,45},
  75.         xx[]={15,15,15,15,15,15,15,15,15,16,16,16,16,17,17,17,18,18,18,19,19,20,20,21,21,22,22,23,24,24,25,26,26,27,28,29,29,30,31,32,33,33,34,35,36,37,38,39,40,40,41,42,43,44,45,46,47,48,49,49,50,51,52,53,54,55,56,56,57,58,59,60,60,61,62,63,63,64,65,66,66,67,67,68,69,69,70,70,71,71,72,72,72,73,73,73,74,74,74,74,74,75,75,75,75,75,75,75,75,75},
  76.         yy[]={43,44,45,46,47,48,49,49,50,51,52,53,54,55,56,56,57,58,59,60,60,61,62,63,63,64,65,66,66,67,67,68,69,69,70,70,71,71,72,72,72,73,73,73,74,74,74,74,74,75,75,75,75,75,75,75,75,75,75,75,75,74,74,74,74,73,73,73,72,72,72,71,71,70,70,69,69,68,68,67,66,66,65,64,64,63,62,61,61,60,59,58,57,57,56,55,54,53,52,51,50,50,49,48,47,46,45,44,43,43};
  77. APTR    stack=NULL;
  78. WORD    cordinates[]={0,0,100,65};    /* zipped window cordinates and size */
  79.  
  80.                                                                                
  81. extern    struct ExecBase    *SysBase;
  82. struct    IntuitionBase *IntuitionBase=NULL;
  83. struct    Library *DiskfontBase=NULL;
  84. struct    Window *window=NULL;
  85. struct    IntuiText abouttext[];
  86. struct    IntuiText proceed;
  87. struct    GfxBase *GfxBase=NULL;
  88. struct    MsgPort *timerport=NULL;
  89. struct    timerequest *timermsg=NULL;
  90. struct    MsgPort *timerport2=NULL;
  91. struct    timerequest *timermsg2=NULL;
  92. struct    Task *task=NULL;
  93. struct    TextFont *textfont;
  94.  
  95. struct    NewWindow mywindow =
  96. {    420,
  97.     14,
  98.     WINDOWWIDTH,
  99.     WINDOWHEIGTH,
  100.     0,1,
  101.     CLOSEWINDOW | MENUPICK | NEWSIZE,
  102.     SMART_REFRESH | WINDOWDRAG | WINDOWCLOSE | WINDOWDEPTH,
  103.     NULL,
  104.     NULL,
  105.     "Perfmeter",
  106.     NULL,
  107.     NULL,
  108.     140,
  109.     90,
  110.     NULL,
  111.     NULL,
  112.     WBENCHSCREEN
  113.  
  114. };
  115.  
  116. struct TagItem tagitems[2]={
  117.     {WA_Zoom,&cordinates},
  118.     {0,}
  119. };
  120.  
  121.  
  122. struct TextAttr TOPAZ80 = {(STRPTR)"topaz.font",TOPAZ_EIGHTY,0,0};
  123.  
  124. struct IntuiText abouttext[9] =
  125. {
  126.     {2,1,JAM1,8, 4,(struct TextAttr *)&TOPAZ80,(UBYTE *)VERS,(struct IntuiText *)&abouttext[1]},
  127.     {2,1,JAM1,8,14,(struct TextAttr *)&TOPAZ80,(UBYTE *)"by Juha Tuominen",(struct IntuiText *)&abouttext[2]},
  128.     {2,1,JAM1,8,22,(struct TextAttr *)&TOPAZ80,(UBYTE *)"Copyright © 1992",(struct IntuiText *)&abouttext[3]},
  129.     {2,1,JAM1,8,30,(struct TextAttr *)&TOPAZ80,(UBYTE *)"Digital Design, Inc.",(struct IntuiText *)&abouttext[4]},
  130.     {2,1,JAM1,8,38,(struct TextAttr *)&TOPAZ80,(UBYTE *)" ",(struct IntuiText *)&abouttext[5]},
  131.     {2,1,JAM1,8,46,(struct TextAttr *)&TOPAZ80,(UBYTE *)"Average 88100 load: 0   %",(struct IntuiText *)&abouttext[6]},
  132.     {2,1,JAM1,8,54,(struct TextAttr *)&TOPAZ80,(UBYTE *)" ",(struct IntuiText *)&abouttext[7]},
  133.     {2,1,JAM1,8,62,(struct TextAttr *)&TOPAZ80,(UBYTE *)"Arska Väijy has found",(struct IntuiText *)&abouttext[8]},
  134.     {2,1,JAM1,8,70,(struct TextAttr *)&TOPAZ80,(UBYTE *)"0 perfect numbers.",(struct IntuiText *)NULL}
  135. };
  136.  
  137. struct IntuiText proceed=
  138. {
  139.     2,1,JAM1,5,3,(struct TextAttr *)&TOPAZ80,(UBYTE *)"Continue",(struct IntuiText *)NULL
  140. };
  141.  
  142. /* This menu isn't visually beatufull but do just fine for this program */
  143.  
  144. struct IntuiText IText1={0,1,JAM1,0,0,&TOPAZ80,"Quit",NULL};
  145. struct MenuItem MenuItem9={NULL,0,64,58,8,ITEMTEXT+ITEMENABLED+HIGHBOX,0,(APTR)&IText1,NULL,NULL,NULL,MENUNULL};
  146. struct IntuiText IText2={0,1,JAM1,0,0,&TOPAZ80,"Switch",NULL};
  147. struct MenuItem MenuItem8={&MenuItem9,0,56,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText2,NULL,NULL,NULL,MENUNULL};
  148. struct IntuiText IText3={0,1,JAM1,0,0,&TOPAZ80,"Public",NULL};
  149. struct MenuItem MenuItem7={&MenuItem8,0,48,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText3,NULL,NULL,NULL,MENUNULL};
  150. struct IntuiText IText4={0,1,JAM1,0,0,&TOPAZ80,"Fast",NULL};
  151. struct MenuItem MenuItem6={&MenuItem7,0,40,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText4,NULL,NULL,NULL,MENUNULL};
  152. struct IntuiText IText5={0,1,JAM1,0,0,&TOPAZ80,"Chip",NULL};
  153. struct MenuItem MenuItem5={&MenuItem6,0,32,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText5,NULL,NULL,NULL,MENUNULL};
  154. struct IntuiText IText6={0,1,JAM1,0,0,&TOPAZ80,"Load",NULL};
  155. struct MenuItem MenuItem4={&MenuItem5,0,24,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText6,NULL,NULL,NULL,MENUNULL};
  156. struct IntuiText IText7={0,1,JAM1,0,0,&TOPAZ80,"CPU",NULL};
  157. struct MenuItem MenuItem3={&MenuItem4,0,16,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText7,NULL,NULL,NULL,MENUNULL};
  158. struct IntuiText IText8={0,1,JAM1,0,0,&TOPAZ80,"Idle",NULL};
  159. struct MenuItem MenuItem2={&MenuItem3,0,8,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText8,NULL,NULL,NULL,MENUNULL};
  160. struct IntuiText IText9={0,1,JAM1,0,0,&TOPAZ80,"About",NULL};
  161. struct MenuItem MenuItem1={&MenuItem2,0,0,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText9,NULL,NULL,NULL,MENUNULL};
  162.  
  163. struct Menu Menu1={NULL,0,0,62,0,    MENUENABLED,"Project",&MenuItem1};
  164.  
  165.  
  166.  
  167. void cleanexit(int error);
  168. void openthings(void);
  169. void addtimerequest(long secs, long micros);
  170. void changefont(void);
  171. void addtimerequest2(long secs, long micros);
  172. void uptime(void);
  173. ULONG maxmemsize(long memtype);
  174. void updatewindow(void);
  175. void oddstuff(void);
  176. void idletask(void);
  177. void __saveds switchroutine(void);
  178. void updatezipped(int i);
  179.  
  180.  
  181. void CXBRK(void) 
  182.     cleanexit(0);
  183. }
  184.  
  185. void cleanexit(int error)
  186. {
  187.     if(task_added) RemTask(task);
  188.     if(task) FreeMem(task,sizeof(struct Task));
  189.     if(stack) FreeMem(stack,STACK_SIZE);
  190.     if(timeropen2)
  191.     {    if(time_requested2)
  192.         {
  193.             AbortIO((struct IORequest *)timermsg2);
  194.             WaitIO((struct IORequest *)timermsg2);
  195.         }
  196.         CloseDevice((struct IORequest *)timermsg2);
  197.     }
  198.     if(timermsg2) DeleteExtIO((struct IORequest *)timermsg2);
  199.     if(timerport2) DeletePort(timerport2);
  200.  
  201.     if(timeropen)
  202.     {    if(time_requested)
  203.         {
  204.             AbortIO((struct IORe