+ pp = q;
+ //printf("1(*i)=%02d\n", (*i)/3);
+ //printf("1z=%02d\n", z/3);
+ chkcolor(bmp, &q, &a, &aa, &z, i);
+ //printf("2(*i)=%02d\n", (*i)/3);
+ //printf("2z=%02d\n", z/3);
+
+ aq=0;
+aqpee:
+ while(aq<=aa)
+ {
+// printf("a[%02d]=(%d)\n", aq, a[aq]);
+ if(a[aq]==-1) aq++;
+ else { aqoffset++; break; }
+ }
+
+ for(lq=0; lq<bufSize; lq++)
+ {
+ //printf("%02d_", bmp->data[lq]+bmp->offset);
+ /*if(bmp->data[lq]+bmp->offset==aq)
+ {
+ //printf("%02d", bmp->data[lq]);
+ //printf("\n%02d\n", bmp->offset);
+ printf("aq=%02d ", aq);
+ printf("a[aq]=%02d ", a[aq]);
+ printf("a[aq]+aqpp=%02d ", a[aq]+aqpp);
+ printf("a[aq]-aqpp=%02d\n", a[aq]-aqpp);
+ //bmp->data[lq]=((bmp->data[lq]+bmp->offset)-a[aq]);
+//++++ bmp->data[lq]=a[aq]-aqpp;
+// printf("_%d ", bmp->data[lq]);
+ //if(lq > 0 && lq%bmp->width==0) printf("\n");
+ }
+ else if(bmp->data[lq]+bmp->offset < ((*i)/3)-aqpp)
+ {
+ if(bmp->data[lq]+bmp->offset >= aq)
+ {
+ bmp->data[lq]=(bmp->data[lq]+bmp->offset)-aqpp;//-((z-(*i))/3);
+ //printf("_%d ", bmp->data[lq]+bmp->offset)-aqpp-((z-(*i))/3);
+ }
+ else bmp->data[lq]+=(bmp->offset-aqpp);
+ }*/
+
+ //printf("%02d`", bmp->data[lq]);
+ //if(lq > 0 && lq%bmp->width==0) printf("\n");
+ }
+
+//printf(" aq=%02d\n", aq);
+//printf(" aa=%02d\n", aa);
+
+ //update the palette~
+ modexPalUpdate(bmp, &pp, aq, aqoffset);
+ (*i)=pp;
+
+ if(aq<aa){ pp=q; aq++; goto aqpee; }
+ }
+}
+
+void
+modexPalUpdate2(byte *p)
+{
+ int i;
+ modexWaitBorder();
+ outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
+ for(i=0; i<PAL_SIZE/2; i++)
+ {
+ outp(PAL_DATA_REG, p[i]);
+ }
+ modexWaitBorder(); /* waits one retrace -- less flicker */
+ for(; i<PAL_SIZE; i++)
+ {
+ outp(PAL_DATA_REG, p[(i)]);
+ }
+}
+
+void
+modexPalUpdate3(byte *p)
+{
+ int i;
+ modexWaitBorder();
+ outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */
+ for(i=0; i<PAL_SIZE/2; i++)
+ {
+ outp(PAL_DATA_REG, rand());
+ }
+ modexWaitBorder(); /* waits one retrace -- less flicker */
+ for(; i<PAL_SIZE; i++)
+ {
+ outp(PAL_DATA_REG, rand());
+ }
+}
+
+//color checker~
+//i want to make another vesion that checks the palette when the palette is being appened~
+void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/)
+{