| 940 | } |
| 941 | |
| 942 | void unpack(const unsigned char* data, unsigned char* output, const int maxLength) { |
| 943 | int pos = 0; |
| 944 | size_t index = 0; |
| 945 | int p2 = 0; |
| 946 | memset(output, 0, maxLength); |
| 947 | while (pos < maxLength) { |
| 948 | // Each byte contains four pairs of bits that identify an MFM sequence to be encoded |
| 949 | |
| 950 | for (int b = 6; b >= 0; b -= 2) { |
| 951 | switch ((data[index] >> b) & 3) { |
| 952 | case 0: |
| 953 | // This can't happen, its invalid data but we account for 4 '0' bits |
| 954 | writeBit(output, pos, p2, 0, maxLength); |
| 955 | writeBit(output, pos, p2, 0, maxLength); |
| 956 | writeBit(output, pos, p2, 0, maxLength); |
| 957 | writeBit(output, pos, p2, 0, maxLength); |
| 958 | break; |
| 959 | case 1: // This is an '01' |
| 960 | writeBit(output, pos, p2, 0, maxLength); |
| 961 | writeBit(output, pos, p2, 1, maxLength); |
| 962 | break; |
| 963 | case 2: // This is an '001' |
| 964 | writeBit(output, pos, p2, 0, maxLength); |
| 965 | writeBit(output, pos, p2, 0, maxLength); |
| 966 | writeBit(output, pos, p2, 1, maxLength); |
| 967 | break; |
| 968 | case 3: // this is an '0001' |
| 969 | writeBit(output, pos, p2, 0, maxLength); |
| 970 | writeBit(output, pos, p2, 0, maxLength); |
| 971 | writeBit(output, pos, p2, 0, maxLength); |
| 972 | writeBit(output, pos, p2, 1, maxLength); |
| 973 | break; |
| 974 | } |
| 975 | } |
| 976 | index++; |
| 977 | if (index >= (size_t)maxLength) return; |
| 978 | } |
| 979 | // There will be left-over data |
| 980 | } |
| 981 | |
| 982 | // Read RAW data from the current track and surface |
| 983 | DiagnosticResponse ArduinoInterface::readCurrentTrack(RawTrackDataDD& trackData, const bool readFromIndexPulse) { |
no test coverage detected