]> git.zerfleddert.de Git - 32620_extract/blobdiff - extract.c
module decoding changes
[32620_extract] / extract.c
index 79fd4233036f07d1c2db4f4121671974474f6b06..805be1a5d2fdf53733acf1b507983ace5dfe64e5 100644 (file)
--- 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;
@@ -62,9 +62,9 @@ int main(int argc, char **argv)
         *
         * 00000000 01000000 01000011 10110111 01001010 01000011 11000011 01011000
         * ^^^^^^^^ ^^^^^^^^ ^^^^^^^^|                          |
-        * LIIIIIII LIILIIII I????LII
-        *        I   I    I I      +-- Amplification (Default: 3)
-        *        I   I    I +--------- Remaining chip select line? (but not quite?)
+        * LIIIIIII LIILIIII LIIIILII
+        *        I   I    I     |  +-- Amplification (Default: 3)
+        *        I   I    I     +----- Chip/Module Select lines/EOF?
         *        I   I    +----------- Address (HI Byte)
         *        I   +---------------- Chip Select lines A15, A14, A13
         *        +-------------------- Address (LO Byte)
@@ -74,27 +74,29 @@ int main(int argc, char **argv)
                uint32_t adr;
 
                lo = header[i];
-               if ((header[i+2] & 0xf8) & 0x40) {
-                       cs = ((header[i+1] & 0xe0) >> 5) - 2;
-               } else {
-                       cs = (((header[i+1] & 0xe0) >> 5) | (1 << 3)) - 4;
-               }
+               hi = header[i+1] & 0x1f;
 
-               //EOF?!
-               if ((header[i+2] & 0xf8) == 0xf8)
-                       cs = last_cs;
-               else
-                       last_cs = cs;
+               // !EOF ?!
+               if ((header[i+2] & 0xf8) != 0xf8)
+                       cs2 = (header[i+2] & 0xf8) >> 3;
+
+               cs = ((header[i+1] & 0xe0) >> 5) - 2;
+
+               // second module?
+               if ((cs2 & 0x08) == 0x00)
+                       cs += 6; // 6 ROMs per module
 
-               hi = header[i+1] & 0x1f;
                amp = header[i+2] & 0x3;
 
                adr = ((hi << 8) | lo) + (cs * 8192);
-               if (cs == 0)
+               if (adr == 0)
                        adr += sizeof(header);
 
-               printf("%02d. hi: 0x%02x, lo: 0x%02x, cs: 0x%02x -> adr: 0x%04x; amp: 0x%02x\n",
-                      i/3, hi, lo, cs, adr, amp);
+               printf("%02d. hi: 0x%02x, lo: 0x%02x, cs: 0x%02x, cs2: 0x%02x -> chip: 0x%02x, adr: 0x%04x; amp: 0x%02x\n",
+                      i/3, hi, lo,
+                      ((header[i+1] & 0xe0) >> 5),
+                      ((header[i+2] & 0xf8) >> 3),
+                      cs, adr, amp);
 
                adrs[i/3] = adr;
                if ((header[i+2] & 0xf8) == 0xf8)
Impressum, Datenschutz