diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2011-07-25 11:45:49 +0000 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2011-07-25 11:45:49 +0000 |
commit | 6ea1929c4b3f3b449a3e8f32e86f8288a02dd8e5 (patch) | |
tree | 50e26a0cdb91e28d61ce2299d3d429b08261f9ac | |
parent | 889c4adeb8d79660c3f972a49840a2fbb85683bf (diff) |
Some more floppy wip (no whatsnew)
-rw-r--r-- | src/emu/imagedev/floppy.c | 36 | ||||
-rw-r--r-- | src/emu/imagedev/floppy.h | 15 |
2 files changed, 44 insertions, 7 deletions
diff --git a/src/emu/imagedev/floppy.c b/src/emu/imagedev/floppy.c index 9349e525c68..78a5c090a9c 100644 --- a/src/emu/imagedev/floppy.c +++ b/src/emu/imagedev/floppy.c @@ -99,9 +99,15 @@ void floppy_image_device::device_start() /* motor off */ m_mon = 1; + /* set write protect on */ + m_wpt = 0; m_rpm = 300.0f; + m_cyl = 0; + m_ss = 1; + m_stp = 1; + m_dskchg = 0; m_index_timer = machine().scheduler().timer_alloc(FUNC(floppy_drive_index_callback), (void *)this); } @@ -111,6 +117,7 @@ bool floppy_image_device::call_load() int best; m_image = global_alloc(floppy_image((void *) image, &image_ioprocs, m_formats)); const struct floppy_format_def *format = m_image->identify(&best); + m_dskchg = 0; if (format) { m_image->load(best); if (m_load_func) @@ -123,6 +130,8 @@ bool floppy_image_device::call_load() void floppy_image_device::call_unload() { + m_dskchg = 0; + if (m_image) global_free(m_image); if (m_unload_func) @@ -167,9 +176,6 @@ void floppy_image_device::index_func() } m_out_idx_func(m_idx); - - //if (drive->index_pulse_callback) -// drive->index_pulse_callback(drive->controller, img, drive->idx); } int floppy_image_device::ready_r() @@ -178,13 +184,33 @@ int floppy_image_device::ready_r() { if (m_mon == 0) { - return 1; + return 0; } } - return 0; + return 1; } double floppy_image_device::get_pos() { return m_index_timer->elapsed().as_double(); +} + +void floppy_image_device::stp_w(int state) +{ + if ( m_stp != state ) { + m_stp = state; + if ( m_stp == 0 ) { + if ( m_dir ) { + if ( m_cyl ) m_cyl--; + } else { + if ( m_cyl < 83 ) m_cyl++; + } + /* Update disk detection if applicable */ + if (exists()) + { + if (m_dskchg==0) m_dskchg = 1; + } + } + } + }
\ No newline at end of file diff --git a/src/emu/imagedev/floppy.h b/src/emu/imagedev/floppy.h index 70950181150..5ac4f0de9a7 100644 --- a/src/emu/imagedev/floppy.h +++ b/src/emu/imagedev/floppy.h @@ -53,12 +53,21 @@ public: virtual const char *file_extensions() const { return m_extension_list; } virtual const option_guide *create_option_guide() const { return NULL; } - UINT8* get_buffer(UINT16 track, UINT8 side) { return m_image->get_buffer(track,side); } + UINT8* get_buffer() { return m_image->get_buffer(m_cyl,m_ss ^ 1); } void mon_w(int state); void index_func(); int ready_r(); double get_pos(); + + int wpt_r() { return m_wpt; } + int dskchg_r() { return m_dskchg; } + int trk00_r() { return (m_cyl==0) ? 0 : 1; } + + void stp_w(int state); + void dir_w(int state) { m_dir = state; } + void ss_w(int state) { m_ss = state; } + protected: // device-level overrides virtual void device_config_complete(); @@ -72,10 +81,11 @@ protected: emu_timer *m_index_timer; /* state of input lines */ - int m_drtn; /* direction */ + int m_dir; /* direction */ int m_stp; /* step */ int m_wtg; /* write gate */ int m_mon; /* motor on */ + int m_ss; /* side select */ /* state of output lines */ int m_idx; /* index pulse */ @@ -87,6 +97,7 @@ protected: /* rotation per minute => gives index pulse frequency */ float m_rpm; + int m_cyl; devcb_resolved_write_line m_out_idx_func; }; |