summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2015-06-05 21:55:08 +0200
committer Olivier Galibert <galibert@pobox.com>2015-06-05 21:59:55 +0200
commita95d0e02c93f57925783c7e5d644f9bd0cf34624 (patch)
treedbf40a3da61d698cf0d019eba08df7f847208d21
parente138491f22a77837cdd8c56697947f423720c246 (diff)
floppy: Ensure that get_next_transition always provide the next transition [O. Galibert]
-rw-r--r--src/emu/imagedev/floppy.c29
-rw-r--r--src/emu/imagedev/floppy.h1
2 files changed, 21 insertions, 9 deletions
diff --git a/src/emu/imagedev/floppy.c b/src/emu/imagedev/floppy.c
index 3f704959d9f..b79cc0c71bd 100644
--- a/src/emu/imagedev/floppy.c
+++ b/src/emu/imagedev/floppy.c
@@ -661,6 +661,22 @@ UINT32 floppy_image_device::find_position(attotime &base, const attotime &when)
return (delta*floppy_ratio_1).as_ticks(1000000000/1000);
}
+attotime floppy_image_device::get_next_index_time(std::vector<UINT32> &buf, int index, int delta, attotime base)
+{
+ UINT32 next_position;
+ int cells = buf.size();
+ if(index+delta < cells)
+ next_position = buf[index+delta] & floppy_image::TIME_MASK;
+ else {
+ if((buf[cells-1]^buf[0]) & floppy_image::MG_MASK)
+ delta--;
+ index = index + delta - cells + 1;
+ next_position = 200000000 + (buf[index] & floppy_image::TIME_MASK);
+ }
+
+ return base + attotime::from_nsec((UINT64(next_position)*2000/floppy_ratio_1+1)/2);
+}
+
attotime floppy_image_device::get_next_transition(const attotime &from_when)
{
if(!image || mon)
@@ -679,15 +695,10 @@ attotime floppy_image_device::get_next_transition(const attotime &from_when)
if(index == -1)
return attotime::never;
- UINT32 next_position;
- if(index < cells-1)
- next_position = buf[index+1] & floppy_image::TIME_MASK;
- else if((buf[index]^buf[0]) & floppy_image::MG_MASK)
- next_position = 200000000;
- else
- next_position = 200000000 + (buf[1] & floppy_image::TIME_MASK);
-
- return base + attotime::from_nsec((UINT64(next_position)*2000/floppy_ratio_1+1)/2);
+ attotime result = get_next_index_time(buf, index, 1, base);
+ if(result > from_when)
+ return result;
+ return get_next_index_time(buf, index, 2, base);
}
void floppy_image_device::write_flux(const attotime &start, const attotime &end, int transition_count, const attotime *transitions)
diff --git a/src/emu/imagedev/floppy.h b/src/emu/imagedev/floppy.h
index 98834facc65..1130260cb81 100644
--- a/src/emu/imagedev/floppy.h
+++ b/src/emu/imagedev/floppy.h
@@ -186,6 +186,7 @@ protected:
int find_index(UINT32 position, const std::vector<UINT32> &buf);
void write_zone(UINT32 *buf, int &cells, int &index, UINT32 spos, UINT32 epos, UINT32 mg);
void commit_image();
+ attotime get_next_index_time(std::vector<UINT32> &buf, int index, int delta, attotime base);
};
class ui_menu_control_floppy_image : public ui_menu_control_device_image {