45 #pragma comment(lib, "GdiPlus.lib")
59 void ErrHR(HRESULT hr,
const char *pAPI,
const char *pFunction,
60 const char *pFile,
int line) {
66 sprintf(msg,
"%s error (%08X) in\n\t%s\nin\n\t%s:%u", pAPI, hr, pFunction,
70 sprintf(caption,
"%s error", pAPI);
117 unsigned int lod_sprite_id) {
127 unsigned int b = (
color & 0x1F) << 3;
128 unsigned int g = ((
color >> 5) & 0x3F) << 2;
129 unsigned int r = ((
color >> 11) & 0x1F) << 3;
131 Gdiplus::Color
c(
r,
g,
b);
136 bool bResult =
false;
138 IDirectDrawSurface4 *pSurface1 =
nullptr;
139 IDirect3DTexture2 *pTexture1 =
nullptr;
150 IDirectDrawSurface4 *pSurface2 =
nullptr;
151 IDirect3DTexture2 *pTexture2 =
nullptr;
170 pTexture1->Release();
171 pTexture2->Release();
172 pSurface1->Release();
173 pSurface2->Release();
198 p->screenspace_projection_factor_x;
200 p->screenspace_projection_factor_y;
202 soft_billboard.
uFlags =
p->field_1E;
212 extern unsigned int BlendColors(
unsigned int a1,
unsigned int a2);
219 pTerrainVertices[128 * 128];
237 int blockScale = 512;
238 int heightScale = 32;
239 for (
unsigned int z = 0;
z < 128; ++
z) {
240 for (
unsigned int x = 0;
x < 128; ++
x) {
242 (-64 + (signed)
x) * blockScale;
244 (64 - (signed)
z) * blockScale;
262 unsigned int Start_X, End_X, Start_Z, End_Z;
263 if (direction >= 0 && direction < 1.0) {
265 Start_Z = 0, End_Z = 128;
266 }
else if (direction >= 1.0 &&
268 Start_X = 0, End_X = 128;
270 }
else if (direction >= 3.0 &&
273 Start_Z = 0, End_Z = 128;
274 }
else if (direction >= 5.0 &&
276 Start_X = 0, End_X = 128;
280 Start_Z = 0, End_Z = 128;
287 float Light_tile_dist;
289 for (
unsigned int z = Start_Z;
z < End_Z; ++
z) {
290 for (
unsigned int x = Start_X;
x < End_X; ++
x) {
292 int xdist = camx -
x;
293 int zdist = camz -
z;
295 if (xdist > tilerange || zdist > tilerange)
continue;
297 int dist = sqrt((xdist)*(xdist)+(zdist)*(zdist));
298 if (dist > tilerange)
continue;
302 pTilePolygon->
flags = 0;
355 memcpy(&
array_73D150[2], &pTerrainVertices[(
z + 1) * 128 +
x + 1],
391 pTilePolygon->
pid = (8 * (0 | (0 << 6))) | 6;
392 for (
unsigned int k = 0; k < pTilePolygon->
uNumVertices; ++k) {
420 if (norm_idx != bottnormidx) {
436 memcpy(&
array_73D150[1], &pTerrainVertices[(
z + 1) * 128 +
x + 1],
445 for (
unsigned int k = 0; k < pTilePolygon->
uNumVertices; ++k) {
469 (float)far_clip_distance <
array_73D150[0].vWorldViewPosition.x ||
471 (float)far_clip_distance <
array_73D150[2].vWorldViewPosition.x;
474 static stru154 static_sub_0048034E_stru_154;
480 uClipFlag = far_clip != 0 ? 5 : 0;
481 static_sub_0048034E_stru_154.ClassifyPolygon(norm, Light_tile_dist);
485 4, &static_sub_0048034E_stru_154,
487 *(
float *)&uClipFlag, -1);
490 &
Lights, &static_sub_0048034E_stru_154, 3,
504 bool transparent =
false;
506 auto tile_texture = tile->GetTexture();
507 if (!(pTilePolygon->
flags & 1)) {
509 if ( tile->IsWaterTile()) {
512 }
else if (tile->IsWaterBorderTile()) {
518 pTilePolygon->
texture = tile_texture;
520 render->DrawTerrainPolygon(pTilePolygon, transparent,
true);
534 memcpy(&
array_73D150[2], &pTerrainVertices[(
z + 1) * 128 +
x + 1],
543 for (
unsigned int k = 0; k < pTilePolygon->
uNumVertices; ++k) {
560 unsigned int a5_2 = 4;
571 (float)far_clip_distance_2 <
array_73D150[0].vWorldViewPosition.x ||
573 (float)far_clip_distance_2 <
array_73D150[2].vWorldViewPosition.x;
576 static stru154 static_sub_0048034E_stru_154_2;
582 uClipFlag_2 = far_clip_2 != 0 ? 5 : 0;
583 static_sub_0048034E_stru_154_2.ClassifyPolygon(norm2, Light_tile_dist);
587 4, &static_sub_0048034E_stru_154_2,
589 *(
float *)&uClipFlag_2, -1);
592 &
Lights, &static_sub_0048034E_stru_154_2, 3,
606 bool transparent =
false;
608 auto tile_texture = tile->GetTexture();
609 if (!(pTilePolygon->
flags & 1)) {
611 if ( tile->IsWaterTile()) {
614 }
else if (tile->IsWaterBorderTile()) {
620 pTilePolygon->
texture = tile_texture;
622 render->DrawTerrainPolygon(pTilePolygon, transparent,
true);
640 if (
engine->config->extended_draw_distance)
641 far_clip_distance = 0x5000;
647 (float)far_clip_distance <
array_73D150[0].vWorldViewPosition.x ||
649 (float)far_clip_distance <
array_73D150[2].vWorldViewPosition.x ||
653 static stru154 static_sub_0048034E_stru_154;
659 uClipFlag = far_clip != 0 ? 5 : 0;
664 4, &static_sub_0048034E_stru_154,
666 *(
float *)&uClipFlag, -1);
677 bool transparent =
false;
679 auto tile_texture = tile->GetTexture();
680 if (!(pTilePolygon->
flags & 1)) {
682 if ( tile->IsWaterTile()) {
685 }
else if (tile->IsWaterBorderTile()) {
691 pTilePolygon->
texture = tile_texture;
693 render->DrawTerrainPolygon(pTilePolygon, transparent,
true);
703 memcpy(&poly_clone, poly,
sizeof(poly_clone));
717 unsigned __int16 *v10;
723 unsigned __int16 *v37;
732 if (!(decor_desc->
uFlags & 0x80)) {
733 if (!(decor_desc->
uFlags & 0x22)) {
741 if (
engine->config->seasons_change) {
765 v37 = (
unsigned __int16 *)v13;
766 if (frame->
uFlags & 2) v38 = 2;
767 if ((256 << v13) & frame->
uFlags) v38 |= 4;
768 if (frame->
uFlags & 0x40000) v38 |= 0x40;
769 if (frame->
uFlags & 0x20000) v38 |= 0x80;
776 if (
render->config->is_using_colored_lights) {
822 int screen_space_half_width = 0;
823 screen_space_half_width =
825 frame->
hw_sprites[(int)v37]->uBufferWidth / 2;
828 if (projected_x + screen_space_half_width >=
830 projected_x - screen_space_half_width <=
880 memset(&local_0, 0, 0x68);
905 unsigned int sCorrectedColor;
912 sCorrectedColor = -1;
914 engine->AlterGamma_ODM(pFace, &sCorrectedColor);
927 if (
config->is_using_specular) {
928 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
929 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
930 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
949 if (
config->is_using_specular)
958 if (pFace->uAttributes & FACE_OUTLINED) {
970 0,
texture->GetDirect3DTexture()));
973 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
991 if (
config->is_using_specular)
1000 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
1003 if (
config->is_using_specular)
1009 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
1020 0,
texture->GetDirect3DTexture()));
1023 if (!
config->is_using_specular)
1027 D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
1031 D3DBLEND_SRCCOLOR));
1034 D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE | D3DFVF_SPECULAR,
1036 if (
config->is_using_specular) {
1048 D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA));
1050 D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA));
1053 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR |
1057 D3DRENDERSTATE_FOGENABLE, TRUE));
1070 D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
1116 RECT dest_rect = {0};
1117 GetWindowRect((HWND)
window->GetWinApiHandle(), &dest_rect);
1119 DDBLTFX lpDDBltFx = {0};
1120 lpDDBltFx.dwSize =
sizeof(DDBLTFX);
1121 lpDDBltFx.dwFillColor = 0;
1122 pBackBuffer4->Blt(&dest_rect, NULL, NULL, DDBLT_COLORFILL, &lpDDBltFx);
1142 FILE *
result = fopen(filename.c_str(),
"wb");
1149 unsigned int pcx_data_real_size = 0;
1151 &pcx_data_real_size);
1152 fwrite(pcx_data, pcx_data_real_size, 1,
result);
1159 FILE *
result = fopen(filename.c_str(),
"wb");
1166 unsigned int pcx_data_real_size = 0;
1168 &pcx_data_real_size);
1169 fwrite(pcx_data, pcx_data_real_size, 1,
result);
1213 unsigned int dst_pitch) {
1216 for (
uint y = 0;
y < 8; ++
y) {
1217 memcpy(
dst +
y * dst_pitch,
src +
y * src_pitch,
1221 for (
uint y = 8;
y < 352; ++
y) {
1228 for (
uint y = 352;
y < 480; ++
y) {
1229 memcpy(
dst +
y * dst_pitch,
src +
y * src_pitch,
1237 if (
src[
x +
y * src_pitch] !=
1239 dst[
x +
y * dst_pitch] =
src[
x +
y * src_pitch];
1248 DDSURFACEDESC2 Dst = {0};
1249 Dst.dwSize =
sizeof(Dst);
1250 if (
r->LockSurface_DDraw4(
r->pBackBuffer4, &Dst, DDLOCK_WAIT)) {
1251 Gdiplus::Rect rect(0, 0, Dst.dwWidth, Dst.dwHeight);
1252 Gdiplus::BitmapData bitmapData;
1253 r->p2DSurface->LockBits(&rect, Gdiplus::ImageLockModeRead,
1254 PixelFormat32bppARGB, &bitmapData);
1256 (
uint32_t *)Dst.lpSurface, Dst.lPitch / 4);
1257 r->p2DSurface->UnlockBits(&bitmapData);
1258 ErrD3D(
r->pBackBuffer4->Unlock(NULL));
1279 if (v7[1].bIsDeviceCompatible) {
1283 Error(
"There aren't any D3D devices to create.");
1289 Error(
"D3Drend->Init failed.");
1306 Error(
"Direct3D renderer: The device failed to return capabilities.");
1318 "Direct3D renderer: The device doesn't support the necessary "
1319 "alpha blending modes.");
1321 if ((v10 & 0x80) != 0) {
1331 "Direct3D renderer: The device doesn't support non-square "
1337 D3DDEVICEDESC halCaps = {0};
1338 halCaps.dwSize =
sizeof(halCaps);
1340 D3DDEVICEDESC refCaps = {0};
1341 refCaps.dwSize =
sizeof(refCaps);
1346 if ((
unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight)
1349 if ((
unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight)
1384 PixelFormat32bppRGB);
1403 unsigned int uLightmapColorMaskR = (pLightmap->
uColorMask >> 16) & 0xFF;
1404 unsigned int uLightmapColorMaskG = (pLightmap->
uColorMask >> 8) & 0xFF;
1405 unsigned int uLightmapColorMaskB = pLightmap->
uColorMask & 0xFF;
1407 unsigned int uLightmapColorR = floorf(
1408 uLightmapColorMaskR * pLightmap->
fBrightness * pColorMult->
x + 0.5f);
1409 unsigned int uLightmapColorG = floorf(
1410 uLightmapColorMaskG * pLightmap->
fBrightness * pColorMult->
y + 0.5f);
1411 unsigned int uLightmapColorB = floorf(
1412 uLightmapColorMaskB * pLightmap->
fBrightness * pColorMult->
z + 0.5f);
1417 if (fabs(z_bias) < 1e-5) {
1422 if (v18 < 0.000099999997) {
1423 v18 = 0.000099999997;
1429 pVerticesD3D[i].
pos.
z = v18;
1432 pVerticesD3D[i].
diffuse = (uLightmapColorR << 16) | (uLightmapColorG << 8) | uLightmapColorB;
1439 int dwFlags = D3DDP_DONOTLIGHT;
1441 dwFlags |= D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS;
1446 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
1455 int uSrcTotalWidth = 0;
1468 src_width = pSrcRect->
z - pSrcRect->
x;
1469 src_height = pSrcRect->
w - pSrcRect->
y;
1477 uSrcPitch = uSrcTotalWidth;
1478 src_surf_pos = &pSrc[pSrcRect->
x + uSrcPitch * pSrcRect->
y];
1485 if (blend_mode == 2) {
1486 uSrcPitch = (uSrcPitch - src_width);
1487 for (
int i = 0; i < src_height; ++i) {
1488 for (
int j = 0; j < src_width; ++j) {
1489 if (*src_surf_pos != v10) {
1490 if (pTargetPoint->
x + j >= 0 &&
1491 pTargetPoint->
x + j <= window->GetWidth() - 1 &&
1492 pTargetPoint->
y + i >= 0 &&
1493 pTargetPoint->
y + i <=
window->GetHeight() - 1)
1494 temppix[j + i * src_width] =
Color32(*src_surf_pos);
1498 src_surf_pos += uSrcPitch;
1501 uSrcPitch = (uSrcPitch - src_width);
1502 for (
int i = 0; i < src_height; ++i) {
1503 for (
int j = 0; j < src_width; ++j) {
1504 if (*src_surf_pos != v10) {
1505 if (pTargetPoint->
x + j >= 0 &&
1506 pTargetPoint->
x + j <= window->GetWidth() - 1 &&
1507 pTargetPoint->
y + i >= 0 &&
1508 pTargetPoint->
y + i <=
window->GetHeight() - 1)
1509 temppix[j + i * src_width] =
Color32((0x7BEF & (*src_surf_pos / 2)));
1513 src_surf_pos += uSrcPitch;
1516 render->DrawTextureAlphaNew(pTargetPoint->
x / 640., pTargetPoint->
y / 480., temp);
1538 Error(
"There aren't any D3D devices to init.");
1542 if (!v7) Error(
"D3Drend->Init failed.");
1549 if (device_caps & 1) {
1558 Error(
"Direct3D renderer: The device failed to return capabilities.");
1560 if (device_caps & 0x3E) {
1570 "Direct3D renderer: The device doesn't support the necessary "
1571 "alpha blending modes.");
1573 if (device_caps & 0x80) {
1583 "Direct3D renderer: The device doesn't support non-square "
1589 D3DDEVICEDESC halCaps = {0};
1590 halCaps.dwSize =
sizeof(halCaps);
1592 D3DDEVICEDESC refCaps = {0};
1593 refCaps.dwSize =
sizeof(refCaps);
1596 int v12 = halCaps.dwMinTextureWidth;
1597 if ((
unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight)
1598 v12 = halCaps.dwMinTextureHeight;
1600 int v13 = halCaps.dwMaxTextureWidth;
1601 if ((
unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight)
1602 v13 = halCaps.dwMaxTextureHeight;
1631 PixelFormat32bppRGB);
1641 unsigned int b = (
color & 0x1F) << 3;
1642 unsigned int g = ((
color >> 5) & 0x3F) << 2;
1643 unsigned int r = ((
color >> 11) & 0x1F) << 3;
1644 Gdiplus::Pen pen(Gdiplus::Color(
r,
g,
b));
1657 if ((1 << v2) & uRedMask) {
1679 DDSURFACEDESC2 *pDesc,
1680 unsigned int uLockFlags) {
1681 HRESULT
result = pSurface->Lock(NULL, pDesc, uLockFlags, NULL);
1688 if (
result == DDERR_SURFACELOST) {
1690 pSurface->Restore();
1696 DDERR_IMPLICITLYCREATED) {
1700 result = (bool)memset(pDesc, 0, 4);
1704 pSurface->Restore();
1706 result = pSurface->Lock(NULL, pDesc, DDLOCK_WAIT, NULL);
1707 if (
result == DDERR_INVALIDRECT ||
1709 DDERR_SURFACEBUSY) {
1714 result = (bool)memset(pDesc, 0, 4);
1719 result = (bool)memset(pDesc, 0, 4);
1728 if (
result == DDERR_INVALIDRECT ||
result == DDERR_SURFACEBUSY) {
1729 result = (bool)memset(pDesc, 0, 4);
1761 IDirectDrawSurface *pFront;
1762 IDirectDrawSurface *pBack;
1765 pFront->BltFast(NULL, NULL, pBack, (RECT *)pSrcRect, DDBLTFAST_WAIT);
1769 return render->uNumBillboardsToDraw;
1773 return render->pBillboardRenderListD3D[uBillboardID].sParentBillboardID;
1779 render->uNumBillboardsToDraw = 0;
1803 engine->draw_debug_outlines();
1816 bool clampAtTextureBorders) {
1825 if (uNumVertices < 3)
return;
1834 if (clampAtTextureBorders)
1841 if (transparent ||
config->is_using_specular) {
1843 D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
1846 D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
1848 D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
1855 D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
1857 D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
1873 if (
config->is_using_specular)
1884 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
1888 D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
1905 if (
config->is_using_specular)
1915 if (
config->is_using_specular)
1921 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
1924 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
1932 ErrD3D(
pRenderD3D->
pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
1933 if (!
config->is_using_specular) {
1936 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
1940 D3DBLEND_SRCCOLOR));
1943 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
1946 if (
config->is_using_specular) {
1958 D3DBLEND_INVSRCALPHA));
1960 D3DBLEND_SRCALPHA));
1963 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
1970 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, FALSE));
1972 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
1973 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
1974 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
1981 if (
engine->config->debug_terrain)
1993 int uPackedID,
unsigned int uColor,
int a8) {
1998 unsigned int sCorrectedColor = uColor;
2003 sCorrectedColor = 0xFFFFFFFF;
2010 if (
engine->CanSaturateFaces() && (pFace->
uAttributes & FACE_CAN_SATURATE_COLOR)) {
2012 float angle = (eightSeconds / 3000.0f) * 2 * 3.1415
f;
2014 int redstart = (sCorrectedColor & 0x00FF0000) >> 16;
2016 int col = (redstart - 64) - (64 * cosf(
angle));
2018 sCorrectedColor = (0xFF << 24) | (redstart << 16) | (col << 8) | col;
2023 uColor = sCorrectedColor = 0xFF20FF20;
2025 uColor = sCorrectedColor = 0xFF109010;
2030 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE,
false));
2031 ErrD3D(
pRenderD3D->
pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
2053 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
2081 0,
texture->GetDirect3DTexture()));
2084 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
2103 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
2104 ErrD3D(
pRenderD3D->
pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
2109 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
2112 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
2121 ErrD3D(
pRenderD3D->
pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
2124 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
2125 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO));
2126 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCCOLOR));
2130 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
2133 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
2134 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
2135 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
2190 if (pSoftBillboard->
uFlags & 4) {
2199 (
unsigned int)((
char *)&
array_77EC08[1852].pEdgeList1[17] + 3) &
2200 ((
unsigned int)v12 >> 1);
2214 v15 = 1.0 - 1.0 / (pSoftBillboard->
screen_space_z * 0.061758894);
2224 if (pSoftBillboard->
uFlags & 4) {
2240 if (pSoftBillboard->
uFlags & 4) {
2256 if (pSoftBillboard->
uFlags & 4) {
2278 float dstX,
float dstY,
float a7,
float a8,
2292 int absYDifference = abs(yDifference);
2293 int absXDifference = abs(xDifference);
2294 unsigned int smallerabsdiff = min(absXDifference, absYDifference);
2295 unsigned int largerabsdiff = max(absXDifference, absYDifference);
2296 int v32 = (11 * smallerabsdiff >> 5) + largerabsdiff;
2297 double v16 = 1.0 / (double)v32;
2298 double v17 = (double)yDifference * v16 * a4;
2299 double v18 = (double)xDifference * v16 * a4;
2304 v20 = a3 * 0.061758894;
2305 v25 = a7 * 0.061758894;
2308 v22 = (double)yDifference * v16 * a8;
2309 v23 = (double)xDifference * v16 * a8;
2310 v26 = 1.0 - 1.0 / v25;
2316 v29[0].
pos.
z = 1.0 - 1.0 / v20;
2366 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v29, 4,
2388 float depth = 1000000.0;
2403 for (
unsigned int i = 0; i < (
unsigned int)a1->
uNumVertices; ++i) {
2417 v10 *= 1000.f / 16192.f;
2427 if (diffuse & 0xFF000000) {
2457 if (
t->initialized) {
2458 IDirectDrawSurface* dds_get =
t->GetDirectDrawSurface();
2459 IDirect3DTexture2* d3dt_get =
t->GetDirect3DTexture();
2460 if (dds_get) dds_get->Release();
2461 if (d3dt_get) d3dt_get->Release();
2470 IDirectDrawSurface4 *dds;
2471 IDirect3DTexture2 *d3dt;
2477 "HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x",
2481 memset(&v19, 0,
sizeof(DDSCAPS2));
2482 v19.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
2484 DDSURFACEDESC2 desc;
2485 memset(&desc, 0,
sizeof(DDSURFACEDESC2));
2486 desc.dwSize =
sizeof(DDSURFACEDESC2);
2490 auto v14 = (
unsigned __int16 *)desc.lpSurface;
2491 for (
uint bMipMaps = 0; bMipMaps < desc.dwHeight; bMipMaps++) {
2492 for (
auto v15 = 0; v15 < desc.dwWidth; v15++) {
2497 v14 += (desc.lPitch >> 1) - desc.dwWidth;
2499 ErrD3D(dds->Unlock(NULL));
2502 t->SetDirect3DTexture2(d3dt);
2503 t->SetDirectDrawSurface((IDirectDrawSurface *)dds);
2515 unsigned int v3 = 0;
2523 int v40 = (char)floorf(
t * 255.0
f + 0.5
f);
2525 unsigned int v7 =
color | (v40 << 24);
2572 D3DBLEND_SRCALPHA));
2574 D3DBLEND_INVSRCALPHA));
2581 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v36, 4,
2725 p2DGraphics->SetClip(Gdiplus::Rect(uX, uY, uZ - uX, uW - uY));
2730 Gdiplus::Rect(0, 0,
window->GetWidth(),
window->GetHeight()));
2735 unsigned int b = (
c & 31) * 8;
2736 unsigned int g = ((
c >> 5) & 63) * 4;
2737 unsigned int r = ((
c >> 11) & 31) * 8;
2739 return (
b << 16) | (
g << 8) |
r;
2743 if (
image ==
nullptr) {
2747 Gdiplus::PixelFormat
format = 0;
2751 switch (
image->GetFormat()) {
2753 format = PixelFormat16bppRGB565;
2759 format = PixelFormat16bppARGB1555;
2765 format = PixelFormat32bppARGB;
2771 format = PixelFormat32bppRGB;
2781 if (
data ==
nullptr) {
2785 Gdiplus::Bitmap *
bitmap =
new Gdiplus::Bitmap(
2787 if (
bitmap->GetLastStatus() != Gdiplus::Ok) {
2796 int custom_height) {
2806 Gdiplus::UnitPixel);
2823 image->GetWidth() - offset_x,
2824 image->GetHeight() - offset_y, Gdiplus::UnitPixel);
2835 Gdiplus::Rect
r(rect.
x, rect.
y, rect.
z - rect.
x, rect.
w - rect.
y);
2846 unsigned int uHeight,
unsigned int color) {
2847 unsigned int b = (
color & 0x1F) << 3;
2848 unsigned int g = ((
color >> 5) & 0x3F) << 2;
2849 unsigned int r = ((
color >> 11) & 0x1F) << 3;
2851 Gdiplus::Color
c(
r,
g,
b);
2852 Gdiplus::SolidBrush brush(
c);
2853 p2DGraphics->FillRectangle(&brush, (INT)uX, (INT)uY, (INT)uWidth,
2858 unsigned int uCharWidth,
unsigned int uCharHeight,
2864 for (
uint y = 0;
y < uCharHeight; ++
y) {
2865 for (
uint x = 0;
x < uCharWidth; ++
x) {
2868 if (*pFontPixels != 1) {
2876 render->DrawTextureAlphaNew(uOutX / 640., uOutY / 480., fonttemp);
2881 unsigned int uFontHeight,
uint8_t *pPalette,
2882 bool present_time_transparency) {
2886 if (present_time_transparency) {
2887 for (
unsigned int dy = 0; dy < uFontHeight; ++dy) {
2888 for (
unsigned int dx = 0; dx < uCharWidth; ++dx) {
2890 ? pPalette[*font_pixels]
2899 for (
unsigned int dy = 0; dy < uFontHeight; ++dy) {
2900 for (
unsigned int dx = 0; dx < uCharWidth; ++dx) {
2906 fontpix[dx + dy * uCharWidth] =
Color32(
r,
g,
b);
2912 render->DrawTextureAlphaNew(
x / 640.,
y / 480., fonttemp);
2934 for (
unsigned int dy = 0; dy < pTexture->
GetHeight(); ++dy) {
2935 for (
unsigned int dx = 0; dx <
width; ++dx) {
2936 if (*
pixels & 0xFF000000)
2937 temppix[dx + dy *
width] =
Color32((((*
pixels >> 16) & 0xFF) >> color_dimming_level),
2938 (((*
pixels >> 8) & 0xFF) >> color_dimming_level), ((*
pixels & 0xFF) >> color_dimming_level))
2943 render->DrawTextureAlphaNew(u,
v, temp);
2964 int bright = (*(pixelpoint + nudge) & 0xFF) + ((*(pixelpoint + nudge) >> 8) & 0xFF) + ((*(pixelpoint + nudge) >> 16) & 0xFF);
2965 if (bright == 0)
continue;
2967 if (bright > brightval) {
2971 if (bright < darkval) {
2979 unsigned int bmax = (*(pixelpoint + brightloc) & 0xFF);
2980 unsigned int gmax = ((*(pixelpoint + brightloc) >> 8) & 0xFF);
2981 unsigned int rmax = ((*(pixelpoint + brightloc) >> 16) & 0xFF);
2984 unsigned int bmin = (*(pixelpoint + darkloc) & 0xFF);
2985 unsigned int gmin = ((*(pixelpoint + darkloc) >> 8) & 0xFF);
2986 unsigned int rmin = ((*(pixelpoint + darkloc) >> 16) & 0xFF);
2989 float bstep = (bmax - bmin) / 128.;
2990 float gstep = (gmax - gmin) / 128.;
2991 float rstep = (rmax - rmin) / 128.;
2993 int timestep = time % 256;
2996 for (
int ydraw = 0; ydraw <
height; ++ydraw) {
2997 for (
int xdraw = 0; xdraw <
width; ++xdraw) {
2999 unsigned int bcur = (*(pixelpoint) & 0xFF);
3000 unsigned int gcur = ((*(pixelpoint) >> 8) & 0xFF);
3001 unsigned int rcur = ((*(pixelpoint) >> 16) & 0xFF);
3002 int pixstepb = (bcur - bmin) / bstep + timestep;
3003 if (pixstepb > 255) pixstepb = pixstepb - 256;
3004 if (pixstepb >= 0 && pixstepb < 128)
3005 bcur = bmin + pixstepb * bstep;
3006 if (pixstepb >= 128 && pixstepb < 256) {
3007 pixstepb = pixstepb - 128;
3008 bcur = bmax - pixstepb * bstep;
3010 int pixstepr = (rcur - rmin) / rstep + timestep;
3011 if (pixstepr > 255) pixstepr = pixstepr - 256;
3012 if (pixstepr >= 0 && pixstepr < 128)
3013 rcur = rmin + pixstepr * rstep;
3014 if (pixstepr >= 128 && pixstepr < 256) {
3015 pixstepr = pixstepr - 128;
3016 rcur = rmax - pixstepr * rstep;
3018 int pixstepg = (gcur - gmin) / gstep + timestep;
3019 if (pixstepg > 255) pixstepg = pixstepg - 256;
3020 if (pixstepg >= 0 && pixstepg < 128)
3021 gcur = gmin + pixstepg * gstep;
3022 if (pixstepg >= 128 && pixstepg < 256) {
3023 pixstepg = pixstepg - 128;
3024 gcur = gmax - pixstepg * gstep;
3027 temppix[xdraw + ydraw *
width] =
Color32(rcur, gcur, bcur);
3033 render->DrawTextureAlphaNew(u,
v, temp);
3039 int x,
int y,
Image *imgin,
Image *imgblend,
int time,
int start_opacity,
3049 if (imgin && imgblend) {
3060 unsigned int bmax = (
c & 0xFF);
3061 unsigned int gmax = ((
c >> 8) & 0xFF);
3062 unsigned int rmax = ((
c >> 16) & 0xFF);
3064 unsigned int bmin = bmax / 10;
3065 unsigned int gmin = gmax / 10;
3066 unsigned int rmin = rmax / 10;
3068 unsigned int bstep = (bmax - bmin) / 128;
3069 unsigned int gstep = (gmax - gmin) / 128;
3070 unsigned int rstep = (rmax - rmin) / 128;
3072 for (
int ydraw = 0; ydraw < Height; ++ydraw) {
3073 for (
int xdraw = 0; xdraw < Width; ++xdraw) {
3081 uint32_t pixcol = *(pixelpointblend + nudge);
3083 unsigned int bcur = (pixcol & 0xFF);
3084 unsigned int gcur = ((pixcol >> 8) & 0xFF);
3085 unsigned int rcur = ((pixcol >> 16) & 0xFF);
3087 int steps = (time) % 128;
3089 if ((time) % 256 >= 128) {
3090 bcur += bstep * (128 - steps);
3091 gcur += gstep * (128 - steps);
3092 rcur += rstep * (128 - steps);
3094 bcur += bstep * steps;
3095 gcur += gstep * steps;
3096 rcur += rstep * steps;
3099 if (bcur > bmax) bcur = bmax;
3100 if (gcur > gmax) gcur = gmax;
3101 if (rcur > rmax) rcur = rmax;
3102 if (bcur < bmin) bcur = bmin;
3103 if (gcur < gmin) gcur = gmin;
3104 if (rcur < rmin) rcur = rmin;
3106 temppix[xdraw + ydraw * Width] =
Color32(rcur, gcur, bcur);
3112 pixelpoint += imgin->
GetWidth() - Width;
3115 render->DrawTextureAlphaNew(
x/640.,
y/480., temp);
3130 Clipped_X = rc.
x - dst_x;
3135 Clipped_Y = rc.
y - dst_y;
3151 int num_top_scanlines_above_frame_y = Clipped_Y - dst_y;
3153 for (
uint y = dst_y;
y < dst_w; ++
y) {
3154 uint src_y = num_top_scanlines_above_frame_y +
y;
3156 for (
uint x = dst_x;
x < dst_z; ++
x) {
3157 uint src_x = Clipped_X - dst_x +
x;
3166 temppix[(
x-dst_x) + 128*(
y-dst_y)] = (
b |
a);
3170 render->SetUIClipRect(rc.
x, rc.
y, rc.
z, rc.
w);
3171 render->DrawTextureAlphaNew(dst_x / 640., dst_y / 480., temp);
3173 render->ResetUIClipRect();
3182 int uX = u * 640.0f;
3183 int uY =
v * 480.0f;
3192 int uOutX = u * this->
window->GetWidth();
3193 int uOutY =
v * this->
window->GetHeight();
3194 unsigned int imgheight =
img->GetHeight();
3195 unsigned int imgwidth =
img->GetWidth();
3198 for (
int xs = 0; xs < imgwidth; xs++) {
3199 for (
int ys = 0; ys < imgheight; ys++) {
3200 if (
pixels[xs + imgwidth * ys] & 0xFF000000) {
3211 ErrD3D(
pRenderD3D->
pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
3212 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
3213 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
3214 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
3224 ->GetDirect3DTexture());
3234 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
3237 D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS));
3240 if (
config->is_using_fog) {
3245 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
3247 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
3248 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
3249 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
3256 if (
config->is_using_fog) {
3263 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA));
3264 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA));
3273 if (
config->is_using_specular) {
3274 if (!
config->is_using_fog) {
3280 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
3281 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
3282 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
3289 L
"SetBillboardBlendOptions: invalid opacity type (%u)", a1);
3298 bool current_vertices_flag;
3299 bool next_vertices_flag;
3301 bool bFound =
false;
3303 if (!num_vertices)
return 0;
3304 for (
uint i = 0; i < num_vertices; ++i) {
3310 if (!bFound)
return 0;
3314 next_vertices_flag =
false;
3315 current_vertices_flag =
false;
3317 current_vertices_flag =
true;
3329 int out_num_vertices = 0;
3330 for (
uint i = 0; i < num_vertices; ++i) {
3331 next_vertices_flag =
3333 if (current_vertices_flag ^ next_vertices_flag) {
3334 if (next_vertices_flag) {
3384 if (!next_vertices_flag) {
3389 current_vertices_flag = next_vertices_flag;
3391 return out_num_vertices >= 3 ? out_num_vertices : 0;
3395 bool current_vertices_flag;
3396 bool next_vertices_flag;
3398 signed int depth_num_vertices;
3406 depth_num_vertices = 0;
3407 current_vertices_flag =
false;
3410 current_vertices_flag =
3420 if (!bFound)
return 0;
3435 if (current_vertices_flag ^
3436 next_vertices_flag) {
3437 if (next_vertices_flag) {
3498 ++depth_num_vertices;
3500 if (!next_vertices_flag) {
3503 depth_num_vertices++;
3505 current_vertices_flag = next_vertices_flag;
3507 return depth_num_vertices >= 3 ? depth_num_vertices : 0;
3524 if (model.
pFaces.empty()) {
3529 if (
face.Invisible()) {
3538 poly->texture =
face.GetTexture();
3540 if (
face.uAttributes & FACE_FLUID) poly->flags |= 2;
3541 if (
face.uAttributes & FACE_INDOOR_SKY) poly->flags |= 0x400;
3543 if (
face.uAttributes & FACE_FLOW_DIAGONAL)
3544 poly->flags |= 0x400;
3545 else if (
face.uAttributes & FACE_FLOW_VERTICAL)
3546 poly->flags |= 0x800;
3548 if (
face.uAttributes & FACE_FLOW_HORIZONTAL)
3549 poly->flags |= 0x2000;
3550 else if (
face.uAttributes & FACE_DONT_CACHE_TEXTURE)
3551 poly->flags |= 0x1000;
3553 poly->sTextureDeltaU =
face.sTextureDeltaU;
3554 poly->sTextureDeltaV =
face.sTextureDeltaV;
3556 unsigned int flow_anim_timer =
OS_GetTime() >> 4;
3557 unsigned int flow_u_mod = poly->texture->GetWidth() - 1;
3558 unsigned int flow_v_mod = poly->texture->GetHeight() - 1;
3560 if (
face.pFacePlane.vNormal.z &&
3561 abs(
face.pFacePlane.vNormal.z) >= 59082) {
3562 if (poly->flags & 0x400)
3563 poly->sTextureDeltaV += flow_anim_timer & flow_v_mod;
3564 if (poly->flags & 0x800)
3565 poly->sTextureDeltaV -= flow_anim_timer & flow_v_mod;
3567 if (poly->flags & 0x400)
3568 poly->sTextureDeltaV -= flow_anim_timer & flow_v_mod;
3569 if (poly->flags & 0x800)
3570 poly->sTextureDeltaV += flow_anim_timer & flow_v_mod;
3573 if (poly->flags & 0x1000)
3574 poly->sTextureDeltaU -= flow_anim_timer & flow_u_mod;
3575 else if (poly->flags & 0x2000)
3576 poly->sTextureDeltaU += flow_anim_timer & flow_u_mod;
3581 for (
uint vertex_id = 1; vertex_id <=
face.uNumVertices;
3590 (poly->sTextureDeltaU +
3591 (__int16)
face.pTextureUIDs[vertex_id - 1]) *
3592 (1.0 / (double)poly->texture->GetWidth());
3594 (poly->sTextureDeltaV +
3595 (__int16)
face.pTextureVIDs[vertex_id - 1]) *
3596 (1.0 / (double)poly->texture->GetHeight());
3598 for (
uint i = 1; i <=
face.uNumVertices; i++) {
3617 if (v53 ==
face.uNumVertices) poly->field_32 |= 1;
3618 poly->pODMFace = &
face;
3619 poly->uNumVertices =
face.uNumVertices;
3627 poly->dimming_level = 20 -
fixpoint_mul(20, v51 + v53 + v52);
3628 if (poly->dimming_level < 0) poly->dimming_level = 0;
3629 if (poly->dimming_level > 31) poly->dimming_level = 31;
3633 poly->uBModelFaceID =
face.index;
3634 poly->uBModelID = model.
index;
3637 for (
int vertex_id = 0; vertex_id <
face.uNumVertices;
3646 static stru154 static_RenderBuildingsD3D_stru_73C834;
3653 v31 = nearclip ? 3 : farclip != 0 ? 5 : 0;
3660 31 - poly->dimming_level, 2,
3661 &static_RenderBuildingsD3D_stru_73C834,
3669 &
Lights, &static_RenderBuildingsD3D_stru_73C834,
3681 if (poly->uNumVertices) {
3682 if (poly->IsWater()) {
3683 if (poly->IsWaterAnimDisabled())
3684 poly->texture =
render->hd_water_tile_anim[0];
3687 render->hd_water_tile_anim
3688 [
render->hd_water_current_frame];
3691 render->DrawPolygon(poly);
3708 for_pixels = pPixels;
3718 memset(&Dst, 0,
sizeof(Dst));
3719 Dst.dwSize =
sizeof(Dst);
3723 memset(&for_pixels, 0,
sizeof(for_pixels));
3727 if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) {
3728 unsigned __int32 *
p =
3729 (
unsigned __int32 *)Dst.lpSurface +
3730 (
int)(
x * interval_x + 8.0) +
3731 (int)(
y * interval_y + 8.0) * (Dst.lPitch >> 2);
3732 *for_pixels =
Color16((*
p >> 16) & 255, (*
p >> 8) & 255,
3734 }
else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) {
3737 (
int)(
x * interval_x + 8.0) +
y * Dst.lPitch;
3765 unsigned int data_size,
3766 unsigned int *out_screenshot_size) {
3785 for (a1a = 0; (
signed int)a1a < (
signed int)v12; ++a1a) {
3797 (
double)pDepth, a1a)) {
3798 if (mon_num < 100) {
3812 ErrD3D(
pRenderD3D->
pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
3814 if (
config->is_using_specular)
3817 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
3818 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
3824 0, ((
TextureD3D *)effpar03)->GetDirect3DTexture()));
3833 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
3834 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
3835 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
3838 if (
config->is_using_specular) {
3846 if (
config->is_using_specular)
3849 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
3850 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
3851 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
3852 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
3858 0, ((
TextureD3D *)effpar03)->GetDirect3DTexture()));
3860 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
3861 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
3865 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
3866 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
3867 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
3870 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
3872 if (
config->is_using_specular)
3877 signed int sDiffuseBegin,
3879 signed int sDiffuseEnd,
float z_stuff) {
3882 memcpy(&vertices[0], pLineBegin,
sizeof(vertices[0]));
3883 memcpy(&vertices[1], pLineEnd,
sizeof(vertices[1]));
3885 vertices[0].
pos.
z = 0.001 - z_stuff;
3886 vertices[1].
pos.
z = 0.001 - z_stuff;
3888 vertices[0].
diffuse = sDiffuseBegin;
3889 vertices[1].
diffuse = sDiffuseEnd;
3897 unsigned int num_vertices) {
3901 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
3902 (
void *)vertices, num_vertices, D3DDP_DONOTLIGHT));
3906 unsigned int num_vertices) {
3914 D3DBLEND_SRCALPHA));
3916 D3DBLEND_INVSRCALPHA));
3921 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
3922 (
void *)vertices, num_vertices, 28));
3938 if (
config->is_using_specular)
3940 ErrD3D(
pRenderD3D->
pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
3942 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
3943 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
3944 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
3945 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
3946 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
3947 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
3957 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
3960 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
3961 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
3962 ErrD3D(
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
3964 if (
config->is_using_specular)
3990 uint uTintR = (uTint >> 16) & 0xFF, uTintG = (uTint >> 8) & 0xFF,
3991 uTintB = uTint & 0xFF;
3998 floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0
f),
4000 floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0
f),
4002 floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0
f);
4009 if (fabs(z_bias) < 1e-5) {
4018 if (v15 < 0.000099999997) v15 = 0.000099999997;
4023 pVerticesD3D[i].
pos.
z = v15;
4026 pVerticesD3D[i].
diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB;
4034 dwFlags = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS;
4036 dwFlags = D3DDP_DONOTLIGHT;
4040 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
4065 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
4066 (
void *)vertices, 4, 28));
4089 unsigned __int16 v10 = 0;
4095 v6 = (
unsigned __int16)a4 >> 2;
4097 a3a = (
unsigned __int16)a3 >> 2;
4098 HEXRAYS_LOWORD(v7) = a3a;
4100 HEXRAYS_LOWORD(v4) = ((
unsigned __int16)a4 >> 2) & 0xE0;
4101 HEXRAYS_LOWORD(v7) = a3a & 0xE0;
4102 HEXRAYS_LOWORD(v9) = v9 & 0x1C00;
4104 HEXRAYS_LOWORD(v7) = v5 & 0xE0;
4106 HEXRAYS_LOWORD(v7) = v8 & 0xE0;
4108 return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) |
4110 ((v8 & 0x1C00) + (v5 & 0x1C00) + v9 +
4111 (
__PAIR__(v10, (
unsigned __int16)a4 >> 2) & 0x1C00));
4129 return 8 * (31 - max_dimm) | ((8 * (31 - max_dimm) | ((31 - max_dimm) << 11)) << 8);
4134 if (
engine->IsUnderwater())
4140 v9 = (
double)v20 * 1024.0;
4150 v6 = floorf(0.5
f +
distance * 216.0 / v9);
4162 if (v6 > 216) v6 = 216;
4163 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
4170 if (fabsf(
distance) < 1.0e-6
f)
return 0xFFF8F8F8;
4173 v11 = 8 * (max_dimm - min_dimm);
4176 if (v11 > 216) v11 = 216;
4181 float fog_density_mult = 216.0f;
4189 if (v6 > 216) v6 = 216;
4190 if (v6 < v11) v6 = v11;
4193 if (!
engine->IsUnderwater()) {
4194 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
4196 v15 = (double)(255 - v6) * 0.0039215689;
4200 a5a = floorf(v15 * 16.0 + 0.5
f);
4203 v18 = floorf(a3c * 194.0 + 0.5
f);
4206 return (
int)floorf(a3c * 153.0 + 0.5
f) |
4207 ((v18 | (a5a << 8)) << 8);
4212 int uBaseLightLevel) {
4218 if (uBaseLightLevel == -1) {
4221 v3 = uBaseLightLevel;
4230 unsigned int uBaseLightLevel,
int uSectorID,
float x,
float y,
float z) {
4250 v6 = uBaseLightLevel;
4254 float distX = abs(
p->vPosition.x -
x);
4255 if (distX <= p->uRadius) {
4256 float distY = abs(
p->vPosition.y -
y);
4257 if (distY <= p->uRadius) {
4258 float distZ = abs(
p->vPosition.z -
z);
4259 if (distZ <= p->uRadius) {
4263 if (distX < distY) {
4272 if (v9 < (
signed int)v10) {
4277 v43 = ((
unsigned int)(11 * v9) / 32) + (v10 / 4) + v8;
4279 if ((
signed int)v43 < v13)
4280 v6 += ((
unsigned __int64)(30i64 *
4281 (
signed int)(v43 << 16) /
4297 if (v17 <= v16->uRadius) {
4299 if (v42 <= v16->uRadius) {
4301 if (v39 <= v16->uRadius) {
4304 if ((
signed int)v44 < v24)
4305 v6 += ((
unsigned __int64)(30i64 *
4321 if (v26 <= pStationaryLightsStack->pLights[i].uRadius) {
4323 if (v40 <= pStationaryLightsStack->pLights[i].uRadius) {
4325 if (v37 <= pStationaryLightsStack->pLights[i].uRadius) {
4328 if ((
signed int)v45 <
4330 v6 += ((
unsigned __int64)(30i64 *
4331 (
signed int)(v45 << 16) /
4354 __int16 pNextSector;
4375 int pSectorsArray[10];
4400 pSectorsArray[pArrayNum] = pNextSector;
4401 if (!(v6 ^ v7))
break;
4405 for (v29 = 0; v29 < i; v29++) {
4408 for (v26 = 0; v26 < v32; v26++) {
4409 pFloor = pSector->
pFloors[v26];
4457 v18 = 8 * pSector->
pFloors[v26];
4504 v24 = 8 * pSector->
pFloors[v26];
4547 face.pFacePlane_old.dist =
4564 face.pXInterceptDisplacements =
4566 face.pYInterceptDisplacements =
4568 face.pZInterceptDisplacements =
4580 if (!
face.Ethereal() && !
face.Portal()) {
4581 v8 = (
face.pFacePlane_old.dist +
4582 face.pFacePlane_old.vNormal.x *
4584 face.pFacePlane_old.vNormal.y *
4586 face.pFacePlane_old.vNormal.z *
4590 v9 = (
face.pFacePlane_old.dist +
4591 face.pFacePlane_old.vNormal.x *
4593 face.pFacePlane_old.vNormal.y *
4595 face.pFacePlane_old.vNormal.z *
4637 v15 = (
face.pFacePlane_old.dist +
4638 face.pFacePlane_old.vNormal.x *
4640 face.pFacePlane_old.vNormal.y *
4642 face.pFacePlane_old.vNormal.z *
4646 v16 = (
face.pFacePlane_old.dist +
4647 face.pFacePlane_old.vNormal.x *
4649 face.pFacePlane_old.vNormal.y *
4651 face.pFacePlane_old.vNormal.z *
4666 model.
index, ecx0)) {
4672 (model.
index << 6)));
4696 (model.
index << 6)));
4712 unsigned int *pFaceID) {
4716 if (floor_level != -30000 && floor_level <=
z + 50) {
4722 *pSectorID = uSectorID;
4725 if (uSectorID && floor_level != -30000)
4770 (
signed __int64)v10) >>
4774 if (v11 <= object->uHeight +
4878 if (v11 <= decor_desc->uDecorationHeight + decor->
vPosition.z) {
4880 if (v12 < 0) v12 = 0;
4899 unsigned int v1 = 0xFFFFFF;
4900 unsigned int v10 = 0xFFFFFF;
4912 face->pFacePlane_old.dist +
4916 face->pFacePlane_old.dist +
4947 unsigned int sub_46DEF2(
signed int a2,
unsigned int uLayingItemID) {
4948 unsigned int result = uLayingItemID;
4979 v7 =
object->uLifetime;
4994 v11 =
object->uLifetime;
5027 bool sub_47531C(
int a1,
int *a2,
int pos_x,
int pos_y,
int pos_z,
int dir_x,
5042 if (a10 &&
face->Ethereal())
return 0;
5046 v12 = v11 + a9b + a10b;
5047 a9a = v11 + a9b + a10b;
5048 v13 = (a1 << 16) - pos_x *
face->pFacePlane_old.vNormal.x -
5049 pos_y *
face->pFacePlane_old.vNormal.y -
5050 pos_z *
face->pFacePlane_old.vNormal.z -
face->pFacePlane_old.dist;
5051 if (abs((a1 << 16) - pos_x *
face->pFacePlane_old.vNormal.x -
5052 pos_y *
face->pFacePlane_old.vNormal.y -
5053 pos_z *
face->pFacePlane_old.vNormal.z -
5054 face->pFacePlane_old.dist) >= a1 << 16) {
5055 a10c = abs(v13) >> 14;
5056 if (a10c > abs(v12))
return 0;
5057 HEXRAYS_LODWORD(v15) = v13 << 16;
5058 HEXRAYS_HIDWORD(v15) = v13 >> 16;
5063 v14 = abs(v13) >> 16;
5066 HEXRAYS_LOWORD(a7a) = (short)pos_x +
5069 HEXRAYS_HIWORD(a7a) = pos_y +
5078 if (a10a >> 16 < 0) *a2 = 0;
5082 bool sub_4754BF(
int a1,
int *a2,
int X,
int Y,
int Z,
int dir_x,
int dir_y,
5097 if (a11 &&
face->Ethereal())
return false;
5101 v13 = v12 + a1b + a11b;
5102 a1a = v12 + a1b + a11b;
5103 v14 = (a1 << 16) - X *
face->pFacePlane_old.vNormal.x -
5104 Y *
face->pFacePlane_old.vNormal.y -
5105 Z *
face->pFacePlane_old.vNormal.z -
face->pFacePlane_old.dist;
5106 if (abs((a1 << 16) - X *
face->pFacePlane_old.vNormal.x -
5107 Y *
face->pFacePlane_old.vNormal.y -
5108 Z *
face->pFacePlane_old.vNormal.z -
face->pFacePlane_old.dist) >=
5110 a11c = abs(v14) >> 14;
5111 if (a11c > abs(v13))
return false;
5112 HEXRAYS_LODWORD(v16) = v14 << 16;
5113 HEXRAYS_HIDWORD(v16) = v14 >> 16;
5118 v15 = abs(v14) >> 16;
5121 HEXRAYS_LOWORD(a7a) = (short)X +
5124 HEXRAYS_HIWORD(a7a) = Y + ((
unsigned int)
fixpoint_mul(a11a, dir_y) >> 16) -
5127 (
short)Z + ((
unsigned int)
fixpoint_mul(a11a, dir_z) >> 16) -
5131 if (a11a >> 16 < 0) *a2 = 0;
5150 if (
face->uAttributes & FACE_XY_PLANE) {
5151 v26 = (
signed __int16)a2;
5152 v27 = HEXRAYS_SHIWORD(a2);
5153 if (
face->uNumVertices) {
5154 for (v28 = 0; v28 <
face->uNumVertices; v28++) {
5156 face->pXInterceptDisplacements[v28] +
5159 face->pYInterceptDisplacements[v28] +
5162 face->pXInterceptDisplacements[v28 + 1] +
5165 face->pYInterceptDisplacements[v28 + 1] +
5170 if (
face->uAttributes & FACE_XZ_PLANE) {
5171 v26 = (
signed __int16)a2;
5173 if (
face->uNumVertices) {
5174 for (v29 = 0; v29 <
face->uNumVertices; v29++) {
5176 face->pXInterceptDisplacements[v29] +
5179 face->pZInterceptDisplacements[v29] +
5182 face->pXInterceptDisplacements[v29 + 1] +
5185 face->pZInterceptDisplacements[v29 + 1] +
5190 v26 = HEXRAYS_SHIWORD(a2);
5192 if (
face->uNumVertices) {
5193 for (v30 = 0; v30 <
face->uNumVertices; v30++) {
5195 face->pYInterceptDisplacements[v30] +
5198 face->pZInterceptDisplacements[v30] +
5201 face->pYInterceptDisplacements[v30 + 1] +
5204 face->pZInterceptDisplacements[v30 + 1] +
5216 if (2 *
face->uNumVertices <= 0)
return 0;
5217 for (v25 = 0; v25 < 2 *
face->uNumVertices; ++v25) {
5218 if (v31 >= 2)
break;
5228 HEXRAYS_LODWORD(v23) = v22 << 16;
5229 HEXRAYS_HIDWORD(v23) = v22 >> 16;
5232 ((
signed int)(((
unsigned __int64)(v23 /
5252 if (v31 != 1)
result = 0;
5269 if (
face->uAttributes & FACE_XY_PLANE) {
5270 v23 = (
signed __int16)a3;
5271 v24 = HEXRAYS_SHIWORD(a3);
5272 if (
face->uNumVertices) {
5273 for (v22 = 0; v22 <
face->uNumVertices; ++v22) {
5275 face->pXInterceptDisplacements[v22] +
5277 .pVertices.pVertices[
face->pVertexIDs[v22]]
5280 face->pYInterceptDisplacements[v22] +
5282 .pVertices.pVertices[
face->pVertexIDs[v22]]
5285 face->pXInterceptDisplacements[v22 + 1] +
5287 .pVertices.pVertices[
face->pVertexIDs[v22 + 1]]
5290 face->pYInterceptDisplacements[v22 + 1] +
5292 .pVertices.pVertices[
face->pVertexIDs[v22 + 1]]
5297 if (
face->uAttributes & FACE_XZ_PLANE) {
5298 v23 = (
signed __int16)a3;
5300 if (
face->uNumVertices) {
5301 for (v22 = 0; v22 <
face->uNumVertices; ++v22) {
5303 face->pXInterceptDisplacements[v22] +
5305 .pVertices.pVertices[
face->pVertexIDs[v22]]
5308 face->pZInterceptDisplacements[v22] +
5310 .pVertices.pVertices[
face->pVertexIDs[v22]]
5313 face->pXInterceptDisplacements[v22 + 1] +
5316 .pVertices.pVertices[
face->pVertexIDs[v22 + 1]]
5319 face->pZInterceptDisplacements[v22 + 1] +
5322 .pVertices.pVertices[
face->pVertexIDs[v22 + 1]]
5327 v23 = HEXRAYS_SHIWORD(a3);
5329 if (
face->uNumVertices) {
5330 for (v22 = 0; v22 <
face->uNumVertices; ++v22) {
5332 face->pYInterceptDisplacements[v22] +
5334 .pVertices.pVertices[
face->pVertexIDs[v22]]
5337 face->pZInterceptDisplacements[v22] +
5339 .pVertices.pVertices[
face->pVertexIDs[v22]]
5342 face->pYInterceptDisplacements[v22 + 1] +
5345 .pVertices.pVertices[
face->pVertexIDs[v22 + 1]]
5348 face->pZInterceptDisplacements[v22 + 1] +
5351 .pVertices.pVertices[
face->pVertexIDs[v22 + 1]]
5363 if (2 *
face->uNumVertices <= 0)
return 0;
5364 for (v21 = 0; v21 < 2 *
face->uNumVertices; ++v21) {
5365 if (a4d >= 2)
break;
5375 HEXRAYS_LODWORD(v19) = v18 << 16;
5376 HEXRAYS_HIDWORD(v19) = v18 >> 16;
5379 ((
signed int)(((
unsigned __int64)(v19 /
5399 if (a4d != 1)
result = 0;
5440 if (v9 < 0)
return 0;
5447 HEXRAYS_LODWORD(v10) = v9 << 16;
5448 HEXRAYS_HIDWORD(v10) = v9 >> 16;
5451 HEXRAYS_LOWORD(v12) =
5452 HEXRAYS_LOWORD(v14->x) +
5453 (((
unsigned int)
fixpoint_mul(v17, v15->x) + 0x8000) >> 16);
5454 HEXRAYS_HIWORD(v12) =
5455 HEXRAYS_LOWORD(v11->y) +
5456 (((
unsigned int)
fixpoint_mul(v17, v15->y) + 0x8000) >> 16);
5457 if (a4c > abs(v7) || (v17 > *a3 << 16) ||
5461 (((
unsigned int)
fixpoint_mul(v17, v15->z) + 0x8000) >> 16)))
5472 int v13 = v10 + v12 + v11;
5473 int v14 = v10 + v12 + v11;
5474 int v22 = v10 + v12 + v11;
5498 HEXRAYS_LODWORD(v18) = v16 << 16;
5499 HEXRAYS_HIDWORD(v18) = v16 >> 16;
5500 int v24 = v18 / v22;
5501 int v23 = v18 / v22;
5503 HEXRAYS_LOWORD(v19) =
5504 a3 + (((
unsigned int)
fixpoint_mul(v23, a6) + 0x8000) >> 16);
5505 HEXRAYS_HIWORD(v19) =
5506 a4 + (((
unsigned int)
fixpoint_mul(v23, a7) + 0x8000) >> 16);
5507 if (v17 > abs(v14) || v23 > *a1 << 16 ||
5510 a5 + (((
unsigned int)
fixpoint_mul(v23, a8) + 0x8000) >> 16)))
5536 if (v9 < model->sBoundingRadius + 256) *reachable =
true;
5544 if (v9 <= pIndoorCameraD3D->GetFarClip() + 2048) {
5549 HEXRAYS_LOBYTE(
result) = v12 >= 0;
5595 if (
v->y > 1000)
v->y = 0;
5599 float len = sqrt((
double)this->
v_18.z * (
double)this->v_18.z +
5600 (
double)this->v_18.y * (
double)this->v_18.y +
5601 (
double)this->v_18.x * (
double)this->v_18.x);
5602 if (fabsf(
len) < 1e-6
f) {
5625 double rot_to_rads = ((2 * pi_double) / 2048);
5628 int horizon_height_offset =
5639 (cam_vec_up + 0.0000001) *
5646 pSkyPolygon.
texture =
nullptr;
5664 pSkyPolygon.
v_18.x =
5666 pSkyPolygon.
v_18.y = 0;
5667 pSkyPolygon.
v_18.z =
5703 int widthperpixel = 65536 /
5705 / tan(half_fov_angle_rads) +
5724 widthperpixel * (horizon_height_offset - floor(
VertexRenderList[i].vWorldViewProjY + 0.5)));
5731 widthperpixel * (horizon_height_offset - floor(
VertexRenderList[i].vWorldViewProjY + 0.
f)));
5739 widthperpixel * (horizon_height_offset - floor(
VertexRenderList[i].vWorldViewProjY + 0.5)));
5744 int top_y_proj = pSkyPolygon.
v_18.x + v9;
5745 if (top_y_proj > 0) top_y_proj = 0;
5748 v14 = widthperpixel * (horizon_height_offset - v32);
5752 v15 = abs(top_y_proj);
5755 if (top_y_proj <= 0)
break;
5760 v14 += widthperpixel;
5761 top_y_proj = pSkyPolygon.
v_18.x + v16;
5764 signed int worldviewdepth = (__int64(-512) * 65536 * 65536) / top_y_proj;
5768 ((
signed int)
fixpoint_mul(skyfinalleft, worldviewdepth) >> 3);
5773 ((
signed int)
fixpoint_mul(finalskyfront, worldviewdepth) >> 3);
5864 ((cos(v5) * 16192.0 + 0.0000001) * 65535.0) *
5865 (sin(v5) * -16192.0 -
5871 pSkyPolygon.
texture =
nullptr;
5879 if (!pSkyPolygon.
texture)
return;
5885 pSkyPolygon.
v_18.y = 0;
5892 extern float _calc_fov(
int viewport_width,
int angle_degree);
5909 int _507D30_idx = 0;
5910 for (_507D30_idx; _507D30_idx < pSkyPolygon.
uNumVertices; _507D30_idx++) {
5931 X = (int)((
char *)v79 + pSkyPolygon.
v_18.x);
5932 HEXRAYS_LODWORD(v76) = (
signed __int64)v18;
5933 v20 = (
void *)(v72 * (v70 - HEXRAYS_LODWORD(v76)));
5936 if (!X)
goto LABEL_14;
5937 v21 = abs(v19 >> 14);
5947 --HEXRAYS_LODWORD(v76);
5948 v20 = (
char *)v20 + v72;
5949 X = v22 + pSkyPolygon.
v_18.x;
5953 HEXRAYS_LODWORD(v23) = v77 << 16;
5954 HEXRAYS_HIDWORD(v23) = v77 >> 16;
5955 v79 = (
void *)(v23 / X);
5959 HEXRAYS_LODWORD(v80) =
5961 ((
signed int)
fixpoint_mul(HEXRAYS_SLODWORD(
s), v23 / X) >> 4);
5963 ((double)HEXRAYS_SLODWORD(v80) * 0.000015259022) *
5968 HEXRAYS_LODWORD(v80) =
5970 ((
signed int)
fixpoint_mul(HEXRAYS_SLODWORD(s2), v23 / X) >> 4);
5972 ((double)HEXRAYS_SLODWORD(v80) * 0.000015259022) * v68;
5975 HEXRAYS_LODWORD(v73) =
fixpoint_mul(HEXRAYS_SLODWORD(s2), v23 / X);
5994 HEXRAYS_LODWORD(v73) = 0;
5997 v28 = (double)HEXRAYS_SLODWORD(v76);
6001 ++HEXRAYS_LODWORD(v73);
6003 HEXRAYS_LODWORD(v76) += 48;
6027 ++HEXRAYS_LODWORD(v73);
6028 *(
unsigned int *)HEXRAYS_LODWORD(v76) = v28;
6029 HEXRAYS_LODWORD(v76) += 48;
6033 if (HEXRAYS_SLODWORD(v73) <= 0)
goto LABEL_40;
6038 for (
int t = (
int)HEXRAYS_LODWORD(v73);
t > 1;
t--) {
6039 v35 = (
const void *)(v72 * (v70 - (
unsigned __int64)(
signed __int64)
6062 (
unsigned __int64)(
signed __int64)
6067 HEXRAYS_LODWORD(v76) = v38;
6068 v39 = v72 * (v70 - v38);
6071 if (!X)
goto LABEL_36;
6073 if (abs((
signed __int64)v65) <= v40)
break;
6078 v78 = pSkyPolygon.
v_18.z;
6080 --HEXRAYS_LODWORD(v76);
6082 X = v41 + pSkyPolygon.
v_18.x;
6083 v81 = (
const void *)1;
6086 v79 = (
void *)pSkyPolygon.
v_18.z;
6087 v78 = 2 * HEXRAYS_LODWORD(v76);
6090 (((
double)v70 - ((double)(2 * HEXRAYS_LODWORD(v76)) -
6093 X = (int)((
char *)v81 + pSkyPolygon.
v_18.x);
6095 HEXRAYS_LODWORD(v42) = v77 << 16;
6096 HEXRAYS_HIDWORD(v42) = v77 >> 16;
6097 v79 = (
void *)(v42 / X);
6104 v74 = (
unsigned int)v37;
6105 HEXRAYS_LODWORD(v76) = v43;
6122 ((double)(v66 + ((
signed int)
fixpoint_mul(v43, v42 / X) >> 4)) *
6126 ((double)(v66 + ((
signed int)
fixpoint_mul(v43, v42 / X) >> 4)) *
6131 0.000015258789 * (double)(
signed int)v79;
6138 if (HEXRAYS_SLODWORD(v73) > 0) {
6139 v48 = (double)HEXRAYS_SLODWORD(v80);
6140 for (HEXRAYS_HIDWORD(v69) = HEXRAYS_LODWORD(v73); HEXRAYS_HIDWORD(v69);
6141 --HEXRAYS_HIDWORD(v69)) {
6150 int pNumVertices = 0;
6151 if (HEXRAYS_SLODWORD(v73) > 0) {
6152 v51 = (double)HEXRAYS_SLODWORD(v80);
6153 for (v80 = v73; v80 != 0.0; --HEXRAYS_LODWORD(v80)) {
6175 if (
config->is_using_specular) {
6176 this->
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
6177 this->
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
6178 this->
pRenderD3D->
pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
6188 if (
config->is_using_specular)
6197 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
6199 D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT);
6214 if (v5 < pOutdoor->max_terrain_dimming_level) {
6225 8 * v5 | ((8 * v5 | (v5 << 11)) << 8);
6234 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,