From 709bb88139079ebd5f12caa3b99d705a15e3bf82 Mon Sep 17 00:00:00 2001 From: Olivier Galibert Date: Thu, 11 Aug 2022 11:12:48 +0200 Subject: woz/flux: better implementation --- src/lib/formats/ap2_dsk.cpp | 18 +++++++++++------- 1 file 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 &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) { -- cgit v1.2.3