From 1a457c6fec7e8bfc8880cbe4a69cc9340e3775e6 Mon Sep 17 00:00:00 2001 From: fishsoupisgood Date: Mon, 27 May 2019 03:47:23 +0100 Subject: initial commit --- master/tools.patch | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 master/tools.patch (limited to 'master/tools.patch') diff --git a/master/tools.patch b/master/tools.patch new file mode 100644 index 0000000..e23a1e4 --- /dev/null +++ b/master/tools.patch @@ -0,0 +1,159 @@ +diff --git a/tools/ana.c b/tools/ana.c +new file mode 100644 +index 0000000..7fe56f9 +--- /dev/null ++++ b/tools/ana.c +@@ -0,0 +1,153 @@ ++#include ++ ++unsigned line = 0, frame = 0; ++ ++ ++void ++byte (FILE * f, unsigned c) ++{ ++ static int len; ++ static int plen; ++ static int state; ++ static unsigned last_frame; ++ ++ unsigned diff; ++ ++ diff = frame - last_frame; ++ last_frame = frame; ++ ++ ++ if (diff > 1) ++ printf ("/* GAP ~%d frames */\n", diff); ++ ++ if (state == 0) ++ { ++ if (c == 0x55) ++ return; ++ if (c == 0xaa) ++ state++; ++ else ++ printf ("ERR %02x ERR\n", c); ++ } ++ if (state == 1) ++ { ++ if (c == 0xaa) ++ return; ++ state++; ++ } ++ ++ if (state == 2) ++ { ++ plen = c; ++ len = 1; ++ state++; ++ printf ("0x%02x, ", c); ++ putc (c, f); ++ return; ++ } ++ ++ if (state == 3) ++ { ++ printf ("0x%02x, ", c); ++ putc (c, f); ++ len++; ++ ++ if (len == plen) ++ { ++ if (plen & 1) ++ { ++ state = 4; ++ printf ("/* 0x00, */\n"); ++ } ++ else ++ { ++ state = 2; ++ printf ("\n"); ++ } ++ } ++ else ++ { ++ if ((len % 16) == 15) ++ { ++ printf ("\n/**/ "); ++ } ++ } ++ ++ return; ++ } ++ ++ if (state == 4) ++ { ++ if (c) ++ printf ("ERR %02x ERR\n", c); ++ state = 2; ++ } ++ ++ ++ ++} ++ ++int ++main (int argc, char *argv) ++{ ++ char buf[1024]; ++ unsigned i, j, c, b; ++ ++ FILE *f = fopen ("timex.dat", "r"); ++ FILE *fo = fopen ("foo.bin", "w"); ++ ++ fwrite ("Timex", 5, 1, fo); ++ ++ while (fgets (buf, sizeof (buf), f)) ++ { ++ ++ while (line > 480) ++ { ++ line -= 480; ++ frame++; ++ } ++ ++ line++; ++ ++ if (strncmp (buf, "255\n", 4)) ++ continue; ++ ++ c = 0; ++ ++ fgets (buf, sizeof (buf), f); ++ fgets (buf, sizeof (buf), f); ++ fgets (buf, sizeof (buf), f); ++ fgets (buf, sizeof (buf), f); ++ ++ line += 4; ++ ++ for (i = 0; i < 8; ++i) ++ { ++ ++ for (j = 0; j < 7; ++j) ++ fgets (buf, sizeof (buf), f); ++ line += 7; ++ ++ b = 0; ++ for (j = 0; j < 8; ++j) ++ { ++ fgets (buf, sizeof (buf), f); ++ line++; ++ b = b || (!strncmp (buf, "255\n", 4)); ++ } ++ b = !b; ++ ++//printf("%d",b); ++ ++ c |= b << i; ++ } ++ ++ byte (fo, c); ++ ++ ++ ++ } ++ fclose (fo); ++ ++ ++} -- cgit v1.2.3