
/********************************************************/
/*							*/
/*	Graph Inversion for MX-80 Bit-Plot Graphics	*/
/*							*/
/*	Don Brittain		3 January 1983		*/
/*							*/
/********************************************************/

#define HSIZE 320
#define VSIZE 328

extern int versize;
extern int pixplot(), unpixplot(), power();
extern short grafbuf[HSIZE][VSIZE/8];

invert(x,h,y,v)		/* Changes all pixels with coords (a,b) */
			/* satisfying   x < a < h  and		*/
int x,h,y,v;		/* y < b < v from 0 to 1 or vice versa	*/

{
    register i,j;
    
    if((x>h)||(y>v))	 {
	printf("Argument error in INVERT: command aborted.\n\n");
	command();	}
    else
	for(j=y; j<=v; j++)
	    for(i=x; i<=h; i++)
		if(get(i,j))
		    unpixplot(i,j);
		else
		    pixplot(i,j);
}


get(h,v)    /* returns the value (0 or 1) of the pixel at (h,v) */

int h,v;

{
    return(power(2,v%8)&grafbuf[h][(versize-1)/8-v/8]);
}
        
	
