Mercurial > mm7
changeset 2417:15440e9ae7b6
pIcons_LOD->uNumLoadedFiles = pIcons_LOD->pFacesLock;
author | Ritor1 |
---|---|
date | Tue, 22 Jul 2014 17:43:28 +0600 |
parents | 8b04ba723324 |
children | 86357e382e33 0313c761d203 |
files | Render.cpp mm7_4.cpp |
diffstat | 2 files changed, 138 insertions(+), 185 deletions(-) [+] |
line wrap: on
line diff
--- a/Render.cpp Mon Jul 21 17:37:03 2014 +0600 +++ b/Render.cpp Tue Jul 22 17:43:28 2014 +0600 @@ -1892,11 +1892,8 @@ unsigned int v9; // ebx@5 unsigned int v10; // eax@5 DWORD v11; // edx@5 - //int v12; // edx@7 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 - //RenderD3D *v15; // [sp+88h] [bp-4h]@1 - - //v15 = this; + memset(&ddsd2, 0, 0x7Cu); ddsd2.dwSize = 0x7Cu; ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; @@ -1932,9 +1929,7 @@ } } else - { ddsd2.dwMipMapCount = 1; - } LABEL_11: ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; @@ -3534,32 +3529,13 @@ //----- (004A05F3) -------------------------------------------------------- bool Render::SwitchToWindow() { - //Render *v2; // esi@1 - //void *v3; // eax@2 - //RenderD3D *v4; // eax@3 - //unsigned int v5; // edx@5 - //RenderD3D__DevInfo *v6; // ecx@5 bool v7; // eax@7 - //RenderD3D *v8; // ecx@12 unsigned int v9; // eax@12 -// RenderD3D *v10; // eax@24 -// HRESULT v11; // eax@24 int v12; // eax@24 int v13; // eax@26 - //bool v14; // eax@32 - //char v15; // zf@32 -// IDirectDraw4 *v16; // eax@35 -// HRESULT v17; // eax@35 - //int *v18; // eax@36 -// int *v19; // edx@38 -// int v20; // eax@38 -// unsigned int v21; // ecx@38 -// int v22; // eax@41 D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@24 DDSURFACEDESC2 pDesc; // [sp+108h] [bp-204h]@37 D3DDEVICEDESC halCaps; // [sp+184h] [bp-188h]@24 -// DDSURFACEDESC2 ddsd2; // [sp+280h] [bp-8Ch]@35 - //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2 int v29; // [sp+308h] [bp-4h]@2 pParty->uFlags |= PARTY_FLAGS_1_0002; @@ -3720,7 +3696,6 @@ ddsd2.dwHeight = 480; ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0)); pBeforePresentFunction = Present_ColorKey;*/ -LABEL_45: using_software_screen_buffer = 1; //LABEL_47: bWindowMode = 1; @@ -3746,27 +3721,26 @@ memset32(pTargetSurface_unaligned, -1, num_pixels); - - pRenderer->pBackBuffer4->Unlock(0); - /*v19 = pTargetSurface_unaligned; - v20 = (unsigned int)pDesc.lpSurface & 7; - v21 = (unsigned int)ptr_400E8 & 7; - if ( v21 == v20 ) - { - pTargetSurface = (unsigned __int16 *)v19; - } - else - { - if ( (signed int)v21 >= v20 ) - v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); - else - v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); - pTargetSurface = (unsigned __int16 *)v22; - }*/ - pTargetSurface = pTargetSurface_unaligned; - uTargetSurfacePitch = window->GetWidth(); - pBeforePresentFunction = Present_NoColorKey; - goto LABEL_45; + pRenderer->pBackBuffer4->Unlock(0); + /*v19 = pTargetSurface_unaligned; + v20 = (unsigned int)pDesc.lpSurface & 7; + v21 = (unsigned int)ptr_400E8 & 7; + if ( v21 == v20 ) + pTargetSurface = (unsigned __int16 *)v19; + else + { + if ( (signed int)v21 >= v20 ) + v22 = (int)((char *)v19 + 2 * (v21 - v20) + 16); + else + v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16); + pTargetSurface = (unsigned __int16 *)v22; + }*/ + pTargetSurface = pTargetSurface_unaligned; + uTargetSurfacePitch = window->GetWidth(); + pBeforePresentFunction = Present_NoColorKey; + using_software_screen_buffer = 1; + bWindowMode = 1; + return 0; } @@ -4075,34 +4049,43 @@ //----- (004A0F40) -------------------------------------------------------- bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) { - //IDirectDrawSurface4 *v4; // esi@1 HRESULT result; // eax@1 HRESULT v6; // eax@4 -// int v7; // [sp-8h] [bp-14h]@10 -// unsigned int v8; // [sp-4h] [bp-10h]@10 char v9; // [sp+Bh] [bp-1h]@1 - //v4 = pSurface; v9 = 1; result = pSurface->Lock(0, pDesc, uLockFlags, 0); + /* + Когда объект DirectDrawSurface теряет поверхностную память, методы возвратят DDERR_SURFACELOST + и не выполнят никакую другую функцию. Метод IDirectDrawSurface::Restore перераспределит поверхностную память + и повторно присоединит ее к объекту DirectDrawSurface. + */ if ( result == DDERR_SURFACELOST ) { - v6 = pSurface->Restore(); + v6 = pSurface->Restore();//Восстанавливает потерянную поверхность. Это происходит, когда поверхностная память, + //связанная с объектом DirectDrawSurface была освобождена. if ( v6 ) { - if ( v6 != DDERR_IMPLICITLYCREATED ) - { -LABEL_20: + if ( v6 != DDERR_IMPLICITLYCREATED )//DDERR_IMPLICITLYCREATED - Поверхность не может быть восстановлена, + //потому что она - неявно созданная поверхность. + { v9 = 0; - result = (bool)memset(pDesc, 0, 4u); - goto LABEL_21; + result = (bool)memset(pDesc, 0, 4); + LOBYTE(result) = v9; + return 0; } pRenderer->pFrontBuffer4->Restore(); pSurface->Restore(); } result = pSurface->Lock(0, pDesc, DDLOCK_WAIT, 0); - if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) - goto LABEL_20; + if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY )//DDERR_SURFACEBUSY - Доступ к этой поверхности отказан, + //потому что поверхность блокирована другой нитью. DDERR_INVALIDRECT - Обеспечиваемый прямоугольник недопустим. + { + v9 = 0; + result = (bool)memset(pDesc, 0, 4); + LOBYTE(result) = v9; + return result; + } ErrD3D(result); if ( result ) { @@ -4110,7 +4093,10 @@ //v7 = 2161; //LABEL_19: //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, result, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8); - goto LABEL_20; + v9 = 0; + result = (bool)memset(pDesc, 0, 4); + LOBYTE(result) = v9; + return result; } if ( pRenderer->pRenderD3D ) pRenderD3D->HandleLostResources(); @@ -4121,16 +4107,19 @@ if ( result ) { if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) - goto LABEL_20; + { + v9 = 0; + result = (bool)memset(pDesc, 0, 4); + LOBYTE(result) = v9; + return result; + } ErrD3D(result); //v8 = 0; //v7 = 2199; //goto LABEL_19; } } -LABEL_21: - LOBYTE(result) = v9; - return result; + return true; } @@ -6289,32 +6278,21 @@ //----- (004A4DE1) -------------------------------------------------------- bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) { -// HRESULT v12; // eax@14 unsigned __int16 *v13; // ecx@19 unsigned __int16 *v14; // eax@19 DWORD v15; // edx@20 -// HRESULT v16; // eax@23 stru350 Dst; // [sp+Ch] [bp-F8h]@12 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); if ( pHWLTexture ) { bMipMaps = !strncmp(pName, "HDWTR", 5); - if ( !pRenderD3D->CreateTexture( - pHWLTexture->uWidth, - pHWLTexture->uHeight, - pOutSurface, - pOutTexture, - true, - bMipMaps, - uMinDeviceTextureDim) ) + if ( !pRenderD3D->CreateTexture(pHWLTexture->uWidth, pHWLTexture->uHeight, pOutSurface, pOutTexture, true, + bMipMaps, uMinDeviceTextureDim) ) Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); - //v10 = *pOutSurface; - //v11 = 0; if (bMipMaps) { Dst._450DDE(); - //v20 = 0; Dst._450DF1(&stru_4EFCBC, &stru_4EFCBC); IDirectDrawSurface4 *pNextSurf = *pOutSurface; @@ -6330,24 +6308,13 @@ if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) { - Dst.sub_451007_scale_image_bicubic( - pHWLTexture->pPixels, - pHWLTexture->uWidth, - pHWLTexture->uHeight, - pHWLTexture->uWidth, - (unsigned short *)desc.lpSurface, - desc.dwWidth, - desc.dwHeight, - desc.lPitch >> 1, - 0, - 0); + Dst.sub_451007_scale_image_bicubic(pHWLTexture->pPixels, pHWLTexture->uWidth, pHWLTexture->uHeight, pHWLTexture->uWidth, + (unsigned short *)desc.lpSurface, desc.dwWidth, desc.dwHeight, desc.lPitch >> 1, 0, 0); ErrD3D(pNextSurf->Unlock(0)); //bMipMaps = 0x4D86ACu; } if (FAILED(pNextSurf->GetAttachedSurface(&v19, &pNextSurf))) break; - //v10 = (IDirectDrawSurface4 *)pName; - //v11 = 0; } //v20 = -1; //nullsub_1(); @@ -6389,8 +6356,7 @@ //----- (004A5048) -------------------------------------------------------- bool Render::MoveSpriteToDevice( Sprite *pSprite ) - { - +{ HWLTexture *sprite_texture; // eax@1 unsigned __int16 *v9; // edx@5 LPVOID v10; // eax@5 @@ -6405,33 +6371,28 @@ pSprite->uBufferHeight = sprite_texture->uBufferHeight; pSprite->uAreaWidth = sprite_texture->uAreaWidth; pSprite->uAreaHeight = sprite_texture->uAreaHeigth; - //v6 = v3->uMinDeviceTextureDim; - //v7 = v3->pRenderD3D; if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim)) Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); - //pSprite = v2->pTextureSurface; - //pSprite = (Sprite *)pSprite->pName; - //v8 = pSprite; memset(&Dst, 0, sizeof(DDSURFACEDESC2)); Dst.dwSize = 124; if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) { - v9 = sprite_texture->pPixels; - v10 = Dst.lpSurface; + v9 = sprite_texture->pPixels; + v10 = Dst.lpSurface; for (int i=0; i<sprite_texture->uHeight; ++i) - { - for (int j=0; j<sprite_texture->uWidth/2; ++j) - { - *(int *)v10 = *(int *)v9; - v9 += 2; - v10 = (char *)v10 + 4; - } - v10 = (char *)v10+Dst.lPitch-sprite_texture->uWidth*2; - } + { + for (int j=0; j<sprite_texture->uWidth/2; ++j) + { + *(int *)v10 = *(int *)v9; + v9 += 2; + v10 = (char *)v10 + 4; + } + v10 = (char *)v10 + Dst.lPitch-sprite_texture->uWidth*2; + } ErrD3D(pSprite->pTextureSurface->Unlock(0)); } - free(sprite_texture->pPixels); - free(sprite_texture); + delete [] sprite_texture->pPixels; + delete sprite_texture; return true; } return false; @@ -8358,11 +8319,7 @@ //----- (004524D8) -------------------------------------------------------- HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) { - //int v11; // eax@13 - //int v12; // ecx@13 void *v13; // eax@13 - //unsigned __int8 v14; // zf@13 - //unsigned __int8 v15; // sf@13 int v16; // esi@14 int v17; // ecx@16 int v18; // esi@16 @@ -8376,14 +8333,12 @@ int v28; // [sp+2Ch] [bp-8h]@13 int pDestb; // [sp+3Ch] [bp+8h]@15 - //v3 = this; - //sprintf(Str1, "%s", pName); - //v4 = uNumItems; if (!uNumItems) return nullptr; - //{ - //v5 = 0, pDesta = uNumItems; + /////////////////////////////// + //quick search(быстрый поиск)// + /////////////////////////////// uint idx1 = 0, idx2 = uNumItems; while (true) @@ -8405,78 +8360,76 @@ return false; } - uint uCompressedSize = 0; fread(&uCompressedSize, 4, 1, pFile); - HWLTexture* pTex = new HWLTexture; - fread(&pTex->uBufferWidth, 4, 1, pFile); - fread(&pTex->uBufferHeight, 4, 1, pFile); - fread(&pTex->uAreaWidth, 4, 1, pFile); - fread(&pTex->uAreaHeigth, 4, 1, pFile); - fread(&pTex->uWidth, 4, 1, pFile); - fread(&pTex->uHeight, 4, 1, pFile); - fread(&pTex->uAreaX, 4, 1, pFile); - fread(&pTex->uAreaY, 4, 1, pFile); - - pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; - if (uCompressedSize) - { - char* pCompressedData = new char[uCompressedSize]; - { - fread(pCompressedData, 1, uCompressedSize, pFile); - uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); - zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); - } - delete [] pCompressedData; - } - else - fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); - - if ( scale_hwls_to_half ) - { - pTex->uHeight /= 2; - pTex->uWidth /= 2; - v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; - v28 = 0; - v26 = (unsigned __int16 *)v13; - if ( pTex->uHeight > 0 ) - { - v16 = pTex->uWidth; - v27 = 1; - do + HWLTexture* pTex = new HWLTexture; + fread(&pTex->uBufferWidth, 4, 1, pFile); + fread(&pTex->uBufferHeight, 4, 1, pFile); + fread(&pTex->uAreaWidth, 4, 1, pFile); + fread(&pTex->uAreaHeigth, 4, 1, pFile); + fread(&pTex->uWidth, 4, 1, pFile); + fread(&pTex->uHeight, 4, 1, pFile); + fread(&pTex->uAreaX, 4, 1, pFile); + fread(&pTex->uAreaY, 4, 1, pFile); + + pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; + if (uCompressedSize) + { + char* pCompressedData = new char[uCompressedSize]; + fread(pCompressedData, 1, uCompressedSize, pFile); + uint uDecompressedSize = pTex->uWidth * pTex->uHeight * sizeof(short); + zlib::MemUnzip(pTex->pPixels, &uDecompressedSize, pCompressedData, uCompressedSize); + delete [] pCompressedData; + } + else + fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); + + if ( scale_hwls_to_half ) + { + __debugbreak();//Ritor1 + pTex->uHeight /= 2; + pTex->uWidth /= 2; + v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; + v28 = 0; + v26 = (unsigned __int16 *)v13; + if ( pTex->uHeight > 0 ) + { + v16 = pTex->uWidth; + v27 = 1; + do + { + pDestb = 0; + if ( v16 > 0 ) { - pDestb = 0; - if ( v16 > 0 ) + do { - do - { - v17 = v16 * v27; - v18 = v28 * v16; - v19 = pTex->pPixels; - v20 = pDestb + 2 * v18; - v21 = (int)&v19[2 * (pDestb + v17)]; - v22 = (int)&v19[2 * v20]; - LOWORD(v20) = *(unsigned short *)(v21 + 2); - LOWORD(v21) = *(unsigned short *)v21; - v23 = pDestb++ + v18; - extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); - v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); - v16 = pTex->uWidth; - } - while (pDestb < pTex->uWidth); + v17 = v16 * v27; + v18 = v28 * v16; + v19 = pTex->pPixels; + v20 = pDestb + 2 * v18; + v21 = (int)&v19[2 * (pDestb + v17)]; + v22 = (int)&v19[2 * v20]; + LOWORD(v20) = *(unsigned short *)(v21 + 2); + LOWORD(v21) = *(unsigned short *)v21; + v23 = pDestb + v18; + pDestb++; + extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); + v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); + v16 = pTex->uWidth; } - ++v28; - v27 += 2; + while (pDestb < pTex->uWidth); } - while ( v28 < (signed int)pTex->uHeight ); - } - delete [] pTex->pPixels; - pTex->pPixels = v26; - } - return pTex; -} - + ++v28; + v27 += 2; + } + while ( v28 < (signed int)pTex->uHeight ); + } + delete [] pTex->pPixels; + pTex->pPixels = v26; + } + return pTex; +} //----- (0045271F) -------------------------------------------------------- bool RenderHWLContainer::Release() {
--- a/mm7_4.cpp Mon Jul 21 17:37:03 2014 +0600 +++ b/mm7_4.cpp Tue Jul 22 17:43:28 2014 +0600 @@ -201,8 +201,8 @@ } while ( v6 >= pIcons_LOD->pFacesLock ); } + pIcons_LOD->uNumLoadedFiles = pIcons_LOD->pFacesLock; pIcons_LOD->pFacesLock = 0; - pIcons_LOD->uNumLoadedFiles = pIcons_LOD->pFacesLock; } // 4ED498: using guessed type char byte_4ED498;