mirror of
https://github.com/holub/mame
synced 2025-04-26 10:13:37 +03:00
Removed device_image_interface::has_been_created()
This method was necessary long ago when devices didn't have distinct load and create paths, which has since been addressed
This commit is contained in:
parent
33245e7945
commit
5f1bb05263
@ -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());
|
||||
disk_sys->load_disk(image);
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
virtual void hblank_irq(int scanline, int vblank, int blanked) 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);
|
||||
|
||||
private:
|
||||
|
@ -231,7 +231,7 @@ bool ti_pio_attached_device::call_load()
|
||||
ti_rs232_pio_device* card = static_cast<ti_rs232_pio_device*>(owner());
|
||||
|
||||
// tell whether the image is readable
|
||||
card->m_pio_readable = !has_been_created();
|
||||
card->m_pio_readable = true;
|
||||
// tell whether the image is writable
|
||||
card->m_pio_writable = !is_readonly();
|
||||
|
||||
|
@ -252,10 +252,15 @@ void cassette_image_device::device_start()
|
||||
|
||||
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()
|
||||
{
|
||||
return internal_load(false);
|
||||
}
|
||||
|
||||
bool cassette_image_device::internal_load(bool is_create)
|
||||
{
|
||||
casserr_t err;
|
||||
int cassette_flags;
|
||||
@ -264,7 +269,7 @@ bool cassette_image_device::call_load()
|
||||
device_image_interface *image = nullptr;
|
||||
interface(image);
|
||||
|
||||
if ((has_been_created()) || (length() == 0))
|
||||
if (is_create || (length() == 0))
|
||||
{
|
||||
/* creating an image */
|
||||
err = cassette_create((void *)image, &image_ioprocs, &wavfile_format, m_create_opts, CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT, &m_cassette);
|
||||
|
@ -95,6 +95,7 @@ protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete() override;
|
||||
virtual void device_start() override;
|
||||
|
||||
private:
|
||||
cassette_image *m_cassette;
|
||||
cassette_state m_state;
|
||||
@ -109,6 +110,8 @@ private:
|
||||
const struct CassetteOptions *m_create_opts;
|
||||
cassette_state m_default_state;
|
||||
const char * m_interface;
|
||||
|
||||
bool internal_load(bool is_create);
|
||||
};
|
||||
|
||||
// device type definition
|
||||
|
@ -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;
|
||||
}
|
||||
@ -417,7 +417,7 @@ void legacy_floppy_image_device::floppy_drive_set_controller(device_t *controlle
|
||||
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;
|
||||
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 */
|
||||
floppy_options = m_config->formats;
|
||||
|
||||
if (has_been_created())
|
||||
if (is_create)
|
||||
{
|
||||
/* creating an image */
|
||||
assert(create_format >= 0);
|
||||
@ -452,6 +452,10 @@ int legacy_floppy_image_device::internal_floppy_device_load(int create_format, u
|
||||
/* disk changed */
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
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()
|
||||
{
|
||||
int retVal = internal_floppy_device_load(-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);
|
||||
}
|
||||
int retVal = internal_floppy_device_load(false, -1, nullptr);
|
||||
|
||||
/* push disk halfway into drive */
|
||||
m_wpt = CLEAR_LINE;
|
||||
|
@ -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_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_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_drive_set_index_pulse_callback(void (*callback)(device_t *controller,device_t *image, int state));
|
||||
int floppy_drive_get_current_track();
|
||||
@ -162,7 +162,7 @@ private:
|
||||
TIMER_CALLBACK_MEMBER(floppy_drive_index_callback);
|
||||
void floppy_drive_init();
|
||||
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 );
|
||||
|
||||
protected:
|
||||
@ -215,7 +215,7 @@ protected:
|
||||
|
||||
floppy_image_legacy *m_floppy;
|
||||
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);
|
||||
int m_floppy_drive_type;
|
||||
|
||||
|
@ -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();
|
||||
|
||||
if (has_been_created()) {
|
||||
if (is_create) {
|
||||
clear_tape();
|
||||
save_tape();
|
||||
} else if (!load_tape()) {
|
||||
@ -1699,10 +1697,16 @@ bool hp_taco_device::call_load()
|
||||
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)
|
||||
{
|
||||
LOG(("call_create %d\n" , has_been_created()));
|
||||
return call_load();
|
||||
LOG(("call_create\n"));
|
||||
return internal_load(true);
|
||||
}
|
||||
|
||||
void hp_taco_device::call_unload()
|
||||
|
@ -182,6 +182,7 @@ private:
|
||||
void set_data_timeout(bool long_timeout);
|
||||
void cmd_fsm(void);
|
||||
void start_cmd_exec(UINT16 new_cmd_reg);
|
||||
bool internal_load(bool is_create);
|
||||
};
|
||||
|
||||
// device type definition
|
||||
|
@ -5,6 +5,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER // NPW - Stupid warning ignore to appease MSVC
|
||||
#pragma warning ( disable : 4505 )
|
||||
#endif
|
||||
|
||||
#include "keyboard.h"
|
||||
|
||||
#include <numeric>
|
||||
|
@ -1079,7 +1079,7 @@ bool device_image_interface::finish_load()
|
||||
{
|
||||
image_checkhash();
|
||||
|
||||
if (has_been_created())
|
||||
if (m_created)
|
||||
{
|
||||
err = call_create(m_create_format, m_create_args);
|
||||
if (err)
|
||||
|
@ -182,7 +182,6 @@ public:
|
||||
util::core_file &image_core_file() const { return *m_file; }
|
||||
UINT64 length() { check_for_file(); return m_file->size(); }
|
||||
bool is_readonly() const { return m_readonly; }
|
||||
bool has_been_created() const { return m_created; }
|
||||
void make_readonly() { m_readonly = true; }
|
||||
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); }
|
||||
|
@ -102,13 +102,13 @@ static const xfd_format xfd_formats[] =
|
||||
*****************************************************************************/
|
||||
|
||||
#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());
|
||||
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 size, i;
|
||||
@ -121,7 +121,7 @@ void atari_fdc_device::atari_load_proc(device_image_interface &image)
|
||||
/* tell whether the image is writable */
|
||||
m_drv[id].mode = !image.is_readonly();
|
||||
/* set up image if it has been created */
|
||||
if (image.has_been_created())
|
||||
if (is_created)
|
||||
{
|
||||
int sector;
|
||||
char buff[256];
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
DECLARE_READ8_MEMBER( serin_r );
|
||||
DECLARE_WRITE8_MEMBER( serout_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:
|
||||
// device-level overrides
|
||||
|
Loading…
Reference in New Issue
Block a user