mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +00:00
Factors HFE track seeking out from the track fetching method.
This commit is contained in:
parent
7b01c1bee6
commit
1cc85615d5
@ -36,7 +36,14 @@ unsigned int HFE::get_head_count() {
|
||||
return head_count_;
|
||||
}
|
||||
|
||||
std::shared_ptr<Track> HFE::get_track_at_position(unsigned int head, unsigned int position) {
|
||||
/*!
|
||||
Seeks to the beginning of the track at @c position underneath @c head,
|
||||
returning its length in bytes.
|
||||
|
||||
To read the track, start from the current file position, read 256 bytes,
|
||||
skip 256 bytes, read 256 bytes, skip 256 bytes, etc.
|
||||
*/
|
||||
uint16_t HFE::seek_track(unsigned int head, unsigned int position) {
|
||||
// Get track position and length from the lookup table; data is then always interleaved
|
||||
// based on an assumption of two heads.
|
||||
fseek(file_, track_list_offset_ + position * 4, SEEK_SET);
|
||||
@ -47,8 +54,14 @@ std::shared_ptr<Track> HFE::get_track_at_position(unsigned int head, unsigned in
|
||||
fseek(file_, track_offset, SEEK_SET);
|
||||
if(head) fseek(file_, 256, SEEK_CUR);
|
||||
|
||||
return track_length / 2;
|
||||
}
|
||||
|
||||
std::shared_ptr<Track> HFE::get_track_at_position(unsigned int head, unsigned int position) {
|
||||
uint16_t track_length = seek_track(head, position);
|
||||
|
||||
PCMSegment segment;
|
||||
uint16_t side_length = track_length / 2;
|
||||
uint16_t side_length = track_length;
|
||||
segment.data.resize(side_length);
|
||||
segment.number_of_bits = side_length * 8;
|
||||
|
||||
@ -68,3 +81,5 @@ std::shared_ptr<Track> HFE::get_track_at_position(unsigned int head, unsigned in
|
||||
return track;
|
||||
}
|
||||
|
||||
void HFE::set_track_at_position(unsigned int head, unsigned int position, const std::shared_ptr<Track> &track) {
|
||||
}
|
||||
|
@ -37,9 +37,11 @@ class HFE: public DiskImage, public Storage::FileHolder {
|
||||
unsigned int get_head_position_count();
|
||||
unsigned int get_head_count();
|
||||
using Storage::FileHolder::get_is_read_only;
|
||||
void set_track_at_position(unsigned int head, unsigned int position, const std::shared_ptr<Track> &track);
|
||||
std::shared_ptr<Track> get_track_at_position(unsigned int head, unsigned int position);
|
||||
|
||||
private:
|
||||
uint16_t seek_track(unsigned int head, unsigned int position);
|
||||
|
||||
unsigned int head_count_;
|
||||
unsigned int track_count_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user