--- np2/fdd/sxsi.c 2004/01/27 03:24:19 1.9 +++ np2/fdd/sxsi.c 2004/02/13 20:31:55 1.11 @@ -66,16 +66,18 @@ SXSIDEV sxsi_getptr(REG8 drv) { UINT num; num = drv & 0x0f; - if (!(drv & 0x20)) { // SASI or IDE - if (num < 2) { + if (!(drv & 0x20)) { // SASI or IDE + if (num < SASIHDD_MAX) { return(sxsi_dev + num); } } +#if defined(SUPPORT_SCSI) else { - if (num < 4) { // SCSI + if (num < SCSIHDD_MAX) { // SCSI return(sxsi_dev + SASIHDD_MAX + num); } } +#endif return(NULL); } @@ -128,18 +130,6 @@ const char *ext; size = 256; totals = cylinders * sectors * surfaces; } - else if ((!file_cmpname(ext, str_hdi)) && (!(drv & 0x20))) { - HDIHDR hdi; // ANEX86 HDD (SASI) thanx Mamiya - if (file_read(fh, &hdi, sizeof(hdi)) != sizeof(hdi)) { - goto sxsiope_err2; - } - headersize = LOADINTELDWORD(hdi.headersize); - surfaces = LOADINTELDWORD(hdi.surfaces); - cylinders = LOADINTELDWORD(hdi.cylinders); - sectors = LOADINTELDWORD(hdi.sectors); - size = LOADINTELDWORD(hdi.sectorsize); - totals = cylinders * sectors * surfaces; - } else if ((!file_cmpname(ext, str_nhd)) && (!(drv & 0x20))) { NHDHDR nhd; // T98Next HDD (IDE) if ((file_read(fh, &nhd, sizeof(nhd)) != sizeof(nhd)) || @@ -153,13 +143,25 @@ const char *ext; size = LOADINTELWORD(nhd.sectorsize); totals = cylinders * sectors * surfaces; } + else if ((!file_cmpname(ext, str_hdi)) && (!(drv & 0x20))) { + HDIHDR hdi; // ANEX86 HDD (SASI) thanx Mamiya + if (file_read(fh, &hdi, sizeof(hdi)) != sizeof(hdi)) { + goto sxsiope_err2; + } + headersize = LOADINTELDWORD(hdi.headersize); + surfaces = LOADINTELDWORD(hdi.surfaces); + cylinders = LOADINTELDWORD(hdi.cylinders); + sectors = LOADINTELDWORD(hdi.sectors); + size = LOADINTELDWORD(hdi.sectorsize); + totals = cylinders * sectors * surfaces; + } else if ((!file_cmpname(ext, str_hdd)) && (drv & 0x20)) { VHDHDR vhd; // Virtual98 HDD (SCSI) if ((file_read(fh, &vhd, sizeof(vhd)) != sizeof(vhd)) || (memcmp(vhd.sig, sig_vhd, 5))) { goto sxsiope_err2; } - headersize = 220; + headersize = sizeof(vhd); surfaces = vhd.surfaces; cylinders = LOADINTELWORD(vhd.cylinders); sectors = vhd.sectors; @@ -219,12 +221,14 @@ void sxsi_open(void) { drv++; } } +#if defined(SUPPORT_SCSI) drv = 0x20; for (i=0; i<4; i++) { if (sxsi_hddopen(drv, np2cfg.scsihdd[i]) == SUCCESS) { drv++; } } +#endif } void sxsi_flash(void) { @@ -262,16 +266,10 @@ void sxsi_trash(void) { static SXSIDEV getdrive(REG8 drv) { - UINT num; SXSIDEV ret; - num = drv & 0x0f; - if (num >= 2) { - return(NULL); - } - num += (drv & 0x20) >> 4; - ret = sxsi_dev + num; - if (ret->fname[0] == '\0') { + ret = sxsi_getptr(drv); + if ((ret == NULL) || (ret->fname[0] == '\0')) { return(NULL); } if ((FILEH)ret->fh == FILEH_INVALID) {