summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2022-08-11 11:12:48 +0200
committer Olivier Galibert <galibert@pobox.com>2022-08-11 11:12:55 +0200
commit709bb88139079ebd5f12caa3b99d705a15e3bf82 (patch)
treefd875743816d60997c6589d35cbf4d528a0d48ea /src/lib/formats
parent5b034e4921faf712d852b10ddaa7582f849c090e (diff)
woz/flux: better implementation
Diffstat (limited to 'src/lib/formats')
-rw-r--r--src/lib/formats/ap2_dsk.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/formats/ap2_dsk.cpp b/src/lib/formats/ap2_dsk.cpp
index 1c128f3d26e..7fb3a2225dd 100644
--- a/src/lib/formats/ap2_dsk.cpp
+++ b/src/lib/formats/ap2_dsk.cpp
@@ -1743,20 +1743,24 @@ bool a2_woz_format::load(util::random_read &io, uint32_t form_factor, const std:
uint32_t boff = (uint32_t)r16(img, trks_off + 0) * 512;
uint32_t track_size = r32(img, trks_off + 4);
- uint32_t total_ticks = 0;
- for(uint32_t i=0; i != track_size; i++)
- total_ticks += img[boff+i];
+ // Ticks are 125ns, e.g. 8000000 ticks per second
+ static const int ticks_per_speed_zone[5] = {
+ 60 * 8000000 / 394,
+ 60 * 8000000 / 429,
+ 60 * 8000000 / 472,
+ 60 * 8000000 / 525,
+ 60 * 8000000 / 590
+ };
- // Assumptions: track starts at index, there's no flux
- // change at index, there's no flux change at the end
+ uint32_t total_ticks = is_35 ? ticks_per_speed_zone[trkid / (2*16)] : 60 * 8000000 / 300;
std::vector<uint32_t> &buf = image->get_buffer(track, head, subtrack);
uint32_t cpos = 0;
for(uint32_t i=0; i != track_size; i++) {
uint8_t step = img[boff+i];
cpos += step;
- if(step != 0xff && i != track_size-1)
- buf.push_back(uint64_t(cpos)*200000000/total_ticks);
+ if(step != 0xff)
+ buf.push_back(floppy_image::MG_F | uint64_t(cpos)*200000000/total_ticks);
}
} else if(idx != 0xff) {