1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2022 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
\r
4 * This file is part of Project 16.
\r
6 * Project 16 is free software; you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation; either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * Project 16 is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with this program. If not, see <http://www.gnu.org/licenses/>, or
\r
18 * write to the Free Software Foundation, Inc., 51 Franklin Street,
\r
19 * Fifth Floor, Boston, MA 02110-1301 USA.
\r
23 #include "src/lib/16_vlpal.h"
\r
26 //i want to make another vesion that checks the palette when the palette is being appened~
\r
27 void modexchkcolor(imgtestpal_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/, global_game_variables_t *gv)
\r
29 byte *pal=&(gv->video.palette);
\r
31 //pal = modexNewPal();
\r
32 // modexPalSave(pal);
\r
34 //check palette for dups
\r
35 for(; (*z)<PAL_SIZE; (*z)+=3)
\r
40 //---- if(pal[(*z)]==pal[(*z)+3] && pal[(*z)+1]==pal[(*z)+4] && pal[(*z)+2]==pal[(*z)+5])
\r
47 else for(zz=0; zz<(*q); zz+=3)
\r
52 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
59 else if(pal[zz]==pal[((*z)+(*q))] && pal[zz+1]==pal[((*z)+(*q))+1] && pal[zz+2]==pal[((*z)+(*q))+2])
\r
66 planned features that i plan to implement~
\r
67 image that has values on the pallete list!
\r
69 no... wait.... no wwww
\r
71 //for(zzii=0; zzii<3; zzii++)
\r
74 a[(((*z)+(*q)))]=zz;
\r
76 (*aa)=(((*z)+(*q)));
\r
81 printf("================\n");
\r
82 printf("zq: %d [%02d][%02d][%02d]\n", ((*z)+(*q))/3, pal[((*z)+(*q))], pal[((*z)+(*q))+1], pal[((*z)+(*q))+2]);
\r
83 printf("zz: %d [%02d][%02d][%02d]\n", (zz)/3, pal[zz], pal[zz+1], pal[zz+2]);
\r
84 printf("z : %d [%02d][%02d][%02d]\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
\r
85 printf("================\n");
\r
95 //what is *i, w, q, qq, z, aq, aa, pp, qp, and aqoffset...
\r
96 //pp is related to i
\r
99 VL_palette(imgtestpal_t *bmp, byte *p, word *i, word qp, word aqoffset, word *apal, global_game_variables_t *gv)
\r
101 //byte *p = bmp->palette;
\r
105 word a[PAL_SIZE]; //palette array of change values!
\r
106 word z=0, aq=0, aa=0, pp=0, iq=0;//iq=(*i)-q
\r
108 //modexWaitBorder();
\r
109 vga_wait_for_vsync();
\r
112 memset(a, -1, sizeof(a));
\r
113 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
\r
123 #ifdef BEVERBOSEPALCHECK
\r
124 printf("q: %02d\n", (q));//
\r
125 printf("qq: %02d\n", (qq));//
\r
126 printf(" (*i)-q=%02d\n", (*i)-q);//
\r
128 outp(PAL_WRITE_REG, qq); /* start at the beginning of palette */
\r
131 if((*i)<PAL_SIZE && w==0)
\r
133 for(; (*i)<PAL_SIZE; (*i)++)
\r
135 //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
136 //____ 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
137 if((((iq)%3==0)) && (p[(iq)]==p[(iq)+3] && p[(iq)+1]==p[(iq)+4] && p[(iq)+2]==p[(iq)+5]))
\r
142 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
\r
144 #ifdef BEVERBOSEPALCHECK
\r
145 printf("qp=%d\n", qp);//
\r
146 printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);//
\r
147 printf(" %d's color=%d\n", (*i), (a[qp])-(bmp->offset*3)+qp);//
\r
149 outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
\r
150 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
\r
154 if(bmp->offset==0 && (*i)<3 && q==0) outp(PAL_DATA_REG, 0);
\r
156 if(qp==0) outp(PAL_DATA_REG, p[iq]);
\r
158 { outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
\r
159 #ifdef BEVERBOSEPALCHECK
\r
160 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp);
\r
165 #ifdef BEVERBOSEPALCHECK
\r
166 if(qp>0) printf("qp=%d\n", qp);//
\r
167 if(qp>0) printf(" (*i)=%d\n", (*i)/3);//
\r
168 printf(" (*i)=%d\n", (*i)/3);
\r
172 #ifdef BEVERBOSEPALCHECK
\r
173 printf("\nqqqqqqqq\n\n");
\r
180 long bufSize = (bmp->width * bmp->height);
\r
182 #ifdef BEVERBOSEPALCHECK
\r
183 printf("1(*i)=%02d\n", (*i)/3);//
\r
184 printf("1z=%02d\n", z/3);//
\r
186 modexchkcolor(bmp, &q, &a, &aa, &z, i, gv);
\r
187 #ifdef BEVERBOSEPALCHECK
\r
188 printf("2(*i)=%02d\n", (*i)/3);
\r
189 printf("2z=%02d\n", z/3);
\r
195 #ifdef BEVERBOSEPALCHECK
\r
196 // printf("a[%02d]=(%d)\n", aq, a[aq]);//0000
\r
198 if(a[aq]==-1) aq++;
\r
199 else { aqoffset++; break; }
\r
201 //update the image data here!
\r
202 for(lq=0; lq<bufSize; lq++)
\r
206 use a[qp] instead of bmp->offset for this spot!
\r
211 Facking bloody point the values of the changed palette to correct values.... major confusion! wwww
\r
214 //(offset/bmp->offset)*bmp->offset
\r
216 #ifdef BEVERBOSEPALCHECK
\r
217 //printf("%02d ",bmp->data[lq]+bmp->offset);//
\r
218 //if(lq > 0 && lq%bmp->width==0) printf("\n");//
\r
219 //printf("%02d_", bmp->data[lq]+bmp->offset);//
\r
221 /*if(bmp->data[lq]+bmp->offset==aq)
\r
223 #ifdef BEVERBOSEPALCHECK
\r
224 printf("%02d", bmp->data[lq]);//
\r
225 printf("\n%02d\n", bmp->offset);//
\r
226 printf("aq=%02d ", aq);
\r
227 printf("a[aq]=%02d ", a[aq]);
\r
228 printf("a[aq]+aqpp=%02d ", a[aq]+aqpp);
\r
229 printf("a[aq]-aqpp=%02d\n", a[aq]-aqpp);
\r
231 //bmp->data[lq]=((bmp->data[lq]+bmp->offset)-a[aq]);
\r
232 //++++ bmp->data[lq]=a[aq]-aqpp;
\r
233 #ifdef BEVERBOSEPALCHECK
\r
234 printf("_%d ", bmp->data[lq]);//
\r
235 if(lq > 0 && lq%bmp->width==0) printf("\n");//
\r
238 else if(bmp->data[lq]+bmp->offset < ((*i)/3)-aqpp)
\r
240 if(bmp->data[lq]+bmp->offset >= aq)
\r
242 bmp->data[lq]=(bmp->data[lq]+bmp->offset)-aqpp;//-((z-(*i))/3);
\r
243 #ifdef BEVERBOSEPALCHECK
\r
244 printf("_%d ", bmp->data[lq]+bmp->offset)-aqpp-((z-(*i))/3);//
\r
247 else bmp->data[lq]+=(bmp->offset-aqpp);
\r
249 #ifdef BEVERBOSEPALCHECK
\r
250 //printf("%02d`", bmp->data[lq]);//
\r
251 //if(lq > 0 && lq%bmp->width==0) printf("\n");//
\r
255 #ifdef BEVERBOSEPALCHECK
\r
256 printf(" aq=%02d\n", aq);//
\r
257 printf(" aa=%02d\n", aa);//
\r
259 //update the palette~
\r
260 VL_palette(bmp, p, &pp, aq, aqoffset, &a, gv);
\r
263 if(aq<aa){ pp=q; aq++; goto aqpee; }
\r