| version 1.62, 2005/03/20 23:48:02 | version 1.66, 2006/12/23 23:34:32 | 
| Line 94  static int   np2quitmsg = 0; | Line 94  static int   np2quitmsg = 0; | 
 | static  HMENU           hStat = NULL; | static  HMENU           hStat = NULL; | 
 | static  UINT8           scrnmode; | static  UINT8           scrnmode; | 
 | static  WINLOCEX        smwlex; | static  WINLOCEX        smwlex; | 
 |  | static  HMODULE         resmod; | 
 |  |  | 
 | 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"); | 
 |  |  | 
 |  |  | 
 |  | // ---- | 
 |  |  | 
 |  | static HINSTANCE loadextinst(HINSTANCE hInstance) { | 
 |  |  | 
 |  | OEMCHAR path[MAX_PATH]; | 
 |  | OEMCHAR cpstr[16]; | 
 |  | HMODULE dll; | 
 |  |  | 
 |  | file_cpyname(path, modulefile, NELEMENTS(path)); | 
 |  | file_cutext(path); | 
 |  | OEMSPRINTF(cpstr, np2resext, GetOEMCP()); | 
 |  | file_catname(path, cpstr, NELEMENTS(path)); | 
 |  | dll = LoadLibrary(path); | 
 |  | resmod = dll; | 
 |  | if (dll != NULL) { | 
 |  | hInstance = (HINSTANCE)dll; | 
 |  | } | 
 |  | return(hInstance); | 
 |  | } | 
 |  |  | 
 |  | static void unloadextinst(void) { | 
 |  |  | 
 |  | HMODULE dll; | 
 |  |  | 
 |  | dll = resmod; | 
 |  | if (dll) { | 
 |  | resmod = 0; | 
 |  | FreeLibrary(dll); | 
 |  | } | 
 |  | } | 
 |  |  | 
 |  |  | 
 |  | // ---- | 
 |  |  | 
 | static void winuienter(void) { | static void winuienter(void) { | 
 |  |  | 
 | winui_en = TRUE; | winui_en = TRUE; | 
| Line 337  static void np2popup(HWND hWnd, LPARAM l | Line 373  static void np2popup(HWND hWnd, LPARAM l | 
 |  |  | 
 | static void np2cmd(HWND hWnd, UINT16 cmd) { | static void np2cmd(HWND hWnd, UINT16 cmd) { | 
 |  |  | 
| UINT    update; | HINSTANCE       hInst; | 
| BOOL    b; | UINT            update; | 
|  | BOOL            b; | 
 |  |  | 
 |  | hInst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); | 
 | update = 0; | update = 0; | 
 | switch(cmd) { | switch(cmd) { | 
 | case IDM_RESET: | case IDM_RESET: | 
| Line 443  static void np2cmd(HWND hWnd, UINT16 cmd | Line 481  static void np2cmd(HWND hWnd, UINT16 cmd | 
 | toolwin_setfdd(3, NULL); | toolwin_setfdd(3, NULL); | 
 | break; | break; | 
 |  |  | 
| case IDM_SASI1OPEN: | case IDM_IDE0OPEN: | 
 | winuienter(); | winuienter(); | 
 | dialog_changehdd(hWnd, 0x00); | dialog_changehdd(hWnd, 0x00); | 
 | winuileave(); | winuileave(); | 
 | break; | break; | 
 |  |  | 
| case IDM_SASI1EJECT: | case IDM_IDE0EJECT: | 
 | diskdrv_sethdd(0x00, NULL); | diskdrv_sethdd(0x00, NULL); | 
 | break; | break; | 
 |  |  | 
| case IDM_SASI2OPEN: | case IDM_IDE1OPEN: | 
 | winuienter(); | winuienter(); | 
 | dialog_changehdd(hWnd, 0x01); | dialog_changehdd(hWnd, 0x01); | 
 | winuileave(); | winuileave(); | 
 | break; | break; | 
 |  |  | 
| case IDM_SASI2EJECT: | case IDM_IDE1EJECT: | 
 | diskdrv_sethdd(0x01, NULL); | diskdrv_sethdd(0x01, NULL); | 
 | break; | 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) | #if defined(SUPPORT_SCSI) | 
 | case IDM_SCSI0OPEN: | case IDM_SCSI0OPEN: | 
 | winuienter(); | winuienter(); | 
| Line 503  static void np2cmd(HWND hWnd, UINT16 cmd | Line 554  static void np2cmd(HWND hWnd, UINT16 cmd | 
 | diskdrv_sethdd(0x23, NULL); | diskdrv_sethdd(0x23, NULL); | 
 | break; | break; | 
 | #endif | #endif | 
 |  |  | 
 | case IDM_WINDOW: | case IDM_WINDOW: | 
 | changescreen(scrnmode & (~SCRNMODE_FULLSCREEN)); | changescreen(scrnmode & (~SCRNMODE_FULLSCREEN)); | 
 | break; | break; | 
| Line 876  static void np2cmd(HWND hWnd, UINT16 cmd | Line 928  static void np2cmd(HWND hWnd, UINT16 cmd | 
 | update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; | 
 | break; | break; | 
 |  |  | 
| case IDM_I286SAVE: | case IDM_CPUSAVE: | 
 | debugsub_status(); | debugsub_status(); | 
 | break; | break; | 
 |  |  | 
| Line 1390  static void processwait(UINT cnt) { | Line 1442  static void processwait(UINT cnt) { | 
 | soundmng_sync(); | soundmng_sync(); | 
 | } | } | 
 |  |  | 
 |  |  | 
 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, | 
 | LPSTR lpszCmdLine, int nCmdShow) { | LPSTR lpszCmdLine, int nCmdShow) { | 
 | WNDCLASS        wc; | WNDCLASS        wc; | 
| Line 1429  int WINAPI WinMain(HINSTANCE hInstance, | Line 1480  int WINAPI WinMain(HINSTANCE hInstance, | 
 | return(FALSE); | return(FALSE); | 
 | } | } | 
 |  |  | 
| hInst = hInstance; | hInst = loadextinst(hInstance); | 
 | hPrev = hPreInst; | hPrev = hPreInst; | 
 | mmxflag = (havemmx())?0:MMXFLAG_NOTSUPPORT; | mmxflag = (havemmx())?0:MMXFLAG_NOTSUPPORT; | 
 | mmxflag += (np2oscfg.disablemmx)?MMXFLAG_DISABLE:0; | mmxflag += (np2oscfg.disablemmx)?MMXFLAG_DISABLE:0; | 
| Line 1453  int WINAPI WinMain(HINSTANCE hInstance, | Line 1504  int WINAPI WinMain(HINSTANCE hInstance, | 
 | winkbd_setf12(np2oscfg.F12COPY); | winkbd_setf12(np2oscfg.F12COPY); | 
 | keystat_initialize(); | keystat_initialize(); | 
 |  |  | 
| np2class_initialize(hInstance); | np2class_initialize(hInst); | 
 | if (!hPreInst) { | if (!hPreInst) { | 
 | 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 = NP2GWL_SIZE; | wc.cbWndExtra = NP2GWL_SIZE; | 
| wc.hInstance = hInstance; | wc.hInstance = hInst; | 
| wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); | wc.hIcon = LoadIcon(hInst, 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); | 
 | wc.lpszClassName = szClassName; | wc.lpszClassName = szClassName; | 
 | if (!RegisterClass(&wc)) { | if (!RegisterClass(&wc)) { | 
 |  | unloadextinst(); | 
 |  | TRACETERM(); | 
 |  | dosio_term(); | 
 | return(FALSE); | return(FALSE); | 
 | } | } | 
 | } | } | 
| toolwin_initapp(hInstance); | toolwin_initapp(hInst); | 
 | kdispwin_initialize(hPreInst); | kdispwin_initialize(hPreInst); | 
 | skbdwin_initialize(hPreInst); | skbdwin_initialize(hPreInst); | 
 | mdbgwin_initialize(hPreInst); | mdbgwin_initialize(hPreInst); | 
| Line 1483  int WINAPI WinMain(HINSTANCE hInstance, | Line 1537  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, hInst, NULL); | 
 | hWndMain = hWnd; | hWndMain = hWnd; | 
 | scrnmng_initialize(); | scrnmng_initialize(); | 
 |  |  | 
| Line 1546  int WINAPI WinMain(HINSTANCE hInstance, | Line 1600  int WINAPI WinMain(HINSTANCE hInstance, | 
 | MessageBox(hWnd, _T("Couldn't create DirectDraw Object"), | MessageBox(hWnd, _T("Couldn't create DirectDraw Object"), | 
 | np2oscfg.titles, MB_OK | MB_ICONSTOP); | np2oscfg.titles, MB_OK | MB_ICONSTOP); | 
 | } | } | 
 |  | unloadextinst(); | 
 |  | TRACETERM(); | 
 |  | dosio_term(); | 
 | return(FALSE); | return(FALSE); | 
 | } | } | 
 | } | } | 
| Line 1603  int WINAPI WinMain(HINSTANCE hInstance, | Line 1660  int WINAPI WinMain(HINSTANCE hInstance, | 
 | sstp_destruct(); | sstp_destruct(); | 
 | soundmng_deinitialize(); | soundmng_deinitialize(); | 
 | scrnmng_destroy(); | scrnmng_destroy(); | 
 |  | unloadextinst(); | 
 | TRACETERM(); | TRACETERM(); | 
 | dosio_term(); | dosio_term(); | 
 | viewer_term(); | viewer_term(); | 
| return(0); | return(FALSE); | 
 | } | } | 
 | } | } | 
 | #endif | #endif | 
| Line 1753  int WINAPI WinMain(HINSTANCE hInstance, | Line 1811  int WINAPI WinMain(HINSTANCE hInstance, | 
 | } | } | 
 | skbdwin_deinitialize(); | skbdwin_deinitialize(); | 
 |  |  | 
 |  | unloadextinst(); | 
 |  |  | 
 | TRACETERM(); | TRACETERM(); | 
 | _MEM_USED("report.txt"); | _MEM_USED("report.txt"); | 
 | dosio_term(); | dosio_term(); |