|
|
1.1 root 1: #include <signal.h>
2:
3: #define DITHSIZE 16
4: #define DITHMASK (DITHSIZE-1)
5:
6: extern void onquit();
7: int ofd;
8:
9: static int dith[DITHSIZE][DITHSIZE]={
10: 0,128, 32,160, 8,136, 40,168, 2,130, 34,162, 10,138, 42,170,
11: 192, 64,224, 96,200, 72,232,104,194, 66,226, 98,202, 74,234,106,
12: 48,176, 16,144, 56,184, 24,152, 50,178, 18,146, 58,186, 26,154,
13: 240,112,208, 80,248,120,216, 88,242,114,210, 82,250,122,218, 90,
14: 12,140, 44,172, 4,132, 36,164, 14,142, 46,174, 6,134, 38,166,
15: 204, 76,236,108,196, 68,228,100,206, 78,238,110,198, 70,230,102,
16: 60,188, 28,156, 52,180, 20,148, 62,190, 30,158, 54,182, 22,150,
17: 252,124,220, 92,244,116,212, 84,254,126,222, 94,246,118,214, 86,
18: 3,131, 35,163, 11,139, 43,171, 1,129, 33,161, 9,137, 41,169,
19: 195, 67,227, 99,203, 75,235,107,193, 65,225, 97,201, 73,233,105,
20: 51,179, 19,147, 59,187, 27,155, 49,177, 17,145, 57,185, 25,153,
21: 243,115,211, 83,251,123,219, 91,241,113,209, 81,249,121,217, 89,
22: 15,143, 47,175, 7,135, 39,167, 13,141, 45,173, 5,133, 37,165,
23: 207, 79,239,111,199, 71,231,103,205, 77,237,109,197, 69,229,101,
24: 63,191, 31,159, 55,183, 23,151, 61,189, 29,157, 53,181, 21,149,
25: 255,127,223, 95,247,119,215, 87,253,125,221, 93,245,117,213, 85,
26: };
27:
28: pvputitall(m)
29: { int y;
30: y = CUROLD; CUROLD = CURSCRATCH; CURSCRATCH = y;
31: for (y = 0; y < DEF_NL; y++)
32: pvlyank(0, y);
33: y = CUROLD; CUROLD = CURSCRATCH; CURSCRATCH = y;
34: }
35:
36: unsigned char out[64];
37:
38: pvlyank(xx, yy)
39: { unsigned char *s = scratchred + DEF_LL*(yy-1);
40: int byte=0, mask=0x80, nout=0, x;
41: int y = yy;
42:
43: if (xx != 0) return;
44:
45: if (DEF_NL == 1024)
46: { if (y%4) return;
47: y /= 4;
48: out[nout++] = y>>8;
49: out[nout++] = y&255;
50: for (x = 0; x < 256; x++, s+=4)
51: { if (*s <= dith[y&DITHMASK][x&DITHMASK])
52: byte |= mask;
53: mask >>= 1;
54: if (mask == 0)
55: { out[nout++] = byte;
56: byte = 0;
57: mask = 0x80;
58: }
59: }
60: } else
61: { if (y%2) return;
62: y /= 2;
63: out[nout++] = y>>8;
64: out[nout++] = y&255;
65: for (x = 0; x < 256; x++, s += 2)
66: { if (*s <= dith[y&DITHMASK][x&DITHMASK])
67: byte |= mask;
68: mask >>= 1;
69: if (mask == 0)
70: { out[nout++] = byte;
71: byte = 0;
72: mask = 0x80;
73: }
74: }
75: }
76: signal(SIGINT, SIG_IGN);
77: write(ofd, out, nout);
78: signal(SIGINT, onquit);
79: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.