From 0986367da71f617aa0770d475eb82bebb2e09b31 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 10 Jan 2011 15:37:23 +0000 Subject: [PATCH] Removed more ifdefs from scsi code (no whatsnew) --- src/emu/machine/idectrl.c | 38 +++++++++++++++++++------------------- src/emu/machine/scsicd.c | 24 +++++++++++++----------- src/emu/machine/scsihd.c | 25 +++++++++++++------------ 3 files changed, 45 insertions(+), 42 deletions(-) diff --git a/src/emu/machine/idectrl.c b/src/emu/machine/idectrl.c index a3cb92001aa..b05730a3372 100644 --- a/src/emu/machine/idectrl.c +++ b/src/emu/machine/idectrl.c @@ -1911,34 +1911,34 @@ static DEVICE_RESET( ide_controller ) LOG(("IDE controller reset performed\n")); -#ifdef MESS - if (!ide->disk) - { - ide->handle = hd_get_chd_file( device->machine->device( "harddisk" ) ); // should be config->master - - if (ide->handle) + if (device->machine->device( "harddisk" )) { + if (!ide->disk) { - ide->disk = hd_get_hard_disk_file( device->machine->device( "harddisk" ) ); // should be config->master + ide->handle = hd_get_chd_file( device->machine->device( "harddisk" ) ); // should be config->master - if (ide->disk != NULL) + if (ide->handle) { - const hard_disk_info *hdinfo; + ide->disk = hd_get_hard_disk_file( device->machine->device( "harddisk" ) ); // should be config->master - hdinfo = hard_disk_get_info(ide->disk); - if (hdinfo->sectorbytes == IDE_DISK_SECTOR_SIZE) + if (ide->disk != NULL) { - ide->num_cylinders = hdinfo->cylinders; - ide->num_sectors = hdinfo->sectors; - ide->num_heads = hdinfo->heads; - if (PRINTF_IDE_COMMANDS) printf("CHS: %d %d %d\n", ide->num_cylinders, ide->num_heads, ide->num_sectors); - } + const hard_disk_info *hdinfo; - /* build the features page */ - ide_build_features(ide); + hdinfo = hard_disk_get_info(ide->disk); + if (hdinfo->sectorbytes == IDE_DISK_SECTOR_SIZE) + { + ide->num_cylinders = hdinfo->cylinders; + ide->num_sectors = hdinfo->sectors; + ide->num_heads = hdinfo->heads; + if (PRINTF_IDE_COMMANDS) printf("CHS: %d %d %d\n", ide->num_cylinders, ide->num_heads, ide->num_sectors); + } + + /* build the features page */ + ide_build_features(ide); + } } } } -#endif /* reset the drive state */ ide->status = IDE_STATUS_DRIVE_READY | IDE_STATUS_SEEK_COMPLETE; diff --git a/src/emu/machine/scsicd.c b/src/emu/machine/scsicd.c index 2ce8bd6f1de..8dfb0ff7e72 100644 --- a/src/emu/machine/scsicd.c +++ b/src/emu/machine/scsicd.c @@ -21,6 +21,7 @@ typedef struct UINT32 cur_subblock; UINT32 play_err_flag; cdrom_file *cdrom; + bool is_file; } SCSICd; static void phys_frame_to_msf(int phys_frame, int *m, int *s, int *f) @@ -689,28 +690,29 @@ static void scsicd_alloc_instance( SCSIInstance *scsiInstance, const char *diskr state_save_register_item( machine, "scsicd", diskregion, 0, our_this->cur_subblock ); state_save_register_item( machine, "scsicd", diskregion, 0, our_this->play_err_flag ); -#ifdef MESS - /* TODO: get rid of this ifdef MESS section */ - our_this->cdrom = cd_get_cdrom_file( machine->device( diskregion ) ); -#else - our_this->cdrom = cdrom_open(get_disk_handle( machine, diskregion )); + if (machine->device( diskregion )) { + our_this->is_file = TRUE; + our_this->cdrom = cd_get_cdrom_file( machine->device( diskregion ) ); + } else { + our_this->is_file = FALSE; + our_this->cdrom = cdrom_open(get_disk_handle( machine, diskregion )); + } if (!our_this->cdrom) { logerror("SCSICD: no CD found!\n"); } -#endif } static void scsicd_delete_instance( SCSIInstance *scsiInstance ) { -#ifndef MESS SCSICd *our_this = (SCSICd *)SCSIThis( &SCSIClassCDROM, scsiInstance ); - if( our_this->cdrom ) - { - cdrom_close( our_this->cdrom ); + if (!our_this->is_file) { + if( our_this->cdrom ) + { + cdrom_close( our_this->cdrom ); + } } -#endif } static void scsicd_get_device( SCSIInstance *scsiInstance, cdrom_file **cdrom ) diff --git a/src/emu/machine/scsihd.c b/src/emu/machine/scsihd.c index 8cdb03c9348..64b99c0c2c3 100644 --- a/src/emu/machine/scsihd.c +++ b/src/emu/machine/scsihd.c @@ -15,6 +15,7 @@ typedef struct UINT32 lba; UINT32 blocks; hard_disk_file *disk; + bool is_file; } SCSIHd; @@ -253,12 +254,13 @@ static void scsihd_alloc_instance( SCSIInstance *scsiInstance, const char *diskr state_save_register_item( machine, "scsihd", diskregion, 0, our_this->lba ); state_save_register_item( machine, "scsihd", diskregion, 0, our_this->blocks ); -#ifdef MESS - /* TODO: get rid of this ifdef MESS section */ - our_this->disk = hd_get_hard_disk_file( machine->device( diskregion ) ); -#else - our_this->disk = hard_disk_open(get_disk_handle( machine, diskregion )); -#endif + if (machine->device( diskregion )) { + our_this->is_file = TRUE; + our_this->disk = hd_get_hard_disk_file( machine->device( diskregion ) ); + } else { + our_this->is_file = FALSE; + our_this->disk = hard_disk_open(get_disk_handle( machine, diskregion )); + } if (!our_this->disk) { @@ -268,14 +270,13 @@ static void scsihd_alloc_instance( SCSIInstance *scsiInstance, const char *diskr static void scsihd_delete_instance( SCSIInstance *scsiInstance ) { -#ifndef MESS SCSIHd *our_this = (SCSIHd *)SCSIThis( &SCSIClassHARDDISK, scsiInstance ); - - if( our_this->disk ) - { - hard_disk_close( our_this->disk ); + if (!our_this->is_file) { + if( our_this->disk ) + { + hard_disk_close( our_this->disk ); + } } -#endif } static void scsihd_get_device( SCSIInstance *scsiInstance, hard_disk_file **disk )