Diff for /np2/win9xc/dialog/d_disk.cpp between versions 1.2 and 1.4

version 1.2, 2004/01/22 01:10:05 version 1.4, 2004/02/14 07:56:51
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
 #include        "strres.h"  #include        "strres.h"
 #include        "resource.h"  #include        "resource.h"
 #include        "strres.h"  
 #include        "np2.h"  #include        "np2.h"
 #include        "dosio.h"  #include        "dosio.h"
   #include        "sysmng.h"
 #include        "dialog.h"  #include        "dialog.h"
 #include        "dialogs.h"  #include        "dialogs.h"
 #include        "ini.h"  
 #include        "pccore.h"  #include        "pccore.h"
 #include        "fddfile.h"  
 #include        "diskdrv.h"  #include        "diskdrv.h"
   #include        "fddfile.h"
 #include        "newdisk.h"  #include        "newdisk.h"
   
   
Line 20  static const char fddui_filter[] =       Line 19  static const char fddui_filter[] =      
                                         "Floppy disk images (*.XDF;*.HDM;*.DUP;*.2HD)\0"        \                                          "Floppy disk images (*.XDF;*.HDM;*.DUP;*.2HD)\0"        \
                                                                         "*.xdf;*.hdm;*.dup;*.2hd;*.tfd\0"       \                                                                          "*.xdf;*.hdm;*.dup;*.2hd;*.tfd\0"       \
                                         "All supported Files\0"                                                         \                                          "All supported Files\0"                                                         \
                                                                         "*.d88;*.88d;*.d98;*.98d;"                      \                                                                          "*.d88;*.88d;*.d98;*.98d;*.fdi;"        \
                                                                         "*.xdf;*.hdm;*.dup;*.2hd;*.tfd\0"       \                                                                          "*.xdf;*.hdm;*.dup;*.2hd;*.tfd\0"       \
                                         "All files (*.*)\0*.*\0";                                          "All files (*.*)\0*.*\0";
 static const FILESEL fddui = {fddui_title, str_d88, fddui_filter, 3};  static const FILESEL fddui = {fddui_title, str_d88, fddui_filter, 3};
   
 static const char hddui_title[] = "Select HDD image";  #if defined(SUPPORT_SASI)
 static const char hddui_filter[] =                                                                              \  static const char sasiui_title[] = "Select SASI/IDE HDD image";
                                         "T98 harddisk image files (*.THD)\0"                            \  #else
                                                                         "*.thd\0"                                                       \  static const char sasiui_title[] = "Select HDD image";
   #endif
   static const char sasiui_filter[] =                                                                             \
                                         "Anex86 harddisk image files (*.HDI)\0"                         \                                          "Anex86 harddisk image files (*.HDI)\0"                         \
                                                                         "*.hdi\0"                                                       \                                                                          "*.hdi\0"                                                       \
                                           "T98 harddisk image files (*.THD)\0"                            \
                                                                           "*.thd\0"                                                       \
                                           "T98-Next harddisk image files (*.NHD)\0"                       \
                                                                           "*.nhd\0"                                                       \
                                         "All supported Files\0"                                                         \                                          "All supported Files\0"                                                         \
                                                                         "*.thd;*.hdi\0";                                                                          "*.thd;*.nhd;*.hdi\0";
 static const FILESEL hddui = {hddui_title, str_thd, hddui_filter, 3};  static const FILESEL sasiui = {sasiui_title, str_thd, sasiui_filter, 4};
   
   #if defined(SUPPORT_SCSI)
   static const char scsiui_title[] = "Select SCSI HDD image";
   static const char scsiui_filter[] =                                                                             \
                                           "Virtual98 harddisk image files (*.HDD)\0"                      \
                                                                           "*.hdd\0";
   static const FILESEL scsiui = {scsiui_title, str_hdd, scsiui_filter, 1};
   #endif
   
 static const char newdisk_title[] = "Create disk image";  static const char newdisk_title[] = "Create disk image";
   #if defined(SUPPORT_SCSI)
   static const char newdisk_filter[] =                                                                    \
                                           "D88 image files (*.D88;*.88D)\0"                                       \
                                                                           "*.d88;*.88d;*.d98;*.98d\0"                     \
                                           "Anex86 harddisk image files (*.HDI)\0"                         \
                                                                           "*.hdi\0"                                                       \
                                           "T98 harddisk image files (*.THD)\0"                            \
                                                                           "*.thd\0"                                                       \
                                           "T98-Next harddisk image files (*.NHD)\0"                       \
                                                                           "*.nhd\0"                                                       \
                                           "Virtual98 harddisk image files (*.HDD)\0"                      \
                                                                           "*.hdd\0";
   #else
 static const char newdisk_filter[] =                                                                    \  static const char newdisk_filter[] =                                                                    \
                                         "D88 image files (*.D88;*.88D)\0"                                       \                                          "D88 image files (*.D88;*.88D)\0"                                       \
                                                                                 "*.d88;*.88d\0"                                 \                                                                          "*.d88;*.88d;*.d98;*.98d\0"                     \
                                           "Anex86 harddisk image files (*.HDI)\0"                         \
                                                                           "*.hdi\0"                                                       \
                                         "T98 harddisk image files (*.THD)\0"                            \                                          "T98 harddisk image files (*.THD)\0"                            \
                                                                                 "*.thd\0";                                                                          "*.thd\0"                                                       \
                                           "T98-Next harddisk image files (*.NHD)\0"                       \
                                                                           "*.nhd\0";
   #endif
 static const FILESEL newdiskui = {newdisk_title, str_d88, newdisk_filter, 1};  static const FILESEL newdiskui = {newdisk_title, str_d88, newdisk_filter, 1};
   
   
 // ----  // ----
   
 void dialog_changefdd(HWND hWnd, BYTE drv) {  void dialog_changefdd(HWND hWnd, REG8 drv) {
   
 const char      *p;  const char      *p;
           char    path[MAX_PATH];
         int             readonly;          int             readonly;
   
         if (drv < 4) {          if (drv < 4) {
                 p = dlgs_selectfile(hWnd, &fddui, fdd_diskname(drv),                  p = fdd_diskname(drv);
                                                                         fddfolder, sizeof(fddfolder), &readonly);                  if ((p == NULL) || (p[0] == '\0')) {
                 if (p != NULL) {                          p = fddfolder;
                   }
                   file_cpyname(path, p, sizeof(path));
                   if (dlgs_selectfile(hWnd, &fddui, path, sizeof(path), &readonly)) {
                           file_cpyname(fddfolder, path, sizeof(fddfolder));
                           sysmng_update(SYS_UPDATEOSCFG);
                         diskdrv_setfdd(drv, p, readonly);                          diskdrv_setfdd(drv, p, readonly);
                 }                  }
         }          }
 }  }
   
 void dialog_changehdd(HWND hWnd, BYTE drv) {  void dialog_changehdd(HWND hWnd, REG8 drv) {
   
 const char *p;          UINT            num;
   const char              *p;
   const FILESEL   *hddui;
           char            path[MAX_PATH];
   
         if (drv < 2) {          num = drv & 0x0f;
                 p = dlgs_selectfile(hWnd, &hddui, np2cfg.sasihdd[drv],          p = NULL;
                                                                         hddfolder, sizeof(hddfolder), NULL);          hddui = NULL;
                 if (p != NULL) {          if (!(drv & 0x20)) {            // SASI/IDE
                         diskdrv_sethdd(drv, p);                  if (num < 2) {
                           p = np2cfg.sasihdd[num];
                           hddui = &sasiui;
                 }                  }
         }          }
   #if defined(SUPPORT_SCSI)
           else {                                          // SCSI
                   if (num < 4) {
                           p = np2cfg.scsihdd[num];
                           hddui = &scsiui;
                   }
           }
   #endif
           if (hddui == NULL) {
                   return;
           }
           if (p[0] == '\0') {
                   p = hddfolder;
           }
           file_cpyname(path, p, sizeof(path));
           if (dlgs_selectfile(hWnd, hddui, path, sizeof(path), NULL)) {
                   file_cpyname(hddfolder, path, sizeof(hddfolder));
                   sysmng_update(SYS_UPDATEOSCFG);
                   diskdrv_sethdd(drv, path);
           }
 }  }
   
   
Line 79  const char *p; Line 141  const char *p;
 static const char str_newdisk[] = "newdisk";  static const char str_newdisk[] = "newdisk";
 static const UINT32 hddsizetbl[5] = {20, 41, 65, 80, 128};  static const UINT32 hddsizetbl[5] = {20, 41, 65, 80, 128};
   
   static const UINT16 sasires[6] = {
                                   IDC_NEWSASI5MB, IDC_NEWSASI10MB,
                                   IDC_NEWSASI15MB, IDC_NEWSASI20MB,
                                   IDC_NEWSASI30MB, IDC_NEWSASI40MB};
   
 static  BYTE    makefdtype = DISKTYPE_2HD << 4;  static  BYTE    makefdtype = DISKTYPE_2HD << 4;
 static  char    disklabel[16+1];  static  char    disklabel[16+1];
 static  UINT    hddsize;  static  UINT    hddsize;
   static  UINT    hddminsize;
   static  UINT    hddmaxsize;
   
 static LRESULT CALLBACK NewHddDlgProc(HWND hWnd, UINT msg,  static LRESULT CALLBACK NewHddDlgProc(HWND hWnd, UINT msg,
                                                                                                         WPARAM wp, LPARAM lp) {                                                                                                          WPARAM wp, LPARAM lp) {
Line 92  static LRESULT CALLBACK NewHddDlgProc(HW Line 161  static LRESULT CALLBACK NewHddDlgProc(HW
         switch (msg) {          switch (msg) {
                 case WM_INITDIALOG:                  case WM_INITDIALOG:
                         SETLISTUINT32(hWnd, IDC_HDDSIZE, hddsizetbl);                          SETLISTUINT32(hWnd, IDC_HDDSIZE, hddsizetbl);
                           SPRINTF(work, "(%d-%dMB)", hddminsize, hddmaxsize);
                           SetWindowText(GetDlgItem(hWnd, IDC_HDDLIMIT), work);
                         SetFocus(GetDlgItem(hWnd, IDC_HDDSIZE));                          SetFocus(GetDlgItem(hWnd, IDC_HDDSIZE));
                         return(FALSE);                          return(FALSE);
   
Line 101  static LRESULT CALLBACK NewHddDlgProc(HW Line 172  static LRESULT CALLBACK NewHddDlgProc(HW
                                         GetWindowText(GetDlgItem(hWnd, IDC_HDDSIZE),                                          GetWindowText(GetDlgItem(hWnd, IDC_HDDSIZE),
                                                                                                         work, sizeof(work));                                                                                                          work, sizeof(work));
                                         val = (UINT)milstr_solveINT(work);                                          val = (UINT)milstr_solveINT(work);
                                         if (val < 0) {                                          if (val < hddminsize) {
                                                 val = 0;                                                  val = hddminsize;
                                           }
                                           else if (val > hddmaxsize) {
                                                   val = hddmaxsize;
                                           }
                                           hddsize = val;
                                           EndDialog(hWnd, IDOK);
                                           break;
   
                                   case IDCANCEL:
                                           EndDialog(hWnd, IDCANCEL);
                                           break;
   
                                   default:
                                           return(FALSE);
                           }
                           break;
   
                   case WM_CLOSE:
                           PostMessage(hWnd, WM_COMMAND, IDCANCEL, 0);
                           break;
   
                   default:
                           return(FALSE);
           }
           return(TRUE);
   }
   
   static LRESULT CALLBACK NewSASIDlgProc(HWND hWnd, UINT msg,
                                                                                                           WPARAM wp, LPARAM lp) {
   
           UINT    val;
   
           switch (msg) {
                   case WM_INITDIALOG:
                           SetFocus(GetDlgItem(hWnd, IDC_NEWSASI5MB));
                           return(FALSE);
   
                   case WM_COMMAND:
                           switch (LOWORD(wp)) {
                                   case IDOK:
                                           for (val=0; val<6; val++) {
                                                   if (GetDlgItemCheck(hWnd, sasires[val])) {
                                                           break;
                                                   }
                                         }                                          }
                                         else if (val > 512) {                                          if (val > 3) {
                                                 val = 512;                                                  val++;
                                         }                                          }
                                         hddsize = val;                                          hddsize = val;
                                         EndDialog(hWnd, IDOK);                                          EndDialog(hWnd, IDOK);
Line 196  static LRESULT CALLBACK NewdiskDlgProc(H Line 311  static LRESULT CALLBACK NewdiskDlgProc(H
 void dialog_newdisk(HWND hWnd) {  void dialog_newdisk(HWND hWnd) {
   
         char            path[MAX_PATH];          char            path[MAX_PATH];
 const char              *p;  
         HINSTANCE       hinst;          HINSTANCE       hinst;
   const char              *ext;
   
         file_cpyname(path, fddfolder, sizeof(path));          file_cpyname(path, fddfolder, sizeof(path));
         file_cutname(path);          file_cutname(path);
         file_catname(path, str_newdisk, sizeof(path));          file_catname(path, str_newdisk, sizeof(path));
   
         p = dlgs_selectwritefile(hWnd, &newdiskui, path, NULL, 0);          if (!dlgs_selectwritefile(hWnd, &newdiskui, path, sizeof(path))) {
         if (p == NULL) {  
                 return;                  return;
         }          }
         hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);          hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
         if (!file_cmpname(file_getext((char *)p), str_thd)) {          ext = file_getext(path);
           if (!file_cmpname(ext, str_thd)) {
                   hddsize = 0;
                   hddminsize = 5;
                   hddmaxsize = 256;
                   if (DialogBox(hinst, MAKEINTRESOURCE(IDD_NEWHDDDISK),
                                                                           hWnd, (DLGPROC)NewHddDlgProc) == IDOK) {
                           newdisk_thd(path, hddsize);
                   }
           }
           else if (!file_cmpname(ext, str_nhd)) {
                   hddsize = 0;
                   hddminsize = 5;
                   hddmaxsize = 512;
                   if (DialogBox(hinst, MAKEINTRESOURCE(IDD_NEWHDDDISK),
                                                                           hWnd, (DLGPROC)NewHddDlgProc) == IDOK) {
                           newdisk_nhd(path, hddsize);
                   }
           }
           else if (!file_cmpname(ext, str_hdi)) {
                   hddsize = 7;
                   if (DialogBox(hinst, MAKEINTRESOURCE(IDD_NEWSASI),
                                                                           hWnd, (DLGPROC)NewSASIDlgProc) == IDOK) {
                           newdisk_hdi(path, hddsize);
                   }
           }
   #if defined(SUPPORT_SCSI)
           else if (!file_cmpname(ext, str_hdd)) {
                 hddsize = 0;                  hddsize = 0;
                   hddminsize = 2;
                   hddmaxsize = 512;
                 if (DialogBox(hinst, MAKEINTRESOURCE(IDD_NEWHDDDISK),                  if (DialogBox(hinst, MAKEINTRESOURCE(IDD_NEWHDDDISK),
                                                                         hWnd, (DLGPROC)NewHddDlgProc) == IDOK) {                                                                          hWnd, (DLGPROC)NewHddDlgProc) == IDOK) {
                         newdisk_thd(p, hddsize);        // (hddsize < 5) || (hddsize > 256)                          newdisk_vhd(path, hddsize);
                 }                  }
         }          }
         else {  #endif
           else if ((!file_cmpname(ext, str_d88)) ||
                           (!file_cmpname(ext, str_d98)) ||
                           (!file_cmpname(ext, str_88d)) ||
                           (!file_cmpname(ext, str_98d))) {
                 if (DialogBox(hinst,                  if (DialogBox(hinst,
                                 MAKEINTRESOURCE(np2cfg.usefd144?IDD_NEWDISK2:IDD_NEWDISK),                                  MAKEINTRESOURCE((np2cfg.usefd144)?IDD_NEWDISK2:IDD_NEWDISK),
                                                                         hWnd, (DLGPROC)NewdiskDlgProc) == IDOK) {                                                                          hWnd, (DLGPROC)NewdiskDlgProc) == IDOK) {
                         newdisk_fdd(p, makefdtype, disklabel);                          newdisk_fdd(path, makefdtype, disklabel);
                 }                  }
         }          }
 }  }

Removed from v.1.2  
changed lines
  Added in v.1.4


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