mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +00:00
Made an attempt to separate and isolate the stuff of creating flux events from a PCMSegment
, eventually to factor that out of PCMTrack
and make it available also to PCMPatchedTrack
.
This commit is contained in:
parent
313db75303
commit
254cc41fd6
@ -11,6 +11,7 @@
|
||||
4B0BE4281D3481E700D5256B /* DigitalPhaseLockedLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0BE4261D3481E700D5256B /* DigitalPhaseLockedLoop.cpp */; };
|
||||
4B0CCC451C62D0B3001CAC5F /* CRT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0CCC421C62D0B3001CAC5F /* CRT.cpp */; };
|
||||
4B121F951E05E66800BFDA12 /* PCMPatchedTrackTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B121F941E05E66800BFDA12 /* PCMPatchedTrackTests.mm */; };
|
||||
4B121F981E060CF000BFDA12 /* PCMSegment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B121F961E060CF000BFDA12 /* PCMSegment.cpp */; };
|
||||
4B14145B1B58879D00E04248 /* CPU6502.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1414571B58879D00E04248 /* CPU6502.cpp */; };
|
||||
4B14145D1B5887A600E04248 /* CPU6502.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1414571B58879D00E04248 /* CPU6502.cpp */; };
|
||||
4B14145E1B5887AA00E04248 /* CPU6502AllRAM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1414591B58879D00E04248 /* CPU6502AllRAM.cpp */; };
|
||||
@ -426,8 +427,9 @@
|
||||
4B0BE4271D3481E700D5256B /* DigitalPhaseLockedLoop.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DigitalPhaseLockedLoop.hpp; sourceTree = "<group>"; };
|
||||
4B0CCC421C62D0B3001CAC5F /* CRT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CRT.cpp; sourceTree = "<group>"; };
|
||||
4B0CCC431C62D0B3001CAC5F /* CRT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CRT.hpp; sourceTree = "<group>"; };
|
||||
4B121F931E05E66800BFDA12 /* PCMPatchedTrackTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCMPatchedTrackTests.h; sourceTree = "<group>"; };
|
||||
4B121F941E05E66800BFDA12 /* PCMPatchedTrackTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PCMPatchedTrackTests.mm; sourceTree = "<group>"; };
|
||||
4B121F961E060CF000BFDA12 /* PCMSegment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PCMSegment.cpp; sourceTree = "<group>"; };
|
||||
4B121F971E060CF000BFDA12 /* PCMSegment.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PCMSegment.hpp; sourceTree = "<group>"; };
|
||||
4B1414501B58848C00E04248 /* ClockSignal-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ClockSignal-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
4B1414571B58879D00E04248 /* CPU6502.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPU6502.cpp; sourceTree = "<group>"; };
|
||||
4B1414581B58879D00E04248 /* CPU6502.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CPU6502.hpp; sourceTree = "<group>"; };
|
||||
@ -503,7 +505,6 @@
|
||||
4B4DC82A1D2C27A4003C5BF8 /* SerialBus.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SerialBus.hpp; sourceTree = "<group>"; };
|
||||
4B5073051DDD3B9400C48FBD /* ArrayBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayBuilder.cpp; sourceTree = "<group>"; };
|
||||
4B5073061DDD3B9400C48FBD /* ArrayBuilder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ArrayBuilder.hpp; sourceTree = "<group>"; };
|
||||
4B5073081DDFCFDF00C48FBD /* ArrayBuilderTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayBuilderTests.h; sourceTree = "<group>"; };
|
||||
4B5073091DDFCFDF00C48FBD /* ArrayBuilderTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ArrayBuilderTests.mm; sourceTree = "<group>"; };
|
||||
4B55CE5B1C3B7D6F0093A61B /* CSOpenGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSOpenGLView.h; sourceTree = "<group>"; };
|
||||
4B55CE5C1C3B7D6F0093A61B /* CSOpenGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSOpenGLView.m; sourceTree = "<group>"; };
|
||||
@ -1302,12 +1303,14 @@
|
||||
4B6C73BB1D387AE500AFCFCA /* DiskController.cpp */,
|
||||
4B30512B1D989E2200B4FED8 /* Drive.cpp */,
|
||||
4B3F1B441E0388D200DB26EE /* PCMPatchedTrack.cpp */,
|
||||
4B121F961E060CF000BFDA12 /* PCMSegment.cpp */,
|
||||
4BAB62B61D3302CA00DF5BA0 /* PCMTrack.cpp */,
|
||||
4B0BE4271D3481E700D5256B /* DigitalPhaseLockedLoop.hpp */,
|
||||
4BAB62AC1D3272D200DF5BA0 /* Disk.hpp */,
|
||||
4B6C73BC1D387AE500AFCFCA /* DiskController.hpp */,
|
||||
4B30512C1D989E2200B4FED8 /* Drive.hpp */,
|
||||
4B3F1B451E0388D200DB26EE /* PCMPatchedTrack.hpp */,
|
||||
4B121F971E060CF000BFDA12 /* PCMSegment.hpp */,
|
||||
4BAB62B71D3302CA00DF5BA0 /* PCMTrack.hpp */,
|
||||
4BB697CF1D4BA44900248BDF /* Encodings */,
|
||||
4BAB62B21D327F7E00DF5BA0 /* Formats */,
|
||||
@ -1681,8 +1684,6 @@
|
||||
4BB73EB51B587A5100552FC2 /* Clock SignalTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4B5073081DDFCFDF00C48FBD /* ArrayBuilderTests.h */,
|
||||
4B121F931E05E66800BFDA12 /* PCMPatchedTrackTests.h */,
|
||||
4B121F941E05E66800BFDA12 /* PCMPatchedTrackTests.mm */,
|
||||
4B5073091DDFCFDF00C48FBD /* ArrayBuilderTests.mm */,
|
||||
4BB73EB81B587A5100552FC2 /* Info.plist */,
|
||||
@ -2450,6 +2451,7 @@
|
||||
4B3BA0D11D318B44005DD7A7 /* TestMachine.mm in Sources */,
|
||||
4B92EACA1B7C112B00246143 /* 6502TimingTests.swift in Sources */,
|
||||
4BB73EB71B587A5100552FC2 /* AllSuiteATests.swift in Sources */,
|
||||
4B121F981E060CF000BFDA12 /* PCMSegment.cpp in Sources */,
|
||||
4BEF6AAC1D35D1C400E73575 /* DPLLTests.swift in Sources */,
|
||||
4B3BA0CF1D318B44005DD7A7 /* MOS6522Bridge.mm in Sources */,
|
||||
4BC751B21D157E61006C31D9 /* 6522Tests.swift in Sources */,
|
||||
|
@ -1,13 +0,0 @@
|
||||
//
|
||||
// ArrayBuilderTests.h
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 19/11/2016.
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@interface ArrayBuilderTests : XCTestCase
|
||||
|
||||
@end
|
@ -6,7 +6,8 @@
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ArrayBuilderTests.h"
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#include "ArrayBuilder.hpp"
|
||||
|
||||
static NSData *inputData, *outputData;
|
||||
@ -17,6 +18,9 @@ static void setData(bool is_input, uint8_t *data, size_t size)
|
||||
if(is_input) inputData = dataObject; else outputData = dataObject;
|
||||
}
|
||||
|
||||
@interface ArrayBuilderTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation ArrayBuilderTests
|
||||
|
||||
+ (void)setUp
|
||||
|
@ -1,13 +0,0 @@
|
||||
//
|
||||
// PCMPatchedTrackTests.h
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 17/12/2016.
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@interface PCMPatchedTrackTests : XCTestCase
|
||||
|
||||
@end
|
@ -6,11 +6,14 @@
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PCMPatchedTrackTests.h"
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#include "PCMTrack.hpp"
|
||||
#include "PCMPatchedTrack.hpp"
|
||||
|
||||
@interface PCMPatchedTrackTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation PCMPatchedTrackTests
|
||||
|
||||
- (std::shared_ptr<Storage::Disk::Track>)togglingTrack
|
||||
@ -50,4 +53,14 @@
|
||||
[self assertOneThirtyTwosForTrack:self.patchableTogglingTrack];
|
||||
}
|
||||
|
||||
- (void)testZeroPatch
|
||||
{
|
||||
std::shared_ptr<Storage::Disk::Track> patchableTrack = self.togglingTrack;
|
||||
Storage::Disk::PCMPatchedTrack *patchable = dynamic_cast<Storage::Disk::PCMPatchedTrack *>(patchableTrack.get());
|
||||
if(patchable)
|
||||
{
|
||||
printf(".");
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
48
Storage/Disk/PCMSegment.cpp
Normal file
48
Storage/Disk/PCMSegment.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
//
|
||||
// PCMSegment.cpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 17/12/2016.
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#include "PCMSegment.hpp"
|
||||
|
||||
using namespace Storage::Disk;
|
||||
|
||||
PCMSegmentEventSource::PCMSegmentEventSource(const PCMSegment &segment) :
|
||||
segment_(segment)
|
||||
{
|
||||
if(segment_.length_of_a_bit.length&1)
|
||||
{
|
||||
segment_.length_of_a_bit.length <<= 1;
|
||||
segment_.length_of_a_bit.clock_rate <<= 1;
|
||||
}
|
||||
next_event_.length.clock_rate = segment_.length_of_a_bit.clock_rate;
|
||||
reset();
|
||||
}
|
||||
|
||||
void PCMSegmentEventSource::reset()
|
||||
{
|
||||
bit_pointer_ = 0;
|
||||
next_event_.length.length = -(segment_.length_of_a_bit.length >> 1);
|
||||
next_event_.type = Track::Event::FluxTransition;
|
||||
}
|
||||
|
||||
Storage::Disk::Track::Event PCMSegmentEventSource::get_next_event()
|
||||
{
|
||||
Storage::Disk::Track::Event next_event;
|
||||
|
||||
const uint8_t *segment_data = segment_.data.data();
|
||||
while(bit_pointer_ < segment_.number_of_bits)
|
||||
{
|
||||
int bit = segment_data[bit_pointer_ >> 3] & (0x80 >> (bit_pointer_&7));
|
||||
bit_pointer_++;
|
||||
next_event_.length.length += segment_.length_of_a_bit.length;
|
||||
|
||||
if(bit) return next_event_;
|
||||
}
|
||||
|
||||
next_event_.type = Track::Event::IndexHole;
|
||||
return next_event;
|
||||
}
|
48
Storage/Disk/PCMSegment.hpp
Normal file
48
Storage/Disk/PCMSegment.hpp
Normal file
@ -0,0 +1,48 @@
|
||||
//
|
||||
// PCMSegment.hpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 17/12/2016.
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef PCMSegment_hpp
|
||||
#define PCMSegment_hpp
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "../Storage.hpp"
|
||||
#include "Disk.hpp"
|
||||
|
||||
namespace Storage {
|
||||
namespace Disk {
|
||||
|
||||
/*!
|
||||
A segment of PCM-sampled data.
|
||||
|
||||
Bits from each byte are taken MSB to LSB.
|
||||
*/
|
||||
struct PCMSegment {
|
||||
Time length_of_a_bit;
|
||||
unsigned int number_of_bits;
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
|
||||
class PCMSegmentEventSource {
|
||||
public:
|
||||
PCMSegmentEventSource(const PCMSegment &segment);
|
||||
|
||||
Track::Event get_next_event();
|
||||
void reset();
|
||||
|
||||
private:
|
||||
PCMSegment segment_;
|
||||
size_t bit_pointer_;
|
||||
Track::Event next_event_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PCMSegment_hpp */
|
@ -10,22 +10,12 @@
|
||||
#define PCMTrack_hpp
|
||||
|
||||
#include "Disk.hpp"
|
||||
#include "PCMSegment.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace Storage {
|
||||
namespace Disk {
|
||||
|
||||
/*!
|
||||
A segment of PCM-sampled data.
|
||||
|
||||
Bits from each byte are taken MSB to LSB.
|
||||
*/
|
||||
struct PCMSegment {
|
||||
Time length_of_a_bit;
|
||||
unsigned int number_of_bits;
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
|
||||
/*!
|
||||
A subclass of @c Track that provides its @c Events by querying a pulse-code modulated record of original
|
||||
flux detections, with an implied index hole at the very start of the data.
|
||||
|
Loading…
x
Reference in New Issue
Block a user