Diff for /np2/fdd/sxsihdd.c between versions 1.1 and 1.3

version 1.1, 2005/03/05 06:02:29 version 1.3, 2005/04/05 09:12:24
Line 21  const SASIHDD sasihdd[7] = { Line 21  const SASIHDD sasihdd[7] = {
   
 // ----  // ----
   
   static BRESULT hdd_reopen(SXSIDEV sxsi) {
   
           FILEH   fh;
   
           fh = file_open(sxsi->fname);
           if (fh != FILEH_INVALID) {
                   sxsi->hdl = (INTPTR)fh;
                   return(SUCCESS);
           }
           else {
                   return(FAILURE);
           }
   }
   
 static REG8 hdd_read(SXSIDEV sxsi, long pos, UINT8 *buf, UINT size) {  static REG8 hdd_read(SXSIDEV sxsi, long pos, UINT8 *buf, UINT size) {
   
           FILEH   fh;
         long    r;          long    r;
         UINT    rsize;          UINT    rsize;
   
Line 33  static REG8 hdd_read(SXSIDEV sxsi, long  Line 48  static REG8 hdd_read(SXSIDEV sxsi, long 
                 return(0x40);                  return(0x40);
         }          }
         pos = pos * sxsi->size + sxsi->headersize;          pos = pos * sxsi->size + sxsi->headersize;
         r = file_seek((FILEH)sxsi->fh, pos, FSEEK_SET);          fh = (FILEH)sxsi->hdl;
           r = file_seek(fh, pos, FSEEK_SET);
         if (pos != r) {          if (pos != r) {
                 return(0xd0);                  return(0xd0);
         }          }
         while(size) {          while(size) {
                 rsize = min(size, sxsi->size);                  rsize = min(size, sxsi->size);
                 CPU_REMCLOCK -= rsize;                  CPU_REMCLOCK -= rsize;
                 if (file_read((FILEH)sxsi->fh, buf, rsize) != rsize) {                  if (file_read(fh, buf, rsize) != rsize) {
                         return(0xd0);                          return(0xd0);
                 }                  }
                 buf += rsize;                  buf += rsize;
Line 51  static REG8 hdd_read(SXSIDEV sxsi, long  Line 67  static REG8 hdd_read(SXSIDEV sxsi, long 
   
 static REG8 hdd_write(SXSIDEV sxsi, long pos, const UINT8 *buf, UINT size) {  static REG8 hdd_write(SXSIDEV sxsi, long pos, const UINT8 *buf, UINT size) {
   
           FILEH   fh;
         long    r;          long    r;
         UINT    wsize;          UINT    wsize;
   
Line 61  static REG8 hdd_write(SXSIDEV sxsi, long Line 78  static REG8 hdd_write(SXSIDEV sxsi, long
                 return(0x40);                  return(0x40);
         }          }
         pos = pos * sxsi->size + sxsi->headersize;          pos = pos * sxsi->size + sxsi->headersize;
         r = file_seek((FILEH)sxsi->fh, pos, FSEEK_SET);          fh = (FILEH)sxsi->hdl;
           r = file_seek(fh, pos, FSEEK_SET);
         if (pos != r) {          if (pos != r) {
                 return(0xd0);                  return(0xd0);
         }          }
         while(size) {          while(size) {
                 wsize = min(size, sxsi->size);                  wsize = min(size, sxsi->size);
                 CPU_REMCLOCK -= wsize;                  CPU_REMCLOCK -= wsize;
                 if (file_write((FILEH)sxsi->fh, buf, wsize) != wsize) {                  if (file_write(fh, buf, wsize) != wsize) {
                         return(0x70);                          return(0x70);
                 }                  }
                 buf += wsize;                  buf += wsize;
Line 79  static REG8 hdd_write(SXSIDEV sxsi, long Line 97  static REG8 hdd_write(SXSIDEV sxsi, long
   
 static REG8 hdd_format(SXSIDEV sxsi, long pos) {  static REG8 hdd_format(SXSIDEV sxsi, long pos) {
   
           FILEH   fh;
         long    r;          long    r;
         UINT16  i;          UINT16  i;
         UINT8   work[256];          UINT8   work[256];
Line 92  static REG8 hdd_format(SXSIDEV sxsi, lon Line 111  static REG8 hdd_format(SXSIDEV sxsi, lon
                 return(0x40);                  return(0x40);
         }          }
         pos = pos * sxsi->size + sxsi->headersize;          pos = pos * sxsi->size + sxsi->headersize;
         r = file_seek((FILEH)sxsi->fh, pos, FSEEK_SET);          fh = (FILEH)sxsi->hdl;
           r = file_seek(fh, pos, FSEEK_SET);
         if (pos != r) {          if (pos != r) {
                 return(0xd0);                  return(0xd0);
         }          }
Line 103  static REG8 hdd_format(SXSIDEV sxsi, lon Line 123  static REG8 hdd_format(SXSIDEV sxsi, lon
                         wsize = min(size, sizeof(work));                          wsize = min(size, sizeof(work));
                         size -= wsize;                          size -= wsize;
                         CPU_REMCLOCK -= wsize;                          CPU_REMCLOCK -= wsize;
                         if (file_write((FILEH)sxsi->fh, work, wsize) != wsize) {                          if (file_write(fh, work, wsize) != wsize) {
                                 return(0x70);                                  return(0x70);
                         }                          }
                 }                  }
Line 111  static REG8 hdd_format(SXSIDEV sxsi, lon Line 131  static REG8 hdd_format(SXSIDEV sxsi, lon
         return(0x00);          return(0x00);
 }  }
   
   static void hdd_close(SXSIDEV sxsi) {
   
           file_close((FILEH)sxsi->hdl);
   }
   
   
 // ----  // ----
   
Line 133  const SASIHDD *sasi; Line 158  const SASIHDD *sasi;
         return(SXSIMEDIA_INVSASI + 7);          return(SXSIMEDIA_INVSASI + 7);
 }  }
   
 BRESULT sxsihdd_open(SXSIDEV sxsi, const OEMCHAR *file) {  BRESULT sxsihdd_open(SXSIDEV sxsi, const OEMCHAR *fname) {
   
         FILEH           fh;          FILEH           fh;
 const OEMCHAR   *ext;  const OEMCHAR   *ext;
Line 145  const OEMCHAR *ext; Line 170  const OEMCHAR *ext;
         UINT32          sectors;          UINT32          sectors;
         UINT32          size;          UINT32          size;
   
         fh = file_open(file);          fh = file_open(fname);
         if (fh == FILEH_INVALID) {          if (fh == FILEH_INVALID) {
                 goto sxsiope_err1;                  goto sxsiope_err1;
         }          }
         ext = file_getext(file);          ext = file_getext(fname);
         iftype = sxsi->drv & SXSIDRV_IFMASK;          iftype = sxsi->drv & SXSIDRV_IFMASK;
         if ((iftype == SXSIDRV_SASI) && (!file_cmpname(ext, str_thd))) {          if ((iftype == SXSIDRV_SASI) && (!file_cmpname(ext, str_thd))) {
                 THDHDR thd;                                             // T98 HDD (IDE)                  THDHDR thd;                                             // T98 HDD (IDE)
Line 217  const OEMCHAR *ext; Line 242  const OEMCHAR *ext;
                         goto sxsiope_err2;                          goto sxsiope_err2;
                 }                  }
         }          }
         sxsi->fh = (INTPTR)fh;          sxsi->reopen = hdd_reopen;
         sxsi->read = hdd_read;          sxsi->read = hdd_read;
         sxsi->write = hdd_write;          sxsi->write = hdd_write;
         sxsi->format = hdd_format;          sxsi->format = hdd_format;
           sxsi->close = hdd_close;
   
           sxsi->hdl = (INTPTR)fh;
         sxsi->totals = totals;          sxsi->totals = totals;
         sxsi->cylinders = (UINT16)cylinders;          sxsi->cylinders = (UINT16)cylinders;
         sxsi->size = (UINT16)size;          sxsi->size = (UINT16)size;
Line 238  sxsiope_err1: Line 265  sxsiope_err1:
         return(FAILURE);          return(FAILURE);
 }  }
   
 // ----  
   
 void sxsihdd_allbind(void) {  
   
         int             i;  
         REG8    drv;  
   
         drv = 0;  
         for (i=0; i<2; i++) {  
                 sxsi_devclose(drv);  
                 sxsi_setdevtype(drv, SXSIDEV_HDD);  
                 if (sxsi_devopen(drv, np2cfg.sasihdd[i]) == SUCCESS) {  
                         drv++;  
                 }  
         }  
 #if defined(SUPPORT_SCSI)  
         drv = 0x20;  
         for (i=0; i<4; i++) {  
                 sxsi_devclose(drv);  
                 sxsi_setdevtype(drv, SXSIDEV_HDD);  
                 if (sxsi_devopen(drv, np2cfg.scsihdd[i]) == SUCCESS) {  
                         drv++;  
                 }  
         }  
 #endif  
 }  
   

Removed from v.1.1  
changed lines
  Added in v.1.3


RetroPC.NET-CVS <cvs@retropc.net>