summaryrefslogtreecommitdiffstats
path: root/cochran.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-01-27 18:27:30 -0800
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-01-27 18:27:30 -0800
commit2d88353b5965853c01a9d394f96a5d0545d86b21 (patch)
treeaa31da3a0f268ea17168af189dab99aa2040fa82 /cochran.c
parent3d8d5da999264595c7fecc786c101b40573689df (diff)
downloadsubsurface-2d88353b5965853c01a9d394f96a5d0545d86b21.tar.gz
Cochran: fix up dive data descrambling
This seems to do the dive data descrambling right for both files I have access to. Except it uses a hardcoded (different) offset for the two. I have yet to figure out how to automatically detect the offset itself properly, so you have to compile for the right file. I'll figure it out, but I'm committing this as a reasonable point in the process. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'cochran.c')
-rw-r--r--cochran.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/cochran.c b/cochran.c
index ce42c3131..360f2eb7c 100644
--- a/cochran.c
+++ b/cochran.c
@@ -8,6 +8,8 @@
#include "dive.h"
#include "file.h"
+#define DON
+
/*
* The Cochran file format is designed to be annoying to read. It's roughly:
*
@@ -153,6 +155,11 @@ static void parse_cochran_dive(const char *filename, int dive,
const unsigned char *in, unsigned size)
{
char *buf = malloc(size);
+#ifdef DON
+ unsigned int offset = 0x4a14;
+#else
+ unsigned int offset = 0x4b14;
+#endif
/*
* The scrambling has odd boundaries. I think the boundaries
@@ -175,9 +182,8 @@ static void parse_cochran_dive(const char *filename, int dive,
* scrambled, but there seems to be size differences in the data,
* so this just descrambles part of it:
*/
- partial_decode(0x48ff, 0x4a14, decode, 0, mod, in, size, buf);
- partial_decode(0x4a14, 0xc9bd, decode, 0, mod, in, size, buf);
- partial_decode(0xc9bd, size, decode, 0, mod, in, size, buf);
+ partial_decode(0x48ff, offset, decode, 0, mod, in, size, buf);
+ partial_decode(offset, size, decode, 0, mod, in, size, buf);
printf("\n%s, dive %d\n\n", filename, dive);
cochran_debug_write(filename, buf, size);