Merge pull request #1163 from npwoods/remove_public_has_been_created

Removed device_image_interface::has_been_created()
This commit is contained in:
Vas Crabb 2016-07-31 22:24:23 +10:00 committed by GitHub
commit 69ac4affc8
13 changed files with 42 additions and 31 deletions

View File

@ -81,7 +81,7 @@ const rom_entry *nes_disksys_device::device_rom_region() const
} }
void nes_disksys_device::load_proc(device_image_interface &image) void nes_disksys_device::load_proc(device_image_interface &image, bool is_created)
{ {
nes_disksys_device *disk_sys = static_cast<nes_disksys_device *>(image.device().owner()); nes_disksys_device *disk_sys = static_cast<nes_disksys_device *>(image.device().owner());
disk_sys->load_disk(image); disk_sys->load_disk(image);

View File

@ -33,7 +33,7 @@ public:
virtual void hblank_irq(int scanline, int vblank, int blanked) override; virtual void hblank_irq(int scanline, int vblank, int blanked) override;
virtual void pcb_reset() override; virtual void pcb_reset() override;
static void load_proc(device_image_interface &image); static void load_proc(device_image_interface &image, bool is_created);
static void unload_proc(device_image_interface &image); static void unload_proc(device_image_interface &image);
private: private:

View File

@ -231,7 +231,7 @@ bool ti_pio_attached_device::call_load()
ti_rs232_pio_device* card = static_cast<ti_rs232_pio_device*>(owner()); ti_rs232_pio_device* card = static_cast<ti_rs232_pio_device*>(owner());
// tell whether the image is readable // tell whether the image is readable
card->m_pio_readable = !has_been_created(); card->m_pio_readable = true;
// tell whether the image is writable // tell whether the image is writable
card->m_pio_writable = !is_readonly(); card->m_pio_writable = !is_readonly();

View File

@ -252,10 +252,15 @@ void cassette_image_device::device_start()
bool cassette_image_device::call_create(int format_type, util::option_resolution *format_options) bool cassette_image_device::call_create(int format_type, util::option_resolution *format_options)
{ {
return call_load(); return internal_load(true);
} }
bool cassette_image_device::call_load() bool cassette_image_device::call_load()
{
return internal_load(false);
}
bool cassette_image_device::internal_load(bool is_create)
{ {
casserr_t err; casserr_t err;
int cassette_flags; int cassette_flags;
@ -264,7 +269,7 @@ bool cassette_image_device::call_load()
device_image_interface *image = nullptr; device_image_interface *image = nullptr;
interface(image); interface(image);
if ((has_been_created()) || (length() == 0)) if (is_create || (length() == 0))
{ {
/* creating an image */ /* creating an image */
err = cassette_create((void *)image, &image_ioprocs, &wavfile_format, m_create_opts, CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT, &m_cassette); err = cassette_create((void *)image, &image_ioprocs, &wavfile_format, m_create_opts, CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT, &m_cassette);

View File

@ -95,6 +95,7 @@ protected:
// device-level overrides // device-level overrides
virtual void device_config_complete() override; virtual void device_config_complete() override;
virtual void device_start() override; virtual void device_start() override;
private: private:
cassette_image *m_cassette; cassette_image *m_cassette;
cassette_state m_state; cassette_state m_state;
@ -109,6 +110,8 @@ private:
const struct CassetteOptions *m_create_opts; const struct CassetteOptions *m_create_opts;
cassette_state m_default_state; cassette_state m_default_state;
const char * m_interface; const char * m_interface;
bool internal_load(bool is_create);
}; };
// device type definition // device type definition

View File

@ -375,7 +375,7 @@ void legacy_floppy_image_device::floppy_drive_write_sector_data(int side, int in
} }
} }
void legacy_floppy_image_device::floppy_install_load_proc(void (*proc)(device_image_interface &image)) void legacy_floppy_image_device::floppy_install_load_proc(void (*proc)(device_image_interface &image, bool is_created))
{ {
m_load_proc = proc; m_load_proc = proc;
} }
@ -417,7 +417,7 @@ void legacy_floppy_image_device::floppy_drive_set_controller(device_t *controlle
m_controller = controller; m_controller = controller;
} }
int legacy_floppy_image_device::internal_floppy_device_load(int create_format, util::option_resolution *create_args) int legacy_floppy_image_device::internal_floppy_device_load(bool is_create, int create_format, util::option_resolution *create_args)
{ {
floperr_t err; floperr_t err;
const struct FloppyFormat *floppy_options; const struct FloppyFormat *floppy_options;
@ -428,7 +428,7 @@ int legacy_floppy_image_device::internal_floppy_device_load(int create_format, u
interface(image); /* figure out the floppy options */ interface(image); /* figure out the floppy options */
floppy_options = m_config->formats; floppy_options = m_config->formats;
if (has_been_created()) if (is_create)
{ {
/* creating an image */ /* creating an image */
assert(create_format >= 0); assert(create_format >= 0);
@ -452,6 +452,10 @@ int legacy_floppy_image_device::internal_floppy_device_load(int create_format, u
/* disk changed */ /* disk changed */
m_dskchg = CLEAR_LINE; m_dskchg = CLEAR_LINE;
// If we have one of our hacky load procs, call it
if (m_load_proc)
m_load_proc(*this, is_create);
return IMAGE_INIT_PASS; return IMAGE_INIT_PASS;
error: error:
@ -832,17 +836,12 @@ void legacy_floppy_image_device::device_config_complete()
bool legacy_floppy_image_device::call_create(int format_type, util::option_resolution *format_options) bool legacy_floppy_image_device::call_create(int format_type, util::option_resolution *format_options)
{ {
return internal_floppy_device_load(format_type, format_options); return internal_floppy_device_load(true, format_type, format_options);
} }
bool legacy_floppy_image_device::call_load() bool legacy_floppy_image_device::call_load()
{ {
int retVal = internal_floppy_device_load(-1, nullptr); int retVal = internal_floppy_device_load(false, -1, nullptr);
if (retVal==IMAGE_INIT_PASS) {
/* if we have one of our hacky unload procs, call it */
if (m_load_proc)
m_load_proc(*this);
}
/* push disk halfway into drive */ /* push disk halfway into drive */
m_wpt = CLEAR_LINE; m_wpt = CLEAR_LINE;

View File

@ -127,7 +127,7 @@ public:
void floppy_drive_format_sector(int side, int sector_index,int c,int h, int r, int n, int filler); void floppy_drive_format_sector(int side, int sector_index,int c,int h, int r, int n, int filler);
void floppy_drive_read_sector_data(int side, int index1, void *ptr, int length); void floppy_drive_read_sector_data(int side, int index1, void *ptr, int length);
void floppy_drive_write_sector_data(int side, int index1, const void *ptr,int length, int ddam); void floppy_drive_write_sector_data(int side, int index1, const void *ptr,int length, int ddam);
void floppy_install_load_proc(void (*proc)(device_image_interface &image)); void floppy_install_load_proc(void (*proc)(device_image_interface &image, bool is_created));
void floppy_install_unload_proc(void (*proc)(device_image_interface &image)); void floppy_install_unload_proc(void (*proc)(device_image_interface &image));
void floppy_drive_set_index_pulse_callback(void (*callback)(device_t *controller,device_t *image, int state)); void floppy_drive_set_index_pulse_callback(void (*callback)(device_t *controller,device_t *image, int state));
int floppy_drive_get_current_track(); int floppy_drive_get_current_track();
@ -162,7 +162,7 @@ private:
TIMER_CALLBACK_MEMBER(floppy_drive_index_callback); TIMER_CALLBACK_MEMBER(floppy_drive_index_callback);
void floppy_drive_init(); void floppy_drive_init();
void floppy_drive_index_func(); void floppy_drive_index_func();
int internal_floppy_device_load(int create_format, util::option_resolution *create_args); int internal_floppy_device_load(bool is_create, int create_format, util::option_resolution *create_args);
TIMER_CALLBACK_MEMBER( set_wpt ); TIMER_CALLBACK_MEMBER( set_wpt );
protected: protected:
@ -215,7 +215,7 @@ protected:
floppy_image_legacy *m_floppy; floppy_image_legacy *m_floppy;
int m_track; int m_track;
void (*m_load_proc)(device_image_interface &image); void (*m_load_proc)(device_image_interface &image, bool is_created);
void (*m_unload_proc)(device_image_interface &image); void (*m_unload_proc)(device_image_interface &image);
int m_floppy_drive_type; int m_floppy_drive_type;

View File

@ -1678,13 +1678,11 @@ void hp_taco_device::start_cmd_exec(UINT16 new_cmd_reg)
} }
} }
bool hp_taco_device::call_load() bool hp_taco_device::internal_load(bool is_create)
{ {
LOG(("call_load %d\n" , has_been_created()));
device_reset(); device_reset();
if (has_been_created()) { if (is_create) {
clear_tape(); clear_tape();
save_tape(); save_tape();
} else if (!load_tape()) { } else if (!load_tape()) {
@ -1699,10 +1697,16 @@ bool hp_taco_device::call_load()
return IMAGE_INIT_PASS; return IMAGE_INIT_PASS;
} }
bool hp_taco_device::call_load()
{
LOG(("call_load\n"));
return internal_load(false);
}
bool hp_taco_device::call_create(int format_type, util::option_resolution *format_options) bool hp_taco_device::call_create(int format_type, util::option_resolution *format_options)
{ {
LOG(("call_create %d\n" , has_been_created())); LOG(("call_create\n"));
return call_load(); return internal_load(true);
} }
void hp_taco_device::call_unload() void hp_taco_device::call_unload()

View File

@ -182,6 +182,7 @@ private:
void set_data_timeout(bool long_timeout); void set_data_timeout(bool long_timeout);
void cmd_fsm(void); void cmd_fsm(void);
void start_cmd_exec(UINT16 new_cmd_reg); void start_cmd_exec(UINT16 new_cmd_reg);
bool internal_load(bool is_create);
}; };
// device type definition // device type definition

View File

@ -1079,7 +1079,7 @@ bool device_image_interface::finish_load()
{ {
image_checkhash(); image_checkhash();
if (has_been_created()) if (m_created)
{ {
err = call_create(m_create_format, m_create_args); err = call_create(m_create_format, m_create_args);
if (err) if (err)

View File

@ -182,7 +182,6 @@ public:
util::core_file &image_core_file() const { return *m_file; } util::core_file &image_core_file() const { return *m_file; }
UINT64 length() { check_for_file(); return m_file->size(); } UINT64 length() { check_for_file(); return m_file->size(); }
bool is_readonly() const { return m_readonly; } bool is_readonly() const { return m_readonly; }
bool has_been_created() const { return m_created; }
void make_readonly() { m_readonly = true; } void make_readonly() { m_readonly = true; }
UINT32 fread(void *buffer, UINT32 length) { check_for_file(); return m_file->read(buffer, length); } UINT32 fread(void *buffer, UINT32 length) { check_for_file(); return m_file->read(buffer, length); }
UINT32 fread(optional_shared_ptr<UINT8> &ptr, UINT32 length) { ptr.allocate(length); return fread(ptr.target(), length); } UINT32 fread(optional_shared_ptr<UINT8> &ptr, UINT32 length) { ptr.allocate(length); return fread(ptr.target(), length); }

View File

@ -102,13 +102,13 @@ static const xfd_format xfd_formats[] =
*****************************************************************************/ *****************************************************************************/
#define MAXSIZE 5760 * 256 + 80 #define MAXSIZE 5760 * 256 + 80
static void _atari_load_proc(device_image_interface &image) static void _atari_load_proc(device_image_interface &image, bool is_created)
{ {
atari_fdc_device *atarifdc = static_cast<atari_fdc_device *>(image.device().owner()); atari_fdc_device *atarifdc = static_cast<atari_fdc_device *>(image.device().owner());
atarifdc->atari_load_proc(image); atarifdc->atari_load_proc(image, is_created);
} }
void atari_fdc_device::atari_load_proc(device_image_interface &image) void atari_fdc_device::atari_load_proc(device_image_interface &image, bool is_created)
{ {
int id = floppy_get_drive(image); int id = floppy_get_drive(image);
int size, i; int size, i;
@ -121,7 +121,7 @@ void atari_fdc_device::atari_load_proc(device_image_interface &image)
/* tell whether the image is writable */ /* tell whether the image is writable */
m_drv[id].mode = !image.is_readonly(); m_drv[id].mode = !image.is_readonly();
/* set up image if it has been created */ /* set up image if it has been created */
if (image.has_been_created()) if (is_created)
{ {
int sector; int sector;
char buff[256]; char buff[256];

View File

@ -18,7 +18,7 @@ public:
DECLARE_READ8_MEMBER( serin_r ); DECLARE_READ8_MEMBER( serin_r );
DECLARE_WRITE8_MEMBER( serout_w ); DECLARE_WRITE8_MEMBER( serout_w );
DECLARE_WRITE_LINE_MEMBER( pia_cb2_w ); DECLARE_WRITE_LINE_MEMBER( pia_cb2_w );
void atari_load_proc(device_image_interface &image); void atari_load_proc(device_image_interface &image, bool is_created);
protected: protected:
// device-level overrides // device-level overrides