mirror of
https://github.com/holub/mame
synced 2025-05-30 09:33:05 +03:00
Getting rid of token usage in devices (nw)
This commit is contained in:
parent
b1c2c8daee
commit
c33fe095b1
@ -28,10 +28,6 @@ static int verbose = VERBOSE;
|
||||
#define LOG2(x) { if (verbose > 1) LOG(x)}
|
||||
#define LOG3(x) { if (verbose > 2) LOG(x)}
|
||||
|
||||
#define DLOG(x) { logerror ("%s: ", cpu_context(disk->device)); logerror x; logerror ("\n"); }
|
||||
#define DLOG1(x) { if (verbose > 0) DLOG(x)}
|
||||
#define DLOG2(x) { if (verbose > 1) DLOG(x)}
|
||||
|
||||
#define OMTI_DISK_SECTOR_SIZE 1056
|
||||
|
||||
#define OMTI_DISK_TYPE_155_MB 0x607 // Micropolis 1355 (170 MB Dtype = 607)
|
||||
@ -51,37 +47,6 @@ static int verbose = VERBOSE;
|
||||
// forward declaration of image class
|
||||
extern const device_type OMTI_DISK;
|
||||
|
||||
class omti_disk_image_device : public device_t,
|
||||
public device_image_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
omti_disk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
// image-level overrides
|
||||
virtual iodevice_t image_type() const { return IO_HARDDISK; }
|
||||
|
||||
virtual bool is_readable() const { return 1; }
|
||||
virtual bool is_writeable() const { return 1; }
|
||||
virtual bool is_creatable() const { return 1; }
|
||||
virtual bool must_be_loaded() const { return 0; }
|
||||
virtual bool is_reset_on_load() const { return 0; }
|
||||
virtual const char *image_interface() const { return NULL; }
|
||||
virtual const char *file_extensions() const { return "awd"; }
|
||||
virtual const option_guide *create_option_guide() const { return NULL; }
|
||||
|
||||
virtual bool call_create(int format_type, option_resolution *format_options);
|
||||
|
||||
disk_data *token() { return &m_token; }
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
disk_data m_token;
|
||||
};
|
||||
|
||||
/*
|
||||
* I/O register offsets
|
||||
*/
|
||||
@ -279,12 +244,9 @@ void omti8621_device::device_start()
|
||||
sector_buffer.resize(OMTI_DISK_SECTOR_SIZE*OMTI_MAX_BLOCK_COUNT);
|
||||
|
||||
m_timer = timer_alloc(0, NULL);
|
||||
|
||||
device_t *device0 = subdevice(OMTI_DISK0_TAG);
|
||||
our_disks[0] = (disk_data *) downcast<omti_disk_image_device *>(device0)->token();
|
||||
|
||||
device_t *device1 = subdevice(OMTI_DISK1_TAG);
|
||||
our_disks[1] = (disk_data *) downcast<omti_disk_image_device *>(device1)->token();
|
||||
|
||||
our_disks[0] = subdevice<omti_disk_image_device>(OMTI_DISK0_TAG);
|
||||
our_disks[1] = subdevice<omti_disk_image_device>(OMTI_DISK1_TAG);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -320,7 +282,7 @@ void omti8621_device::device_reset()
|
||||
m_installed = true;
|
||||
}
|
||||
|
||||
set_jumper(our_disks[0]->type);
|
||||
set_jumper(our_disks[0]->m_type);
|
||||
|
||||
// should go from reset to idle after 100 us
|
||||
// state->omti_state = OMTI_STATE_RESET;
|
||||
@ -422,18 +384,18 @@ void omti8621_device::set_configuration_data(UINT8 lun) {
|
||||
LOG2(("set_configuration_data lun=%x", lun));
|
||||
|
||||
// initialize the configuration data
|
||||
disk_data *disk = our_disks[lun];
|
||||
omti_disk_image_device *disk = our_disks[lun];
|
||||
|
||||
disk->config_data[0] = (disk->cylinders - 1) >> 8; // Number of Cylinders (MSB)
|
||||
disk->config_data[1] = (disk->cylinders - 1) & 0xff; // Number of Cylinders (LSB) (-1)
|
||||
disk->config_data[2] = disk->heads - 1; // Number of Heads (-1)
|
||||
disk->config_data[3] = disk->sectors - 1; // Number of Sectors (-1)
|
||||
disk->config_data[4] = 0x02; // Drive Configuration Word (MSB)
|
||||
disk->config_data[5] = 0x44; // Drive Configuration Word (LSB)
|
||||
disk->config_data[6] = 0x00; // ISG AFTER INDEX
|
||||
disk->config_data[7] = 0x00; // PLO SYN Field (ID)
|
||||
disk->config_data[8] = 0x00; // PLO SYN Field (DATA)
|
||||
disk->config_data[9] = 0x00; // ISG AFTER SECTOR
|
||||
disk->m_config_data[0] = (disk->m_cylinders - 1) >> 8; // Number of Cylinders (MSB)
|
||||
disk->m_config_data[1] = (disk->m_cylinders - 1) & 0xff; // Number of Cylinders (LSB) (-1)
|
||||
disk->m_config_data[2] = disk->m_heads - 1; // Number of Heads (-1)
|
||||
disk->m_config_data[3] = disk->m_sectors - 1; // Number of Sectors (-1)
|
||||
disk->m_config_data[4] = 0x02; // Drive Configuration Word (MSB)
|
||||
disk->m_config_data[5] = 0x44; // Drive Configuration Word (LSB)
|
||||
disk->m_config_data[6] = 0x00; // ISG AFTER INDEX
|
||||
disk->m_config_data[7] = 0x00; // PLO SYN Field (ID)
|
||||
disk->m_config_data[8] = 0x00; // PLO SYN Field (DATA)
|
||||
disk->m_config_data[9] = 0x00; // ISG AFTER SECTOR
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
@ -457,10 +419,10 @@ UINT8 omti8621_device::check_disk_address(const UINT8 *cdb)
|
||||
UINT16 sector = cdb[2] & 0x3f;
|
||||
UINT32 cylinder = cdb[3] + ((cdb[2] & 0xc0) << 2) + ((cdb[1] & 0x80) << 3);
|
||||
UINT8 block_count = cdb[4];
|
||||
disk_data *disk = our_disks[lun];
|
||||
omti_disk_image_device *disk = our_disks[lun];
|
||||
|
||||
UINT32 disk_track = cylinder * disk->heads + head;
|
||||
UINT32 disk_addr = (disk_track * disk->sectors) + sector;
|
||||
UINT32 disk_track = cylinder * disk->m_heads + head;
|
||||
UINT32 disk_addr = (disk_track * disk->m_sectors) + sector;
|
||||
|
||||
if (block_count > OMTI_MAX_BLOCK_COUNT) {
|
||||
LOG(("########### check_disk_address: unexpected block count %x", block_count));
|
||||
@ -469,13 +431,13 @@ UINT8 omti8621_device::check_disk_address(const UINT8 *cdb)
|
||||
|
||||
if (lun > OMTI_MAX_LUN) {
|
||||
sense_code = OMTI_SENSE_CODE_DRIVE_NOT_READY;
|
||||
} else if (!disk->image->exists()) {
|
||||
} else if (!disk->m_image->exists()) {
|
||||
sense_code = OMTI_SENSE_CODE_DRIVE_NOT_READY;
|
||||
} else if (sector >= OMTI_MAX_BLOCK_COUNT) {
|
||||
sense_code = OMTI_SENSE_CODE_ILLEGAL_ADDRESS | OMTI_SENSE_CODE_ADDRESS_VALID;
|
||||
} else if (head >= disk->heads) {
|
||||
} else if (head >= disk->m_heads) {
|
||||
sense_code = OMTI_SENSE_CODE_ILLEGAL_ADDRESS | OMTI_SENSE_CODE_ADDRESS_VALID;
|
||||
} else if (cylinder >= disk->cylinders) {
|
||||
} else if (cylinder >= disk->m_cylinders) {
|
||||
sense_code = OMTI_SENSE_CODE_ILLEGAL_ADDRESS | OMTI_SENSE_CODE_ADDRESS_VALID;
|
||||
} else if ( disk_track == diskaddr_format_bad_track && disk_track != 0) {
|
||||
sense_code = OMTI_SENSE_CODE_BAD_TRACK;
|
||||
@ -502,7 +464,7 @@ UINT32 omti8621_device::get_disk_track(const UINT8 * cdb) {
|
||||
UINT8 lun = get_lun(cdb);
|
||||
UINT16 head = cdb[1] & 0x1f;
|
||||
UINT32 cylinder = cdb[3] + ((cdb[2] & 0xc0) << 2) + ((cdb[1] & 0x80) << 3);
|
||||
return cylinder * our_disks[lun]->heads + head;
|
||||
return cylinder * our_disks[lun]->m_heads + head;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
@ -512,7 +474,7 @@ UINT32 omti8621_device::get_disk_track(const UINT8 * cdb) {
|
||||
UINT32 omti8621_device::get_disk_address(const UINT8 * cdb) {
|
||||
UINT8 lun = get_lun(cdb);
|
||||
UINT16 sector = cdb[2] & 0x3f;
|
||||
return get_disk_track(cdb) * our_disks[lun]->sectors + sector;
|
||||
return get_disk_track(cdb) * our_disks[lun]->m_sectors + sector;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
@ -538,7 +500,7 @@ void omti8621_device::set_data_transfer(UINT8 *data, UINT16 length)
|
||||
void omti8621_device::read_sectors_from_disk(INT32 diskaddr, UINT8 count, UINT8 lun)
|
||||
{
|
||||
UINT8 *data_buffer = sector_buffer;
|
||||
device_image_interface *image = our_disks[lun]->image;
|
||||
device_image_interface *image = our_disks[lun]->m_image;
|
||||
|
||||
while (count-- > 0) {
|
||||
LOG2(("read_sectors_from_disk lun=%d diskaddr=%x", lun, diskaddr));
|
||||
@ -558,7 +520,7 @@ void omti8621_device::read_sectors_from_disk(INT32 diskaddr, UINT8 count, UINT8
|
||||
void omti8621_device::write_sectors_to_disk(INT32 diskaddr, UINT8 count, UINT8 lun)
|
||||
{
|
||||
UINT8 *data_buffer = sector_buffer;
|
||||
device_image_interface *image = our_disks[lun]->image;
|
||||
device_image_interface *image = our_disks[lun]->m_image;
|
||||
|
||||
while (count-- > 0) {
|
||||
LOG2(("write_sectors_to_disk lun=%d diskaddr=%x", lun, diskaddr));
|
||||
@ -582,7 +544,7 @@ void omti8621_device::write_sectors_to_disk(INT32 diskaddr, UINT8 count, UINT8 l
|
||||
|
||||
void omti8621_device::copy_sectors(INT32 dst_addr, INT32 src_addr, UINT8 count, UINT8 lun)
|
||||
{
|
||||
device_image_interface *image = our_disks[lun]->image;
|
||||
device_image_interface *image = our_disks[lun]->m_image;
|
||||
|
||||
LOG2(("copy_sectors lun=%d src_addr=%x dst_addr=%x count=%x", lun, src_addr, dst_addr, count));
|
||||
|
||||
@ -635,9 +597,9 @@ void omti8621_device::format_track(const UINT8 * cdb)
|
||||
|
||||
if (check_disk_address(cdb) ) {
|
||||
if ((cdb[5] & 0x40) == 0) {
|
||||
memset(sector_buffer, 0x6C, OMTI_DISK_SECTOR_SIZE * our_disks[lun]->sectors);
|
||||
memset(sector_buffer, 0x6C, OMTI_DISK_SECTOR_SIZE * our_disks[lun]->m_sectors);
|
||||
}
|
||||
write_sectors_to_disk(disk_addr, our_disks[lun]->sectors, lun);
|
||||
write_sectors_to_disk(disk_addr, our_disks[lun]->m_sectors, lun);
|
||||
}
|
||||
|
||||
}
|
||||
@ -648,14 +610,14 @@ void omti8621_device::format_track(const UINT8 * cdb)
|
||||
|
||||
void omti8621_device::set_esdi_defect_list(UINT8 lun, UINT8 head)
|
||||
{
|
||||
disk_data *disk = our_disks[lun];
|
||||
omti_disk_image_device *disk = our_disks[lun];
|
||||
|
||||
memset(disk->esdi_defect_list, 0, sizeof(disk->esdi_defect_list));
|
||||
disk->esdi_defect_list[0] = 1; // month
|
||||
disk->esdi_defect_list[1] = 1; // day
|
||||
disk->esdi_defect_list[2] = 90; // year
|
||||
disk->esdi_defect_list[3] = head;
|
||||
memset(disk->esdi_defect_list+6, 0xff, 5); // end of defect list
|
||||
memset(disk->m_esdi_defect_list, 0, sizeof(disk->m_esdi_defect_list));
|
||||
disk->m_esdi_defect_list[0] = 1; // month
|
||||
disk->m_esdi_defect_list[1] = 1; // day
|
||||
disk->m_esdi_defect_list[2] = 90; // year
|
||||
disk->m_esdi_defect_list[3] = head;
|
||||
memset(disk->m_esdi_defect_list+6, 0xff, 5); // end of defect list
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
@ -785,7 +747,7 @@ void omti8621_device::log_data()
|
||||
void omti8621_device::do_command(const UINT8 cdb[], const UINT16 cdb_length)
|
||||
{
|
||||
UINT8 lun = get_lun(cdb);
|
||||
disk_data *disk = our_disks[lun];
|
||||
omti_disk_image_device *disk = our_disks[lun];
|
||||
int command_duration = 0; // ms
|
||||
|
||||
log_command( cdb, cdb_length);
|
||||
@ -799,13 +761,13 @@ void omti8621_device::do_command(const UINT8 cdb[], const UINT16 cdb_length)
|
||||
set_interrupt(CLEAR_LINE);
|
||||
}
|
||||
|
||||
if (!disk->image->exists()) {
|
||||
if (!disk->m_image->exists()) {
|
||||
command_status |= OMTI_COMMAND_STATUS_ERROR; // no such drive
|
||||
}
|
||||
|
||||
switch (cdb[0]) {
|
||||
case OMTI_CMD_TEST_DRIVE_READY: // 0x00
|
||||
if (!disk->image->exists())
|
||||
if (!disk->m_image->exists())
|
||||
{
|
||||
set_sense_data(OMTI_SENSE_CODE_DRIVE_NOT_READY, cdb);
|
||||
}
|
||||
@ -866,7 +828,7 @@ void omti8621_device::do_command(const UINT8 cdb[], const UINT16 cdb_length)
|
||||
|
||||
case OMTI_CMD_READ_ESDI_DEFECT_LIST: // 0x37
|
||||
set_esdi_defect_list(get_lun(cdb), cdb[1] & 0x1f);
|
||||
set_data_transfer(disk->esdi_defect_list, sizeof(disk->esdi_defect_list));
|
||||
set_data_transfer(disk->m_esdi_defect_list, sizeof(disk->m_esdi_defect_list));
|
||||
break;
|
||||
|
||||
case OMTI_CMD_ASSIGN_ALTERNATE_TRACK: // 0x11
|
||||
@ -917,7 +879,7 @@ void omti8621_device::do_command(const UINT8 cdb[], const UINT16 cdb_length)
|
||||
|
||||
case OMTI_CMD_READ_CONFIGURATION: // 0xEC
|
||||
set_configuration_data(get_lun(cdb));
|
||||
set_data_transfer(disk->config_data, sizeof(disk->config_data));
|
||||
set_data_transfer(disk->m_config_data, sizeof(disk->m_config_data));
|
||||
break;
|
||||
|
||||
case OMTI_CMD_INVALID_COMMAND: // 0xFF
|
||||
@ -1196,9 +1158,9 @@ void omti8621_device::set_verbose(int on_off)
|
||||
|
||||
UINT32 omti8621_device::get_sector(INT32 diskaddr, UINT8 *data_buffer, UINT32 length, UINT8 lun)
|
||||
{
|
||||
disk_data *disk = our_disks[lun];
|
||||
omti_disk_image_device *disk = our_disks[lun];
|
||||
|
||||
if (disk->image == NULL || !disk->image->exists())
|
||||
if (disk->m_image == NULL || !disk->m_image->exists())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -1209,8 +1171,8 @@ UINT32 omti8621_device::get_sector(INT32 diskaddr, UINT8 *data_buffer, UINT32 le
|
||||
// restrict length to size of 1 sector (i.e. 1024 Byte)
|
||||
length = length < OMTI_DISK_SECTOR_SIZE ? length : OMTI_DISK_SECTOR_SIZE;
|
||||
|
||||
disk->image->fseek(diskaddr * OMTI_DISK_SECTOR_SIZE, SEEK_SET);
|
||||
disk->image->fread(data_buffer, length);
|
||||
disk->m_image->fseek(diskaddr * OMTI_DISK_SECTOR_SIZE, SEEK_SET);
|
||||
disk->m_image->fread(data_buffer, length);
|
||||
|
||||
return length;
|
||||
}
|
||||
@ -1281,43 +1243,33 @@ void omti_disk_image_device::device_config_complete()
|
||||
};
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
get_safe_disk_token - makes sure that the passed in device is a OMTI disk
|
||||
***************************************************************************/
|
||||
|
||||
INLINE disk_data *get_safe_disk_token(device_t *device) {
|
||||
assert(device != NULL);
|
||||
assert(device->type() == OMTI_DISK);
|
||||
return (disk_data *) downcast<omti_disk_image_device *>(device)->token();
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
omti_disk_config - configure disk parameters
|
||||
***************************************************************************/
|
||||
|
||||
static void omti_disk_config(disk_data *disk, UINT16 disk_type)
|
||||
void omti_disk_image_device::omti_disk_config(UINT16 disk_type)
|
||||
{
|
||||
DLOG1(("omti_disk_config: configuring disk with type %x", disk_type));
|
||||
LOG1(("omti_disk_config: configuring disk with type %x", disk_type));
|
||||
|
||||
switch (disk_type)
|
||||
{
|
||||
case OMTI_DISK_TYPE_348_MB: // Maxtor 380 MB (348-MB FA formatted)
|
||||
disk->cylinders = 1223;
|
||||
disk->heads = 15;
|
||||
disk->sectors = 18;
|
||||
m_cylinders = 1223;
|
||||
m_heads = 15;
|
||||
m_sectors = 18;
|
||||
break;
|
||||
|
||||
case OMTI_DISK_TYPE_155_MB: // Micropolis 170 MB (155-MB formatted)
|
||||
default:
|
||||
disk->cylinders = 1023;
|
||||
disk->heads = 8;
|
||||
disk->sectors = 18;
|
||||
m_cylinders = 1023;
|
||||
m_heads = 8;
|
||||
m_sectors = 18;
|
||||
break;
|
||||
}
|
||||
|
||||
disk->type = disk_type;
|
||||
disk->sectorbytes = OMTI_DISK_SECTOR_SIZE;
|
||||
disk->sector_count = disk->cylinders * disk->heads * disk->sectors;
|
||||
m_type = disk_type;
|
||||
m_sectorbytes = OMTI_DISK_SECTOR_SIZE;
|
||||
m_sector_count = m_cylinders * m_heads * m_sectors;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -1326,24 +1278,19 @@ static void omti_disk_config(disk_data *disk, UINT16 disk_type)
|
||||
|
||||
void omti_disk_image_device::device_start()
|
||||
{
|
||||
disk_data *disk = get_safe_disk_token(this);
|
||||
m_image = this;
|
||||
|
||||
disk->device = this;
|
||||
// note: we must have disk->device before we can log
|
||||
|
||||
disk->image = this;
|
||||
|
||||
if (disk->image->image_core_file() == NULL)
|
||||
if (m_image->image_core_file() == NULL)
|
||||
{
|
||||
DLOG1(("device_start_omti_disk: no disk"));
|
||||
LOG1(("device_start_omti_disk: no disk"));
|
||||
}
|
||||
else
|
||||
{
|
||||
DLOG1(("device_start_omti_disk: with disk image %s",disk->image->basename() ));
|
||||
LOG1(("device_start_omti_disk: with disk image %s",m_image->basename() ));
|
||||
}
|
||||
|
||||
// default disk type
|
||||
omti_disk_config(disk, OMTI_DISK_TYPE_DEFAULT);
|
||||
omti_disk_config(OMTI_DISK_TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -1351,17 +1298,16 @@ void omti_disk_image_device::device_start()
|
||||
-------------------------------------------------*/
|
||||
|
||||
void omti_disk_image_device::device_reset()
|
||||
{
|
||||
disk_data *disk = get_safe_disk_token(this);
|
||||
DLOG1(("device_reset_omti_disk"));
|
||||
{
|
||||
LOG1(("device_reset_omti_disk"));
|
||||
|
||||
if (exists() && fseek(0, SEEK_END) == 0)
|
||||
{
|
||||
UINT32 disk_size = (UINT32)(ftell() / OMTI_DISK_SECTOR_SIZE);
|
||||
UINT16 disk_type = disk_size >= 300000 ? OMTI_DISK_TYPE_348_MB : OMTI_DISK_TYPE_155_MB;
|
||||
if (disk_type != disk->type) {
|
||||
DLOG1(("device_reset_omti_disk: disk size=%d blocks, disk type=%x", disk_size, disk_type ));
|
||||
omti_disk_config(disk, disk_type);
|
||||
if (disk_type != m_type) {
|
||||
LOG1(("device_reset_omti_disk: disk size=%d blocks, disk type=%x", disk_size, disk_type ));
|
||||
omti_disk_config(disk_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1372,15 +1318,14 @@ void omti_disk_image_device::device_reset()
|
||||
|
||||
bool omti_disk_image_device::call_create(int format_type, option_resolution *format_options)
|
||||
{
|
||||
disk_data *disk = get_safe_disk_token(this);
|
||||
DLOG(("device_create_omti_disk: creating OMTI Disk with %d blocks", disk->sector_count));
|
||||
LOG(("device_create_omti_disk: creating OMTI Disk with %d blocks", m_sector_count));
|
||||
|
||||
int x;
|
||||
unsigned char sectordata[OMTI_DISK_SECTOR_SIZE]; // empty block data
|
||||
|
||||
|
||||
memset(sectordata, 0x55, sizeof(sectordata));
|
||||
for (x = 0; x < disk->sector_count; x++)
|
||||
for (x = 0; x < m_sector_count; x++)
|
||||
{
|
||||
if (fwrite(sectordata, OMTI_DISK_SECTOR_SIZE)
|
||||
< OMTI_DISK_SECTOR_SIZE)
|
||||
|
@ -27,23 +27,48 @@
|
||||
FUNCTION PROTOTYPES
|
||||
***************************************************************************/
|
||||
|
||||
struct disk_data
|
||||
class omti_disk_image_device : public device_t,
|
||||
public device_image_interface
|
||||
{
|
||||
device_t *device;
|
||||
UINT16 type;
|
||||
UINT16 cylinders;
|
||||
UINT16 heads;
|
||||
UINT16 sectors;
|
||||
UINT32 sectorbytes;
|
||||
UINT32 sector_count;
|
||||
public:
|
||||
// construction/destruction
|
||||
omti_disk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
device_image_interface *image;
|
||||
// image-level overrides
|
||||
virtual iodevice_t image_type() const { return IO_HARDDISK; }
|
||||
|
||||
virtual bool is_readable() const { return 1; }
|
||||
virtual bool is_writeable() const { return 1; }
|
||||
virtual bool is_creatable() const { return 1; }
|
||||
virtual bool must_be_loaded() const { return 0; }
|
||||
virtual bool is_reset_on_load() const { return 0; }
|
||||
virtual const char *image_interface() const { return NULL; }
|
||||
virtual const char *file_extensions() const { return "awd"; }
|
||||
virtual const option_guide *create_option_guide() const { return NULL; }
|
||||
|
||||
virtual bool call_create(int format_type, option_resolution *format_options);
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
void omti_disk_config(UINT16 disk_type);
|
||||
public:
|
||||
UINT16 m_type;
|
||||
UINT16 m_cylinders;
|
||||
UINT16 m_heads;
|
||||
UINT16 m_sectors;
|
||||
UINT32 m_sectorbytes;
|
||||
UINT32 m_sector_count;
|
||||
|
||||
device_image_interface *m_image;
|
||||
|
||||
// configuration data
|
||||
UINT8 config_data[10];
|
||||
UINT8 m_config_data[10];
|
||||
|
||||
// ESDI defect list data
|
||||
UINT8 esdi_defect_list[256];
|
||||
UINT8 m_esdi_defect_list[256];
|
||||
};
|
||||
|
||||
/* ----- device interface ----- */
|
||||
@ -87,7 +112,7 @@ protected:
|
||||
void set_interrupt(enum line_state line_state);
|
||||
|
||||
private:
|
||||
disk_data *our_disks[OMTI_MAX_LUN+1];
|
||||
omti_disk_image_device *our_disks[OMTI_MAX_LUN+1];
|
||||
|
||||
UINT16 jumper;
|
||||
|
||||
|
@ -14,40 +14,6 @@
|
||||
|
||||
#define MESSIMG_DISK_SECTOR_SIZE (512)
|
||||
|
||||
// messimg_disk_image_device
|
||||
|
||||
class messimg_disk_image_device : public device_t,
|
||||
public device_image_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
messimg_disk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
// image-level overrides
|
||||
virtual iodevice_t image_type() const { return IO_QUICKLOAD; }
|
||||
|
||||
virtual bool is_readable() const { return 1; }
|
||||
virtual bool is_writeable() const { return 1; }
|
||||
virtual bool is_creatable() const { return 0; }
|
||||
virtual bool must_be_loaded() const { return 0; }
|
||||
virtual bool is_reset_on_load() const { return 0; }
|
||||
virtual const char *image_interface() const { return NULL; }
|
||||
virtual const char *file_extensions() const { return "img"; }
|
||||
virtual const option_guide *create_option_guide() const { return NULL; }
|
||||
|
||||
virtual bool call_load();
|
||||
virtual void call_unload();
|
||||
|
||||
disk_data *token() { return &m_token; }
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
disk_data m_token;
|
||||
};
|
||||
|
||||
// device type definition
|
||||
extern const device_type MESSIMG_DISK;
|
||||
|
||||
@ -65,64 +31,46 @@ void messimg_disk_image_device::device_config_complete()
|
||||
};
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
get_safe_disk_token - makes sure that the passed in device is a messimg disk
|
||||
***************************************************************************/
|
||||
|
||||
INLINE disk_data *get_safe_disk_token(device_t *device) {
|
||||
assert(device != NULL);
|
||||
assert(device->type() == MESSIMG_DISK);
|
||||
return (disk_data *) downcast<messimg_disk_image_device *>(device)->token();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
device start callback
|
||||
-------------------------------------------------*/
|
||||
|
||||
void messimg_disk_image_device::device_start()
|
||||
{
|
||||
disk_data *disk = get_safe_disk_token(this);
|
||||
|
||||
disk->device = this;
|
||||
disk->image = this;
|
||||
disk->data = (UINT8 *)NULL;
|
||||
m_data = (UINT8 *)NULL;
|
||||
|
||||
if (exists() && fseek(0, SEEK_END) == 0)
|
||||
{
|
||||
disk->size = (UINT32)ftell();
|
||||
m_size = (UINT32)ftell();
|
||||
}
|
||||
}
|
||||
|
||||
bool messimg_disk_image_device::call_load()
|
||||
{
|
||||
disk_data *disk = get_safe_disk_token(this);
|
||||
|
||||
fseek(0, SEEK_END);
|
||||
disk->size = (UINT32)ftell();
|
||||
if (disk->size > (256*1024*1024))
|
||||
m_size = (UINT32)ftell();
|
||||
if (m_size > (256*1024*1024))
|
||||
{
|
||||
printf("Mac image too large: must be 256MB or less!\n");
|
||||
disk->size = 0;
|
||||
m_size = 0;
|
||||
return IMAGE_INIT_FAIL;
|
||||
}
|
||||
|
||||
disk->data = (UINT8 *)auto_alloc_array_clear(machine(), UINT32, disk->size/sizeof(UINT32));
|
||||
m_data = (UINT8 *)auto_alloc_array_clear(machine(), UINT32, m_size/sizeof(UINT32));
|
||||
fseek(0, SEEK_SET);
|
||||
fread(disk->data, disk->size);
|
||||
disk->ejected = false;
|
||||
fread(m_data, m_size);
|
||||
m_ejected = false;
|
||||
|
||||
return IMAGE_INIT_PASS;
|
||||
}
|
||||
|
||||
void messimg_disk_image_device::call_unload()
|
||||
{
|
||||
disk_data *disk = get_safe_disk_token(this);
|
||||
|
||||
// TODO: track dirty sectors and only write those
|
||||
fseek(0, SEEK_SET);
|
||||
fwrite(disk->data, disk->size);
|
||||
disk->size = 0;
|
||||
//free(disk->data);
|
||||
fwrite(m_data, m_size);
|
||||
m_size = 0;
|
||||
//free(m_data);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -210,8 +158,7 @@ void nubus_image_device::device_start()
|
||||
m_nubus->install_device(slotspace+4, slotspace+7, read32_delegate(FUNC(nubus_image_device::image_status_r), this), write32_delegate(FUNC(nubus_image_device::image_status_w), this));
|
||||
m_nubus->install_device(superslotspace, superslotspace+((256*1024*1024)-1), read32_delegate(FUNC(nubus_image_device::image_super_r), this), write32_delegate(FUNC(nubus_image_device::image_super_w), this));
|
||||
|
||||
device_t *device0 = subdevice(IMAGE_DISK0_TAG);
|
||||
m_image = (disk_data *) downcast<messimg_disk_image_device *>(device0)->token();
|
||||
m_image = subdevice<messimg_disk_image_device>(IMAGE_DISK0_TAG);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -224,16 +171,16 @@ void nubus_image_device::device_reset()
|
||||
|
||||
WRITE32_MEMBER( nubus_image_device::image_status_w )
|
||||
{
|
||||
m_image->ejected = true;
|
||||
m_image->m_ejected = true;
|
||||
}
|
||||
|
||||
READ32_MEMBER( nubus_image_device::image_status_r )
|
||||
{
|
||||
if(m_image->ejected) {
|
||||
if(m_image->m_ejected) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(m_image->size) {
|
||||
if(m_image->m_size) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@ -245,12 +192,12 @@ WRITE32_MEMBER( nubus_image_device::image_w )
|
||||
|
||||
READ32_MEMBER( nubus_image_device::image_r )
|
||||
{
|
||||
return m_image->size;
|
||||
return m_image->m_size;
|
||||
}
|
||||
|
||||
WRITE32_MEMBER( nubus_image_device::image_super_w )
|
||||
{
|
||||
UINT32 *image = (UINT32*)m_image->data;
|
||||
UINT32 *image = (UINT32*)m_image->m_data;
|
||||
data = ((data & 0xff) << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8) | ((data & 0xff000000) >> 24);
|
||||
mem_mask = ((mem_mask & 0xff) << 24) | ((mem_mask & 0xff00) << 8) | ((mem_mask & 0xff0000) >> 8) | ((mem_mask & 0xff000000) >> 24);
|
||||
|
||||
@ -259,7 +206,7 @@ WRITE32_MEMBER( nubus_image_device::image_super_w )
|
||||
|
||||
READ32_MEMBER( nubus_image_device::image_super_r )
|
||||
{
|
||||
UINT32 *image = (UINT32*)m_image->data;
|
||||
UINT32 *image = (UINT32*)m_image->m_data;
|
||||
UINT32 data = image[offset];
|
||||
return ((data & 0xff) << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8) | ((data & 0xff000000) >> 24);
|
||||
}
|
||||
|
@ -10,14 +10,39 @@
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
struct disk_data
|
||||
{
|
||||
device_t *device;
|
||||
UINT32 size;
|
||||
UINT8 *data;
|
||||
bool ejected;
|
||||
// messimg_disk_image_device
|
||||
|
||||
device_image_interface *image;
|
||||
class messimg_disk_image_device : public device_t,
|
||||
public device_image_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
messimg_disk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
// image-level overrides
|
||||
virtual iodevice_t image_type() const { return IO_QUICKLOAD; }
|
||||
|
||||
virtual bool is_readable() const { return 1; }
|
||||
virtual bool is_writeable() const { return 1; }
|
||||
virtual bool is_creatable() const { return 0; }
|
||||
virtual bool must_be_loaded() const { return 0; }
|
||||
virtual bool is_reset_on_load() const { return 0; }
|
||||
virtual const char *image_interface() const { return NULL; }
|
||||
virtual const char *file_extensions() const { return "img"; }
|
||||
virtual const option_guide *create_option_guide() const { return NULL; }
|
||||
|
||||
virtual bool call_load();
|
||||
virtual void call_unload();
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
public:
|
||||
UINT32 m_size;
|
||||
UINT8 *m_data;
|
||||
bool m_ejected;
|
||||
};
|
||||
|
||||
// ======================> nubus_image_device
|
||||
@ -48,7 +73,7 @@ protected:
|
||||
DECLARE_WRITE32_MEMBER(image_super_w);
|
||||
|
||||
public:
|
||||
disk_data *m_image;
|
||||
messimg_disk_image_device *m_image;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user