mirror of
https://github.com/holub/mame
synced 2025-04-22 00:11:58 +03:00
Some legacy floppy fixes and cleanups (#3047)
* thomflop.cpp: removed usage of floppy_get_drive() (nw) * flopdrv.cpp: got rid of bogus default drive in lookup functions (nw) * flopdrv.cpp: avoid some potential nullptr dereferences (nw) * flopdrv.cpp: made floppy_get_drive() internal (nw)
This commit is contained in:
parent
71c0ae310b
commit
45854ff96c
@ -498,7 +498,7 @@ legacy_floppy_image_device *floppy_get_device_by_type(running_machine &machine,i
|
||||
int cnt = 0;
|
||||
for (i=0;i<4;i++) {
|
||||
legacy_floppy_image_device *disk = floppy_get_device(machine,i);
|
||||
if (disk->floppy_get_drive_type()==ftype) {
|
||||
if (disk && disk->floppy_get_drive_type()==ftype) {
|
||||
if (cnt==drive) {
|
||||
return disk;
|
||||
}
|
||||
@ -508,9 +508,9 @@ legacy_floppy_image_device *floppy_get_device_by_type(running_machine &machine,i
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int floppy_get_drive(device_t *image)
|
||||
static int floppy_get_drive(device_t *image)
|
||||
{
|
||||
int drive =0;
|
||||
int drive = -1;
|
||||
if (strcmp(image->tag(), ":" FLOPPY_0) == 0) drive = 0;
|
||||
if (strcmp(image->tag(), ":" FLOPPY_1) == 0) drive = 1;
|
||||
if (strcmp(image->tag(), ":" FLOPPY_2) == 0) drive = 2;
|
||||
@ -523,14 +523,14 @@ int floppy_get_drive_by_type(legacy_floppy_image_device *image,int ftype)
|
||||
int i,drive =0;
|
||||
for (i=0;i<4;i++) {
|
||||
legacy_floppy_image_device *disk = floppy_get_device(image->machine(),i);
|
||||
if (disk->floppy_get_drive_type()==ftype) {
|
||||
if (disk && disk->floppy_get_drive_type()==ftype) {
|
||||
if (image==disk) {
|
||||
return drive;
|
||||
}
|
||||
drive++;
|
||||
}
|
||||
}
|
||||
return drive;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int floppy_get_count(running_machine &machine)
|
||||
@ -718,7 +718,7 @@ legacy_floppy_image_device::legacy_floppy_image_device(const machine_config &mco
|
||||
m_wpt(0),
|
||||
m_rdy(0),
|
||||
m_dskchg(0),
|
||||
m_drive_id(0),
|
||||
m_drive_id(-1),
|
||||
m_active(0),
|
||||
m_config(nullptr),
|
||||
m_flags(0),
|
||||
|
@ -233,7 +233,6 @@ DECLARE_DEVICE_TYPE(LEGACY_FLOPPY, legacy_floppy_image_device)
|
||||
|
||||
legacy_floppy_image_device *floppy_get_device(running_machine &machine,int drive);
|
||||
legacy_floppy_image_device *floppy_get_device_by_type(running_machine &machine,int ftype,int drive);
|
||||
int floppy_get_drive(device_t *image);
|
||||
int floppy_get_drive_by_type(legacy_floppy_image_device *image,int ftype);
|
||||
int floppy_get_count(running_machine &machine);
|
||||
|
||||
|
@ -992,7 +992,7 @@ int thomson_state::thmfc_floppy_find_sector( chrn_id* dst )
|
||||
}
|
||||
|
||||
thmfc1->stat0 = THMFC1_STAT0_CRC_ERROR | THMFC1_STAT0_FINISHED;
|
||||
LOG (( "thmfc_floppy_find_sector: sector not found drive=%i track=%i sector=%i\n", floppy_get_drive(img), thmfc1->track, thmfc1->sector ));
|
||||
LOG (( "thmfc_floppy_find_sector: sector not found drive=%s track=%i sector=%i\n", img->tag(), thmfc1->track, thmfc1->sector ));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user