From 8bde7f776c77b343aca29b8c7b58464d915ac245 Mon Sep 17 00:00:00 2001 From: wdenk Date: Fri, 27 Jun 2003 21:31:46 +0000 Subject: * Code cleanup: - remove trailing white space, trailing empty lines, C++ comments, etc. - split cmd_boot.c (separate cmd_bdinfo.c and cmd_load.c) * Patches by Kenneth Johansson, 25 Jun 2003: - major rework of command structure (work done mostly by Michal Cendrowski and Joakim Kristiansen) --- .../bios_emulator/scitech/src/pm/win32/cpuinfo.c | 22 +- .../MAI/bios_emulator/scitech/src/pm/win32/ddraw.c | 357 +++++++++-------- .../MAI/bios_emulator/scitech/src/pm/win32/event.c | 285 +++++++------- .../bios_emulator/scitech/src/pm/win32/ntservc.c | 183 +++++---- .../MAI/bios_emulator/scitech/src/pm/win32/oshdr.h | 3 +- board/MAI/bios_emulator/scitech/src/pm/win32/pm.c | 435 ++++++++++----------- .../bios_emulator/scitech/src/pm/win32/ztimer.c | 30 +- 7 files changed, 655 insertions(+), 660 deletions(-) (limited to 'board/MAI/bios_emulator/scitech/src/pm/win32') diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c b/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c index 5978b9f76e..7da9752051 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/cpuinfo.c @@ -46,7 +46,7 @@ static int SetMaxThreadPriority(void) oldPriority = GetThreadPriority(hThread); if (oldPriority != THREAD_PRIORITY_ERROR_RETURN) - SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); + SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); return oldPriority; } @@ -60,7 +60,7 @@ static void RestoreThreadPriority( HANDLE hThread = GetCurrentThread(); if (oldPriority != THREAD_PRIORITY_ERROR_RETURN) - SetThreadPriority(hThread, oldPriority); + SetThreadPriority(hThread, oldPriority); } /**************************************************************************** @@ -71,12 +71,12 @@ static void GetCounterFrequency( CPU_largeInteger *freq) { if (!QueryPerformanceFrequency((LARGE_INTEGER*)freq)) { - havePerformanceCounter = false; - freq->low = 100000; - freq->high = 0; - } + havePerformanceCounter = false; + freq->low = 100000; + freq->high = 0; + } else - havePerformanceCounter = true; + havePerformanceCounter = true; } /**************************************************************************** @@ -86,9 +86,9 @@ Read the counter and return the counter value. #define GetCounter(t) \ { \ if (havePerformanceCounter) \ - QueryPerformanceCounter((LARGE_INTEGER*)t); \ + QueryPerformanceCounter((LARGE_INTEGER*)t); \ else { \ - (t)->low = timeGetTime() * 100; \ - (t)->high = 0; \ - } \ + (t)->low = timeGetTime() * 100; \ + (t)->high = 0; \ + } \ } diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c b/board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c index cf89401fe6..d6c3f60e84 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/ddraw.c @@ -85,11 +85,11 @@ static void DisableAutoPlay(void) HKEY hKey; if (RegOpenKeyEx(HKEY_CURRENT_USER,szAutoPlayKey,0,KEY_EXECUTE | KEY_WRITE,&hKey) == ERROR_SUCCESS) { - RegQueryValueEx(hKey,szAutoPlayValue,NULL,NULL,(void*)&dwAutoPlay,&dwSize); - dwAutoPlay |= AUTOPLAY_DRIVE_CDROM; - RegSetValueEx(hKey,szAutoPlayValue,0,REG_DWORD,(void*)&dwAutoPlay,dwSize); - RegCloseKey(hKey); - } + RegQueryValueEx(hKey,szAutoPlayValue,NULL,NULL,(void*)&dwAutoPlay,&dwSize); + dwAutoPlay |= AUTOPLAY_DRIVE_CDROM; + RegSetValueEx(hKey,szAutoPlayValue,0,REG_DWORD,(void*)&dwAutoPlay,dwSize); + RegCloseKey(hKey); + } } /**************************************************************************** @@ -102,11 +102,11 @@ static void RestoreAutoPlay(void) HKEY hKey; if (RegOpenKeyEx(HKEY_CURRENT_USER,szAutoPlayKey,0,KEY_EXECUTE | KEY_WRITE,&hKey) == ERROR_SUCCESS) { - RegQueryValueEx(hKey,szAutoPlayValue,NULL,NULL,(void*)&dwAutoPlay,&dwSize); - dwAutoPlay &= ~AUTOPLAY_DRIVE_CDROM; - RegSetValueEx(hKey,szAutoPlayValue,0,REG_DWORD,(void*)&dwAutoPlay,dwSize); - RegCloseKey(hKey); - } + RegQueryValueEx(hKey,szAutoPlayValue,NULL,NULL,(void*)&dwAutoPlay,&dwSize); + dwAutoPlay &= ~AUTOPLAY_DRIVE_CDROM; + RegSetValueEx(hKey,szAutoPlayValue,0,REG_DWORD,(void*)&dwAutoPlay,dwSize); + RegCloseKey(hKey); + } } /**************************************************************************** @@ -121,20 +121,20 @@ static void LeaveFullScreen(void) int retCode = PM_SUSPEND_APP; if (backInGDI) - return; + return; if (suspendApp) - retCode = suspendApp(PM_DEACTIVATE); + retCode = suspendApp(PM_DEACTIVATE); RestoreAutoPlay(); backInGDI = true; /* Now process messages normally until we are re-activated */ waitActive = true; if (retCode != PM_NO_SUSPEND_APP) { - while (waitActive) { - _EVT_pumpMessages(); - Sleep(200); - } - } + while (waitActive) { + _EVT_pumpMessages(); + Sleep(200); + } + } } /**************************************************************************** @@ -147,27 +147,27 @@ static void RestoreFullScreen(void) static ibool firstTime = true; if (firstTime) { - /* Clear the message queue while waiting for the surfaces to be - * restored. - */ - firstTime = false; - while (1) { - /* Continue looping until out application has been restored - * and we have reset the display mode. - */ - _EVT_pumpMessages(); - if (GetActiveWindow() == _PM_hwndConsole) { - if (suspendApp) - suspendApp(PM_REACTIVATE); - DisableAutoPlay(); - backInGDI = false; - waitActive = false; - firstTime = true; - return; - } - Sleep(200); - } - } + /* Clear the message queue while waiting for the surfaces to be + * restored. + */ + firstTime = false; + while (1) { + /* Continue looping until out application has been restored + * and we have reset the display mode. + */ + _EVT_pumpMessages(); + if (GetActiveWindow() == _PM_hwndConsole) { + if (suspendApp) + suspendApp(PM_REACTIVATE); + DisableAutoPlay(); + backInGDI = false; + waitActive = false; + firstTime = true; + return; + } + Sleep(200); + } + } } /**************************************************************************** @@ -192,17 +192,17 @@ void PMAPI PM_doSuspendApp(void) /* Call system DLL version if found */ if (_PM_imports.PM_doSuspendApp != PM_doSuspendApp) { - _PM_imports.PM_doSuspendApp(); - return; - } + _PM_imports.PM_doSuspendApp(); + return; + } if (firstTime) { - if (suspendApp) - suspendApp(PM_DEACTIVATE); - RestoreAutoPlay(); - firstTime = false; - backInGDI = true; - } + if (suspendApp) + suspendApp(PM_DEACTIVATE); + RestoreAutoPlay(); + firstTime = false; + backInGDI = true; + } RestoreFullScreen(); firstTime = true; } @@ -220,60 +220,60 @@ static LONG CALLBACK PM_winProc( LONG lParam) { switch (msg) { - case WM_SYSCHAR: - /* Stop Alt-Space from pausing our application */ - return 0; - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - if (HIWORD(lParam) & KF_REPEAT) { - if (msg == WM_SYSKEYDOWN) - return 0; - break; - } - /* Fall through for keydown events */ - case WM_KEYUP: - case WM_SYSKEYUP: - if (msg == WM_SYSKEYDOWN || msg == WM_SYSKEYUP) { - if ((HIWORD(lParam) & KF_ALTDOWN) && wParam == VK_RETURN) - break; - /* We ignore the remainder of the system keys to stop the - * system menu from being activated from the keyboard and pausing - * our app while fullscreen (ie: pressing the Alt key). - */ - return 0; - } - break; - case WM_SYSCOMMAND: - switch (wParam & ~0x0F) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - /* Ignore screensaver requests in fullscreen modes */ - return 0; - } - break; - case WM_SIZE: - if (waitActive && backInGDI && (wParam != SIZE_MINIMIZED)) { - /* Start the re-activation process */ - PostMessage(hwnd,WM_DO_SUSPEND_APP,WM_PM_RESTORE_FULLSCREEN,0); - } - else if (!waitActive && isFullScreen && !backInGDI && (wParam == SIZE_MINIMIZED)) { - /* Start the de-activation process */ - PostMessage(hwnd,WM_DO_SUSPEND_APP,WM_PM_LEAVE_FULLSCREEN,0); - } - break; - case WM_DO_SUSPEND_APP: - switch (wParam) { + case WM_SYSCHAR: + /* Stop Alt-Space from pausing our application */ + return 0; + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + if (HIWORD(lParam) & KF_REPEAT) { + if (msg == WM_SYSKEYDOWN) + return 0; + break; + } + /* Fall through for keydown events */ + case WM_KEYUP: + case WM_SYSKEYUP: + if (msg == WM_SYSKEYDOWN || msg == WM_SYSKEYUP) { + if ((HIWORD(lParam) & KF_ALTDOWN) && wParam == VK_RETURN) + break; + /* We ignore the remainder of the system keys to stop the + * system menu from being activated from the keyboard and pausing + * our app while fullscreen (ie: pressing the Alt key). + */ + return 0; + } + break; + case WM_SYSCOMMAND: + switch (wParam & ~0x0F) { + case SC_SCREENSAVE: + case SC_MONITORPOWER: + /* Ignore screensaver requests in fullscreen modes */ + return 0; + } + break; + case WM_SIZE: + if (waitActive && backInGDI && (wParam != SIZE_MINIMIZED)) { + /* Start the re-activation process */ + PostMessage(hwnd,WM_DO_SUSPEND_APP,WM_PM_RESTORE_FULLSCREEN,0); + } + else if (!waitActive && isFullScreen && !backInGDI && (wParam == SIZE_MINIMIZED)) { + /* Start the de-activation process */ + PostMessage(hwnd,WM_DO_SUSPEND_APP,WM_PM_LEAVE_FULLSCREEN,0); + } + break; + case WM_DO_SUSPEND_APP: + switch (wParam) { case WM_PM_RESTORE_FULLSCREEN: RestoreFullScreen(); break; case WM_PM_LEAVE_FULLSCREEN: LeaveFullScreen(); break; - } - return 0; - } + } + return 0; + } if (oldWinProc) - return oldWinProc(hwnd,msg,wParam,lParam); + return oldWinProc(hwnd,msg,wParam,lParam); return DefWindowProc(hwnd,msg,wParam,lParam); } @@ -349,32 +349,32 @@ void * PMAPI PM_loadDirectDraw( /* Call system DLL version if found */ if (_PM_imports.PM_loadDirectDraw != PM_loadDirectDraw) - return _PM_imports.PM_loadDirectDraw(device); + return _PM_imports.PM_loadDirectDraw(device); - // TODO: Handle multi-monitor!! + /* TODO: Handle multi-monitor!! */ if (device != 0) - return NULL; + return NULL; /* Load the DirectDraw DLL if not presently loaded */ GET_DEFAULT_CW(); if (!hInstDD) { - hdc = GetDC(NULL); - bits = GetDeviceCaps(hdc,BITSPIXEL); - ReleaseDC(NULL,hdc); - if (bits < 8) - return NULL; - if ((hInstDD = LoadLibrary("ddraw.dll")) == NULL) - return NULL; - pDirectDrawCreate = (void*)GetProcAddress(hInstDD,"DirectDrawCreate"); - if (!pDirectDrawCreate) - return NULL; - } + hdc = GetDC(NULL); + bits = GetDeviceCaps(hdc,BITSPIXEL); + ReleaseDC(NULL,hdc); + if (bits < 8) + return NULL; + if ((hInstDD = LoadLibrary("ddraw.dll")) == NULL) + return NULL; + pDirectDrawCreate = (void*)GetProcAddress(hInstDD,"DirectDrawCreate"); + if (!pDirectDrawCreate) + return NULL; + } /* Create the DirectDraw object */ if (!lpDD && pDirectDrawCreate(NULL, &lpDD, NULL) != DD_OK) { - lpDD = NULL; - return NULL; - } + lpDD = NULL; + return NULL; + } RESET_DEFAULT_CW(); return lpDD; } @@ -394,13 +394,13 @@ void PMAPI PM_unloadDirectDraw( { /* Call system DLL version if found */ if (_PM_imports.PM_unloadDirectDraw != PM_unloadDirectDraw) { - _PM_imports.PM_unloadDirectDraw(device); - return; - } + _PM_imports.PM_unloadDirectDraw(device); + return; + } if (lpDD) { - IDirectDraw_Release(lpDD); - lpDD = NULL; - } + IDirectDraw_Release(lpDD); + lpDD = NULL; + } (void)device; } @@ -423,56 +423,56 @@ PM_HWND PMAPI PM_openConsole( /* Call system DLL version if found */ GA_getSystemPMImports(); if (_PM_imports.PM_openConsole != PM_openConsole) { - if (fullScreen) { - _PM_deskX = xRes; - _PM_deskY = yRes; - } - return _PM_imports.PM_openConsole(hWndUser,device,xRes,yRes,bpp,fullScreen); - } + if (fullScreen) { + _PM_deskX = xRes; + _PM_deskY = yRes; + } + return _PM_imports.PM_openConsole(hWndUser,device,xRes,yRes,bpp,fullScreen); + } /* Create the fullscreen window if necessary */ hwndUser = hWndUser; if (fullScreen) { - if (!classRegistered) { - /* Create a Window class for the fullscreen window in here, since - * we need to register one that will do all our event handling for - * us. - */ - hInstApp = GetModuleHandle(NULL); - cls.hCursor = LoadCursor(NULL,IDC_ARROW); - cls.hIcon = LoadIcon(hInstApp,MAKEINTRESOURCE(1)); - cls.lpszMenuName = NULL; - cls.lpszClassName = szWinClassName; - cls.hbrBackground = GetStockObject(BLACK_BRUSH); - cls.hInstance = hInstApp; - cls.style = CS_DBLCLKS; - cls.lpfnWndProc = PM_winProc; - cls.cbWndExtra = 0; - cls.cbClsExtra = 0; - if (!RegisterClass(&cls)) - return NULL; - classRegistered = true; - } - _PM_deskX = xRes; - _PM_deskY = yRes; - if (!hwndUser) { - char windowTitle[80]; - if (LoadString(hInstApp,1,windowTitle,sizeof(windowTitle)) == 0) - strcpy(windowTitle,"MGL Fullscreen Application"); - _PM_hwndConsole = CreateWindowEx(WS_EX_APPWINDOW,szWinClassName, - windowTitle,WS_POPUP | WS_SYSMENU,0,0,xRes,yRes, - NULL,NULL,hInstApp,NULL); - } - else { - _PM_hwndConsole = _PM_convertUserWindow(hwndUser,xRes,yRes); - } - ShowCursor(false); - isFullScreen = true; - } + if (!classRegistered) { + /* Create a Window class for the fullscreen window in here, since + * we need to register one that will do all our event handling for + * us. + */ + hInstApp = GetModuleHandle(NULL); + cls.hCursor = LoadCursor(NULL,IDC_ARROW); + cls.hIcon = LoadIcon(hInstApp,MAKEINTRESOURCE(1)); + cls.lpszMenuName = NULL; + cls.lpszClassName = szWinClassName; + cls.hbrBackground = GetStockObject(BLACK_BRUSH); + cls.hInstance = hInstApp; + cls.style = CS_DBLCLKS; + cls.lpfnWndProc = PM_winProc; + cls.cbWndExtra = 0; + cls.cbClsExtra = 0; + if (!RegisterClass(&cls)) + return NULL; + classRegistered = true; + } + _PM_deskX = xRes; + _PM_deskY = yRes; + if (!hwndUser) { + char windowTitle[80]; + if (LoadString(hInstApp,1,windowTitle,sizeof(windowTitle)) == 0) + strcpy(windowTitle,"MGL Fullscreen Application"); + _PM_hwndConsole = CreateWindowEx(WS_EX_APPWINDOW,szWinClassName, + windowTitle,WS_POPUP | WS_SYSMENU,0,0,xRes,yRes, + NULL,NULL,hInstApp,NULL); + } + else { + _PM_hwndConsole = _PM_convertUserWindow(hwndUser,xRes,yRes); + } + ShowCursor(false); + isFullScreen = true; + } else { - _PM_hwndConsole = hwndUser; - isFullScreen = false; - } + _PM_hwndConsole = hwndUser; + isFullScreen = false; + } SetFocus(_PM_hwndConsole); SetForegroundWindow(_PM_hwndConsole); DisableAutoPlay(); @@ -488,7 +488,7 @@ int PMAPI PM_getConsoleStateSize(void) { /* Call system DLL version if found */ if (_PM_imports.PM_getConsoleStateSize != PM_getConsoleStateSize) - return _PM_imports.PM_getConsoleStateSize(); + return _PM_imports.PM_getConsoleStateSize(); /* Not used in Windows */ return 1; @@ -504,9 +504,9 @@ void PMAPI PM_saveConsoleState( { /* Call system DLL version if found */ if (_PM_imports.PM_saveConsoleState != PM_saveConsoleState) { - _PM_imports.PM_saveConsoleState(stateBuf,hwndConsole); - return; - } + _PM_imports.PM_saveConsoleState(stateBuf,hwndConsole); + return; + } /* Not used in Windows */ (void)stateBuf; @@ -522,9 +522,9 @@ void PMAPI PM_setSuspendAppCallback( { /* Call system DLL version if found */ if (_PM_imports.PM_setSuspendAppCallback != PM_setSuspendAppCallback) { - _PM_imports.PM_setSuspendAppCallback(saveState); - return; - } + _PM_imports.PM_setSuspendAppCallback(saveState); + return; + } suspendApp = saveState; } @@ -538,9 +538,9 @@ void PMAPI PM_restoreConsoleState( { /* Call system DLL version if found */ if (_PM_imports.PM_restoreConsoleState != PM_restoreConsoleState) { - _PM_imports.PM_restoreConsoleState(stateBuf,hwndConsole); - return; - } + _PM_imports.PM_restoreConsoleState(stateBuf,hwndConsole); + return; + } /* Not used in Windows */ (void)stateBuf; @@ -556,15 +556,15 @@ void PMAPI PM_closeConsole( { /* Call system DLL version if found */ if (_PM_imports.PM_closeConsole != PM_closeConsole) { - _PM_imports.PM_closeConsole(hwndConsole); - return; - } + _PM_imports.PM_closeConsole(hwndConsole); + return; + } ShowCursor(true); RestoreAutoPlay(); if (hwndUser) - _PM_restoreUserWindow(hwndConsole); + _PM_restoreUserWindow(hwndConsole); else - DestroyWindow(hwndConsole); + DestroyWindow(hwndConsole); hwndUser = NULL; _PM_hwndConsole = NULL; } @@ -577,7 +577,6 @@ PM_HWND PMAPI PM_getDirectDrawWindow(void) { /* Call system DLL version if found */ if (_PM_imports.PM_getDirectDrawWindow != PM_getDirectDrawWindow) - return _PM_imports.PM_getDirectDrawWindow(); + return _PM_imports.PM_getDirectDrawWindow(); return _PM_hwndConsole; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/event.c b/board/MAI/bios_emulator/scitech/src/pm/win32/event.c index c14377dcda..86448e32fa 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/event.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/event.c @@ -70,143 +70,143 @@ void _EVT_pumpMessages(void) MSG charMsg; event_t evt; - // TODO: Add support for DirectInput! We can't support relative mouse - // movement motion counters without DirectInput ;-(. + /* TODO: Add support for DirectInput! We can't support relative mouse */ + /* movement motion counters without DirectInput ;-(. */ while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - memset(&evt,0,sizeof(evt)); - switch (msg.message) { - case WM_MOUSEMOVE: - evt.what = EVT_MOUSEMOVE; - break; - case WM_LBUTTONDBLCLK: - evt.what = EVT_MOUSEDOWN; - evt.message = EVT_LEFTBMASK | EVT_DBLCLICK; - break; - case WM_LBUTTONDOWN: - evt.what = EVT_MOUSEDOWN; - evt.message = EVT_LEFTBMASK; - break; - case WM_LBUTTONUP: - evt.what = EVT_MOUSEUP; - evt.message = EVT_LEFTBMASK; - break; - case WM_RBUTTONDBLCLK: - evt.what = EVT_MOUSEDOWN | EVT_DBLCLICK; - evt.message = EVT_RIGHTBMASK; - break; - case WM_RBUTTONDOWN: - evt.what = EVT_MOUSEDOWN; - evt.message = EVT_RIGHTBMASK; - break; - case WM_RBUTTONUP: - evt.what = EVT_MOUSEUP; - evt.message = EVT_RIGHTBMASK; - break; - case WM_MBUTTONDBLCLK: - evt.what = EVT_MOUSEDOWN | EVT_DBLCLICK; - evt.message = EVT_MIDDLEBMASK; - break; - case WM_MBUTTONDOWN: - evt.what = EVT_MOUSEDOWN; - evt.message = EVT_MIDDLEBMASK; - break; - case WM_MBUTTONUP: - evt.what = EVT_MOUSEUP; - evt.message = EVT_MIDDLEBMASK; - break; - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - if (HIWORD(msg.lParam) & KF_REPEAT) { - evt.what = EVT_KEYREPEAT; - } - else { - evt.what = EVT_KEYDOWN; - } - break; - case WM_KEYUP: - case WM_SYSKEYUP: - evt.what = EVT_KEYUP; - break; - } - - /* Convert mouse event modifier flags */ - if (evt.what & EVT_MOUSEEVT) { - if (_PM_deskX) { - evt.where_x = ((long)msg.pt.x * rangeX) / _PM_deskX; - evt.where_y = ((long)msg.pt.y * rangeY) / _PM_deskY; - } - else { - ScreenToClient(_PM_hwndConsole, &msg.pt); - evt.where_x = msg.pt.x; - evt.where_y = msg.pt.y; - } - if (evt.what == EVT_MOUSEMOVE) { - /* Save the current mouse position */ - EVT.mx = evt.where_x; - EVT.my = evt.where_y; - if (EVT.oldMove != -1) { - EVT.evtq[EVT.oldMove].where_x = evt.where_x;/* Modify existing one */ - EVT.evtq[EVT.oldMove].where_y = evt.where_y; -// EVT.evtq[EVT.oldMove].relative_x += mickeyX; // TODO! -// EVT.evtq[EVT.oldMove].relative_y += mickeyY; // TODO! - evt.what = 0; - } - else { - EVT.oldMove = EVT.freeHead; /* Save id of this move event */ -// evt.relative_x = mickeyX; // TODO! -// evt.relative_y = mickeyY; // TODO! - } - } - else - EVT.oldMove = -1; - if (msg.wParam & MK_LBUTTON) - evt.modifiers |= EVT_LEFTBUT; - if (msg.wParam & MK_RBUTTON) - evt.modifiers |= EVT_RIGHTBUT; - if (msg.wParam & MK_MBUTTON) - evt.modifiers |= EVT_MIDDLEBUT; - if (msg.wParam & MK_SHIFT) - evt.modifiers |= EVT_SHIFTKEY; - if (msg.wParam & MK_CONTROL) - evt.modifiers |= EVT_CTRLSTATE; - } - - /* Convert keyboard codes */ - TranslateMessage(&msg); - if (evt.what & EVT_KEYEVT) { - int scanCode = (msg.lParam >> 16) & 0xFF; - if (evt.what == EVT_KEYUP) { - /* Get message for keyup code from table of cached down values */ - evt.message = keyUpMsg[scanCode]; - keyUpMsg[scanCode] = 0; - } - else { - if (PeekMessage(&charMsg,NULL,WM_CHAR,WM_CHAR,PM_REMOVE)) - evt.message = charMsg.wParam; - if (PeekMessage(&charMsg,NULL,WM_SYSCHAR,WM_SYSCHAR,PM_REMOVE)) - evt.message = charMsg.wParam; - evt.message |= ((msg.lParam >> 8) & 0xFF00); - keyUpMsg[scanCode] = (ushort)evt.message; - } - if (evt.what == EVT_KEYREPEAT) - evt.message |= (msg.lParam << 16); - if (HIWORD(msg.lParam) & KF_ALTDOWN) - evt.modifiers |= EVT_ALTSTATE; - if (GetKeyState(VK_SHIFT) & 0x8000U) - evt.modifiers |= EVT_SHIFTKEY; - if (GetKeyState(VK_CONTROL) & 0x8000U) - evt.modifiers |= EVT_CTRLSTATE; - EVT.oldMove = -1; - } - - if (evt.what != 0) { - /* Add time stamp and add the event to the queue */ - evt.when = msg.time; - if (EVT.count < EVENTQSIZE) - addEvent(&evt); - } - DispatchMessage(&msg); - } + memset(&evt,0,sizeof(evt)); + switch (msg.message) { + case WM_MOUSEMOVE: + evt.what = EVT_MOUSEMOVE; + break; + case WM_LBUTTONDBLCLK: + evt.what = EVT_MOUSEDOWN; + evt.message = EVT_LEFTBMASK | EVT_DBLCLICK; + break; + case WM_LBUTTONDOWN: + evt.what = EVT_MOUSEDOWN; + evt.message = EVT_LEFTBMASK; + break; + case WM_LBUTTONUP: + evt.what = EVT_MOUSEUP; + evt.message = EVT_LEFTBMASK; + break; + case WM_RBUTTONDBLCLK: + evt.what = EVT_MOUSEDOWN | EVT_DBLCLICK; + evt.message = EVT_RIGHTBMASK; + break; + case WM_RBUTTONDOWN: + evt.what = EVT_MOUSEDOWN; + evt.message = EVT_RIGHTBMASK; + break; + case WM_RBUTTONUP: + evt.what = EVT_MOUSEUP; + evt.message = EVT_RIGHTBMASK; + break; + case WM_MBUTTONDBLCLK: + evt.what = EVT_MOUSEDOWN | EVT_DBLCLICK; + evt.message = EVT_MIDDLEBMASK; + break; + case WM_MBUTTONDOWN: + evt.what = EVT_MOUSEDOWN; + evt.message = EVT_MIDDLEBMASK; + break; + case WM_MBUTTONUP: + evt.what = EVT_MOUSEUP; + evt.message = EVT_MIDDLEBMASK; + break; + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + if (HIWORD(msg.lParam) & KF_REPEAT) { + evt.what = EVT_KEYREPEAT; + } + else { + evt.what = EVT_KEYDOWN; + } + break; + case WM_KEYUP: + case WM_SYSKEYUP: + evt.what = EVT_KEYUP; + break; + } + + /* Convert mouse event modifier flags */ + if (evt.what & EVT_MOUSEEVT) { + if (_PM_deskX) { + evt.where_x = ((long)msg.pt.x * rangeX) / _PM_deskX; + evt.where_y = ((long)msg.pt.y * rangeY) / _PM_deskY; + } + else { + ScreenToClient(_PM_hwndConsole, &msg.pt); + evt.where_x = msg.pt.x; + evt.where_y = msg.pt.y; + } + if (evt.what == EVT_MOUSEMOVE) { + /* Save the current mouse position */ + EVT.mx = evt.where_x; + EVT.my = evt.where_y; + if (EVT.oldMove != -1) { + EVT.evtq[EVT.oldMove].where_x = evt.where_x;/* Modify existing one */ + EVT.evtq[EVT.oldMove].where_y = evt.where_y; +/* EVT.evtq[EVT.oldMove].relative_x += mickeyX; // TODO! */ +/* EVT.evtq[EVT.oldMove].relative_y += mickeyY; // TODO! */ + evt.what = 0; + } + else { + EVT.oldMove = EVT.freeHead; /* Save id of this move event */ +/* evt.relative_x = mickeyX; // TODO! */ +/* evt.relative_y = mickeyY; // TODO! */ + } + } + else + EVT.oldMove = -1; + if (msg.wParam & MK_LBUTTON) + evt.modifiers |= EVT_LEFTBUT; + if (msg.wParam & MK_RBUTTON) + evt.modifiers |= EVT_RIGHTBUT; + if (msg.wParam & MK_MBUTTON) + evt.modifiers |= EVT_MIDDLEBUT; + if (msg.wParam & MK_SHIFT) + evt.modifiers |= EVT_SHIFTKEY; + if (msg.wParam & MK_CONTROL) + evt.modifiers |= EVT_CTRLSTATE; + } + + /* Convert keyboard codes */ + TranslateMessage(&msg); + if (evt.what & EVT_KEYEVT) { + int scanCode = (msg.lParam >> 16) & 0xFF; + if (evt.what == EVT_KEYUP) { + /* Get message for keyup code from table of cached down values */ + evt.message = keyUpMsg[scanCode]; + keyUpMsg[scanCode] = 0; + } + else { + if (PeekMessage(&charMsg,NULL,WM_CHAR,WM_CHAR,PM_REMOVE)) + evt.message = charMsg.wParam; + if (PeekMessage(&charMsg,NULL,WM_SYSCHAR,WM_SYSCHAR,PM_REMOVE)) + evt.message = charMsg.wParam; + evt.message |= ((msg.lParam >> 8) & 0xFF00); + keyUpMsg[scanCode] = (ushort)evt.message; + } + if (evt.what == EVT_KEYREPEAT) + evt.message |= (msg.lParam << 16); + if (HIWORD(msg.lParam) & KF_ALTDOWN) + evt.modifiers |= EVT_ALTSTATE; + if (GetKeyState(VK_SHIFT) & 0x8000U) + evt.modifiers |= EVT_SHIFTKEY; + if (GetKeyState(VK_CONTROL) & 0x8000U) + evt.modifiers |= EVT_CTRLSTATE; + EVT.oldMove = -1; + } + + if (evt.what != 0) { + /* Add time stamp and add the event to the queue */ + evt.when = msg.time; + if (EVT.count < EVENTQSIZE) + addEvent(&evt); + } + DispatchMessage(&msg); + } } /**************************************************************************** @@ -299,7 +299,7 @@ and this function can be used to resume it again later. ****************************************************************************/ void EVT_resume(void) { - // Do nothing for Win32 + /* Do nothing for Win32 */ } /**************************************************************************** @@ -309,7 +309,7 @@ de-install the event handling code. ****************************************************************************/ void EVT_suspend(void) { - // Do nothing for Win32 + /* Do nothing for Win32 */ } /**************************************************************************** @@ -343,7 +343,7 @@ EVT_joySetLowerRight, EVT_joySetCenter, EVT_joyIsPresent ****************************************************************************/ int EVTAPI EVT_joyIsPresent(void) { - // TODO: Implement joystick code based on DirectX! + /* TODO: Implement joystick code based on DirectX! */ return 0; } @@ -362,9 +362,9 @@ All information polled from the joystick will be posted to the event queue for later retrieval. Note: Most analogue joysticks will provide readings that change even - though the joystick has not moved. Hence if you call this routine - you will likely get an EVT_JOYMOVE event every time through your - event loop. + though the joystick has not moved. Hence if you call this routine + you will likely get an EVT_JOYMOVE event every time through your + event loop. SEE ALSO: EVT_getNext, EVT_peekNext, EVT_joySetUpperLeft, EVT_joySetLowerRight, @@ -457,4 +457,3 @@ EVT_joySetUpperLeft, EVT_joySetLowerRight, EVT_joySetCenter void EVTAPI EVT_joySetCenter(void) { } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c b/board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c index a3324d33b8..59d9aa0c7c 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/ntservc.c @@ -64,63 +64,63 @@ ulong PMAPI PM_installService( char keyPath[MAX_PATH]; ulong status; - // Obtain a handle to the service control manager requesting all access + /* Obtain a handle to the service control manager requesting all access */ if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); + return GetLastError(); - // Find the path to the driver in system directory + /* Find the path to the driver in system directory */ GetSystemDirectory(szDriverPath, sizeof(szDriverPath)); strcat(szDriverPath, "\\drivers\\"); strcat(szDriverPath, szDriverName); - // Create the service with the Service Control Manager. + /* Create the service with the Service Control Manager. */ driverHandle = CreateService(scmHandle, - szServiceName, - szServiceName, - SERVICE_ALL_ACCESS, - dwServiceType, - SERVICE_BOOT_START, - SERVICE_ERROR_NORMAL, - szDriverPath, - szLoadGroup, - NULL, - NULL, - NULL, - NULL); - - // Check to see if the driver could actually be installed. + szServiceName, + szServiceName, + SERVICE_ALL_ACCESS, + dwServiceType, + SERVICE_BOOT_START, + SERVICE_ERROR_NORMAL, + szDriverPath, + szLoadGroup, + NULL, + NULL, + NULL, + NULL); + + /* Check to see if the driver could actually be installed. */ if (!driverHandle) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(scmHandle); + return status; + } - // Get a handle to the key for driver so that it can be altered in the - // next step. + /* Get a handle to the key for driver so that it can be altered in the */ + /* next step. */ strcpy(keyPath, "SYSTEM\\CurrentControlSet\\Services\\"); strcat(keyPath, szServiceName); if ((status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,keyPath,0,KEY_ALL_ACCESS,&key)) != ERROR_SUCCESS) { - // A problem has occured. Delete the service so that it is not installed. - status = GetLastError(); - DeleteService(driverHandle); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } - - // Delete the ImagePath value in the newly created key so that the - // system looks for the driver in the normal location. + /* A problem has occured. Delete the service so that it is not installed. */ + status = GetLastError(); + DeleteService(driverHandle); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } + + /* Delete the ImagePath value in the newly created key so that the */ + /* system looks for the driver in the normal location. */ if ((status = RegDeleteValue(key, "ImagePath")) != ERROR_SUCCESS) { - // A problem has occurred. Delete the service so that it is not - // installed and will not try to start. - RegCloseKey(key); - DeleteService(driverHandle); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } - - // Clean up and exit + /* A problem has occurred. Delete the service so that it is not */ + /* installed and will not try to start. */ + RegCloseKey(key); + DeleteService(driverHandle); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } + + /* Clean up and exit */ RegCloseKey(key); CloseServiceHandle(driverHandle); CloseServiceHandle(scmHandle); @@ -145,32 +145,32 @@ ulong PMAPI PM_startService( SERVICE_STATUS serviceStatus; ulong status; - // Obtain a handle to the service control manager requesting all access + /* Obtain a handle to the service control manager requesting all access */ if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); + return GetLastError(); - // Open the service with the Service Control Manager. + /* Open the service with the Service Control Manager. */ if ((driverHandle = OpenService(scmHandle,szServiceName,SERVICE_ALL_ACCESS)) == NULL) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(scmHandle); + return status; + } - // Start the service + /* Start the service */ if (!StartService(driverHandle,0,NULL)) { - status = GetLastError(); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } - - // Query the service to make sure it is there - if (!QueryServiceStatus(driverHandle,&serviceStatus)) { - status = GetLastError(); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } + + /* Query the service to make sure it is there */ + if (!QueryServiceStatus(driverHandle,&serviceStatus)) { + status = GetLastError(); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } CloseServiceHandle(driverHandle); CloseServiceHandle(scmHandle); return ERROR_SUCCESS; @@ -194,24 +194,24 @@ ulong PMAPI PM_stopService( SERVICE_STATUS serviceStatus; ulong status; - // Obtain a handle to the service control manager requesting all access + /* Obtain a handle to the service control manager requesting all access */ if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); + return GetLastError(); - // Open the service with the Service Control Manager. + /* Open the service with the Service Control Manager. */ if ((driverHandle = OpenService(scmHandle,szServiceName,SERVICE_ALL_ACCESS)) == NULL) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(scmHandle); + return status; + } - // Stop the service from running + /* Stop the service from running */ if (!ControlService(driverHandle, SERVICE_CONTROL_STOP, &serviceStatus)) { - status = GetLastError(); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } CloseServiceHandle(driverHandle); CloseServiceHandle(scmHandle); return ERROR_SUCCESS; @@ -234,26 +234,25 @@ ulong PMAPI PM_removeService( SC_HANDLE driverHandle; ulong status; - // Obtain a handle to the service control manager requesting all access + /* Obtain a handle to the service control manager requesting all access */ if ((scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL) - return GetLastError(); + return GetLastError(); - // Open the service with the Service Control Manager. + /* Open the service with the Service Control Manager. */ if ((driverHandle = OpenService(scmHandle,szServiceName,SERVICE_ALL_ACCESS)) == NULL) { - status = GetLastError(); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(scmHandle); + return status; + } - // Remove the service + /* Remove the service */ if (!DeleteService(driverHandle)) { - status = GetLastError(); - CloseServiceHandle(driverHandle); - CloseServiceHandle(scmHandle); - return status; - } + status = GetLastError(); + CloseServiceHandle(driverHandle); + CloseServiceHandle(scmHandle); + return status; + } CloseServiceHandle(driverHandle); CloseServiceHandle(scmHandle); return ERROR_SUCCESS; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h b/board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h index 018c936d8a..0c59e9006f 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/oshdr.h @@ -47,7 +47,7 @@ #define GET_DEFAULT_CW() \ { \ if (_PM_cw_default == 0) \ - _PM_cw_default = _control87(0,0); \ + _PM_cw_default = _control87(0,0); \ } #define RESET_DEFAULT_CW() \ _control87(_PM_cw_default,0xFFFFFFFF) @@ -77,4 +77,3 @@ extern HWND _PM_hwndConsole; /* Window handle for console */ /*-------------------------- Internal Functions ---------------------------*/ void _EVT_pumpMessages(void); - diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/pm.c b/board/MAI/bios_emulator/scitech/src/pm/win32/pm.c index d08da4c630..1ffdbccabc 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/pm.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/pm.c @@ -69,10 +69,10 @@ static char *szMachineName = "ComputerName"; #define CHECK_FOR_PMHELP() \ { \ if (_PM_hDevice == INVALID_HANDLE_VALUE) \ - if (_PM_haveWinNT) \ - PM_fatalError("Unable to connect to PMHELP.SYS or SDDHELP.SYS!"); \ - else \ - PM_fatalError("Unable to connect to PMHELP.VXD or SDDHELP.VXD!"); \ + if (_PM_haveWinNT) \ + PM_fatalError("Unable to connect to PMHELP.SYS or SDDHELP.SYS!"); \ + else \ + PM_fatalError("Unable to connect to PMHELP.VXD or SDDHELP.VXD!"); \ } /**************************************************************************** @@ -95,71 +95,71 @@ void PMAPI PM_init(void) * of SDD is loaded, we use the PMHELP VxD instead. */ if (!inited) { - /* Determine if we are running under Windows NT or not and - * set the global OS type variable. - */ - _PM_haveWinNT = false; - if ((GetVersion() & 0x80000000UL) == 0) - _PM_haveWinNT = true; - ___drv_os_type = (_PM_haveWinNT) ? _OS_WINNT : _OS_WIN95; - - /* Now try to connect to SDDHELP.VXD or SDDHELP.SYS */ - _PM_hDevice = CreateFile(SDDHELP_MODULE_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); - if (_PM_hDevice != INVALID_HANDLE_VALUE) { - if (!DeviceIoControl(_PM_hDevice, PMHELP_GETVER32, NULL, 0, - outBuf, sizeof(outBuf), &count, NULL) || outBuf[0] < PMHELP_VERSION) { - /* Old version of SDDHELP loaded, so use PMHELP instead */ - CloseHandle(_PM_hDevice); - _PM_hDevice = INVALID_HANDLE_VALUE; - } - } - if (_PM_hDevice == INVALID_HANDLE_VALUE) { - /* First try to see if there is a currently loaded PMHELP driver. - * This is usually the case when we are running under Windows NT/2K. - */ - _PM_hDevice = CreateFile(PMHELP_MODULE_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); - if (_PM_hDevice == INVALID_HANDLE_VALUE) { - /* The driver was not staticly loaded, so try creating a file handle - * to a dynamic version of the VxD if possible. Note that on WinNT/2K we - * cannot support dynamically loading the drivers. - */ - _PM_hDevice = CreateFile(PMHELP_VXD_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); - } - } - if (_PM_hDevice != INVALID_HANDLE_VALUE) { - /* Call the driver to determine the version number */ - if (!DeviceIoControl(_PM_hDevice, PMHELP_GETVER32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL) || outBuf[0] < PMHELP_VERSION) { - if (_PM_haveWinNT) - PM_fatalError("Older version of PMHELP.SYS found!"); - else - PM_fatalError("Older version of PMHELP.VXD found!"); - } - - /* Now set the current path inside the VxD so it knows what the - * current directory is for loading Nucleus drivers. - */ - inBuf[0] = (ulong)PM_getCurrentPath(cntPath,sizeof(cntPath)); - if (!DeviceIoControl(_PM_hDevice, PMHELP_SETCNTPATH32, inBuf, sizeof(inBuf), outBuf, sizeof(outBuf), &count, NULL)) - PM_fatalError("Unable to set VxD current path!"); - - /* Now pass down the NUCLEUS_PATH environment variable to the device - * driver so it can use this value if it is found. - */ - if ((env = getenv("NUCLEUS_PATH")) != NULL) { - inBuf[0] = (ulong)env; - if (!DeviceIoControl(_PM_hDevice, PMHELP_SETNUCLEUSPATH32, inBuf, sizeof(inBuf), outBuf, sizeof(outBuf), &count, NULL)) - PM_fatalError("Unable to set VxD Nucleus path!"); - } - - /* Enable IOPL for ring-3 code by default if driver is present */ - if (_PM_haveWinNT) - PM_setIOPL(3); - } - - /* Indicate that we have been initialised */ - inited = true; - } + /* Determine if we are running under Windows NT or not and + * set the global OS type variable. + */ + _PM_haveWinNT = false; + if ((GetVersion() & 0x80000000UL) == 0) + _PM_haveWinNT = true; + ___drv_os_type = (_PM_haveWinNT) ? _OS_WINNT : _OS_WIN95; + + /* Now try to connect to SDDHELP.VXD or SDDHELP.SYS */ + _PM_hDevice = CreateFile(SDDHELP_MODULE_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); + if (_PM_hDevice != INVALID_HANDLE_VALUE) { + if (!DeviceIoControl(_PM_hDevice, PMHELP_GETVER32, NULL, 0, + outBuf, sizeof(outBuf), &count, NULL) || outBuf[0] < PMHELP_VERSION) { + /* Old version of SDDHELP loaded, so use PMHELP instead */ + CloseHandle(_PM_hDevice); + _PM_hDevice = INVALID_HANDLE_VALUE; + } + } + if (_PM_hDevice == INVALID_HANDLE_VALUE) { + /* First try to see if there is a currently loaded PMHELP driver. + * This is usually the case when we are running under Windows NT/2K. + */ + _PM_hDevice = CreateFile(PMHELP_MODULE_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); + if (_PM_hDevice == INVALID_HANDLE_VALUE) { + /* The driver was not staticly loaded, so try creating a file handle + * to a dynamic version of the VxD if possible. Note that on WinNT/2K we + * cannot support dynamically loading the drivers. + */ + _PM_hDevice = CreateFile(PMHELP_VXD_PATH, 0,0,0, CREATE_NEW, FILE_FLAG_DELETE_ON_CLOSE, 0); + } + } + if (_PM_hDevice != INVALID_HANDLE_VALUE) { + /* Call the driver to determine the version number */ + if (!DeviceIoControl(_PM_hDevice, PMHELP_GETVER32, inBuf, sizeof(inBuf), + outBuf, sizeof(outBuf), &count, NULL) || outBuf[0] < PMHELP_VERSION) { + if (_PM_haveWinNT) + PM_fatalError("Older version of PMHELP.SYS found!"); + else + PM_fatalError("Older version of PMHELP.VXD found!"); + } + + /* Now set the current path inside the VxD so it knows what the + * current directory is for loading Nucleus drivers. + */ + inBuf[0] = (ulong)PM_getCurrentPath(cntPath,sizeof(cntPath)); + if (!DeviceIoControl(_PM_hDevice, PMHELP_SETCNTPATH32, inBuf, sizeof(inBuf), outBuf, sizeof(outBuf), &count, NULL)) + PM_fatalError("Unable to set VxD current path!"); + + /* Now pass down the NUCLEUS_PATH environment variable to the device + * driver so it can use this value if it is found. + */ + if ((env = getenv("NUCLEUS_PATH")) != NULL) { + inBuf[0] = (ulong)env; + if (!DeviceIoControl(_PM_hDevice, PMHELP_SETNUCLEUSPATH32, inBuf, sizeof(inBuf), outBuf, sizeof(outBuf), &count, NULL)) + PM_fatalError("Unable to set VxD Nucleus path!"); + } + + /* Enable IOPL for ring-3 code by default if driver is present */ + if (_PM_haveWinNT) + PM_setIOPL(3); + } + + /* Indicate that we have been initialised */ + inited = true; + } } /**************************************************************************** @@ -177,14 +177,14 @@ int PMAPI PM_setIOPL( /* Enable I/O by adjusting the I/O permissions map on Windows NT */ if (_PM_haveWinNT) { - CHECK_FOR_PMHELP(); - if (iopl == 3) - DeviceIoControl(_PM_hDevice, PMHELP_ENABLERING3IOPL, inBuf, sizeof(inBuf),outBuf, sizeof(outBuf), &count, NULL); - else - DeviceIoControl(_PM_hDevice, PMHELP_DISABLERING3IOPL, inBuf, sizeof(inBuf),outBuf, sizeof(outBuf), &count, NULL); - cntIOPL = iopl; - return oldIOPL; - } + CHECK_FOR_PMHELP(); + if (iopl == 3) + DeviceIoControl(_PM_hDevice, PMHELP_ENABLERING3IOPL, inBuf, sizeof(inBuf),outBuf, sizeof(outBuf), &count, NULL); + else + DeviceIoControl(_PM_hDevice, PMHELP_DISABLERING3IOPL, inBuf, sizeof(inBuf),outBuf, sizeof(outBuf), &count, NULL); + cntIOPL = iopl; + return oldIOPL; + } /* We always have IOPL on Windows 9x */ return 3; @@ -197,9 +197,9 @@ We do have BIOS access under Windows 9x, but not under Windows NT. ibool PMAPI PM_haveBIOSAccess(void) { if (PM_getOSType() == _OS_WINNT) - return false; + return false; else - return _PM_hDevice != INVALID_HANDLE_VALUE; + return _PM_hDevice != INVALID_HANDLE_VALUE; } /**************************************************************************** @@ -209,9 +209,9 @@ Return the operating system type identifier. long PMAPI PM_getOSType(void) { if ((GetVersion() & 0x80000000UL) == 0) - return ___drv_os_type = _OS_WINNT; + return ___drv_os_type = _OS_WINNT; else - return ___drv_os_type = _OS_WIN95; + return ___drv_os_type = _OS_WIN95; } /**************************************************************************** @@ -232,9 +232,9 @@ void PMAPI PM_backslash( { uint pos = strlen(s); if (s[pos-1] != '\\') { - s[pos] = '\\'; - s[pos+1] = '\0'; - } + s[pos] = '\\'; + s[pos+1] = '\0'; + } } /**************************************************************************** @@ -255,7 +255,7 @@ void PMAPI PM_fatalError( const char *msg) { if (fatalErrorCleanup) - fatalErrorCleanup(); + fatalErrorCleanup(); MessageBox(NULL,msg,"Fatal Error!", MB_ICONEXCLAMATION); exit(1); } @@ -279,19 +279,19 @@ void * PMAPI PM_getVESABuf( * memory blocks out of order). */ if (!inited) - PM_init(); + PM_init(); if (!VESABuf_ptr) { - CHECK_FOR_PMHELP(); - if (DeviceIoControl(_PM_hDevice, PMHELP_GETVESABUF32, NULL, 0, - outBuf, sizeof(outBuf), &count, NULL)) { - if (!outBuf[0]) - return NULL; - VESABuf_ptr = (void*)outBuf[0]; - VESABuf_len = outBuf[1]; - VESABuf_rseg = outBuf[2]; - VESABuf_roff = outBuf[3]; - } - } + CHECK_FOR_PMHELP(); + if (DeviceIoControl(_PM_hDevice, PMHELP_GETVESABUF32, NULL, 0, + outBuf, sizeof(outBuf), &count, NULL)) { + if (!outBuf[0]) + return NULL; + VESABuf_ptr = (void*)outBuf[0]; + VESABuf_len = outBuf[1]; + VESABuf_rseg = outBuf[2]; + VESABuf_roff = outBuf[3]; + } + } *len = VESABuf_len; *rseg = VESABuf_rseg; *roff = VESABuf_roff; @@ -405,7 +405,7 @@ static ibool REG_queryStringEx( DWORD type; if (RegQueryValueEx(hKey,(PCHAR)szValue,(PDWORD)NULL,(PDWORD)&type,(LPBYTE)value,(PDWORD)&size) == ERROR_SUCCESS) - return true; + return true; return false; } @@ -424,9 +424,9 @@ static ibool REG_queryString( memset(value,0,sizeof(value)); if (RegOpenKey(HKEY_LOCAL_MACHINE,szKey,&hKey) == ERROR_SUCCESS) { - status = REG_queryStringEx(hKey,szValue,value,size); - RegCloseKey(hKey); - } + status = REG_queryStringEx(hKey,szValue,value,size); + RegCloseKey(hKey); + } return status; } @@ -460,7 +460,7 @@ const char * PMAPI PM_getNucleusPath(void) char *env; if ((env = getenv("NUCLEUS_PATH")) != NULL) - return env; + return env; GetSystemDirectory(path,sizeof(path)); strcat(path,"\\nucleus"); return path; @@ -497,9 +497,9 @@ const char * PMAPI PM_getMachineName(void) static char name[256]; if (REG_queryString(szMachineNameKey,szMachineName,name,sizeof(name))) - return name; + return name; if (REG_queryString(szMachineNameKeyNT,szMachineName,name,sizeof(name))) - return name; + return name; return "Unknown"; } @@ -510,13 +510,13 @@ Return a pointer to the real mode BIOS data area. void * PMAPI PM_getBIOSPointer(void) { if (_PM_haveWinNT) { - /* On Windows NT we have to map it physically directly */ + /* On Windows NT we have to map it physically directly */ return PM_mapPhysicalAddr(0x400, 0x1000, true); - } + } else { - /* For Windows 9x we can access this memory directly */ - return (void*)0x400; - } + /* For Windows 9x we can access this memory directly */ + return (void*)0x400; + } } /**************************************************************************** @@ -526,16 +526,16 @@ Return a pointer to 0xA0000 physical VGA graphics framebuffer. void * PMAPI PM_getA0000Pointer(void) { if (_PM_haveWinNT) { - /* On Windows NT we have to map it physically directly */ + /* On Windows NT we have to map it physically directly */ return PM_mapPhysicalAddr(0xA0000, 0x0FFFF, false); - } + } else { - /* Always use the 0xA0000 linear address so that we will use - * whatever page table mappings are set up for us (ie: for virtual - * bank switching. - */ - return (void*)0xA0000; - } + /* Always use the 0xA0000 linear address so that we will use + * whatever page table mappings are set up for us (ie: for virtual + * bank switching. + */ + return (void*)0xA0000; + } } /**************************************************************************** @@ -552,14 +552,14 @@ void * PMAPI PM_mapPhysicalAddr( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = base; inBuf[1] = limit; inBuf[2] = isCached; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_MAPPHYS32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return (void*)outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return (void*)outBuf[0]; return NULL; } @@ -590,12 +590,12 @@ ulong PMAPI PM_getPhysicalAddr( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = (ulong)p; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_GETPHYSICALADDR32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0xFFFFFFFFUL; } @@ -613,14 +613,14 @@ ibool PMAPI PM_getPhysicalAddrRange( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = (ulong)p; inBuf[1] = (ulong)length; inBuf[2] = (ulong)physAddress; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_GETPHYSICALADDRRANGE32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return false; } @@ -640,14 +640,14 @@ Return the base I/O port for the specified COM port. ****************************************************************************/ int PMAPI PM_getCOMPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ switch (port) { - case 0: return 0x3F8; - case 1: return 0x2F8; - case 2: return 0x3E8; - case 3: return 0x2E8; - } + case 0: return 0x3F8; + case 1: return 0x2F8; + case 2: return 0x3E8; + case 3: return 0x2E8; + } return 0; } @@ -657,13 +657,13 @@ Return the base I/O port for the specified LPT port. ****************************************************************************/ int PMAPI PM_getLPTPort(int port) { - // TODO: Re-code this to determine real values using the Plug and Play - // manager for the OS. + /* TODO: Re-code this to determine real values using the Plug and Play */ + /* manager for the OS. */ switch (port) { - case 0: return 0x3BC; - case 1: return 0x378; - case 2: return 0x278; - } + case 0: return 0x3BC; + case 1: return 0x378; + case 2: return 0x278; + } return 0; } @@ -685,8 +685,8 @@ void * PMAPI PM_mallocShared( inBuf[0] = size; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_MALLOCSHARED32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return (void*)outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return (void*)outBuf[0]; return NULL; } @@ -772,12 +772,12 @@ void PMAPI DPMI_int86( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = intno; inBuf[1] = (ulong)regs; CHECK_FOR_PMHELP(); DeviceIoControl(_PM_hDevice, PMHELP_DPMIINT8632, inBuf, sizeof(inBuf), - NULL, 0, &count, NULL); + NULL, 0, &count, NULL); } /**************************************************************************** @@ -794,14 +794,14 @@ int PMAPI PM_int86( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = intno; inBuf[1] = (ulong)in; inBuf[2] = (ulong)out; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_INT8632, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -820,15 +820,15 @@ int PMAPI PM_int86x( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = intno; inBuf[1] = (ulong)in; inBuf[2] = (ulong)out; inBuf[3] = (ulong)sregs; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_INT86X32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -846,14 +846,14 @@ void PMAPI PM_callRealMode( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = seg; inBuf[1] = off; inBuf[2] = (ulong)in; inBuf[3] = (ulong)sregs; CHECK_FOR_PMHELP(); DeviceIoControl(_PM_hDevice, PMHELP_CALLREALMODE32, inBuf, sizeof(inBuf), - NULL, 0, &count, NULL); + NULL, 0, &count, NULL); } /**************************************************************************** @@ -883,15 +883,15 @@ void * PMAPI PM_allocLockedMem( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = size; inBuf[1] = (ulong)physAddr; inBuf[2] = (ulong)contiguous; inBuf[3] = (ulong)below16M; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_ALLOCLOCKED32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return (void*)outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return (void*)outBuf[0]; return NULL; } @@ -908,13 +908,13 @@ void PMAPI PM_freeLockedMem( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = (ulong)p; inBuf[1] = size; inBuf[2] = contiguous; CHECK_FOR_PMHELP(); DeviceIoControl(_PM_hDevice, PMHELP_FREELOCKED32, inBuf, sizeof(inBuf), - NULL, 0, &count, NULL); + NULL, 0, &count, NULL); } /**************************************************************************** @@ -929,12 +929,12 @@ void * PMAPI PM_allocPage( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = locked; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_ALLOCPAGE32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return (void*)outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return (void*)outBuf[0]; return NULL; } @@ -949,11 +949,11 @@ void PMAPI PM_freePage( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = (ulong)p; CHECK_FOR_PMHELP(); DeviceIoControl(_PM_hDevice, PMHELP_FREEPAGE32, inBuf, sizeof(inBuf), - NULL, 0, &count, NULL); + NULL, 0, &count, NULL); } /**************************************************************************** @@ -971,8 +971,8 @@ int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh) inBuf[2] = (ulong)lh; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_LOCKDATAPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -991,8 +991,8 @@ int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh) inBuf[2] = (ulong)lh; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_UNLOCKDATAPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -1011,8 +1011,8 @@ int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh) inBuf[2] = (ulong)lh; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_LOCKCODEPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -1031,8 +1031,8 @@ int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh) inBuf[2] = (ulong)lh; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_UNLOCKCODEPAGES32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -1099,14 +1099,14 @@ ibool PMAPI PM_enableWriteCombine( DWORD count; /* Count of bytes returned from VxD */ if (!inited) - PM_init(); + PM_init(); inBuf[0] = base; inBuf[1] = length; inBuf[2] = type; CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_ENABLELFBCOMB32, inBuf, sizeof(inBuf), - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return false; } @@ -1121,8 +1121,8 @@ ulong PMAPI _PM_getPDB(void) CHECK_FOR_PMHELP(); if (DeviceIoControl(_PM_hDevice, PMHELP_GETPDB32, NULL, 0, - outBuf, sizeof(outBuf), &count, NULL)) - return outBuf[0]; + outBuf, sizeof(outBuf), &count, NULL)) + return outBuf[0]; return 0; } @@ -1201,15 +1201,15 @@ static void convertFindData( memset(findData,0,findData->dwSize); findData->dwSize = dwSize; if (blk->dwFileAttributes & FILE_ATTRIBUTE_READONLY) - findData->attrib |= PM_FILE_READONLY; + findData->attrib |= PM_FILE_READONLY; if (blk->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - findData->attrib |= PM_FILE_DIRECTORY; + findData->attrib |= PM_FILE_DIRECTORY; if (blk->dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) - findData->attrib |= PM_FILE_ARCHIVE; + findData->attrib |= PM_FILE_ARCHIVE; if (blk->dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) - findData->attrib |= PM_FILE_HIDDEN; + findData->attrib |= PM_FILE_HIDDEN; if (blk->dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) - findData->attrib |= PM_FILE_SYSTEM; + findData->attrib |= PM_FILE_SYSTEM; findData->sizeLo = blk->nFileSizeLow; findData->sizeHi = blk->nFileSizeHigh; strncpy(findData->name,blk->cFileName,PM_MAX_PATH); @@ -1228,9 +1228,9 @@ void *PMAPI PM_findFirstFile( HANDLE hfile; if ((hfile = FindFirstFile(filename,&blk)) != INVALID_HANDLE_VALUE) { - convertFindData(findData,&blk); - return (void*)hfile; - } + convertFindData(findData,&blk); + return (void*)hfile; + } return PM_FILE_INVALID; } @@ -1245,9 +1245,9 @@ ibool PMAPI PM_findNextFile( WIN32_FIND_DATA blk; if (FindNextFile((HANDLE)handle,&blk)) { - convertFindData(findData,&blk); - return true; - } + convertFindData(findData,&blk); + return true; + } return false; } @@ -1295,8 +1295,8 @@ void PMAPI PM_getdcwd( char *dir, int len) { - // NT stores the current directory for drive N in the magic environment - // variable =N: so we simply look for that environment variable. + /* NT stores the current directory for drive N in the magic environment */ + /* variable =N: so we simply look for that environment variable. */ char envname[4]; envname[0] = '='; @@ -1304,14 +1304,14 @@ void PMAPI PM_getdcwd( envname[2] = ':'; envname[3] = '\0'; if (GetEnvironmentVariable(envname,dir,len) == 0) { - // The current directory or the drive has not been set yet, so - // simply set it to the root. - dir[0] = envname[1]; - dir[1] = ':'; - dir[2] = '\\'; - dir[3] = '\0'; - SetEnvironmentVariable(envname,dir); - } + /* The current directory or the drive has not been set yet, so */ + /* simply set it to the root. */ + dir[0] = envname[1]; + dir[1] = ':'; + dir[2] = '\\'; + dir[3] = '\0'; + SetEnvironmentVariable(envname,dir); + } } /**************************************************************************** @@ -1325,13 +1325,13 @@ void PMAPI PM_setFileAttr( DWORD attr = 0; if (attrib & PM_FILE_READONLY) - attr |= FILE_ATTRIBUTE_READONLY; + attr |= FILE_ATTRIBUTE_READONLY; if (attrib & PM_FILE_ARCHIVE) - attr |= FILE_ATTRIBUTE_ARCHIVE; + attr |= FILE_ATTRIBUTE_ARCHIVE; if (attrib & PM_FILE_HIDDEN) - attr |= FILE_ATTRIBUTE_HIDDEN; + attr |= FILE_ATTRIBUTE_HIDDEN; if (attrib & PM_FILE_SYSTEM) - attr |= FILE_ATTRIBUTE_SYSTEM; + attr |= FILE_ATTRIBUTE_SYSTEM; SetFileAttributes((LPSTR)filename, attr); } @@ -1346,13 +1346,13 @@ uint PMAPI PM_getFileAttr( uint attrib = 0; if (attr & FILE_ATTRIBUTE_READONLY) - attrib |= PM_FILE_READONLY; + attrib |= PM_FILE_READONLY; if (attr & FILE_ATTRIBUTE_ARCHIVE) - attrib |= PM_FILE_ARCHIVE; + attrib |= PM_FILE_ARCHIVE; if (attr & FILE_ATTRIBUTE_HIDDEN) - attrib |= PM_FILE_HIDDEN; + attrib |= PM_FILE_HIDDEN; if (attr & FILE_ATTRIBUTE_SYSTEM) - attrib |= PM_FILE_SYSTEM; + attrib |= PM_FILE_SYSTEM; return attrib; } @@ -1393,17 +1393,17 @@ ibool PMAPI PM_getFileTime( of.cBytes = sizeof(of); if ((f = OpenFile(filename,&of,OF_READ)) == HFILE_ERROR) - return false; + return false; if (!GetFileTime((HANDLE)f,NULL,NULL,&utcTime)) - goto Exit; + goto Exit; if (!gmTime) { - if (!FileTimeToLocalFileTime(&utcTime,&localTime)) - goto Exit; - } + if (!FileTimeToLocalFileTime(&utcTime,&localTime)) + goto Exit; + } else - localTime = utcTime; + localTime = utcTime; if (!FileTimeToSystemTime(&localTime,&sysTime)) - goto Exit; + goto Exit; time->year = sysTime.wYear; time->mon = sysTime.wMonth-1; time->day = sysTime.wYear; @@ -1434,7 +1434,7 @@ ibool PMAPI PM_setFileTime( of.cBytes = sizeof(of); if ((f = OpenFile(filename,&of,OF_WRITE)) == HFILE_ERROR) - return false; + return false; sysTime.wYear = time->year; sysTime.wMonth = time->mon+1; sysTime.wYear = time->day; @@ -1442,19 +1442,18 @@ ibool PMAPI PM_setFileTime( sysTime.wMinute = time->min; sysTime.wSecond = time->sec; if (!SystemTimeToFileTime(&sysTime,&localTime)) - goto Exit; + goto Exit; if (!gmTime) { - if (!LocalFileTimeToFileTime(&localTime,&utcTime)) - goto Exit; - } + if (!LocalFileTimeToFileTime(&localTime,&utcTime)) + goto Exit; + } else - utcTime = localTime; + utcTime = localTime; if (!SetFileTime((HANDLE)f,NULL,NULL,&utcTime)) - goto Exit; + goto Exit; status = true; Exit: CloseHandle((HANDLE)f); return status; } - diff --git a/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c b/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c index 318929a2c0..5a901a4422 100644 --- a/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c +++ b/board/MAI/bios_emulator/scitech/src/pm/win32/ztimer.c @@ -57,9 +57,9 @@ static void __LZTimerOn( LZTimerObject *tm) { if (havePerformanceCounter) - QueryPerformanceCounter((LARGE_INTEGER*)&tm->start); + QueryPerformanceCounter((LARGE_INTEGER*)&tm->start); else - tm->start.low = timeGetTime(); + tm->start.low = timeGetTime(); } /**************************************************************************** @@ -72,14 +72,14 @@ static ulong __LZTimerLap( CPU_largeInteger tmLap,tmCount; if (havePerformanceCounter) { - QueryPerformanceCounter((LARGE_INTEGER*)&tmLap); - _CPU_diffTime64(&tm->start,&tmLap,&tmCount); - return _CPU_calcMicroSec(&tmCount,countFreq.low); - } + QueryPerformanceCounter((LARGE_INTEGER*)&tmLap); + _CPU_diffTime64(&tm->start,&tmLap,&tmCount); + return _CPU_calcMicroSec(&tmCount,countFreq.low); + } else { - tmLap.low = timeGetTime(); - return (tmLap.low - tm->start.low) * 1000L; - } + tmLap.low = timeGetTime(); + return (tmLap.low - tm->start.low) * 1000L; + } } /**************************************************************************** @@ -90,9 +90,9 @@ static void __LZTimerOff( LZTimerObject *tm) { if (havePerformanceCounter) - QueryPerformanceCounter((LARGE_INTEGER*)&tm->end); + QueryPerformanceCounter((LARGE_INTEGER*)&tm->end); else - tm->end.low = timeGetTime(); + tm->end.low = timeGetTime(); } /**************************************************************************** @@ -105,11 +105,11 @@ static ulong __LZTimerCount( CPU_largeInteger tmCount; if (havePerformanceCounter) { - _CPU_diffTime64(&tm->start,&tm->end,&tmCount); - return _CPU_calcMicroSec(&tmCount,countFreq.low); - } + _CPU_diffTime64(&tm->start,&tm->end,&tmCount); + return _CPU_calcMicroSec(&tmCount,countFreq.low); + } else - return (tm->end.low - tm->start.low) * 1000L; + return (tm->end.low - tm->start.low) * 1000L; } /**************************************************************************** -- cgit v1.2.1