Changeset 15d3e8a in thomson
- Timestamp:
- Mar 20, 2016, 10:04:25 PM (8 years ago)
- Branches:
- main
- Children:
- a8929a8
- Parents:
- 2366419
- Location:
- tools/gfx2mo5
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gfx2mo5/libraw2mo5.c
r2366419 r15d3e8a 19 19 bool lfo = false; 20 20 uint8_t val; 21 static const int width = 320; 21 22 22 23 tmpBuffer = (unsigned char*)calloc(0x4000,1); … … 26 27 exit(4); 27 28 } 28 #define width 32029 29 30 30 for (y = 0; y < height; y++) … … 94 94 return tmpBuffer; 95 95 } 96 97 98 unsigned char *raw2bm16(unsigned char *input, int height) 99 { 100 unsigned char *tmpBuffer; 101 int x,y; 102 int p1 = 0; 103 int p2 = 0x2000; 104 static const int width = 160; 105 106 tmpBuffer = (unsigned char*)calloc(0x4000,1); 107 if (tmpBuffer == NULL) 108 { 109 printf("Allocation tmpBuffer raté\n"); 110 exit(4); 111 } 112 113 for (y = 0; y < height; y++) 114 for (x = 0; x < width; x+=4) { 115 int pix; 116 117 for(pix = 0; pix < 4; pix++) { 118 int nc = input[y*width+x+pix]; 119 if (nc > 15) printf("Color over limit!\n"); 120 121 switch(pix) { 122 case 0: 123 tmpBuffer[p1] = nc << 4; 124 break; 125 case 1: 126 tmpBuffer[p1++] |= nc; 127 break; 128 case 2: 129 tmpBuffer[p2] = nc << 4; 130 break; 131 case 3: 132 tmpBuffer[p2++] |= nc; 133 break; 134 } 135 } 136 } 137 138 return tmpBuffer; 139 } -
tools/gfx2mo5/libraw2mo5.h
r2366419 r15d3e8a 10 10 #define LIBRAW2mo5_H 1 11 11 12 /* Convert picture to MO5/TO7/"40 columns" format (320x200, 16 colors, 8x1 blocks) */ 12 13 unsigned char * raw2mo5(unsigned char *input, int height, int fixup, bool to); 13 14 15 /* Convert picture to "direct bitmap 16" format (160x200, 16 colors) */ 16 unsigned char * raw2bm16(unsigned char *input, int height); 17 14 18 #endif -
tools/gfx2mo5/png2mo5.c
r2366419 r15d3e8a 39 39 40 40 char opt; 41 int fixup = -1; 42 bool to = false; 41 int fixup; 42 bool to; 43 bool bitmap16; 43 44 44 45 unsigned char thomheader[] = { … … 51 52 52 53 // End marker block : type=255, size and address=0 53 const unsigned char end[]={255,0,0,0,0};54 static const unsigned char end[]={255,0,0,0,0}; 54 55 55 56 if(argc < 3) 56 57 { 57 58 printf("Utilisation : %s [options] input_filename output_filename\n",argv[0]); 59 printf("Option -m s: Mode to use (bm16/40c)\n"); 58 60 printf("Option -t: use TO transcoding.\n"); 59 61 printf("Option -f n: use modified algorithm to avoid artifacts on some MO5 gate array versions. n is the index of the background color.\n"); … … 61 63 } 62 64 63 while((opt = getopt(argc, argv, "tf:")) != -1) { 65 fixup = -1; 66 to = false; 67 bitmap16 = false; 68 69 while((opt = getopt(argc, argv, "tf:m:")) != -1) { 64 70 switch(opt) { 65 71 case 't': … … 73 79 fixup = atoi(optarg); 74 80 break; 81 case 'm': 82 if (strcmp(optarg, "bm16") == 0) 83 bitmap16 = true; 75 84 } 76 85 } … … 153 162 png_read_image(png_ptr, ptrRow); 154 163 155 outBuffer = raw2mo5(inBuffer, height, fixup, to); 156 157 pxsize = width * height / 8; 164 if (bitmap16) { 165 if (width != 160) { 166 puts("Image not using the full screen width are not supported yet!"); 167 return ERROR; 168 } 169 outBuffer = raw2bm16(inBuffer, height); 170 pxsize = width * height / 4; 171 } else { 172 if (width != 320) { 173 puts("Image not using the full screen width are not supported yet!"); 174 return ERROR; 175 } 176 outBuffer = raw2mo5(inBuffer, height, fixup, to); 177 pxsize = width * height / 8; 178 } 179 158 180 thomheader[7] = pxsize >> 8; 159 181 thomheader[8] = pxsize;
Note:
See TracChangeset
for help on using the changeset viewer.