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

Enables write support.

This commit is contained in:
Thomas Harte 2019-09-18 20:18:02 -04:00
parent 962275c22a
commit 128a1da626

View File

@ -41,19 +41,14 @@ std::vector<uint8_t> HFV::get_block(size_t address) {
} }
void HFV::set_block(size_t address, const std::vector<uint8_t> &contents) { void HFV::set_block(size_t address, const std::vector<uint8_t> &contents) {
writes_[address] = contents; const auto source_address = mapper_.to_source_address(address);
if(source_address >= 0 && size_t(source_address)*get_block_size() < size_t(file_.stats().st_size)) {
printf("[%zu]: ", address); const long file_offset = long(get_block_size()) * long(source_address);
for(uint8_t v: contents) { file_.seek(file_offset, SEEK_SET);
printf("%02x ", v); file_.write(contents);
} } else {
printf("\n"); writes_[address] = contents;
// const auto source_address = mapper_.to_source_address(address); }
// if(source_address >= 0 && size_t(source_address)*get_block_size() < size_t(file_.stats().st_size)) {
// const long file_offset = long(get_block_size()) * long(source_address);
// file_.seek(file_offset, SEEK_SET);
// file_.write(contents);
// }
} }
void HFV::set_drive_type(Encodings::Macintosh::DriveType drive_type) { void HFV::set_drive_type(Encodings::Macintosh::DriveType drive_type) {