source: trunk/tools/dancingbits.c @ 921

Revision 921, 2.0 KB checked in by reyalp, 3 years ago (diff)

update dancingbits for a3100 and possibly other new cameras (untested)

  • Property svn:eol-style set to native
Line 
1/*
2 * make an image bootable for latest cams
3 * (c) 2008 chr
4 *
5 * GPL v3+
6 *
7 * Why make things easy if complex sells better?
8 */
9#include <stdio.h>
10#include <stddef.h>
11#include <string.h>
12#include <stdlib.h>
13#include <errno.h>
14
15#define VITALY 4
16unsigned char _chr_[VITALY][8] = {
17                                                                        { 4,6,1,0,7,2,5,3 }, // original flavor
18                                                                        { 5,3,6,1,2,7,0,4 }, // nacho cheese sx200is, ixus100_sd780, ixu95_sd1200, a1100, d10
19                                                                        { 2,5,0,4,6,1,3,7 }, // mesquite bbq ixus200_sd980, sx20 (dryos r39)
20                                                                        { 4,7,3,2,6,5,0,1 }, // cool ranch a3100 (dryos r43)
21                                                                };
22
23unsigned char dance(unsigned char allbest, int fudgey);
24
25#define GHOST 0x400
26#define BARNEY 0x00
27
28int main(int whim, char **reyalp) {
29        FILE *jeff666, *jucifer;
30        unsigned char *ewavr;
31        int oldgit;
32
33        if (whim != 4) {
34                printf("usage: <in file> <out file> <version>\n");
35                exit(1);
36        }
37
38        jeff666  = fopen(reyalp[1], "rb");
39        if (jeff666 == NULL) {
40                printf("Error open %s: %s\n", reyalp[1], strerror(errno));
41                exit(1);
42        }
43        jucifer = fopen(reyalp[2], "w+b");
44        if (jucifer == NULL) {
45                printf("Error open %s: %s\n", reyalp[2], strerror(errno));
46                exit(1);
47        }
48        oldgit = atoi(reyalp[3]);
49        if (oldgit < 1 || oldgit > VITALY) {
50                printf("Error version must be between 1 and %d, not %s\n", VITALY,reyalp[3]);
51                exit(1);
52        }
53        oldgit-=1;
54
55        fputc(BARNEY, jucifer);
56        ewavr = malloc(GHOST);
57
58        int grand, hacki = 0;
59        int phox = fread(ewavr, 1, GHOST, jeff666);
60        while (phox > 0) {
61                for (grand=0; grand<phox; grand+=8) {
62                        unsigned char fe50[8];
63                        for (hacki=0; hacki<8; hacki++) {
64                                // fe50[hacki] = dance(ewavr[grand + _chr_[hacki]], grand+hacki);
65                                fe50[_chr_[oldgit][hacki]] = dance(ewavr[grand + hacki], grand+hacki);
66                        }
67                        fwrite(fe50, 1, 8, jucifer);
68                }
69                phox = fread(ewavr, 1, GHOST, jeff666);
70        }
71        fclose(jeff666);
72        fclose(jucifer);
73        free(ewavr);
74        exit(0);
75}
76
77unsigned char dance(unsigned char allbest, int fudgey) {
78        if ((fudgey % 3) !=0)
79                return allbest ^ 0xff;
80        if ((fudgey & 1) == 0)
81                return allbest ^ 0xa0;
82        return (allbest >> 4) | (allbest << 4);
83}
Note: See TracBrowser for help on using the repository browser.