removing now unneeded dir from package
[drnoksnes] / clip.cpp
1 /*
2  * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
3  *
4  * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
5  *                           Jerremy Koot (jkoot@snes9x.com)
6  *
7  * Super FX C emulator code 
8  * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
9  *                           Gary Henderson.
10  * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
11  *
12  * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
13  * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
14  * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
15  *
16  * DOS port code contains the works of other authors. See headers in
17  * individual files.
18  *
19  * Snes9x homepage: http://www.snes9x.com
20  *
21  * Permission to use, copy, modify and distribute Snes9x in both binary and
22  * source form, for non-commercial purposes, is hereby granted without fee,
23  * providing that this license information and copyright notice appear with
24  * all copies and any derived work.
25  *
26  * This software is provided 'as-is', without any express or implied
27  * warranty. In no event shall the authors be held liable for any damages
28  * arising from the use of this software.
29  *
30  * Snes9x is freeware for PERSONAL USE only. Commercial users should
31  * seek permission of the copyright holders first. Commercial use includes
32  * charging money for Snes9x or software derived from Snes9x.
33  *
34  * The copyright holders request that bug fixes and improvements to the code
35  * should be forwarded to them so everyone can benefit from the modifications
36  * in future versions.
37  *
38  * Super NES and Super Nintendo Entertainment System are trademarks of
39  * Nintendo Co., Limited and its subsidiary companies.
40  */
41 #include <stdlib.h>
42
43 #include "snes9x.h"
44 #include "memmap.h"
45 #include "ppu.h"
46
47 struct Band
48 {
49     uint32 Left;
50     uint32 Right;
51 };
52
53 #undef MIN
54 #undef MAX
55 #define MIN(A,B) ((A) < (B) ? (A) : (B))
56 #define MAX(A,B) ((A) > (B) ? (A) : (B))
57 #define BAND_EMPTY(B) (B.Left >= B.Right)
58 #define BANDS_INTERSECT(A,B) ((A.Left >= B.Left && A.Left < B.Right) || \
59                               (A.Right > B.Left && A.Right <= B.Right))
60 #define OR_BANDS(R,A,B) {\
61     R.Left = MIN(A.Left, B.Left); \
62     R.Right = MAX(A.Right, B.Right);}
63     
64 #define AND_BANDS(R,A,B) {\
65     R.Left = MAX(A.Left, B.Left); \
66     R.Right = MIN(A.Right, B.Right);}
67
68 #ifndef _SNESPPC
69 static int IntCompare (const void *d1, const void *d2)
70 #else
71 static int _cdecl IntCompare (const void *d1, const void *d2)
72 #endif
73 {
74     if (*(uint32 *) d1 > *(uint32 *) d2)
75         return (1);
76     else
77     if (*(uint32 *) d1 < *(uint32 *) d2)
78         return (-1);
79     return (0);
80 }
81
82 #ifndef _SNESPPC
83 static int BandCompare (const void *d1, const void *d2)
84 #else
85 static int _cdecl BandCompare (const void *d1, const void *d2)
86 #endif
87 {
88     if (((struct Band *) d1)->Left > ((struct Band *) d2)->Left)
89         return (1);
90     else
91     if (((struct Band *) d1)->Left < ((struct Band *) d2)->Left)
92         return (-1);
93     return (0);
94 }
95
96 void ComputeClipWindows ()
97 {
98     struct ClipData *pClip = &IPPU.Clip [0];
99
100     // Loop around the main screen then the sub-screen.
101     for (int c = 0; c < 2; c++, pClip++)
102     {
103         // Loop around the colour window then a clip window for each of the
104         // background layers.
105         for (int w = 5; w >= 0; w--)
106         {
107             pClip->Count[w] = 0;
108
109             if (w == 5) // The colour window...
110             {
111                 if (c == 0) // ... on the main screen
112                 {
113                     if ((Memory.FillRAM [0x2130] & 0xc0) == 0xc0)
114                     {
115                         // The whole of the main screen is switched off,
116                         // completely clip everything.
117                         for (int i = 0; i < 6; i++)
118                         {
119                             IPPU.Clip [c].Count [i] = 1;
120                             IPPU.Clip [c].Left [0][i] = 1;
121                             IPPU.Clip [c].Right [0][i] = 0;
122                         }
123                         continue;
124                     }
125                     else
126                     if ((Memory.FillRAM [0x2130] & 0xc0) == 0x00)
127                         continue;
128                 }
129                 else
130                 {
131                     // .. colour window on the sub-screen.
132                     if ((Memory.FillRAM [0x2130] & 0x30) == 0x30)
133                     {
134                         // The sub-screen is switched off, completely
135                         // clip everything.
136                         for (int i = 0; i < 6; i++)
137                         {
138                             IPPU.Clip [1].Count [i] = 1;
139                             IPPU.Clip [1].Left [0][i] = 1;
140                             IPPU.Clip [1].Right [0][i] = 0;
141                         }
142                         return;
143                     }
144                     else
145                     if ((Memory.FillRAM [0x2130] & 0x30) == 0x00)
146                         continue;
147                 }
148             }
149             if (!Settings.DisableGraphicWindows)
150             {
151                 if (w == 5 || pClip->Count [5] ||
152                     (Memory.FillRAM [0x212c + c] & 
153                      Memory.FillRAM [0x212e + c] & (1 << w)))
154                 {
155                     struct Band Win1[3];
156                     struct Band Win2[3];
157                     uint32 Window1Enabled = 0;
158                     uint32 Window2Enabled = 0;
159                     bool8_32 invert = (w == 5 && 
160                                     ((c == 1 && (Memory.FillRAM [0x2130] & 0x30) == 0x10) ||
161                                      (c == 0 && (Memory.FillRAM [0x2130] & 0xc0) == 0x40)));
162
163                     if (w == 5 ||
164                         (Memory.FillRAM [0x212c + c] & Memory.FillRAM [0x212e + c] & (1 << w)))
165                     {
166                         if (PPU.ClipWindow1Enable [w])
167                         {
168                             if (!PPU.ClipWindow1Inside [w])
169                             {
170                                 Win1[Window1Enabled].Left = PPU.Window1Left;
171                                 Win1[Window1Enabled++].Right = PPU.Window1Right + 1;
172                             }
173                             else
174                             {
175                                 if (PPU.Window1Left <= PPU.Window1Right)
176                                 {
177                                     if (PPU.Window1Left > 0)
178                                     {
179                                         Win1[Window1Enabled].Left = 0;
180                                         Win1[Window1Enabled++].Right = PPU.Window1Left;
181                                     }
182                                     if (PPU.Window1Right < 255)
183                                     {
184                                         Win1[Window1Enabled].Left = PPU.Window1Right + 1;
185                                         Win1[Window1Enabled++].Right = 256;
186                                     }
187                                     if (Window1Enabled == 0)
188                                     {
189                                         Win1[Window1Enabled].Left = 1;
190                                         Win1[Window1Enabled++].Right = 0;
191                                     }
192                                 }
193                                 else
194                                 {
195                                     // 'outside' a window with no range - 
196                                     // appears to be the whole screen.
197                                     Win1[Window1Enabled].Left = 0;
198                                     Win1[Window1Enabled++].Right = 256;
199                                 }
200                             }
201                         }
202                         if (PPU.ClipWindow2Enable [w])
203                         {
204                             if (!PPU.ClipWindow2Inside [w])
205                             {
206                                 Win2[Window2Enabled].Left = PPU.Window2Left;
207                                 Win2[Window2Enabled++].Right = PPU.Window2Right + 1;
208                             }
209                             else
210                             {
211                                 if (PPU.Window2Left <= PPU.Window2Right)
212                                 {
213                                     if (PPU.Window2Left > 0)
214                                     {
215                                         Win2[Window2Enabled].Left = 0;
216                                         Win2[Window2Enabled++].Right = PPU.Window2Left;
217                                     }
218                                     if (PPU.Window2Right < 255)
219                                     {
220                                         Win2[Window2Enabled].Left = PPU.Window2Right + 1;
221                                         Win2[Window2Enabled++].Right = 256;
222                                     }
223                                     if (Window2Enabled == 0)
224                                     {
225                                         Win2[Window2Enabled].Left = 1;
226                                         Win2[Window2Enabled++].Right = 0;
227                                     }
228                                 }
229                                 else
230                                 {
231                                     Win2[Window2Enabled].Left = 0;
232                                     Win2[Window2Enabled++].Right = 256;
233                                 }
234                             }
235                         }
236                     }
237                     if (Window1Enabled && Window2Enabled)
238                     {
239                         // Overlap logic
240                         //
241                         // Each window will be in one of three states:
242                         // 1. <no range> (Left > Right. One band)
243                         // 2. |    ----------------             | (Left >= 0, Right <= 255, Left <= Right. One band)
244                         // 3. |------------           ----------| (Left1 == 0, Right1 < Left2; Left2 > Right1, Right2 == 255. Two bands)
245                         
246                         struct Band Bands [6];
247                         int B = 0;
248                         switch (PPU.ClipWindowOverlapLogic [w] ^ 1)
249                         {
250                         case CLIP_OR:
251                             if (Window1Enabled == 1)
252                             {
253                                 if (BAND_EMPTY(Win1[0]))
254                                 {
255                                     B = Window2Enabled;
256                                     memmove (Bands, Win2,
257                                              sizeof(Win2[0]) * Window2Enabled);
258                                 }
259                                 else
260                                 {
261                                     if (Window2Enabled == 1)
262                                     {
263                                         if (BAND_EMPTY (Win2[0]))
264                                             Bands[B++] = Win1[0];
265                                         else
266                                         {
267                                             if (BANDS_INTERSECT (Win1[0], Win2[0]))
268                                             {
269                                                 OR_BANDS(Bands[0],Win1[0], Win2[0])
270                                                 B = 1;
271                                             }
272                                             else
273                                             {
274                                                 Bands[B++] = Win1[0];
275                                                 Bands[B++] = Win2[0];
276                                             }
277                                         }
278                                     }
279                                     else
280                                     {
281                                         if (BANDS_INTERSECT(Win1[0], Win2[0]))
282                                         {
283                                             OR_BANDS(Bands[0], Win1[0], Win2[0])
284                                             if (BANDS_INTERSECT(Win1[0], Win2[1]))
285                                                 OR_BANDS(Bands[1], Win1[0], Win2[1])
286                                             else
287                                                 Bands[1] = Win2[1];
288                                             B = 1;
289                                             if (BANDS_INTERSECT(Bands[0], Bands[1]))
290                                                 OR_BANDS(Bands[0], Bands[0], Bands[1])
291                                             else
292                                                 B = 2;
293                                         }
294                                         else
295                                         if (BANDS_INTERSECT(Win1[0], Win2[1]))
296                                         {
297                                             Bands[B++] = Win2[0];
298                                             OR_BANDS(Bands[B], Win1[0], Win2[1]);
299                                             B++;
300                                         }
301                                         else
302                                         {
303                                             Bands[0] = Win2[0];
304                                             Bands[1] = Win1[0];
305                                             Bands[2] = Win2[1];
306                                             B = 3;
307                                         }
308                                     }
309                                 }
310                             }
311                             else
312                             if (Window2Enabled == 1)
313                             {
314                                 if (BAND_EMPTY(Win2[0]))
315                                 {
316                                     // Window 2 defines an empty range - just
317                                     // use window 1 as the clipping (which
318                                     // could also be empty).
319                                     B = Window1Enabled;
320                                     memmove (Bands, Win1,
321                                              sizeof(Win1[0]) * Window1Enabled);
322                                 }
323                                 else
324                                 {
325                                     // Window 1 has two bands and Window 2 has one.
326                                     // Neither is an empty region.
327                                     if (BANDS_INTERSECT(Win2[0], Win1[0]))
328                                     {
329                                         OR_BANDS(Bands[0], Win2[0], Win1[0])
330                                         if (BANDS_INTERSECT(Win2[0], Win1[1]))
331                                             OR_BANDS(Bands[1], Win2[0], Win1[1])
332                                         else
333                                             Bands[1] = Win1[1];
334                                         B = 1;
335                                         if (BANDS_INTERSECT(Bands[0], Bands[1]))
336                                             OR_BANDS(Bands[0], Bands[0], Bands[1])
337                                         else
338                                             B = 2;
339                                     }
340                                     else
341                                     if (BANDS_INTERSECT(Win2[0], Win1[1]))
342                                     {
343                                         Bands[B++] = Win1[0];
344                                         OR_BANDS(Bands[B], Win2[0], Win1[1]);
345                                         B++;
346                                     }
347                                     else
348                                     {
349                                         Bands[0] = Win1[0];
350                                         Bands[1] = Win2[0];
351                                         Bands[2] = Win1[1];
352                                         B = 3;
353                                     }
354                                 }
355                             }
356                             else
357                             {
358                                 // Both windows have two bands
359                                 OR_BANDS(Bands[0], Win1[0], Win2[0]);
360                                 OR_BANDS(Bands[1], Win1[1], Win2[1]);
361                                 B = 1;
362                                 if (BANDS_INTERSECT(Bands[0], Bands[1]))
363                                     OR_BANDS(Bands[0], Bands[0], Bands[1])
364                                 else
365                                     B = 2;
366                             }
367                             break;
368
369                         case CLIP_AND:
370                             if (Window1Enabled == 1)
371                             {
372                                 // Window 1 has one band
373                                 if (BAND_EMPTY(Win1[0]))
374                                     Bands [B++] = Win1[0];
375                                 else
376                                 if (Window2Enabled == 1)
377                                 {
378                                     if (BAND_EMPTY (Win2[0]))
379                                         Bands [B++] = Win2[0];
380                                     else
381                                     {
382                                         AND_BANDS(Bands[0], Win1[0], Win2[0]);
383                                         B = 1;
384                                     }
385                                 }
386                                 else
387                                 {
388                                     AND_BANDS(Bands[0], Win1[0], Win2[0]);
389                                     AND_BANDS(Bands[1], Win1[0], Win2[1]);
390                                     B = 2;
391                                 }
392                             }
393                             else
394                             if (Window2Enabled == 1)
395                             {
396                                 if (BAND_EMPTY(Win2[0]))
397                                     Bands[B++] = Win2[0];
398                                 else
399                                 {
400                                     // Window 1 has two bands.
401                                     AND_BANDS(Bands[0], Win1[0], Win2[0]);
402                                     AND_BANDS(Bands[1], Win1[1], Win2[0]);
403                                     B = 2;
404                                 }
405                             }
406                             else
407                             {
408                                 // Both windows have two bands.
409                                 AND_BANDS(Bands[0], Win1[0], Win2[0]);
410                                 AND_BANDS(Bands[1], Win1[1], Win2[1]);
411                                 B = 2;
412                                 if (BANDS_INTERSECT(Win1[0], Win2[1]))
413                                 {
414                                     AND_BANDS(Bands[2], Win1[0], Win2[1]);
415                                     B = 3;
416                                 }
417                                 else
418                                 if (BANDS_INTERSECT(Win1[1], Win2[0]))
419                                 {
420                                     AND_BANDS(Bands[2], Win1[1], Win2[0]);
421                                     B = 3;
422                                 }
423                             }
424                             break;
425                         case CLIP_XNOR:
426                             invert = !invert;
427                             // Fall...
428
429                         case CLIP_XOR:
430                             if (Window1Enabled == 1 && BAND_EMPTY(Win1[0]))
431                             {
432                                 B = Window2Enabled;
433                                 memmove (Bands, Win2,
434                                          sizeof(Win2[0]) * Window2Enabled);
435                             }
436                             else
437                             if (Window2Enabled == 1 && BAND_EMPTY(Win2[0]))
438                             {
439                                 B = Window1Enabled;
440                                 memmove (Bands, Win1,
441                                          sizeof(Win1[0]) * Window1Enabled);
442                             }
443                             else
444                             {
445                                 uint32 p = 0;
446                                 uint32 points [10];
447                                 uint32 i;
448
449                                 invert = !invert;
450                                 // Build an array of points (window edges)
451                                 points [p++] = 0;
452                                 for (i = 0; i < Window1Enabled; i++)
453                                 {
454                                     points [p++] = Win1[i].Left;
455                                     points [p++] = Win1[i].Right;
456                                 }
457                                 for (i = 0; i < Window2Enabled; i++)
458                                 {
459                                     points [p++] = Win2[i].Left;
460                                     points [p++] = Win2[i].Right;
461                                 }
462                                 points [p++] = 256;
463                                 // Sort them
464                                 qsort ((void *) points, p, sizeof (points [0]),
465                                        IntCompare);
466                                 for (i = 0; i < p; i += 2)
467                                 {
468                                     if (points [i] == points [i + 1])
469                                         continue;
470                                     Bands [B].Left = points [i];
471                                     while (i + 2 < p && 
472                                            points [i + 1] == points [i + 2])
473                                     {
474                                         i += 2;
475                                     }
476                                     Bands [B++].Right = points [i + 1];
477                                 }
478                             }
479                             break;
480                         }
481                         if (invert)
482                         {
483                             int b;
484                             int j = 0;
485                             int empty_band_count = 0;
486
487                             // First remove all empty bands from the list.
488                             for (b = 0; b < B; b++)
489                             {
490                                 if (!BAND_EMPTY(Bands[b]))
491                                 {
492                                     if (b != j)
493                                         Bands[j] = Bands[b];
494                                     j++;
495                                 }
496                                 else
497                                     empty_band_count++;
498                             }
499                             
500                             if (j > 0)
501                             {
502                                 if (j == 1)
503                                 {
504                                     j = 0;
505                                     // Easy case to deal with, so special case it.
506
507                                     if (Bands[0].Left > 0)
508                                     {
509                                         pClip->Left[j][w] = 0;
510                                         pClip->Right[j++][w] = Bands[0].Left + 1;
511                                     }
512                                     if (Bands[0].Right < 256)
513                                     {
514                                         pClip->Left[j][w] = Bands[0].Right;
515                                         pClip->Right[j++][w] = 256;
516                                     }
517                                     if (j == 0)
518                                     {
519                                         pClip->Left[j][w] = 1;
520                                         pClip->Right[j++][w] = 0;
521                                     }
522                                 }
523                                 else
524                                 {
525                                     // Now sort the bands into order
526                                     B = j;
527                                     qsort ((void *) Bands, B,
528                                            sizeof (Bands [0]), BandCompare);
529
530                                     // Now invert the area the bands cover
531                                     j = 0;
532                                     for (b = 0; b < B; b++)
533                                     {
534                                         if (b == 0 && Bands[b].Left > 0)
535                                         {
536                                             pClip->Left[j][w] = 0;
537                                             pClip->Right[j++][w] = Bands[b].Left + 1;
538                                         }
539                                         else
540                                         if (b == B - 1 && Bands[b].Right < 256)
541                                         {
542                                             pClip->Left[j][w] = Bands[b].Right;
543                                             pClip->Right[j++][w] = 256;
544                                         }
545                                         if (b < B - 1)
546                                         {
547                                             pClip->Left[j][w] = Bands[b].Right;
548                                             pClip->Right[j++][w] = Bands[b + 1].Left + 1;
549                                         }
550                                     }
551                                 }
552                             }
553                             else
554                             {
555                                 // Inverting a window that consisted of only
556                                 // empty bands is the whole width of the screen.
557                                 // Needed for Mario Kart's rear-view mirror display.
558                                 if (empty_band_count)
559                                 {
560                                     pClip->Left[j][w] = 0;
561                                     pClip->Right[j][w] = 256;
562                                     j++;
563                                 }
564                             }
565                             pClip->Count[w] = j;
566                         }
567                         else
568                         {
569                             for (int j = 0; j < B; j++)
570                             {
571                                 pClip->Left[j][w] = Bands[j].Left;
572                                 pClip->Right[j][w] = Bands[j].Right;
573                             }
574                             pClip->Count [w] = B;
575                         }
576                     }
577                     else
578                     {
579                         // Only one window enabled so no need to perform
580                         // complex overlap logic...
581
582                         if (Window1Enabled)
583                         {
584                             if (invert)
585                             {
586                                 int j = 0;
587
588                                 if (Window1Enabled == 1)
589                                 {
590                                     if (Win1[0].Left <= Win1[0].Right)
591                                     {
592                                         if (Win1[0].Left > 0)
593                                         {
594                                             pClip->Left[j][w] = 0;
595                                             pClip->Right[j++][w] = Win1[0].Left;
596                                         }
597                                         if (Win1[0].Right < 256)
598                                         {
599                                             pClip->Left[j][w] = Win1[0].Right;
600                                             pClip->Right[j++][w] = 256;
601                                         }
602                                         if (j == 0)
603                                         {
604                                             pClip->Left[j][w] = 1;
605                                             pClip->Right[j++][w] = 0;
606                                         }
607                                     }
608                                     else
609                                     {
610                                         pClip->Left[j][w] = 0;
611                                         pClip->Right[j++][w] = 256;
612                                     }
613                                 }
614                                 else
615                                 {
616                                     pClip->Left [j][w] = Win1[0].Right;
617                                     pClip->Right[j++][w] = Win1[1].Left;
618                                 }
619                                 pClip->Count [w] = j;
620                             }
621                             else
622                             {
623                                 for (uint32 j = 0; j < Window1Enabled; j++)
624                                 {
625                                     pClip->Left [j][w] = Win1[j].Left;
626                                     pClip->Right [j][w] = Win1[j].Right;
627                                 }
628                                 pClip->Count [w] = Window1Enabled;
629                             }
630                         }
631                         else
632                         if (Window2Enabled)
633                         {
634                             if (invert)
635                             {
636                                 int j = 0;
637                                 if (Window2Enabled == 1)
638                                 {
639                                     if (Win2[0].Left <= Win2[0].Right)
640                                     {
641                                         if (Win2[0].Left > 0)
642                                         {
643                                             pClip->Left[j][w] = 0;
644                                             pClip->Right[j++][w] = Win2[0].Left;
645                                         }
646                                         if (Win2[0].Right < 256)
647                                         {
648                                             pClip->Left[j][w] = Win2[0].Right;
649                                             pClip->Right[j++][w] = 256;
650                                         }
651                                         if (j == 0)
652                                         {
653                                             pClip->Left[j][w] = 1;
654                                             pClip->Right[j++][w] = 0;
655                                         }
656                                     }
657                                     else
658                                     {
659                                         pClip->Left[j][w] = 0;
660                                         pClip->Right[j++][w] = 256;
661                                     }
662                                 }
663                                 else
664                                 {
665                                     pClip->Left [j][w] = Win2[0].Right;
666                                     pClip->Right[j++][w] = Win2[1].Left + 1;
667                                 }
668                                 pClip->Count [w] = j;
669                             }
670                             else
671                             {
672                                 for (uint32 j = 0; j < Window2Enabled; j++)
673                                 {
674                                     pClip->Left [j][w] = Win2[j].Left;
675                                     pClip->Right [j][w] = Win2[j].Right;
676                                 }
677                                 pClip->Count [w] = Window2Enabled;
678                             }
679                         }
680                     }
681
682                     if (w != 5)
683                     {
684                         if (pClip->Count [5])
685                         {
686                             // Colour window enabled. Set the
687                             // clip windows for all remaining backgrounds to be
688                             // the same as the colour window.
689                             if (pClip->Count [w] == 0)
690                             {
691                                 pClip->Count [w] = pClip->Count [5];
692                                 for (uint32 i = 0; i < pClip->Count [w]; i++)
693                                 {
694                                     pClip->Left [i][w] = pClip->Left [i][5];
695                                     pClip->Right [i][w] = pClip->Right [i][5];
696                                 }
697                             }
698                             else
699                             {
700                                 // Intersect the colour window with the bg's
701                                 // own clip window.
702                                 for (uint32 i = 0; i < pClip->Count [w]; i++)
703                                 {
704                                                 uint32 j;
705                                                 for (j = 0; j < pClip->Count [5]; j++)
706                                     {
707                                                         if((pClip->Left[i][w] >= pClip->Left[j][5] && pClip->Left[i][w] < pClip->Right[j][5]) || (pClip->Left[j][5] >= pClip->Left[i][w] && pClip->Left[j][5] < pClip->Right[i][w])){
708                                                                 // Found an intersection!
709                                                                 pClip->Left[i][w]=MAX(pClip->Left[i][w], pClip->Left[j][5]);
710                                                                 pClip->Right[i][w]=MIN(pClip->Right[i][w], pClip->Right[j][5]);
711                                                                 goto Clip_ok;
712                                         }
713                                     }
714                                                 // no intersection, nullify it
715                                                 pClip->Left[i][w]=1;
716                                                 pClip->Right[i][w]=0;
717 Clip_ok:
718                                                 j=0; // dummy statement
719                                 }
720                             }
721                         }
722                     }
723                 } // if (w == 5 | ...
724             } // if (!Settings.DisableGraphicWindows)
725         } // for (int w...
726     } // for (int c...
727 }