home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG035.ARC
/
GRAFFILE.C
< prev
next >
Wrap
Text File
|
1979-12-31
|
2KB
|
84 lines
/********************************************************/
/* */
/* File-Handling for MX-80 Bit-Plot Graphics */
/* */
/* Don Brittain 3 January 1983 */
/* */
/********************************************************/
#define HSIZE 320
#define VSIZE 328
extern int horsize, versize;
extern short grafbuf[HSIZE][VSIZE/8];
static char grafname[13];
#include "libc.h"
savegraf(h,v,name) /* saves graph having dimensions h x v */
/* under the filename NAME.GRF */
int h,v;
char *name;
{
FILE *fopen(), *fp;
int vrt;
register i,j;
vrt=(versize+7)/8;
graffcb(name);
fp=fopen(grafname,"w");
putw(h,fp);
putw(v,fp); /* NO ERROR CHECKING !!!!! */
for(j=0; j<vrt; j++)
for(i=0; i<horsize; i++)
putc(grafbuf[i][j],fp);
fclose(fp);
}
getgraf(name) /* retrieves graph saved by savegraf() */
char *name;
{
FILE *fopen(), *fp;
int vrt;
register i,j;
/* ONLY MINIMAL ERROR CHECKING !!!!! */
graffcb(name);
fp=fopen(grafname,"r");
if(fp==NULL) {
printf("\nERROR: %s does not exist on ",grafname);
printf("the current drive.\n\n");
return(); }
horsize=getw(fp);
versize=getw(fp);
vrt=(versize+7)/8;
printf("\nThe graph in %s has the following dimensions:",grafname);
printf("\n\tHorizontal size: %3d",horsize);
printf("\n\tVertical size: %3d\n\n",versize);
for(j=0; j<vrt; j++)
for(i=0; i<horsize; i++)
grafbuf[i][j]=getc(fp);
fclose(fp);
}
graffcb(name) /* changes "name" to NAME.GRF */
char *name;
{
register i;
for(i=0; (grafname[i]=toupper(name[i]))!='\0'; i++);
grafname[i++]='.';
grafname[i++]='G';
grafname[i++]='R';
grafname[i++]='F';
grafname[i]='\0';
}