mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +00:00
commit
90bfec8c04
@ -478,7 +478,7 @@ template <Analyser::Static::AppleII::Target::Model model> class ConcreteMachine:
|
||||
// The IIe and Enhanced IIe ROMs often distributed are oversized; trim if necessary.
|
||||
if(system == ROM::Name::AppleIIe || system == ROM::Name::AppleIIEnhancedE) {
|
||||
if(rom_.size() > 16128) {
|
||||
rom_.erase(rom_.begin(), rom_.end() - off_t(16128));
|
||||
rom_.erase(rom_.begin(), rom_.end() - 16128);
|
||||
}
|
||||
}
|
||||
video_.set_character_rom(roms.find(character)->second);
|
||||
|
@ -19,10 +19,11 @@ using namespace Storage::Disk;
|
||||
|
||||
AcornADF::AcornADF(const std::string &file_name) : MFMSectorDump(file_name) {
|
||||
// Check that the disk image contains a whole number of sector.
|
||||
if(file_.stats().st_size % off_t(128 << sector_size)) throw Error::InvalidFormat;
|
||||
using sizeT = decltype(file_.stats().st_size);
|
||||
if(file_.stats().st_size % sizeT(128 << sector_size)) throw Error::InvalidFormat;
|
||||
|
||||
// Check that the disk image is at least large enough to hold an ADFS catalogue.
|
||||
if(file_.stats().st_size < 7 * off_t(128 << sector_size)) throw Error::InvalidFormat;
|
||||
if(file_.stats().st_size < 7 * sizeT(128 << sector_size)) throw Error::InvalidFormat;
|
||||
|
||||
// Check that the initial directory's 'Hugo's are present.
|
||||
file_.seek(513, SEEK_SET);
|
||||
@ -35,7 +36,7 @@ AcornADF::AcornADF(const std::string &file_name) : MFMSectorDump(file_name) {
|
||||
if(bytes[0] != 'H' || bytes[1] != 'u' || bytes[2] != 'g' || bytes[3] != 'o') throw Error::InvalidFormat;
|
||||
|
||||
// Pick a number of heads; treat this image as double sided if it's too large to be single-sided.
|
||||
head_count_ = 1 + (file_.stats().st_size > sectors_per_track * off_t(128 << sector_size) * 80);
|
||||
head_count_ = 1 + (file_.stats().st_size > sectors_per_track * sizeT(128 << sector_size) * 80);
|
||||
|
||||
// Announce disk geometry.
|
||||
set_geometry(sectors_per_track, sector_size, 0, true);
|
||||
|
@ -16,7 +16,7 @@ FAT12::FAT12(const std::string &file_name) :
|
||||
MFMSectorDump(file_name) {
|
||||
// The only sanity check here is whether a sensible
|
||||
// geometry is encoded in the first sector, or can be guessed.
|
||||
off_t file_size = file_.stats().st_size;
|
||||
const auto file_size = file_.stats().st_size;
|
||||
|
||||
if(file_size < 512) throw Error::InvalidFormat;
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
using namespace Storage::Disk;
|
||||
|
||||
MacintoshIMG::MacintoshIMG(const std::string &file_name, FixedType type, size_t offset, off_t length) :
|
||||
MacintoshIMG::MacintoshIMG(const std::string &file_name, FixedType type, size_t offset, size_t length) :
|
||||
file_(file_name) {
|
||||
|
||||
switch(type) {
|
||||
@ -51,7 +51,7 @@ MacintoshIMG::MacintoshIMG(const std::string &file_name) :
|
||||
if(!((name_length == 0x4c && magic_word == 0x4b) || (name_length == 0x00 && magic_word == 0x00)))
|
||||
throw Error::InvalidFormat;
|
||||
|
||||
construct_raw_gcr(0, -1);
|
||||
construct_raw_gcr(0);
|
||||
} else {
|
||||
// DiskCopy 4.2 it is then:
|
||||
//
|
||||
@ -122,10 +122,10 @@ MacintoshIMG::MacintoshIMG(const std::string &file_name) :
|
||||
}
|
||||
}
|
||||
|
||||
void MacintoshIMG::construct_raw_gcr(size_t offset, off_t size) {
|
||||
void MacintoshIMG::construct_raw_gcr(size_t offset, size_t size) {
|
||||
is_diskCopy_file_ = false;
|
||||
if(size == -1) {
|
||||
size = file_.stats().st_size;
|
||||
if(size == 0) {
|
||||
size = size_t(file_.stats().st_size);
|
||||
}
|
||||
if(size != 819200 && size != 409600)
|
||||
throw Error::InvalidFormat;
|
||||
|
@ -42,7 +42,7 @@ class MacintoshIMG: public DiskImage {
|
||||
If @c offset and @c length are specified and non-zero, only that portion of the file
|
||||
will be modified.
|
||||
*/
|
||||
MacintoshIMG(const std::string &file_name, FixedType type, size_t offset = 0, off_t length = -1);
|
||||
MacintoshIMG(const std::string &file_name, FixedType type, size_t offset = 0, size_t length = 0);
|
||||
|
||||
// implemented to satisfy @c Disk
|
||||
HeadPosition get_maximum_head_position() final;
|
||||
@ -69,7 +69,7 @@ class MacintoshIMG: public DiskImage {
|
||||
std::mutex buffer_mutex_;
|
||||
|
||||
uint32_t checksum(const std::vector<uint8_t> &, size_t bytes_to_skip = 0);
|
||||
void construct_raw_gcr(size_t offset, off_t length);
|
||||
void construct_raw_gcr(size_t offset, size_t length = 0);
|
||||
long raw_offset_ = 0;
|
||||
};
|
||||
|
||||
|
@ -118,8 +118,8 @@ std::shared_ptr<::Storage::Disk::Track> NIB::get_track_at_position(::Storage::Di
|
||||
// when the initial sync was detected to carry over the index hole,
|
||||
// in which case there's nothing to copy.
|
||||
std::vector<uint8_t> data_segment(
|
||||
track_data.begin() + off_t(index),
|
||||
track_data.begin() + off_t(location));
|
||||
track_data.begin() + ptrdiff_t(index),
|
||||
track_data.begin() + ptrdiff_t(location));
|
||||
segment += PCMSegment(data_segment);
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ std::shared_ptr<::Storage::Disk::Track> NIB::get_track_at_position(::Storage::Di
|
||||
// with sync, so no need to deal with that case here.
|
||||
if(index < track_length) {
|
||||
std::vector<uint8_t> data_segment(
|
||||
track_data.begin() + off_t(index),
|
||||
track_data.begin() + ptrdiff_t(index),
|
||||
track_data.end());
|
||||
segment += PCMSegment(data_segment);
|
||||
}
|
||||
@ -181,7 +181,7 @@ void NIB::set_tracks(const std::map<Track::Address, std::shared_ptr<Track>> &tra
|
||||
} else {
|
||||
while(track.size() < track_length) {
|
||||
std::vector<uint8_t> extra_data(size_t(track_length) - track.size(), 0xff);
|
||||
track.insert(track.begin() + off_t(sync_location), extra_data.begin(), extra_data.end());
|
||||
track.insert(track.begin() + ptrdiff_t(sync_location), extra_data.begin(), extra_data.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ using namespace Storage::Disk;
|
||||
std::shared_ptr<Track> Storage::Disk::track_for_sectors(const uint8_t *const source, int number_of_sectors, uint8_t track, uint8_t side, uint8_t first_sector, uint8_t size, bool is_double_density) {
|
||||
std::vector<Storage::Encodings::MFM::Sector> sectors;
|
||||
|
||||
off_t byte_size = off_t(128 << size);
|
||||
off_t source_pointer = 0;
|
||||
size_t byte_size = size_t(128 << size);
|
||||
size_t source_pointer = 0;
|
||||
for(int sector = 0; sector < number_of_sectors; sector++) {
|
||||
sectors.emplace_back();
|
||||
|
||||
|
@ -60,12 +60,12 @@ void PCMSegment::rotate_right(size_t length) {
|
||||
// the left, do the opposite.
|
||||
std::vector<uint8_t> data_copy;
|
||||
if(length > 0) {
|
||||
data_copy.insert(data_copy.end(), data.end() - off_t(length), data.end());
|
||||
data.erase(data.end() - off_t(length), data.end());
|
||||
data_copy.insert(data_copy.end(), data.end() - ptrdiff_t(length), data.end());
|
||||
data.erase(data.end() - ptrdiff_t(length), data.end());
|
||||
data.insert(data.begin(), data_copy.begin(), data_copy.end());
|
||||
} else {
|
||||
data_copy.insert(data_copy.end(), data.begin(), data.begin() - off_t(length));
|
||||
data.erase(data.begin(), data.begin() - off_t(length));
|
||||
data_copy.insert(data_copy.end(), data.begin(), data.begin() - ptrdiff_t(length));
|
||||
data.erase(data.begin(), data.begin() - ptrdiff_t(length));
|
||||
data.insert(data.end(), data_copy.begin(), data_copy.end());
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ void PCMTrack::add_segment(const Time &start_time, const PCMSegment &segment, bo
|
||||
const size_t selected_end_bit = std::min(end_bit, destination.data.size());
|
||||
|
||||
// Reset the destination.
|
||||
std::fill(destination.data.begin() + off_t(start_bit), destination.data.begin() + off_t(selected_end_bit), false);
|
||||
std::fill(destination.data.begin() + ptrdiff_t(start_bit), destination.data.begin() + ptrdiff_t(selected_end_bit), false);
|
||||
|
||||
// Step through the source data from start to finish, stopping early if it goes out of bounds.
|
||||
for(size_t bit = 0; bit < segment.data.size(); ++bit) {
|
||||
@ -183,12 +183,12 @@ void PCMTrack::add_segment(const Time &start_time, const PCMSegment &segment, bo
|
||||
if(target_width >= destination.data.size()) {
|
||||
std::fill(destination.data.begin(), destination.data.end(), false);
|
||||
} else {
|
||||
std::fill(destination.data.begin(), destination.data.begin() + off_t(end_bit % destination.data.size()), false);
|
||||
std::fill(destination.data.begin() + off_t(start_bit), destination.data.end(), false);
|
||||
std::fill(destination.data.begin(), destination.data.begin() + ptrdiff_t(end_bit % destination.data.size()), false);
|
||||
std::fill(destination.data.begin() + ptrdiff_t(start_bit), destination.data.end(), false);
|
||||
}
|
||||
|
||||
// Run backwards from final bit back to first, stopping early if overlapping the beginning.
|
||||
for(off_t bit = off_t(segment.data.size()-1); bit >= 0; --bit) {
|
||||
for(auto bit = ptrdiff_t(segment.data.size()-1); bit >= 0; --bit) {
|
||||
// Store flux transitions only; non-transitions can be ignored.
|
||||
if(segment.data[size_t(bit)]) {
|
||||
// Map to the proper output destination; stop if now potentially overwriting where we began.
|
||||
|
Loading…
x
Reference in New Issue
Block a user