amigafdc: Modernize, but don't change a thing (yet) [O. Galibert]

This commit is contained in:
Olivier Galibert 2011-09-03 20:50:58 +00:00
parent fcd0950265
commit 2831f2f9cd
2 changed files with 34 additions and 2 deletions

View File

@ -20,7 +20,6 @@ floppy_image_device::floppy_image_device(const machine_config &mconfig, const ch
device_image_interface(mconfig, *this),
m_image(NULL)
{
}
//-------------------------------------------------
@ -81,6 +80,21 @@ void floppy_image_device::device_config_complete()
update_names();
}
void floppy_image_device::setup_load_cb(load_cb cb)
{
cur_load_cb = cb;
}
void floppy_image_device::setup_unload_cb(unload_cb cb)
{
cur_unload_cb = cb;
}
void floppy_image_device::setup_index_pulse_cb(index_pulse_cb cb)
{
cur_index_pulse_cb = cb;
}
static TIMER_CALLBACK(floppy_drive_index_callback)
{
floppy_image_device *image = (floppy_image_device *) ptr;
@ -123,10 +137,12 @@ bool floppy_image_device::call_load()
format->load(m_image);
if (m_load_func)
return m_load_func(*this);
if (!cur_load_cb.isnull())
return cur_load_cb(this);
return IMAGE_INIT_PASS;
} else {
return IMAGE_INIT_FAIL;
}
return IMAGE_INIT_PASS;
}
void floppy_image_device::call_unload()
@ -137,6 +153,8 @@ void floppy_image_device::call_unload()
global_free(m_image);
if (m_unload_func)
m_unload_func(*this);
if (!cur_unload_cb.isnull())
cur_unload_cb(this);
}
/* motor on, active low */
@ -177,6 +195,8 @@ void floppy_image_device::index_func()
}
m_out_idx_func(m_idx);
if (!cur_index_pulse_cb.isnull())
cur_index_pulse_cb(this, m_idx);
}
int floppy_image_device::ready_r()

View File

@ -32,6 +32,10 @@ class floppy_image_device : public device_t,
public device_image_interface
{
public:
typedef delegate<int (floppy_image_device *)> load_cb;
typedef delegate<void (floppy_image_device *)> unload_cb;
typedef delegate<void (floppy_image_device *, int)> index_pulse_cb;
// construction/destruction
floppy_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
virtual ~floppy_image_device();
@ -53,6 +57,10 @@ public:
virtual const char *file_extensions() const { return m_extension_list; }
virtual const option_guide *create_option_guide() const { return NULL; }
void setup_load_cb(load_cb cb);
void setup_unload_cb(unload_cb cb);
void setup_index_pulse_cb(index_pulse_cb cb);
UINT8* get_buffer() { return m_image->get_buffer(m_cyl,m_ss ^ 1); }
void mon_w(int state);
@ -100,6 +108,10 @@ protected:
int m_cyl;
devcb_resolved_write_line m_out_idx_func;
load_cb cur_load_cb;
unload_cb cur_unload_cb;
index_pulse_cb cur_index_pulse_cb;
};
// device type definition