- c = (r << 11) | (g << 5) | b;
- mippixels_start[i+2] = c & 255;
- mippixels_start[i+3] = c >> 8;
+ c1new = (r << 11) | (g << 5) | b;
+ // swap the colors if needed to fix order
+ if(c0 > c1) // thirds
+ {
+ if(c0new < c1new)
+ {
+ c = c0new;
+ c0new = c1new;
+ c1new = c;
+ if(c0new == c1new)
+ mippixels_start[i+4] ^= 0x55;
+ mippixels_start[i+5] ^= 0x55;
+ mippixels_start[i+6] ^= 0x55;
+ mippixels_start[i+7] ^= 0x55;
+ }
+ else if(c0new == c1new)
+ {
+ mippixels_start[i+4] = 0x00;
+ mippixels_start[i+5] = 0x00;
+ mippixels_start[i+6] = 0x00;
+ mippixels_start[i+7] = 0x00;
+ }
+ }
+ else // half + transparent
+ {
+ if(c0new > c1new)
+ {
+ c = c0new;
+ c0new = c1new;
+ c1new = c;
+ mippixels_start[i+4] ^= (~mippixels_start[i+4] >> 1) & 0x55;
+ mippixels_start[i+5] ^= (~mippixels_start[i+5] >> 1) & 0x55;
+ mippixels_start[i+6] ^= (~mippixels_start[i+6] >> 1) & 0x55;
+ mippixels_start[i+7] ^= (~mippixels_start[i+7] >> 1) & 0x55;
+ }
+ }
+ mippixels_start[i] = c0new & 255;
+ mippixels_start[i+1] = c0new >> 8;
+ mippixels_start[i+2] = c1new & 255;
+ mippixels_start[i+3] = c1new >> 8;