Changeset 068b1fa in thomson
- Timestamp:
- Mar 17, 2014, 10:51:11 AM (10 years ago)
- Branches:
- main
- Children:
- 05f2b4a
- Parents:
- 87bafa6
- Location:
- tools/gfx2mo5
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gfx2mo5/libraw2mo5.c
r87bafa6 r068b1fa 7 7 8 8 #include <stdbool.h> 9 #include <stdint.h> 9 10 #include <stdio.h> 10 11 #include <stdlib.h> 11 12 #include <string.h> 12 13 13 unsigned char *raw2mo5(unsigned char *input, int height, int fixup )14 unsigned char *raw2mo5(unsigned char *input, int height, int fixup, bool to) 14 15 { 15 16 unsigned char *tmpBuffer; 16 17 int x,y; 17 18 int previous = 0; 19 bool lfo = false; 20 uint8_t val; 18 21 19 22 tmpBuffer = (unsigned char*)calloc(0x4000,1); … … 25 28 #define width 320 26 29 27 bool lfo = false;28 30 for (y = 0; y < height; y++) 29 31 for (x = 0; x < 320; x+=8) { … … 71 73 // are both FORME or both FOND, else we get an ugly glitch on the 72 74 // 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)) 74 77 { 75 previous = (previous >> 4)| (previous << 4);78 previous = 7 | (previous << 4); 76 79 tmpBuffer[(y*320+x)/8] ^= 0xFF; 77 80 78 81 lfo = !lfo; 82 } 83 84 // TO8 mode 85 if(to) 86 { 87 previous = (previous & 0x7) | ((previous & 0xF0) >> 1) | ((previous & 0x8) << 4); 88 previous ^= 0xC0; 79 89 } 80 90 -
tools/gfx2mo5/libraw2mo5.h
r87bafa6 r068b1fa 10 10 #define LIBRAW2mo5_H 1 11 11 12 unsigned char * raw2mo5(unsigned char *input, int height, int fixup );12 unsigned char * raw2mo5(unsigned char *input, int height, int fixup, bool to); 13 13 14 14 #endif -
tools/gfx2mo5/png2mo5.c
r87bafa6 r068b1fa 1 1 /* GFX2mo5 - png2mo5.c 2 2 * CloudStrife - 20080921 3 * PulkoMandy - 2012-2014 3 4 * Diffusé sous licence libre CeCILL v2 4 5 * Voir LICENCE 5 6 */ 6 7 8 #include <getopt.h> 7 9 #include <stdio.h> 8 10 #include <stdlib.h> … … 33 35 34 36 png_bytep * ptrRow; 37 int pxsize; 38 39 char opt; 40 int fixup = -1; 41 bool to = false; 42 35 43 unsigned char thomheader[] = { 36 44 // Block 1 : address A7C0, 1 byte, select FORME … … 46 54 if(argc < 3) 47 55 { 48 printf("Utilisation : %s input_filename output_filename options\n",argv[0]);56 printf("Utilisation : %s [options] input_filename output_filename\n",argv[0]); 49 57 exit(0); 50 58 } 51 59 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"); 53 76 54 77 if (inFile == NULL) … … 127 150 png_read_image(png_ptr, ptrRow); 128 151 129 outBuffer = raw2mo5(inBuffer, height, argc > 3 ? atoi(argv[3]):-1);152 outBuffer = raw2mo5(inBuffer, height, fixup, to); 130 153 131 intpxsize = width * height / 8;154 pxsize = width * height / 8; 132 155 thomheader[7] = pxsize >> 8; 133 156 thomheader[8] = pxsize; 134 157 135 outFile = fopen(argv[ 2], "wb");158 outFile = fopen(argv[optind++], "wb"); 136 159 fwrite(thomheader, 1, sizeof(thomheader), outFile); 137 160 //write forme data 138 161 fwrite(outBuffer, 1, pxsize, outFile); 139 thomheader[5] = 0x50;162 --thomheader[5]; 140 163 fwrite(thomheader, 1, sizeof(thomheader), outFile); 141 164 // write color data
Note:
See TracChangeset
for help on using the changeset viewer.