Mercurial > mm7
changeset 2459:e5c88c2b02ab
Audio_GetFirstHardwareDigitalDriver
author | Ritor1 |
---|---|
date | Wed, 30 Jul 2014 11:19:53 +0600 |
parents | d53da932f594 |
children | 1921b140607a |
files | Arcomage.cpp AudioPlayer.cpp MMT.cpp OSWindow.cpp Registry.cpp mm7_2.cpp |
diffstat | 6 files changed, 69 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/Arcomage.cpp Sat Jul 26 13:03:43 2014 +0600 +++ b/Arcomage.cpp Wed Jul 30 11:19:53 2014 +0600 @@ -556,16 +556,18 @@ bool ArcomageGame::MsgLoop(int a1, ArcomageGame_stru1 *a2) { void *v2; // ebp@1 - BOOL v3; // eax@1 + //BOOL v3; // eax@1 v2 = a2; pArcomageGame->field_0 = 0; pArcomageGame->stru1.field_0 = 0; - v3 = PeekMessageA(&pArcomageGame->msg, 0, 0, 0, PM_REMOVE); - if ( pArcomageGame->msg.message == WM_QUIT ) - Game_DeinitializeAndTerminate(0); - if ( v3 > 0 ) + //v3 = PeekMessageA(&pArcomageGame->msg, 0, 0, 0, PM_REMOVE); + //if ( pArcomageGame->msg.message == WM_QUIT ) + //Game_DeinitializeAndTerminate(0); + if ( PeekMessageA(&pArcomageGame->msg, 0, 0, 0, PM_REMOVE) ) { + if ( pArcomageGame->msg.message == WM_QUIT ) + Game_DeinitializeAndTerminate(0); TranslateMessage(&pArcomageGame->msg); DispatchMessageA(&pArcomageGame->msg); }
--- a/AudioPlayer.cpp Sat Jul 26 13:03:43 2014 +0600 +++ b/AudioPlayer.cpp Wed Jul 30 11:19:53 2014 +0600 @@ -2238,21 +2238,21 @@ size_t v2; // eax@4 signed int v3; // kr14_4@9 char *v5; // [sp+10h] [bp-Ch]@2 - unsigned int v6; // [sp+14h] [bp-8h]@1 + unsigned int pNum_devices; // [sp+14h] [bp-8h]@1 _DIG_DRIVER *hDrv; // [sp+18h] [bp-4h]@3 - static int dword_4F00DC = 22050; - static int dword_4F00E0 = 16; - static int dword_4F00E4 = 2; + static int sample_Rate = 22050; + static int bitsPerSample = 16; + static int channels = 2; AIL_set_preference(15, 0); AIL_set_preference(33, 1); - v0 = dword_4F00DC; + v0 = sample_Rate; pAudioPlayer->pDeviceNames[0][0] = 0; pAudioPlayer->uNumDevices = 0; - v6 = 0; + pNum_devices = 0; - if ( dword_4F00DC < 11025 ) + if ( sample_Rate < 11025 ) return 0; v1 = 0; v5 = (char *)pAudioPlayer->array_000BF0; @@ -2261,48 +2261,51 @@ while ( 1 ) { pcmWaveFormat.wf.wFormatTag = 1; - pcmWaveFormat.wf.nChannels = dword_4F00E4; + pcmWaveFormat.wf.nChannels = channels;// Channels: 1 = mono, 2 = stereo pcmWaveFormat.wf.nSamplesPerSec = v0; - pcmWaveFormat.wf.nBlockAlign = dword_4F00E4 * dword_4F00E0 / 8; - pcmWaveFormat.wBitsPerSample = dword_4F00E0; - pcmWaveFormat.wf.nAvgBytesPerSec = v0 * dword_4F00E4 * dword_4F00E0 / 8; + pcmWaveFormat.wf.nBlockAlign = channels * bitsPerSample / 8; + pcmWaveFormat.wBitsPerSample = bitsPerSample; + pcmWaveFormat.wf.nAvgBytesPerSec = v0 * channels * bitsPerSample / 8; if ( !AIL_waveOutOpen(&hDrv, 0, -1, &pcmWaveFormat.wf) ) + { + strcpy(pAudioPlayer->pDeviceNames[v1 / 8], "Device: "); + v2 = strlen(pAudioPlayer->pDeviceNames[v1 / 8]); + AIL_digital_configuration(hDrv, (int *)v5, (int *)(v5 + 64), (char *)pAudioPlayer->pDeviceNames + v2 + v1 * 16); + ++pNum_devices; + v1 += 8; + v5 += 4; + pAudioPlayer->uNumDevices = pNum_devices; + if ( AIL_get_preference(15) ) + return hDrv; + if ( !strstr(pAudioPlayer->pDeviceNames[v1 / 8 - 1], "Emulated") ) + return hDrv; + AIL_waveOutClose(hDrv); + AIL_set_preference(15, 1); break; + } if ( !AIL_get_preference(15) ) - goto LABEL_8; - v3 = dword_4F00DC; - v0 = dword_4F00DC / 2; - dword_4F00DC /= 2; - if ( v3 / 2 < 11025 ) { - if ( dword_4F00E0 == 8 ) - { + AIL_set_preference(15, 1); + if ( sample_Rate < 11025 ) + return 0; + break; + } + //v3 = sample_Rate; + v0 = sample_Rate / 2; + sample_Rate /= 2; + if ( sample_Rate / 2 < 11025 ) + { + if ( bitsPerSample == 8 ) + { v0 = 22050; - dword_4F00E0 = 8; - dword_4F00DC = 22050; + bitsPerSample = 8; + sample_Rate = 22050; } - goto LABEL_12; + if ( v0 < 11025 ) + return 0; + break; } } - strcpy(pAudioPlayer->pDeviceNames[v1 / 8], "Device: "); - v2 = strlen(pAudioPlayer->pDeviceNames[v1 / 8]); - AIL_digital_configuration(hDrv, (int *)v5, (int *)(v5 + 64), (char *)pAudioPlayer->pDeviceNames + v2 + v1 * 16); - ++v6; - v1 += 8; - v5 += 4; - pAudioPlayer->uNumDevices = v6; - if ( AIL_get_preference(15) ) - return hDrv; - if ( !strstr(pAudioPlayer->pDeviceNames[v1 / 8 - 1], "Emulated") ) - return hDrv; - AIL_waveOutClose(hDrv); - AIL_set_preference(15, 1); -LABEL_8: - AIL_set_preference(15, 1); - v0 = dword_4F00DC; -LABEL_12: - if ( v0 < 11025 ) - return 0; } }
--- a/MMT.cpp Sat Jul 26 13:03:43 2014 +0600 +++ b/MMT.cpp Wed Jul 30 11:19:53 2014 +0600 @@ -175,6 +175,7 @@ unsigned int pY; // [sp-18h] [bp-54h]@39 Texture *pTexture; // [sp-14h] [bp-50h]@39 char pContainerName[64]; + MSG msg; pCurrentScreen = SCREEN_GAME; @@ -225,7 +226,7 @@ POINT cursor; pMouse->GetCursorPos(&cursor); - for (MSG msg; PeekMessageW(&msg, 0, 0, 0, PM_REMOVE);) + while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) Game_DeinitializeAndTerminate(0); @@ -296,7 +297,7 @@ pRenderer->EndScene(); pRenderer->Present(); - //remove resurs + //remove resource pTexture_PCX.Release(); if ( pGUIWindow2 ) {
--- a/OSWindow.cpp Sat Jul 26 13:03:43 2014 +0600 +++ b/OSWindow.cpp Wed Jul 30 11:19:53 2014 +0600 @@ -401,21 +401,21 @@ bool OSWindow::Initialize(const wchar_t *title, int window_width, int window_height) { WNDCLASSEXW wcxw; + wcxw.cbSize = sizeof(WNDCLASSEXW); + wcxw.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; + wcxw.lpfnWndProc = WinApiMsgRouter; wcxw.cbClsExtra = 0; - wcxw.cbSize = sizeof(wcxw); wcxw.cbWndExtra = 0; - wcxw.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1); - wcxw.hCursor = nullptr; - wcxw.hIcon = wcxw.hIconSm = nullptr; wcxw.hInstance = GetModuleHandleW(nullptr); - wcxw.lpfnWndProc = WinApiMsgRouter; + wcxw.hIcon = wcxw.hIconSm = LoadIcon(NULL, IDI_QUESTION);// nullptr; + wcxw.hCursor = LoadCursor(NULL, IDC_WAIT);//nullptr; + wcxw.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);//(COLOR_BACKGROUND + 1); + wcxw.lpszMenuName = nullptr; wcxw.lpszClassName = L"M&MTrilogy"; - wcxw.lpszMenuName = nullptr; - wcxw.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; if (!RegisterClassExW(&wcxw)) return false; - api_handle = CreateWindowExW(0, wcxw.lpszClassName, title, 0, + api_handle = CreateWindowExW(NULL, wcxw.lpszClassName, title, 0, ReadWindowsRegistryInt("window X", (GetSystemMetrics(SM_CXSCREEN) - window_width) / 2), ReadWindowsRegistryInt("window Y", (GetSystemMetrics(SM_CYSCREEN) - window_height) / 2), window_width, window_height, nullptr, @@ -459,7 +459,7 @@ -LRESULT __stdcall OSWindow::WinApiMsgRouter(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +LRESULT CALLBACK OSWindow::WinApiMsgRouter(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if (msg == WM_NCCREATE) {
--- a/Registry.cpp Sat Jul 26 13:03:43 2014 +0600 +++ b/Registry.cpp Wed Jul 30 11:19:53 2014 +0600 @@ -43,7 +43,7 @@ GetLastError(); *(int *)Data = uDefValue; - RegSetValueExA(v11, lpValueName, 0, 4u, Data, 4u); + RegSetValueExA(v11, lpValueName, 0, 4, Data, 4); } RegCloseKey(v11); }
--- a/mm7_2.cpp Sat Jul 26 13:03:43 2014 +0600 +++ b/mm7_2.cpp Wed Jul 30 11:19:53 2014 +0600 @@ -68,7 +68,7 @@ #include "MMT.h" #include "Registry.h" -int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam); +//int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam); int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4); bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive); bool __fastcall Initialize(HINSTANCE hInst, char *pCmdLine); @@ -150,6 +150,7 @@ int v20; // [sp+BCh] [bp-14h]@7 GUIFont *pFont; // [sp+C4h] [bp-Ch]@1 unsigned __int64 v23; // [sp+C8h] [bp-8h]@5 + MSG msg; v15 = ecx0; @@ -247,7 +248,7 @@ LODWORD(v23) = GetTickCount() + 5000; while ( (unsigned int)v23 > GetTickCount() ) ; - for (MSG msg; PeekMessage(&msg, 0, 0, 0, PM_REMOVE);) + while ( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) ) { if (msg.message == WM_QUIT) Game_DeinitializeAndTerminate(0); @@ -263,7 +264,7 @@ pKeyActionMap->uLastKeyPressed = 0; do { - for (MSG msg; PeekMessage(&msg, 0, 0, 0, PM_REMOVE);) + while ( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) ) { if (msg.message == WM_QUIT) Game_DeinitializeAndTerminate(0); @@ -914,6 +915,7 @@ unsigned int pY; // [sp-18h] [bp-54h]@39 Texture *pTexture; // [sp-14h] [bp-50h]@39 GUIWindow *pWindow; // [sp+4h] [bp-38h]@11 + MSG msg; pCurrentScreen = SCREEN_GAME; @@ -957,7 +959,7 @@ pWindow = pGUIWindow_CurrentMenu; } - for (MSG msg; PeekMessageW(&msg, 0, 0, 0, PM_REMOVE);) + while ( PeekMessageW(&msg, 0, 0, 0, PM_REMOVE) ) { if (msg.message == WM_QUIT) Game_DeinitializeAndTerminate(0);