--- np2/win9x/np2.cpp 2004/04/16 06:14:57 1.51 +++ np2/win9x/np2.cpp 2005/03/24 01:42:47 1.64 @@ -51,43 +51,52 @@ #define OPENING_WAIT 1500 #endif -static char szClassName[] = "NP2-MainWindow"; +static TCHAR szClassName[] = _T("NP2-MainWindow"); HWND hWndMain; HINSTANCE hInst; HINSTANCE hPrev; int mmxflag; - BYTE np2break = 0; // ver0.30 + UINT8 np2break = 0; // ver0.30 BOOL winui_en; NP2OSCFG np2oscfg = { - "Neko Project II", "NP2", +#if !defined(SUPPORT_PC9821) + OEMTEXT("Neko Project II"), +#else + OEMTEXT("Neko Project 21"), +#endif + OEMTEXT("NP2"), CW_USEDEFAULT, CW_USEDEFAULT, 1, 1, 0, 1, 0, 0, 0, 0, KEY_UNKNOWN, 0, 0, 0, 0, {1, 2, 2, 1}, - {5, 0, 0x3e, 19200, "", "", "", ""}, // ver0.34 - {0, 0, 0x3e, 19200, "", "", "", ""}, // ver0.34 - {0, 0, 0x3e, 19200, "", "", "", ""}, // ver0.34 - {0, 0, 0x3e, 19200, "", "", "", ""}, // ver0.34 + {5, 0, 0x3e, 19200, + OEMTEXT(""), OEMTEXT(""), OEMTEXT(""), OEMTEXT("")}, + {0, 0, 0x3e, 19200, + OEMTEXT(""), OEMTEXT(""), OEMTEXT(""), OEMTEXT("")}, + {0, 0, 0x3e, 19200, + OEMTEXT(""), OEMTEXT(""), OEMTEXT(""), OEMTEXT("")}, + {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, 1, 0, 9801, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - char fddfolder[MAX_PATH]; - char hddfolder[MAX_PATH]; - char bmpfilefolder[MAX_PATH]; - char modulefile[MAX_PATH]; + OEMCHAR fddfolder[MAX_PATH]; + OEMCHAR hddfolder[MAX_PATH]; + OEMCHAR bmpfilefolder[MAX_PATH]; + OEMCHAR modulefile[MAX_PATH]; static UINT framecnt = 0; static UINT waitcnt = 0; static UINT framemax = 1; -static BYTE np2stopemulate = 0; +static UINT8 np2stopemulate = 0; static int np2opening = 1; static int np2quitmsg = 0; static HMENU hStat = NULL; -static BYTE scrnmode; +static UINT8 scrnmode; static WINLOCEX smwlex; -static const char np2help[] = "np2.chm"; -static const char np2flagext[] = "S%02d"; +static const OEMCHAR np2help[] = OEMTEXT("np2.chm"); +static const OEMCHAR np2flagext[] = OEMTEXT("S%02d"); static void winuienter(void) { @@ -127,10 +136,10 @@ WINLOCEX np2_winlocexallwin(HWND base) { return(winlocex_create(base, list, cnt)); } -static void changescreen(BYTE newmode) { +static void changescreen(UINT8 newmode) { - BYTE change; - BYTE renewal; + UINT8 change; + UINT8 renewal; WINLOCEX wlex; change = scrnmode ^ newmode; @@ -209,7 +218,7 @@ static void wincentering(HWND hWnd) { MoveWindow(hWndMain, np2oscfg.winx, np2oscfg.winy, width, height, TRUE); } -void np2active_renewal(void) { // ver0.30 +void np2active_renewal(void) { // ver0.30 if (np2break & (~NP2BREAK_MAIN)) { np2stopemulate = 2; @@ -239,7 +248,7 @@ void np2active_renewal(void) { / // ---- resume and statsave #if defined(SUPPORT_RESUME) || defined(SUPPORT_STATSAVE) -static void getstatfilename(char *path, const char *ext, int size) { +static void getstatfilename(OEMCHAR *path, const OEMCHAR *ext, int size) { file_cpyname(path, modulefile, size); file_cutext(path); @@ -247,12 +256,12 @@ static void getstatfilename(char *path, file_catname(path, ext, size); } -static int flagsave(const char *ext) { +static int flagsave(const OEMCHAR *ext) { int ret; - char path[MAX_PATH]; + OEMCHAR path[MAX_PATH]; - getstatfilename(path, ext, sizeof(path)); + getstatfilename(path, ext, NELEMENTS(path)); soundmng_stop(); ret = statsave_save(path); if (ret) { @@ -262,32 +271,33 @@ static int flagsave(const char *ext) { return(ret); } -static void flagdelete(const char *ext) { +static void flagdelete(const OEMCHAR *ext) { - char path[MAX_PATH]; + OEMCHAR path[MAX_PATH]; - getstatfilename(path, ext, sizeof(path)); + getstatfilename(path, ext, NELEMENTS(path)); file_delete(path); } -static int flagload(const char *ext, const char *title, BOOL force) { +static int flagload(const OEMCHAR *ext, const OEMCHAR *title, BOOL force) { int ret; int id; - char path[MAX_PATH]; - char buf[1024]; + OEMCHAR path[MAX_PATH]; + OEMCHAR buf[1024]; - getstatfilename(path, ext, sizeof(path)); + getstatfilename(path, ext, NELEMENTS(path)); winuienter(); id = IDYES; - ret = statsave_check(path, buf, sizeof(buf)); + ret = statsave_check(path, buf, NELEMENTS(buf)); if (ret & (~STATFLAG_DISKCHG)) { - MessageBox(hWndMain, "Couldn't restart", title, MB_OK | MB_ICONSTOP); + MessageBox(hWndMain, _T("Couldn't restart"), title, + MB_OK | MB_ICONSTOP); id = IDNO; } else if ((!force) && (ret & STATFLAG_DISKCHG)) { - char buf2[1024 + 256]; - wsprintf(buf2, "Conflict!\n\n%s\nContinue?", buf); + OEMCHAR buf2[1024 + 256]; + OEMSPRINTF(buf2, OEMTEXT("Conflict!\n\n%s\nContinue?"), buf); id = MessageBox(hWndMain, buf2, title, MB_YESNOCANCEL | MB_ICONQUESTION); } @@ -339,7 +349,7 @@ static void np2cmd(HWND hWnd, UINT16 cmd } else if (sstpconfirm_reset()) { winuienter(); - if (MessageBox(hWnd, "Sure?", "Reset", + if (MessageBox(hWnd, OEMTEXT("Sure?"), OEMTEXT("Reset"), MB_ICONQUESTION | MB_YESNO) == IDYES) { b = TRUE; } @@ -358,6 +368,18 @@ static void np2cmd(HWND hWnd, UINT16 cmd sstpmsg_config(); DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), hWnd, (DLGPROC)CfgDialogProc); + if (!scrnmng_isfullscreen()) { + UINT8 thick; + thick = (GetWindowLong(hWnd, GWL_STYLE) & WS_THICKFRAME)?1:0; + if (thick != np2oscfg.thickframe) { + WINLOCEX wlex; + wlex = np2_winlocexallwin(hWnd); + winlocex_setholdwnd(wlex, hWnd); + np2class_frametype(hWnd, np2oscfg.thickframe); + winlocex_move(wlex); + winlocex_destroy(wlex); + } + } winuileave(); break; @@ -421,25 +443,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(); @@ -481,6 +516,7 @@ static void np2cmd(HWND hWnd, UINT16 cmd diskdrv_sethdd(0x23, NULL); break; #endif + case IDM_WINDOW: changescreen(scrnmode & (~SCRNMODE_FULLSCREEN)); break; @@ -776,7 +812,7 @@ static void np2cmd(HWND hWnd, UINT16 cmd winuileave(); break; - case IDM_MIDIPANIC: // ver0.29 + case IDM_MIDIPANIC: rs232c_midipanic(); mpu98ii_midipanic(); pc9861k_midipanic(); @@ -793,7 +829,7 @@ static void np2cmd(HWND hWnd, UINT16 cmd dialog_writebmp(hWnd); winuileave(); break; -#if defined(SUPPPORT_S98) +#if defined(SUPPORT_S98) case IDM_S98LOGGING: winuienter(); dialog_s98(hWnd); @@ -854,7 +890,7 @@ static void np2cmd(HWND hWnd, UINT16 cmd update |= SYS_UPDATECFG; break; - case IDM_I286SAVE: + case IDM_CPUSAVE: debugsub_status(); break; @@ -877,15 +913,15 @@ static void np2cmd(HWND hWnd, UINT16 cmd #if defined(SUPPORT_STATSAVE) if ((cmd >= IDM_FLAGSAVE) && (cmd < (IDM_FLAGSAVE + SUPPORT_STATSAVE))) { - char ext[4]; - SPRINTF(ext, np2flagext, cmd - IDM_FLAGSAVE); + OEMCHAR ext[4]; + OEMSPRINTF(ext, np2flagext, cmd - IDM_FLAGSAVE); flagsave(ext); } else if ((cmd >= IDM_FLAGLOAD) && (cmd < (IDM_FLAGLOAD + SUPPORT_STATSAVE))) { - char ext[4]; - SPRINTF(ext, np2flagext, cmd - IDM_FLAGLOAD); - flagload(ext, "Status Load", TRUE); + OEMCHAR ext[4]; + OEMSPRINTF(ext, np2flagext, cmd - IDM_FLAGLOAD); + flagload(ext, OEMTEXT("Status Load"), TRUE); } #endif break; @@ -982,7 +1018,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT viewer_open(); break; - case IDM_SCRNMUL4: // ver0.26 + case IDM_SCRNMUL4: case IDM_SCRNMUL6: case IDM_SCRNMUL8: case IDM_SCRNMUL10: @@ -1059,7 +1095,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT GetClientRect(hWnd, &rect); width = rect.right - rect.left; height = rect.bottom - rect.top; - hbmp = LoadBitmap(hinst, "NP2BMP"); + hbmp = LoadBitmap(hinst, _T("NP2BMP")); GetObject(hbmp, sizeof(BITMAP), &bmp); hbrush = (HBRUSH)SelectObject(hdc, GetStockObject(BLACK_BRUSH)); @@ -1210,7 +1246,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT } break; - case WM_MBUTTONDOWN: // ver0.26 + case WM_MBUTTONDOWN: mousemng_toggle(MOUSEPROC_SYSTEM); xmenu_setmouse(np2oscfg.MOUSE_SW ^ 1); sysmng_update(SYS_UPDATECFG); @@ -1262,7 +1298,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT } else if (sstpconfirm_exit()) { winuienter(); - if (MessageBox(hWnd, "Sure?", "Exit", + if (MessageBox(hWnd, _T("Sure?"), _T("Exit"), MB_ICONQUESTION | MB_YESNO) == IDYES) { b = TRUE; } @@ -1344,10 +1380,10 @@ static void framereset(UINT cnt) { framecnt = 0; scrnmng_dispclock(); - kdispwin_draw((BYTE)cnt); + kdispwin_draw((UINT8)cnt); skbdwin_process(); mdbgwin_process(); - toolwin_draw((BYTE)cnt); + toolwin_draw((UINT8)cnt); viewer_allreload(FALSE); if (np2oscfg.DISPCLK & 3) { if (sysmng_workclockrenewal()) { @@ -1375,16 +1411,18 @@ int WINAPI WinMain(HINSTANCE hInstance, MSG msg; HWND hWnd; UINT i; + DWORD style; #ifdef OPENING_WAIT UINT32 tick; #endif + BOOL xrollkey; _MEM_INIT(); - GetModuleFileName(NULL, modulefile, sizeof(modulefile)); + GetModuleFileName(NULL, modulefile, NELEMENTS(modulefile)); dosio_init(); file_setcd(modulefile); - np2arg_analize(lpszCmdLine); + np2arg_analize(); initload(); toolwin_readini(); kdispwin_readini(); @@ -1393,7 +1431,9 @@ int WINAPI WinMain(HINSTANCE hInstance, rand_setseed((unsigned)time(NULL)); - CopyMemory(szClassName, np2oscfg.winid, 3); + szClassName[0] = (TCHAR)np2oscfg.winid[0]; + szClassName[1] = (TCHAR)np2oscfg.winid[1]; + szClassName[2] = (TCHAR)np2oscfg.winid[2]; if ((hWnd = FindWindow(szClassName, NULL)) != NULL) { sstpmsg_running(); @@ -1409,10 +1449,12 @@ int WINAPI WinMain(HINSTANCE hInstance, mmxflag += (np2oscfg.disablemmx)?MMXFLAG_DISABLE:0; TRACEINIT(); - if (np2oscfg.KEYBOARD >= KEY_TYPEMAX) { // ver0.28 + xrollkey = (np2oscfg.xrollkey == 0); + if (np2oscfg.KEYBOARD >= KEY_TYPEMAX) { int keytype = GetKeyboardType(1); if ((keytype & 0xff00) == 0x0d00) { np2oscfg.KEYBOARD = KEY_PC98; + xrollkey = !xrollkey; } else if (!keytype) { np2oscfg.KEYBOARD = KEY_KEY101; @@ -1421,7 +1463,7 @@ int WINAPI WinMain(HINSTANCE hInstance, np2oscfg.KEYBOARD = KEY_KEY106; } } - winkbd_roll(np2oscfg.KEYBOARD != KEY_PC98); + winkbd_roll(xrollkey); winkbd_setf12(np2oscfg.F12COPY); keystat_initialize(); @@ -1449,9 +1491,11 @@ int WINAPI WinMain(HINSTANCE hInstance, mousemng_initialize(); - hWnd = CreateWindowEx(0, szClassName, np2oscfg.titles, - WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | - WS_THICKFRAME | WS_MINIMIZEBOX, + style = WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX; + if (np2oscfg.thickframe) { + style |= WS_THICKFRAME; + } + hWnd = CreateWindowEx(0, szClassName, np2oscfg.titles, style, np2oscfg.winx, np2oscfg.winy, 640, 400, NULL, NULL, hInstance, NULL); hWndMain = hWnd; @@ -1491,8 +1535,7 @@ int WINAPI WinMain(HINSTANCE hInstance, xmenu_initialize(); DrawMenuBar(hWnd); - // ver0.30 - if (file_attr_c(np2help) == (short)-1) { + if (file_attr_c(np2help) == (short)-1) { // ver0.30 EnableMenuItem(GetMenu(hWnd), IDM_HELP, MF_GRAYED); } @@ -1501,7 +1544,7 @@ int WINAPI WinMain(HINSTANCE hInstance, sysmenu_setwinsnap(np2oscfg.WINSNAP); sysmenu_setbackground(np2oscfg.background); sysmenu_setbgsound(np2oscfg.background); - sysmenu_setscrnmul(8); // ver0.26 + sysmenu_setscrnmul(8); scrnmode = 0; if (np2arg.fullscreen) { @@ -1514,7 +1557,7 @@ int WINAPI WinMain(HINSTANCE hInstance, scrnmode ^= SCRNMODE_FULLSCREEN; if (scrnmng_create(scrnmode) != SUCCESS) { if (sstpmsg_dxerror()) { - MessageBox(hWnd, "Couldn't create DirectDraw Object", + MessageBox(hWnd, _T("Couldn't create DirectDraw Object"), np2oscfg.titles, MB_OK | MB_ICONSTOP); } return(FALSE); @@ -1522,8 +1565,8 @@ int WINAPI WinMain(HINSTANCE hInstance, } if (soundmng_initialize() == SUCCESS) { - soundmng_pcmload(SOUND_PCMSEEK, "SEEKWAV", EXTROMIO_RES); - soundmng_pcmload(SOUND_PCMSEEK1, "SEEK1WAV", EXTROMIO_RES); + soundmng_pcmload(SOUND_PCMSEEK, OEMTEXT("SEEKWAV"), EXTROMIO_RES); + soundmng_pcmload(SOUND_PCMSEEK1, OEMTEXT("SEEK1WAV"), EXTROMIO_RES); soundmng_pcmvolume(SOUND_PCMSEEK, np2cfg.MOTORVOL); soundmng_pcmvolume(SOUND_PCMSEEK1, np2cfg.MOTORVOL); } @@ -1562,7 +1605,9 @@ int WINAPI WinMain(HINSTANCE hInstance, id = flagload(str_sav, str_resume, FALSE); if (id == IDYES) { - for (i=0; i<4; i++) np2arg.disk[i] = NULL; + for (i=0; i<4; i++) { + np2arg.disk[i] = NULL; + } } else if (id == IDCANCEL) { DestroyWindow(hWnd); @@ -1580,11 +1625,10 @@ int WINAPI WinMain(HINSTANCE hInstance, } #endif -// リセットしてから… コマンドラインのディスク挿入。 // ver0.29 +// リセットしてから… コマンドラインのディスク挿入。 for (i=0; i<4; i++) { if (np2arg.disk[i]) { - milstr_ncpy(diskdrv_fname[i], np2arg.disk[i], MAX_PATH); - diskdrv_delay[i] = 1; + diskdrv_readyfdd((REG8)i, np2arg.disk[i], 0); } } @@ -1727,7 +1771,7 @@ int WINAPI WinMain(HINSTANCE hInstance, _MEM_USED("report.txt"); dosio_term(); - viewer_term(); // ver0.30 + viewer_term(); // ver0.30 return(msg.wParam); }