#include #include #include #include "epromwriter.h" #include "filter_tabs.h" float conversion [16] = { 0x0, 0x5, 0x3, 0x9, 0x8, 0x7, 0x6, 0x1, 0x2, 0x4, 0xB, 0xC, 0xD, 0xF, 0xE, 0xA }; void save_eprom( GtkWidget *tab_group, gchar * filename ) { FILE *f; guint MainCounter; guint MemoryCounter; guint RedMask, BlueMask, GreenMask; guchar r, g, b, color_code; guint i, j; f = fopen (filename, "wb"); if (!f) { fprintf(stderr, "Impossible d'ouvrir le fichier \"%s\"\n", filename); exit(EXIT_FAILURE); } MainCounter = 0; MemoryCounter = 0; RedMask = 0xF800; GreenMask = 0x07E0; BlueMask = 0x001F; for (MainCounter=0; MainCounter<=65535; MainCounter++) { MemoryCounter = 0; // le poids fort du SAA et relié au poids faible de l'UVPROM... /* MemoryCounter=(unsigned long)( 32768*(MainCounter & 0x0001)+ 16384*((MainCounter & 0x0002)>>1)+ 8192*((MainCounter & 0x0004)>>2)+ 4096*((MainCounter & 0x0008)>>3)+ 2048*((MainCounter & 0x0010)>>4)+ 1024*((MainCounter & 0x0020)>>5)+ 512*((MainCounter & 0x0040)>>6)+ 256*((MainCounter & 0x0080)>>7)+ 128*((MainCounter & 0x0100)>>8)+ 64*((MainCounter & 0x0200)>>9)+ 32*((MainCounter & 0x0400)>>10)+ 16*((MainCounter & 0x0800)>>11)+ 8*((MainCounter & 0x1000)>>12)+ 4*((MainCounter & 0x2000)>>13)+ 2*((MainCounter & 0x4000)>>14)+ 1*((MainCounter & 0x8000)>>15) ); */ for (i=0; i<16; i++) { /* replace the bit i with the bit conversion[i] */ j = conversion[i]; MemoryCounter += (long) ((MainCounter & (1 << j))>>j)<>5)<<2); /* 5 bits mis surle poids fort */ r = (guchar) (((MemoryCounter & RedMask)>>11)<<3); get_value_and_color_of_pixel(tab_group, &r, &g, &b, &color_code, NULL, NULL, NULL); fwrite (&color_code, 1, 1, f); } fclose(f); }