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