home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 9
/
FreshFishVol9-CD2.bin
/
bbs
/
util
/
perfmeter-2.2.lha
/
PerfMeter
/
perfmeter.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-03
|
20KB
|
728 lines
;/* PerfMeter by Digital Design, Inc.
lc -j73 -v -y -ba perfmeter.c
blink lib:cback.o+perfmeter.o to perfmeter lib lib:lc.lib+lib:amiga.lib
quit
Author: Juha 'Comm' Tuominen / Digital Design
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Released: 15-Jul-91 v1.10
Revised: 07-Sep-91 v1.11
Revised: 08-Sep-91 v1.12
Revised: 18-Sep-91 v1.2 (needs KS2.0 now)
Revised: 19-Oct-91 v1.21 (uptime bug fixed)
Revised: 04-Nov-91 v2.0 (major bug fixing)
Revised: 25-Nov-92 v2.1 (small bug fix)
Revices: 03-Dec-92 v2.2 (extented font support)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiler: SAS/C v5.10->
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <exec/execbase.h>
#include <exec/tasks.h>
#include <libraries/dos.h>
#include <devices/timer.h>
#include <intuition/intuitionbase.h>
#include <libraries/diskfont.h>
#include <graphics/rastport.h>
#include <graphics/gfx.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <graphics/text.h>
#include <proto/all.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define STACK_SIZE 1000L /* Arska's stack size */
#define NAME "Perfmeter"
#define VERSION 2
#define REVISION 2
#define DATE "02.12.92"
#define VERS "Perfmeter 2.2"
#define VSTRING "PerfMeter 2.2 (03.12.92)\n\0"
#define VERSTAG "\0$VER: Perfmeter 2.2 (03.12.92)\0"
#define FONTSIZE 8
#define FONTNAME "blob.font"
#define WINDOWWIDTH 172
#define WINDOWHEIGTH 130
long _stack=16384;
char *_procname=VSTRING;
long _priority=5;
long _BackGroundIO=FALSE;
void MemCleanup() {}
UBYTE versiontag[]=VERSTAG; /* for version command */
BOOL task_added=FALSE,zipped=FALSE,oldzipped=FALSE,timeropen=FALSE,timeropen2=FALSE,
keepgoing=TRUE,time_requested=FALSE,time_requested2=FALSE;
ULONG maxchip, maxfast, freechip=0, freefast=0,maxpub,freepub,cputime=NULL,
cputemp=NULL,prevcpu=68,count=0,chipscale=0, fastscale=0, publicscale=0,
jakaja=0,cputemp2=0,tag1;
char processor[10]="68000",*taskname="Arska Väijy",itemname[10]=" Idle";
int cpuload=0,mode=0,oldmode=1,buffer[7][151],load=0,switchcount=0,upsecs=0,
upmins=0,uphours=0,updays=0,oldi=0,offset;
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},
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},
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},
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};
APTR stack=NULL;
WORD cordinates[]={0,0,100,65}; /* zipped window cordinates and size */
extern struct ExecBase *SysBase;
struct IntuitionBase *IntuitionBase=NULL;
struct Library *DiskfontBase=NULL;
struct Window *window=NULL;
struct IntuiText abouttext[];
struct IntuiText proceed;
struct GfxBase *GfxBase=NULL;
struct MsgPort *timerport=NULL;
struct timerequest *timermsg=NULL;
struct MsgPort *timerport2=NULL;
struct timerequest *timermsg2=NULL;
struct Task *task=NULL;
struct TextFont *textfont;
struct NewWindow mywindow =
{ 420,
14,
WINDOWWIDTH,
WINDOWHEIGTH,
0,1,
CLOSEWINDOW | MENUPICK | NEWSIZE,
SMART_REFRESH | WINDOWDRAG | WINDOWCLOSE | WINDOWDEPTH,
NULL,
NULL,
"Perfmeter",
NULL,
NULL,
140,
90,
NULL,
NULL,
WBENCHSCREEN
};
struct TagItem tagitems[2]={
{WA_Zoom,&cordinates},
{0,}
};
struct TextAttr TOPAZ80 = {(STRPTR)"topaz.font",TOPAZ_EIGHTY,0,0};
struct IntuiText abouttext[9] =
{
{2,1,JAM1,8, 4,(struct TextAttr *)&TOPAZ80,(UBYTE *)VERS,(struct IntuiText *)&abouttext[1]},
{2,1,JAM1,8,14,(struct TextAttr *)&TOPAZ80,(UBYTE *)"by Juha Tuominen",(struct IntuiText *)&abouttext[2]},
{2,1,JAM1,8,22,(struct TextAttr *)&TOPAZ80,(UBYTE *)"Copyright © 1992",(struct IntuiText *)&abouttext[3]},
{2,1,JAM1,8,30,(struct TextAttr *)&TOPAZ80,(UBYTE *)"Digital Design, Inc.",(struct IntuiText *)&abouttext[4]},
{2,1,JAM1,8,38,(struct TextAttr *)&TOPAZ80,(UBYTE *)" ",(struct IntuiText *)&abouttext[5]},
{2,1,JAM1,8,46,(struct TextAttr *)&TOPAZ80,(UBYTE *)"Average 88100 load: 0 %",(struct IntuiText *)&abouttext[6]},
{2,1,JAM1,8,54,(struct TextAttr *)&TOPAZ80,(UBYTE *)" ",(struct IntuiText *)&abouttext[7]},
{2,1,JAM1,8,62,(struct TextAttr *)&TOPAZ80,(UBYTE *)"Arska Väijy has found",(struct IntuiText *)&abouttext[8]},
{2,1,JAM1,8,70,(struct TextAttr *)&TOPAZ80,(UBYTE *)"0 perfect numbers.",(struct IntuiText *)NULL}
};
struct IntuiText proceed=
{
2,1,JAM1,5,3,(struct TextAttr *)&TOPAZ80,(UBYTE *)"Continue",(struct IntuiText *)NULL
};
/* This menu isn't visually beatufull but do just fine for this program */
struct IntuiText IText1={0,1,JAM1,0,0,&TOPAZ80,"Quit",NULL};
struct MenuItem MenuItem9={NULL,0,64,58,8,ITEMTEXT+ITEMENABLED+HIGHBOX,0,(APTR)&IText1,NULL,NULL,NULL,MENUNULL};
struct IntuiText IText2={0,1,JAM1,0,0,&TOPAZ80,"Switch",NULL};
struct MenuItem MenuItem8={&MenuItem9,0,56,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText2,NULL,NULL,NULL,MENUNULL};
struct IntuiText IText3={0,1,JAM1,0,0,&TOPAZ80,"Public",NULL};
struct MenuItem MenuItem7={&MenuItem8,0,48,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText3,NULL,NULL,NULL,MENUNULL};
struct IntuiText IText4={0,1,JAM1,0,0,&TOPAZ80,"Fast",NULL};
struct MenuItem MenuItem6={&MenuItem7,0,40,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText4,NULL,NULL,NULL,MENUNULL};
struct IntuiText IText5={0,1,JAM1,0,0,&TOPAZ80,"Chip",NULL};
struct MenuItem MenuItem5={&MenuItem6,0,32,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText5,NULL,NULL,NULL,MENUNULL};
struct IntuiText IText6={0,1,JAM1,0,0,&TOPAZ80,"Load",NULL};
struct MenuItem MenuItem4={&MenuItem5,0,24,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText6,NULL,NULL,NULL,MENUNULL};
struct IntuiText IText7={0,1,JAM1,0,0,&TOPAZ80,"CPU",NULL};
struct MenuItem MenuItem3={&MenuItem4,0,16,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText7,NULL,NULL,NULL,MENUNULL};
struct IntuiText IText8={0,1,JAM1,0,0,&TOPAZ80,"Idle",NULL};
struct MenuItem MenuItem2={&MenuItem3,0,8,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText8,NULL,NULL,NULL,MENUNULL};
struct IntuiText IText9={0,1,JAM1,0,0,&TOPAZ80,"About",NULL};
struct MenuItem MenuItem1={&MenuItem2,0,0,58,8,ITEMTEXT+ITEMENABLED+HIGHCOMP,0,(APTR)&IText9,NULL,NULL,NULL,MENUNULL};
struct Menu Menu1={NULL,0,0,62,0, MENUENABLED,"Project",&MenuItem1};
void cleanexit(int error);
void openthings(void);
void addtimerequest(long secs, long micros);
void changefont(void);
void addtimerequest2(long secs, long micros);
void uptime(void);
ULONG maxmemsize(long memtype);
void updatewindow(void);
void oddstuff(void);
void idletask(void);
void __saveds switchroutine(void);
void updatezipped(int i);
void CXBRK(void)
{
cleanexit(0);
}
void cleanexit(int error)
{
if(task_added) RemTask(task);
if(task) FreeMem(task,sizeof(struct Task));
if(stack) FreeMem(stack,STACK_SIZE);
if(timeropen2)
{ if(time_requested2)
{
AbortIO((struct IORequest *)timermsg2);
WaitIO((struct IORequest *)timermsg2);
}
CloseDevice((struct IORequest *)timermsg2);
}
if(timermsg2) DeleteExtIO((struct IORequest *)timermsg2);
if(timerport2) DeletePort(timerport2);
if(timeropen)
{ if(time_requested)
{
AbortIO((struct IORe