--- np2/win9x/np2.cpp 2005/03/20 23:48:02 1.62 +++ np2/win9x/np2.cpp 2007/12/28 22:12:05 1.76 @@ -8,7 +8,6 @@ #include "parts.h" #include "np2.h" #include "np2arg.h" -#include "cputype.h" #include "dosio.h" #include "extromio.h" #include "commng.h" @@ -23,7 +22,6 @@ #include "winloc.h" #include "sstp.h" #include "sstpmsg.h" -#include "dclock.h" #include "toolwin.h" #include "juliet.h" #include "np2class.h" @@ -45,6 +43,12 @@ #include "debugsub.h" #include "subwind.h" #include "viewer.h" +#if !defined(_WIN64) +#include "cputype.h" +#endif +#if defined(SUPPORT_DCLOCK) +#include "dclock.h" +#endif #ifdef BETA_RELEASE @@ -52,21 +56,19 @@ #endif static TCHAR szClassName[] = _T("NP2-MainWindow"); - HWND hWndMain; - HINSTANCE hInst; - HINSTANCE hPrev; + HWND g_hWndMain; + HINSTANCE g_hInstance; + HINSTANCE g_hPrevInst; +#if !defined(_WIN64) int mmxflag; +#endif UINT8 np2break = 0; // ver0.30 BOOL winui_en; NP2OSCFG np2oscfg = { -#if !defined(SUPPORT_PC9821) - OEMTEXT("Neko Project II"), -#else - OEMTEXT("Neko Project 21"), -#endif + OEMTEXT(PROJECTNAME) OEMTEXT(PROJECTSUBNAME), OEMTEXT("NP2"), - CW_USEDEFAULT, CW_USEDEFAULT, 1, 1, 0, 1, 0, 0, + CW_USEDEFAULT, CW_USEDEFAULT, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, KEY_UNKNOWN, 0, 0, 0, 0, {1, 2, 2, 1}, {5, 0, 0x3e, 19200, @@ -78,7 +80,7 @@ static TCHAR szClassName[] = _T("NP2-Ma {0, 0, 0x3e, 19200, OEMTEXT(""), OEMTEXT(""), OEMTEXT(""), OEMTEXT("")}, 0xffffff, 0xffbf6a, 0, 0, - 0, 1, 0, 9801, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + 0, 1, 0, 9801, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; OEMCHAR fddfolder[MAX_PATH]; OEMCHAR hddfolder[MAX_PATH]; @@ -91,13 +93,82 @@ static UINT framemax = 1; static UINT8 np2stopemulate = 0; static int np2opening = 1; static int np2quitmsg = 0; -static HMENU hStat = NULL; static UINT8 scrnmode; static WINLOCEX smwlex; +static HMODULE s_hModResource; static const OEMCHAR np2help[] = OEMTEXT("np2.chm"); static const OEMCHAR np2flagext[] = OEMTEXT("S%02d"); +#if defined(_WIN64) +static const OEMCHAR szNp2ResDll[] = OEMTEXT("np2x64_%u.dll"); +#else // defined(_WIN64) +static const OEMCHAR szNp2ResDll[] = OEMTEXT("np2_%u.dll"); +#endif // defined(_WIN64) + + +// ---- + +static int messagebox(HWND hWnd, LPCTSTR lpcszText, UINT uType) +{ + int nRet; + LPTSTR lpszText; + +#if defined(OSLANG_UTF8) + TCHAR szCation[128]; + oemtotchar(szCaption, NELEMENTS(szCaption), np2oscfg.titles, -1); +#else // defined(OSLANG_UTF8) + LPCTSTR szCaption = np2oscfg.titles; +#endif // defined(OSLANG_UTF8) + + nRet = 0; + if (HIWORD(lpcszText)) + { + nRet = MessageBox(hWnd, lpcszText, szCaption, uType); + } + else + { + lpszText = lockstringresource(lpcszText); + nRet = MessageBox(hWnd, lpszText, szCaption, uType); + unlockstringresource(lpszText); + } + return nRet; +} +// ---- + +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); +} + +static void unloadextinst(void) +{ + HMODULE hMod; + + hMod = s_hModResource; + s_hModResource = 0; + if (hMod) + { + FreeLibrary(hMod); + } +} + + +// ---- static void winuienter(void) { @@ -120,7 +191,7 @@ WINLOCEX np2_winlocexallwin(HWND base) { HWND list[5]; cnt = 0; - list[cnt++] = hWndMain; + list[cnt++] = g_hWndMain; list[cnt++] = toolwin_gethwnd(); list[cnt++] = kdispwin_gethwnd(); list[cnt++] = skbdwin_gethwnd(); @@ -130,7 +201,7 @@ WINLOCEX np2_winlocexallwin(HWND base) { list[i] = NULL; } } - if (base != hWndMain) { // hWndMainのみ全体移動 + if (base != g_hWndMain) { // hWndMainのみ全体移動 base = NULL; } return(winlocex_create(base, list, cnt)); @@ -159,8 +230,8 @@ static void changescreen(UINT8 newmode) mdbgwin_destroy(); } else if (renewal & SCRNMODE_ROTATEMASK) { - wlex = np2_winlocexallwin(hWndMain); - winlocex_setholdwnd(wlex, hWndMain); + wlex = np2_winlocexallwin(g_hWndMain); + winlocex_setholdwnd(wlex, g_hWndMain); } soundmng_stop(); mousemng_disable(MOUSEPROC_WINUI); @@ -178,10 +249,10 @@ static void changescreen(UINT8 newmode) if (renewal & SCRNMODE_FULLSCREEN) { if (!scrnmng_isfullscreen()) { if (np2oscfg.toolwin) { - toolwin_create(); + toolwin_create(g_hInstance); } if (np2oscfg.keydisp) { - kdispwin_create(); + kdispwin_create(g_hInstance); } } } @@ -215,7 +286,7 @@ static void wincentering(HWND hWnd) { np2oscfg.winy = 0; } sysmng_update(SYS_UPDATEOSCFG); - MoveWindow(hWndMain, np2oscfg.winx, np2oscfg.winy, width, height, TRUE); + MoveWindow(g_hWndMain, np2oscfg.winx, np2oscfg.winy, width, height, TRUE); } void np2active_renewal(void) { // ver0.30 @@ -279,37 +350,47 @@ static void flagdelete(const OEMCHAR *ex 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 nRet; + int nID; + OEMCHAR szPath[MAX_PATH]; + OEMCHAR szStat[1024]; + TCHAR szFormat[256]; + TCHAR szMessage[1024 + 256]; - int ret; - int id; - OEMCHAR path[MAX_PATH]; - OEMCHAR buf[1024]; - - getstatfilename(path, ext, NELEMENTS(path)); + getstatfilename(szPath, ext, NELEMENTS(szPath)); winuienter(); - id = IDYES; - ret = statsave_check(path, buf, NELEMENTS(buf)); - if (ret & (~STATFLAG_DISKCHG)) { - MessageBox(hWndMain, _T("Couldn't restart"), title, - MB_OK | MB_ICONSTOP); - id = IDNO; - } - else if ((!force) && (ret & STATFLAG_DISKCHG)) { - OEMCHAR buf2[1024 + 256]; - OEMSPRINTF(buf2, OEMTEXT("Conflict!\n\n%s\nContinue?"), buf); - id = MessageBox(hWndMain, buf2, title, - MB_YESNOCANCEL | MB_ICONQUESTION); - } - if (id == IDYES) { - statsave_load(path); + nID = IDYES; + nRet = statsave_check(szPath, szStat, NELEMENTS(szStat)); + if (nRet & (~STATFLAG_DISKCHG)) + { + messagebox(hWnd, MAKEINTRESOURCE(IDS_ERROR_RESUME), + MB_OK | MB_ICONSTOP); + nID = IDNO; + } + else if ((!force) && (nRet & STATFLAG_DISKCHG)) + { +#if defined(OSLANG_UTF8) + 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 (nID == IDYES) + { + statsave_load(szPath); toolwin_setfdd(0, fdd_diskname(0)); toolwin_setfdd(1, fdd_diskname(1)); } sysmng_workclockreset(); sysmng_updatecaption(1); winuileave(); - return(id); + return nID; } #endif @@ -322,7 +403,7 @@ static void np2popup(HWND hWnd, LPARAM l HMENU hMenu; POINT pt; - mainmenu = (HMENU)GetWindowLong(hWnd, NP2GWL_HMENU); + mainmenu = (HMENU)GetWindowLongPtr(hWnd, NP2GWLP_HMENU); if (mainmenu == NULL) { return; } @@ -335,27 +416,36 @@ static void np2popup(HWND hWnd, LPARAM l DestroyMenu(hMenu); } -static void np2cmd(HWND hWnd, UINT16 cmd) { - - UINT update; - BOOL b; +static void OnCommand(HWND hWnd, WPARAM wParam) +{ + HINSTANCE hInstance; + UINT update; + UINT uID; + BOOL b; + hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);; update = 0; - switch(cmd) { + uID = LOWORD(wParam); + switch(uID) + { case IDM_RESET: b = FALSE; - if (!np2oscfg.comfirm) { + if (!np2oscfg.comfirm) + { b = TRUE; } - else if (sstpconfirm_reset()) { + else if (sstpconfirm_reset()) + { winuienter(); - if (MessageBox(hWnd, OEMTEXT("Sure?"), OEMTEXT("Reset"), - MB_ICONQUESTION | MB_YESNO) == IDYES) { + if (messagebox(hWnd, MAKEINTRESOURCE(IDS_CONFIRM_RESET), + MB_ICONQUESTION | MB_YESNO) == IDYES) + { b = TRUE; } winuileave(); } - if (b) { + if (b) + { sstpmsg_reset(); juliet_YMF288Reset(); pccore_cfgupdate(); @@ -366,7 +456,7 @@ static void np2cmd(HWND hWnd, UINT16 cmd case IDM_CONFIG: winuienter(); sstpmsg_config(); - DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), + DialogBox(hInstance, MAKEINTRESOURCE(IDD_CONFIG), hWnd, (DLGPROC)CfgDialogProc); if (!scrnmng_isfullscreen()) { UINT8 thick; @@ -443,25 +533,38 @@ static void np2cmd(HWND hWnd, UINT16 cmd toolwin_setfdd(3, NULL); break; - case IDM_SASI1OPEN: + case IDM_IDE0OPEN: winuienter(); dialog_changehdd(hWnd, 0x00); winuileave(); break; - case IDM_SASI1EJECT: + case IDM_IDE0EJECT: diskdrv_sethdd(0x00, NULL); break; - case IDM_SASI2OPEN: + case IDM_IDE1OPEN: winuienter(); dialog_changehdd(hWnd, 0x01); winuileave(); break; - case IDM_SASI2EJECT: + case IDM_IDE1EJECT: diskdrv_sethdd(0x01, NULL); break; + +#if defined(SUPPORT_IDEIO) + case IDM_IDE2OPEN: + winuienter(); + dialog_changehdd(hWnd, 0x02); + winuileave(); + break; + + case IDM_IDE2EJECT: + diskdrv_sethdd(0x02, NULL); + break; +#endif + #if defined(SUPPORT_SCSI) case IDM_SCSI0OPEN: winuienter(); @@ -503,6 +606,7 @@ static void np2cmd(HWND hWnd, UINT16 cmd diskdrv_sethdd(0x23, NULL); break; #endif + case IDM_WINDOW: changescreen(scrnmode & (~SCRNMODE_FULLSCREEN)); break; @@ -739,6 +843,18 @@ static void np2cmd(HWND hWnd, UINT16 cmd update |= SYS_UPDATECFG; break; +#if defined(SUPPORT_PX) + case IDM_PX1: + xmenu_setsound(0x30); + update |= SYS_UPDATECFG; + break; + + case IDM_PX2: + xmenu_setsound(0x50); + update |= SYS_UPDATECFG; + break; +#endif // defined(SUPPORT_PX) + case IDM_JASTSOUND: xmenu_setjastsound(np2oscfg.jastsnd ^ 1); update |= SYS_UPDATEOSCFG; @@ -793,7 +909,7 @@ static void np2cmd(HWND hWnd, UINT16 cmd case IDM_MPUPC98: winuienter(); - DialogBox(hInst, MAKEINTRESOURCE(IDD_MPUPC98), + DialogBox(hInstance, MAKEINTRESOURCE(IDD_MPUPC98), hWnd, (DLGPROC)MidiDialogProc); winuileave(); break; @@ -841,7 +957,7 @@ static void np2cmd(HWND hWnd, UINT16 cmd case IDM_CALENDAR: winuienter(); - DialogBox(hInst, MAKEINTRESOURCE(IDD_CALENDAR), + DialogBox(hInstance, MAKEINTRESOURCE(IDD_CALENDAR), hWnd, (DLGPROC)ClndDialogProc); winuileave(); break; @@ -876,7 +992,7 @@ static void np2cmd(HWND hWnd, UINT16 cmd update |= SYS_UPDATECFG; break; - case IDM_I286SAVE: + case IDM_CPUSAVE: debugsub_status(); break; @@ -889,7 +1005,7 @@ static void np2cmd(HWND hWnd, UINT16 cmd sstpmsg_about(); if (sstp_result() != SSTP_SENDING) { winuienter(); - DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), + DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUT), hWnd, (DLGPROC)AboutDialogProc); winuileave(); } @@ -897,17 +1013,17 @@ static void np2cmd(HWND hWnd, UINT16 cmd default: #if defined(SUPPORT_STATSAVE) - if ((cmd >= IDM_FLAGSAVE) && - (cmd < (IDM_FLAGSAVE + SUPPORT_STATSAVE))) { + if ((uID >= IDM_FLAGSAVE) && + (uID < (IDM_FLAGSAVE + SUPPORT_STATSAVE))) { OEMCHAR ext[4]; - OEMSPRINTF(ext, np2flagext, cmd - IDM_FLAGSAVE); + OEMSPRINTF(ext, np2flagext, uID - IDM_FLAGSAVE); flagsave(ext); } - else if ((cmd >= IDM_FLAGLOAD) && - (cmd < (IDM_FLAGLOAD + SUPPORT_STATSAVE))) { + else if ((uID >= IDM_FLAGLOAD) && + (uID < (IDM_FLAGLOAD + SUPPORT_STATSAVE))) { OEMCHAR ext[4]; - OEMSPRINTF(ext, np2flagext, cmd - IDM_FLAGLOAD); - flagload(ext, OEMTEXT("Status Load"), TRUE); + OEMSPRINTF(ext, np2flagext, uID - IDM_FLAGLOAD); + flagload(hWnd, ext, _T("Status Load"), TRUE); } #endif break; @@ -941,7 +1057,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT case IDM_TOOLWIN: sysmenu_settoolwin(np2oscfg.toolwin ^ 1); if (np2oscfg.toolwin) { - toolwin_create(); + toolwin_create(g_hInstance); } else { toolwin_destroy(); @@ -953,7 +1069,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT case IDM_KEYDISP: sysmenu_setkeydisp(np2oscfg.keydisp ^ 1); if (np2oscfg.keydisp) { - kdispwin_create(); + kdispwin_create(g_hInstance); } else { kdispwin_destroy(); @@ -962,12 +1078,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT #endif #if defined(SUPPORT_SOFTKBD) case IDM_SOFTKBD: - skbdwin_create(); + skbdwin_create(g_hInstance); break; #endif #if defined(CPUCORE_IA32) && defined(SUPPORT_MEMDBG32) case IDM_MEMDBG32: - mdbgwin_create(); + mdbgwin_create(g_hInstance); break; #endif case IDM_SCREENCENTER: @@ -1001,7 +1117,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT break; case IDM_DEBUGUTY: - viewer_open(); + viewer_open(g_hInstance); break; case IDM_SCRNMUL4: @@ -1011,9 +1127,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT case IDM_SCRNMUL12: case IDM_SCRNMUL16: if ((!scrnmng_isfullscreen()) && - !(GetWindowLong(hWndMain, GWL_STYLE) & WS_MINIMIZE)) { - sysmenu_setscrnmul(wParam - IDM_SCRNMUL); - scrnmng_setmultiple(wParam - IDM_SCRNMUL); + !(GetWindowLong(g_hWndMain, GWL_STYLE) & WS_MINIMIZE)) + { + sysmenu_setscrnmul((UINT8)(wParam - IDM_SCRNMUL)); + scrnmng_setmultiple((int)(wParam - IDM_SCRNMUL)); } break; @@ -1049,7 +1166,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT break; case WM_COMMAND: - np2cmd(hWnd, LOWORD(wParam)); + OnCommand(hWnd, wParam); break; case WM_ACTIVATE: @@ -1069,7 +1186,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT case WM_PAINT: hdc = BeginPaint(hWnd, &ps); if (np2opening) { - HINSTANCE hinst; + HINSTANCE hInstance; RECT rect; int width; int height; @@ -1077,11 +1194,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT BITMAP bmp; HDC hmdc; HBRUSH hbrush; - hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); + hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE); GetClientRect(hWnd, &rect); width = rect.right - rect.left; height = rect.bottom - rect.top; - hbmp = LoadBitmap(hinst, _T("NP2BMP")); + hbmp = LoadBitmap(hInstance, _T("NP2BMP")); GetObject(hbmp, sizeof(BITMAP), &bmp); hbrush = (HBRUSH)SelectObject(hdc, GetStockObject(BLACK_BRUSH)); @@ -1157,7 +1274,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT case WM_KEYDOWN: if (wParam == VK_F11) { - np2class_enablemenu(hWndMain, TRUE); + np2class_enablemenu(g_hWndMain, TRUE); return(DefWindowProc(hWnd, WM_SYSKEYDOWN, VK_F10, lParam)); } if ((wParam == VK_F12) && (!np2oscfg.F12COPY)) { @@ -1214,14 +1331,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT HTCAPTION, 0L)); } } +#if defined(SUPPORT_DCLOCK) else { POINT p; - if ((GetCursorPos(&p)) && (p.y >= 466)) { + if ((GetCursorPos(&p)) && + (scrnmng_isdispclockclick(&p))) { np2oscfg.clk_x++; sysmng_update(SYS_UPDATEOSCFG); dclock_reset(); } } +#endif return(DefWindowProc(hWnd, msg, wParam, lParam)); } break; @@ -1243,15 +1363,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT if (!scrnmng_isfullscreen()) { np2popup(hWnd, lParam); } +#if defined(SUPPORT_DCLOCK) else { POINT p; - if ((GetCursorPos(&p)) && (p.y >= 466) && - (np2oscfg.clk_x)) { + if ((GetCursorPos(&p)) && + (scrnmng_isdispclockclick(&p)) && + (np2oscfg.clk_x)) { np2oscfg.clk_fnt++; sysmng_update(SYS_UPDATEOSCFG); dclock_reset(); } } +#endif return(DefWindowProc(hWnd, msg, wParam, lParam)); } break; @@ -1284,8 +1407,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT } else if (sstpconfirm_exit()) { winuienter(); - if (MessageBox(hWnd, _T("Sure?"), _T("Exit"), - MB_ICONQUESTION | MB_YESNO) == IDYES) { + if (messagebox(hWnd, MAKEINTRESOURCE(IDS_CONFIRM_EXIT), + MB_ICONQUESTION | MB_YESNO) == IDYES) + { b = TRUE; } winuileave(); @@ -1297,7 +1421,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT break; case WM_DESTROY: - DestroyMenu(hStat); np2class_wmdestroy(hWnd); PostQuitMessage(0); break; @@ -1365,7 +1488,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT static void framereset(UINT cnt) { framecnt = 0; +#if defined(SUPPORT_DCLOCK) scrnmng_dispclock(); +#endif kdispwin_draw((UINT8)cnt); skbdwin_process(); mdbgwin_process(); @@ -1390,8 +1515,7 @@ static void processwait(UINT cnt) { soundmng_sync(); } - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow) { WNDCLASS wc; MSG msg; @@ -1429,10 +1553,12 @@ int WINAPI WinMain(HINSTANCE hInstance, return(FALSE); } - hInst = hInstance; - hPrev = hPreInst; + g_hInstance = loadextinst(hInstance); + g_hPrevInst = hPrevInst; +#if !defined(_WIN64) mmxflag = (havemmx())?0:MMXFLAG_NOTSUPPORT; mmxflag += (np2oscfg.disablemmx)?MMXFLAG_DISABLE:0; +#endif TRACEINIT(); xrollkey = (np2oscfg.xrollkey == 0); @@ -1453,27 +1579,31 @@ int WINAPI WinMain(HINSTANCE hInstance, winkbd_setf12(np2oscfg.F12COPY); keystat_initialize(); - np2class_initialize(hInstance); - if (!hPreInst) { + np2class_initialize(g_hInstance); + if (!hPrevInst) { wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; - wc.cbWndExtra = NP2GWL_SIZE; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); + wc.cbWndExtra = NP2GWLP_SIZE; + wc.hInstance = g_hInstance; + wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON1)); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAIN); wc.lpszClassName = szClassName; if (!RegisterClass(&wc)) { + unloadextinst(); + TRACETERM(); + dosio_term(); return(FALSE); } + + toolwin_initapp(g_hInstance); + kdispwin_initialize(g_hInstance); + skbdwin_initialize(g_hInstance); + mdbgwin_initialize(g_hInstance); + viewer_init(g_hInstance); } - toolwin_initapp(hInstance); - kdispwin_initialize(hPreInst); - skbdwin_initialize(hPreInst); - mdbgwin_initialize(hPreInst); - viewer_init(hPreInst); mousemng_initialize(); @@ -1483,8 +1613,8 @@ int WINAPI WinMain(HINSTANCE hInstance, } hWnd = CreateWindowEx(0, szClassName, np2oscfg.titles, style, np2oscfg.winx, np2oscfg.winy, 640, 400, - NULL, NULL, hInstance, NULL); - hWndMain = hWnd; + NULL, NULL, g_hInstance, NULL); + g_hWndMain = hWnd; scrnmng_initialize(); xmenu_setroltate(0); @@ -1542,10 +1672,14 @@ int WINAPI WinMain(HINSTANCE hInstance, if (scrnmng_create(scrnmode) != SUCCESS) { scrnmode ^= SCRNMODE_FULLSCREEN; if (scrnmng_create(scrnmode) != SUCCESS) { - if (sstpmsg_dxerror()) { - MessageBox(hWnd, _T("Couldn't create DirectDraw Object"), - np2oscfg.titles, MB_OK | MB_ICONSTOP); + if (sstpmsg_dxerror()) + { + messagebox(hWnd, MAKEINTRESOURCE(IDS_ERROR_DIRECTDRAW), + MB_OK | MB_ICONSTOP); } + unloadextinst(); + TRACETERM(); + dosio_term(); return(FALSE); } } @@ -1589,7 +1723,7 @@ int WINAPI WinMain(HINSTANCE hInstance, if (np2oscfg.resume) { int id; - id = flagload(str_sav, str_resume, FALSE); + id = flagload(hWnd, str_sav, _T("Resume"), FALSE); if (id == IDYES) { for (i=0; i<4; i++) { np2arg.disk[i] = NULL; @@ -1603,10 +1737,11 @@ int WINAPI WinMain(HINSTANCE hInstance, sstp_destruct(); soundmng_deinitialize(); scrnmng_destroy(); + unloadextinst(); TRACETERM(); dosio_term(); viewer_term(); - return(0); + return(FALSE); } } #endif @@ -1620,10 +1755,10 @@ int WINAPI WinMain(HINSTANCE hInstance, if (!(scrnmode & SCRNMODE_FULLSCREEN)) { if (np2oscfg.toolwin) { - toolwin_create(); + toolwin_create(g_hInstance); } if (np2oscfg.keydisp) { - kdispwin_create(); + kdispwin_create(g_hInstance); } } @@ -1645,7 +1780,9 @@ int WINAPI WinMain(HINSTANCE hInstance, joymng_sync(); mousemng_sync(); pccore_exec(framecnt == 0); +#if defined(SUPPORT_DCLOCK) dclock_callback(); +#endif if (np2oscfg.DRAW_SKIP) { // nowait frame skip framecnt++; if (framecnt >= np2oscfg.DRAW_SKIP) { @@ -1664,7 +1801,9 @@ int WINAPI WinMain(HINSTANCE hInstance, joymng_sync(); mousemng_sync(); pccore_exec(framecnt == 0); +#if defined(SUPPORT_DCLOCK) dclock_callback(); +#endif framecnt++; } else { @@ -1677,7 +1816,9 @@ int WINAPI WinMain(HINSTANCE hInstance, joymng_sync(); mousemng_sync(); pccore_exec(framecnt == 0); +#if defined(SUPPORT_DCLOCK) dclock_callback(); +#endif framecnt++; cnt = timing_getcount(); if (framecnt > cnt) { @@ -1753,12 +1894,14 @@ int WINAPI WinMain(HINSTANCE hInstance, } skbdwin_deinitialize(); + unloadextinst(); + TRACETERM(); _MEM_USED("report.txt"); dosio_term(); viewer_term(); // ver0.30 - return(msg.wParam); + return((int)msg.wParam); }