diff options
author | fulivi <fulivi@users.noreply.github.com> | 2017-05-21 19:24:11 +0200 |
---|---|---|
committer | Olivier Galibert <galibert@pobox.com> | 2017-05-21 19:24:11 +0200 |
commit | a662d26e2957acdcd506f641cd0983e99bfc576f (patch) | |
tree | 9e9f20f85323a1ba8140209b901f7b9169cedabe /src/devices/imagedev | |
parent | a43cc7edeb6aa0ec2d6388ab6fc50d009ed12559 (diff) |
floppy: Fix for a segfault when emulating HP9895 drive [F.Ulivi]
Diffstat (limited to 'src/devices/imagedev')
-rw-r--r-- | src/devices/imagedev/floppy.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index cacd4b6bda5..313ecc6ceb5 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -737,7 +737,14 @@ uint32_t floppy_image_device::find_position(attotime &base, const attotime &when base -= rev_time; } - return (delta*floppy_ratio_1).as_ticks(1000000000/1000); + uint32_t res = (delta*floppy_ratio_1).as_ticks(1000000000/1000); + if (res > 200000000) { + // Due to rounding errors in the previous operation, + // 'res' sometimes overflows 2E+8 + res -= 200000000; + base += rev_time; + } + return res; } attotime floppy_image_device::get_next_index_time(std::vector<uint32_t> &buf, int index, int delta, attotime base) |