Mercurial > mm7
comparison Render.cpp @ 1802:633f81bb3ae7
HWND -> class OSWindow
author | Nomad |
---|---|
date | Mon, 07 Oct 2013 11:52:33 +0200 |
parents | 4da5644df18f |
children | 9f93b5700e2d |
comparison
equal
deleted
inserted
replaced
1760:a2ea57410b15 | 1802:633f81bb3ae7 |
---|---|
2092 | 2092 |
2093 hd_water_tile_id = -1; | 2093 hd_water_tile_id = -1; |
2094 hd_water_current_frame = 0; | 2094 hd_water_current_frame = 0; |
2095 } | 2095 } |
2096 | 2096 |
2097 bool Render::Initialize(bool bWindowed, int windowed_width, int windowed_height, uint32_t uDefaultDevice, | 2097 bool Render::Initialize(bool bWindowed, OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) |
2098 bool bColoredLights, uint32_t uDetailLevel, bool bTinting) | 2098 { |
2099 { | 2099 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); |
2100 bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | 2100 |
2101 | 2101 this->window = window; |
2102 bStartInWindow = bWindowed; | 2102 bStartInWindow = bWindowed; |
2103 windowed_mode_width = windowed_width; | 2103 //windowed_mode_width = windowed_width; |
2104 windowed_mode_height = windowed_height; | 2104 //windowed_mode_height = windowed_height; |
2105 | 2105 |
2106 uDesiredDirect3DDevice = uDefaultDevice;//ReadWindowsRegistryInt("D3D Device", 1); | 2106 uDesiredDirect3DDevice = 0;//ReadWindowsRegistryInt("D3D Device", 1); |
2107 | 2107 |
2108 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); | 2108 bUseColoredLights = bColoredLights;//ReadWindowsRegistryInt("Colored Lights", 0); |
2109 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); | 2109 uLevelOfDetail = uDetailLevel;//ReadWindowsRegistryInt("Detail Level", 1); |
2110 | 2110 |
2111 this->bTinting = bTinting; | 2111 this->bTinting = bTinting; |
2184 IDirectDrawSurface *v2; // eax@3 | 2184 IDirectDrawSurface *v2; // eax@3 |
2185 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | 2185 DDBLTFX v3; // [sp+4h] [bp-74h]@5 |
2186 RECT x; // [sp+68h] [bp-10h]@3 | 2186 RECT x; // [sp+68h] [bp-10h]@3 |
2187 | 2187 |
2188 memset(&v3, 0, sizeof(DDBLTFX)); | 2188 memset(&v3, 0, sizeof(DDBLTFX)); |
2189 GetWindowRect(hWnd, &x); | 2189 GetWindowRect(window->GetApiHandle(), &x); |
2190 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | 2190 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
2191 pVersion->pVersionInfo.dwMajorVersion >= 5) | 2191 pVersion->pVersionInfo.dwMajorVersion >= 5) |
2192 { | 2192 { |
2193 v2 = (IDirectDrawSurface *)this->pBackBuffer4; | 2193 v2 = (IDirectDrawSurface *)this->pBackBuffer4; |
2194 } | 2194 } |
2907 if ( v1->field_40110 ) | 2907 if ( v1->field_40110 ) |
2908 { | 2908 { |
2909 pRenderD3D->Present(false); | 2909 pRenderD3D->Present(false); |
2910 } | 2910 } |
2911 } | 2911 } |
2912 else | 2912 else __debugbreak(); // no sr |
2913 { | 2913 /*{ |
2914 if ( v1->bWindowMode ) | 2914 if ( v1->bWindowMode ) |
2915 { | 2915 { |
2916 RestoreFrontBuffer(); | 2916 RestoreFrontBuffer(); |
2917 GetClientRect(v1->hWnd, &Rect); | 2917 GetClientRect(v1->hWnd, &Rect); |
2918 Point.y = 0; | 2918 Point.y = 0; |
2932 a4.bottom = 480; | 2932 a4.bottom = 480; |
2933 a4.left = 0; | 2933 a4.left = 0; |
2934 a4.right = 640; | 2934 a4.right = 640; |
2935 BltBackToFontFast(0, 0, &a4); | 2935 BltBackToFontFast(0, 0, &a4); |
2936 } | 2936 } |
2937 } | 2937 }*/ |
2938 } | 2938 } |
2939 } | 2939 } |
2940 | 2940 |
2941 //----- (0049FD3A) -------------------------------------------------------- | 2941 //----- (0049FD3A) -------------------------------------------------------- |
2942 void Render::_49FD3A() | 2942 void Render::_49FD3A() |
2977 | 2977 |
2978 //----- (0049FE05) -------------------------------------------------------- | 2978 //----- (0049FE05) -------------------------------------------------------- |
2979 void Render::Release() | 2979 void Render::Release() |
2980 { | 2980 { |
2981 Render *v1; // esi@1 | 2981 Render *v1; // esi@1 |
2982 RenderD3D *v2; // ecx@1 | 2982 //RenderD3D *v2; // ecx@1 |
2983 char v3; // zf@4 | 2983 //char v3; // zf@4 |
2984 void *v4; // ebx@6 | 2984 //void *v4; // ebx@6 |
2985 IDirectDraw *v5; // eax@10 | 2985 IDirectDraw *v5; // eax@10 |
2986 IDirectDrawSurface2 *v6; // eax@11 | 2986 IDirectDrawSurface2 *v6; // eax@11 |
2987 IDirectDrawSurface2 *v7; // eax@13 | 2987 IDirectDrawSurface2 *v7; // eax@13 |
2988 IDirectDrawSurface2 *v8; // eax@15 | 2988 IDirectDrawSurface2 *v8; // eax@15 |
2989 IDirectDraw2 *v9; // eax@17 | 2989 IDirectDraw2 *v9; // eax@17 |
2994 IDirectDraw4 *v14; // eax@26 | 2994 IDirectDraw4 *v14; // eax@26 |
2995 unsigned __int16 **v15; // ebx@28 | 2995 unsigned __int16 **v15; // ebx@28 |
2996 void **v16; // esi@29 | 2996 void **v16; // esi@29 |
2997 | 2997 |
2998 v1 = this; | 2998 v1 = this; |
2999 v2 = this->pRenderD3D; | 2999 if (pRenderD3D) |
3000 if ( v2 ) | |
3001 { | 3000 { |
3002 if ( v1->field_40110 ) | 3001 if ( v1->field_40110 ) |
3003 { | 3002 { |
3004 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | 3003 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
3005 pRenderD3D->Present(0); | 3004 pRenderD3D->Present(0); |
3006 pRenderD3D->ClearTarget(1u, 0, 0, 1.0); | 3005 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
3007 } | 3006 } |
3008 v1->pColorKeySurface4 = 0; | 3007 v1->pColorKeySurface4 = 0; |
3009 v1->pBackBuffer4 = 0; | 3008 v1->pBackBuffer4 = 0; |
3010 v3 = v1->pTargetSurface == 0; | |
3011 v1->pFrontBuffer4 = 0; | 3009 v1->pFrontBuffer4 = 0; |
3012 v1->pDirectDraw4 = 0; | 3010 v1->pDirectDraw4 = 0; |
3013 if ( !v3 ) | 3011 if (v1->pTargetSurface) |
3014 { | 3012 { |
3015 free(v1->ptr_400E8); | 3013 free(v1->ptr_400E8); |
3016 v1->pTargetSurface = 0; | 3014 v1->pTargetSurface = 0; |
3017 v1->ptr_400E8 = 0; | 3015 v1->ptr_400E8 = 0; |
3018 } | 3016 } |
3019 v4 = v1->pRenderD3D; | 3017 if (pRenderD3D) |
3020 if ( v4 ) | |
3021 { | 3018 { |
3022 pRenderD3D->Release(); | 3019 pRenderD3D->Release(); |
3023 free(v4); | 3020 delete pRenderD3D; |
3024 } | 3021 } |
3025 v1->pRenderD3D = 0; | 3022 pRenderD3D = 0; |
3026 } | 3023 } |
3027 else | 3024 else |
3028 { | 3025 ;//__debugbreak(); // no sr |
3026 /*{ | |
3029 if ( bWinNT4_0 == 1 ) | 3027 if ( bWinNT4_0 == 1 ) |
3030 { | 3028 { |
3031 v5 = (IDirectDraw *)v1->pDirectDraw2; | 3029 v5 = (IDirectDraw *)v1->pDirectDraw2; |
3032 if ( !v5 ) | 3030 if ( !v5 ) |
3033 return; | 3031 return; |
3096 v16 = (void **)&v1->ptr_400E8; | 3094 v16 = (void **)&v1->ptr_400E8; |
3097 free(*v16); | 3095 free(*v16); |
3098 *v15 = 0; | 3096 *v15 = 0; |
3099 *v16 = 0; | 3097 *v16 = 0; |
3100 } | 3098 } |
3101 } | 3099 }*/ |
3102 } | 3100 } |
3103 | 3101 |
3104 //----- (0049FFD7) -------------------------------------------------------- | 3102 //----- (0049FFD7) -------------------------------------------------------- |
3105 void Render::CreateSomeTexture() | 3103 void Render::CreateSomeTexture() |
3106 { | 3104 { |
3107 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); | 3105 pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); |
3108 } | 3106 } |
3109 | 3107 |
3110 //----- (0049FFFB) -------------------------------------------------------- | 3108 //----- (0049FFFB) -------------------------------------------------------- |
3111 bool Render::InitializeFullscreen(HWND hWnd) | 3109 bool Render::InitializeFullscreen() |
3112 { | 3110 { |
3113 //Render *v2; // esi@1 | 3111 //Render *v2; // esi@1 |
3114 //HWND v3; // ebx@1 | 3112 //HWND v3; // ebx@1 |
3115 //void *v4; // eax@2 | 3113 //void *v4; // eax@2 |
3116 //RenderD3D *v5; // eax@3 | 3114 //RenderD3D *v5; // eax@3 |
3145 this->pFrontBuffer4 = 0; | 3143 this->pFrontBuffer4 = 0; |
3146 this->pDirectDraw4 = 0; | 3144 this->pDirectDraw4 = 0; |
3147 this->bColorKeySupported = 0; | 3145 this->bColorKeySupported = 0; |
3148 Release(); | 3146 Release(); |
3149 //v3 = hWnd; | 3147 //v3 = hWnd; |
3150 this->hWnd = hWnd; | 3148 this->window = window; |
3151 CreateZBuffer(); | 3149 CreateZBuffer(); |
3152 if ( bUserDirect3D ) | 3150 |
3153 { | 3151 /*if (!bUserDirect3D) |
3152 { | |
3153 CreateDirectDraw(); | |
3154 SetDirectDrawCooperationMode(hWnd, 1); | |
3155 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3156 CreateDirectDrawPrimarySurface(); | |
3157 v15 = 1; | |
3158 } | |
3159 else | |
3160 {*/ | |
3154 pRenderD3D = new RenderD3D; | 3161 pRenderD3D = new RenderD3D; |
3155 v28 = pRenderD3D; | 3162 v28 = pRenderD3D; |
3156 v6 = uDesiredDirect3DDevice; | 3163 v6 = uDesiredDirect3DDevice; |
3157 v29 = -1; | 3164 v29 = -1; |
3158 v7 = pRenderD3D->pAvailableDevices; | 3165 v7 = pRenderD3D->pAvailableDevices; |
3159 if ( v7[v6].bIsDeviceCompatible ) | 3166 if ( v7[v6].bIsDeviceCompatible ) |
3160 { | 3167 { |
3161 v8 = pRenderD3D->CreateDevice(v6, 0, hWnd); | 3168 v8 = pRenderD3D->CreateDevice(v6, 0, window->GetApiHandle()); |
3162 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | 3169 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; |
3163 } | 3170 } |
3164 else | 3171 else |
3165 { | 3172 { |
3166 if ( v7[1].bIsDeviceCompatible ) | 3173 if ( v7[1].bIsDeviceCompatible ) |
3167 { | 3174 { |
3168 v8 = pRenderD3D->CreateDevice(1u, 0, hWnd); | 3175 v8 = pRenderD3D->CreateDevice(1u, 0, window->GetApiHandle()); |
3169 uAcquiredDirect3DDevice = 1; | 3176 uAcquiredDirect3DDevice = 1; |
3170 } | 3177 } |
3171 else | 3178 else |
3172 { | 3179 { |
3173 if ( !v7->bIsDeviceCompatible ) | 3180 if ( !v7->bIsDeviceCompatible ) |
3174 Error("There aren't any D3D devices to create."); | 3181 Error("There aren't any D3D devices to create."); |
3175 | 3182 |
3176 v8 = pRenderD3D->CreateDevice(0, 0, hWnd); | 3183 v8 = pRenderD3D->CreateDevice(0, 0, window->GetApiHandle()); |
3177 uAcquiredDirect3DDevice = 0; | 3184 uAcquiredDirect3DDevice = 0; |
3178 } | 3185 } |
3179 } | 3186 } |
3180 if ( !v8 ) | 3187 if ( !v8 ) |
3181 Error("D3Drend->Init failed."); | 3188 Error("D3Drend->Init failed."); |
3259 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | 3266 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); |
3260 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | 3267 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); |
3261 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | 3268 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); |
3262 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | 3269 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); |
3263 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | 3270 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); |
3264 } | 3271 //} |
3265 else | |
3266 { | |
3267 CreateDirectDraw(); | |
3268 SetDirectDrawCooperationMode(hWnd, 1); | |
3269 SetDirectDrawDisplayMode(640u, 480u, 16u); | |
3270 CreateDirectDrawPrimarySurface(); | |
3271 v15 = 1; | |
3272 } | |
3273 ddpfPrimareSuface.dwSize = 32; | 3272 ddpfPrimareSuface.dwSize = 32; |
3274 GetTargetPixelFormat(&ddpfPrimareSuface); | 3273 GetTargetPixelFormat(&ddpfPrimareSuface); |
3275 ParseTargetPixelFormat(); | 3274 ParseTargetPixelFormat(); |
3276 _49EBF1(); | 3275 _49EBF1(); |
3277 if ( pRenderD3D ) | 3276 if ( pRenderD3D ) |
3327 pViewport->_4C02F8(36044); | 3326 pViewport->_4C02F8(36044); |
3328 return v15 != 0; | 3327 return v15 != 0; |
3329 } | 3328 } |
3330 | 3329 |
3331 //----- (004A05F3) -------------------------------------------------------- | 3330 //----- (004A05F3) -------------------------------------------------------- |
3332 bool Render::SwitchToWindow(HWND hWnd) | 3331 bool Render::SwitchToWindow() |
3333 { | 3332 { |
3334 //Render *v2; // esi@1 | 3333 //Render *v2; // esi@1 |
3335 //void *v3; // eax@2 | 3334 //void *v3; // eax@2 |
3336 //RenderD3D *v4; // eax@3 | 3335 //RenderD3D *v4; // eax@3 |
3337 //unsigned int v5; // edx@5 | 3336 //unsigned int v5; // edx@5 |
3369 pBackBuffer4 = 0; | 3368 pBackBuffer4 = 0; |
3370 pFrontBuffer4 = 0; | 3369 pFrontBuffer4 = 0; |
3371 pDirectDraw4 = 0; | 3370 pDirectDraw4 = 0; |
3372 bColorKeySupported = 0; | 3371 bColorKeySupported = 0; |
3373 CreateZBuffer(); | 3372 CreateZBuffer(); |
3374 if ( bUserDirect3D ) | 3373 /*if (!bUserDirect3D) |
3375 { | 3374 { |
3375 CreateDirectDraw(); | |
3376 SetDirectDrawCooperationMode(hWnd, 0); | |
3377 field_4004C = 1; | |
3378 CreateFrontBuffer(); | |
3379 CreateClipper(hWnd); | |
3380 CreateBackBuffer(); | |
3381 field_40030 = 0; | |
3382 field_18_locked_pitch = 0; | |
3383 } | |
3384 else | |
3385 {*/ | |
3376 /*v3 = malloc(0x148u); | 3386 /*v3 = malloc(0x148u); |
3377 thisa = (RenderD3D *)v3; | 3387 thisa = (RenderD3D *)v3; |
3378 v29 = 0; | 3388 v29 = 0; |
3379 if ( v3 ) | 3389 if ( v3 ) |
3380 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); | 3390 v4 = RenderD3D::RenderD3D((RenderD3D *)v3); |
3386 v29 = -1; | 3396 v29 = -1; |
3387 //v6 = pRenderD3D->pAvailableDevices; | 3397 //v6 = pRenderD3D->pAvailableDevices; |
3388 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | 3398 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && |
3389 uDesiredDirect3DDevice != 1 ) | 3399 uDesiredDirect3DDevice != 1 ) |
3390 { | 3400 { |
3391 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, hWnd); | 3401 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, window->GetApiHandle()); |
3392 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | 3402 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; |
3393 } | 3403 } |
3394 else | 3404 else |
3395 { | 3405 { |
3396 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | 3406 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) |
3397 Error("There aren't any D3D devices to init."); | 3407 Error("There aren't any D3D devices to init."); |
3398 | 3408 |
3399 v7 = pRenderD3D->CreateDevice(0, 1, hWnd); | 3409 v7 = pRenderD3D->CreateDevice(0, 1, window->GetApiHandle()); |
3400 uAcquiredDirect3DDevice = 0; | 3410 uAcquiredDirect3DDevice = 0; |
3401 } | 3411 } |
3402 if ( !v7 ) | 3412 if ( !v7 ) |
3403 Error("D3Drend->Init failed."); | 3413 Error("D3Drend->Init failed."); |
3404 | 3414 |
3478 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); | 3488 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0)); |
3479 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | 3489 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); |
3480 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | 3490 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); |
3481 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | 3491 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); |
3482 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | 3492 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); |
3483 } | 3493 //} |
3484 else | 3494 |
3485 { | |
3486 CreateDirectDraw(); | |
3487 SetDirectDrawCooperationMode(hWnd, 0); | |
3488 field_4004C = 1; | |
3489 CreateFrontBuffer(); | |
3490 CreateClipper(hWnd); | |
3491 CreateBackBuffer(); | |
3492 field_40030 = 0; | |
3493 field_18_locked_pitch = 0; | |
3494 } | |
3495 ddpfPrimareSuface.dwSize = 32; | 3495 ddpfPrimareSuface.dwSize = 32; |
3496 GetTargetPixelFormat(&ddpfPrimareSuface); | 3496 GetTargetPixelFormat(&ddpfPrimareSuface); |
3497 ParseTargetPixelFormat(); | 3497 ParseTargetPixelFormat(); |
3498 _49EBF1(); | 3498 _49EBF1(); |
3499 if ( !pRenderD3D ) | 3499 if ( !pRenderD3D ) |
3521 pBeforePresentFunction = Present_ColorKey; | 3521 pBeforePresentFunction = Present_ColorKey; |
3522 LABEL_45: | 3522 LABEL_45: |
3523 field_40110 = 1; | 3523 field_40110 = 1; |
3524 LABEL_47: | 3524 LABEL_47: |
3525 bWindowMode = 1; | 3525 bWindowMode = 1; |
3526 hWnd = hWnd; | 3526 //hWnd = hWnd; |
3527 return 0; | 3527 return 0; |
3528 } | 3528 } |
3529 pTargetSurface = 0; | 3529 pTargetSurface = 0; |
3530 ptr_400E8 = 0; | 3530 ptr_400E8 = 0; |
3531 v18 = (int *)new char[0x96020]; | 3531 v18 = (int *)new char[0x96020]; |
3995 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); | 3995 ErrD3D(DirectDrawCreate(0, &lpDD, 0)); |
3996 | 3996 |
3997 pDirectDraw2 = nullptr; | 3997 pDirectDraw2 = nullptr; |
3998 pDirectDraw4 = nullptr; | 3998 pDirectDraw4 = nullptr; |
3999 | 3999 |
4000 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 4000 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4001 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4001 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); | 4002 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4)); |
4002 else | 4003 else |
4003 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); | 4004 ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2)); |
4004 | 4005 |
4005 lpDD->Release(); | 4006 lpDD->Release(); |
4016 unsigned int v7; // [sp-4h] [bp-4h]@3 | 4017 unsigned int v7; // [sp-4h] [bp-4h]@3 |
4017 | 4018 |
4018 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : | 4019 flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : |
4019 DDSCL_NORMAL; | 4020 DDSCL_NORMAL; |
4020 | 4021 |
4021 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 4022 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4023 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4022 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); | 4024 ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED)); |
4023 else | 4025 else |
4024 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); | 4026 ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags)); |
4025 } | 4027 } |
4026 | 4028 |
4027 //----- (004A11C6) -------------------------------------------------------- | 4029 //----- (004A11C6) -------------------------------------------------------- |
4028 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) | 4030 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP) |
4029 { | 4031 { |
4030 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 4032 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4033 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4031 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | 4034 ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); |
4032 else | 4035 else |
4033 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); | 4036 ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0)); |
4034 } | 4037 } |
4035 | 4038 |
4044 int v6; // [sp-8h] [bp-8Ch]@3 | 4047 int v6; // [sp-8h] [bp-8Ch]@3 |
4045 unsigned int v7; // [sp-4h] [bp-88h]@3 | 4048 unsigned int v7; // [sp-4h] [bp-88h]@3 |
4046 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | 4049 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 |
4047 | 4050 |
4048 v1 = this; | 4051 v1 = this; |
4049 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 4052 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4053 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4050 { | 4054 { |
4051 memset(&a2, 0, 0x7Cu); | 4055 memset(&a2, 0, 0x7Cu); |
4052 pDD = (IDirectDraw *)v1->pDirectDraw4; | 4056 pDD = (IDirectDraw *)v1->pDirectDraw4; |
4053 a2.dwSize = 124; | 4057 a2.dwSize = 124; |
4054 a2.dwFlags = 1; | 4058 a2.dwFlags = 1; |
4084 int v6; // [sp-8h] [bp-8Ch]@3 | 4088 int v6; // [sp-8h] [bp-8Ch]@3 |
4085 unsigned int v7; // [sp-4h] [bp-88h]@3 | 4089 unsigned int v7; // [sp-4h] [bp-88h]@3 |
4086 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 | 4090 DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3 |
4087 | 4091 |
4088 v1 = this; | 4092 v1 = this; |
4089 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 4093 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4094 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4090 { | 4095 { |
4091 memset(&a2, 0, 0x7Cu); | 4096 memset(&a2, 0, 0x7Cu); |
4092 v2 = (IDirectDraw *)v1->pDirectDraw4; | 4097 v2 = (IDirectDraw *)v1->pDirectDraw4; |
4093 a2.dwSize = 124; | 4098 a2.dwSize = 124; |
4094 a2.dwFlags = 7; | 4099 a2.dwFlags = 7; |
4138 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 | 4143 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-94h]@3 |
4139 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 | 4144 DDSCAPS2 v17; // [sp+88h] [bp-18h]@4 |
4140 int a4; // [sp+98h] [bp-8h]@3 | 4145 int a4; // [sp+98h] [bp-8h]@3 |
4141 | 4146 |
4142 v1 = this; | 4147 v1 = this; |
4143 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 4148 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4149 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4144 { | 4150 { |
4145 v2 = 0; | 4151 v2 = 0; |
4146 this->field_4004C = 1; | 4152 this->field_4004C = 1; |
4147 memset(&ddsd2, 0, 0x7Cu); | 4153 memset(&ddsd2, 0, 0x7Cu); |
4148 v7 = v1->pDirectDraw4; | 4154 v7 = v1->pDirectDraw4; |
4189 } | 4195 } |
4190 | 4196 |
4191 //----- (004A14F4) -------------------------------------------------------- | 4197 //----- (004A14F4) -------------------------------------------------------- |
4192 void Render::CreateClipper(HWND a2) | 4198 void Render::CreateClipper(HWND a2) |
4193 { | 4199 { |
4194 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 4200 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4201 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4195 { | 4202 { |
4196 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); | 4203 ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0)); |
4197 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); | 4204 ErrD3D(pDDrawClipper->SetHWnd(0, a2)); |
4198 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); | 4205 ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper)); |
4199 } | 4206 } |
4207 //----- (004A15D8) -------------------------------------------------------- | 4214 //----- (004A15D8) -------------------------------------------------------- |
4208 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) | 4215 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut) |
4209 { | 4216 { |
4210 IDirectDrawSurface *v2; // eax@3 | 4217 IDirectDrawSurface *v2; // eax@3 |
4211 | 4218 |
4212 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 4219 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4220 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4213 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; | 4221 v2 = (IDirectDrawSurface *)this->pFrontBuffer4; |
4214 else | 4222 else |
4215 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; | 4223 v2 = (IDirectDrawSurface *)this->pFrontBuffer2; |
4216 v2->GetPixelFormat(pOut); | 4224 v2->GetPixelFormat(pOut); |
4217 } | 4225 } |
4221 { | 4229 { |
4222 Render *v3; // esi@1 | 4230 Render *v3; // esi@1 |
4223 signed int v4; // eax@3 | 4231 signed int v4; // eax@3 |
4224 | 4232 |
4225 v3 = this; | 4233 v3 = this; |
4226 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 4234 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4235 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4227 { | 4236 { |
4228 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 | 4237 DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 |
4229 memset(&pDesc, 0, 0x7Cu); | 4238 memset(&pDesc, 0, 0x7Cu); |
4230 pDesc.dwSize = 124; | 4239 pDesc.dwSize = 124; |
4231 LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); | 4240 LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); |
4242 v4 = pDesc.dwReserved; | 4251 v4 = pDesc.dwReserved; |
4243 } | 4252 } |
4244 *pOutPixelsPerRow = v4 >> 1; | 4253 *pOutPixelsPerRow = v4 >> 1; |
4245 } | 4254 } |
4246 | 4255 |
4247 //----- (004A169E) -------------------------------------------------------- | |
4248 bool Render::UsingDirect3D() | |
4249 { | |
4250 return bUserDirect3D == 0; | |
4251 } | |
4252 | |
4253 //----- (004A16E1) -------------------------------------------------------- | 4256 //----- (004A16E1) -------------------------------------------------------- |
4254 void Render::UnlockBackBuffer() | 4257 void Render::UnlockBackBuffer() |
4255 { | 4258 { |
4256 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 4259 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4260 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
4257 ErrD3D(pBackBuffer4->Unlock(0)); | 4261 ErrD3D(pBackBuffer4->Unlock(0)); |
4258 else | 4262 else |
4259 ErrD3D(pBackBuffer2->Unlock(0)); | 4263 ErrD3D(pBackBuffer2->Unlock(0)); |
4260 } | 4264 } |
4261 | 4265 |
8314 pBitmaps_LOD->ReleaseHardwareTextures(); | 8318 pBitmaps_LOD->ReleaseHardwareTextures(); |
8315 pSprites_LOD->ReleaseAll(); | 8319 pSprites_LOD->ReleaseAll(); |
8316 } | 8320 } |
8317 if ( pRenderer->bWindowMode ) | 8321 if ( pRenderer->bWindowMode ) |
8318 { | 8322 { |
8319 SetMenu(hWnd, 0); | 8323 //SetMenu(hWnd, 0); |
8320 SetWindowLongA(hWnd, -20, 0); | 8324 //SetWindowLongA(hWnd, -20, 0); |
8321 SetWindowLongA(hWnd, -16, 0x10000000u); | 8325 //SetWindowLongA(hWnd, -16, 0x10000000u); |
8322 pRenderer->InitializeFullscreen(hWnd); | 8326 window->SetFullscreenMode(); |
8327 pRenderer->InitializeFullscreen(); | |
8323 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; | 8328 v0 = (double)(signed int)uGammaPos * 0.1 + 0.6; |
8324 pGame->pGammaController->Initialize(v0); | 8329 pGame->pGammaController->Initialize(v0); |
8325 } | 8330 } |
8326 else | 8331 else |
8327 { | 8332 { |
8328 ClipCursor(0); | 8333 //ClipCursor(0); |
8329 pRenderer->SwitchToWindow(hWnd); | 8334 window->SetWindowedMode(window->GetWidth(), window->GetHeight()); |
8335 pRenderer->SwitchToWindow(); | |
8330 } | 8336 } |
8331 if ( pRenderer->pRenderD3D ) | 8337 if ( pRenderer->pRenderD3D ) |
8332 { | 8338 { |
8333 pBitmaps_LOD->_410423_move_textures_to_device(); | 8339 pBitmaps_LOD->_410423_move_textures_to_device(); |
8334 pSprites_LOD->MoveSpritesToVideoMemory(); | 8340 pSprites_LOD->MoveSpritesToVideoMemory(); |
8377 } | 8383 } |
8378 } | 8384 } |
8379 viewparams->bRedrawGameUI = 1; | 8385 viewparams->bRedrawGameUI = 1; |
8380 viewparams->InitGrayPalette(); | 8386 viewparams->InitGrayPalette(); |
8381 pMouse->SetCurrentCursorBitmap(); | 8387 pMouse->SetCurrentCursorBitmap(); |
8382 if ( pRenderer->bWindowMode ) | 8388 /*if ( pRenderer->bWindowMode ) |
8383 { | 8389 { |
8384 //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); | 8390 //MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); |
8385 CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height); | 8391 CenterWindowAndAdjustSize(hWnd, windowed_mode_width, windowed_mode_height); |
8386 ShowWindow(hWnd, SW_SHOWNORMAL); | 8392 ShowWindow(hWnd, SW_SHOWNORMAL); |
8387 } | 8393 }*/ |
8388 pMouse->bActive = 1; | 8394 pMouse->bActive = true; |
8389 if ( pVideoPlayer->AnyMovieLoaded() ) | 8395 if ( pVideoPlayer->AnyMovieLoaded() ) |
8390 pVideoPlayer->SelectMovieType(); | 8396 pVideoPlayer->SelectMovieType(); |
8391 if (dword_6BE364_game_settings_1 & 0x0800 ) | 8397 if (dword_6BE364_game_settings_1 & 0x0800 ) |
8392 BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; | 8398 BYTE1(dword_6BE364_game_settings_1) &= 0xF7u; |
8393 else | 8399 else |