Changeset 0c42eb7 in thomson


Ignore:
Timestamp:
Feb 13, 2013, 9:28:41 PM (11 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
b9b1bde
Parents:
2557cd0
Message:

Make sure the last point of a GPL use the same color (FORME or FOND) as the first point of the next GPL.
This avoids a glitch on the EFGJ033 gate array.

git-svn-id: svn://localhost/thomson@35 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gfx2mo5/libraw2mo5.c

    r2557cd0 r0c42eb7  
    11/* GFX2mo5 - libraw2mo5.c
    22 * CloudStrife - 20080921
    3  * PulkoMandy - 20101221
     3 * PulkoMandy - 20101221, 20130213
    44 * Diffusé sous licence libre CeCILL v2
    5  * Voire LICENCE
     5 * Voir LICENCE
    66 */
    77
     8#include <stdbool.h>
    89#include <stdio.h>
    910#include <stdlib.h>
     
    1415  unsigned char *tmpBuffer;
    1516  int x,y;
     17  int previous = 0;
    1618
    1719  tmpBuffer = (unsigned char*)calloc(0x4000,1);
     
    2325        #define width 320
    2426
     27  bool lfo = false;
    2528  for (y = 0; y < 200; y++)
    2629        for (x = 0; x < 320; x+=8) {
     
    2831                int back = 255;
    2932                int pix;
     33                bool oldlfo = lfo;
     34
    3035                for(pix = 0; pix < 8; pix++) {
    3136                        int nc = input[y*width+x+pix];
     
    3338                        if (back == nc) {
    3439                                // Pixel is in backcolor, set FORME to 0
     40                                lfo = false;
    3541                        } else if (fore == nc) {
    3642                                // Pixel is in forecolor, set FORME to 1
    3743                                tmpBuffer[(y*320+x)/8] |= 0x80>>pix;
     44                                lfo = true;
    3845                        } else if (back==255) {
    3946                                // Pixel is in unknown color, back is free : allocate backcolor
    4047                                back = nc;
     48                                lfo = false;
    4149                        } else if (fore == 255) {
    4250                                // Pixel is unknown color, back is allocated : allocate front and set FORME
    4351                                fore = nc;
    4452                                tmpBuffer[(y*320+x)/8] |= 0x80>>pix;
     53                                lfo = true;
    4554                        } else {
    4655                                printf("Color clash at %d %d : %d %d %d\n",x+pix,y,fore, back,
     
    4857                        }
    4958                }
    50                 if (fore == 255) fore = 0;
    51                 if (back == 255) back = 0;
    5259
    53                 tmpBuffer[0x2000+(y*320+x)/8] = (fore << 4) | back;
     60                if (fore != 255) {
     61                        previous &= 0xF;
     62                        previous |= fore << 4;
     63                }
     64                if (back != 255) {
     65                        previous &= 0xF0;
     66                        previous |= back;
     67                }
     68
     69                // Make sure the last pixel of this GPL and the first of the next GPL
     70                // are both FORME or both FOND, else we get an ugly glitch on the
     71                // EFGJ033 Gate Array MO5!
     72                if(oldlfo == !(tmpBuffer[(y*320+x)/8] & 0x80))
     73                {
     74                        previous = (previous >> 4) | (previous << 4);
     75                        tmpBuffer[(y*320+x)/8] ^= 0xFF;
     76
     77                        lfo = !lfo;
     78                }
     79
     80                tmpBuffer[0x2000+(y*320+x)/8] = previous;
    5481  }
    5582
Note: See TracChangeset for help on using the changeset viewer.