OSDN Git Service

got 8086 port of wolf3d to work and sod to work
[proj16/16.git] / 16 / sod8086 / oldscale.c
1 // WL_SCALE.C\r
2 \r
3 #include "WL_DEF.H"\r
4 #pragma hdrstop\r
5 \r
6 #define OP_RETF 0xcb\r
7 \r
8 /*\r
9 =============================================================================\r
10 \r
11                                                   GLOBALS\r
12 \r
13 =============================================================================\r
14 */\r
15 \r
16 t_compscale _seg *scaledirectory[MAXSCALEHEIGHT+1];\r
17 long                    fullscalefarcall[MAXSCALEHEIGHT+1];\r
18 \r
19 int                     maxscale,maxscaleshl2;\r
20 \r
21 /*\r
22 =============================================================================\r
23 \r
24                                                   LOCALS\r
25 \r
26 =============================================================================\r
27 */\r
28 \r
29 t_compscale     _seg *work;\r
30 unsigned BuildCompScale (int height, memptr *finalspot);\r
31 \r
32 int                     stepbytwo;\r
33 \r
34 //===========================================================================\r
35 \r
36 /*\r
37 ==============\r
38 =\r
39 = BadScale\r
40 =\r
41 ==============\r
42 */\r
43 \r
44 void far BadScale (void)\r
45 {\r
46         Quit ("BadScale called!");\r
47 }\r
48 \r
49 \r
50 /*\r
51 ==========================\r
52 =\r
53 = SetupScaling\r
54 =\r
55 ==========================\r
56 */\r
57 \r
58 void SetupScaling (int maxscaleheight)\r
59 {\r
60         int             i,x,y;\r
61         byte    far *dest;\r
62 \r
63         maxscaleheight/=2;                      // one scaler every two pixels\r
64 \r
65         maxscale = maxscaleheight-1;\r
66         maxscaleshl2 = maxscale<<2;\r
67 \r
68 //\r
69 // free up old scalers\r
70 //\r
71         for (i=1;i<MAXSCALEHEIGHT;i++)\r
72         {\r
73                 if (scaledirectory[i])\r
74                         MM_FreePtr (&(memptr)scaledirectory[i]);\r
75                 if (i>=stepbytwo)\r
76                         i += 2;\r
77         }\r
78         memset (scaledirectory,0,sizeof(scaledirectory));\r
79 \r
80         MM_SortMem ();\r
81 \r
82 //\r
83 // build the compiled scalers\r
84 //\r
85         stepbytwo = viewheight/2;       // save space by double stepping\r
86         MM_GetPtr (&(memptr)work,20000);\r
87         if (mmerror)\r
88                 return;\r
89 \r
90         for (i=1;i<=maxscaleheight;i++)\r
91         {\r
92                 BuildCompScale (i*2,&(memptr)scaledirectory[i]);\r
93                 if (mmerror)\r
94                 {\r
95                         MM_FreePtr (&(memptr)work);\r
96                         return;\r
97                 }\r
98                 if (i>=stepbytwo)\r
99                         i+= 2;\r
100         }\r
101         MM_FreePtr (&(memptr)work);\r
102 \r
103 //\r
104 // compact memory and lock down scalers\r
105 //\r
106         MM_SortMem ();\r
107         for (i=1;i<=maxscaleheight;i++)\r
108         {\r
109                 MM_SetLock (&(memptr)scaledirectory[i],true);\r
110                 fullscalefarcall[i] = (unsigned)scaledirectory[i];\r
111                 fullscalefarcall[i] <<=16;\r
112                 fullscalefarcall[i] += scaledirectory[i]->codeofs[0];\r
113                 if (i>=stepbytwo)\r
114                 {\r
115                         scaledirectory[i+1] = scaledirectory[i];\r
116                         fullscalefarcall[i+1] = fullscalefarcall[i];\r
117                         scaledirectory[i+2] = scaledirectory[i];\r
118                         fullscalefarcall[i+2] = fullscalefarcall[i];\r
119                         i+=2;\r
120                 }\r
121         }\r
122         scaledirectory[0] = scaledirectory[1];\r
123         fullscalefarcall[0] = fullscalefarcall[1];\r
124 \r
125 //\r
126 // check for oversize wall drawing\r
127 //\r
128         for (i=maxscaleheight;i<MAXSCALEHEIGHT;i++)\r
129                 fullscalefarcall[i] = (long)BadScale;\r
130 \r
131 }\r
132 \r
133 //===========================================================================\r
134 \r
135 /*\r
136 ========================\r
137 =\r
138 = BuildCompScale\r
139 =\r
140 = Builds a compiled scaler object that will scale a 64 tall object to\r
141 = the given height (centered vertically on the screen)\r
142 =\r
143 = height should be even\r
144 =\r
145 = Call with\r
146 = ---------\r
147 = DS:SI         Source for scale\r
148 = ES:DI         Dest for scale\r
149 =\r
150 = Calling the compiled scaler only destroys AL\r
151 =\r
152 ========================\r
153 */\r
154 \r
155 unsigned BuildCompScale (int height, memptr *finalspot)\r
156 {\r
157         byte            far *code;\r
158 \r
159         int                     i;\r
160         long            fix,step;\r
161         unsigned        src,totalscaled,totalsize;\r
162         int                     startpix,endpix,toppix;\r
163 \r
164 \r
165         step = ((long)height<<16) / 64;\r
166         code = &work->code[0];\r
167         toppix = (viewheight-height)/2;\r
168         fix = 0;\r
169 \r
170         for (src=0;src<=64;src++)\r
171         {\r
172                 startpix = fix>>16;\r
173                 fix += step;\r
174                 endpix = fix>>16;\r
175 \r
176                 if (endpix>startpix)\r
177                         work->width[src] = endpix-startpix;\r
178                 else\r
179                         work->width[src] = 0;\r
180 \r
181 //\r
182 // mark the start of the code\r
183 //\r
184                 work->codeofs[src] = FP_OFF(code);\r
185 \r
186 //\r
187 // compile some code if the source pixel generates any screen pixels\r
188 //\r
189                 startpix+=toppix;\r
190                 endpix+=toppix;\r
191 \r
192                 if (startpix == endpix || endpix < 0 || startpix >= viewheight || src == 64)\r
193                         continue;\r
194 \r
195         //\r
196         // mov al,[si+src]\r
197         //\r
198                 *code++ = 0x8a;\r
199                 *code++ = 0x44;\r
200                 *code++ = src;\r
201 \r
202                 for (;startpix<endpix;startpix++)\r
203                 {\r
204                         if (startpix >= viewheight)\r
205                                 break;                                          // off the bottom of the view area\r
206                         if (startpix < 0)\r
207                                 continue;                                       // not into the view area\r
208 \r
209                 //\r
210                 // mov [es:di+heightofs],al\r
211                 //\r
212                         *code++ = 0x26;\r
213                         *code++ = 0x88;\r
214                         *code++ = 0x85;\r
215                         *((unsigned far *)code)++ = startpix*SCREENBWIDE;\r
216                 }\r
217 \r
218         }\r
219 \r
220 //\r
221 // retf\r
222 //\r
223         *code++ = 0xcb;\r
224 \r
225         totalsize = FP_OFF(code);\r
226         MM_GetPtr (finalspot,totalsize);\r
227         if (mmerror)\r
228                 return 0;\r
229         _fmemcpy ((byte _seg *)(*finalspot),(byte _seg *)work,totalsize);\r
230 \r
231         return totalsize;\r
232 }\r
233 \r
234 \r
235 /*\r
236 =======================\r
237 =\r
238 = ScaleLine\r
239 =\r
240 = linescale should have the high word set to the segment of the scaler\r
241 =\r
242 =======================\r
243 */\r
244 \r
245 extern  int                     slinex,slinewidth;\r
246 extern  unsigned        far *linecmds;\r
247 extern  long            linescale;\r
248 extern  unsigned        maskword;\r
249 \r
250 byte    mask1,mask2,mask3;\r
251 \r
252 \r
253 void near ScaleLine (void)\r
254 {\r
255 asm     mov     cx,WORD PTR [linescale+2]\r
256 asm     mov     es,cx                                           // segment of scaler\r
257 \r
258 asm     mov bp,WORD PTR [linecmds]\r
259 asm     mov     dx,SC_INDEX+1                           // to set SC_MAPMASK\r
260 \r
261 asm     mov     bx,[slinex]\r
262 asm     mov     di,bx\r
263 asm     shr     di,1                                            // X in bytes\r
264 asm     shr     di,1\r
265 asm     add     di,[bufferofs]\r
266 asm     and     bx,3\r
267 asm     shl     bx,3\r
268 asm     add     bx,[slinewidth]                         // bx = (pixel*8+pixwidth)\r
269 asm     mov     al,BYTE [mapmasks3-1+bx]        // -1 because pixwidth of 1 is first\r
270 asm     mov     ds,WORD PTR [linecmds+2]\r
271 asm     or      al,al\r
272 asm     jz      notthreebyte                            // scale across three bytes\r
273 asm     jmp     threebyte\r
274 notthreebyte:\r
275 asm     mov     al,BYTE PTR ss:[mapmasks2-1+bx] // -1 because pixwidth of 1 is first\r
276 asm     or      al,al\r
277 asm     jnz     twobyte                                         // scale across two bytes\r
278 \r
279 //\r
280 // one byte scaling\r
281 //\r
282 asm     mov     al,BYTE PTR ss:[mapmasks1-1+bx] // -1 because pixwidth of 1 is first\r
283 asm     out     dx,al                                           // set map mask register\r
284 \r
285 scalesingle:\r
286 \r
287 asm     mov     bx,[ds:bp]                                      // table location of rtl to patch\r
288 asm     or      bx,bx\r
289 asm     jz      linedone                                        // 0 signals end of segment list\r
290 asm     mov     bx,[es:bx]\r
291 asm     mov     dl,[es:bx]                                      // save old value\r
292 asm     mov     BYTE PTR es:[bx],OP_RETF        // patch a RETF in\r
293 asm     mov     si,[ds:bp+4]                            // table location of entry spot\r
294 asm     mov     ax,[es:si]\r
295 asm     mov     WORD PTR ss:[linescale],ax      // call here to start scaling\r
296 asm     mov     si,[ds:bp+2]                            // corrected top of shape for this segment\r
297 asm     add     bp,6                                            // next segment list\r
298 \r
299 asm     mov     ax,SCREENSEG\r
300 asm     mov     es,ax\r
301 asm     call ss:[linescale]                             // scale the segment of pixels\r
302 \r
303 asm     mov     es,cx                                           // segment of scaler\r
304 asm     mov     BYTE PTR es:[bx],dl                     // unpatch the RETF\r
305 asm     jmp     scalesingle                                     // do the next segment\r
306 \r
307 \r
308 //\r
309 // done\r
310 //\r
311 linedone:\r
312 asm     mov     ax,ss\r
313 asm     mov     ds,ax\r
314 return;\r
315 \r
316 //\r
317 // two byte scaling\r
318 //\r
319 twobyte:\r
320 asm     mov     ss:[mask2],al\r
321 asm     mov     al,BYTE PTR ss:[mapmasks1-1+bx] // -1 because pixwidth of 1 is first\r
322 asm     mov     ss:[mask1],al\r
323 \r
324 scaledouble:\r
325 \r
326 asm     mov     bx,[ds:bp]                                      // table location of rtl to patch\r
327 asm     or      bx,bx\r
328 asm     jz      linedone                                        // 0 signals end of segment list\r
329 asm     mov     bx,[es:bx]\r
330 asm     mov     cl,[es:bx]                                      // save old value\r
331 asm     mov     BYTE PTR es:[bx],OP_RETF        // patch a RETF in\r
332 asm     mov     si,[ds:bp+4]                            // table location of entry spot\r
333 asm     mov     ax,[es:si]\r
334 asm     mov     WORD PTR ss:[linescale],ax      // call here to start scaling\r
335 asm     mov     si,[ds:bp+2]                            // corrected top of shape for this segment\r
336 asm     add     bp,6                                            // next segment list\r
337 \r
338 asm     mov     ax,SCREENSEG\r
339 asm     mov     es,ax\r
340 asm     mov     al,ss:[mask1]\r
341 asm     out     dx,al                                           // set map mask register\r
342 asm     call ss:[linescale]                             // scale the segment of pixels\r
343 asm     inc     di\r
344 asm     mov     al,ss:[mask2]\r
345 asm     out     dx,al                                           // set map mask register\r
346 asm     call ss:[linescale]                             // scale the segment of pixels\r
347 asm     dec     di\r
348 \r
349 asm     mov     es,WORD PTR ss:[linescale+2] // segment of scaler\r
350 asm     mov     BYTE PTR es:[bx],cl                     // unpatch the RETF\r
351 asm     jmp     scaledouble                                     // do the next segment\r
352 \r
353 \r
354 //\r
355 // three byte scaling\r
356 //\r
357 threebyte:\r
358 asm     mov     ss:[mask3],al\r
359 asm     mov     al,BYTE PTR ss:[mapmasks2-1+bx] // -1 because pixwidth of 1 is first\r
360 asm     mov     ss:[mask2],al\r
361 asm     mov     al,BYTE PTR ss:[mapmasks1-1+bx] // -1 because pixwidth of 1 is first\r
362 asm     mov     ss:[mask1],al\r
363 \r
364 scaletriple:\r
365 \r
366 asm     mov     bx,[ds:bp]                                      // table location of rtl to patch\r
367 asm     or      bx,bx\r
368 asm     jz      linedone                                        // 0 signals end of segment list\r
369 asm     mov     bx,[es:bx]\r
370 asm     mov     cl,[es:bx]                                      // save old value\r
371 asm     mov     BYTE PTR es:[bx],OP_RETF        // patch a RETF in\r
372 asm     mov     si,[ds:bp+4]                            // table location of entry spot\r
373 asm     mov     ax,[es:si]\r
374 asm     mov     WORD PTR ss:[linescale],ax      // call here to start scaling\r
375 asm     mov     si,[ds:bp+2]                            // corrected top of shape for this segment\r
376 asm     add     bp,6                                            // next segment list\r
377 \r
378 asm     mov     ax,SCREENSEG\r
379 asm     mov     es,ax\r
380 asm     mov     al,ss:[mask1]\r
381 asm     out     dx,al                                           // set map mask register\r
382 asm     call ss:[linescale]                             // scale the segment of pixels\r
383 asm     inc     di\r
384 asm     mov     al,ss:[mask2]\r
385 asm     out     dx,al                                           // set map mask register\r
386 asm     call ss:[linescale]                             // scale the segment of pixels\r
387 asm     inc     di\r
388 asm     mov     al,ss:[mask3]\r
389 asm     out     dx,al                                           // set map mask register\r
390 asm     call ss:[linescale]                             // scale the segment of pixels\r
391 asm     dec     di\r
392 asm     dec     di\r
393 \r
394 asm     mov     es,WORD PTR ss:[linescale+2] // segment of scaler\r
395 asm     mov     BYTE PTR es:[bx],cl                     // unpatch the RETF\r
396 asm     jmp     scaletriple                                     // do the next segment\r
397 \r
398 \r
399 }\r
400 \r
401 \r
402 /*\r
403 =======================\r
404 =\r
405 = ScaleShape\r
406 =\r
407 = Draws a compiled shape at [scale] pixels high\r
408 =\r
409 = each vertical line of the shape has a pointer to segment data:\r
410 =       end of segment pixel*2 (0 terminates line) used to patch rtl in scaler\r
411 =       top of virtual line with segment in proper place\r
412 =       start of segment pixel*2, used to jsl into compiled scaler\r
413 =       <repeat>\r
414 =\r
415 = Setup for call\r
416 = --------------\r
417 = GC_MODE                       read mode 1, write mode 2\r
418 = GC_COLORDONTCARE  set to 0, so all reads from video memory return 0xff\r
419 = GC_INDEX                      pointing at GC_BITMASK\r
420 =\r
421 =======================\r
422 */\r
423 \r
424 static  long            longtemp;\r
425 \r
426 void ScaleShape (int xcenter, int shapenum, unsigned height)\r
427 {\r
428         t_compshape     _seg *shape;\r
429         t_compscale _seg *comptable;\r
430         unsigned        scale,srcx,stopx,tempx;\r
431         int                     t;\r
432         unsigned        far *cmdptr;\r
433         boolean         leftvis,rightvis;\r
434 \r
435 \r
436         shape = PM_GetSpritePage (shapenum);\r
437 \r
438         scale = height>>3;                                              // low three bits are fractional\r
439         if (!scale || scale>maxscale)\r
440                 return;                                                         // too close or far away\r
441         comptable = scaledirectory[scale];\r
442 \r
443         *(((unsigned *)&linescale)+1)=(unsigned)comptable;      // seg of far call\r
444         *(((unsigned *)&linecmds)+1)=(unsigned)shape;           // seg of shape\r
445 \r
446 //\r
447 // scale to the left (from pixel 31 to shape->leftpix)\r
448 //\r
449         srcx = 32;\r
450         slinex = xcenter;\r
451         stopx = shape->leftpix;\r
452         cmdptr = &shape->dataofs[31-stopx];\r
453 \r
454         while ( --srcx >=stopx && slinex>0)\r
455         {\r
456                 (unsigned)linecmds = *cmdptr--;\r
457                 if ( !(slinewidth = comptable->width[srcx]) )\r
458                         continue;\r
459 \r
460                 if (slinewidth == 1)\r
461                 {\r
462                         slinex--;\r
463                         if (slinex<viewwidth)\r
464                         {\r
465                                 if (wallheight[slinex] >= height)\r
466                                         continue;               // obscured by closer wall\r
467                                 ScaleLine ();\r
468                         }\r
469                         continue;\r
470                 }\r
471 \r
472                 //\r
473                 // handle multi pixel lines\r
474                 //\r
475                 if (slinex>viewwidth)\r
476                 {\r
477                         slinex -= slinewidth;\r
478                         slinewidth = viewwidth-slinex;\r
479                         if (slinewidth<1)\r
480                                 continue;               // still off the right side\r
481                 }\r
482                 else\r
483                 {\r
484                         if (slinewidth>slinex)\r
485                                 slinewidth = slinex;\r
486                         slinex -= slinewidth;\r
487                 }\r
488 \r
489 \r
490                 leftvis = (wallheight[slinex] < height);\r
491                 rightvis = (wallheight[slinex+slinewidth-1] < height);\r
492 \r
493                 if (leftvis)\r
494                 {\r
495                         if (rightvis)\r
496                                 ScaleLine ();\r
497                         else\r
498                         {\r
499                                 while (wallheight[slinex+slinewidth-1] >= height)\r
500                                         slinewidth--;\r
501                                 ScaleLine ();\r
502                         }\r
503                 }\r
504                 else\r
505                 {\r
506                         if (!rightvis)\r
507                                 continue;               // totally obscured\r
508 \r
509                         while (wallheight[slinex] >= height)\r
510                         {\r
511                                 slinex++;\r
512                                 slinewidth--;\r
513                         }\r
514                         ScaleLine ();\r
515                         break;                  // the rest of the shape is gone\r
516                 }\r
517         }\r
518 \r
519 \r
520 //\r
521 // scale to the right\r
522 //\r
523         slinex = xcenter;\r
524         stopx = shape->rightpix;\r
525         if (shape->leftpix<31)\r
526         {\r
527                 srcx = 31;\r
528                 cmdptr = &shape->dataofs[32-shape->leftpix];\r
529         }\r
530         else\r
531         {\r
532                 srcx = shape->leftpix-1;\r
533                 cmdptr = &shape->dataofs[0];\r
534         }\r
535         slinewidth = 0;\r
536 \r
537         while ( ++srcx <= stopx && (slinex+=slinewidth)<viewwidth)\r
538         {\r
539                 (unsigned)linecmds = *cmdptr++;\r
540                 if ( !(slinewidth = comptable->width[srcx]) )\r
541                         continue;\r
542 \r
543                 if (slinewidth == 1)\r
544                 {\r
545                         if (slinex>=0 && wallheight[slinex] < height)\r
546                         {\r
547                                 ScaleLine ();\r
548                         }\r
549                         continue;\r
550                 }\r
551 \r
552                 //\r
553                 // handle multi pixel lines\r
554                 //\r
555                 if (slinex<0)\r
556                 {\r
557                         if (slinewidth <= -slinex)\r
558                                 continue;               // still off the left edge\r
559 \r
560                         slinewidth += slinex;\r
561                         slinex = 0;\r
562                 }\r
563                 else\r
564                 {\r
565                         if (slinex + slinewidth > viewwidth)\r
566                                 slinewidth = viewwidth-slinex;\r
567                 }\r
568 \r
569 \r
570                 leftvis = (wallheight[slinex] < height);\r
571                 rightvis = (wallheight[slinex+slinewidth-1] < height);\r
572 \r
573                 if (leftvis)\r
574                 {\r
575                         if (rightvis)\r
576                         {\r
577                                 ScaleLine ();\r
578                         }\r
579                         else\r
580                         {\r
581                                 while (wallheight[slinex+slinewidth-1] >= height)\r
582                                         slinewidth--;\r
583                                 ScaleLine ();\r
584                                 break;                  // the rest of the shape is gone\r
585                         }\r
586                 }\r
587                 else\r
588                 {\r
589                         if (rightvis)\r
590                         {\r
591                                 while (wallheight[slinex] >= height)\r
592                                 {\r
593                                         slinex++;\r
594                                         slinewidth--;\r
595                                 }\r
596                                 ScaleLine ();\r
597                         }\r
598                         else\r
599                                 continue;               // totally obscured\r
600                 }\r
601         }\r
602 }\r
603 \r
604 \r
605 \r
606 /*\r
607 =======================\r
608 =\r
609 = SimpleScaleShape\r
610 =\r
611 = NO CLIPPING, height in pixels\r
612 =\r
613 = Draws a compiled shape at [scale] pixels high\r
614 =\r
615 = each vertical line of the shape has a pointer to segment data:\r
616 =       end of segment pixel*2 (0 terminates line) used to patch rtl in scaler\r
617 =       top of virtual line with segment in proper place\r
618 =       start of segment pixel*2, used to jsl into compiled scaler\r
619 =       <repeat>\r
620 =\r
621 = Setup for call\r
622 = --------------\r
623 = GC_MODE                       read mode 1, write mode 2\r
624 = GC_COLORDONTCARE  set to 0, so all reads from video memory return 0xff\r
625 = GC_INDEX                      pointing at GC_BITMASK\r
626 =\r
627 =======================\r
628 */\r
629 \r
630 void SimpleScaleShape (int xcenter, int shapenum, unsigned height)\r
631 {\r
632         t_compshape     _seg *shape;\r
633         t_compscale _seg *comptable;\r
634         unsigned        scale,srcx,stopx,tempx;\r
635         int                     t;\r
636         unsigned        far *cmdptr;\r
637         boolean         leftvis,rightvis;\r
638 \r
639 \r
640         shape = PM_GetSpritePage (shapenum);\r
641 \r
642         scale = height>>1;\r
643         comptable = scaledirectory[scale];\r
644 \r
645         *(((unsigned *)&linescale)+1)=(unsigned)comptable;      // seg of far call\r
646         *(((unsigned *)&linecmds)+1)=(unsigned)shape;           // seg of shape\r
647 \r
648 //\r
649 // scale to the left (from pixel 31 to shape->leftpix)\r
650 //\r
651         srcx = 32;\r
652         slinex = xcenter;\r
653         stopx = shape->leftpix;\r
654         cmdptr = &shape->dataofs[31-stopx];\r
655 \r
656         while ( --srcx >=stopx )\r
657         {\r
658                 (unsigned)linecmds = *cmdptr--;\r
659                 if ( !(slinewidth = comptable->width[srcx]) )\r
660                         continue;\r
661 \r
662                 slinex -= slinewidth;\r
663                 ScaleLine ();\r
664         }\r
665 \r
666 \r
667 //\r
668 // scale to the right\r
669 //\r
670         slinex = xcenter;\r
671         stopx = shape->rightpix;\r
672         if (shape->leftpix<31)\r
673         {\r
674                 srcx = 31;\r
675                 cmdptr = &shape->dataofs[32-shape->leftpix];\r
676         }\r
677         else\r
678         {\r
679                 srcx = shape->leftpix-1;\r
680                 cmdptr = &shape->dataofs[0];\r
681         }\r
682         slinewidth = 0;\r
683 \r
684         while ( ++srcx <= stopx )\r
685         {\r
686                 (unsigned)linecmds = *cmdptr++;\r
687                 if ( !(slinewidth = comptable->width[srcx]) )\r
688                         continue;\r
689 \r
690                 ScaleLine ();\r
691                 slinex+=slinewidth;\r
692         }\r
693 }\r
694 \r
695 \r
696 \r
697 \r
698 //\r
699 // bit mask tables for drawing scaled strips up to eight pixels wide\r
700 //\r
701 // down here so the STUPID inline assembler doesn't get confused!\r
702 //\r
703 \r
704 \r
705 byte    mapmasks1[4][8] = {\r
706 {1 ,3 ,7 ,15,15,15,15,15},\r
707 {2 ,6 ,14,14,14,14,14,14},\r
708 {4 ,12,12,12,12,12,12,12},\r
709 {8 ,8 ,8 ,8 ,8 ,8 ,8 ,8} };\r
710 \r
711 byte    mapmasks2[4][8] = {\r
712 {0 ,0 ,0 ,0 ,1 ,3 ,7 ,15},\r
713 {0 ,0 ,0 ,1 ,3 ,7 ,15,15},\r
714 {0 ,0 ,1 ,3 ,7 ,15,15,15},\r
715 {0 ,1 ,3 ,7 ,15,15,15,15} };\r
716 \r
717 byte    mapmasks3[4][8] = {\r
718 {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0},\r
719 {0 ,0 ,0 ,0 ,0 ,0 ,0 ,1},\r
720 {0 ,0 ,0 ,0 ,0 ,0 ,1 ,3},\r
721 {0 ,0 ,0 ,0 ,0 ,1 ,3 ,7} };\r
722 \r
723 \r
724 unsigned        wordmasks[8][8] = {\r
725 {0x0080,0x00c0,0x00e0,0x00f0,0x00f8,0x00fc,0x00fe,0x00ff},\r
726 {0x0040,0x0060,0x0070,0x0078,0x007c,0x007e,0x007f,0x807f},\r
727 {0x0020,0x0030,0x0038,0x003c,0x003e,0x003f,0x803f,0xc03f},\r
728 {0x0010,0x0018,0x001c,0x001e,0x001f,0x801f,0xc01f,0xe01f},\r
729 {0x0008,0x000c,0x000e,0x000f,0x800f,0xc00f,0xe00f,0xf00f},\r
730 {0x0004,0x0006,0x0007,0x8007,0xc007,0xe007,0xf007,0xf807},\r
731 {0x0002,0x0003,0x8003,0xc003,0xe003,0xf003,0xf803,0xfc03},\r
732 {0x0001,0x8001,0xc001,0xe001,0xf001,0xf801,0xfc01,0xfe01} };\r
733 \r
734 int                     slinex,slinewidth;\r
735 unsigned        far *linecmds;\r
736 long            linescale;\r
737 unsigned        maskword;\r
738 \r