| 29 | { |
| 30 | public: |
| 31 | ScpFluxSource(const ScpFluxSourceProto& config): _config(config) |
| 32 | { |
| 33 | _if.open(_config.filename(), std::ios::in | std::ios::binary); |
| 34 | if (!_if.is_open()) |
| 35 | error("cannot open input file '{}': {}", |
| 36 | _config.filename(), |
| 37 | strerror(errno)); |
| 38 | |
| 39 | _if.read((char*)&_header, sizeof(_header)); |
| 40 | check_for_error(); |
| 41 | |
| 42 | if ((_header.file_id[0] != 'S') || (_header.file_id[1] != 'C') || |
| 43 | (_header.file_id[2] != 'P')) |
| 44 | error("input not a SCP file"); |
| 45 | |
| 46 | _extraConfig.mutable_drive()->set_drive_type( |
| 47 | (_header.flags & SCP_FLAG_96TPI) ? DRIVETYPE_80TRACK |
| 48 | : DRIVETYPE_40TRACK); |
| 49 | |
| 50 | _resolution = 25 * (_header.resolution + 1); |
| 51 | int startSide = (_header.heads == 2) ? 1 : 0; |
| 52 | int endSide = (_header.heads == 1) ? 0 : 1; |
| 53 | |
| 54 | if ((_header.cell_width != 0) && (_header.cell_width != 16)) |
| 55 | error("currently only 16-bit cells in SCP files are supported"); |
| 56 | |
| 57 | std::vector<CylinderHead> chs; |
| 58 | for (unsigned cylinder = trackno(_header.start_track); |
| 59 | cylinder <= trackno(_header.end_track); |
| 60 | cylinder++) |
| 61 | for (unsigned head = startSide; head <= endSide; head++) |
| 62 | chs.push_back(CylinderHead{cylinder, head}); |
| 63 | _extraConfig.mutable_drive()->set_tracks( |
| 64 | convertCylinderHeadsToString(chs)); |
| 65 | |
| 66 | log("SCP tracks {}-{}, heads {}-{}", |
| 67 | trackno(_header.start_track), |
| 68 | trackno(_header.end_track), |
| 69 | startSide, |
| 70 | endSide); |
| 71 | log("SCP sample resolution: {} ns", _resolution); |
| 72 | } |
| 73 | |
| 74 | public: |
| 75 | std::unique_ptr<const Fluxmap> readSingleFlux(int track, int side) override |
nothing calls this directly
no test coverage detected