vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

computil.c (679B)


      1 #include "u.h"
      2 #include "lib.h"
      3 #include "draw.h"
      4 
      5 /*
      6  * compressed data are seuences of byte codes.  
      7  * if the first byte b has the 0x80 bit set, the next (b^0x80)+1 bytes
      8  * are data.  otherwise, it's two bytes specifying a previous string to repeat.
      9  */
     10 void
     11 _twiddlecompressed(uchar *buf, int n)
     12 {
     13 	uchar *ebuf;
     14 	int j, k, c;
     15 
     16 	ebuf = buf+n;
     17 	while(buf < ebuf){
     18 		c = *buf++;
     19 		if(c >= 128){
     20 			k = c-128+1;
     21 			for(j=0; j<k; j++, buf++)
     22 				*buf ^= 0xFF;
     23 		}else
     24 			buf++;
     25 	}
     26 }
     27 
     28 int
     29 _compblocksize(Rectangle r, int depth)
     30 {
     31 	int bpl;
     32 
     33 	bpl = bytesperline(r, depth);
     34 	bpl = 2*bpl;	/* add plenty extra for blocking, etc. */
     35 	if(bpl < NCBLOCK)
     36 		return NCBLOCK;
     37 	return bpl;
     38 }