home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
system
/
vmem
/
demo
/
demo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-27
|
2KB
|
120 lines
#include <Libraries/VMem.h>
#include <Proto/Exec.h>
#include <Proto/DOS.h>
#include <StdIO.h>
#include <StdLib.h>
char __stdiowin[]="CON:10/20/620/120/";
char __stdiov37[]="/AUTO/CLOSE/WAIT";
#define NELS (10)
#define ELSIZE (60000)
struct Library *VMemBase;
vmBlock *b;
ULONG i;
UBYTE *data;
UBYTE HeaderText[]="\f\n\
* VIRTUAL MEMORY DEMONSTRATION *\n\
Courtesy of vmem.library (c)1994\n\
By Lee Braiden\n\
\n\
\n\
THIS IS A (TOTALLY ?) USELESS DEMO PROGRAM FOR VMEM\n\
\n\
NOTE THAT VMEM MUST BE INSTALLED, AND FAST MEM EMULATION\n\
MUST BE SET TO CHIP/PUBLIC TO RUN THIS ON AN UNEXPANDED\n\
AMIGA. SEE DEMO.manual FOR MORE INFO.\n\
\n\
\n\
Enter up to 10 lines of text,finishing each line with <Return>\n\
when you want to stop, type <Esc><Return>.\n\
\n\
When your system runs out of memory for all the lines,vmem will kick-in\n\
and start moving them onto disk to save memory. When you've finished,\n\
they will be moved back into mem, and typed back to this window.\n\n\n";
void CloseDown(char *mess);
void CloseDown(char *mess)
{
if(mess)
{
printf("*** Virtual Memory Test :\n\t%s !\n",mess);
Delay(50*3);
};
if(b)
{
if(data)
{
vmUnLock(b,i);
};
vmFreeBlock(b);
};
if(VMemBase)
CloseLibrary(VMemBase);
exit(0);
}
void main()
{
if(VMemBase = OpenLibrary("vmem.library",VMEM_VERSION))
{
if(!(b = vmAllocBlock(ELSIZE,NELS,MEMF_FAST|MEMF_CLEAR)))
CloseDown("Couldn't alloc vmem");
puts(HeaderText);
for(i=0;i<NELS;i++)
{
if(!(data = vmLock(b,i)))
CloseDown("Couldn't Lock El");
printf(" > ");
fflush(stdout);
gets(data);
if(*data == '\x1B')
{
vmUnLock(b,i);
data = NULL;
goto Next;
};
vmUnLock(b,i);
data = NULL;
};
Next:
printf("\n\n\n\x1B[41m\x1B[33m");
for(i=0;i<NELS;i++)
{
if(!(data = vmLock(b,i)))
CloseDown("Couldn't Lock El");
puts(data);
vmUnLock(b,i);
data = NULL;
};
printf("\x1B[0m\f");
CloseDown("\n\n\n\tAll OK");
}else
CloseDown("Couldn't open vmem.library");
}