summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2015-01-24 00:29:33 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-24 12:33:23 +1200
commitbc3b56a9690e3171aeae6105827bfc001f6b1743 (patch)
tree5b62684f45216dd7cd3e5ff8f76f299bf36a6c4b /parse-xml.c
parent724a07b7e08c3bb8f85328c30744753198139395 (diff)
downloadsubsurface-bc3b56a9690e3171aeae6105827bfc001f6b1743.tar.gz
DLF import: cleanup start mode decoding
As i thought, only 3 bits there where dive mode. Only look at those. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 98ffab32f..9113aae06 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -2569,21 +2569,33 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size)
cur_dc->duration.seconds = ((ptr[14] & 0xFE) << 16) + (ptr[13] << 8) + ptr[12];
- // ptr[15] is dive type
- if (0xc8 <= ptr[15] && ptr[15] <= 0xcf)
+ // ptr[14] >> 1 is scrubber used in %
+
+ // 3 bit dive type
+ switch((ptr[15] & 0x30) >> 3) {
+ case 0: // unknown
+ case 1:
cur_dc->divemode = OC;
- else if (0xd0 <= ptr[15] && ptr[15] <= 0xd7)
+ break;
+ case 2:
cur_dc->divemode = CCR;
- else if (0xd8 <= ptr[15] && ptr[15] <= 0xdf)
+ break;
+ case 3:
cur_dc->divemode = CCR; // mCCR
- else if (0xe0 <= ptr[15] && ptr[15] <= 0xe7)
+ break;
+ case 4:
cur_dc->divemode = FREEDIVE;
- else if (0xe8 <= ptr[15] && ptr[15] <= 0xef)
+ break;
+ case 5:
cur_dc->divemode = OC; // Gauge
- else if (0xf0 <= ptr[15] && ptr[15] <= 0xf7)
+ break;
+ case 6:
cur_dc->divemode = PSCR; // ASCR
- else if (0xf8 <= ptr[15] && ptr[15] <= 0xff)
+ break;
+ case 7:
cur_dc->divemode = PSCR;
+ break;
+ }
cur_dc->maxdepth.mm = ((ptr[21] << 8) + ptr[20]) * 10;