Diff for /np2/win9x/np2.cpp between versions 1.74 and 1.75

version 1.74, 2007/11/11 07:11:27 version 1.75, 2007/12/28 20:36:39
Line 93  static UINT  framemax = 1; Line 93  static UINT  framemax = 1;
 static  UINT8           np2stopemulate = 0;  static  UINT8           np2stopemulate = 0;
 static  int                     np2opening = 1;  static  int                     np2opening = 1;
 static  int                     np2quitmsg = 0;  static  int                     np2quitmsg = 0;
 static  HMENU           hStat = NULL;  
 static  UINT8           scrnmode;  static  UINT8           scrnmode;
 static  WINLOCEX        smwlex;  static  WINLOCEX        smwlex;
 static  HMODULE         resmod;  static  HMODULE         s_hModResource;
   
 static const OEMCHAR np2help[] = OEMTEXT("np2.chm");  static const OEMCHAR np2help[] = OEMTEXT("np2.chm");
 static const OEMCHAR np2flagext[] = OEMTEXT("S%02d");  static const OEMCHAR np2flagext[] = OEMTEXT("S%02d");
 static const OEMCHAR np2resext[] = OEMTEXT(".%u");  #if defined(_WIN64)
   static const OEMCHAR szNp2ResDll[] = OEMTEXT("np2x64_%u.dll");
   #else   // defined(_WIN64)
   static const OEMCHAR szNp2ResDll[] = OEMTEXT("np2_%u.dll");
   #endi   // defined(_WIN64)
   
   
 // ----  // ----
   
 static HINSTANCE loadextinst(HINSTANCE hInstance) {  static int messagebox(HWND hWnd, LPCTSTR lpcszText, UINT uType)
   {
           int             nRet;
           LPTSTR  lpszText;
   
         OEMCHAR path[MAX_PATH];  #if defined(OSLANG_UTF8)
         OEMCHAR cpstr[16];          TCHAR szCation[128];
         HMODULE dll;          oemtotchar(szCaption, NELEMENTS(szCaption), np2oscfg.titles, -1);
   #else   // defined(OSLANG_UTF8)
           LPCTSTR szCaption = np2oscfg.titles;
   #endif  // defined(OSLANG_UTF8)
   
         file_cpyname(path, modulefile, NELEMENTS(path));          nRet = 0;
         file_cutext(path);          if (HIWORD(lpcszText))
         OEMSPRINTF(cpstr, np2resext, GetOEMCP());          {
         file_catname(path, cpstr, NELEMENTS(path));                  nRet = MessageBox(hWnd, lpcszText, szCaption, uType);
         dll = LoadLibrary(path);  
         resmod = dll;  
         if (dll != NULL) {  
                 hInstance = (HINSTANCE)dll;  
         }          }
         return(hInstance);          else
           {
                   lpszText = lockstringresource(lpcszText);
                   nRet = MessageBox(hWnd, lpszText, szCaption, uType);
                   unlockstringresource(lpszText);
           }
           return nRet;
 }  }
   
 static void unloadextinst(void) {  // ----
   
         HMODULE dll;  static HINSTANCE loadextinst(HINSTANCE hInstance)
   {
           OEMCHAR szPath[MAX_PATH];
           OEMCHAR szDllName[32];
           HMODULE hMod;
   
           file_cpyname(szPath, modulefile, NELEMENTS(szPath));
           file_cutname(szPath);
           OEMSPRINTF(szDllName, szNp2ResDll, GetOEMCP());
           file_catname(szPath, szDllName, NELEMENTS(szPath));
           hMod = LoadLibrary(szPath);
           s_hModResource = hMod;
           if (hMod != NULL)
           {
                   hInstance = (HINSTANCE)hMod;
           }
           return(hInstance);
   }
   
         dll = resmod;  static void unloadextinst(void)
         if (dll) {  {
                 resmod = 0;          HMODULE hMod;
                 FreeLibrary(dll);  
           hMod = s_hModResource;
           s_hModResource = 0;
           if (hMod)
           {
                   FreeLibrary(hMod);
         }          }
 }  }
   
Line 317  static void flagdelete(const OEMCHAR *ex Line 350  static void flagdelete(const OEMCHAR *ex
         file_delete(path);          file_delete(path);
 }  }
   
 static int flagload(const OEMCHAR *ext, const OEMCHAR *title, BOOL force) {  static int flagload(HWND hWnd, const OEMCHAR *ext, LPCTSTR title, BOOL force)
   {
         int             ret;          int             nRet;
         int             id;          int             nID;
         OEMCHAR path[MAX_PATH];          OEMCHAR szPath[MAX_PATH];
         OEMCHAR buf[1024];          OEMCHAR szStat[1024];
           TCHAR   szFormat[256];
           TCHAR   szMessage[1024 + 256];
   
         getstatfilename(path, ext, NELEMENTS(path));          getstatfilename(szPath, ext, NELEMENTS(szPath));
         winuienter();          winuienter();
         id = IDYES;          nID = IDYES;
         ret = statsave_check(path, buf, NELEMENTS(buf));          nRet = statsave_check(szPath, szStat, NELEMENTS(szStat));
         if (ret & (~STATFLAG_DISKCHG)) {          if (nRet & (~STATFLAG_DISKCHG))
                 MessageBox(g_hWndMain, _T("Couldn't restart"), title,          {
                                                                                 MB_OK | MB_ICONSTOP);                  messagebox(hWnd, MAKEINTRESOURCE(IDS_ERROR_RESUME),
                 id = IDNO;                                                                                                          MB_OK | MB_ICONSTOP);
         }                  nID = IDNO;
         else if ((!force) && (ret & STATFLAG_DISKCHG)) {          }
                 OEMCHAR buf2[1024 + 256];          else if ((!force) && (nRet & STATFLAG_DISKCHG))
                 OEMSPRINTF(buf2, OEMTEXT("Conflict!\n\n%s\nContinue?"), buf);          {
                 id = MessageBox(g_hWndMain, buf2, title,  #if defined(OSLANG_UTF8)
                                                                                 MB_YESNOCANCEL | MB_ICONQUESTION);                  TCHAR szStat2[128];
                   oemtotchar(szStat2, NELEMENTS(szStat2), szStat, -1);
   #else   // defined(OSLANG_UTF8)
                   LPCTSTR szStat2 = szStat;
   #endif  // defined(OSLANG_UTF8)
                   loadstringresource(IDS_CONFIRM_RESUME, szFormat, NELEMENTS(szFormat));
                   wsprintf(szMessage, szFormat, szStat2);
                   nID = messagebox(hWnd, szMessage, MB_YESNOCANCEL | MB_ICONQUESTION);
         }          }
         if (id == IDYES) {          if (nID == IDYES)
                 statsave_load(path);          {
                   statsave_load(szPath);
                 toolwin_setfdd(0, fdd_diskname(0));                  toolwin_setfdd(0, fdd_diskname(0));
                 toolwin_setfdd(1, fdd_diskname(1));                  toolwin_setfdd(1, fdd_diskname(1));
         }          }
         sysmng_workclockreset();          sysmng_workclockreset();
         sysmng_updatecaption(1);          sysmng_updatecaption(1);
         winuileave();          winuileave();
         return(id);          return nID;
 }  }
 #endif  #endif
   
Line 380  static void OnCommand(HWND hWnd, WPARAM  Line 423  static void OnCommand(HWND hWnd, WPARAM 
         UINT            uID;          UINT            uID;
         BOOL            b;          BOOL            b;
   
         hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);          hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);;
         update = 0;          update = 0;
         uID = LOWORD(wParam);          uID = LOWORD(wParam);
         switch(uID)          switch(uID)
         {          {
                 case IDM_RESET:                  case IDM_RESET:
                         b = FALSE;                          b = FALSE;
                         if (!np2oscfg.comfirm) {                          if (!np2oscfg.comfirm)
                           {
                                 b = TRUE;                                  b = TRUE;
                         }                          }
                         else if (sstpconfirm_reset()) {                          else if (sstpconfirm_reset())
                           {
                                 winuienter();                                  winuienter();
                                 if (MessageBox(hWnd, OEMTEXT("Sure?"), OEMTEXT("Reset"),                                  if (messagebox(hWnd, MAKEINTRESOURCE(IDS_CONFIRM_RESET),
                                                                         MB_ICONQUESTION | MB_YESNO) == IDYES) {                                                                          MB_ICONQUESTION | MB_YESNO) == IDYES)
                                   {
                                         b = TRUE;                                          b = TRUE;
                                 }                                  }
                                 winuileave();                                  winuileave();
                         }                          }
                         if (b) {                          if (b)
                           {
                                 sstpmsg_reset();                                  sstpmsg_reset();
                                 juliet_YMF288Reset();                                  juliet_YMF288Reset();
                                 pccore_cfgupdate();                                  pccore_cfgupdate();
Line 976  static void OnCommand(HWND hWnd, WPARAM  Line 1023  static void OnCommand(HWND hWnd, WPARAM 
                                 (uID < (IDM_FLAGLOAD + SUPPORT_STATSAVE))) {                                  (uID < (IDM_FLAGLOAD + SUPPORT_STATSAVE))) {
                                 OEMCHAR ext[4];                                  OEMCHAR ext[4];
                                 OEMSPRINTF(ext, np2flagext, uID - IDM_FLAGLOAD);                                  OEMSPRINTF(ext, np2flagext, uID - IDM_FLAGLOAD);
                                 flagload(ext, OEMTEXT("Status Load"), TRUE);                                  flagload(hWnd, ext, _T("Status Load"), TRUE);
                         }                          }
 #endif  #endif
                         break;                          break;
Line 1360  LRESULT CALLBACK WndProc(HWND hWnd, UINT Line 1407  LRESULT CALLBACK WndProc(HWND hWnd, UINT
                         }                          }
                         else if (sstpconfirm_exit()) {                          else if (sstpconfirm_exit()) {
                                 winuienter();                                  winuienter();
                                 if (MessageBox(hWnd, _T("Sure?"), _T("Exit"),                                  if (messagebox(hWnd, MAKEINTRESOURCE(IDS_CONFIRM_EXIT),
                                                                         MB_ICONQUESTION | MB_YESNO) == IDYES) {                                                                          MB_ICONQUESTION | MB_YESNO) == IDYES)
                                   {
                                         b = TRUE;                                          b = TRUE;
                                 }                                  }
                                 winuileave();                                  winuileave();
Line 1373  LRESULT CALLBACK WndProc(HWND hWnd, UINT Line 1421  LRESULT CALLBACK WndProc(HWND hWnd, UINT
                         break;                          break;
   
                 case WM_DESTROY:                  case WM_DESTROY:
                         DestroyMenu(hStat);  
                         np2class_wmdestroy(hWnd);                          np2class_wmdestroy(hWnd);
                         PostQuitMessage(0);                          PostQuitMessage(0);
                         break;                          break;
Line 1532  int WINAPI WinMain(HINSTANCE hInstance,  Line 1579  int WINAPI WinMain(HINSTANCE hInstance, 
         winkbd_setf12(np2oscfg.F12COPY);          winkbd_setf12(np2oscfg.F12COPY);
         keystat_initialize();          keystat_initialize();
   
         np2class_initialize(hInstance);          np2class_initialize(g_hInstance);
         if (!hPrevInst) {          if (!hPrevInst) {
                 wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;                  wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
                 wc.lpfnWndProc = WndProc;                  wc.lpfnWndProc = WndProc;
                 wc.cbClsExtra = 0;                  wc.cbClsExtra = 0;
                 wc.cbWndExtra = NP2GWLP_SIZE;                  wc.cbWndExtra = NP2GWLP_SIZE;
                 wc.hInstance = hInstance;                  wc.hInstance = g_hInstance;
                 wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));                  wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON1));
                 wc.hCursor = LoadCursor(NULL, IDC_ARROW);                  wc.hCursor = LoadCursor(NULL, IDC_ARROW);
                 wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);                  wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
                 wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAIN);                  wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAIN);
Line 1551  int WINAPI WinMain(HINSTANCE hInstance,  Line 1598  int WINAPI WinMain(HINSTANCE hInstance, 
                         return(FALSE);                          return(FALSE);
                 }                  }
   
                 toolwin_initapp(hInstance);                  toolwin_initapp(g_hInstance);
                 kdispwin_initialize(hInstance);                  kdispwin_initialize(g_hInstance);
                 skbdwin_initialize(hInstance);                  skbdwin_initialize(g_hInstance);
                 mdbgwin_initialize(hInstance);                  mdbgwin_initialize(g_hInstance);
                 viewer_init(hInstance);                  viewer_init(g_hInstance);
         }          }
   
         mousemng_initialize();          mousemng_initialize();
Line 1566  int WINAPI WinMain(HINSTANCE hInstance,  Line 1613  int WINAPI WinMain(HINSTANCE hInstance, 
         }          }
         hWnd = CreateWindowEx(0, szClassName, np2oscfg.titles, style,          hWnd = CreateWindowEx(0, szClassName, np2oscfg.titles, style,
                                                 np2oscfg.winx, np2oscfg.winy, 640, 400,                                                  np2oscfg.winx, np2oscfg.winy, 640, 400,
                                                 NULL, NULL, hInstance, NULL);                                                  NULL, NULL, g_hInstance, NULL);
         g_hWndMain = hWnd;          g_hWndMain = hWnd;
         scrnmng_initialize();          scrnmng_initialize();
   
Line 1625  int WINAPI WinMain(HINSTANCE hInstance,  Line 1672  int WINAPI WinMain(HINSTANCE hInstance, 
         if (scrnmng_create(scrnmode) != SUCCESS) {          if (scrnmng_create(scrnmode) != SUCCESS) {
                 scrnmode ^= SCRNMODE_FULLSCREEN;                  scrnmode ^= SCRNMODE_FULLSCREEN;
                 if (scrnmng_create(scrnmode) != SUCCESS) {                  if (scrnmng_create(scrnmode) != SUCCESS) {
                         if (sstpmsg_dxerror()) {                          if (sstpmsg_dxerror())
                                 MessageBox(hWnd, _T("Couldn't create DirectDraw Object"),                          {
                                                                                 np2oscfg.titles, MB_OK | MB_ICONSTOP);                                  messagebox(hWnd, MAKEINTRESOURCE(IDS_ERROR_DIRECTDRAW),
                                                                                                                   MB_OK | MB_ICONSTOP);
                         }                          }
                         unloadextinst();                          unloadextinst();
                         TRACETERM();                          TRACETERM();
Line 1675  int WINAPI WinMain(HINSTANCE hInstance,  Line 1723  int WINAPI WinMain(HINSTANCE hInstance, 
         if (np2oscfg.resume) {          if (np2oscfg.resume) {
                 int             id;                  int             id;
   
                 id = flagload(str_sav, str_resume, FALSE);                  id = flagload(hWnd, str_sav, _T("Resume"), FALSE);
                 if (id == IDYES) {                  if (id == IDYES) {
                         for (i=0; i<4; i++) {                          for (i=0; i<4; i++) {
                                 np2arg.disk[i] = NULL;                                  np2arg.disk[i] = NULL;
Line 1707  int WINAPI WinMain(HINSTANCE hInstance,  Line 1755  int WINAPI WinMain(HINSTANCE hInstance, 
   
         if (!(scrnmode & SCRNMODE_FULLSCREEN)) {          if (!(scrnmode & SCRNMODE_FULLSCREEN)) {
                 if (np2oscfg.toolwin) {                  if (np2oscfg.toolwin) {
                         toolwin_create(hInstance);                          toolwin_create(g_hInstance);
                 }                  }
                 if (np2oscfg.keydisp) {                  if (np2oscfg.keydisp) {
                         kdispwin_create(hInstance);                          kdispwin_create(g_hInstance);
                 }                  }
         }          }
   

Removed from v.1.74  
changed lines
  Added in v.1.75


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