1 /* Project 16 Source Code~
\r
2 * Copyright (C) 2012-2017 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*/)
\r
31 pal = modexNewPal();
\r
33 //printf("q: %02d\n", (*q));
\r
34 printf("chkcolor start~\n");
\r
35 printf("1 (*z): %d\n", (*z)/3);
\r
36 printf("1 (*i): %d\n", (*i)/3);
\r
37 // printf("1 offset of color in palette (*q): %d\n", (*q)/3);
\r
38 printf("wwwwwwwwwwwwwwww\n");
\r
39 //check palette for dups
\r
40 for(; (*z)<PAL_SIZE; (*z)+=3)
\r
42 //printf("\n z: %d\n", (*z));
\r
43 //printf(" q: %d\n", (*q));
\r
44 //printf(" z+q: %d\n\n", ((*z)+(*q)));
\r
47 //---- if(pal[(*z)]==pal[(*z)+3] && pal[(*z)+1]==pal[(*z)+4] && pal[(*z)+2]==pal[(*z)+5])
\r
50 // printf("\n%d [%02d][%02d][%02d]\n", (*z), pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
\r
51 // printf("%d [%02d][%02d][%02d]\n\n", (*z)+3, pal[(*z)+3], pal[(*z)+4], pal[(*z)+5]);
\r
55 else for(zz=0; zz<(*q); zz+=3)
\r
57 //printf("zz: %02d\n", zz/3);
\r
60 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
64 // printf("\nzq1:%d[%02d][%02d][%02d]\n", (zz+q), pal[(zz+q)], pal[(zz+q)+1], pal[(zz+q)+2]);
\r
65 // printf("zq2:%d[%02d][%02d][%02d]\n\n", (zz+q)+3, pal[(zz+q)+3], pal[(zz+q)+4], pal[(zz+q)+5]);
\r
68 else if(pal[zz]==pal[((*z)+(*q))] && pal[zz+1]==pal[((*z)+(*q))+1] && pal[zz+2]==pal[((*z)+(*q))+2])
\r
70 // printf("\n\nwwwwwwwwwwwwwwww\n");
\r
71 // 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
72 // 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
73 // //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
74 // printf(" z : %d [%02d][%02d][%02d] offset value~\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
\r
79 planned features that i plan to implement~
\r
80 image that has values on the pallete list!
\r
82 no... wait.... no wwww
\r
84 //for(zzii=0; zzii<3; zzii++)
\r
86 //printf("z+q: %d\n\n", ((*z)+(*q)));
\r
87 a[(((*z)+(*q)))]=zz;
\r
89 (*aa)=(((*z)+(*q)));
\r
90 printf("!! a[%02d]: %d\n", (((*z)+(*q))/3), zz/3);
\r
91 // printf("\n aa: %d\n\n", (*aa));
\r
92 // printf(" a[%02d]=(%02d) offset array i think the palette should be updated again~\n", ((*z)+(*q))/3, a[((*z)+(*q))/3]);
\r
93 // printf("wwwwwwwwwwwwwwww\n\n");
\r
97 printf("================\n");
\r
98 printf("zq: %d [%02d][%02d][%02d]\n", ((*z)+(*q))/3, pal[((*z)+(*q))], pal[((*z)+(*q))+1], pal[((*z)+(*q))+2]);
\r
99 printf("zz: %d [%02d][%02d][%02d]\n", (zz)/3, pal[zz], pal[zz+1], pal[zz+2]);
\r
100 printf("z : %d [%02d][%02d][%02d]\n", (*z)/3, pal[(*z)], pal[(*z)+1], pal[(*z)+2]);
\r
101 printf("================\n");
\r
103 //printf("[%d]", (zz+q));
\r
107 printf("wwwwwwwwwwwwwwww\n");
\r
108 printf("2 (*z): %d\n", (*z)/3);
\r
109 printf("2 (*i): %d\n", (*i)/3);
\r
110 // printf("2 offset of color in palette (*q): %d\n", (*q)/3);
\r
111 printf("chkcolor end~\n");
\r
116 VL_palette(imgtestpal_t *bmp, byte *p, word *i, word qp, word aqoffset)
\r
118 //byte *p = bmp->palette;
\r
122 static word a[PAL_SIZE]; //palette array of change values!
\r
123 word z=0, aq=0, aa=0, pp=0;
\r
125 //modexWaitBorder();
\r
126 vga_wait_for_vsync();
\r
129 memset(a, -1, sizeof(a));
\r
130 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
\r
140 // printf("q: %02d\n", (q));
\r
141 // printf("qq: %02d\n", (qq));
\r
142 //printf(" (*i)-q=%02d\n", (*i)-q);
\r
143 outp(PAL_WRITE_REG, qq); /* start at the beginning of palette */
\r
145 if((*i)<PAL_SIZE/2 && w==0)
\r
147 for(; (*i)<PAL_SIZE/2; (*i)++)
\r
149 //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
150 //____ 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
151 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
156 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
\r
158 //printf("qp=%d\n", qp);
\r
159 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
\r
160 printf(" %d's color=%d\n", (*i), (a[qp])-(bmp->offset*3)+qp);
\r
161 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
\r
162 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
\r
166 if(bmp->offset==0 && (*i)<3 && q==0) outp(PAL_DATA_REG, 0);
\r
168 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
\r
169 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
\r
170 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
\r
173 //if(qp>0) printf("qp=%d\n", qp);
\r
174 //if(qp>0) printf(" (*i)=%d\n", (*i)/3);
\r
176 //modexWaitBorder(); /* waits one retrace -- less flicker */
\r
177 vga_wait_for_vsync();
\r
178 if((*i)>=PAL_SIZE/2 && w==0)
\r
180 for(; (*i)<PAL_SIZE; (*i)++)
\r
182 //____ 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
183 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
188 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
\r
190 //printf("qp=%d\n", qp);
\r
191 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
\r
192 printf(" %d's color=%d\n", (*i), (a[qp]-(bmp->offset*3)+qp));
\r
193 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
\r
194 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
\r
198 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
\r
199 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
\r
200 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
\r
203 //printf(" (*i)=%d\n", (*i)/3);
\r
206 printf("\nqqqqqqqq\n\n");
\r
212 long bufSize = (bmp->width * bmp->height);
\r
214 //printf("1(*i)=%02d\n", (*i)/3);
\r
215 //printf("1z=%02d\n", z/3);
\r
216 modexchkcolor(bmp, &q, &a, &aa, &z, i);
\r
217 //printf("2(*i)=%02d\n", (*i)/3);
\r
218 //printf("2z=%02d\n", z/3);
\r
223 // printf("a[%02d]=(%d)\n", aq, a[aq]);
\r
224 if(a[aq]==-1) aq++;
\r
225 else { aqoffset++; break; }
\r
227 //update the image data here!
\r
228 for(lq=0; lq<bufSize; lq++)
\r
232 use a[qp] instead of bmp->offset for this spot!
\r
237 Facking bloody point the values of the changed palette to correct values.... major confusion! wwww
\r
240 //(offset/bmp->offset)*bmp->offset
\r
243 //printf("%02d ",bmp->data[lq]+bmp->offset);
\r
244 //if(lq > 0 && lq%bmp->width==0) printf("\n");
\r
245 //printf("%02d_", bmp->data[lq]+bmp->offset);
\r
246 /*if(bmp->data[lq]+bmp->offset==aq)
\r
248 //printf("%02d", bmp->data[lq]);
\r
249 //printf("\n%02d\n", bmp->offset);
\r
250 printf("aq=%02d ", aq);
\r
251 printf("a[aq]=%02d ", a[aq]);
\r
252 printf("a[aq]+aqpp=%02d ", a[aq]+aqpp);
\r
253 printf("a[aq]-aqpp=%02d\n", a[aq]-aqpp);
\r
254 //bmp->data[lq]=((bmp->data[lq]+bmp->offset)-a[aq]);
\r
255 //++++ bmp->data[lq]=a[aq]-aqpp;
\r
256 // printf("_%d ", bmp->data[lq]);
\r
257 //if(lq > 0 && lq%bmp->width==0) printf("\n");
\r
259 else if(bmp->data[lq]+bmp->offset < ((*i)/3)-aqpp)
\r
261 if(bmp->data[lq]+bmp->offset >= aq)
\r
263 bmp->data[lq]=(bmp->data[lq]+bmp->offset)-aqpp;//-((z-(*i))/3);
\r
264 //printf("_%d ", bmp->data[lq]+bmp->offset)-aqpp-((z-(*i))/3);
\r
266 else bmp->data[lq]+=(bmp->offset-aqpp);
\r
269 //printf("%02d`", bmp->data[lq]);
\r
270 //if(lq > 0 && lq%bmp->width==0) printf("\n");
\r
273 //printf(" aq=%02d\n", aq);
\r
274 //printf(" aa=%02d\n", aa);
\r
276 //update the palette~
\r
277 VL_palette(bmp, p, &pp, aq, aqoffset);
\r
280 if(aq<aa){ pp=q; aq++; goto aqpee; }
\r