Changeset 068b1fa in thomson


Ignore:
Timestamp:
Mar 17, 2014, 10:51:11 AM (10 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
05f2b4a
Parents:
87bafa6
Message:

gfx2mo5: make TO mode a run-time option

  • Use getopt for parsing option.
  • The "MO5 gate array fixup" is now option -f
  • The "TO modeis now option -t

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

Location:
tools/gfx2mo5
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tools/gfx2mo5/libraw2mo5.c

    r87bafa6 r068b1fa  
    77
    88#include <stdbool.h>
     9#include <stdint.h>
    910#include <stdio.h>
    1011#include <stdlib.h>
    1112#include <string.h>
    1213
    13 unsigned char *raw2mo5(unsigned char *input, int height, int fixup)
     14unsigned char *raw2mo5(unsigned char *input, int height, int fixup, bool to)
    1415{
    1516  unsigned char *tmpBuffer;
    1617  int x,y;
    1718  int previous = 0;
     19  bool lfo = false;
     20  uint8_t val;
    1821
    1922  tmpBuffer = (unsigned char*)calloc(0x4000,1);
     
    2528        #define width 320
    2629
    27   bool lfo = false;
    2830  for (y = 0; y < height; y++)
    2931        for (x = 0; x < 320; x+=8) {
     
    7173                // are both FORME or both FOND, else we get an ugly glitch on the
    7274                // EFGJ033 Gate Array MO5!
    73                 if(fixup > 0 && oldlfo == !(tmpBuffer[(y*320+x)/8] & 0x80))
     75                val = tmpBuffer[(y*320+x)/8];
     76                if(fixup > 0 && ((oldlfo == !(val & 0x80) && val != 0) || val == 0xFF))
    7477                {
    75                         previous = (previous >> 4) | (previous << 4);
     78                        previous = 7 | (previous << 4);
    7679                        tmpBuffer[(y*320+x)/8] ^= 0xFF;
    7780
    7881                        lfo = !lfo;
     82                }
     83
     84                // TO8 mode
     85                if(to)
     86                {
     87                        previous = (previous & 0x7) | ((previous & 0xF0) >> 1) | ((previous & 0x8) << 4);
     88                        previous ^= 0xC0;
    7989                }
    8090
  • tools/gfx2mo5/libraw2mo5.h

    r87bafa6 r068b1fa  
    1010#define LIBRAW2mo5_H 1
    1111
    12 unsigned char * raw2mo5(unsigned char *input, int height, int fixup);
     12unsigned char * raw2mo5(unsigned char *input, int height, int fixup, bool to);
    1313
    1414#endif
  • tools/gfx2mo5/png2mo5.c

    r87bafa6 r068b1fa  
    11/* GFX2mo5 - png2mo5.c
    22 * CloudStrife - 20080921
     3 * PulkoMandy - 2012-2014
    34 * Diffusé sous licence libre CeCILL v2
    45 * Voir LICENCE
    56 */
    67
     8#include <getopt.h>
    79#include <stdio.h>
    810#include <stdlib.h>
     
    3335
    3436  png_bytep * ptrRow;
     37  int pxsize;
     38
     39  char opt;
     40  int fixup = -1;
     41  bool to = false;
     42
    3543  unsigned char thomheader[] = {
    3644        // Block 1 : address A7C0, 1 byte, select FORME
     
    4654  if(argc < 3)
    4755  {
    48     printf("Utilisation : %s input_filename output_filename options\n",argv[0]);
     56    printf("Utilisation : %s [options] input_filename output_filename\n",argv[0]);
    4957    exit(0);
    5058  }
    5159
    52   inFile = fopen(argv[1],"rb");
     60  while((opt = getopt(argc, argv, "tf:")) != -1) {
     61    switch(opt) {
     62      case 't':
     63                  to = true;
     64                  thomheader[3] = 0xE7;
     65                  thomheader[4] = 0xC3;
     66                  thomheader[5] = 0x65;
     67                  thomheader[9] = 0x40;
     68                  break;
     69          case 'f':
     70                  fixup = atoi(optarg);
     71                  break;
     72        }
     73  }
     74
     75  inFile = fopen(argv[optind++],"rb");
    5376
    5477  if (inFile == NULL)
     
    127150  png_read_image(png_ptr, ptrRow);
    128151
    129   outBuffer = raw2mo5(inBuffer, height, argc > 3 ? atoi(argv[3]):-1);
     152  outBuffer = raw2mo5(inBuffer, height, fixup, to);
    130153
    131   int pxsize = width * height / 8;
     154  pxsize = width * height / 8;
    132155  thomheader[7] = pxsize >> 8;
    133156  thomheader[8] = pxsize;
    134157
    135   outFile = fopen(argv[2], "wb");
     158  outFile = fopen(argv[optind++], "wb");
    136159  fwrite(thomheader, 1, sizeof(thomheader), outFile);
    137160  //write forme data
    138161  fwrite(outBuffer, 1, pxsize, outFile);
    139   thomheader[5] = 0x50;
     162  --thomheader[5];
    140163  fwrite(thomheader, 1, sizeof(thomheader), outFile);
    141164  // write color data
Note: See TracChangeset for help on using the changeset viewer.