home *** CD-ROM | disk | FTP | other *** search
- /*------------------------- AvailMem V1.10 ----------------------------*/
- /*Written and copyright (c)1988, 1989, 1990 by Dave Schreiber. All rights*/
- /*reserved. This program may not be sold, but reasonable charges for */
- /*media, duplication, shipping/handling, etc. are permitted. */
- /*---------------------------------------------------------------------*/
- /*Keeps a running count of the amount of FAST, CHIP, and total memory */
- /*free. Updates every .7 seconds. With a stack size of 4K, it takes */
- /*up about 12K of RAM. Compiled under Lattice C V5.02 */
- /*----------------------------- Enjoy ---------------------------------*/
- /*Version history: */
- /* 1.10 - Added a counter of the largest block free for FAST, CHIP, and*/
- /* total memory */
- /* 1.03 - First release to the public. Included on Fred Fish disk #285*/
- /*---------------------------------------------------------------------*/
-
-
- /*Standard #include files*/
- #include <exec/types.h>
- #include <exec/exec.h>
- #include <intuition/intuition.h>
-
- /*Window and IntuiText definitions*/
- #include "AvailMem.h"
-
- struct IntuitionBase *IntuitionBase; /*Library base pointers*/
- struct GfxBase *GfxBase;
-
- void MainLoop();
- void MakeString();
-
- #define Rp Wdw->RPort
-
- /*Using _main() keeps AmigaDOS from opening an extra */
- _main() /*console window when AvailMem is run from Workbench.*/
- {
- if((IntuitionBase=(struct IntuitionBase *) /*Open Intuition*/
- OpenLibrary("intuition.library",0))==NULL)
- exit(10);
- /*Open Graphics*/
- if((GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0))==NULL)
- {
- CloseLibrary(IntuitionBase); /*Like it really matters...*/
- exit(20);
- }
-
- MainLoop();
-
- CloseLibrary(GfxBase); /*Close the libraries*/
- CloseLibrary(IntuitionBase);
- }
-
- void MainLoop() /*The main loop*/
- {
- struct Window *Wdw; /*Window pointer*/
- ULONG c,f;
-
- /*Open the window*/
- if((Wdw=(struct Window *)OpenWindow(&NewWindowStructure1))==NULL)
- exit(30);
-
- PrintIText(Rp,&IText1,-6,2);
-
- /*while the close gadget wasn't pressed...*/
- while( ( GetMsg(Wdw->UserPort) ) == NULL)
- { /*For each possibility, get the memory count, convert it to text,
- /*put it into the appropriate intuitext structure,*/
-
- c=AvailMem(MEMF_LARGEST|MEMF_CHIP);
- f=AvailMem(MEMF_LARGEST|MEMF_FAST);
- MakeString(IText12.IText,(c < f) ? f : c);
- MakeString(IText11.IText,c);
- MakeString(IText10.IText,f);
-
- c=AvailMem(MEMF_CHIP);
- f=AvailMem(MEMF_FAST);
- MakeString(IText9.IText,c+f);
- MakeString(IText8.IText,c);
- MakeString(IText7.IText,f);
-
- PrintIText(Rp,&IText7,-6,2); /*and print it*/
- Delay(35); /*Wait for .7 seconds, then do the whole thing again*/
- }
- CloseWindow(Wdw); /*Close the window*/
- }
-
- void MakeString(string,amt) /*Convert amt to a string, put into 'string'*/
- char *string; /*and pad out with spaces*/
- ULONG amt;
- {
- BYTE c;
- stcu_d(string,amt,8); /*Convert number into text*/
- for(c=strlen(string);c<8;c++)
- string[c]=' '; /*Pad out with spaces*/
-
- string[8]=NULL; /*And terminate with a NULL*/
- }
-