1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-30 19:30:17 +00:00

Ensures prefixes are MFM encoded and decoded.

This commit is contained in:
Thomas Harte 2020-01-11 22:10:41 -05:00
parent 2b4c924399
commit f81a7f0faf
2 changed files with 12 additions and 5 deletions

View File

@ -67,7 +67,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableASanStackUseAfterReturn = "YES"

View File

@ -56,9 +56,15 @@ class TrackConstructor {
std::vector<uint8_t> result;
result.reserve(size_t(end - begin) + prefix.size());
// Encode as MFM.
PCMSegment segment;
std::unique_ptr<Storage::Encodings::MFM::Encoder> encoder = Storage::Encodings::MFM::GetMFMEncoder(segment.data);
// Encode prefix.
for(auto c: prefix) {
encoder->add_byte(c);
}
// Encode body.
while(begin != end) {
encoder->add_byte(*begin);
++begin;
@ -69,9 +75,6 @@ class TrackConstructor {
Shifter shifter;
shifter.set_should_obey_syncs(true);
// Add the prefix.
std::copy(prefix.begin(), prefix.end(), std::back_inserter(result));
// Add whatever comes from the track.
for(auto bit: segment.data) {
shifter.add_input_bit(int(bit));
@ -243,6 +246,10 @@ std::shared_ptr<::Storage::Disk::Track> STX::get_track_at_position(::Storage::Di
const int track_index = (address.head * 0x80) + address.position.as_int();
if(!offset_by_track_[track_index]) return nullptr;
if(track_index == 41) {
printf("Y\n");
} else printf("N\n");
// Seek to the track (skipping the record size field).
file_.seek(offset_by_track_[track_index] + 4, SEEK_SET);