1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 */ 6 7 #ifndef lint 8 static char sccsid[] = "@(#)setmat.c 5.1 (Berkeley) 04/26/85"; 9 #endif not lint 10 11 /* 12 * setmat: set the value in m[r, c] to nval. 13 */ 14 15 #include "bit.h" 16 17 setmat(m, rows, cols, r, c, nval) 18 bitmat m; 19 int rows, cols, r, c, nval; 20 { 21 register int offset, thisbit; 22 23 if (r<0 || c<0 || r>=rows || c>=cols) { 24 #ifdef TRACE 25 if (trace) 26 fprintf(trace, "setmat range error: (%d, %d) <- %d in a (%d, %d) matrix %x\n", r, c, nval, rows, cols, m); 27 #endif 28 29 return; 30 } 31 offset = r*((cols+7)>>3) + (c>>3); 32 thisbit = 0x80 >> (c&7); 33 if (nval) 34 m[offset] |= thisbit; 35 else 36 m[offset] &= ~thisbit; 37 } 38