Blob
1 #include <u.h>2 #include <libc.h>3 #include <draw.h>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 bytes8 * are data. otherwise, it's two bytes specifying a previous string to repeat.9 */10 void11 _twiddlecompressed(uchar *buf, int n)12 {13 uchar *ebuf;14 int j, k, c;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 }else24 buf++;25 }26 }28 int29 _compblocksize(Rectangle r, int depth)30 {31 int bpl;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 }