OSDN Git Service

updated copyleft and need to test and fix newer version of open watcom
[proj16/16.git] / src / lib / 16_vlpal.c
index 02e5229..f0b8d5f 100755 (executable)
@@ -1,5 +1,5 @@
 /* Project 16 Source Code~\r
- * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
+ * Copyright (C) 2012-2022 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
  *\r
  * This file is part of Project 16.\r
  *\r
 \r
 //color checker~\r
 //i want to make another vesion that checks the palette when the palette is being appened~\r
-void modexchkcolor(imgtestpal_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/)\r
+void modexchkcolor(imgtestpal_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/, global_game_variables_t *gv)\r
 {\r
-               byte *pal;\r
+               byte *pal=&(gv->video.palette);\r
                word zz=0;\r
-               pal = modexNewPal();\r
-               modexPalSave(pal);\r
-#ifdef BEVERBOSEPALCHECK\r
-               printf("q: %02d\n", (*q));//\r
-\r
-               printf("chkcolor start~\n");\r
-               printf("1                                  (*z): %d\n", (*z)/3);\r
-               printf("1                                  (*i): %d\n", (*i)/3);\r
-               printf("1 offset of color in palette    (*q): %d\n", (*q)/3);//\r
-               printf("wwwwwwwwwwwwwwww\n");\r
-#endif\r
+               //pal = modexNewPal();\r
+//             modexPalSave(pal);\r
+               CHKCOLDBGOUT1\r
                //check palette for dups\r
                for(; (*z)<PAL_SIZE; (*z)+=3)\r
                {\r
-#ifdef BEVERBOSEPALCHECK\r
-                       printf("\n              z: %d\n", (*z));//\r
-                       printf("                  q: %d\n", (*q));//\r
-                       printf("                  z+q: %d\n\n", ((*z)+(*q)));//\r
-#endif\r
+                       CHKCOLDBGOUT2\r
                        //if((*z)%3==0)\r
                        //{\r
 //----                   if(pal[(*z)]==pal[(*z)+3] && pal[(*z)+1]==pal[(*z)+4] && pal[(*z)+2]==pal[(*z)+5])\r
                                if((*z)==(*i))\r
                                {\r
-#ifdef BEVERBOSEPALCHECK\r
-                                         printf("\n%d  [%02d][%02d][%02d]\n", (*z), pal[(*z)], pal[(*z)+1], pal[(*z)+2]);//\r
-                                         printf("%d      [%02d][%02d][%02d]\n\n", (*z)+3, pal[(*z)+3], pal[(*z)+4], pal[(*z)+5]);//\r
-#endif\r
+                                       CHKCOLDBGOUT3\r
 //0000                           (*z)-=3;\r
                                        break;\r
                                }\r
                                else for(zz=0; zz<(*q); zz+=3)\r
                                {\r
-#ifdef BEVERBOSEPALCHECK\r
-                                       printf("zz: %02d\n", zz/3);//\r
-#endif\r
+                                       CHKCOLDBGOUT4\r
                                        if(zz%3==0)\r
                                        {\r
                                                if(pal[((*z)+(*q))]==pal[((*z)+(*q))+3] && pal[((*z)+(*q))+1]==pal[((*z)+(*q))+4] && pal[((*z)+(*q))+2]==pal[((*z)+(*q))+5])    //break if duplicate colors found in palette because it have reached the end of the current data of the palette\r
                                                {\r
 //                                                       (*z)-=3;\r
 //                                                       (*i)-=3;\r
-#ifdef BEVERBOSEPALCHECK\r
-                                                         printf("\nzq1:%d[%02d][%02d][%02d]\n", (zz+*q), pal[(zz+*q)], pal[(zz+*q)+1], pal[(zz+*q)+2]);//\r
-                                                         printf("zq2:%d[%02d][%02d][%02d]\n\n", (zz+*q)+3, pal[(zz+*q)+3], pal[(zz+*q)+4], pal[(zz+*q)+5]);//\r
-#endif\r
+                                                       CHKCOLDBGOUT5\r
                                                        break;\r
                                                }\r
                                                else if(pal[zz]==pal[((*z)+(*q))] && pal[zz+1]==pal[((*z)+(*q))+1] && pal[zz+2]==pal[((*z)+(*q))+2])\r
                                                {\r
-#ifdef BEVERBOSEPALCHECK\r
-                                                         printf("\n\nwwwwwwwwwwwwwwww\n");//\r
-                                                         printf("      zq: %d  [%02d][%02d][%02d] value that is needing to be changed~\n", ((*z)+(*q))/3, pal[((*z)+(*q))], pal[((*z)+(*q))+1], pal[((*z)+(*q))+2]);//\r
-                                                         printf("      zz: %d  [%02d][%02d][%02d] value that the previous value is going to change to~\n", (zz)/3, pal[zz], pal[zz+1], pal[zz+2]);//\r
-                                                         //printf("      zv: %d  [%02d][%02d][%02d] wwww\n", (zz-z+q)/3, pal[(zz-z+q)], pal[(zz-z+q)+1], pal[(zz-z+q)+2]);//\r
-                                                         printf("      z : %d  [%02d][%02d][%02d] offset value~\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);//\r
-#endif\r
+                                                       CHKCOLDBGOUT6\r
 //++++                                           (*i)--;\r
 //                                                       (*z)--;\r
                                                        //expand dong here\r
@@ -96,18 +70,11 @@ no... wait.... no wwww
 */\r
                                                        //for(zzii=0; zzii<3; zzii++)\r
                                                        //{\r
-#ifdef BEVERBOSEPALCHECK\r
-                                                               printf("z+q: %d\n\n", ((*z)+(*q)));\r
-#endif\r
+                                                               CHKCOLDBGOUT7\r
                                                                a[(((*z)+(*q)))]=zz;\r
                                                        //}\r
                                                        (*aa)=(((*z)+(*q)));\r
-#ifdef BEVERBOSEPALCHECK\r
-                                                       printf("!!                                        a[%02d]: %d\n", (((*z)+(*q))/3), zz/3);\r
-                                                         printf("\n              aa: %d\n\n", (*aa));//\r
-                                                         printf("      a[%02d]=(%02d) offset array i think the palette should be updated again~\n", ((*z)+(*q))/3, a[((*z)+(*q))/3]);//\r
-                                                         printf("wwwwwwwwwwwwwwww\n\n");//\r
-#endif\r
+                                                       CHKCOLDBGOUT8\r
                                                }\r
                                                /*else\r
                                                {\r
@@ -117,31 +84,26 @@ no... wait.... no wwww
                                                        printf("z : %d  [%02d][%02d][%02d]\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);\r
                                                        printf("================\n");\r
                                                }*/\r
-#ifdef BEVERBOSEPALCHECK\r
-                                               printf("[%d]", (zz+*q));//\r
-#endif\r
+                                               CHKCOLDBGOUT9\r
                                        }\r
                                }\r
                }\r
-#ifdef BEVERBOSEPALCHECK\r
-               printf("wwwwwwwwwwwwwwww\n");\r
-               printf("2                                  (*z): %d\n", (*z)/3);\r
-               printf("2                                  (*i): %d\n", (*i)/3);\r
-               printf("2 offset of color in palette    (*q): %d\n", (*q)/3);//\r
-               printf("chkcolor end~\n");\r
-#endif\r
+               CHKCOLDBGOUT10\r
                //free(pal);\r
 }\r
 \r
+//what is *i, w, q, qq, z, aq, aa, pp, qp, and aqoffset...\r
+//pp is related to i\r
+\r
 void\r
-VL_palette(imgtestpal_t *bmp, byte *p, word *i, word qp, word aqoffset)\r
+VL_palette(imgtestpal_t *bmp, byte *p, word *i, word qp, word aqoffset, word *apal, global_game_variables_t *gv)\r
 {\r
        //byte *p = bmp->palette;\r
        word w=0;\r
        word q=0;\r
        word qq=0;\r
-       static word a[PAL_SIZE];        //palette array of change values!\r
-       word z=0, aq=0, aa=0, pp=0;\r
+       word a[PAL_SIZE];       //palette array of change values!\r
+       word z=0, aq=0, aa=0, pp=0, iq=0;//iq=(*i)-q\r
 \r
        //modexWaitBorder();\r
        vga_wait_for_vsync();\r
@@ -165,13 +127,14 @@ VL_palette(imgtestpal_t *bmp, byte *p, word *i, word qp, word aqoffset)
 #endif\r
                outp(PAL_WRITE_REG, qq);  /* start at the beginning of palette */\r
        }\r
+       iq=(*i)-q;\r
        if((*i)<PAL_SIZE && w==0)\r
        {\r
                for(; (*i)<PAL_SIZE; (*i)++)\r
                {\r
                        //if(i%3==0 && (p[i+5]==p[i+4] && p[i+4]==p[i+3] && p[i+3]==p[i+2] && p[i+2]==p[i+1] && p[i+1]==p[i] && p[i+5]==p[i]))\r
-//____           if((qp>0)&&((*i)-q)%3==0 && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5])) outp(PAL_DATA_REG, p[(*i)-q]); else\r
-                       if(((((*i)-q)%3==0)) && (p[((*i)-q)]==p[((*i)-q)+3] && p[((*i)-q)+1]==p[((*i)-q)+4] && p[((*i)-q)+2]==p[((*i)-q)+5]))\r
+//____           if((qp>0)&&(iq)%3==0 && (p[(iq)]==p[(iq)+3] && p[(iq)+1]==p[(iq)+4] && p[(iq)+2]==p[(iq)+5])) outp(PAL_DATA_REG, p[iq]); else\r
+                       if((((iq)%3==0)) && (p[(iq)]==p[(iq)+3] && p[(iq)+1]==p[(iq)+4] && p[(iq)+2]==p[(iq)+5]))\r
                        {\r
                                w++;\r
                                break;\r
@@ -190,7 +153,7 @@ VL_palette(imgtestpal_t *bmp, byte *p, word *i, word qp, word aqoffset)
                        {\r
                                if(bmp->offset==0 && (*i)<3 && q==0) outp(PAL_DATA_REG, 0);\r
                                else\r
-                               if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);\r
+                               if(qp==0) outp(PAL_DATA_REG, p[iq]);\r
                                else\r
                                { outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);\r
 #ifdef BEVERBOSEPALCHECK\r
@@ -220,7 +183,7 @@ VL_palette(imgtestpal_t *bmp, byte *p, word *i, word qp, word aqoffset)
                printf("1(*i)=%02d\n", (*i)/3);//\r
                printf("1z=%02d\n", z/3);//\r
 #endif\r
-               modexchkcolor(bmp, &q, &a, &aa, &z, i);\r
+               modexchkcolor(bmp, &q, &a, &aa, &z, i, gv);\r
 #ifdef BEVERBOSEPALCHECK\r
                printf("2(*i)=%02d\n", (*i)/3);\r
                printf("2z=%02d\n", z/3);\r
@@ -230,7 +193,7 @@ aqpee:
                while(aq<=aa)\r
                {\r
 #ifdef BEVERBOSEPALCHECK\r
-                       printf("a[%02d]=(%d)\n", aq, a[aq]);//\r
+//                     printf("a[%02d]=(%d)\n", aq, a[aq]);//0000\r
 #endif\r
                        if(a[aq]==-1) aq++;\r
                        else { aqoffset++; break; }\r
@@ -294,7 +257,7 @@ printf("              aq=%02d\n", aq);//
 printf("                 aa=%02d\n", aa);//\r
 #endif\r
        //update the palette~\r
-       VL_palette(bmp, p, &pp, aq, aqoffset);\r
+       VL_palette(bmp, p, &pp, aq, aqoffset, &a, gv);\r
        (*i)=pp;\r
 \r
        if(aq<aa){ pp=q; aq++; goto aqpee; }\r