| 58 | } |
| 59 | |
| 60 | static void write_sector_data( |
| 61 | std::vector<bool>& bits, unsigned& cursor, const Bytes& data) |
| 62 | { |
| 63 | write_bits(bits, cursor, 0xffffffff, 32); |
| 64 | write_bits(bits, cursor, BROTHER_DATA_RECORD, 32); |
| 65 | |
| 66 | uint16_t fifo = 0; |
| 67 | int width = 0; |
| 68 | |
| 69 | if (data.size() != BROTHER_DATA_RECORD_PAYLOAD) |
| 70 | error("unsupported sector size"); |
| 71 | |
| 72 | auto write_byte = [&](uint8_t byte) |
| 73 | { |
| 74 | fifo |= (byte << (8 - width)); |
| 75 | width += 8; |
| 76 | |
| 77 | while (width >= 5) |
| 78 | { |
| 79 | uint8_t quintet = fifo >> 11; |
| 80 | fifo <<= 5; |
| 81 | width -= 5; |
| 82 | |
| 83 | write_bits(bits, cursor, encode_data_gcr(quintet), 8); |
| 84 | } |
| 85 | }; |
| 86 | |
| 87 | for (uint8_t byte : data) |
| 88 | write_byte(byte); |
| 89 | |
| 90 | uint32_t realCrc = crcbrother(data); |
| 91 | write_byte(realCrc >> 16); |
| 92 | write_byte(realCrc >> 8); |
| 93 | write_byte(realCrc); |
| 94 | write_byte(0x58); /* magic */ |
| 95 | write_byte(0xd4); |
| 96 | while (width != 0) |
| 97 | write_byte(0); |
| 98 | } |
| 99 | |
| 100 | class BrotherEncoder : public Encoder |
| 101 | { |
no test coverage detected