#include #include #include #include int dx = 64, dy = 64; Biobuf *bi, *bo; u32int pal[256]; u8int get8(void) { uchar v; if(Bread(bi, &v, 1) != 1) sysfatal("get8: short read"); return v; } u16int get16(void) { u8int v; v = get8(); return get8() << 8 | v; } u32int get32(void) { u16int v; v = get16(); return get16() << 16 | v; } u32int* unpic(void) { int n, h; u32int *p, *d, *cols, *buf; dx = get16(); dy = get16(); cols = mallocz(dx * sizeof *cols, 1); buf = mallocz(dx * dy * sizeof *buf, 1); if(cols == nil || buf == nil) sysfatal("mallocz: %r"); get32(); for(p=cols; p0; d+=dx) *d = pal[get8()]; get8(); } } free(cols); return buf; } u32int* unflat(void) { u32int *p; static u32int buf[4096]; for(p=buf; p