/* rast.c PAK 8/86 save and restore the raster under dialog boxes */ /* I would have used vro_cpyfm, but where can I get a hold of the screen MFDB?*/ /* note: the notation "alphaPbeta" denotes a dimensional constant which is the number of alpha's per beta */ #include struct rast /* the piece of the screen being saved now */ { long *Buffer; long Hsize, Vsize; long *Saddr; int bytesPblock; } rast; rast_save(x0, y0, xw, yw, p, n) int x0, y0, xw, yw, n; long *p; { long *scr, *screen; int i,j; # define pixPblock 16 # define bytesPlong 4 # define bytesPy 160 /* hi(low) res: 640(320) 2(4)-bit pix/line */ rast.Buffer = p; rast.Vsize = yw; rast.Saddr=scr=screen= y0*bytesPy + (x0/pixPblock)*rast.bytesPblock + Logbase(); xw = rast.bytesPblock*(xw/pixPblock +2); /* +1 for each end */ /* now # bytes wide*/ if (xw*yw > n) panic("Buffer supplied to Rast: %ld is too small\n",(long)n,0L); rast.Hsize = xw /= bytesPlong; /* now # longs wide */ for (j = yw; j--;) { for (i = xw; i--;) *p++ = *scr++; scr = screen += bytesPy/bytesPlong; } } long rastSize(x0, y0, xw, yw) int x0, y0, xw, yw; { int i; xw = xw/pixPblock +2; /* + one for each end */ /*now # blocks wide */ i = Getrez(); /* C-compiler bug -- needs to be previous stmnt*/ if (i == 2) panic("no support for B/W monitor \n"); rast.bytesPblock = 8 >> i; /*lo=8, med=4, hi=2*/ return ((long)xw*rast.bytesPblock*yw); } rast_restore() { long *p, *scr, *screen; int i,j, xw; p = rast.Buffer; scr = screen = rast.Saddr; xw = rast.Hsize; for (j = rast.Vsize; j--;) { for (i = xw; i--;) *scr++ = *p++; scr = screen += bytesPy/bytesPlong; } }