From: Michael Gernoth Date: Sat, 5 Sep 2020 19:32:03 +0000 (+0200) Subject: cleanup chipselect X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/32620_extract/commitdiff_plain/b2130b29087d653cfbab0e1dd81d47b1dbbd37c7 cleanup chipselect --- diff --git a/extract.c b/extract.c index 79fd423..7d7c9d1 100644 --- a/extract.c +++ b/extract.c @@ -34,7 +34,7 @@ int main(int argc, char **argv) { uint8_t header[64]; uint32_t adrs[(64/3)+1] = { 0 }; - uint8_t last_cs = 0; + uint8_t cs2 = 0; int fd; int r; int i; @@ -74,19 +74,18 @@ int main(int argc, char **argv) uint32_t adr; lo = header[i]; - if ((header[i+2] & 0xf8) & 0x40) { + hi = header[i+1] & 0x1f; + + //!EOF ?! + if ((header[i+2] & 0xf8) != 0xf8) + cs2 = header[i+2] & 0xf8; + + if (cs2 & 0x40) { cs = ((header[i+1] & 0xe0) >> 5) - 2; } else { cs = (((header[i+1] & 0xe0) >> 5) | (1 << 3)) - 4; } - //EOF?! - if ((header[i+2] & 0xf8) == 0xf8) - cs = last_cs; - else - last_cs = cs; - - hi = header[i+1] & 0x1f; amp = header[i+2] & 0x3; adr = ((hi << 8) | lo) + (cs * 8192);