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
25 void VL_palette(bitmap_t *bmp, word *i, word qp, word aqoffset)
\r
27 byte *p = bmp->palette;
\r
31 static word a[PAL_SIZE]; //palette array of change values!
\r
32 word z=0, aq=0, aa=0, pp=0;
\r
34 //modexWaitBorder();
\r
35 vga_wait_for_vsync();
\r
38 memset(a, -1, sizeof(a));
\r
39 outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
\r
49 // printf("q: %02d\n", (q));
\r
50 // printf("qq: %02d\n", (qq));
\r
51 //printf(" (*i)-q=%02d\n", (*i)-q);
\r
52 outp(PAL_WRITE_REG, qq); /* start at the beginning of palette */
\r
54 if((*i)<PAL_SIZE/2 && w==0)
\r
56 for(; (*i)<PAL_SIZE/2; (*i)++)
\r
58 //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
59 //____ 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
60 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
65 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
\r
67 //printf("qp=%d\n", qp);
\r
68 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
\r
69 printf(" %d's color=%d\n", (*i), (a[qp])-(bmp->offset*3)+qp);
\r
70 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
\r
71 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
\r
75 if(bmp->offset==0 && (*i)<3 && q==0) outp(PAL_DATA_REG, 0);
\r
77 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
\r
78 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
\r
79 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
\r
82 //if(qp>0) printf("qp=%d\n", qp);
\r
83 //if(qp>0) printf(" (*i)=%d\n", (*i)/3);
\r
85 //modexWaitBorder(); /* waits one retrace -- less flicker */
\r
86 vga_wait_for_vsync();
\r
87 if((*i)>=PAL_SIZE/2 && w==0)
\r
89 for(; (*i)<PAL_SIZE; (*i)++)
\r
91 //____ 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
92 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
97 else if(qp>0 && (*i)>=(qp) && (*i)<((qp)+3))
\r
99 //printf("qp=%d\n", qp);
\r
100 //printf(" (*i)=%d a[%d]=%d\n", (*i), qp, a[qp]);
\r
101 printf(" %d's color=%d\n", (*i), (a[qp]-(bmp->offset*3)+qp));
\r
102 //outp(PAL_DATA_REG, p[((a[qp])-(bmp->offset*3)+qp)]);// fix this shit!
\r
103 if((*i)+1==(qp)+3){ w++; /*(*i)++;*/ break; }
\r
107 if(qp==0) outp(PAL_DATA_REG, p[(*i)-q]);
\r
108 else{ //outp(PAL_DATA_REG, p[((*i)-(bmp->offset*3)+qp)]);
\r
109 printf("p[]=%d qp=%d p[]-qp=%d\n", ((*i)-(bmp->offset*3)), qp, ((*i)-(bmp->offset*3))+qp); }
\r
112 //printf(" (*i)=%d\n", (*i)/3);
\r
115 printf("\nqqqqqqqq\n\n");
\r
121 long bufSize = (bmp->width * bmp->height);
\r
123 //printf("1(*i)=%02d\n", (*i)/3);
\r
124 //printf("1z=%02d\n", z/3);
\r
125 modexchkcolor(bmp, &q, &a, &aa, &z, i);
\r
126 //printf("2(*i)=%02d\n", (*i)/3);
\r
127 //printf("2z=%02d\n", z/3);
\r
132 // printf("a[%02d]=(%d)\n", aq, a[aq]);
\r
133 if(a[aq]==-1) aq++;
\r
134 else { aqoffset++; break; }
\r
136 //update the image data here!
\r
137 for(lq=0; lq<bufSize; lq++)
\r
141 use a[qp] instead of bmp->offset for this spot!
\r
146 Facking bloody point the values of the changed palette to correct values.... major confusion! wwww
\r
149 //(offset/bmp->offset)*bmp->offset
\r
152 //printf("%02d ",bmp->data[lq]+bmp->offset);
\r
153 //if(lq > 0 && lq%bmp->width==0) printf("\n");
\r
154 //printf("%02d_", bmp->data[lq]+bmp->offset);
\r
155 /*if(bmp->data[lq]+bmp->offset==aq)
\r
157 //printf("%02d", bmp->data[lq]);
\r
158 //printf("\n%02d\n", bmp->offset);
\r
159 printf("aq=%02d ", aq);
\r
160 printf("a[aq]=%02d ", a[aq]);
\r
161 printf("a[aq]+aqpp=%02d ", a[aq]+aqpp);
\r
162 printf("a[aq]-aqpp=%02d\n", a[aq]-aqpp);
\r
163 //bmp->data[lq]=((bmp->data[lq]+bmp->offset)-a[aq]);
\r
164 //++++ bmp->data[lq]=a[aq]-aqpp;
\r
165 // printf("_%d ", bmp->data[lq]);
\r
166 //if(lq > 0 && lq%bmp->width==0) printf("\n");
\r
168 else if(bmp->data[lq]+bmp->offset < ((*i)/3)-aqpp)
\r
170 if(bmp->data[lq]+bmp->offset >= aq)
\r
172 bmp->data[lq]=(bmp->data[lq]+bmp->offset)-aqpp;//-((z-(*i))/3);
\r
173 //printf("_%d ", bmp->data[lq]+bmp->offset)-aqpp-((z-(*i))/3);
\r
175 else bmp->data[lq]+=(bmp->offset-aqpp);
\r
178 //printf("%02d`", bmp->data[lq]);
\r
179 //if(lq > 0 && lq%bmp->width==0) printf("\n");
\r
182 //printf(" aq=%02d\n", aq);
\r
183 //printf(" aa=%02d\n", aa);
\r
185 //update the palette~
\r
186 VL_palette(bmp, &pp, aq, aqoffset);
\r
189 if(aq<aa){ pp=q; aq++; goto aqpee; }
\r