Mercurial > hg > forks > pwpunix
annotate pwplib/attrconv.c @ 63:b87192212b9a
Delete dead function convcalc_monotab_attr(int parms)
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 09 Jul 2011 11:58:24 +0300 |
parents | 0e2d7767c00d |
children |
rev | line source |
---|---|
0 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 | |
4 #include "convert.h" | |
5 | |
6 /* | |
7 * Doubleheight IBM | |
8 * | |
9 */ | |
10 | |
55 | 11 void convcalc_1to12(void) /* &1 == ibm2ibm, */ |
0 | 12 { |
55 | 13 static const u8 tabsrc[] = { |
0 | 14 '\"', '\"',' ', |
15 '/', '|','/', | |
16 '\'', '\'',' ', | |
17 '/', '|', '/', | |
18 | |
19 '\\', '\\','|', | |
20 '^', '^', ' ', | |
21 | |
22 '`', '`', ' ', | |
23 | |
24 '|', '|', '|', | |
25 '~', '~', ' ', | |
26 | |
27 176, 176, 176, | |
28 177, 177, 177, | |
29 178, 178, 178, | |
30 | |
31 179, 179, 179, | |
32 180, 179, 180, | |
33 181, 179, 181, | |
34 182, 186, 182, | |
35 185, 186, 185, | |
36 186, 186, 186, | |
37 188, 186, 188, | |
38 189, 186, 189, | |
39 190, 179, 190, | |
40 192, 179, 192, | |
41 193, 179, 193, | |
42 195, 179, 195, | |
43 197, 179, 197, | |
44 198, 179, 198, | |
45 199, 186, 199, | |
46 200, 186, 200, | |
47 202, 186, 202, | |
48 204, 186, 204, | |
49 206, 186, 206, | |
50 207, 179, 207, | |
51 208, 186, 208, | |
52 211, 186, 211, | |
53 212, 179, 212, | |
54 215, 186, 215, | |
55 216, 179, 216, | |
56 217, 179, 217, | |
57 | |
58 219, 219, 219, | |
59 220, 32, 219, | |
60 221, 221, 221, | |
61 222, 222, 222, | |
62 223, 219, 32, | |
63 0 | |
64 }; | |
55 | 65 const u8 *t = tabsrc; |
66 int i; | |
0 | 67 |
55 | 68 for(i = 0;i<256;i++) |
0 | 69 pwpconv.tab1to12[i]=BYTES2(pwpconv.font[i],32); |
70 | |
71 while(*t) | |
72 { | |
73 pwpconv.tab1to12[*t]=BYTES2(pwpconv.font[t[2]],pwpconv.font[t[1]]); | |
74 t+=3; | |
75 } | |
76 } | |
77 | |
55 | 78 static void conv_1to12(u8*d,u8*s,int w,int h) |
0 | 79 { |
80 w<<=1; | |
81 for(;h;h--) | |
82 { | |
83 int x=w>>1; | |
84 for(;x;x--) | |
85 { | |
86 int a=pwpconv.tab1to12[*s]; | |
87 | |
88 d[0]=SECONDBYTE(a); | |
89 d[w]=FIRSTBYTE(a); | |
90 d[1]=d[w+1]=s[1]; | |
91 | |
92 d+=2; | |
93 s+=2; | |
94 } | |
95 d+=w; | |
96 } | |
97 } | |
98 | |
99 /* | |
100 * Megatab (ibm color16x16 => any) initialization | |
101 * | |
102 * | |
103 */ | |
104 | |
105 /* | |
106 * purely font/charset related | |
107 */ | |
108 | |
62
0e2d7767c00d
convcalc_ascii()'s one argument is unused, remove it.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
109 void convcalc_ascii(void) |
0 | 110 { |
111 memcpy(pwpconv.font, | |
112 /*00*/ " OOwoxAoooo6qrn*" | |
113 /*10*/ "><8!PS_8^v><L-^v" | |
114 /*20*/ " !\"#$%&'()*+,-./" | |
115 /*30*/ "0123456789:;<=>?" | |
116 /*40*/ "@ABCDEFGHIJKLMNO" | |
117 /*50*/ "PQRSTUVWXYZ[\\]^_" | |
118 /*60*/ "`abcdefghijklmno" | |
119 /*70*/ "pqrstuvwxyz{|}~A" | |
120 /*80*/ "CueaaaaceeeiiiAA" | |
121 /*90*/ "E&&ooouuyOUcEVPf" | |
122 /*A0*/ "aiounNao?--%%!<>" | |
123 /*B0*/ "%#M||||..||.'''." | |
124 /*C0*/ "`--|-+||`.--|-+-" | |
125 /*D0*/ "---``-.++'.8opd^" | |
126 /*E0*/ "aBrhEouiO0Od-%EA" | |
127 /*F0*/ "=+><|J%~o-.Vn2o ",256*sizeof(char)); | |
128 } | |
129 | |
55 | 130 void convcalc_termsafe(void) |
0 | 131 { |
132 int i=256;u8*s=pwpconv.font; | |
133 for(;i;i--) | |
134 { | |
135 if(*s<32 || *s==127)*s=32; | |
136 s++; | |
137 } | |
138 } | |
139 | |
140 /* | |
141 * purely colortab related | |
142 */ | |
143 | |
144 void convcalc_monotab(int parms) | |
145 { | |
146 memset(pwpconv.col,(parms&1)?0x00:0x07,256*sizeof(u8)); | |
147 } | |
148 | |
149 void convcalc_colortab(int parms) | |
150 { | |
151 int i; | |
152 char tabs[32]; | |
153 | |
154 for(i=0;i<32;i++)tabs[i]=i&15; | |
155 | |
156 if(parms&1){ /* 8 colors in foreground, else 16 */ | |
157 memcpy(tabs+8, "\003\003\002\003\004\005\006\007",8); | |
158 } | |
159 | |
160 if(parms&2) /* 8 colors in background, else 16 */ | |
161 memcpy(tabs+24, "\003\003\002\003\004\005\006\007",8); | |
162 | |
163 if(parms&4) /* ansi color order (bgr) instead of cga (rgb) */ | |
164 for(i=0;i<32;i++) | |
165 tabs[i]=(tabs[i]&~7)| | |
166 "\000\004\002\006\001\005\003\007"[tabs[i]&7]; | |
167 | |
168 for(i=0;i<256;i++) | |
169 pwpconv.col[i]=tabs[i&15]|(tabs[16+((i>>4)&15)]<<4); | |
170 } | |
171 | |
172 /* | |
173 * finishing the megatab | |
174 */ | |
175 | |
176 /* | |
177 1: eliminate 178/219 (if inverse supported & 178/219 doesnt exist) | |
178 2: eliminate halfblocks (if chars, preferably if we have rasterchar && fullres) | |
179 4: replace rasters (if no bgcolors or no colors at all? smwhr else?) | |
180 8: sometimes repl 176 with 177 (if only 8 colors at bg - dont use with &4) | |
181 | |
182 normal ascii rasterchars: 176='%', 177='@' | |
183 in vt100, both 176&177 are replaced with halfraster | |
184 */ | |
185 void convcalc_megatab_finish(int flags) | |
186 { | |
187 const char intens[16]= | |
188 { | |
189 0,1,6,7, 3,4,9,10, | |
190 1,2,9,10,5,6,13,15 | |
191 }; | |
192 | |
193 int ch,at; | |
194 u8*s=(u8*)pwpconv.megatab; | |
195 | |
196 # ifndef BIG_ENDIAN | |
197 for(at=0;at<256;at++) | |
198 for(ch=0;ch<256;ch++) | |
199 # else | |
200 for(ch=0;ch<256;ch++) | |
201 for(at=0;at<256;at++) | |
202 # endif | |
203 { | |
204 int fg=at&15,bg=(at>>4)&15,at1=at,ch1=ch; | |
205 | |
206 if(ch==32 || ch==0 || ch==255)fg=bg;else | |
207 if(ch==219)bg=fg; | |
208 | |
209 if(fg==bg) | |
210 { | |
211 if(fg&8) | |
212 { | |
213 ch1=219;at1=fg; | |
214 } | |
215 else | |
216 { | |
217 ch1=32;at1=fg<<4; | |
218 } | |
219 } | |
220 else | |
221 if(ch>=220 && ch<=223) | |
222 { | |
223 if((at1&128) && intens[bg]>intens[fg]) | |
224 { | |
225 ch1=223-(ch1-220); | |
226 at1=((at1>>4)&15)|((at1<<4)&0xf0); | |
227 } | |
228 if(flags&2)ch1=177; | |
229 } | |
230 else | |
231 if(ch>=176 && ch<=178) | |
232 { | |
233 if((at1&128) || intens[bg]>intens[fg]) | |
234 { | |
235 if(ch1==176)ch1=178; else | |
236 if(ch1==178)ch1=176; | |
237 | |
238 at1=((at1>>4)&15)|((at1<<4)&0xf0); | |
239 | |
240 /* flags&8: use 177 when 176 with doublebright */ | |
241 if((at1&128) && (flags&8) && (ch1==176)) | |
242 ch1=177; | |
243 } | |
244 } | |
245 | |
246 /* flags&1: eliminate 178/219 */ | |
247 if((ch1==178 || (ch1==219)) && (flags&1)) | |
248 { | |
249 ch1=(ch1==178)?176:32; | |
250 at1=((at1>>4)&15)|((at1<<4)&0xf0); | |
251 } | |
252 | |
253 /* flags&4: replace rasters (32/176/177) with something else | |
254 (replace color info with char stuff | |
255 */ | |
256 | |
257 s[0]=pwpconv.font[ch1]; | |
258 s[1]=pwpconv.col[at1]; | |
259 | |
260 s+=2; | |
261 } | |
262 } | |
263 | |
264 /*******************************/ | |
265 | |
266 | |
55 | 267 void conv_dump_ibm_megatab(void) |
0 | 268 { |
269 TEMPMALL(u16,tmp,pwplib.videobuf.height*pwplib.videobuf.width*2), | |
270 *s=(u16*)pwplib.videobuf.d,*d=tmp; | |
271 | |
272 int i=pwplib.videobuf.height*pwplib.videobuf.width; | |
273 for(;i;i--)*d++=pwpconv.megatab[*s++]; | |
274 | |
275 {u8*pushed=pwplib.videobuf.d; | |
276 pwplib.videobuf.d=(u8*)tmp; | |
277 pwpconv.orig_dump_attr(); | |
278 pwplib.videobuf.d=pushed; | |
279 } | |
280 | |
281 TEMPFREE(tmp); | |
282 } | |
283 | |
55 | 284 static void conv_fromibm_double(void) |
0 | 285 { |
286 int lgt=pwplib.videobuf.width*pwplib.videobuf.height; | |
287 | |
288 TEMPMALL(u8,tmp,lgt*2*2); | |
289 | |
290 conv_1to12(tmp,pwplib.videobuf.d,pwplib.videobuf.width,pwplib.videobuf.height); | |
291 | |
55 | 292 {u8 *save=pwplib.videobuf.d; |
0 | 293 pwplib.videobuf.d=tmp; |
294 pwplib.videobuf.height<<=1; | |
295 conv_dump_ibm_megatab(); | |
296 pwplib.videobuf.height>>=1; | |
297 pwplib.videobuf.d=save; | |
298 } | |
299 | |
300 TEMPFREE(tmp); | |
301 } | |
302 | |
55 | 303 static void conv_fromibm_half(void) |
0 | 304 { |
305 TEMPMALL(u8,tmp,pwplib.videobuf.width*pwplib.videobuf.height), | |
306 *d=tmp,*s=pwplib.videobuf.d; | |
307 | |
308 int y; | |
309 y=pwplib.videobuf.height>>1; | |
310 | |
311 for(;y;y--) | |
312 { | |
313 int x=pwplib.videobuf.width, | |
314 w=x<<1; | |
315 for(;x;x--) | |
316 { | |
317 d[0]=pwpconv.font[s[0]]; | |
318 d[1]=s[1]|s[1+w]; | |
319 s+=2;d+=2; | |
320 } | |
321 s+=w; | |
322 } | |
323 | |
55 | 324 {u8 *save=pwplib.videobuf.d; |
0 | 325 pwplib.videobuf.d=tmp; |
326 pwplib.videobuf.height>>=1; | |
327 conv_dump_ibm_megatab(); | |
328 pwpconv.orig_dump_attr(); | |
329 pwplib.videobuf.d=save; | |
330 pwplib.videobuf.height<<=1; | |
331 } | |
332 | |
333 TEMPFREE(tmp); | |
334 } | |
335 | |
336 /* dump_ibm_halved, dump_ibm_realsize */ | |
55 | 337 void conv_dump_ibm(void) |
0 | 338 { |
339 if(pwplib.setup[SETUP_HALVE]) | |
340 { | |
341 if(pwplib.videobuf.height==50) /* kludge */ | |
342 conv_fromibm_half(); | |
343 else conv_dump_ibm_megatab(); | |
344 } | |
345 else | |
346 { | |
347 if(pwplib.videobuf.height==50) | |
348 conv_dump_ibm_megatab(); | |
349 else conv_fromibm_double(); | |
350 } | |
351 } |