示例#1
0
文件: menu.c 项目: perabuss/np2wii
int wiimenu_do_selection(int opt)
{
	if(!started) opt += 2;
	switch(opt) {
		case 0:
			return -1;
		case 1:
			pccore_cfgupdate();
			pccore_reset();
			return -1;
		case 2:
			wiimenu_controlconf();
			return 3;
		case 3:
			wiimenu_loadgame();
			return -1;
		case 4:
			wiimenu_options();
			return 5;
		case 5:
			wii_shutdown(0);
			return 0;
		case 6:
			wii_shutdown(9001);
			return 0;
		default:
			return 0;
	}
}
示例#2
0
文件: np2.cpp 项目: FREEWING-JP/np2pi
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst,
										LPSTR lpszCmdLine, int nCmdShow) {
	WNDCLASS	wc;
	MSG			msg;
	HWND		hWnd;
	int			i;
#ifdef OPENING_WAIT
	UINT32		tick;
#endif

	_MEM_INIT();

	GetModuleFileName(NULL, modulefile, NELEMENTS(modulefile));
	dosio_init();
	file_setcd(modulefile);
	np2arg_analize();
	initload();
	memdbg_readini();
	skbdwin_readini();

	rand_setseed((unsigned)time(NULL));

	if ((hWnd = FindWindow(szClassName, NULL)) != NULL) {
		ShowWindow(hWnd, SW_RESTORE);
		SetForegroundWindow(hWnd);
		dosio_term();
		return(FALSE);
	}

	hInst = hInstance;
	hPrev = hPreInst;
	TRACEINIT();

	if (np2oscfg.KEYBOARD >= KEY_TYPEMAX) {							// ver0.28
		int keytype = GetKeyboardType(1);
		if ((keytype & 0xff00) == 0x0d00) {
			np2oscfg.KEYBOARD = KEY_PC98;
		}
		else if (!keytype) {
			np2oscfg.KEYBOARD = KEY_KEY101;
		}
		else {
			np2oscfg.KEYBOARD = KEY_KEY106;
		}
	}
	keystat_initialize();

	if (!hPreInst) {
		wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW;
		wc.lpfnWndProc = WndProc;
		wc.cbClsExtra = 0;
		wc.cbWndExtra = 0;
		wc.hInstance = hInstance;
		wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
		wc.hCursor = LoadCursor(NULL, IDC_ARROW);
		wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
		wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAIN);
		wc.lpszClassName = szClassName;
		if (!RegisterClass(&wc)) {
			return(FALSE);
		}
	}
	memdbg_initialize(hInstance);
	skbdwin_initialize(hInstance);

	mousemng_initialize();

	hWnd = CreateWindowEx(0, szClassName, szAppCaption,
						WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION |
						WS_MINIMIZEBOX,
						np2oscfg.winx, np2oscfg.winy, 640, 400,
						NULL, NULL, hInstance, NULL);
	hWndMain = hWnd;
	scrnmng_initialize();

	xmenu_setroltate(0);
	xmenu_setdispmode(np2cfg.DISPSYNC);
	xmenu_setraster(np2cfg.RASTER);
	xmenu_setwaitflg(np2oscfg.NOWAIT);
	xmenu_setframe(np2oscfg.DRAW_SKIP);

	xmenu_setkey(0);
	xmenu_setxshift(0);
	xmenu_setf12copy(np2oscfg.F12COPY);
	xmenu_setbeepvol(np2cfg.BEEP_VOL);
	xmenu_setsound(np2cfg.SOUND_SW);
	xmenu_setjastsound(np2oscfg.jastsnd);
	xmenu_setmotorflg(np2cfg.MOTOR);
	xmenu_setextmem(np2cfg.EXTMEM);
	xmenu_setmouse(np2oscfg.MOUSE_SW);

	xmenu_setbtnmode(np2cfg.BTN_MODE);
	xmenu_setbtnrapid(np2cfg.BTN_RAPID);
	xmenu_setmsrapid(np2cfg.MOUSERAPID);

	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);

#ifdef OPENING_WAIT
	tick = GetTickCount();
#endif

	sysmenu_initialize();
	xmenu_initialize();
	DrawMenuBar(hWnd);

	// ver0.30
	if (file_attr_c(np2help) == (short)-1) {
		EnableMenuItem(GetMenu(hWnd), IDM_HELP, MF_GRAYED);
	}

	scrnmode = 0;
	if (np2arg.fullscreen) {
		scrnmode |= SCRNMODE_FULLSCREEN;
	}
	if (np2cfg.RASTER) {
		scrnmode |= SCRNMODE_HIGHCOLOR;
	}
	if (scrnmng_create(scrnmode) != SUCCESS) {
		scrnmode ^= SCRNMODE_FULLSCREEN;
		if (scrnmng_create(scrnmode) != SUCCESS) {
			MessageBox(hWnd, _T("Couldn't create DirectDraw Object"),
										szAppCaption, MB_OK | MB_ICONSTOP);
			return(FALSE);
		}
	}

	soundmng_initialize();
	if (np2oscfg.MOUSE_SW) {										// ver0.30
		mousemng_enable(MOUSEPROC_SYSTEM);
	}

	commng_initialize();
	sysmng_initialize();

	joy_init();
	pccore_init();
	S98_init();

#ifdef OPENING_WAIT
	while((GetTickCount() - tick) < OPENING_WAIT);
#endif

	scrndraw_redraw();

	pccore_reset();

	np2opening = 0;

	// れじうむ
#if defined(SUPPORT_RESUME)
	if (np2oscfg.resume) {
		int		id;

		id = flagload(str_sav, str_resume, FALSE);
		if (id == IDYES) {
			for (i=0; i<4; i++) np2arg.disk[i] = NULL;
		}
		else if (id == IDCANCEL) {
			DestroyWindow(hWnd);
			mousemng_disable(MOUSEPROC_WINUI);
			S98_trash();
			pccore_term();
			soundmng_deinitialize();
			scrnmng_destroy();
			TRACETERM();
			dosio_term();
			return(0);
		}
	}
#endif

//	リセットしてから… コマンドラインのディスク挿入。				// ver0.29
	for (i=0; i<4; i++) {
		if (np2arg.disk[i]) {
			diskdrv_readyfdd((REG8)i, np2arg.disk[i], 0);
		}
	}

	memdbg_create();
	skbdwin_create();

	while(1) {
		if (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) {
			if (!GetMessage(&msg, NULL, 0, 0)) {
				break;
			}
			if ((msg.message != WM_SYSKEYDOWN) &&
				(msg.message != WM_SYSKEYUP)) {
				TranslateMessage(&msg);
			}
			DispatchMessage(&msg);
		}
		else {
			if (np2oscfg.NOWAIT) {
				joy_flash();
				mousemng_sync();
				pccore_exec(framecnt == 0);
				if (np2oscfg.DRAW_SKIP) {			// nowait frame skip
					framecnt++;
					if (framecnt >= np2oscfg.DRAW_SKIP) {
						processwait(0);
					}
				}
				else {							// nowait auto skip
					framecnt = 1;
					if (timing_getcount()) {
						processwait(0);
					}
				}
			}
			else if (np2oscfg.DRAW_SKIP) {		// frame skip
				if (framecnt < np2oscfg.DRAW_SKIP) {
					joy_flash();
					mousemng_sync();
					pccore_exec(framecnt == 0);
					framecnt++;
				}
				else {
					processwait(np2oscfg.DRAW_SKIP);
				}
			}
			else {								// auto skip
				if (!waitcnt) {
					UINT cnt;
					joy_flash();
					mousemng_sync();
					pccore_exec(framecnt == 0);
					framecnt++;
					cnt = timing_getcount();
					if (framecnt > cnt) {
						waitcnt = framecnt;
						if (framemax > 1) {
							framemax--;
						}
					}
					else if (framecnt >= framemax) {
						if (framemax < 12) {
							framemax++;
						}
						if (cnt >= 12) {
							timing_reset();
						}
						else {
							timing_setcount(cnt - framecnt);
						}
						framereset();
					}
				}
				else {
					processwait(waitcnt);
					waitcnt = framecnt;
				}
			}
		}
	}

	pccore_cfgupdate();

	mousemng_disable(MOUSEPROC_WINUI);
	S98_trash();

#if defined(SUPPORT_RESUME)
	if (np2oscfg.resume) {
		flagsave(str_sav);
	}
	else {
		flagdelete(str_sav);
	}
#endif

	pccore_term();
	memdbg_destroy();
	skbdwin_destroy();

	soundmng_deinitialize();
	scrnmng_destroy();

	if (sys_updates	& (SYS_UPDATECFG | SYS_UPDATEOSCFG)) {
		initsave();
		memdbg_writeini();
		skbdwin_writeini();
	}

	skbdwin_deinitialize();

	TRACETERM();
	_MEM_USED("report.txt");
	dosio_term();

	return static_cast<int>(msg.wParam);
}
示例#3
0
文件: np2.cpp 项目: FREEWING-JP/np2pi
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {

	PAINTSTRUCT	ps;
	RECT		rc;
	HDC			hdc;
	UINT		update;

	switch (msg) {
		case WM_CREATE:
#ifndef __GNUC__
			WINNLSEnableIME(hWnd, FALSE);
#endif
			break;

		case WM_SYSCOMMAND:
			update = 0;
			switch(wParam) {
				case IDM_MEMORYDUMP:
					debugsub_memorydump();
					break;

				default:
					return(DefWindowProc(hWnd, msg, wParam, lParam));
			}
			sysmng_update(update);
			break;

		case WM_COMMAND:
			np2cmd(hWnd, LOWORD(wParam));
			break;

		case WM_ACTIVATE:
			if (LOWORD(wParam) != WA_INACTIVE) {
				scrnmng_update();
				keystat_allrelease();
				mousemng_enable(MOUSEPROC_BG);
			}
			else {
				mousemng_disable(MOUSEPROC_BG);
			}
			break;

		case WM_PAINT:
			hdc = BeginPaint(hWnd, &ps);
			if (np2opening) {
				HINSTANCE	hinst;
				RECT		rect;
				int			width;
				int			height;
				HBITMAP		hbmp;
				BITMAP		bmp;
				HDC			hmdc;
				HBRUSH		hbrush;

#if defined(_WIN64)
				hinst = reinterpret_cast<HINSTANCE>(::GetWindowLongPtr(hWnd, GWLP_HINSTANCE));
#else
				hinst = reinterpret_cast<HINSTANCE>(::GetWindowLong(hWnd, GWL_HINSTANCE));
#endif
				GetClientRect(hWnd, &rect);
				width = rect.right - rect.left;
				height = rect.bottom - rect.top;
				hbmp = LoadBitmap(hinst, _T("NP2BMP"));
				GetObject(hbmp, sizeof(BITMAP), &bmp);
				hbrush = (HBRUSH)SelectObject(hdc,
												GetStockObject(BLACK_BRUSH));
				PatBlt(hdc, 0, 0, width, height, PATCOPY);
				SelectObject(hdc, hbrush);
				hmdc = CreateCompatibleDC(hdc);
				SelectObject(hmdc, hbmp);
				BitBlt(hdc, (width - bmp.bmWidth) / 2,
						(height - bmp.bmHeight) / 2,
							bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, SRCCOPY);
				DeleteDC(hmdc);
				DeleteObject(hbmp);
			}
			else {
//				scrnmng_update();
				scrndraw_redraw();
			}
			EndPaint(hWnd, &ps);
			break;

		case WM_QUERYNEWPALETTE:
			scrnmng_querypalette();
			break;

		case WM_MOVE:
			if ((!scrnmng_isfullscreen()) &&
				(!(GetWindowLong(hWnd, GWL_STYLE) &
									(WS_MAXIMIZE | WS_MINIMIZE)))) {
				GetWindowRect(hWnd, &rc);
				np2oscfg.winx = rc.left;
				np2oscfg.winy = rc.top;
				sysmng_update(SYS_UPDATEOSCFG);
			}
			break;

		case WM_SIZE:
			if (wParam == SIZE_RESTORED) {
				scrnmng_restoresize();
			}
			break;

		case WM_ENTERMENULOOP:
			winuienter();
			if (scrnmng_isfullscreen()) {
				DrawMenuBar(hWnd);
			}
			break;

		case WM_EXITMENULOOP:
			winuileave();
			break;

		case WM_ENTERSIZEMOVE:
			soundmng_disable(SNDPROC_MAIN);
			mousemng_disable(MOUSEPROC_WINUI);
			break;

		case WM_EXITSIZEMOVE:
			mousemng_enable(MOUSEPROC_WINUI);
			soundmng_enable(SNDPROC_MAIN);
			break;

		case WM_KEYDOWN:
			if (wParam == VK_F11) {
				return(DefWindowProc(hWnd, WM_SYSKEYDOWN, VK_F10, lParam));
			}
			if ((wParam == VK_F12) && (!np2oscfg.F12COPY)) {
				mousemng_toggle(MOUSEPROC_SYSTEM);
				xmenu_setmouse(np2oscfg.MOUSE_SW ^ 1);
				sysmng_update(SYS_UPDATECFG);
			}
			else {
				winkbd_keydown(wParam, lParam);
			}
			break;

		case WM_KEYUP:
			if (wParam == VK_F11) {
				return(DefWindowProc(hWnd, WM_SYSKEYUP, VK_F10, lParam));
			}
			if ((wParam != VK_F12) || (np2oscfg.F12COPY)) {
				winkbd_keyup(wParam, lParam);
			}
			break;

		case WM_SYSKEYDOWN:
			winkbd_keydown(wParam, lParam);
			break;

		case WM_SYSKEYUP:
			winkbd_keyup(wParam, lParam);
			break;

		case WM_LBUTTONDOWN:
			if (!mousemng_buttonevent(MOUSEMNG_LEFTDOWN)) {
				return(DefWindowProc(hWnd, msg, wParam, lParam));
			}
			break;

		case WM_LBUTTONUP:
			if (!mousemng_buttonevent(MOUSEMNG_LEFTUP)) {
				return(DefWindowProc(hWnd, msg, wParam, lParam));
			}
			break;

		case WM_MBUTTONDOWN:									// ver0.26
			mousemng_toggle(MOUSEPROC_SYSTEM);
			xmenu_setmouse(np2oscfg.MOUSE_SW ^ 1);
			sysmng_update(SYS_UPDATECFG);
			break;

		case WM_RBUTTONDOWN:
			if (!mousemng_buttonevent(MOUSEMNG_RIGHTDOWN)) {
				return(DefWindowProc(hWnd, msg, wParam, lParam));
			}
			break;

		case WM_RBUTTONUP:
			if (!mousemng_buttonevent(MOUSEMNG_RIGHTUP)) {
				return(DefWindowProc(hWnd, msg, wParam, lParam));
			}
			break;

		case WM_CLOSE:
			DestroyWindow(hWnd);
			break;

		case WM_DESTROY:
			PostQuitMessage(0);
			break;

		case WM_NP2CMD:
			switch(LOWORD(lParam)) {
				case NP2CMD_EXIT:
					np2quitmsg = 1;
					PostQuitMessage(0);
					break;

				case NP2CMD_EXIT2:
					np2quitmsg = 2;
					PostQuitMessage(0);
					break;

				case NP2CMD_RESET:
					pccore_cfgupdate();
					pccore_reset();
					break;
			}
			break;

		default:
			return(DefWindowProc(hWnd, msg, wParam, lParam));
	}
	return(0L);
}
示例#4
0
文件: np2.cpp 项目: FREEWING-JP/np2pi
static void np2cmd(HWND hWnd, UINT16 cmd) {

	UINT	update;

	update = 0;
	switch(cmd) {
		case IDM_RESET:
			pccore_cfgupdate();
			pccore_reset();
			break;

		case IDM_CONFIG:
			winuienter();
			DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG),
											hWnd, (DLGPROC)CfgDialogProc);
			winuileave();
			break;

		case IDM_NEWDISK:
			winuienter();
			dialog_newdisk(hWnd);
			winuileave();
			break;

		case IDM_CHANGEFONT:
			winuienter();
			dialog_font(hWnd);
			winuileave();
			break;

		case IDM_EXIT:
			SendMessage(hWnd, WM_CLOSE, 0, 0L);
			break;

		case IDM_FDD1OPEN:
			winuienter();
			dialog_changefdd(hWnd, 0);
			winuileave();
			break;

		case IDM_FDD1EJECT:
			diskdrv_setfdd(0, NULL, 0);
			break;

		case IDM_FDD2OPEN:
			winuienter();
			dialog_changefdd(hWnd, 1);
			winuileave();
			break;

		case IDM_FDD2EJECT:
			diskdrv_setfdd(1, NULL, 0);
			break;

		case IDM_SASI1OPEN:
			winuienter();
			dialog_changehdd(hWnd, 0);
			winuileave();
			break;

		case IDM_SASI1EJECT:
			diskdrv_sethdd(0, NULL);
			break;

		case IDM_SASI2OPEN:
			winuienter();
			dialog_changehdd(hWnd, 1);
			winuileave();
			break;

		case IDM_SASI2EJECT:
			diskdrv_sethdd(1, NULL);
			break;

		case IDM_WINDOW:
			changescreen(scrnmode & (~SCRNMODE_FULLSCREEN));
			break;

		case IDM_FULLSCREEN:
			changescreen(scrnmode | SCRNMODE_FULLSCREEN);
			break;

		case IDM_ROLNORMAL:
			xmenu_setroltate(0);
			changescreen(scrnmode & (~SCRNMODE_ROTATEMASK));
			break;

		case IDM_ROLLEFT:
			xmenu_setroltate(1);
			changescreen((scrnmode & (~SCRNMODE_ROTATEMASK)) |
														SCRNMODE_ROTATELEFT);
			break;

		case IDM_ROLRIGHT:
			xmenu_setroltate(2);
			changescreen((scrnmode & (~SCRNMODE_ROTATEMASK)) |
														SCRNMODE_ROTATERIGHT);
			break;

		case IDM_DISPSYNC:
			xmenu_setdispmode(np2cfg.DISPSYNC ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_RASTER:
			xmenu_setraster(np2cfg.RASTER ^ 1);
			if (np2cfg.RASTER) {
				changescreen(scrnmode | SCRNMODE_HIGHCOLOR);
			}
			else {
				changescreen(scrnmode & (~SCRNMODE_HIGHCOLOR));
			}
			update |= SYS_UPDATECFG;
			break;

		case IDM_NOWAIT:
			xmenu_setwaitflg(np2oscfg.NOWAIT ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_AUTOFPS:
			xmenu_setframe(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_60FPS:
			xmenu_setframe(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_30FPS:
			xmenu_setframe(2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_20FPS:
			xmenu_setframe(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_15FPS:
			xmenu_setframe(4);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SCREENOPT:
			winuienter();
			dialog_scropt(hWnd);
			winuileave();
			break;

		case IDM_KEY:
			xmenu_setkey(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_JOY1:
			xmenu_setkey(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_JOY2:
			xmenu_setkey(2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_XSHIFT:
			xmenu_setxshift(np2cfg.XSHIFT ^ 1);
			keystat_forcerelease(0x70);
			update |= SYS_UPDATECFG;
			break;

		case IDM_XCTRL:
			xmenu_setxshift(np2cfg.XSHIFT ^ 2);
			keystat_forcerelease(0x74);
			update |= SYS_UPDATECFG;
			break;

		case IDM_XGRPH:
			xmenu_setxshift(np2cfg.XSHIFT ^ 4);
			keystat_forcerelease(0x73);
			update |= SYS_UPDATECFG;
			break;

		case IDM_F12MOUSE:
			xmenu_setf12copy(0);
			winkbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12COPY:
			xmenu_setf12copy(1);
			winkbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12STOP:
			xmenu_setf12copy(2);
			winkbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12EQU:
			xmenu_setf12copy(3);
			winkbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12COMMA:
			xmenu_setf12copy(4);
			winkbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_BEEPOFF:
			xmenu_setbeepvol(0);
			beep_setvol(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPLOW:
			xmenu_setbeepvol(1);
			beep_setvol(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPMID:
			xmenu_setbeepvol(2);
			beep_setvol(2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPHIGH:
			xmenu_setbeepvol(3);
			beep_setvol(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_NOSOUND:
			xmenu_setsound(0x00);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_14:
			xmenu_setsound(0x01);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_26K:
			xmenu_setsound(0x02);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_86:
			xmenu_setsound(0x04);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_26_86:
			xmenu_setsound(0x06);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_86_CB:
			xmenu_setsound(0x14);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_118:
			xmenu_setsound(0x08);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SPEAKBOARD:
			xmenu_setsound(0x20);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SPARKBOARD:
			xmenu_setsound(0x40);
			update |= SYS_UPDATECFG;
			break;

		case IDM_AMD98:
			xmenu_setsound(0x80);
			update |= SYS_UPDATECFG;
			break;

		case IDM_JASTSOUND:
			xmenu_setjastsound(np2oscfg.jastsnd ^ 1);
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_SEEKSND:
			xmenu_setmotorflg(np2cfg.MOTOR ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM640:
			xmenu_setextmem(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM16:
			xmenu_setextmem(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM36:
			xmenu_setextmem(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM76:
			xmenu_setextmem(7);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM116:
			xmenu_setextmem(11);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM136:
			xmenu_setextmem(13);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MOUSE:
			mousemng_toggle(MOUSEPROC_SYSTEM);
			xmenu_setmouse(np2oscfg.MOUSE_SW ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MPUPC98:
			winuienter();
			DialogBox(hInst, MAKEINTRESOURCE(IDD_MPUPC98),
											hWnd, (DLGPROC)MidiDialogProc);
			winuileave();
			break;

		case IDM_MIDIPANIC:									// ver0.29
			rs232c_midipanic();
			mpu98ii_midipanic();
			pc9861k_midipanic();
			break;

		case IDM_SNDOPT:
			winuienter();
			dialog_sndopt(hWnd);
			winuileave();
			break;

		case IDM_BMPSAVE:
			winuienter();
			dialog_writebmp(hWnd);
			winuileave();
			break;
#if defined(SUPPPORT_S98)
		case IDM_S98LOGGING:
			winuienter();
			dialog_s98(hWnd);
			winuileave();
			break;
#endif
#if defined(SUPPORT_WAVEREC)
		case IDM_WAVEREC:
			winuienter();
			dialog_waverec(hWnd);
			winuileave();
			break;
#endif
		case IDM_CALENDAR:
			winuienter();
			DialogBox(hInst, MAKEINTRESOURCE(IDD_CALENDAR),
											hWnd, (DLGPROC)ClndDialogProc);
			winuileave();
			break;

		case IDM_JOYX:
			xmenu_setbtnmode(np2cfg.BTN_MODE ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_RAPID:
			xmenu_setbtnrapid(np2cfg.BTN_RAPID ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MSRAPID:
			xmenu_setmsrapid(np2cfg.MOUSERAPID ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_I286SAVE:
			debugsub_status();
			break;

		case IDM_HELP:
			ShellExecute(hWnd, NULL, file_getcd(np2help),
											NULL, NULL, SW_SHOWNORMAL);
			break;

		case IDM_ABOUT:
			winuienter();
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT),
									hWnd, (DLGPROC)AboutDialogProc);
			winuileave();
			break;
	}
	sysmng_update(update);
}
示例#5
0
文件: sysmenu.c 项目: perabuss/np2wii
static void sys_cmd(MENUID id) {

    UINT	update;

    update = 0;
    switch(id) {
    case MID_RESET:
        pccore_cfgupdate();
        pccore_reset();
        break;

    case MID_CONFIG:
        menudlg_create(DLGCFG_WIDTH, DLGCFG_HEIGHT,
                       (char *)mstr_cfg, dlgcfg_cmd);
        break;

    case MID_FDD1OPEN:
        filesel_fdd(0);
        break;

    case MID_FDD1EJECT:
        diskdrv_setfdd(0, NULL, 0);
        break;

    case MID_FDD2OPEN:
        filesel_fdd(1);
        break;

    case MID_FDD2EJECT:
        diskdrv_setfdd(1, NULL, 0);
        break;

    case MID_SASI1OPEN:
        filesel_hdd(0x00);
        break;

    case MID_SASI1EJECT:
        diskdrv_sethdd(0x00, NULL);
        break;

    case MID_SASI2OPEN:
        filesel_hdd(0x01);
        break;

    case MID_SASI2EJECT:
        diskdrv_sethdd(0x01, NULL);
        break;
#if defined(SUPPORT_SCSI)
    case MID_SCSI0OPEN:
        filesel_hdd(0x20);
        break;

    case MID_SCSI0EJECT:
        diskdrv_sethdd(0x20, NULL);
        break;

    case MID_SCSI1OPEN:
        filesel_hdd(0x21);
        break;

    case MID_SCSI1EJECT:
        diskdrv_sethdd(0x21, NULL);
        break;

    case MID_SCSI2OPEN:
        filesel_hdd(0x22);
        break;

    case MID_SCSI2EJECT:
        diskdrv_sethdd(0x22, NULL);
        break;

    case MID_SCSI3OPEN:
        filesel_hdd(0x23);
        break;

    case MID_SCSI3EJECT:
        diskdrv_sethdd(0x23, NULL);
        break;
#endif
    case MID_DISPSYNC:
        np2cfg.DISPSYNC ^= 1;
        update |= SYS_UPDATECFG;
        break;

    case MID_RASTER:
        np2cfg.RASTER ^= 1;
        update |= SYS_UPDATECFG;
        break;

    case MID_NOWAIT:
        np2oscfg.NOWAIT ^= 1;
        update |= SYS_UPDATECFG;
        break;

    case MID_AUTOFPS:
        np2oscfg.DRAW_SKIP = 0;
        update |= SYS_UPDATECFG;
        break;

    case MID_60FPS:
        np2oscfg.DRAW_SKIP = 1;
        update |= SYS_UPDATECFG;
        break;

    case MID_30FPS:
        np2oscfg.DRAW_SKIP = 2;
        update |= SYS_UPDATECFG;
        break;

    case MID_20FPS:
        np2oscfg.DRAW_SKIP = 3;
        update |= SYS_UPDATECFG;
        break;

    case MID_15FPS:
        np2oscfg.DRAW_SKIP = 4;
        update |= SYS_UPDATECFG;
        break;

    case MID_SCREENOPT:
        menudlg_create(DLGSCR_WIDTH, DLGSCR_HEIGHT,
                       (char *)mstr_scropt, dlgscr_cmd);
        break;

    case MID_KEY:
        np2cfg.KEY_MODE = 0;
        keystat_resetjoykey();
        update |= SYS_UPDATECFG;
        break;

    case MID_JOY1:
        np2cfg.KEY_MODE = 1;
        keystat_resetjoykey();
        update |= SYS_UPDATECFG;
        break;

    case MID_JOY2:
        np2cfg.KEY_MODE = 2;
        keystat_resetjoykey();
        update |= SYS_UPDATECFG;
        break;

    case MID_MOUSEKEY:
        np2cfg.KEY_MODE = 3;
        keystat_resetjoykey();
        update |= SYS_UPDATECFG;
        break;

    case MID_XSHIFT:
        np2cfg.XSHIFT ^= 1;
        keystat_forcerelease(0x70);
        update |= SYS_UPDATECFG;
        break;

    case MID_XCTRL:
        np2cfg.XSHIFT ^= 2;
        keystat_forcerelease(0x74);
        update |= SYS_UPDATECFG;
        break;

    case MID_XGRPH:
        np2cfg.XSHIFT ^= 4;
        keystat_forcerelease(0x73);
        update |= SYS_UPDATECFG;
        break;

    case MID_F12MOUSE:
        np2oscfg.F12KEY = 0;
        sdlkbd_resetf12();
        update |= SYS_UPDATEOSCFG;
        break;

    case MID_F12COPY:
        np2oscfg.F12KEY = 1;
        sdlkbd_resetf12();
        update |= SYS_UPDATEOSCFG;
        break;

    case MID_F12STOP:
        np2oscfg.F12KEY = 2;
        sdlkbd_resetf12();
        update |= SYS_UPDATEOSCFG;
        break;

    case MID_F12EQU:
        np2oscfg.F12KEY = 3;
        sdlkbd_resetf12();
        update |= SYS_UPDATEOSCFG;
        break;

    case MID_F12COMMA:
        np2oscfg.F12KEY = 4;
        sdlkbd_resetf12();
        update |= SYS_UPDATEOSCFG;
        break;

    case MID_BEEPOFF:
        np2cfg.BEEP_VOL = 0;
        beep_setvol(0);
        update |= SYS_UPDATECFG;
        break;

    case MID_BEEPLOW:
        np2cfg.BEEP_VOL = 1;
        beep_setvol(1);
        update |= SYS_UPDATECFG;
        break;

    case MID_BEEPMID:
        np2cfg.BEEP_VOL = 2;
        beep_setvol(2);
        update |= SYS_UPDATECFG;
        break;

    case MID_BEEPHIGH:
        np2cfg.BEEP_VOL = 3;
        beep_setvol(3);
        update |= SYS_UPDATECFG;
        break;

    case MID_NOSOUND:
        np2cfg.SOUND_SW = 0x00;
        update |= SYS_UPDATECFG;
        break;

    case MID_PC9801_14:
        np2cfg.SOUND_SW = 0x01;
        update |= SYS_UPDATECFG;
        break;

    case MID_PC9801_26K:
        np2cfg.SOUND_SW = 0x02;
        update |= SYS_UPDATECFG;
        break;

    case MID_PC9801_86:
        np2cfg.SOUND_SW = 0x04;
        update |= SYS_UPDATECFG;
        break;

    case MID_PC9801_26_86:
        np2cfg.SOUND_SW = 0x06;
        update |= SYS_UPDATECFG;
        break;

    case MID_PC9801_86_CB:
        np2cfg.SOUND_SW = 0x14;
        update |= SYS_UPDATECFG;
        break;

    case MID_PC9801_118:
        np2cfg.SOUND_SW = 0x08;
        update |= SYS_UPDATECFG;
        break;

    case MID_SPEAKBOARD:
        np2cfg.SOUND_SW = 0x20;
        update |= SYS_UPDATECFG;
        break;

    case MID_SPARKBOARD:
        np2cfg.SOUND_SW = 0x40;
        update |= SYS_UPDATECFG;
        break;

    case MID_AMD98:
        np2cfg.SOUND_SW = 0x80;
        update |= SYS_UPDATECFG;
        break;

    case MID_JASTSND:
        np2oscfg.jastsnd ^= 1;
        update |= SYS_UPDATEOSCFG;
        break;

    case MID_SEEKSND:
        np2cfg.MOTOR ^= 1;
        update |= SYS_UPDATECFG;
        break;
#if 0
    case IDM_SNDOPT:
        winuienter();
        dialog_sndopt(hWnd);
        winuileave();
        break;
#endif
    case MID_MEM640:
        np2cfg.EXTMEM = 0;
        update |= SYS_UPDATECFG;
        break;

    case MID_MEM16:
        np2cfg.EXTMEM = 1;
        update |= SYS_UPDATECFG;
        break;

    case MID_MEM36:
        np2cfg.EXTMEM = 3;
        update |= SYS_UPDATECFG;
        break;

    case MID_MEM76:
        np2cfg.EXTMEM = 7;
        update |= SYS_UPDATECFG;
        break;
#if 0
    case IDM_MOUSE:
        mousemng_toggle(MOUSEPROC_SYSTEM);
        xmenu_setmouse(np2oscfg.MOUSE_SW ^ 1);
        update |= SYS_UPDATECFG;
        break;

    case IDM_SERIAL1:
        winuienter();
        dialog_serial(hWnd);
        winuileave();
        break;

    case IDM_MPUPC98:
        winuienter();
        DialogBox(hInst, MAKEINTRESOURCE(IDD_MPUPC98),
                  hWnd, (DLGPROC)MidiDialogProc);
        winuileave();
        break;
#endif
    case MID_MIDIPANIC:
        rs232c_midipanic();
        mpu98ii_midipanic();
        pc9861k_midipanic();
        break;
#if 0
    case IDM_BMPSAVE:
        winuienter();
        dialog_writebmp(hWnd);
        winuileave();
        break;

    case IDM_S98LOGGING:
        winuienter();
        dialog_s98(hWnd);
        winuileave();
        break;

    case IDM_DISPCLOCK:
        xmenu_setdispclk(np2oscfg.DISPCLK ^ 1);
        update |= SYS_UPDATECFG;
        break;

    case IDM_DISPFRAME:
        xmenu_setdispclk(np2oscfg.DISPCLK ^ 2);
        update |= SYS_UPDATECFG;
        break;

    case IDM_CALENDAR:
        winuienter();
        DialogBox(hInst, MAKEINTRESOURCE(IDD_CALENDAR),
                  hWnd, (DLGPROC)ClndDialogProc);
        winuileave();
        break;

    case IDM_ALTENTER:
        xmenu_setshortcut(np2oscfg.shortcut ^ 1);
        update |= SYS_UPDATECFG;
        break;

    case IDM_ALTF4:
        xmenu_setshortcut(np2oscfg.shortcut ^ 2);
        update |= SYS_UPDATECFG;
        break;
#endif
    case MID_JOYX:
        np2cfg.BTN_MODE ^= 1;
        update |= SYS_UPDATECFG;
        break;

    case MID_RAPID:
        np2cfg.BTN_RAPID ^= 1;
        update |= SYS_UPDATECFG;
        break;

    case MID_MSRAPID:
        np2cfg.MOUSERAPID ^= 1;
        update |= SYS_UPDATECFG;
        break;

    case MID_ABOUT:
        menudlg_create(DLGABOUT_WIDTH, DLGABOUT_HEIGHT,
                       (char *)mstr_about, dlgabout_cmd);
        break;

#if defined(MENU_TASKMINIMIZE)
    case SID_MINIMIZE:
        taskmng_minimize();
        break;
#endif
    case MID_EXIT:
    case SID_CLOSE:
        taskmng_exit();
        break;
    }
    sysmng_update(update);
}
示例#6
0
void taskmng_rol(void) {

	SDL_Event	e;

	if (SDL_GetTicks() > count + 30 ) {			//0.03秒たった?
		count = SDL_GetTicks() + 10000000;					//カウントリセット
		tap = 0;									//タップ解除
		mousemng.btn |= uPD8255A_LEFTBIT;			//左クリック解除
//		__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL mouseup");
	}


	if ((!task_avail) || (!SDL_PollEvent(&e))) {
		return;
	}
	switch(e.type) {
		case SDL_MOUSEMOTION:

			if (menuvram == NULL) {

				if(e.motion.state == 1) {	//ボタン押されてる
					tap = FALSE;			//動いたのでtapじゃないよ
					mousemng.x = e.motion.xrel;
					mousemng.y = e.motion.yrel;//移動
				}
				else { 						//最初のいらないモーション
				}
			}
			else {
				menubase_moving(e.motion.x, e.motion.y, 0);
			}
			break;

		case SDL_MOUSEBUTTONUP:
//			switch(e.button.button) {
//				case SDL_BUTTON_LEFT:
//					longtap = SDL_GetTicks();//カウントリセット

					if (menuvram == NULL) {
						if (tap) {	//tapかどうかチェック
							mousemng.btn &= ~(uPD8255A_LEFTBIT);//	左クリックを送るよ
							count = SDL_GetTicks();//カウント開始
//							__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL mousedown");
						}

					}
					else {
						menubase_moving(e.button.x, e.button.y, 2);
					}
					break;

//				case SDL_BUTTON_RIGHT:
//					break;
//			}
//			break;

		case SDL_MOUSEBUTTONDOWN:
//			switch(e.button.button) {
//				case SDL_BUTTON_LEFT:

					if (menuvram == NULL) {
						tap = TRUE;	//tapかも知れないよ
//						longtap = SDL_GetTicks();//カウントリセット
					}
					else {
						menubase_moving(e.button.x, e.button.y, 1);
					}
//					break;

//				case SDL_BUTTON_RIGHT:
//					break;
//			}
			break;

		case SDL_KEYDOWN:
			if (e.key.keysym.scancode == SDL_SCANCODE_MENU) {
				if (menuvram == NULL) {
					sysmenu_menuopen(0, 0, 0);
				}
				else {
					menubase_close();
				}
			}
			else if (e.key.keysym.scancode == SDL_SCANCODE_POWER) {
				pccore_cfgupdate();
				pccore_reset();
			}
			else if (e.key.keysym.scancode == SDL_SCANCODE_SELECT) {
				mousemng.btn &= ~(uPD8255A_LEFTBIT);
			}
			else if (e.key.keysym.scancode == SDL_SCANCODE_AC_BACK) {
				mousemng.btn &= ~(uPD8255A_RIGHTBIT);
			}
			else {
				sdlkbd_keydown(e.key.keysym.scancode);
			}
			break;

		case SDL_KEYUP:
			if (e.key.keysym.scancode == SDL_SCANCODE_SELECT) {
				mousemng.btn |= uPD8255A_LEFTBIT;
			}
			else if (e.key.keysym.scancode == SDL_SCANCODE_AC_BACK) {
				mousemng.btn |= uPD8255A_RIGHTBIT;
			}
			else {
				sdlkbd_keyup(e.key.keysym.scancode);
			}
			break;

		case SDL_QUIT:
			task_avail = FALSE;
			break;
	}
}
示例#7
0
文件: np2.cpp 项目: perabuss/np2wii
int main(int argc, char *argv[]) {

	Rect		wRect;
	EventRecord	event;
	UINT		t;
	GrafPtr		saveport;
	Point		pt;

	dosio_init();
	file_setcd(target);

	InitToolBox();
	macossub_init();
	initload();

	MenuBarInit();

	TRACEINIT();

	keystat_initialize();

	SetRect(&wRect, np2oscfg.posx, np2oscfg.posy, 100, 100);
#if !defined(SUPPORT_PC9821)
	hWndMain = NewWindow(0, &wRect, "\pNeko Project II", FALSE,
								noGrowDocProc, (WindowPtr)-1, TRUE, 0);
#else
	hWndMain = NewWindow(0, &wRect, "\pNeko Project 21", FALSE,
								noGrowDocProc, (WindowPtr)-1, TRUE, 0);
#endif
	if (!hWndMain) {
		TRACETERM();
		macossub_term();
		dosio_term();
		return(0);
	}
	scrnmng_initialize();
	SizeWindow(hWndMain, 640, 400, TRUE);
	ShowWindow(hWndMain);

	menu_setrotate(0);
	menu_setdispmode(np2cfg.DISPSYNC);
	menu_setraster(np2cfg.RASTER);
	menu_setwaitflg(np2oscfg.NOWAIT);
	menu_setframe(np2oscfg.DRAW_SKIP);

	menu_setkey(0);
	menu_setxshift(0);
	menu_setf11key(np2oscfg.F11KEY);
	menu_setf12key(np2oscfg.F12KEY);
	menu_setbeepvol(np2cfg.BEEP_VOL);
	menu_setsound(np2cfg.SOUND_SW);
	menu_setjastsnd(np2oscfg.jastsnd);
	menu_setmotorflg(np2cfg.MOTOR);
	menu_setextmem(np2cfg.EXTMEM);

	menu_setdispclk(np2oscfg.DISPCLK);
	menu_setbtnrapid(np2cfg.BTN_RAPID);
	menu_setbtnmode(np2cfg.BTN_MODE);

	scrnmode = 0;
	if (scrnmng_create(scrnmode) != SUCCESS) {
		TRACETERM();
		macossub_term();
		dosio_term();
		DisposeWindow(hWndMain);
		return(0);
	}

	np2open();
	t = GETTICK();
	while((GETTICK() - t) < 100) {
		if (WaitNextEvent(everyEvent, &event, 0, 0)) {
			eventproc(&event);
		}
	}

	commng_initialize();
	sysmng_initialize();
	mackbd_initialize();
	pccore_init();
	S98_init();

	mousemng_initialize();
	if (np2oscfg.MOUSE_SW) {										// ver0.30
		mousemng_enable(MOUSEPROC_SYSTEM);
	}
//	scrndraw_redraw();
	pccore_reset();

#if defined(SUPPORT_RESUME)
	if (np2oscfg.resume) {
		flagload(np2resumeext, FALSE);
	}
#endif

	SetEventMask(everyEvent);

	np2running = TRUE;
	while(np2running) {
		if (WaitNextEvent(everyEvent, &event, 0, 0)) {
			eventproc(&event);
		}
		else {
			if (np2oscfg.NOWAIT) {
				mackbd_callback();
				mousemng_callback();
				pccore_exec(framecnt == 0);
				if (np2oscfg.DRAW_SKIP) {			// nowait frame skip
					framecnt++;
					if (framecnt >= np2oscfg.DRAW_SKIP) {
						processwait(0);
					}
				}
				else {								// nowait auto skip
					framecnt = 1;
					if (timing_getcount()) {
						processwait(0);
					}
				}
			}
			else if (np2oscfg.DRAW_SKIP) {			// frame skip
				if (framecnt < np2oscfg.DRAW_SKIP) {
					mackbd_callback();
                    mousemng_callback();
					pccore_exec(framecnt == 0);
					framecnt++;
				}
				else {
					processwait(np2oscfg.DRAW_SKIP);
				}
			}
			else {								// auto skip
				if (!waitcnt) {
					UINT cnt;
					mackbd_callback();
                    mousemng_callback();
					pccore_exec(framecnt == 0);
					framecnt++;
					cnt = timing_getcount();
					if (framecnt > cnt) {
						waitcnt = framecnt;
						if (framemax > 1) {
							framemax--;
						}
					}
					else if (framecnt >= framemax) {
						if (framemax < 12) {
							framemax++;
						}
						if (cnt >= 12) {
							timing_reset();
						}
						else {
							timing_setcount(cnt - framecnt);
						}
						framereset();
					}
				}
				else {
					processwait(waitcnt);
					waitcnt = framecnt;
				}
			}
		}
	}

	GetPort(&saveport);
#if TARGET_API_MAC_CARBON
	SetPortWindowPort(hWndMain);
#else
	SetPort(hWndMain);
#endif
	pt.h = 0;
	pt.v = 0;
	LocalToGlobal(&pt);
	SetPort(saveport);
	if ((np2oscfg.posx != pt.h) || (np2oscfg.posy != pt.v)) {
		np2oscfg.posx = pt.h;
		np2oscfg.posy = pt.v;
		sysmng_update(SYS_UPDATEOSCFG);
	}

	np2running = FALSE;

	pccore_cfgupdate();

#if defined(SUPPORT_RESUME)
	if (np2oscfg.resume) {
		flagsave(np2resumeext);
	}
	else {
		flagdelete(np2resumeext);
	}
#endif

	pccore_term();
	S98_trash();

	mousemng_disable(MOUSEPROC_SYSTEM);

	scrnmng_destroy();

	if (sys_updates	& (SYS_UPDATECFG | SYS_UPDATEOSCFG)) {
		initsave();
	}
	TRACETERM();
	macossub_term();
	dosio_term();

	DisposeWindow(hWndMain);

	(void)argc;
	(void)argv;
	return(0);
}
示例#8
0
文件: np2.cpp 项目: perabuss/np2wii
static void HandleMenuChoice(long wParam) {

	UINT	update;
	Str255	applname;
#if defined(SUPPORT_STATSAVE)
	UINT	num;
	char	ext[16];
#endif

	update = 0;
	switch(wParam) {
		case IDM_ABOUT:
			AboutDialogProc();
			break;

		case IDM_RESET:
			pccore_cfgupdate();
			pccore_reset();
			break;

		case IDM_CONFIGURE:
			ConfigDialogProc();
			break;

		case IDM_NEWDISK:
			dialog_newdisk();
			break;

		case IDM_FONT:
			dialog_font();
			break;

		case IDM_EXIT:
			np2running = FALSE;
			break;

		case IDM_FDD1OPEN:
			dialog_changefdd(0);
			break;

		case IDM_FDD1EJECT:
			diskdrv_setfdd(0, NULL, 0);
			break;

		case IDM_FDD2OPEN:
			dialog_changefdd(1);
			break;

		case IDM_FDD2EJECT:
			diskdrv_setfdd(1, NULL, 0);
			break;

		case IDM_FDD3OPEN:
			dialog_changefdd(2);
			break;

		case IDM_FDD3EJECT:
			diskdrv_setfdd(2, NULL, 0);
			break;

		case IDM_FDD4OPEN:
			dialog_changefdd(3);
			break;

		case IDM_FDD4EJECT:
			diskdrv_setfdd(3, NULL, 0);
			break;

		case IDM_SASI1OPEN:
			dialog_changehdd(0x00);
			break;

		case IDM_SASI1REMOVE:
			diskdrv_sethdd(0x00, NULL);
			break;

		case IDM_SASI2OPEN:
			dialog_changehdd(0x01);
			break;

		case IDM_SASI2REMOVE:
			diskdrv_sethdd(0x01, NULL);
			break;

		case IDM_SCSI0OPEN:
			dialog_changehdd(0x20);
			break;

		case IDM_SCSI0REMOVE:
			diskdrv_sethdd(0x20, NULL);
			break;

		case IDM_SCSI1OPEN:
			dialog_changehdd(0x21);
			break;

		case IDM_SCSI1REMOVE:
			diskdrv_sethdd(0x21, NULL);
			break;

		case IDM_SCSI2OPEN:
			dialog_changehdd(0x22);
			break;

		case IDM_SCSI2REMOVE:
			diskdrv_sethdd(0x22, NULL);
			break;

		case IDM_SCSI3OPEN:
			dialog_changehdd(0x23);
			break;

		case IDM_SCSI3REMOVE:
			diskdrv_sethdd(0x23, NULL);
			break;

		case IDM_ROLNORMAL:
			menu_setrotate(0);
			changescreen(scrnmode & (~SCRNMODE_ROTATEMASK));
			break;

		case IDM_ROLLEFT:
			menu_setrotate(1);
			changescreen((scrnmode & (~SCRNMODE_ROTATEMASK)) |
														SCRNMODE_ROTATELEFT);
			break;

		case IDM_ROLRIGHT:
			menu_setrotate(2);
			changescreen((scrnmode & (~SCRNMODE_ROTATEMASK)) |
														SCRNMODE_ROTATERIGHT);
			break;

		case IDM_DISPSYNC:
			menu_setdispmode(np2cfg.DISPSYNC ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_RASTER:
			menu_setraster(np2cfg.RASTER ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_NOWAIT:
			menu_setwaitflg(np2oscfg.NOWAIT ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_AUTOFPS:
			menu_setframe(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_60FPS:
			menu_setframe(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_30FPS:
			menu_setframe(2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_20FPS:
			menu_setframe(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_15FPS:
			menu_setframe(4);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SCREENOPT:
			dialog_scropt();
			break;

		case IDM_MOUSE:
			mousemng_toggle(MOUSEPROC_SYSTEM);
			menu_setmouse(np2oscfg.MOUSE_SW ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MIDIOPT:
			MPU98DialogProc();
			break;

		case IDM_MIDIPANIC:
			rs232c_midipanic();
			mpu98ii_midipanic();
			pc9861k_midipanic();
			break;

		case IDM_KEY:
			menu_setkey(0);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_JOY1:
			menu_setkey(1);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_JOY2:
			menu_setkey(2);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_MOUSEKEY:
			menu_setkey(3);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_XSHIFT:
			menu_setxshift(np2cfg.XSHIFT ^ 1);
			keystat_forcerelease(0x70);
			update |= SYS_UPDATECFG;
			break;

		case IDM_XCTRL:
			menu_setxshift(np2cfg.XSHIFT ^ 2);
			keystat_forcerelease(0x74);
			update |= SYS_UPDATECFG;
			break;

		case IDM_XGRPH:
			menu_setxshift(np2cfg.XSHIFT ^ 4);
			keystat_forcerelease(0x73);
			update |= SYS_UPDATECFG;
			break;

		case IDM_F11KANA:
			menu_setf11key(0);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F11STOP:
			menu_setf11key(1);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F11NFER:
			menu_setf11key(3);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F11USER:
			menu_setf11key(4);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12MOUSE:
			menu_setf12key(0);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12COPY:
			menu_setf12key(1);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12XFER:
			menu_setf12key(3);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12USER:
			menu_setf12key(4);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_BEEPOFF:
			menu_setbeepvol(0);
			beep_setvol(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPLOW:
			menu_setbeepvol(1);
			beep_setvol(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPMID:
			menu_setbeepvol(2);
			beep_setvol(2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPHIGH:
			menu_setbeepvol(3);
			beep_setvol(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_NOSOUND:
			menu_setsound(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_14:
			menu_setsound(0x01);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_26K:
			menu_setsound(0x02);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_86:
			menu_setsound(0x04);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_26_86:
			menu_setsound(0x06);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_86_CB:
			menu_setsound(0x14);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_118:
			menu_setsound(0x08);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SPEAKBOARD:
			menu_setsound(0x20);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SPARKBOARD:
			menu_setsound(0x40);
			update |= SYS_UPDATECFG;
			break;

		case IDM_AMD98:
			menu_setsound(0x80);
			update |= SYS_UPDATECFG;
			break;

		case IDM_JASTSND:
			menu_setjastsnd(np2oscfg.jastsnd ^ 1);
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_SEEKSND:
			menu_setmotorflg(np2cfg.MOTOR ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM640:
			menu_setextmem(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM16:
			menu_setextmem(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM36:
			menu_setextmem(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM76:
			menu_setextmem(7);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM116:
			menu_setextmem(11);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM136:
			menu_setextmem(13);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BMPSAVE:
			dialog_writebmp();
			break;

		case IDM_CALENDAR:
			CalendarDialogProc();
			break;

		case IDM_DISPCLOCK:
			menu_setdispclk(np2oscfg.DISPCLK ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_DISPFLAME:
			menu_setdispclk(np2oscfg.DISPCLK ^ 2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_JOYX:
			menu_setbtnmode(np2cfg.BTN_MODE ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_RAPID:
			menu_setbtnrapid(np2cfg.BTN_RAPID ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_I286SAVE:
			debugsub_status();
			break;

		default:
			if (HiWord(wParam) == IDM_APPLE) {
				GetMenuItemText(GetMenuHandle(IDM_APPLE), 
											LoWord(wParam), applname);
#if !TARGET_API_MAC_CARBON
				(void)OpenDeskAcc(applname);
#endif
			}
#if defined(SUPPORT_STATSAVE)
			else if (HiWord(wParam) == IDM_STATSAVE) {
				num = LoWord(wParam);
				if ((num >= 1) && (num < (1 + 10))) {
					SPRINTF(ext, np2flagext, num - 1);
					flagsave(ext);
				}
				else if ((num >= 12) && (num < (12 + 10))) {
					SPRINTF(ext, np2flagext, num - 12);
					flagload(ext, TRUE);
				}
			}
#endif
			break;
	}
	sysmng_update(update);
	HiliteMenu(0);
}
示例#9
0
文件: np2.c 项目: FREEWING-JP/np2pi
int SDL_main(int argc, char **argv) {

	int		pos;
	char	*p;
	int		id;

	pos = 1;
	while(pos < argc) {
		p = argv[pos++];
		if ((!milstr_cmp(p, "-h")) || (!milstr_cmp(p, "--help"))) {
			usage(argv[0]);
			goto np2main_err1;
		}
		else {
			printf("error command: %s\n", p);
			goto np2main_err1;
		}
	}

	dosio_init();
	file_setcd(datadir);
	initload();

	TRACEINIT();

	if (fontmng_init() != SUCCESS) {
		goto np2main_err2;
	}
	inputmng_init();
	keystat_initialize();

	if (sysmenu_create() != SUCCESS) {
		goto np2main_err3;
	}

	mousemng_initialize();

	scrnmng_initialize();
	if (scrnmng_create(FULLSCREEN_WIDTH, FULLSCREEN_HEIGHT) != SUCCESS) {
		goto np2main_err4;
	}

	sdlkbd_initialize();  // this must be after SDL_VIDEO initialized

	soundmng_initialize();
	commng_initialize();
	sysmng_initialize();
	taskmng_initialize();
	pccore_init();
	S98_init();

	mousemng_hidecursor();
	scrndraw_redraw();
	pccore_reset();

	if (np2oscfg.resume) {
		id = flagload(str_sav, str_resume, FALSE);
		if (id == DID_CANCEL) {
			goto np2main_err5;
		}
	}

	while(taskmng_isavail()) {
		taskmng_rol();
		if (np2oscfg.NOWAIT) {
			pccore_exec(framecnt == 0);
			if (np2oscfg.DRAW_SKIP) {			// nowait frame skip
				framecnt++;
				if (framecnt >= np2oscfg.DRAW_SKIP) {
					processwait(0);
				}
			}
			else {							// nowait auto skip
				framecnt = 1;
				if (timing_getcount()) {
					processwait(0);
				}
			}
		}
		else if (np2oscfg.DRAW_SKIP) {		// frame skip
			if (framecnt < np2oscfg.DRAW_SKIP) {
				pccore_exec(framecnt == 0);
				framecnt++;
			}
			else {
				processwait(np2oscfg.DRAW_SKIP);
			}
		}
		else {								// auto skip
			if (!waitcnt) {
				UINT cnt;
				pccore_exec(framecnt == 0);
				framecnt++;
				cnt = timing_getcount();
				if (framecnt > cnt) {
					waitcnt = framecnt;
					if (framemax > 1) {
						framemax--;
					}
				}
				else if (framecnt >= framemax) {
					if (framemax < 12) {
						framemax++;
					}
					if (cnt >= 12) {
						timing_reset();
					}
					else {
						timing_setcount(cnt - framecnt);
					}
					framereset(0);
				}
			}
			else {
				processwait(waitcnt);
				waitcnt = framecnt;
			}
		}
	}

	pccore_cfgupdate();
	if (np2oscfg.resume) {
		flagsave(str_sav);
	}
	else {
		flagdelete(str_sav);
	}
	pccore_term();
	S98_trash();
	soundmng_deinitialize();

	if (sys_updates	& (SYS_UPDATECFG | SYS_UPDATEOSCFG)) {
		initsave();
	}

	scrnmng_destroy();
	sysmenu_destroy();
	TRACETERM();
	SDL_Quit();
	dosio_term();
	return(SUCCESS);

np2main_err5:
	pccore_term();
	S98_trash();
	soundmng_deinitialize();

np2main_err4:
	scrnmng_destroy();

np2main_err3:
	sysmenu_destroy();

np2main_err2:
	TRACETERM();
	SDL_Quit();
	dosio_term();

np2main_err1:
	return(FAILURE);
}
示例#10
0
/*
 * main
 */
int
main(int argc, char *argv[])
{
	struct stat sb;
	BOOL result;
	int rv = 1;
	int ch;
	int i, drvmax;

	progname = argv[0];

	toolkit_initialize();
	toolkit_arginit(&argc, &argv);

	while ((ch = getopt_long(argc, argv, "c:C:t:vh", longopts, NULL)) != -1) {
		switch (ch) {
		case 'c':
			if (stat(optarg, &sb) < 0 || !S_ISREG(sb.st_mode)) {
				fprintf(stderr, "Can't access %s.\n", optarg);
				exit(1);
			}
			milstr_ncpy(modulefile, optarg, sizeof(modulefile));

			/* resume/statsave dir */
			file_cpyname(statpath, modulefile, sizeof(statpath));
			file_cutname(statpath);
			break;

		case 'C':
			if (stat(optarg, &sb) < 0 || !S_ISREG(sb.st_mode)) {
				fprintf(stderr, "Can't access %s.\n", optarg);
				exit(1);
			}
			milstr_ncpy(timidity_cfgfile_path, optarg,
			    sizeof(timidity_cfgfile_path));
			break;

		case 't':
			if (stat(optarg, &sb) < 0 || !S_ISREG(sb.st_mode)) {
				fprintf(stderr, "Can't access %s.\n", optarg);
				exit(1);
			}
			milstr_ncpy(fontfilename, optarg, sizeof(fontfilename));
			break;

		case 'v':
			verbose = 1;
			break;

		case 'h':
		case '?':
		default:
			usage();
			break;
		}
	}
	argc -= optind;
	argv += optind;

	if (modulefile[0] == '\0') {
		char *env = getenv("HOME");
		if (env) {
			/* base dir */
			snprintf(modulefile, sizeof(modulefile),
			    "%s/.np2", env);
			if (stat(modulefile, &sb) < 0) {
				if (mkdir(modulefile, 0700) < 0) {
					perror(modulefile);
					exit(1);
				}
			} else if (!S_ISDIR(sb.st_mode)) {
				fprintf(stderr, "%s isn't directory.\n",
				    modulefile);
				exit(1);
			}

			/* font file */
			snprintf(np2cfg.fontfile, sizeof(np2cfg.fontfile),
			    "%s/font.bmp", modulefile);

			/* resume/statsave dir */
			file_cpyname(statpath, modulefile, sizeof(statpath));
			file_catname(statpath, "/sav/", sizeof(statpath));
			if (stat(statpath, &sb) < 0) {
				if (mkdir(statpath, 0700) < 0) {
					perror(statpath);
					exit(1);
				}
			} else if (!S_ISDIR(sb.st_mode)) {
				fprintf(stderr, "%s isn't directory.\n",
				    statpath);
				exit(1);
			}

			/* config file */
			milstr_ncat(modulefile, "/np2rc", sizeof(modulefile));
			if ((stat(modulefile, &sb) >= 0)
			 && !S_ISREG(sb.st_mode)) {
				fprintf(stderr, "%s isn't regular file.\n",
				    modulefile);
			}
		}
	}
	if (timidity_cfgfile_path[0] == '\0') {
		file_cpyname(timidity_cfgfile_path, modulefile,
		    sizeof(timidity_cfgfile_path));
		file_cutname(timidity_cfgfile_path);
		file_catname(timidity_cfgfile_path, "timidity.cfg",
		    sizeof(timidity_cfgfile_path));
	}

	dosio_init();
	file_setcd(modulefile);
	initload();
	toolwin_readini();
	kdispwin_readini();
	skbdwin_readini();

	rand_setseed((SINT32)time(NULL));

#if defined(GCC_CPU_ARCH_IA32)
	mmxflag = havemmx() ? 0 : MMXFLAG_NOTSUPPORT;
	mmxflag += np2oscfg.disablemmx ? MMXFLAG_DISABLE : 0;
#endif

	TRACEINIT();

	if (fontmng_init() != SUCCESS)
		goto fontmng_failure;

	kdispwin_initialize();
	viewer_init();
	skbdwin_initialize();

	toolkit_widget_create();
	scrnmng_initialize();
	kbdmng_init();
	inputmng_init();
	keystat_initialize();

	scrnmode = 0;
	if (np2cfg.RASTER) {
		scrnmode |= SCRNMODE_HIGHCOLOR;
	}
	if (sysmenu_create() != SUCCESS)
		goto sysmenu_failure;
	if (scrnmng_create(scrnmode) != SUCCESS)
		goto scrnmng_failure;

	if (soundmng_initialize() == SUCCESS) {
		result = soundmng_pcmload(SOUND_PCMSEEK, file_getcd("fddseek.wav"));
		if (!result) {
			result = soundmng_pcmload(SOUND_PCMSEEK, SYSRESPATH "/fddseek.wav");
		}
		if (result) {
			soundmng_pcmvolume(SOUND_PCMSEEK, np2cfg.MOTORVOL);
		}

		result = soundmng_pcmload(SOUND_PCMSEEK1, file_getcd("fddseek1.wav"));
		if (!result) {
			result = soundmng_pcmload(SOUND_PCMSEEK1, SYSRESPATH "/fddseek1.wav");
		}
		if (result) {
			soundmng_pcmvolume(SOUND_PCMSEEK1, np2cfg.MOTORVOL);
		}
	}

	joymng_initialize();
	mousemng_initialize();
	if (np2oscfg.MOUSE_SW) {
		mouse_running(MOUSE_ON);
	}

	commng_initialize();
	sysmng_initialize();
	taskmng_initialize();

	pccore_init();
	S98_init();

	toolkit_widget_show();
	scrndraw_redraw();

	pccore_reset();

	if (!(scrnmode & SCRNMODE_FULLSCREEN)) {
		if (np2oscfg.toolwin) {
			toolwin_create();
		}
		if (np2oscfg.keydisp) {
			kdispwin_create();
		}
		if (np2oscfg.softkbd) {
			skbdwin_create();
		}
	}

#if !defined(CPUCORE_IA32)
	if (np2oscfg.resume) {
		flagload(np2resumeext, "Resume", FALSE);
	}
#endif
	sysmng_workclockreset();

	drvmax = (argc < 4) ? argc : 4;
	for (i = 0; i < drvmax; i++) {
		diskdrv_readyfdd(i, argv[i], 0);
	}

	setup_signal(SIGINT, sighandler);
	setup_signal(SIGTERM, sighandler);

	toolkit_widget_mainloop();
	rv = 0;

	kdispwin_destroy();
	toolwin_destroy();
	skbdwin_destroy();

	pccore_cfgupdate();

	mouse_running(MOUSE_OFF);
	joymng_deinitialize();
	S98_trash();

#if !defined(CPUCORE_IA32)
	if (np2oscfg.resume) {
		flagsave(np2resumeext);
	} else {
		flagdelete(np2resumeext);
	}
#endif

	pccore_term();
	debugwin_destroy();

	soundmng_deinitialize();
	scrnmng_destroy();

scrnmng_failure:
	sysmenu_destroy();

sysmenu_failure:
	fontmng_terminate();

fontmng_failure:
	if (sys_updates & (SYS_UPDATECFG|SYS_UPDATEOSCFG)) {
		initsave();
		toolwin_writeini();
		kdispwin_writeini();
		skbdwin_writeini();
	}

	skbdwin_deinitialize();

	TRACETERM();
	dosio_term();

	viewer_term();
	toolkit_terminate();

	return rv;
}
示例#11
0
文件: np2.cpp 项目: histat/dc-np2
int main(void)
{
	NP2MAIN np2main;

#ifndef NOSERIAL
	serial_init(57600);
	usleep(20000);
	printf("Serial OK\n");
#endif

	maple_init();
	dc_setup_ta();
	init_arm();
  
	__dc_avail = true;

	dc_savedtimes = 0;
	dc_joyinput = 0;

	dc_mouseaxis1 = 0;
	dc_mouseaxis2 = 0;

	ui_init();
  
	dosio_init();
	file_setcd(modulefile);
	initload();

	TRACEINIT();

	keystat_initialize();
	mousemng_initialize();
	
	scrnmng_initialize();

	UINT8 scrnmode = 0;

	if (scrnmng_create(scrnmode)  != SUCCESS) {
		return -1;
	}

	softkbddc_initialize();

	dckbd_bindinit();
	dckbd_bindcur(np2oscfg.bindcur);
	dckbd_bindbtn(np2oscfg.bindbtn);
  
	soundmng_initialize();
  
	commng_initialize();
	sysmng_initialize();
	taskmng_initialize();

	joymng_initialize();
	pccore_init();
	S98_init();

	pccore_reset();
	scrndraw_redraw();

	np2main.uFrameCount = 0;
	np2main.uWaitCount = 0;
	np2main.uFrameMax = 1;

#if 0
	if (np2oscfg.resume) {
		id = flagload(str_sav, str_resume, FALSE);
		if (id == DID_CANCEL) {
			DestroyWindow(hWnd);
			goto np2main_err4;
		}
	}
#endif
	
	while (dcsys_task()) {
		if (np2oscfg.NOWAIT) {
			exec1frame(np2main);

			if (np2oscfg.DRAW_SKIP) {
				// nowait frame skip
				if (np2main.uFrameCount >= np2oscfg.DRAW_SKIP) {
					processwait(np2main, 0);
				}
			} else {
				// nowait auto skip
				if (timing_getcount()) {
					processwait(np2main, 0);
				}
			}
		} else if (np2oscfg.DRAW_SKIP) {
			// frame skip
			if (np2main.uFrameCount < np2oscfg.DRAW_SKIP) {
				exec1frame(np2main);
			} else {
				processwait(np2main, np2oscfg.DRAW_SKIP);
			}
		} else {
			// auto skip
			if (!np2main.uWaitCount) {
				exec1frame(np2main);
				const UINT uCount = timing_getcount();
				if (np2main.uFrameCount > uCount) {
					np2main.uWaitCount = np2main.uFrameCount;
					if (np2main.uFrameMax > 1) {
						np2main.uFrameMax--;
					}
				} else if (np2main.uFrameCount >= np2main.uFrameMax) {
					if (np2main.uFrameMax < MAX_FRAMESKIP) {
						np2main.uFrameMax++;
					}
					if (uCount >= MAX_FRAMESKIP) {
						timing_reset();
					} else {
						timing_setcount(uCount - np2main.uFrameCount);
					}
					framereset(np2main, 0);
				}
			} else {
				processwait(np2main, np2main.uWaitCount);
				np2main.uWaitCount = np2main.uFrameCount;
			}
		}
	}

	pccore_cfgupdate();
#if 0	
	if (np2oscfg.resume) {
		flagsave(str_sav);
	}
	else {
		flagdelete(str_sav);
	}
#endif
	pccore_term();
	S98_trash();
	scrnmng_destroy();

	if (sys_updates & (SYS_UPDATECFG | SYS_UPDATEOSCFG)) {
		initsave();
	}
	TRACETERM();
	dosio_term();

#ifdef NOSERIAL
	(*(void(**)(int))0x8c0000e0)(1);
	while (1) { }
#endif
	
	return 0;
}