Move magneto-optical types to a table.
This commit is contained in:
@@ -2476,6 +2476,7 @@ mo_load(mo_t *dev, const wchar_t *fn)
|
||||
{
|
||||
int read_only = dev->drv->ui_writeprot;
|
||||
int size = 0;
|
||||
unsigned int i, found = 0;
|
||||
|
||||
dev->drv->f = plat_fopen(fn, dev->drv->ui_writeprot ? L"rb" : L"rb+");
|
||||
if (!dev->drv->ui_writeprot && !dev->drv->f) {
|
||||
@@ -2486,29 +2487,19 @@ mo_load(mo_t *dev, const wchar_t *fn)
|
||||
fseek(dev->drv->f, 0, SEEK_END);
|
||||
size = ftell(dev->drv->f);
|
||||
|
||||
switch(size)
|
||||
for(i = 0; i < sizeof(mo_types); i++)
|
||||
{
|
||||
case MO_SECTORS_ISO10090 * MO_BPS_ISO10090:
|
||||
dev->drv->medium_size = MO_SECTORS_ISO10090;
|
||||
dev->drv->sector_size = MO_BPS_ISO10090;
|
||||
if(size == mo_types[i].disk_size)
|
||||
{
|
||||
found = 1;
|
||||
dev->drv->medium_size = mo_types[i].sectors;
|
||||
dev->drv->sector_size = mo_types[i].bytes_per_sector;
|
||||
break;
|
||||
case MO_SECTORS_ISO13963 * MO_BPS_ISO13963:
|
||||
dev->drv->medium_size = MO_SECTORS_ISO13963;
|
||||
dev->drv->sector_size = MO_BPS_ISO13963;
|
||||
break;
|
||||
case MO_SECTORS_ISO15498 * MO_BPS_ISO15498:
|
||||
dev->drv->medium_size = MO_SECTORS_ISO15498;
|
||||
dev->drv->sector_size = MO_BPS_ISO15498;
|
||||
break;
|
||||
case MO_SECTORS_GIGAMO * MO_BPS_GIGAMO:
|
||||
dev->drv->medium_size = MO_SECTORS_GIGAMO;
|
||||
dev->drv->sector_size = MO_BPS_GIGAMO;
|
||||
break;
|
||||
case MO_SECTORS_GIGAMO2 * MO_BPS_GIGAMO2:
|
||||
dev->drv->medium_size = MO_SECTORS_GIGAMO2;
|
||||
dev->drv->sector_size = MO_BPS_GIGAMO2;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
if(!found)
|
||||
{
|
||||
DEBUG("File is incorrect size for a magneto-optical image\n");
|
||||
fclose(dev->drv->f);
|
||||
dev->drv->f = NULL;
|
||||
|
||||
@@ -44,19 +44,21 @@
|
||||
|
||||
#define MO_TIME (5LL * 100LL * (1LL << TIMER_SHIFT))
|
||||
|
||||
// TODO: Create arrays with media-type, sectors, bps
|
||||
// 3.5" standard M.O. disks
|
||||
#define MO_SECTORS_ISO10090 (248826)
|
||||
#define MO_SECTORS_ISO13963 (446325)
|
||||
#define MO_SECTORS_ISO15498 (310352)
|
||||
#define MO_SECTORS_GIGAMO (605846)
|
||||
#define MO_SECTORS_GIGAMO2 (1063146)
|
||||
typedef struct {
|
||||
uint32_t sectors;
|
||||
uint16_t bytes_per_sector;
|
||||
int64_t disk_size;
|
||||
char name[255];
|
||||
} mo_type_t;
|
||||
|
||||
#define MO_BPS_ISO10090 (512)
|
||||
#define MO_BPS_ISO13963 (512)
|
||||
#define MO_BPS_ISO15498 (2048)
|
||||
#define MO_BPS_GIGAMO (2048)
|
||||
#define MO_BPS_GIGAMO2 (2048)
|
||||
static const mo_type_t mo_types[5] = {
|
||||
// 3.5" standard M.O. disks
|
||||
{ 248826, 512, 127398912, "3.5\" 128Mb M.O. (ISO 10090)" },
|
||||
{ 446325, 512, 228518400, "3.5\" 230Mb M.O. (ISO 13963)" },
|
||||
{ 310352, 2048, 635600896, "3.5\" 640Mb M.O. (ISO 15498)" },
|
||||
{ 605846, 2048, 1240772608, "3.5\" 1.3Gb M.O. (GigaMO)" },
|
||||
{ 1063146, 2048, 2177323008, "3.5\" 2.3Gb M.O. (GigaMO 2)" }
|
||||
};
|
||||
|
||||
enum {
|
||||
MO_BUS_DISABLED = 0,
|
||||
|
||||
Reference in New Issue
Block a user