mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 16:31:31 +00:00
Switched PCMSegment
s to std::vector
; ensured generated [M]FM tracks are correctly sized, thereby making sure the individual flux windows will be correctly sized.
This commit is contained in:
parent
d9aaf456f0
commit
5409c8ec54
@ -130,7 +130,8 @@ template<class T> std::shared_ptr<Storage::Disk::Track>
|
||||
size_t post_index_address_mark_bytes, uint8_t post_index_address_mark_value,
|
||||
size_t pre_address_mark_bytes, size_t post_address_mark_bytes,
|
||||
size_t pre_data_mark_bytes, size_t post_data_bytes,
|
||||
size_t inter_sector_gap)
|
||||
size_t inter_sector_gap,
|
||||
size_t expected_track_bytes)
|
||||
{
|
||||
T shifter;
|
||||
NumberTheory::CRC16 crc_generator(0x1021, 0xffff);
|
||||
@ -188,18 +189,18 @@ template<class T> std::shared_ptr<Storage::Disk::Track>
|
||||
for(int c = 0; c < inter_sector_gap; c++) shifter.add_byte(0x4e);
|
||||
}
|
||||
|
||||
// TODO: total size check
|
||||
while(shifter.segment.data.size() < expected_track_bytes) shifter.add_byte(0x00);
|
||||
|
||||
Storage::Disk::PCMSegment segment;
|
||||
return std::shared_ptr<Storage::Disk::Track>(new Storage::Disk::PCMTrack(std::move(segment)));
|
||||
shifter.segment.number_of_bits = shifter.segment.data.size() * 8;
|
||||
return std::shared_ptr<Storage::Disk::Track>(new Storage::Disk::PCMTrack(std::move(shifter.segment)));
|
||||
}
|
||||
|
||||
struct VectorReceiver {
|
||||
void output_short(uint16_t value) {
|
||||
data.push_back(value >> 8);
|
||||
data.push_back(value & 0xff);
|
||||
segment.data.push_back(value >> 8);
|
||||
segment.data.push_back(value & 0xff);
|
||||
}
|
||||
std::vector<uint8_t> data;
|
||||
Storage::Disk::PCMSegment segment;
|
||||
};
|
||||
|
||||
std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetFMTrackWithSectors(const std::vector<Sector> §ors)
|
||||
@ -212,7 +213,8 @@ std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetFMTrackWithSec
|
||||
16, 0x00,
|
||||
6, 0,
|
||||
17, 14,
|
||||
0);
|
||||
0,
|
||||
6400);
|
||||
}
|
||||
|
||||
std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetMFMTrackWithSectors(const std::vector<Sector> §ors)
|
||||
@ -225,5 +227,6 @@ std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetMFMTrackWithSe
|
||||
50, 0x4e,
|
||||
12, 22,
|
||||
12, 18,
|
||||
32);
|
||||
32,
|
||||
12800);
|
||||
}
|
||||
|
@ -102,8 +102,8 @@ std::shared_ptr<Track> D64::get_track_at_position(unsigned int position)
|
||||
PCMSegment track;
|
||||
size_t track_bytes = 349 * (size_t)sectors_by_zone[zone];
|
||||
track.number_of_bits = (unsigned int)track_bytes * 8;
|
||||
uint8_t *data = new uint8_t[track_bytes];
|
||||
track.data.reset(data);
|
||||
track.data.resize(track_bytes);
|
||||
uint8_t *data = &track.data[0];
|
||||
|
||||
memset(data, 0, track_bytes);
|
||||
|
||||
|
@ -84,8 +84,8 @@ std::shared_ptr<Track> G64::get_track_at_position(unsigned int position)
|
||||
track_length |= (uint16_t)fgetc(_file) << 8;
|
||||
|
||||
// grab the byte contents of this track
|
||||
std::unique_ptr<uint8_t> track_contents(new uint8_t[track_length]);
|
||||
fread(track_contents.get(), 1, track_length, _file);
|
||||
std::vector<uint8_t> track_contents(track_length);
|
||||
fread(&track_contents[0], 1, track_length, _file);
|
||||
|
||||
// seek to this track's entry in the speed zone table
|
||||
fseek(_file, (long)((position * 4) + 0x15c), SEEK_SET);
|
||||
@ -123,8 +123,8 @@ std::shared_ptr<Track> G64::get_track_at_position(unsigned int position)
|
||||
PCMSegment segment;
|
||||
segment.number_of_bits = number_of_bytes * 8;
|
||||
segment.length_of_a_bit = Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(current_speed);
|
||||
segment.data.reset(new uint8_t[number_of_bytes]);
|
||||
memcpy(segment.data.get(), &track_contents.get()[start_byte_in_current_speed], number_of_bytes);
|
||||
segment.data.resize(number_of_bytes);
|
||||
memcpy(&segment.data[0], &track_contents[start_byte_in_current_speed], number_of_bytes);
|
||||
segments.push_back(std::move(segment));
|
||||
|
||||
current_speed = byte_speed;
|
||||
|
@ -36,7 +36,7 @@ PCMTrack::Event PCMTrack::get_next_event()
|
||||
unsigned int clock_multiplier = _track_clock_rate / _segments[_segment_pointer].length_of_a_bit.clock_rate;
|
||||
unsigned int bit_length = clock_multiplier * _segments[_segment_pointer].length_of_a_bit.length;
|
||||
|
||||
const uint8_t *segment_data = _segments[_segment_pointer].data.get();
|
||||
const uint8_t *segment_data = &_segments[_segment_pointer].data[0];
|
||||
while(_bit_pointer < _segments[_segment_pointer].number_of_bits)
|
||||
{
|
||||
// for timing simplicity, bits are modelled as happening at the end of their window
|
||||
|
@ -23,7 +23,7 @@ namespace Disk {
|
||||
struct PCMSegment {
|
||||
Time length_of_a_bit;
|
||||
unsigned int number_of_bits;
|
||||
std::unique_ptr<uint8_t> data;
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user