/* Alternate-Help to disk: This program is designed to automatically
dump whatever is on the screen to a DEGAS file. It is designed to run from
an AUTO folder. This program will write the file, PICDUMP.PIn (n according
to the screen resolution being displayed whenever ALT-HELP is pressed) to
the root directory of the drive that held the auto folder which contained
this program at startup. The normal hardcopy operation is restored by a
warm boot. Uses 1K of RAM. Note- If you dump the screen more than 36 times,
the program will very likely crash. -- David Mace, 12 JAN 1990. */ 

#include <osbind.h>
#include <linea.h>

static char pth[20]="A:\\PICDUMP@.PI1";

void dump()
{
static int c,fd,r,pal[16];
char *pic;

	r=Getrez();
	pth[14]='1'+r;		/* Append current resolution to name */
	for(c=0;c<16;++c)	/* Get pallette */
		pal[c]=Setcolor(c,-1);
	pic=(char *)Physbase(); /* Get location of current screen */
	pth[10]++;
	if(pth[10]>'Z')
		pth[10]='0';

	/* Write picture to path in a DEGAS format */

	if((fd=Fcreate(pth,0))>-1)
		{
		Fwrite(fd,2L,&r);
		Fwrite(fd,32L,pal);
		Fwrite(fd,32000L,pic);
		Fclose(fd);
		}
}

main()
{
	pth[0]='A'+Dgetdrv();	/* Set path to boot drive root directory */
	pokel(0x50Al,(long)dump); /* Set prt_vec to my screen dump */

	Cconws("\n\rDisplay Dumper installed.\n\rBy David Mace, Jan 1990\n\r");

	Ptermres(1024L,0);	/* Exit without removing this program */
}
