Mercurial > mm7
comparison Render.cpp @ 2069:259df09dfb50
32bits almost there
author | Nomad |
---|---|
date | Tue, 03 Dec 2013 20:18:17 +0200 |
parents | b2a434d65344 |
children | 38bf1c70fc70 |
comparison
equal
deleted
inserted
replaced
2061:b2a434d65344 | 2069:259df09dfb50 |
---|---|
85 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); | 85 HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *a2); |
86 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); | 86 HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, struct RenderD3D_aux *a6); |
87 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb | 87 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb |
88 | 88 |
89 //----- (0049E79F) -------------------------------------------------------- | 89 //----- (0049E79F) -------------------------------------------------------- |
90 bool CheckTextureStages() | 90 bool CheckTextureStages() |
91 { | 91 { |
92 bool v0; // edi@1 | 92 bool v0; // edi@1 |
93 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 | 93 IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1 |
94 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 | 94 IDirectDrawSurface4 *pSurface1; // [sp+10h] [bp-10h]@1 |
95 DWORD v4; // [sp+14h] [bp-Ch]@1 | 95 DWORD v4; // [sp+14h] [bp-Ch]@1 |
1204 //----- (0049D717) -------------------------------------------------------- | 1204 //----- (0049D717) -------------------------------------------------------- |
1205 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) | 1205 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst) |
1206 { | 1206 { |
1207 HRESULT v2; // esi@2 | 1207 HRESULT v2; // esi@2 |
1208 | 1208 |
1209 if ( Src->dwFlags & 0x400 | 0x2000 ) | 1209 if ( Src->dwFlags & (0x400 | 0x2000)) |
1210 { | 1210 { |
1211 v2 = 0; | 1211 v2 = 0; |
1212 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) | 1212 if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask ) |
1213 goto LABEL_6; | 1213 goto LABEL_6; |
1214 if ( !Dst->dwSize ) | 1214 if ( !Dst->dwSize ) |
1373 v1->pHost = 0; | 1373 v1->pHost = 0; |
1374 } | 1374 } |
1375 } | 1375 } |
1376 | 1376 |
1377 //----- (0049DE14) -------------------------------------------------------- | 1377 //----- (0049DE14) -------------------------------------------------------- |
1378 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd) | 1378 bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window) |
1379 { | 1379 { |
1380 //IDirectDraw4 *v8; // eax@12 | 1380 //IDirectDraw4 *v8; // eax@12 |
1381 //IDirectDraw4 *v9; // eax@16 | 1381 //IDirectDraw4 *v9; // eax@16 |
1382 //IDirectDraw4 *v10; // eax@20 | 1382 //IDirectDraw4 *v10; // eax@20 |
1383 //IDirectDraw4 *v13; // eax@35 | 1383 //IDirectDraw4 *v13; // eax@35 |
1389 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 | 1389 DDSURFACEDESC2 ddsd2; // [sp+1Ch] [bp-BCh]@11 |
1390 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 | 1390 D3DVIEWPORT2 d3dvp2; // [sp+98h] [bp-40h]@28 |
1391 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 | 1391 IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18 |
1392 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 | 1392 LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1 |
1393 | 1393 |
1394 auto hWnd = window->GetApiHandle(); | |
1395 int game_width = window->GetWidth(); | |
1396 int game_height = window->GetHeight(); | |
1397 | |
1394 this->bWindowed = bWindowed; | 1398 this->bWindowed = bWindowed; |
1395 this->hWindow = hWnd; | 1399 this->hWindow = hWnd; |
1396 | 1400 |
1397 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) | 1401 if (FAILED(DirectDrawCreate(pAvailableDevices[uDeviceID].pDirectDrawGUID, &lpDD, 0))) |
1398 { | 1402 { |
1430 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; | 1434 ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; |
1431 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) | 1435 if ( !pHost->CreateSurface(&ddsd2, &pFrontBuffer, 0) ) |
1432 { | 1436 { |
1433 ddsd2.dwSize = sizeof(DDSURFACEDESC2); | 1437 ddsd2.dwSize = sizeof(DDSURFACEDESC2); |
1434 pHost->GetDisplayMode(&ddsd2); | 1438 pHost->GetDisplayMode(&ddsd2); |
1435 if ( ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) | 1439 if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 ) |
1436 { | 1440 { |
1437 v24 = "Init - Desktop isn't in 16 bit mode.\n"; | 1441 v24 = "Init - Desktop isn't in 16 bit mode.\n"; |
1438 goto LABEL_14; | 1442 goto LABEL_14; |
1439 } | 1443 } |
1440 | 1444 |
1441 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; | 1445 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; |
1442 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; | 1446 ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; |
1443 ddsd2.dwWidth = 640; | 1447 ddsd2.dwWidth = game_width; |
1444 ddsd2.dwHeight = 480; | 1448 ddsd2.dwHeight = game_height; |
1445 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) | 1449 if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) ) |
1446 { | 1450 { |
1447 v24 = "Init - Failed to create back buffer.\n"; | 1451 v24 = "Init - Failed to create back buffer.\n"; |
1448 LABEL_14: | 1452 LABEL_14: |
1449 sprintf(pErrorMessage, v24); | 1453 sprintf(pErrorMessage, v24); |
1467 | 1471 |
1468 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); | 1472 pHost->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D); |
1469 | 1473 |
1470 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; | 1474 ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; |
1471 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; | 1475 ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER; |
1472 ddsd2.dwWidth = 640; | 1476 ddsd2.dwWidth = game_width; |
1473 ddsd2.dwHeight = 480; | 1477 ddsd2.dwHeight = game_height; |
1474 | 1478 |
1475 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, | 1479 if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID, |
1476 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, | 1480 (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator, |
1477 &ddsd2.ddpfPixelFormat) ) | 1481 &ddsd2.ddpfPixelFormat) ) |
1478 goto LABEL_21; | 1482 goto LABEL_21; |
1608 d3dvp2.dvMaxZ = 1.0; | 1612 d3dvp2.dvMaxZ = 1.0; |
1609 | 1613 |
1610 LABEL_54: | 1614 LABEL_54: |
1611 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); | 1615 d3dvp2.dwSize = sizeof(D3DVIEWPORT2); |
1612 //v17 = *hWnda; | 1616 //v17 = *hWnda; |
1613 d3dvp2.dwWidth = 640; | 1617 d3dvp2.dwWidth = game_width; |
1614 d3dvp2.dwHeight = 480; | 1618 d3dvp2.dwHeight = game_height; |
1615 d3dvp2.dvClipX = -1.0; | 1619 d3dvp2.dvClipX = -1.0; |
1616 //v18 = v17->lpVtbl; | 1620 //v18 = v17->lpVtbl; |
1617 //v32 = &v4->pViewport; | 1621 //v32 = &v4->pViewport; |
1618 if (pDirect3D->CreateViewport(&pViewport, 0)) | 1622 if (pDirect3D->CreateViewport(&pViewport, 0)) |
1619 { | 1623 { |
2104 v1->pColorKeySurface4 = 0; | 2108 v1->pColorKeySurface4 = 0; |
2105 v1->pDirectDraw4 = 0; | 2109 v1->pDirectDraw4 = 0; |
2106 v1->pRenderD3D = 0; | 2110 v1->pRenderD3D = 0; |
2107 v1->uNumSceneBegins = 0; | 2111 v1->uNumSceneBegins = 0; |
2108 v1->uNumD3DSceneBegins = 0; | 2112 v1->uNumD3DSceneBegins = 0; |
2109 v1->field_40110 = 0; | 2113 v1->using_software_screen_buffer = 0; |
2110 v1->pTargetSurface = 0; | 2114 v1->pTargetSurface = 0; |
2111 v1->uTargetSurfacePitch = 0; | 2115 v1->uTargetSurfacePitch = 0; |
2112 v1->uClipY = 0; | 2116 v1->uClipY = 0; |
2113 v1->uClipX = 0; | 2117 v1->uClipX = 0; |
2114 v1->uClipW = 480; | 2118 v1->uClipW = 480; |
2115 v1->bClip = 1; | 2119 v1->bClip = 1; |
2116 v1->bColorKeySupported = 0; | 2120 //v1->bColorKeySupported = 0; |
2117 v1->bRequiredTextureStagesAvailable = 0; | 2121 v1->bRequiredTextureStagesAvailable = 0; |
2118 v1->bTinting = 1; | 2122 v1->bTinting = 1; |
2119 LOBYTE(v1->field_103668) = 0; | 2123 LOBYTE(v1->field_103668) = 0; |
2120 v1->field_1036B8 = 0; | 2124 v1->field_1036B8 = 0; |
2121 v1->_gpu_memory_used = 0; | 2125 v1->_gpu_memory_used = 0; |
2125 hd_water_tile_id = -1; | 2129 hd_water_tile_id = -1; |
2126 hd_water_current_frame = 0; | 2130 hd_water_current_frame = 0; |
2127 sub_4A19B0(); | 2131 sub_4A19B0(); |
2128 } | 2132 } |
2129 | 2133 |
2130 bool Render::Initialize(bool bWindowed, OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) | 2134 bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) |
2131 { | 2135 { |
2132 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); | 2136 //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); |
2133 | 2137 |
2134 this->window = window; | 2138 this->window = window; |
2135 bStartInWindow = bWindowed; | 2139 //bStartInWindow = true; |
2136 //windowed_mode_width = windowed_width; | 2140 //windowed_mode_width = windowed_width; |
2137 //windowed_mode_height = windowed_height; | 2141 //windowed_mode_height = windowed_height; |
2138 | 2142 |
2139 uDesiredDirect3DDevice = ReadWindowsRegistryInt("D3D Device", 0); | 2143 uDesiredDirect3DDevice = ReadWindowsRegistryInt("D3D Device", 0); |
2140 | 2144 |
2147 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); | 2151 bool r2 = pD3DSprites.Load(L"data\\d3dsprite.hwl"); |
2148 | 2152 |
2149 return r1 && r2; | 2153 return r1 && r2; |
2150 } | 2154 } |
2151 | 2155 |
2152 //----- (0049EBF1) -------------------------------------------------------- | |
2153 void Render::_49EBF1() | |
2154 { | |
2155 signed int uNumRedBits; // edx@1 | |
2156 signed int uNuGreenBits; // edi@1 | |
2157 signed int uNumBlueBits; // esi@1 | |
2158 unsigned int v4; // edx@4 | |
2159 unsigned int v5; // edi@4 | |
2160 int v6; // ebx@4 | |
2161 int v7; // edx@4 | |
2162 signed int v8; // [sp+8h] [bp-24h]@1 | |
2163 signed int v9; // [sp+Ch] [bp-20h]@1 | |
2164 signed int v10; // [sp+20h] [bp-Ch]@1 | |
2165 signed int i; // [sp+24h] [bp-8h]@2 | |
2166 signed int v12; // [sp+28h] [bp-4h]@3 | |
2167 | |
2168 v10 = 0; | |
2169 uNumRedBits = 1 << this->uTargetRBits; | |
2170 uNuGreenBits = 1 << this->uTargetGBits; | |
2171 uNumBlueBits = 1 << this->uTargetBBits; | |
2172 v9 = 1 << this->uTargetRBits; | |
2173 v8 = 1 << this->uTargetGBits; | |
2174 if ( uNumRedBits > 0 ) | |
2175 { | |
2176 do | |
2177 { | |
2178 for ( i = 0; i < uNuGreenBits; ++i ) | |
2179 { | |
2180 v12 = 0; | |
2181 if ( uNumBlueBits > 0 ) | |
2182 { | |
2183 do | |
2184 { | |
2185 v4 = this->uTargetBBits; | |
2186 v5 = v4 + this->uTargetGBits; | |
2187 v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits); | |
2188 v7 = (v10 << v5) + v12++ + (i << v4); | |
2189 this->field_2C[v7] = v6; | |
2190 } | |
2191 while ( v12 < uNumBlueBits ); | |
2192 uNumRedBits = v9; | |
2193 uNuGreenBits = v8; | |
2194 } | |
2195 } | |
2196 ++v10; | |
2197 } | |
2198 while ( v10 < uNumRedBits ); | |
2199 } | |
2200 } | |
2201 | 2156 |
2202 //----- (0049ECC4) -------------------------------------------------------- | 2157 //----- (0049ECC4) -------------------------------------------------------- |
2203 void Render::ClearBlack() | 2158 void Render::ClearBlack() |
2204 { | 2159 { |
2205 if (pRenderD3D) | 2160 if (pRenderD3D) |
2206 { | 2161 { |
2207 if (field_40110) | 2162 if (using_software_screen_buffer) |
2208 pRenderD3D->ClearTarget(true, 0, false, 0.0); | 2163 pRenderD3D->ClearTarget(true, 0, false, 0.0); |
2209 } | 2164 } |
2210 else | 2165 else |
2211 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); | 2166 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); |
2212 } | 2167 } |
2273 int i; // [sp+15Ch] [bp-8h]@10 | 2228 int i; // [sp+15Ch] [bp-8h]@10 |
2274 unsigned __int8 v34; // [sp+163h] [bp-1h]@17 | 2229 unsigned __int8 v34; // [sp+163h] [bp-1h]@17 |
2275 | 2230 |
2276 v1 = this; | 2231 v1 = this; |
2277 v2 = 0; | 2232 v2 = 0; |
2278 if ( !this->pRenderD3D || this->field_40110 ) | 2233 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
2279 { | 2234 { |
2280 sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); | 2235 sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); |
2281 File = fopen(Filename, "wb"); | 2236 File = fopen(Filename, "wb"); |
2282 if ( File ) | 2237 if ( File ) |
2283 { | 2238 { |
2418 } | 2373 } |
2419 } | 2374 } |
2420 // 4EFA80: using guessed type int dword_4EFA80; | 2375 // 4EFA80: using guessed type int dword_4EFA80; |
2421 | 2376 |
2422 //----- (0049F1BC) -------------------------------------------------------- | 2377 //----- (0049F1BC) -------------------------------------------------------- |
2423 void Render::_49F1BC(const char *a1) | 2378 void Render::SaveWinnersCertificate(const char *a1) |
2424 { | 2379 { |
2425 Render *v2; // esi@1 | 2380 Render *v2; // esi@1 |
2426 __int16 v3; // di@1 | 2381 __int16 v3; // di@1 |
2427 int v4; // eax@4 | 2382 int v4; // eax@4 |
2428 char *v5; // ecx@4 | 2383 char *v5; // ecx@4 |
2468 char *i; // [sp+130h] [bp-8h]@10 | 2423 char *i; // [sp+130h] [bp-8h]@10 |
2469 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 | 2424 unsigned __int8 v46; // [sp+137h] [bp-1h]@17 |
2470 | 2425 |
2471 v2 = this; | 2426 v2 = this; |
2472 v3 = 0; | 2427 v3 = 0; |
2473 if ( !this->pRenderD3D || this->field_40110 ) | 2428 if ( !this->pRenderD3D || this->using_software_screen_buffer ) |
2474 { | 2429 { |
2475 ++dword_4EFA84; | 2430 ++dword_4EFA84; |
2476 File = fopen(a1, "wb"); | 2431 File = fopen(a1, "wb"); |
2477 if ( File ) | 2432 if ( File ) |
2478 { | 2433 { |
2496 v3 = 0; | 2451 v3 = 0; |
2497 } | 2452 } |
2498 else | 2453 else |
2499 { | 2454 { |
2500 pRenderer->BeginScene(); | 2455 pRenderer->BeginScene(); |
2501 v42 = pRenderer->pTargetSurface; | 2456 //v42 = pRenderer->pTargetSurface; |
2502 v6 = pRenderer->uTargetSurfacePitch; | 2457 v6 = pRenderer->uTargetSurfacePitch; |
2503 } | 2458 } |
2504 i = (char *)v6; | 2459 i = (char *)v6; |
2505 v33 = v25 - 1; | 2460 v33 = v25 - 1; |
2506 v31 = v3; | 2461 v31 = v3; |
2907 //----- (0049FBCD) -------------------------------------------------------- | 2862 //----- (0049FBCD) -------------------------------------------------------- |
2908 void Render::ClearTarget(unsigned int uColor) | 2863 void Render::ClearTarget(unsigned int uColor) |
2909 { | 2864 { |
2910 if (pRenderD3D) | 2865 if (pRenderD3D) |
2911 { | 2866 { |
2912 if (field_40110) | 2867 if (using_software_screen_buffer) |
2913 pRenderD3D->ClearTarget(true, uColor, false, 0.0); | 2868 pRenderD3D->ClearTarget(true, uColor, false, 0.0); |
2914 } | 2869 } |
2915 else | 2870 else |
2916 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); | 2871 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); |
2917 } | 2872 } |
2930 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 | 2885 struct tagRECT Rect; // [sp+8h] [bp-28h]@11 |
2931 RECT a4; // [sp+18h] [bp-18h]@11 | 2886 RECT a4; // [sp+18h] [bp-18h]@11 |
2932 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 | 2887 struct tagPOINT Point; // [sp+28h] [bp-8h]@11 |
2933 | 2888 |
2934 v1 = this; | 2889 v1 = this; |
2935 if ( !pRenderer->pRenderD3D || this->field_40110 ) | 2890 if ( !pRenderer->pRenderD3D || this->using_software_screen_buffer ) |
2936 { | 2891 { |
2937 this->pBeforePresentFunction(); | 2892 this->pBeforePresentFunction(); |
2938 if ( v1->pRenderD3D ) | 2893 if ( v1->pRenderD3D ) |
2939 { | 2894 { |
2940 if ( v1->field_40110 ) | 2895 if ( v1->using_software_screen_buffer ) |
2941 { | 2896 { |
2942 pRenderD3D->Present(false); | 2897 pRenderD3D->Present(false); |
2943 } | 2898 } |
2944 } | 2899 } |
2945 else __debugbreak(); // no sr | 2900 else __debugbreak(); // no sr |
3029 void **v16; // esi@29 | 2984 void **v16; // esi@29 |
3030 | 2985 |
3031 v1 = this; | 2986 v1 = this; |
3032 if (pRenderD3D) | 2987 if (pRenderD3D) |
3033 { | 2988 { |
3034 if ( v1->field_40110 ) | 2989 if ( v1->using_software_screen_buffer ) |
3035 { | 2990 { |
3036 pRenderD3D->ClearTarget(true, 0, false, 1.0); | 2991 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
3037 pRenderD3D->Present(0); | 2992 pRenderD3D->Present(0); |
3038 pRenderD3D->ClearTarget(true, 0, false, 1.0); | 2993 pRenderD3D->ClearTarget(true, 0, false, 1.0); |
3039 } | 2994 } |
3041 v1->pBackBuffer4 = 0; | 2996 v1->pBackBuffer4 = 0; |
3042 v1->pFrontBuffer4 = 0; | 2997 v1->pFrontBuffer4 = 0; |
3043 v1->pDirectDraw4 = 0; | 2998 v1->pDirectDraw4 = 0; |
3044 if (v1->pTargetSurface) | 2999 if (v1->pTargetSurface) |
3045 { | 3000 { |
3046 free(v1->ptr_400E8); | 3001 delete [] v1->pTargetSurface_unaligned; |
3047 v1->pTargetSurface = 0; | 3002 v1->pTargetSurface = 0; |
3048 v1->ptr_400E8 = 0; | 3003 v1->pTargetSurface_unaligned = 0; |
3049 } | 3004 } |
3050 if (pRenderD3D) | 3005 if (pRenderD3D) |
3051 { | 3006 { |
3052 pRenderD3D->Release(); | 3007 pRenderD3D->Release(); |
3053 delete pRenderD3D; | 3008 delete pRenderD3D; |
3153 RenderD3D *v11; // eax@25 | 3108 RenderD3D *v11; // eax@25 |
3154 HRESULT v12; // eax@25 | 3109 HRESULT v12; // eax@25 |
3155 int v13; // ecx@25 | 3110 int v13; // ecx@25 |
3156 int v14; // eax@27 | 3111 int v14; // eax@27 |
3157 signed int v15; // ebx@31 | 3112 signed int v15; // ebx@31 |
3158 bool v16; // eax@35 | 3113 //bool v16; // eax@35 |
3159 char v17; // zf@35 | 3114 //char v17; // zf@35 |
3160 IDirectDraw4 *v18; // eax@38 | 3115 IDirectDraw4 *v18; // eax@38 |
3161 HRESULT v19; // eax@38 | 3116 HRESULT v19; // eax@38 |
3162 int *v20; // eax@39 | 3117 //int *v20; // eax@39 |
3163 int *v22; // eax@42 | 3118 int *v22; // eax@42 |
3164 int v23; // ecx@42 | 3119 int v23; // ecx@42 |
3165 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 | 3120 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25 |
3166 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 | 3121 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@40 |
3167 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 | 3122 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@25 |
3168 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 | 3123 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@38 |
3169 void *v28; // [sp+2FCh] [bp-10h]@2 | 3124 void *v28; // [sp+2FCh] [bp-10h]@2 |
3170 int v29; // [sp+308h] [bp-4h]@2 | 3125 int v29; // [sp+308h] [bp-4h]@2 |
3171 | 3126 |
3127 __debugbreak(); // Nomad | |
3128 | |
3172 //v2 = this; | 3129 //v2 = this; |
3173 this->field_40110 = 0; | 3130 this->using_software_screen_buffer = 0; |
3174 this->pColorKeySurface4 = 0; | 3131 this->pColorKeySurface4 = 0; |
3175 this->pBackBuffer4 = 0; | 3132 this->pBackBuffer4 = 0; |
3176 this->pFrontBuffer4 = 0; | 3133 this->pFrontBuffer4 = 0; |
3177 this->pDirectDraw4 = 0; | 3134 this->pDirectDraw4 = 0; |
3178 this->bColorKeySupported = 0; | 3135 //this->bColorKeySupported = 0; |
3179 Release(); | 3136 Release(); |
3180 //v3 = hWnd; | 3137 //v3 = hWnd; |
3181 this->window = window; | 3138 this->window = window; |
3182 CreateZBuffer(); | 3139 CreateZBuffer(); |
3183 | 3140 |
3196 v6 = uDesiredDirect3DDevice; | 3153 v6 = uDesiredDirect3DDevice; |
3197 v29 = -1; | 3154 v29 = -1; |
3198 v7 = pRenderD3D->pAvailableDevices; | 3155 v7 = pRenderD3D->pAvailableDevices; |
3199 if ( v7[v6].bIsDeviceCompatible ) | 3156 if ( v7[v6].bIsDeviceCompatible ) |
3200 { | 3157 { |
3201 v8 = pRenderD3D->CreateDevice(v6, 0, window->GetApiHandle()); | 3158 v8 = pRenderD3D->CreateDevice(v6, /*0*/true, window); |
3202 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | 3159 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; |
3203 } | 3160 } |
3204 else | 3161 else |
3205 { | 3162 { |
3206 if ( v7[1].bIsDeviceCompatible ) | 3163 if ( v7[1].bIsDeviceCompatible ) |
3207 { | 3164 { |
3208 v8 = pRenderD3D->CreateDevice(1u, 0, window->GetApiHandle()); | 3165 v8 = pRenderD3D->CreateDevice(1, /*0*/true, window); |
3209 uAcquiredDirect3DDevice = 1; | 3166 uAcquiredDirect3DDevice = 1; |
3210 } | 3167 } |
3211 else | 3168 else |
3212 { | 3169 { |
3213 if ( !v7->bIsDeviceCompatible ) | 3170 if ( !v7->bIsDeviceCompatible ) |
3214 Error("There aren't any D3D devices to create."); | 3171 Error("There aren't any D3D devices to create."); |
3215 | 3172 |
3216 v8 = pRenderD3D->CreateDevice(0, 0, window->GetApiHandle()); | 3173 v8 = pRenderD3D->CreateDevice(0, /*0*/true, window); |
3217 uAcquiredDirect3DDevice = 1; | 3174 uAcquiredDirect3DDevice = 1; |
3218 } | 3175 } |
3219 } | 3176 } |
3220 if ( !v8 ) | 3177 if ( !v8 ) |
3221 Error("D3Drend->Init failed."); | 3178 Error("D3Drend->Init failed."); |
3300 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); | 3257 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u)); |
3301 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | 3258 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); |
3302 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | 3259 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); |
3303 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | 3260 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); |
3304 //} | 3261 //} |
3305 ddpfPrimareSuface.dwSize = 32; | 3262 ddpfPrimarySuface.dwSize = 32; |
3306 GetTargetPixelFormat(&ddpfPrimareSuface); | 3263 GetTargetPixelFormat(&ddpfPrimarySuface); |
3307 ParseTargetPixelFormat(); | 3264 ParseTargetPixelFormat(); |
3308 _49EBF1(); | 3265 |
3309 if ( pRenderD3D ) | 3266 if (!pRenderD3D) |
3310 { | 3267 { |
3311 v16 = IsColorKeySupported(pDirectDraw4); | 3268 __debugbreak(); |
3269 pBeforePresentFunction = 0;//nullsub_1; | |
3270 } | |
3271 //else | |
3272 //{ | |
3273 /*v16 = IsColorKeySupported(pDirectDraw4); | |
3312 v17 = uAcquiredDirect3DDevice == v15; | 3274 v17 = uAcquiredDirect3DDevice == v15; |
3313 bColorKeySupported = v16; | 3275 bColorKeySupported = v16; |
3314 if ( !v17 ) | 3276 if ( !v17 ) |
3315 bColorKeySupported = 0; | 3277 bColorKeySupported = 0; |
3316 if ( bColorKeySupported ) | 3278 if ( bColorKeySupported ) |
3325 ddsd2.dwWidth = 640; | 3287 ddsd2.dwWidth = 640; |
3326 ddsd2.dwHeight = 480; | 3288 ddsd2.dwHeight = 480; |
3327 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | 3289 ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); |
3328 pBeforePresentFunction = Present_ColorKey; | 3290 pBeforePresentFunction = Present_ColorKey; |
3329 } | 3291 } |
3330 else | 3292 else*/ |
3331 { | 3293 { |
3332 pTargetSurface = 0; | 3294 pTargetSurface = 0; |
3333 ptr_400E8 = 0; | 3295 pTargetSurface_unaligned = 0; |
3334 v20 = (int *)malloc(0x96020u); | 3296 pTargetSurface_unaligned = (unsigned int *)malloc(640 * 480 * 2 + 32); |
3335 ptr_400E8 = v20; | 3297 if ( !pTargetSurface_unaligned |
3336 if ( !v20 | |
3337 || (memset(&pDesc, 0, 0x7Cu), | 3298 || (memset(&pDesc, 0, 0x7Cu), |
3338 pDesc.dwSize = 124, | 3299 pDesc.dwSize = 124, |
3339 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) | 3300 !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) ) |
3340 return 0; | 3301 return 0; |
3341 pBackBuffer4->Unlock(0); | 3302 pBackBuffer4->Unlock(0); |
3342 v22 = ptr_400E8 + 4; | 3303 v22 = (int *)pTargetSurface_unaligned + 4; |
3343 v23 = (unsigned int)pDesc.lpSurface & 7; | 3304 v23 = (unsigned int)pDesc.lpSurface & 7; |
3344 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; | 3305 LOBYTE(v22) = (unsigned __int8)v22 & 0xF8; |
3345 uTargetSurfacePitch = 640; | 3306 uTargetSurfacePitch = 640; |
3346 pBeforePresentFunction = Present_NoColorKey; | 3307 pBeforePresentFunction = Present_NoColorKey; |
3347 v15 = 1; | 3308 v15 = 1; |
3348 pTargetSurface = (unsigned __int16 *)((char *)v22 + 2 * v23); | 3309 pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23); |
3349 } | 3310 } |
3350 field_40110 = v15; | 3311 using_software_screen_buffer = v15; |
3351 } | 3312 //} |
3352 else | |
3353 { | |
3354 pBeforePresentFunction = 0;//nullsub_1; | |
3355 } | |
3356 bWindowMode = 0; | 3313 bWindowMode = 0; |
3357 pParty->uFlags |= 2u; | 3314 pParty->uFlags |= 2u; |
3358 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; __debugbreak(); // replace with actual float | 3315 flt_6BE3A0 = 0.55000001f; |
3359 pViewport->_4C02F8(36044); | 3316 pViewport->_4C02F8(36044); |
3360 return v15 != 0; | 3317 return v15 != 0; |
3361 } | 3318 } |
3362 | 3319 |
3363 //----- (004A05F3) -------------------------------------------------------- | 3320 //----- (004A05F3) -------------------------------------------------------- |
3373 unsigned int v9; // eax@12 | 3330 unsigned int v9; // eax@12 |
3374 RenderD3D *v10; // eax@24 | 3331 RenderD3D *v10; // eax@24 |
3375 HRESULT v11; // eax@24 | 3332 HRESULT v11; // eax@24 |
3376 int v12; // eax@24 | 3333 int v12; // eax@24 |
3377 int v13; // eax@26 | 3334 int v13; // eax@26 |
3378 bool v14; // eax@32 | 3335 //bool v14; // eax@32 |
3379 char v15; // zf@32 | 3336 //char v15; // zf@32 |
3380 IDirectDraw4 *v16; // eax@35 | 3337 IDirectDraw4 *v16; // eax@35 |
3381 HRESULT v17; // eax@35 | 3338 HRESULT v17; // eax@35 |
3382 int *v18; // eax@36 | 3339 //int *v18; // eax@36 |
3383 int *v19; // edx@38 | 3340 int *v19; // edx@38 |
3384 int v20; // eax@38 | 3341 int v20; // eax@38 |
3385 unsigned int v21; // ecx@38 | 3342 unsigned int v21; // ecx@38 |
3386 int v22; // eax@41 | 3343 int v22; // eax@41 |
3387 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 | 3344 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 |
3389 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 | 3346 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 |
3390 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 | 3347 DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 |
3391 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 | 3348 //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 |
3392 int v29; // [sp+308h] [bp-4h]@2 | 3349 int v29; // [sp+308h] [bp-4h]@2 |
3393 | 3350 |
3394 pParty->uFlags |= 2u; | 3351 pParty->uFlags |= PARTY_FLAGS_1_0002; |
3395 //v2 = this; | 3352 //v2 = this; |
3396 flt_6BE3A0 = 0.55000001f; | 3353 flt_6BE3A0 = 0.55000001f; |
3397 pViewport->_4C02F8(36044); | 3354 pViewport->_4C02F8(36044); |
3398 field_40110 = 0; | 3355 using_software_screen_buffer = 0; |
3399 Release(); | 3356 Release(); |
3400 pColorKeySurface4 = 0; | 3357 pColorKeySurface4 = 0; |
3401 pBackBuffer4 = 0; | 3358 pBackBuffer4 = 0; |
3402 pFrontBuffer4 = 0; | 3359 pFrontBuffer4 = 0; |
3403 pDirectDraw4 = 0; | 3360 pDirectDraw4 = 0; |
3404 bColorKeySupported = 0; | 3361 //bColorKeySupported = 0; |
3405 CreateZBuffer(); | 3362 CreateZBuffer(); |
3406 /*if (!bUserDirect3D) | 3363 /*if (!bUserDirect3D) |
3407 { | 3364 { |
3408 CreateDirectDraw(); | 3365 CreateDirectDraw(); |
3409 SetDirectDrawCooperationMode(hWnd, 0); | 3366 SetDirectDrawCooperationMode(hWnd, 0); |
3429 v29 = -1; | 3386 v29 = -1; |
3430 //v6 = pRenderD3D->pAvailableDevices; | 3387 //v6 = pRenderD3D->pAvailableDevices; |
3431 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && | 3388 if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible && |
3432 uDesiredDirect3DDevice != 1 ) | 3389 uDesiredDirect3DDevice != 1 ) |
3433 { | 3390 { |
3434 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, window->GetApiHandle()); | 3391 v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window); |
3435 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; | 3392 uAcquiredDirect3DDevice = uDesiredDirect3DDevice; |
3436 } | 3393 } |
3437 else | 3394 else |
3438 { | 3395 { |
3439 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) | 3396 if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible ) |
3440 Error("There aren't any D3D devices to init."); | 3397 Error("There aren't any D3D devices to init."); |
3441 | 3398 |
3442 v7 = pRenderD3D->CreateDevice(0, 1, window->GetApiHandle()); | 3399 v7 = pRenderD3D->CreateDevice(0, true, window); |
3443 uAcquiredDirect3DDevice = 0; | 3400 uAcquiredDirect3DDevice = 0; |
3444 } | 3401 } |
3445 if ( !v7 ) | 3402 if ( !v7 ) |
3446 Error("D3Drend->Init failed."); | 3403 Error("D3Drend->Init failed."); |
3447 | 3404 |
3498 memset(&refCaps, 0, 0xFCu); | 3455 memset(&refCaps, 0, 0xFCu); |
3499 //v10 = v2->pRenderD3D; | 3456 //v10 = v2->pRenderD3D; |
3500 refCaps.dwSize = 252; | 3457 refCaps.dwSize = 252; |
3501 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); | 3458 ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps)); |
3502 v12 = halCaps.dwMinTextureWidth; | 3459 v12 = halCaps.dwMinTextureWidth; |
3503 if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight ) | 3460 if ( (unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight ) |
3504 v12 = halCaps.dwMinTextureHeight; | 3461 v12 = halCaps.dwMinTextureHeight; |
3505 uMinDeviceTextureDim = v12; | 3462 uMinDeviceTextureDim = v12; |
3506 v13 = halCaps.dwMaxTextureWidth; | 3463 v13 = halCaps.dwMaxTextureWidth; |
3507 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) | 3464 if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight ) |
3508 v13 = halCaps.dwMaxTextureHeight; | 3465 v13 = halCaps.dwMaxTextureHeight; |
3523 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); | 3480 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u)); |
3524 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); | 3481 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0)); |
3525 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); | 3482 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u)); |
3526 //} | 3483 //} |
3527 | 3484 |
3528 ddpfPrimareSuface.dwSize = 32; | 3485 ddpfPrimarySuface.dwSize = 32; |
3529 GetTargetPixelFormat(&ddpfPrimareSuface); | 3486 GetTargetPixelFormat(&ddpfPrimarySuface); |
3530 ParseTargetPixelFormat(); | 3487 ParseTargetPixelFormat(); |
3531 _49EBF1(); | 3488 |
3532 if ( !pRenderD3D ) | 3489 if ( !pRenderD3D ) |
3533 { | 3490 { |
3534 pBeforePresentFunction = 0;//nullsub_1; | 3491 __debugbreak(); |
3535 goto LABEL_47; | 3492 //pBeforePresentFunction = 0;//nullsub_1; |
3536 } | 3493 //goto LABEL_47; |
3537 v14 = IsColorKeySupported(pDirectDraw4); | 3494 } |
3495 /*v14 = IsColorKeySupported(pDirectDraw4); | |
3538 v15 = uAcquiredDirect3DDevice == 1; | 3496 v15 = uAcquiredDirect3DDevice == 1; |
3539 bColorKeySupported = v14; | 3497 bColorKeySupported = v14; |
3540 if ( !v15 ) | 3498 if ( !v15 ) |
3541 bColorKeySupported = 0; | 3499 bColorKeySupported = 0;*/ |
3542 if ( bColorKeySupported ) | 3500 //if ( bColorKeySupported ) |
3543 { | 3501 if (false) |
3544 memset(&ddsd2, 0, 0x7Cu); | 3502 { |
3503 /*memset(&ddsd2, 0, 0x7Cu); | |
3545 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; | 3504 ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask; |
3546 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; | 3505 ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue; |
3547 v16 = pDirectDraw4; | 3506 v16 = pDirectDraw4; |
3548 ddsd2.dwSize = 124; | 3507 ddsd2.dwSize = 124; |
3549 ddsd2.dwFlags = 65543; | 3508 ddsd2.dwFlags = 65543; |
3550 ddsd2.ddsCaps.dwCaps = 2112; | 3509 ddsd2.ddsCaps.dwCaps = 2112; |
3551 ddsd2.dwWidth = 640; | 3510 ddsd2.dwWidth = 640; |
3552 ddsd2.dwHeight = 480; | 3511 ddsd2.dwHeight = 480; |
3553 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); | 3512 ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); |
3554 pBeforePresentFunction = Present_ColorKey; | 3513 pBeforePresentFunction = Present_ColorKey;*/ |
3555 LABEL_45: | 3514 LABEL_45: |
3556 field_40110 = 1; | 3515 using_software_screen_buffer = 1; |
3557 LABEL_47: | 3516 //LABEL_47: |
3558 bWindowMode = 1; | 3517 bWindowMode = 1; |
3559 //hWnd = hWnd; | 3518 //hWnd = hWnd; |
3560 return 0; | 3519 return 0; |
3561 } | 3520 } |
3562 pTargetSurface = 0; | 3521 pTargetSurface = 0; |
3563 ptr_400E8 = 0; | 3522 pTargetSurface_unaligned = 0; |
3564 v18 = (int *)new char[0x96020]; | 3523 |
3565 memset(v18, -1, 0x96020); | 3524 uint num_pixels = window->GetWidth() * window->GetHeight(); |
3566 ptr_400E8 = v18; | 3525 pTargetSurface_unaligned = new unsigned int[num_pixels]; |
3567 if ( v18 ) | 3526 |
3568 { | 3527 if (!pTargetSurface_unaligned) |
3569 memset(&pDesc, 0, 0x7Cu); | 3528 return false; |
3570 pDesc.dwSize = 124; | 3529 |
3571 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) ) | 3530 memset(&pDesc, 0, 0x7Cu); |
3572 { | 3531 pDesc.dwSize = 124; |
3532 if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT)) | |
3533 { | |
3534 delete [] pTargetSurface_unaligned; | |
3535 return false; | |
3536 } | |
3537 | |
3538 memset32(pTargetSurface_unaligned, -1, num_pixels); | |
3539 | |
3540 | |
3573 pRenderer->pBackBuffer4->Unlock(0); | 3541 pRenderer->pBackBuffer4->Unlock(0); |
3574 v19 = ptr_400E8; | 3542 /*v19 = pTargetSurface_unaligned; |
3575 v20 = (unsigned int)pDesc.lpSurface & 7; | 3543 v20 = (unsigned int)pDesc.lpSurface & 7; |
3576 v21 = (unsigned int)ptr_400E8 & 7; | 3544 v21 = (unsigned int)ptr_400E8 & 7; |
3577 if ( v21 == v20 ) | 3545 if ( v21 == v20 ) |
3578 { | 3546 { |
3579 pTargetSurface = (unsigned __int16 *)v19; | 3547 pTargetSurface = (unsigned __int16 *)v19; |
3583 if ( (signed int)v21 >= v20 ) | 3551 if ( (signed int)v21 >= v20 ) |
3584 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); | 3552 v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); |
3585 else | 3553 else |
3586 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); | 3554 v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); |
3587 pTargetSurface = (unsigned __int16 *)v22; | 3555 pTargetSurface = (unsigned __int16 *)v22; |
3588 } | 3556 }*/ |
3589 uTargetSurfacePitch = 640; | 3557 pTargetSurface = pTargetSurface_unaligned; |
3558 uTargetSurfacePitch = window->GetWidth(); | |
3590 pBeforePresentFunction = Present_NoColorKey; | 3559 pBeforePresentFunction = Present_NoColorKey; |
3591 goto LABEL_45; | 3560 goto LABEL_45; |
3592 } | |
3593 } | |
3594 return 0; | |
3595 } | 3561 } |
3596 | 3562 |
3597 //----- (004A0BEE) -------------------------------------------------------- | 3563 //----- (004A0BEE) -------------------------------------------------------- |
3598 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) | 3564 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) |
3599 { | 3565 { |
3686 { | 3652 { |
3687 uXa = -uXa; | 3653 uXa = -uXa; |
3688 v24 = -1; | 3654 v24 = -1; |
3689 } | 3655 } |
3690 v25 = 0; | 3656 v25 = 0; |
3691 v26 = v35->pTargetSurface; | 3657 |
3658 __debugbreak(); //target sruface will most likely be 32bits/pixel, but this sub awaits 16 bits | |
3659 v26 = (unsigned __int16 *)v35->pTargetSurface; | |
3692 if ( v26 ) | 3660 if ( v26 ) |
3693 { | 3661 { |
3694 if ( (signed int)uXa <= v23 ) | 3662 if ( (signed int)uXa <= v23 ) |
3695 { | 3663 { |
3696 v30 = v23 + 1; | 3664 v30 = v23 + 1; |
3850 DWORD uRedMask; // edx@1 | 3818 DWORD uRedMask; // edx@1 |
3851 unsigned int uGreenMask; // esi@5 | 3819 unsigned int uGreenMask; // esi@5 |
3852 signed int v5; // ecx@5 | 3820 signed int v5; // ecx@5 |
3853 unsigned int uBlueMask; // edx@9 | 3821 unsigned int uBlueMask; // edx@9 |
3854 signed int v7; // ecx@9 | 3822 signed int v7; // ecx@9 |
3855 unsigned int v8; // ecx@13 | 3823 //unsigned int v8; // ecx@13 |
3856 | 3824 |
3857 v1 = this; | 3825 v1 = this; |
3858 v2 = 0; | 3826 v2 = 0; |
3859 uRedMask = v1->ddpfPrimareSuface.dwRBitMask; | 3827 uRedMask = v1->ddpfPrimarySuface.dwRBitMask; |
3860 v1->uTargetBBits = 0; | 3828 v1->uTargetBBits = 0; |
3861 v1->uTargetGBits = 0; | 3829 v1->uTargetGBits = 0; |
3862 v1->uTargetRBits = 0; | 3830 v1->uTargetRBits = 0; |
3863 do | 3831 do |
3864 { | 3832 { |
3865 if ( (1 << v2) & uRedMask ) | 3833 if ( (1 << v2) & uRedMask ) |
3866 ++v1->uTargetRBits; | 3834 ++v1->uTargetRBits; |
3867 ++v2; | 3835 ++v2; |
3868 } | 3836 } |
3869 while ( v2 < 16 ); | 3837 while ( v2 < 32 ); |
3870 uGreenMask = v1->ddpfPrimareSuface.dwGBitMask; | 3838 uGreenMask = v1->ddpfPrimarySuface.dwGBitMask; |
3871 v5 = 0; | 3839 v5 = 0; |
3872 do | 3840 do |
3873 { | 3841 { |
3874 if ( (1 << v5) & uGreenMask ) | 3842 if ( (1 << v5) & uGreenMask ) |
3875 ++v1->uTargetGBits; | 3843 ++v1->uTargetGBits; |
3876 ++v5; | 3844 ++v5; |
3877 } | 3845 } |
3878 while ( v5 < 16 ); | 3846 while ( v5 < 32 ); |
3879 uBlueMask = v1->ddpfPrimareSuface.dwBBitMask; | 3847 uBlueMask = v1->ddpfPrimarySuface.dwBBitMask; |
3880 v7 = 0; | 3848 v7 = 0; |
3881 do | 3849 do |
3882 { | 3850 { |
3883 if ( (1 << v7) & uBlueMask ) | 3851 if ( (1 << v7) & uBlueMask ) |
3884 ++v1->uTargetBBits; | 3852 ++v1->uTargetBBits; |
3885 ++v7; | 3853 ++v7; |
3886 } | 3854 } |
3887 while ( v7 < 16 ); | 3855 while ( v7 < 32 ); |
3888 v8 = v1->ddpfPrimareSuface.dwRBitMask; | |
3889 v1->uTargetGMask = uGreenMask; | 3856 v1->uTargetGMask = uGreenMask; |
3890 v1->uTargetRMask = v8; | 3857 v1->uTargetRMask = v1->ddpfPrimarySuface.dwRBitMask; |
3891 v1->uTargetBMask = uBlueMask; | 3858 v1->uTargetBMask = uBlueMask; |
3892 } | 3859 } |
3893 | 3860 |
3894 //----- (004A0F40) -------------------------------------------------------- | 3861 //----- (004A0F40) -------------------------------------------------------- |
3895 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) | 3862 bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) |
6153 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; | 6120 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; |
6154 else | 6121 else |
6155 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; | 6122 pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; |
6156 } | 6123 } |
6157 | 6124 |
6158 //----- (004A48E4) -------------------------------------------------------- | |
6159 int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6) | |
6160 { | |
6161 int v6; // ecx@1 | |
6162 int v7; // ebx@1 | |
6163 int v8; // ecx@1 | |
6164 int v9; // edx@1 | |
6165 int v10; // edi@1 | |
6166 unsigned int x; // esi@1 | |
6167 int result; // eax@8 | |
6168 int v13; // [sp+Ch] [bp-10h]@1 | |
6169 int v14; // [sp+10h] [bp-Ch]@1 | |
6170 int v15; // [sp+14h] [bp-8h]@1 | |
6171 int v16; // [sp+18h] [bp-4h]@1 | |
6172 int v17; // [sp+24h] [bp+8h]@1 | |
6173 unsigned int v18; // [sp+28h] [bp+Ch]@1 | |
6174 int v19; // [sp+34h] [bp+18h]@1 | |
6175 | |
6176 v6 = screenSpaceX; | |
6177 v7 = (a6 >> 1) + screenSpaceY; | |
6178 v17 = 0; | |
6179 v15 = 0; | |
6180 v8 = (a6 >> 1) + v6; | |
6181 v14 = (a6 >> 1) * (a6 >> 1); | |
6182 v9 = 2 * (a6 >> 1); | |
6183 v10 = (a6 >> 1) * ((a6 >> 1) - 1); | |
6184 x = v8 - (a6 >> 1); | |
6185 v16 = (a6 >> 1) + screenSpaceY - v8; | |
6186 v19 = a6 >> 1; | |
6187 v13 = v9; | |
6188 v18 = v8; | |
6189 do | |
6190 { | |
6191 sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor); | |
6192 if ( v15 ) | |
6193 sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor); | |
6194 v14 -= v15; | |
6195 if ( v14 <= v10 ) | |
6196 { | |
6197 if ( v19 != v17 ) | |
6198 { | |
6199 sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor); | |
6200 sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor); | |
6201 } | |
6202 --v19; | |
6203 v13 -= 2; | |
6204 ++x; | |
6205 v10 -= v13; | |
6206 } | |
6207 result = v17++; | |
6208 v15 += 2; | |
6209 --v18; | |
6210 } | |
6211 while ( result < v19 ); | |
6212 return result; | |
6213 } | |
6214 | 6125 |
6215 //----- (004A49D0) -------------------------------------------------------- | 6126 //----- (004A49D0) -------------------------------------------------------- |
6216 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) | 6127 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) |
6217 { | 6128 { |
6218 int absXDifference; // eax@1 | 6129 int absXDifference; // eax@1 |
6534 this->uNumSceneBegins = v2 + 1; | 6445 this->uNumSceneBegins = v2 + 1; |
6535 if ( !v2 ) | 6446 if ( !v2 ) |
6536 { | 6447 { |
6537 if ( this->pRenderD3D ) | 6448 if ( this->pRenderD3D ) |
6538 { | 6449 { |
6539 if ( this->bColorKeySupported ) | 6450 /*if ( this->bColorKeySupported ) |
6540 { | 6451 { |
6541 memset(&Dst, 0, 0x7Cu); | 6452 memset(&Dst, 0, 0x7Cu); |
6542 Dst.dwSize = 124; | 6453 Dst.dwSize = 124; |
6543 if ( LockSurface_DDraw4(this->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) ) | 6454 if ( LockSurface_DDraw4(this->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) ) |
6544 { | 6455 { |
6545 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; | 6456 this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; |
6546 this->uTargetSurfacePitch = Dst.lPitch >> 1; | 6457 this->uTargetSurfacePitch = Dst.lPitch >> 1; |
6547 this->field_18_locked_pitch = Dst.lPitch >> 1; | 6458 this->field_18_locked_pitch = Dst.lPitch >> 1; |
6548 } | 6459 } |
6549 --this->uNumSceneBegins; | 6460 --this->uNumSceneBegins; |
6550 } | 6461 }*/ |
6551 } | 6462 } |
6552 else | 6463 else |
6553 { | 6464 { |
6554 if ( !this->pTargetSurface ) | 6465 if ( !this->pTargetSurface ) |
6555 { | 6466 { |
6573 this->uNumSceneBegins--; | 6484 this->uNumSceneBegins--; |
6574 if ( !this->uNumSceneBegins ) | 6485 if ( !this->uNumSceneBegins ) |
6575 { | 6486 { |
6576 if ( this->pRenderD3D ) | 6487 if ( this->pRenderD3D ) |
6577 { | 6488 { |
6578 if ( this->bColorKeySupported ) | 6489 /*if ( this->bColorKeySupported ) |
6579 { | 6490 { |
6580 this->pTargetSurface = 0; | 6491 this->pTargetSurface = 0; |
6581 this->uTargetSurfacePitch = 0; | 6492 this->uTargetSurfacePitch = 0; |
6582 this->field_18_locked_pitch = 0; | 6493 this->field_18_locked_pitch = 0; |
6583 ErrD3D(this->pColorKeySurface4->Unlock(0)); | 6494 ErrD3D(this->pColorKeySurface4->Unlock(0)); |
6584 } | 6495 }*/ |
6585 } | 6496 } |
6586 else | 6497 else |
6587 { | 6498 { |
6588 this->pTargetSurface = 0; | 6499 this->pTargetSurface = 0; |
6589 this->uTargetSurfacePitch = 0; | 6500 this->uTargetSurfacePitch = 0; |
6825 this->bClip = 1; | 6736 this->bClip = 1; |
6826 this->uClipW = 480; | 6737 this->uClipW = 480; |
6827 this->uClipZ = 640; | 6738 this->uClipZ = 640; |
6828 } | 6739 } |
6829 | 6740 |
6741 unsigned __int32 Color32(unsigned __int16 color16) | |
6742 { | |
6743 unsigned __int32 c = color16; | |
6744 unsigned int b = (c & 31) * 8; | |
6745 unsigned int g = ((c >> 5) & 63) * 4; | |
6746 unsigned int r = ((c >> 11) & 31) * 8; | |
6747 | |
6748 return 0xFF000000 | (r << 16) | (g << 8) | b; | |
6749 } | |
6750 | |
6751 //----- (0040DEF3) -------------------------------------------------------- | |
6752 unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b) | |
6753 { | |
6754 //return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + | |
6755 // LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + | |
6756 // LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8)); | |
6757 return (b >> (8 - 5)) | | |
6758 0x7E0 & (g << (6 + 5 - 8)) | | |
6759 0xF800 & (r << (6 + 5 + 5 - 8)); | |
6760 } | |
6761 | |
6762 | |
6830 //----- (004A5BE3) -------------------------------------------------------- | 6763 //----- (004A5BE3) -------------------------------------------------------- |
6831 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) | 6764 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) |
6832 { | 6765 { |
6833 int v4; // edi@3 | 6766 int v4; // edi@3 |
6834 unsigned __int16 *v5; // edx@3 | 6767 //unsigned __int16 *v5; // edx@3 |
6835 unsigned __int16 *v6; // esi@3 | 6768 unsigned __int16 *v6; // esi@3 |
6836 unsigned int v8; // eax@5 | 6769 unsigned int v8; // eax@5 |
6837 unsigned int v9; // ebx@5 | 6770 unsigned int v9; // ebx@5 |
6838 unsigned int v11; // eax@7 | 6771 unsigned int v11; // eax@7 |
6839 unsigned int v12; // ebx@8 | 6772 unsigned int v12; // ebx@8 |
6843 int v23; // [sp+28h] [bp+10h]@3 | 6776 int v23; // [sp+28h] [bp+10h]@3 |
6844 | 6777 |
6845 if ( this->uNumSceneBegins && a4 ) | 6778 if ( this->uNumSceneBegins && a4 ) |
6846 { | 6779 { |
6847 v4 = a4->uWidth; | 6780 v4 = a4->uWidth; |
6848 v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | 6781 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
6849 v6 = a4->pPixels; | 6782 v6 = a4->pPixels; |
6850 v23 = a4->uHeight; | 6783 v23 = a4->uHeight; |
6851 v19 = v4; | 6784 v19 = v4; |
6852 if ( this->bClip ) | 6785 if ( this->bClip ) |
6853 { | 6786 { |
6856 v8 = this->uClipX - uOutX; | 6789 v8 = this->uClipX - uOutX; |
6857 v9 = uOutX - this->uClipX; | 6790 v9 = uOutX - this->uClipX; |
6858 v8 *= 2; | 6791 v8 *= 2; |
6859 v4 += v9; | 6792 v4 += v9; |
6860 v6 = (unsigned __int16 *)((char *)v6 + v8); | 6793 v6 = (unsigned __int16 *)((char *)v6 + v8); |
6861 v5 = (unsigned __int16 *)((char *)v5 + v8); | 6794 //v5 = (unsigned __int16 *)((char *)v5 + v8); |
6862 } | 6795 } |
6863 if ( (signed int)uOutY < (signed int)this->uClipY ) | 6796 if ( (signed int)uOutY < (signed int)this->uClipY ) |
6864 { | 6797 { |
6865 v11 = this->uClipY - uOutY; | 6798 v11 = this->uClipY - uOutY; |
6866 v6 += v19 * v11; | 6799 v6 += v19 * v11; |
6867 v23 += uOutY - this->uClipY; | 6800 v23 += uOutY - this->uClipY; |
6868 v5 += this->uTargetSurfacePitch * v11; | 6801 //v5 += this->uTargetSurfacePitch * v11; |
6869 } | 6802 } |
6870 v12 = max(this->uClipX, uOutX); | 6803 v12 = max(this->uClipX, uOutX); |
6871 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) | 6804 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) |
6872 { | 6805 { |
6873 v4 = this->uClipZ - max(this->uClipX, uOutX); | 6806 v4 = this->uClipZ - max(this->uClipX, uOutX); |
6877 { | 6810 { |
6878 v23 = this->uClipW - max(this->uClipY, uOutY); | 6811 v23 = this->uClipW - max(this->uClipY, uOutY); |
6879 } | 6812 } |
6880 } | 6813 } |
6881 | 6814 |
6882 for (int outerCounter = 0; outerCounter < v23; outerCounter++) | 6815 for (int y = 0; y < v23; y++) |
6883 { | 6816 { |
6884 for (int counter = 0; counter < v4; counter++) | 6817 for (int x = 0; x < v4; x++) |
6885 { | 6818 { |
6886 *v5 = *v6; | 6819 WritePixel16(uOutX + x, uOutY + y, *v6); |
6887 ++v5; | 6820 //*v5 = *v6; |
6821 //++v5; | |
6888 ++v6; | 6822 ++v6; |
6889 } | 6823 } |
6890 v6 += v19 - v4; | 6824 v6 += v19 - v4; |
6891 v5 += this->uTargetSurfacePitch - v4; | 6825 //v5 += this->uTargetSurfacePitch - v4; |
6892 } | 6826 } |
6893 } | 6827 } |
6894 } | 6828 } |
6895 | 6829 |
6896 //----- (004A5D33) -------------------------------------------------------- | 6830 //----- (004A5D33) -------------------------------------------------------- |
6897 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) | 6831 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) |
6898 { | 6832 { |
6899 unsigned __int16 *v7; // ebx@3 | 6833 //unsigned __int16 *v7; // ebx@3 |
6900 int full_width; // ecx@3 | 6834 int full_width; // ecx@3 |
6901 int full_height; // edi@3 | 6835 int full_height; // edi@3 |
6902 int v23; // edi@23 | 6836 //int v23; // edi@23 |
6903 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 | 6837 unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3 |
6904 | 6838 |
6905 if ( this->uNumSceneBegins && pTexture ) | 6839 if ( this->uNumSceneBegins && pTexture ) |
6906 { | 6840 { |
6907 v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch]; | 6841 /*auto v7 = this->pTargetSurface; |
6842 if (FORCE_16_BITS) | |
6843 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 2); | |
6844 else | |
6845 v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 4);*/ | |
6908 full_width = pTexture->uWidth - move_X; | 6846 full_width = pTexture->uWidth - move_X; |
6909 full_height = pTexture->uHeight - move_Y; | 6847 full_height = pTexture->uHeight - move_Y; |
6910 pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth]; | 6848 pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth]; |
6911 if ( this->bClip ) | 6849 if ( this->bClip ) |
6912 { | 6850 { |
6913 if ( pX < this->uClipX )//åñëè êàäð âûõîäèò çà ïðàâóþ ãðàíèöó | 6851 if ( pX < this->uClipX )//åñëè êàäð âûõîäèò çà ïðàâóþ ãðàíèöó |
6914 { | 6852 { |
6915 pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX))); | 6853 pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX))); |
6916 full_width += pX - this->uClipX; | 6854 full_width += pX - this->uClipX; |
6917 v7 = (unsigned __int16 *)((char *)v7 + (2 * (this->uClipX - pX))); | 6855 //v7 = (unsigned __int32 *)((char *)v7 + ((FORCE_16_BITS ? 2 : 4) * (this->uClipX - pX))); |
6918 } | 6856 } |
6919 if ( pY < this->uClipY )//åñëè êàäð âûõîäèò çà âåðõíþþ ãðàíèöó | 6857 if ( pY < this->uClipY )//åñëè êàäð âûõîäèò çà âåðõíþþ ãðàíèöó |
6920 { | 6858 { |
6921 pTexturea += pTexture->uWidth * (this->uClipY - pY); | 6859 pTexturea += pTexture->uWidth * (this->uClipY - pY); |
6922 full_height += pY - this->uClipY; | 6860 full_height += pY - this->uClipY; |
6923 v7 += this->uTargetSurfacePitch * (this->uClipY - pY); | 6861 //v7 = (unsigned __int32 *)((char *)v7 + (FORCE_16_BITS ? 2 : 4) * this->uTargetSurfacePitch * (this->uClipY - pY)); |
6924 } | 6862 } |
6925 if ( this->uClipX < pX )//åñëè ïðàâàÿ ãðàíèöà îêíà ìåíüøå õ êîîðäèíàòû êàäðà | 6863 if ( this->uClipX < pX )//åñëè ïðàâàÿ ãðàíèöà îêíà ìåíüøå õ êîîðäèíàòû êàäðà |
6926 this->uClipX = pX; | 6864 this->uClipX = pX; |
6927 if ( this->uClipY < pY )//åñëè âåðõíÿÿ ãðàíèöà îêíà ìåíüøå y êîîðäèíàòû êàäðà | 6865 if ( this->uClipY < pY )//åñëè âåðõíÿÿ ãðàíèöà îêíà ìåíüøå y êîîðäèíàòû êàäðà |
6928 this->uClipY = pY; | 6866 this->uClipY = pY; |
6937 if ( this->uClipY < pY ) | 6875 if ( this->uClipY < pY ) |
6938 this->uClipY = pY; | 6876 this->uClipY = pY; |
6939 full_height = this->uClipW - this->uClipY; | 6877 full_height = this->uClipW - this->uClipY; |
6940 } | 6878 } |
6941 } | 6879 } |
6942 if ( full_height > 0 ) | 6880 |
6943 { | 6881 for (int y = 0; y < full_height; ++y) |
6944 do | 6882 { |
6945 { | 6883 for (int x = 0; x < full_width; ++x) |
6946 if ( full_width > 0 ) | 6884 { |
6947 { | 6885 if ( *pTexturea != Color16(0, 0xFFu, 0xFFu) ) |
6948 v23 = full_width; | 6886 { |
6949 do | 6887 WritePixel16(pX + x, pY + y, *pTexturea); |
6950 { | 6888 /*if (FORCE_16_BITS) |
6951 if ( *pTexturea != TargetColor(0, 0xFFu, 0xFFu) ) | 6889 *(unsigned __int16 *)v7 = *pTexturea; |
6952 *v7 = *pTexturea; | 6890 else |
6891 *(unsigned __int32 *)v7 = r5g6b5_2_r8g8b8(*pTexturea);*/ | |
6892 } | |
6953 ++pTexturea; | 6893 ++pTexturea; |
6954 ++v7; | 6894 //++v7; |
6955 --v23; | |
6956 } | |
6957 while ( v23 ); | |
6958 } | 6895 } |
6959 v7 += this->uTargetSurfacePitch - full_width; | 6896 //v7 += this->uTargetSurfacePitch - full_width; |
6960 pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width)); | 6897 pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width)); |
6961 --full_height; | 6898 } |
6962 } | |
6963 while ( full_height ); | |
6964 } | |
6965 } | 6899 } |
6966 } | 6900 } |
6967 | 6901 |
6968 //----- (004A6E7E) -------------------------------------------------------- | 6902 //----- (004A6E7E) -------------------------------------------------------- |
6969 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) | 6903 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) |
6970 { | 6904 { |
6971 unsigned __int16 *v4; // eax@4 | 6905 //unsigned __int16 *v4; // eax@4 |
6972 int v5; // edx@4 | 6906 int v5; // edx@4 |
6973 unsigned int v6; // edi@4 | 6907 unsigned int v6; // edi@4 |
6974 unsigned int v7; // edx@5 | 6908 unsigned int v7; // edx@5 |
6975 unsigned int v8; // edx@6 | 6909 unsigned int v8; // edx@6 |
6976 unsigned int v9; // edx@7 | 6910 unsigned int v9; // edx@7 |
6990 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 | 6924 unsigned int v23; // [sp+2Ch] [bp+Ch]@23 |
6991 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 | 6925 unsigned int v24; // [sp+2Ch] [bp+Ch]@32 |
6992 | 6926 |
6993 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) | 6927 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) |
6994 { | 6928 { |
6995 v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | 6929 //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; |
6996 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; | 6930 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; |
6997 v5 = a4->uTextureWidth; | 6931 v5 = a4->uTextureWidth; |
6998 v6 = a4->uTextureHeight; | 6932 v6 = a4->uTextureHeight; |
6999 v19 = a4->uTextureWidth; | 6933 v19 = a4->uTextureWidth; |
7000 v18 = a4->uTextureWidth; | 6934 v18 = a4->uTextureWidth; |
6935 int clipped_out_x = a2; | |
6936 int clipped_out_y = a3; | |
7001 if ( this->bClip ) | 6937 if ( this->bClip ) |
7002 { | 6938 { |
7003 v7 = this->uClipX; | 6939 v7 = this->uClipX; |
7004 if ( (signed int)a2 < (signed int)v7 ) | 6940 if ( (signed int)a2 < (signed int)v7 ) |
7005 { | 6941 { |
7006 v8 = v7 - a2; | 6942 v8 = v7 - a2; |
7007 v20 += v8; | 6943 v20 += v8; |
7008 v19 += a2 - this->uClipX; | 6944 v19 += a2 - this->uClipX; |
7009 v4 += v8; | 6945 //v4 += v8; |
6946 clipped_out_x = uClipX; | |
7010 } | 6947 } |
7011 v9 = this->uClipY; | 6948 v9 = this->uClipY; |
7012 if ( (signed int)a3 < (signed int)v9 ) | 6949 if ( (signed int)a3 < (signed int)v9 ) |
7013 { | 6950 { |
7014 v10 = v9 - a3; | 6951 v10 = v9 - a3; |
7015 v20 += v18 * v10; | 6952 v20 += v18 * v10; |
7016 v6 = a3 - this->uClipY + a4->uTextureHeight; | 6953 v6 = a3 - this->uClipY + a4->uTextureHeight; |
7017 v4 += this->uTargetSurfacePitch * v10; | 6954 //v4 += this->uTargetSurfacePitch * v10; |
6955 clipped_out_y = uClipY; | |
7018 } | 6956 } |
7019 v11 = this->uClipX; | 6957 v11 = this->uClipX; |
7020 v5 = v19; | 6958 v5 = v19; |
7021 if ( (signed int)v11 < (signed int)a2 ) | 6959 if ( (signed int)v11 < (signed int)a2 ) |
7022 v11 = a2; | 6960 v11 = a2; |
7038 if ( (signed int)v16 < (signed int)a3 ) | 6976 if ( (signed int)v16 < (signed int)a3 ) |
7039 v16 = a3; | 6977 v16 = a3; |
7040 v6 = v15 - v16; | 6978 v6 = v15 - v16; |
7041 } | 6979 } |
7042 } | 6980 } |
7043 if ( pRenderer->uTargetGBits == 5 ) | 6981 |
6982 for (int y = 0; y < v6; ++y) | |
6983 { | |
6984 for (int x = 0; x < v5; ++x) | |
6985 { | |
6986 if ( *v20 ) | |
6987 WritePixel16(clipped_out_x + x, clipped_out_y + y, ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF); | |
6988 ++v20; | |
6989 } | |
6990 v20 += v18 - v5; | |
6991 } | |
6992 | |
6993 /*if ( pRenderer->uTargetGBits == 5 ) | |
7044 { | 6994 { |
7045 if ( (signed int)v6 > 0 ) | 6995 if ( (signed int)v6 > 0 ) |
7046 { | 6996 { |
7047 v23 = v6; | 6997 v23 = v6; |
7048 do | 6998 do |
7091 v17 = v24-- == 1; | 7041 v17 = v24-- == 1; |
7092 v4 += this->uTargetSurfacePitch - v5; | 7042 v4 += this->uTargetSurfacePitch - v5; |
7093 } | 7043 } |
7094 while ( !v17 ); | 7044 while ( !v17 ); |
7095 } | 7045 } |
7096 } | 7046 }*/ |
7097 } | 7047 } |
7098 } | 7048 } |
7099 | 7049 |
7100 //----- (004A6DF5) -------------------------------------------------------- | 7050 //----- (004A6DF5) -------------------------------------------------------- |
7101 int Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) | 7051 void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) |
7102 { | 7052 { |
7103 int result; // eax@0 | 7053 int result; // eax@0 |
7104 int v8; // ecx@3 | 7054 int v8; // ecx@3 |
7105 unsigned __int16 *v9; // edi@4 | 7055 unsigned __int16 *v9; // edi@4 |
7106 unsigned __int16 *v10; // ebx@4 | 7056 unsigned __int16 *v10; // ebx@4 |
7107 int v11; // esi@4 | 7057 int v11; // esi@4 |
7108 unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3 | 7058 unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3 |
7109 unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3 | 7059 unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3 |
7110 | 7060 |
7111 if ( pBitmap ) | 7061 if ( !pBitmap || !pTarget) |
7112 { | 7062 return; |
7113 if ( pTarget ) | 7063 |
7114 { | |
7115 pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y]; | 7064 pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y]; |
7116 pTargeta = &pTarget[a7->x + uTargetPitch * a7->y]; | 7065 |
7066 __debugbreak(); // sub expects 16bit target surface, we may have 32bit | |
7067 pTargeta = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y; | |
7117 v8 = a7->z - a7->x; | 7068 v8 = a7->z - a7->x; |
7118 result = a7->w - a7->y; | 7069 v11 = a7->w - a7->y; |
7119 if ( result > 0 ) | 7070 if ( v11 > 0 ) |
7120 { | 7071 { |
7121 v9 = pBitmapa; | 7072 v9 = pBitmapa; |
7122 v10 = pTargeta; | 7073 v10 = pTargeta; |
7123 v11 = a7->w - a7->y; | |
7124 do | 7074 do |
7125 { | 7075 { |
7126 if ( v8 > 0 ) | 7076 if ( v8 > 0 ) |
7127 { | 7077 { |
7128 result = v8; | 7078 result = v8; |
7139 v10 += uTargetPitch - v8; | 7089 v10 += uTargetPitch - v8; |
7140 --v11; | 7090 --v11; |
7141 } | 7091 } |
7142 while ( v11 ); | 7092 while ( v11 ); |
7143 } | 7093 } |
7144 } | |
7145 } | |
7146 return result; | |
7147 } | 7094 } |
7148 | 7095 |
7149 //----- (004A6D87) -------------------------------------------------------- | 7096 //----- (004A6D87) -------------------------------------------------------- |
7150 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) | 7097 void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) |
7151 { | 7098 { |
7153 return; | 7100 return; |
7154 | 7101 |
7155 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; | 7102 unsigned __int32 twoColors = (uColor16 << 16) | uColor16; |
7156 for (uint y = 0; y < uHeight; ++y) | 7103 for (uint y = 0; y < uHeight; ++y) |
7157 { | 7104 { |
7158 ushort* pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch]; | 7105 void *pDst = (char *)pTargetSurface + (FORCE_16_BITS ? 2 : 4) * (uX + (y + uY) * uTargetSurfacePitch); |
7159 | 7106 |
7160 memset32(pDst, twoColors, uWidth / 2); | 7107 memset32(pDst, |
7161 if (uWidth & 1) | 7108 FORCE_16_BITS ? twoColors : Color32(uColor16), // two colors per int (16bit) or 1 (32bit) |
7162 pDst[uWidth - 1] = uColor16; | 7109 uWidth / (FORCE_16_BITS ? 2 : 1)); // two pixels per int (16bit) or 1 (32bit) |
7110 | |
7111 if (FORCE_16_BITS && uWidth & 1) // we may miss one pixel for 16bit | |
7112 ((unsigned __int16 *)pTargetSurface)[uX + uWidth - 1 + (y + uY) * uTargetSurfacePitch] = uColor16; | |
7163 } | 7113 } |
7164 } | 7114 } |
7165 | 7115 |
7166 //----- (004A6C4F) -------------------------------------------------------- | 7116 //----- (004A6C4F) -------------------------------------------------------- |
7167 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) | 7117 void Render::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) |
7168 { | 7118 { |
7169 unsigned int v9; // edi@2 | 7119 unsigned int v9; // edi@2 |
7170 unsigned int v10; // esi@2 | 7120 unsigned int v10; // esi@2 |
7171 unsigned __int16 *v11; // eax@2 | 7121 //unsigned __int16 *v11; // eax@2 |
7172 unsigned int v12; // ebx@3 | 7122 unsigned int v12; // ebx@3 |
7173 signed int v13; // edx@5 | 7123 signed int v13; // edx@5 |
7174 int v14; // edx@6 | 7124 int v14; // edx@6 |
7175 signed int v15; // ebx@7 | 7125 signed int v15; // ebx@7 |
7176 unsigned int v16; // edx@9 | 7126 unsigned int v16; // edx@9 |
7177 signed int v17; // edi@10 | 7127 signed int v17; // edi@10 |
7178 signed int v18; // ebx@13 | 7128 signed int v18; // ebx@13 |
7179 unsigned int v19; // edx@15 | 7129 unsigned int v19; // edx@15 |
7180 signed int v20; // esi@16 | 7130 signed int v20; // esi@16 |
7181 unsigned int v21; // esi@22 | 7131 //unsigned int v21; // esi@22 |
7182 unsigned __int16 v22; // dx@24 | 7132 unsigned __int16 v22; // dx@24 |
7183 char v23; // zf@28 | 7133 //char v23; // zf@28 |
7184 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 | 7134 unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2 |
7185 unsigned int uOutXa; // [sp+18h] [bp+8h]@20 | 7135 //unsigned int uOutXa; // [sp+18h] [bp+8h]@20 |
7186 | 7136 |
7187 if ( this->uNumSceneBegins ) | 7137 if (!this->uNumSceneBegins) |
7188 { | 7138 return; |
7139 | |
7189 v9 = uCharWidth; | 7140 v9 = uCharWidth; |
7190 v10 = uCharHeight; | 7141 v10 = uCharHeight; |
7191 v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | 7142 //v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
7192 v24 = pFontPixels; | 7143 v24 = pFontPixels; |
7144 | |
7145 int clipped_out_x = uOutX, clipped_out_y = uOutY; | |
7193 if ( this->bClip ) | 7146 if ( this->bClip ) |
7194 { | 7147 { |
7195 v12 = this->uClipX; | 7148 v12 = this->uClipX; |
7196 if ( uOutX < (signed int)v12 ) | 7149 if ( uOutX < (signed int)v12 ) |
7197 { | 7150 { |
7198 v24 = &pFontPixels[v12 - uOutX]; | 7151 v24 = &pFontPixels[v12 - uOutX]; |
7199 v11 += v12 - uOutX; | 7152 //v11 += v12 - uOutX; |
7153 clipped_out_x = uClipX; | |
7200 v9 = uCharWidth + uOutX - v12; | 7154 v9 = uCharWidth + uOutX - v12; |
7201 } | 7155 } |
7202 v13 = this->uClipY; | 7156 v13 = this->uClipY; |
7203 if ( uOutY < v13 ) | 7157 if ( uOutY < v13 ) |
7204 { | 7158 { |
7205 v14 = v13 - uOutY; | 7159 v14 = v13 - uOutY; |
7206 v24 += uCharWidth * v14; | 7160 v24 += uCharWidth * v14; |
7207 v10 = uCharHeight + uOutY - this->uClipY; | 7161 v10 = uCharHeight + uOutY - this->uClipY; |
7208 v11 += this->uTargetSurfacePitch * v14; | 7162 //v11 += this->uTargetSurfacePitch * v14; |
7163 clipped_out_y = uClipY; | |
7209 } | 7164 } |
7210 v15 = this->uClipX; | 7165 v15 = this->uClipX; |
7211 if ( v15 < uOutX ) | 7166 if ( v15 < uOutX ) |
7212 v15 = uOutX; | 7167 v15 = uOutX; |
7213 v16 = this->uClipZ; | 7168 v16 = this->uClipZ; |
7228 if ( v20 < uOutY ) | 7183 if ( v20 < uOutY ) |
7229 v20 = uOutY; | 7184 v20 = uOutY; |
7230 v10 = v19 - v20; | 7185 v10 = v19 - v20; |
7231 } | 7186 } |
7232 } | 7187 } |
7233 if ( (signed int)v10 > 0 ) | 7188 |
7234 { | 7189 for (int y = 0; y < v10; ++y) |
7235 uOutXa = v10; | 7190 { |
7236 do | 7191 for (int x = 0; x < v9; ++x) |
7237 { | 7192 { |
7238 if ( (signed int)v9 > 0 ) | 7193 if (*v24) |
7239 { | 7194 { |
7240 v21 = v9; | 7195 v22 = uShadowColor; |
7241 do | 7196 if ( *v24 != 1 ) |
7242 { | 7197 v22 = uFaceColor; |
7243 if ( *v24 ) | 7198 WritePixel16(clipped_out_x + x, clipped_out_y + y, v22); |
7244 { | |
7245 v22 = uShadowColor; | |
7246 if ( *v24 != 1 ) | |
7247 v22 = uFaceColor; | |
7248 *v11 = v22; | |
7249 } | |
7250 ++v11; | |
7251 ++v24; | |
7252 --v21; | |
7253 } | |
7254 while ( v21 ); | |
7255 } | 7199 } |
7200 } | |
7256 v24 += uCharWidth - v9; | 7201 v24 += uCharWidth - v9; |
7257 v23 = uOutXa-- == 1; | 7202 //v23 = uOutXa-- == 1; |
7258 v11 += this->uTargetSurfacePitch - v9; | 7203 //v11 += this->uTargetSurfacePitch - v9; |
7259 } | 7204 } |
7260 while ( !v23 ); | |
7261 } | |
7262 } | |
7263 } | 7205 } |
7264 | 7206 |
7265 //----- (004A6A68) -------------------------------------------------------- | 7207 //----- (004A6A68) -------------------------------------------------------- |
7266 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) | 7208 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) |
7267 { | 7209 { |
7276 //----- (004A6AB1) -------------------------------------------------------- | 7218 //----- (004A6AB1) -------------------------------------------------------- |
7277 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 ) | 7219 void Render::DrawTextPalette( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8 ) |
7278 { | 7220 { |
7279 int v8; // edi@2 | 7221 int v8; // edi@2 |
7280 unsigned int v9; // esi@2 | 7222 unsigned int v9; // esi@2 |
7281 unsigned __int16 *v10; // eax@2 | 7223 //unsigned __int16 *v10; // eax@2 |
7282 unsigned char *v11; // edx@2 | 7224 unsigned char *v11; // edx@2 |
7283 unsigned int v12; // ebx@3 | 7225 unsigned int v12; // ebx@3 |
7284 signed int v13; // edx@5 | 7226 signed int v13; // edx@5 |
7285 int v14; // edx@6 | 7227 int v14; // edx@6 |
7286 signed int v15; // ebx@7 | 7228 signed int v15; // ebx@7 |
7301 unsigned int v30; // [sp+24h] [bp+14h]@31 | 7243 unsigned int v30; // [sp+24h] [bp+14h]@31 |
7302 | 7244 |
7303 int a2 = x; | 7245 int a2 = x; |
7304 int a3 = y; | 7246 int a3 = y; |
7305 uint a6 = uFontHeight; | 7247 uint a6 = uFontHeight; |
7306 if ( this->uNumSceneBegins ) | 7248 if (!this->uNumSceneBegins) |
7307 { | 7249 return; |
7250 | |
7308 v8 = a5; | 7251 v8 = a5; |
7309 v9 = a6; | 7252 v9 = a6; |
7310 v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; | 7253 //v10 = &pTargetSurface[x + y * uTargetSurfacePitch]; |
7311 v11 = (unsigned char *)font_pixels; | 7254 v11 = (unsigned char *)font_pixels; |
7312 v25 = (int)font_pixels; | 7255 v25 = (int)font_pixels; |
7256 int clipped_out_x = x; | |
7257 int clipped_out_y = y; | |
7313 if ( this->bClip ) | 7258 if ( this->bClip ) |
7314 { | 7259 { |
7315 v12 = this->uClipX; | 7260 v12 = this->uClipX; |
7316 if ( a2 < (signed int)v12 ) | 7261 if ( a2 < (signed int)v12 ) |
7317 { | 7262 { |
7318 v25 = v12 - a2 + (int)font_pixels; | 7263 v25 = v12 - a2 + (int)font_pixels; |
7319 v10 += v12 - a2; | 7264 //v10 += v12 - a2; |
7320 v8 = a5 + a2 - v12; | 7265 v8 = a5 + a2 - v12; |
7266 clipped_out_x = uClipX; | |
7321 } | 7267 } |
7322 v13 = this->uClipY; | 7268 v13 = this->uClipY; |
7323 if ( a3 < v13 ) | 7269 if ( a3 < v13 ) |
7324 { | 7270 { |
7325 v14 = v13 - a3; | 7271 v14 = v13 - a3; |
7326 v25 += a5 * v14; | 7272 v25 += a5 * v14; |
7327 v9 = a6 + a3 - this->uClipY; | 7273 v9 = a6 + a3 - this->uClipY; |
7328 v10 += this->uTargetSurfacePitch * v14; | 7274 //v10 += this->uTargetSurfacePitch * v14; |
7275 clipped_out_y = uClipY; | |
7329 } | 7276 } |
7330 v15 = this->uClipX; | 7277 v15 = this->uClipX; |
7331 if ( v15 < a2 ) | 7278 if ( v15 < a2 ) |
7332 v15 = a2; | 7279 v15 = a2; |
7333 v16 = this->uClipZ; | 7280 v16 = this->uClipZ; |
7349 v20 = a3; | 7296 v20 = a3; |
7350 v9 = v19 - v20; | 7297 v9 = v19 - v20; |
7351 } | 7298 } |
7352 v11 = (unsigned char *)v25; | 7299 v11 = (unsigned char *)v25; |
7353 } | 7300 } |
7301 | |
7354 if ( a8 ) | 7302 if ( a8 ) |
7355 { | 7303 { |
7356 v28 = pRenderer->uTargetGMask | pRenderer->uTargetBMask; | 7304 v28 = 0x7FF; // 16bit pRenderer->uTargetGMask | pRenderer->uTargetBMask; |
7357 if ( (signed int)v9 > 0 ) | 7305 for (int dy = 0; dy < v9; ++dy) |
7306 { | |
7307 for (int dx = 0; dx < v8; ++dx) | |
7308 { | |
7309 if ( *v11 ) | |
7310 v24 = pPalette[*v11]; | |
7311 else | |
7312 v24 = v28; | |
7313 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, v24); | |
7314 //*v10 = v24; | |
7315 //++v10; | |
7316 //++v11; | |
7317 //--v27; | |
7318 } | |
7319 v11 += a5 - v8; | |
7320 } | |
7321 /*if ( (signed int)v9 > 0 ) | |
7358 { | 7322 { |
7359 v23 = a5; | 7323 v23 = a5; |
7360 v30 = v9; | 7324 v30 = v9; |
7361 do | 7325 do |
7362 { | 7326 { |
7379 v11 += v23 - v8; | 7343 v11 += v23 - v8; |
7380 v22 = v30-- == 1; | 7344 v22 = v30-- == 1; |
7381 v10 += this->uTargetSurfacePitch - v8; | 7345 v10 += this->uTargetSurfacePitch - v8; |
7382 } | 7346 } |
7383 while ( !v22 ); | 7347 while ( !v22 ); |
7384 } | 7348 }*/ |
7385 } | 7349 } |
7386 else | 7350 else |
7387 { | 7351 { |
7388 if ( (signed int)v9 > 0 ) | 7352 for (int dy = 0; dy < v9; ++dy) |
7353 { | |
7354 for (int dx = 0; dx < v8; ++dx) | |
7355 { | |
7356 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, pPalette[*v11]); | |
7357 //*v10 = v24; | |
7358 //++v10; | |
7359 //++v11; | |
7360 //--v27; | |
7361 } | |
7362 v11 += a5 - v8; | |
7363 } | |
7364 | |
7365 /*if ( (signed int)v9 > 0 ) | |
7389 { | 7366 { |
7390 v21 = a5; | 7367 v21 = a5; |
7391 v29 = v9; | 7368 v29 = v9; |
7392 do | 7369 do |
7393 { | 7370 { |
7407 v11 += v21 - v8; | 7384 v11 += v21 - v8; |
7408 v22 = v29-- == 1; | 7385 v22 = v29-- == 1; |
7409 v10 += this->uTargetSurfacePitch - v8; | 7386 v10 += this->uTargetSurfacePitch - v8; |
7410 } | 7387 } |
7411 while ( !v22 ); | 7388 while ( !v22 ); |
7412 } | 7389 }*/ |
7413 } | 7390 } |
7414 } | |
7415 } | 7391 } |
7416 | 7392 |
7417 //----- (004A68EF) -------------------------------------------------------- | 7393 //----- (004A68EF) -------------------------------------------------------- |
7418 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | 7394 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) |
7419 { | 7395 { |
7420 Texture *v4; // edi@2 | 7396 DrawMasked(a2, a3, pTexture, 0x07E0); |
7421 unsigned int v5; // ebx@4 | 7397 } |
7422 unsigned __int16 *v6; // eax@4 | 7398 |
7423 signed int v7; // edx@5 | |
7424 int v8; // edx@6 | |
7425 signed int v9; // edx@7 | |
7426 int v10; // edx@8 | |
7427 signed int v11; // edx@9 | |
7428 signed int v12; // esi@12 | |
7429 signed int v13; // esi@15 | |
7430 unsigned int v14; // edx@17 | |
7431 signed int v15; // esi@18 | |
7432 unsigned __int8 *v16; // ebx@22 | |
7433 char v17; // zf@28 | |
7434 int v18; // [sp+10h] [bp-10h]@4 | |
7435 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7436 int v20; // [sp+1Ch] [bp-4h]@4 | |
7437 int v21; // [sp+28h] [bp+8h]@24 | |
7438 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
7439 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
7440 | |
7441 if ( this->uNumSceneBegins ) | |
7442 { | |
7443 v4 = pTexture; | |
7444 if ( pTexture ) | |
7445 { | |
7446 if ( pTexture->pPalette16 ) | |
7447 { | |
7448 v5 = pTexture->uTextureHeight; | |
7449 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
7450 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; | |
7451 v20 = pTexture->uTextureWidth; | |
7452 v18 = pTexture->uTextureWidth; | |
7453 if ( this->bClip ) | |
7454 { | |
7455 v7 = this->uClipX; | |
7456 if ( a2 < v7 ) | |
7457 { | |
7458 v8 = v7 - a2; | |
7459 v19 += v8; | |
7460 v20 += a2 - this->uClipX; | |
7461 v6 += v8; | |
7462 } | |
7463 v9 = this->uClipY; | |
7464 v5 = pTexture->uTextureHeight; | |
7465 if ( a3 < v9 ) | |
7466 { | |
7467 v10 = v9 - a3; | |
7468 v19 += v18 * v10; | |
7469 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
7470 v4 = pTexture; | |
7471 v6 += this->uTargetSurfacePitch * v10; | |
7472 } | |
7473 v11 = this->uClipX; | |
7474 if ( v11 < a2 ) | |
7475 v11 = a2; | |
7476 pTexturea = this->uClipZ; | |
7477 if ( v11 + v20 > (signed int)pTexturea ) | |
7478 { | |
7479 v12 = this->uClipX; | |
7480 if ( v12 < a2 ) | |
7481 v12 = a2; | |
7482 v20 = pTexturea - v12; | |
7483 } | |
7484 v13 = this->uClipY; | |
7485 if ( v13 < a3 ) | |
7486 v13 = a3; | |
7487 v14 = this->uClipW; | |
7488 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7489 { | |
7490 v15 = this->uClipY; | |
7491 if ( v15 < a3 ) | |
7492 v15 = a3; | |
7493 v5 = v14 - v15; | |
7494 } | |
7495 } | |
7496 if ( (signed int)v5 > 0 ) | |
7497 { | |
7498 v22 = v5; | |
7499 v16 = v19; | |
7500 do | |
7501 { | |
7502 if ( v20 > 0 ) | |
7503 { | |
7504 v21 = v20; | |
7505 do | |
7506 { | |
7507 if ( *v16 ) | |
7508 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
7509 ++v6; | |
7510 ++v16; | |
7511 --v21; | |
7512 } | |
7513 while ( v21 ); | |
7514 } | |
7515 v16 += v18 - v20; | |
7516 v17 = v22-- == 1; | |
7517 v6 += this->uTargetSurfacePitch - v20; | |
7518 } | |
7519 while ( !v17 ); | |
7520 } | |
7521 } | |
7522 } | |
7523 } | |
7524 } | |
7525 | 7399 |
7526 //----- (004A6776) -------------------------------------------------------- | 7400 //----- (004A6776) -------------------------------------------------------- |
7527 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) | 7401 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) |
7528 { | 7402 { |
7529 Texture *v4; // edi@2 | 7403 DrawMasked(a2, a3, a4, 0xF800); |
7404 /*Texture *v4; // edi@2 | |
7530 unsigned int v5; // ebx@4 | 7405 unsigned int v5; // ebx@4 |
7531 unsigned __int16 *v6; // eax@4 | 7406 unsigned __int16 *v6; // eax@4 |
7532 unsigned int v7; // edx@5 | 7407 unsigned int v7; // edx@5 |
7533 unsigned int v8; // edx@6 | 7408 unsigned int v8; // edx@6 |
7534 unsigned int v9; // edx@7 | 7409 unsigned int v9; // edx@7 |
7627 } | 7502 } |
7628 while ( !v17 ); | 7503 while ( !v17 ); |
7629 } | 7504 } |
7630 } | 7505 } |
7631 } | 7506 } |
7632 } | 7507 }*/ |
7633 } | 7508 } |
7509 | |
7510 //----- (004A68EF) -------------------------------------------------------- | |
7511 void Render::DrawMasked(signed int a2, signed int a3, Texture *pTexture, unsigned __int16 mask) | |
7512 { | |
7513 Texture *v4; // edi@2 | |
7514 unsigned int v5; // ebx@4 | |
7515 //unsigned __int16 *v6; // eax@4 | |
7516 signed int v7; // edx@5 | |
7517 int v8; // edx@6 | |
7518 signed int v9; // edx@7 | |
7519 int v10; // edx@8 | |
7520 signed int v11; // edx@9 | |
7521 signed int v12; // esi@12 | |
7522 signed int v13; // esi@15 | |
7523 unsigned int v14; // edx@17 | |
7524 signed int v15; // esi@18 | |
7525 unsigned __int8 *v16; // ebx@22 | |
7526 char v17; // zf@28 | |
7527 int v18; // [sp+10h] [bp-10h]@4 | |
7528 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
7529 int v20; // [sp+1Ch] [bp-4h]@4 | |
7530 int v21; // [sp+28h] [bp+8h]@24 | |
7531 unsigned int v22; // [sp+2Ch] [bp+Ch]@22 | |
7532 unsigned int pTexturea; // [sp+30h] [bp+10h]@11 | |
7533 | |
7534 if (!uNumSceneBegins || !pTexture) | |
7535 return; | |
7536 | |
7537 v4 = pTexture; | |
7538 | |
7539 if ( pTexture->pPalette16 ) | |
7540 { | |
7541 v5 = pTexture->uTextureHeight; | |
7542 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
7543 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; | |
7544 v20 = pTexture->uTextureWidth; | |
7545 v18 = pTexture->uTextureWidth; | |
7546 int clipped_out_x = a2; | |
7547 int clipped_out_y = a3; | |
7548 if ( this->bClip ) | |
7549 { | |
7550 v7 = this->uClipX; | |
7551 if ( a2 < v7 ) | |
7552 { | |
7553 v8 = v7 - a2; | |
7554 v19 += v8; | |
7555 v20 += a2 - this->uClipX; | |
7556 //v6 += v8; | |
7557 clipped_out_x = uClipX; | |
7558 } | |
7559 v9 = this->uClipY; | |
7560 v5 = pTexture->uTextureHeight; | |
7561 if ( a3 < v9 ) | |
7562 { | |
7563 v10 = v9 - a3; | |
7564 v19 += v18 * v10; | |
7565 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | |
7566 v4 = pTexture; | |
7567 //v6 += this->uTargetSurfacePitch * v10; | |
7568 clipped_out_y = uClipY; | |
7569 } | |
7570 v11 = this->uClipX; | |
7571 if ( v11 < a2 ) | |
7572 v11 = a2; | |
7573 pTexturea = this->uClipZ; | |
7574 if ( v11 + v20 > (signed int)pTexturea ) | |
7575 { | |
7576 v12 = this->uClipX; | |
7577 if ( v12 < a2 ) | |
7578 v12 = a2; | |
7579 v20 = pTexturea - v12; | |
7580 } | |
7581 v13 = this->uClipY; | |
7582 if ( v13 < a3 ) | |
7583 v13 = a3; | |
7584 v14 = this->uClipW; | |
7585 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7586 { | |
7587 v15 = this->uClipY; | |
7588 if ( v15 < a3 ) | |
7589 v15 = a3; | |
7590 v5 = v14 - v15; | |
7591 } | |
7592 } | |
7593 | |
7594 v16 = v19; | |
7595 for (int y = 0; y < v5; ++y) | |
7596 { | |
7597 for (int x = 0; x < v20; ++x) | |
7598 { | |
7599 if ( *v16 ) | |
7600 WritePixel16(clipped_out_x + x, clipped_out_y + y, v4->pPalette16[*v16] & mask); | |
7601 ++v16; | |
7602 } | |
7603 v16 += v18 - v20; | |
7604 } | |
7605 | |
7606 /*if ( (signed int)v5 > 0 ) | |
7607 { | |
7608 v22 = v5; | |
7609 v16 = v19; | |
7610 do | |
7611 { | |
7612 if ( v20 > 0 ) | |
7613 { | |
7614 v21 = v20; | |
7615 do | |
7616 { | |
7617 if ( *v16 ) | |
7618 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
7619 ++v6; | |
7620 ++v16; | |
7621 --v21; | |
7622 } | |
7623 while ( v21 ); | |
7624 } | |
7625 v16 += v18 - v20; | |
7626 v17 = v22-- == 1; | |
7627 v6 += this->uTargetSurfacePitch - v20; | |
7628 } | |
7629 while ( !v17 ); | |
7630 }*/ | |
7631 } | |
7632 } | |
7633 | |
7634 | 7634 |
7635 //----- (004A65CC) -------------------------------------------------------- | 7635 //----- (004A65CC) -------------------------------------------------------- |
7636 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | 7636 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) |
7637 { | 7637 { |
7638 unsigned __int16 *v8; // esi@6 | 7638 //unsigned __int16 *v8; // esi@6 |
7639 unsigned int v9; // edi@6 | 7639 unsigned int v9; // edi@6 |
7640 unsigned int v10; // eax@7 | 7640 unsigned int v10; // eax@7 |
7641 unsigned int v11; // eax@8 | 7641 unsigned int v11; // eax@8 |
7642 unsigned int v12; // eax@9 | 7642 unsigned int v12; // eax@9 |
7643 unsigned int v13; // eax@10 | 7643 unsigned int v13; // eax@10 |
7656 unsigned int ya; // [sp+24h] [bp+Ch]@24 | 7656 unsigned int ya; // [sp+24h] [bp+Ch]@24 |
7657 int v27; // [sp+2Ch] [bp+14h]@6 | 7657 int v27; // [sp+2Ch] [bp+14h]@6 |
7658 | 7658 |
7659 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) | 7659 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) |
7660 { | 7660 { |
7661 v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; | 7661 //v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch]; |
7662 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; | 7662 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; |
7663 v27 = a4->uTextureWidth; | 7663 v27 = a4->uTextureWidth; |
7664 v9 = a4->uTextureHeight; | 7664 v9 = a4->uTextureHeight; |
7665 v22 = a4->uTextureWidth; | 7665 v22 = a4->uTextureWidth; |
7666 int clipped_out_x = x; | |
7667 int clipped_out_y = y; | |
7666 if ( this->bClip ) | 7668 if ( this->bClip ) |
7667 { | 7669 { |
7668 v10 = this->uClipX; | 7670 v10 = this->uClipX; |
7669 if ( (signed int)x < (signed int)v10 ) | 7671 if ( (signed int)x < (signed int)v10 ) |
7670 { | 7672 { |
7671 v11 = v10 - x; | 7673 v11 = v10 - x; |
7672 v24 += v11; | 7674 v24 += v11; |
7673 v27 += x - this->uClipX; | 7675 v27 += x - this->uClipX; |
7674 v8 += v11; | 7676 //v8 += v11; |
7677 clipped_out_x = uClipX; | |
7675 } | 7678 } |
7676 v12 = this->uClipY; | 7679 v12 = this->uClipY; |
7677 if ( (signed int)y < (signed int)v12 ) | 7680 if ( (signed int)y < (signed int)v12 ) |
7678 { | 7681 { |
7679 v13 = v12 - y; | 7682 v13 = v12 - y; |
7680 v24 += v22 * v13; | 7683 v24 += v22 * v13; |
7681 v9 = y - this->uClipY + a4->uTextureHeight; | 7684 v9 = y - this->uClipY + a4->uTextureHeight; |
7682 v8 += this->uTargetSurfacePitch * v13; | 7685 //v8 += this->uTargetSurfacePitch * v13; |
7686 clipped_out_y = uClipY; | |
7683 } | 7687 } |
7684 v14 = this->uClipX; | 7688 v14 = this->uClipX; |
7685 if ( (signed int)v14 < (signed int)x ) | 7689 if ( (signed int)v14 < (signed int)x ) |
7686 v14 = x; | 7690 v14 = x; |
7687 v15 = this->uClipZ; | 7691 v15 = this->uClipZ; |
7702 if ( (signed int)v19 < (signed int)y ) | 7706 if ( (signed int)v19 < (signed int)y ) |
7703 v19 = y; | 7707 v19 = y; |
7704 v9 = v18 - v19; | 7708 v9 = v18 - v19; |
7705 } | 7709 } |
7706 } | 7710 } |
7707 if ( (signed int)v9 > 0 ) | 7711 |
7712 for (int dy = 0; dy < v9; ++dy) | |
7713 { | |
7714 for (int dx = 0; dx < v27; ++dx) | |
7715 { | |
7716 v20 = *v24; | |
7717 if ( v20 >= a7 && v20 <= a8 ) | |
7718 { | |
7719 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7720 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7721 v21 = 2 * a8 - v21 - a7; | |
7722 //*v8 = a4->pPalette16[v21]; | |
7723 WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]); | |
7724 } | |
7725 ++v24; | |
7726 } | |
7727 v24 += v22 - v27; | |
7728 } | |
7729 /*if ( (signed int)v9 > 0 ) | |
7708 { | 7730 { |
7709 ya = v9; | 7731 ya = v9; |
7710 v23 = v22 - v27; | 7732 v23 = v22 - v27; |
7711 do | 7733 do |
7712 { | 7734 { |
7732 v8 += this->uTargetSurfacePitch - v27; | 7754 v8 += this->uTargetSurfacePitch - v27; |
7733 v24 += v23; | 7755 v24 += v23; |
7734 --ya; | 7756 --ya; |
7735 } | 7757 } |
7736 while ( ya ); | 7758 while ( ya ); |
7737 } | 7759 }*/ |
7738 } | 7760 } |
7739 } | 7761 } |
7740 | 7762 |
7741 //----- (004A63E6) -------------------------------------------------------- | 7763 //----- (004A63E6) -------------------------------------------------------- |
7742 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) | 7764 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) |
7743 { | 7765 { |
7744 Texture *v8; // eax@2 | 7766 Texture *v8; // eax@2 |
7745 Texture *v9; // ebx@4 | 7767 //Texture *v9; // ebx@4 |
7746 unsigned __int16 *v10; // esi@6 | 7768 //unsigned __int16 *v10; // esi@6 |
7747 unsigned int v11; // edi@7 | 7769 unsigned int v11; // edi@7 |
7748 unsigned int v12; // eax@9 | 7770 unsigned int v12; // eax@9 |
7749 unsigned int v13; // eax@10 | 7771 unsigned int v13; // eax@10 |
7750 unsigned int v14; // edx@11 | 7772 unsigned int v14; // edx@11 |
7751 unsigned int v15; // eax@13 | 7773 unsigned int v15; // eax@13 |
7768 v8 = a4; | 7790 v8 = a4; |
7769 if ( a4 ) | 7791 if ( a4 ) |
7770 { | 7792 { |
7771 if ( a4->pPalette16 ) | 7793 if ( a4->pPalette16 ) |
7772 { | 7794 { |
7773 v9 = a5; | |
7774 if ( a5 ) | 7795 if ( a5 ) |
7775 { | 7796 { |
7776 if ( a5->pPalette16 ) | 7797 if ( a5->pPalette16 ) |
7777 { | 7798 { |
7778 v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | 7799 //v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; |
7779 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; | 7800 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; |
7780 v25 = v8->uTextureWidth; | 7801 v25 = v8->uTextureWidth; |
7781 v24 = v8->uTextureHeight; | 7802 v24 = v8->uTextureHeight; |
7782 v22 = v8->uTextureWidth; | 7803 v22 = v8->uTextureWidth; |
7804 | |
7805 int clipped_out_x = a2; | |
7806 int clipped_out_y = a3; | |
7783 if ( this->bClip ) | 7807 if ( this->bClip ) |
7784 { | 7808 { |
7785 v11 = this->uClipX; | 7809 v11 = this->uClipX; |
7786 if ( (signed int)a2 < (signed int)v11 ) | 7810 if ( (signed int)a2 < (signed int)v11 ) |
7787 { | 7811 { |
7788 v28 += v11 - a2; | 7812 v28 += v11 - a2; |
7789 v25 += a2 - v11; | 7813 v25 += a2 - v11; |
7790 v9 = a5; | 7814 //v10 += v11 - a2; |
7791 v10 += v11 - a2; | 7815 clipped_out_x = uClipX; |
7792 } | 7816 } |
7793 v12 = this->uClipY; | 7817 v12 = this->uClipY; |
7794 if ( (signed int)a3 < (signed int)v12 ) | 7818 if ( (signed int)a3 < (signed int)v12 ) |
7795 { | 7819 { |
7796 v13 = v12 - a3; | 7820 v13 = v12 - a3; |
7797 v9 = a5; | |
7798 v28 += v22 * v13; | 7821 v28 += v22 * v13; |
7799 v24 += a3 - this->uClipY; | 7822 v24 += a3 - this->uClipY; |
7800 v10 += this->uTargetSurfacePitch * v13; | 7823 //v10 += this->uTargetSurfacePitch * v13; |
7824 clipped_out_y = uClipY; | |
7801 } | 7825 } |
7802 v14 = this->uClipX; | 7826 v14 = this->uClipX; |
7803 if ( (signed int)v14 < (signed int)a2 ) | 7827 if ( (signed int)v14 < (signed int)a2 ) |
7804 v14 = a2; | 7828 v14 = a2; |
7805 v15 = this->uClipZ; | 7829 v15 = this->uClipZ; |
7820 if ( (signed int)v19 < (signed int)a3 ) | 7844 if ( (signed int)v19 < (signed int)a3 ) |
7821 v19 = a3; | 7845 v19 = a3; |
7822 v24 = v18 - v19; | 7846 v24 = v18 - v19; |
7823 } | 7847 } |
7824 } | 7848 } |
7849 | |
7825 v27 = 0; | 7850 v27 = 0; |
7826 if ( v24 > 0 ) | 7851 for (int y = 0; y < v24; ++y) |
7852 { | |
7853 for (int x = 0; x < v25; ++x) | |
7854 { | |
7855 if ( *v28 ) | |
7856 { | |
7857 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[i & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); | |
7858 if ( v20 >= a7 ) | |
7859 { | |
7860 if ( v20 <= a8 ) | |
7861 { | |
7862 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | |
7863 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) | |
7864 v21 = 2 * a8 - v21 - a7; | |
7865 //v9 = a5; | |
7866 //*v10 = a5->pPalette16[v21]; | |
7867 WritePixel16(clipped_out_x + x, clipped_out_y + y, a5->pPalette16[v21]); | |
7868 } | |
7869 } | |
7870 } | |
7871 v28++; | |
7872 } | |
7873 v28 += v22 - v25; | |
7874 } | |
7875 | |
7876 /*if ( v24 > 0 ) | |
7827 { | 7877 { |
7828 v23 = v22 - v25; | 7878 v23 = v22 - v25; |
7829 do | 7879 do |
7830 { | 7880 { |
7831 for ( i = 0; i < v25; ++v28 ) | 7881 for ( i = 0; i < v25; ++v28 ) |
7851 ++v27; | 7901 ++v27; |
7852 v10 += this->uTargetSurfacePitch - v25; | 7902 v10 += this->uTargetSurfacePitch - v25; |
7853 v28 += v23; | 7903 v28 += v23; |
7854 } | 7904 } |
7855 while ( v27 < v24 ); | 7905 while ( v27 < v24 ); |
7856 } | 7906 }*/ |
7907 | |
7908 | |
7909 | |
7857 } | 7910 } |
7858 } | 7911 } |
7859 } | 7912 } |
7860 } | 7913 } |
7861 } | 7914 } |
7864 //----- (004A6274) -------------------------------------------------------- | 7917 //----- (004A6274) -------------------------------------------------------- |
7865 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) | 7918 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture) |
7866 { | 7919 { |
7867 Texture *pCurrentTexture; // edi@2 | 7920 Texture *pCurrentTexture; // edi@2 |
7868 int uHeight; // ebx@4 | 7921 int uHeight; // ebx@4 |
7869 unsigned __int16 *v6; // eax@4 | 7922 //unsigned __int16 *v6; // eax@4 |
7870 unsigned int v7; // edx@5 | 7923 unsigned int v7; // edx@5 |
7871 unsigned int v8; // edx@6 | 7924 unsigned int v8; // edx@6 |
7872 unsigned int v9; // edx@7 | 7925 unsigned int v9; // edx@7 |
7873 unsigned int v10; // edx@8 | 7926 unsigned int v10; // edx@8 |
7874 unsigned int v11; // edx@9 | 7927 unsigned int v11; // edx@9 |
7891 if ( pTexture ) | 7944 if ( pTexture ) |
7892 { | 7945 { |
7893 if ( pTexture->pPalette16 ) | 7946 if ( pTexture->pPalette16 ) |
7894 { | 7947 { |
7895 uHeight = pTexture->uTextureHeight; | 7948 uHeight = pTexture->uTextureHeight; |
7896 v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | 7949 //v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; |
7897 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; | 7950 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; |
7898 uWidth = pTexture->uTextureWidth; | 7951 uWidth = pTexture->uTextureWidth; |
7899 v18 = pTexture->uTextureWidth; | 7952 v18 = pTexture->uTextureWidth; |
7953 | |
7954 int clipped_out_x = uX; | |
7955 int clipped_out_y = uY; | |
7900 if ( this->bClip ) | 7956 if ( this->bClip ) |
7901 { | 7957 { |
7902 v7 = this->uClipX; | 7958 v7 = this->uClipX; |
7903 if ( (signed int)uX < (signed int)v7 ) | 7959 if ( (signed int)uX < (signed int)v7 ) |
7904 { | 7960 { |
7905 v8 = v7 - uX; | 7961 v8 = v7 - uX; |
7906 v19 += v8; | 7962 v19 += v8; |
7907 uWidth += uX - this->uClipX; | 7963 uWidth += uX - this->uClipX; |
7908 v6 += v8; | 7964 //v6 += v8; |
7965 clipped_out_x = uClipX; | |
7909 } | 7966 } |
7910 v9 = this->uClipY; | 7967 v9 = this->uClipY; |
7911 uHeight = pTexture->uTextureHeight; | 7968 uHeight = pTexture->uTextureHeight; |
7912 if ( (signed int)uY < (signed int)v9 ) | 7969 if ( (signed int)uY < (signed int)v9 ) |
7913 { | 7970 { |
7914 v10 = v9 - uY; | 7971 v10 = v9 - uY; |
7915 v19 += v18 * v10; | 7972 v19 += v18 * v10; |
7916 uHeight = uY - this->uClipY + pTexture->uTextureHeight; | 7973 uHeight = uY - this->uClipY + pTexture->uTextureHeight; |
7917 pCurrentTexture = pTexture; | 7974 pCurrentTexture = pTexture; |
7918 v6 += this->uTargetSurfacePitch * v10; | 7975 //v6 += this->uTargetSurfacePitch * v10; |
7976 clipped_out_y = uClipY; | |
7919 } | 7977 } |
7920 v11 = this->uClipX; | 7978 v11 = this->uClipX; |
7921 if ( (signed int)v11 < (signed int)uX ) | 7979 if ( (signed int)v11 < (signed int)uX ) |
7922 v11 = uX; | 7980 v11 = uX; |
7923 pTexturea = this->uClipZ; | 7981 pTexturea = this->uClipZ; |
7938 if ( (signed int)v15 < (signed int)uY ) | 7996 if ( (signed int)v15 < (signed int)uY ) |
7939 v15 = uY; | 7997 v15 = uY; |
7940 uHeight = v14 - v15; | 7998 uHeight = v14 - v15; |
7941 } | 7999 } |
7942 } | 8000 } |
7943 if ( (signed int)uHeight > 0 ) | 8001 |
8002 v16 = v19; | |
8003 for (int y = 0; y < uHeight; ++y) | |
8004 { | |
8005 for (int x = 0; x < uWidth; ++x) | |
8006 { | |
8007 if ( *v16 ) | |
8008 WritePixel16(clipped_out_x + x, clipped_out_y + y, pCurrentTexture->pPalette16[*v16]); | |
8009 ++v16; | |
8010 } | |
8011 v16 += v18 - uWidth; | |
8012 } | |
8013 /*if ( (signed int)uHeight > 0 ) | |
7944 { | 8014 { |
7945 uYa = uHeight; | 8015 uYa = uHeight; |
7946 v16 = v19; | 8016 v16 = v19; |
7947 do | 8017 do |
7948 { | 8018 { |
7961 v16 += v18 - uWidth; | 8031 v16 += v18 - uWidth; |
7962 uFlag = uYa-- == 1; | 8032 uFlag = uYa-- == 1; |
7963 v6 += this->uTargetSurfacePitch - uWidth; | 8033 v6 += this->uTargetSurfacePitch - uWidth; |
7964 } | 8034 } |
7965 while ( !uFlag ); | 8035 while ( !uFlag ); |
7966 } | 8036 }*/ |
7967 } | 8037 } |
7968 } | 8038 } |
7969 } | 8039 } |
7970 } | 8040 } |
7971 | 8041 |
8157 | 8227 |
8158 //----- (004A5EB2) -------------------------------------------------------- | 8228 //----- (004A5EB2) -------------------------------------------------------- |
8159 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) | 8229 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4) |
8160 { | 8230 { |
8161 Texture *v4; // edi@2 | 8231 Texture *v4; // edi@2 |
8162 unsigned int v5; // ebx@4 | 8232 int v5; // ebx@4 |
8163 unsigned __int16 *pTarget; // eax@4 | 8233 //unsigned __int16 *pTarget; // eax@4 |
8164 unsigned int v7; // edx@5 | 8234 unsigned int v7; // edx@5 |
8165 unsigned int v8; // edx@6 | 8235 unsigned int v8; // edx@6 |
8166 unsigned int v9; // edx@7 | 8236 unsigned int v9; // edx@7 |
8167 unsigned int v10; // edx@8 | 8237 unsigned int v10; // edx@8 |
8168 unsigned int v11; // edx@9 | 8238 unsigned int v11; // edx@9 |
8169 unsigned int v12; // esi@12 | 8239 unsigned int v12; // esi@12 |
8170 unsigned int v13; // esi@15 | 8240 unsigned int v13; // esi@15 |
8171 unsigned int v14; // edx@17 | 8241 //unsigned int v14; // edx@17 |
8172 unsigned int v15; // esi@18 | 8242 unsigned int v15; // esi@18 |
8173 unsigned __int8 *v16; // edx@22 | 8243 unsigned __int8 *v16; // edx@22 |
8174 char v17; // zf@26 | 8244 char v17; // zf@26 |
8175 int v18; // [sp+10h] [bp-10h]@4 | 8245 int v18; // [sp+10h] [bp-10h]@4 |
8176 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | 8246 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 |
8185 if ( a4 ) | 8255 if ( a4 ) |
8186 { | 8256 { |
8187 if ( a4->pPalette16 ) | 8257 if ( a4->pPalette16 ) |
8188 { | 8258 { |
8189 v5 = a4->uTextureHeight; | 8259 v5 = a4->uTextureHeight; |
8190 pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; | 8260 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; |
8191 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; | 8261 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; |
8192 v20 = a4->uTextureWidth; | 8262 v20 = a4->uTextureWidth; |
8193 v18 = a4->uTextureWidth; | 8263 v18 = a4->uTextureWidth; |
8264 | |
8265 int clipped_out_x = uX; | |
8266 int clipped_out_y = uY; | |
8194 if ( this->bClip ) | 8267 if ( this->bClip ) |
8195 { | 8268 { |
8196 v7 = this->uClipX; | 8269 v7 = this->uClipX; |
8197 if ( (signed int)uX < (signed int)v7 ) | 8270 if ( (signed int)uX < (signed int)v7 ) |
8198 { | 8271 { |
8199 v8 = v7 - uX; | 8272 v8 = v7 - uX; |
8200 v19 += v8; | 8273 v19 += v8; |
8201 v20 += uX - this->uClipX; | 8274 v20 += uX - this->uClipX; |
8202 pTarget += v8; | 8275 //pTarget += v8; |
8276 clipped_out_x = uClipX; | |
8203 } | 8277 } |
8204 v9 = this->uClipY; | 8278 v9 = this->uClipY; |
8205 v5 = a4->uTextureHeight; | 8279 v5 = a4->uTextureHeight; |
8206 if ( (signed int)uY < (signed int)v9 ) | 8280 if ( (signed int)uY < (signed int)v9 ) |
8207 { | 8281 { |
8208 v10 = v9 - uY; | 8282 v10 = v9 - uY; |
8209 v19 += v18 * v10; | 8283 v19 += v18 * v10; |
8210 v5 = uY - this->uClipY + a4->uTextureHeight; | 8284 v5 = uY - this->uClipY + a4->uTextureHeight; |
8211 v4 = a4; | 8285 v4 = a4; |
8212 pTarget += this->uTargetSurfacePitch * v10; | 8286 //pTarget += this->uTargetSurfacePitch * v10; |
8287 clipped_out_y = uClipY; | |
8213 } | 8288 } |
8214 v11 = this->uClipX; | 8289 v11 = this->uClipX; |
8215 if ( (signed int)v11 < (signed int)uX ) | 8290 if ( (signed int)v11 < (signed int)uX ) |
8216 v11 = uX; | 8291 v11 = uX; |
8217 v23 = this->uClipZ; | 8292 v23 = this->uClipZ; |
8223 v20 = v23 - v12; | 8298 v20 = v23 - v12; |
8224 } | 8299 } |
8225 v13 = this->uClipY; | 8300 v13 = this->uClipY; |
8226 if ( (signed int)v13 < (signed int)uY ) | 8301 if ( (signed int)v13 < (signed int)uY ) |
8227 v13 = uY; | 8302 v13 = uY; |
8228 v14 = this->uClipW; | 8303 |
8229 if ( (signed int)(v5 + v13) > (signed int)v14 ) | 8304 if ( (signed int)(v5 + v13) > (signed int)uClipW ) |
8230 { | 8305 { |
8231 v15 = this->uClipY; | 8306 v15 = this->uClipY; |
8232 if ( (signed int)v15 < (signed int)uY ) | 8307 if ( (signed int)v15 < (signed int)uY ) |
8233 v15 = uY; | 8308 v15 = uY; |
8234 v5 = v14 - v15; | 8309 v5 = uClipW - v15; |
8235 } | 8310 } |
8236 } | 8311 } |
8237 if ( (signed int)v5 > 0 ) | 8312 |
8313 v16 = v19; | |
8314 for (int y = 0; y < v5; ++y) | |
8315 { | |
8316 for (int x = 0; x < v20; ++x) | |
8317 { | |
8318 WritePixel16(clipped_out_x + x, clipped_out_y + y, v4->pPalette16[*v16]); | |
8319 ++v16; | |
8320 } | |
8321 v16 += v18 - v20; | |
8322 } | |
8323 /*if ( (signed int)v5 > 0 ) | |
8238 { | 8324 { |
8239 uYa = v5; | 8325 uYa = v5; |
8240 v16 = v19; | 8326 v16 = v19; |
8241 do | 8327 do |
8242 { | 8328 { |
8255 v16 += v18 - v20; | 8341 v16 += v18 - v20; |
8256 v17 = uYa-- == 1; | 8342 v17 = uYa-- == 1; |
8257 pTarget += this->uTargetSurfacePitch - v20; | 8343 pTarget += this->uTargetSurfacePitch - v20; |
8258 } | 8344 } |
8259 while ( !v17 ); | 8345 while ( !v17 ); |
8260 } | 8346 }*/ |
8261 } | 8347 } |
8262 } | 8348 } |
8263 } | 8349 } |
8264 } | 8350 } |
8265 | 8351 |