home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
lang
/
skel_azt.sha
/
drawgraf.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-07-08
|
2KB
|
98 lines
/*
* drawgraf.c -- draw the contents of the graphics window
*/
#include <quickdraw.h>
#include <memory.h>
#include <pb.h>
#include <syserr.h>
#include <toolutil.h>
#include <window.h>
#include "def.h"
#define BUFSIZE 10240
#define BMINUSSECT (BUFSIZE-512)
void
drawgraf()
{
long count;
char dest[72];
Rect dgr;
char *dp;
OSErr e;
char *ep;
extern BitMap gibits;
extern Rect grafr;
int i, j;
extern int paint; /* file refnum or zero */
BitMap sbm;
char *sp;
char *srcp;
extern WindowPtr wp[NWINDOWS];
EraseRect(&grafr);
if (paint) {
SetRect(&dgr, 0, 0, 576, 1);
sbm.baseAddr = dest;
sbm.rowBytes = 72;
BlockMove(&dgr, &sbm.bounds, (long)sizeof(Rect));
if (e = SetFPos(paint, fsFromStart, 512L)) {
errmsg(9, e); /* file seek error */
return;
};
srcp = NewPtr((Size)BUFSIZE);
if (srcp == NIL) {
errmsg(10, 0); /* Not enough memory to read paint */
return;
};
sp = srcp;
count = (long)BUFSIZE;
if ((e = FSRead(paint, &count, srcp)) && e != eofErr) {
errmsg(4, e); /* File Read Error */
DisposPtr(srcp);
return;
};
if (count < 1440L) {
errmsg(11, (OSErr)count); /* Not a paint file */
DisposPtr(srcp);
return;
};
ep = srcp + count;
for (i = 0; i < 720; ) {
dp = dest;
UnpackBits(&sp, &dp, 72);
if (sp > ep) {
errmsg(12, 0); /* Premature end of file */
DisposPtr(srcp);
return;
};
dgr.top = i;
dgr.bottom = ++i;
CopyBits(&sbm, &wp[0]->portBits, &sbm.bounds, &dgr,
srcCopy, wp[0]->clipRgn);
if ((sp - srcp) > BMINUSSECT) {
BlockMove(srcp + BMINUSSECT, srcp, 512L);
count = (long)BMINUSSECT;
if ((e = FSRead(paint, &count, srcp + 512)) &&
e != eofErr) {
errmsg(4, e); /* File Read Error */
DisposPtr(srcp);
return;
};
ep = srcp + count + 512;
sp -= BMINUSSECT;
};
};
DisposPtr(srcp);
}
else
for (i = 0, j = 32; i < 480; i += j, j <<= 1) {
SetRect(&dgr, i, i, i + j, i + j);
CopyBits(&gibits, &wp[0]->portBits, &gibits.bounds, &dgr,
srcCopy, wp[0]->clipRgn);
};
} /* end of drawgraf */