Mercurial > might-and-magic-trilogy
changeset 6:82f81d5b7221
Слияние
author | Серик@ПончиК |
---|---|
date | Tue, 09 Oct 2012 20:00:24 +0600 |
parents | ca90d9e499b3 (current diff) ac0fb48cd27a (diff) |
children | 1200e31f08e5 |
files | Might and Magic Trilogy.vcxproj |
diffstat | 13 files changed, 278 insertions(+), 576 deletions(-) [+] |
line wrap: on
line diff
--- a/Indoor.cpp Tue Oct 09 20:00:01 2012 +0600 +++ b/Indoor.cpp Tue Oct 09 20:00:24 2012 +0600 @@ -791,7 +791,7 @@ v108 = v4; if ( v4 ) { - v6 = HIWORD(v4->palette); + v6 = v4->palette_id2; LOBYTE(v2->uAttributes) |= 0x80u; v109 = v6; sub_4AE5F1(v1);
--- a/LOD.cpp Tue Oct 09 20:00:01 2012 +0600 +++ b/LOD.cpp Tue Oct 09 20:00:24 2012 +0600 @@ -3,6 +3,7 @@ #include "Allocator.h" #include "PaletteManager.h" #include "Viewport.h" +#include "Log.h" #include "mm7_data.h" @@ -380,7 +381,7 @@ v3 = 0; do { - v4 = v1->pHardwareSprites[v3].pTextureSurface; + v4 = (IDirectDrawSurface *)v1->pHardwareSprites[v3].pTextureSurface; if ( v4 && v4->IsLost() == DDERR_SURFACELOST ) { v5 = v1->pHardwareSprites[v3].pTexture; @@ -389,7 +390,7 @@ v5->Release(); v1->pHardwareSprites[v3].pTexture = 0; } - v6 = v1->pHardwareSprites[v3].pTextureSurface; + v6 = (IDirectDrawSurface *)v1->pHardwareSprites[v3].pTextureSurface; v6->Release(); v1->pHardwareSprites[v3].pTextureSurface = 0; pRenderer->MoveSpriteToDevice(&v1->pHardwareSprites[v3]); @@ -434,7 +435,7 @@ v6 = v1->pHardwareSprites; if ( v6 ) { - v7 = v6[v3].pTextureSurface; + v7 = (IDirectDrawSurface *)v6[v3].pTextureSurface; if ( v7 ) { v7->Release(); @@ -1135,22 +1136,17 @@ //----- (00450D68) -------------------------------------------------------- void Sprite::Release() { - Sprite *v1; // esi@1 - IDirectDrawSurface *v2; // eax@3 - IDirect3DTexture2 *v3; // eax@5 + if (pName) + pAllocator->FreeChunk((void *)pName); + pName = nullptr; - v1 = this; - if ( this->pName ) - pAllocator->FreeChunk((void *)this->pName); - v2 = v1->pTextureSurface; - if ( v2 ) - v2->Release(); - v3 = v1->pTexture; - if ( v3 ) - v3->Release(); - v1->pName = 0; - v1->pTextureSurface = 0; - v1->pTexture = 0; + if (pTextureSurface) + pTextureSurface->Release(); + pTextureSurface = nullptr; + + if (pTexture) + pTexture->Release(); + pTexture = nullptr; } @@ -2623,7 +2619,7 @@ pRenderer->LoadTexture( v3 - 2, *((short *)v3 + 17), - &v1->pHardwareSurfaces[v2], + (IDirectDrawSurface4 **)&v1->pHardwareSurfaces[v2], &v1->pHardwareTextures[v2]); } else @@ -2635,7 +2631,7 @@ pRenderer->LoadTexture( v5, *((short *)v3 + 17), - &v1->pHardwareSurfaces[v2], + (IDirectDrawSurface4 **)&v1->pHardwareSurfaces[v2], &v1->pHardwareTextures[v2]); free(v5); } @@ -2819,12 +2815,7 @@ //----- (0040FC08) -------------------------------------------------------- int LODFile_IconsBitmaps::LoadTextureFromLOD(Texture *pOutTex, const char *pContainer, enum TEXTURE_TYPE eTextureType) { - const char *v4; // ebx@1 - LODFile_IconsBitmaps *v5; // edi@1 - FILE *v6; // eax@1 Texture *v8; // esi@3 - char *v9; // eax@8 - void *v10; // ST24_4@8 size_t v11; // eax@14 enum TEXTURE_TYPE v12; // eax@14 signed int v13; // esi@14 @@ -2857,59 +2848,59 @@ int v40; // edx@40 signed int v41; // ecx@43 signed int v42; // ecx@48 - FILE *File; // [sp+14h] [bp-4h]@1 - v4 = pContainer; - v5 = this; - v6 = FindContainer(pContainer, 0); - File = v6; - if ( !v6 ) + //v4 = pContainer; + //v5 = this; + //v6 = FindContainer(pContainer, 0); + //File = v6; + auto pFile = FindContainer(pContainer, false); + if (!pFile) return -1; v8 = pOutTex; - fread(pOutTex, 1u, 0x30u, v6); - strcpy(v8->pName, v4); - if ( pRenderer->pRenderD3D && v8->pBits & 2 && v5->dword_011BA8 ) + fread(pOutTex, 1u, 0x30u, pFile); + strcpy(v8->pName, pContainer); + if (pRenderer->pRenderD3D && v8->pBits & 2 && dword_011BA8) { - if ( !v5->pHardwareSurfaces || !v5->pHardwareTextures ) + if ( !pHardwareSurfaces || !pHardwareTextures ) { - v5->pHardwareSurfaces = (struct IDirectDrawSurface **)operator new(0xFA0u); - v5->pHardwareTextures = (struct IDirect3DTexture2 **)operator new(0xFA0u); - v9 = (char *)operator new(0x3E8u); - v10 = v5->pHardwareSurfaces; - v5->ptr_011BB4 = v9; - memset(v10, 0, 0xFA0u); - memset(v5->pHardwareTextures, 0, 0xFA0u); - memset(v5->ptr_011BB4, 0, 0x3E8u); + pHardwareSurfaces = new IDirectDrawSurface *[1000]; + memset(pHardwareSurfaces, 0, 1000 * sizeof(IDirectDrawSurface4 *)); + + pHardwareTextures = new IDirect3DTexture2 *[1000]; + memset(pHardwareTextures, 0, 1000 * sizeof(IDirect3DTexture2 *)); + + ptr_011BB4 = new char[1000]; + memset(ptr_011BB4, 0, 1000); } - if ( *v4 != 'w' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'd' || v4[4] != 'r' ) + if (strcmp(pContainer, "wtrdr"))//*v4 != 'w' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'd' || v4[4] != 'r' ) { - if ( *v4 != 'W' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'T' || v4[4] != 'y' || v4[5] != 'l' ) + if (strcmp(pContainer, "WtrTyl"))//if ( *v4 != 'W' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'T' || v4[4] != 'y' || v4[5] != 'l' ) { - v14 = v5->uNumLoadedFiles; + v14 = uNumLoadedFiles; } else { - pRenderer->field_1036AC_bitmapid = v5->uNumLoadedFiles; - v14 = v5->uNumLoadedFiles; + pRenderer->field_1036AC_bitmapid = uNumLoadedFiles; + v14 = uNumLoadedFiles; } v13 = pRenderer->LoadTexture( - v4, - LOWORD(v8->palette), - &v5->pHardwareSurfaces[v14], - &v5->pHardwareTextures[v14]); + pContainer, + v8->palette_id1, + (IDirectDrawSurface4 **)&pHardwareSurfaces[v14], + &pHardwareTextures[v14]); } else { - v11 = strlen(v4); + v11 = strlen(pContainer); v12 = (enum TEXTURE_TYPE)(int)operator new(v11 + 2); eTextureType = v12; *(char *)v12 = 104; - strcpy((char *)(v12 + 1), v4); + strcpy((char *)(v12 + 1), pContainer); v13 = pRenderer->LoadTexture( (const char *)eTextureType, - LOWORD(v8->palette), - &v5->pHardwareSurfaces[v5->uNumLoadedFiles], - &v5->pHardwareTextures[v5->uNumLoadedFiles]); + v8->palette_id1, + (IDirectDrawSurface4 **)&pHardwareSurfaces[uNumLoadedFiles], + &pHardwareTextures[uNumLoadedFiles]); free((void *)eTextureType); } return v13; @@ -2917,12 +2908,12 @@ v15 = v8->uTextureSize; v16 = &v8->uDecompressedSize; pOutTex = (Texture *)v8->uTextureSize; - if ( !v8->uDecompressedSize || v5->dword_011BA4 ) + if ( !v8->uDecompressedSize || dword_011BA4 ) { v20 = pAllocator; v32 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0, v15, v8->pName); v8->pLevelOfDetail0 = (unsigned __int8 *)v32; - fread(v32, 1u, (size_t)pOutTex, File); + fread(v32, 1u, (size_t)pOutTex, pFile); } else { @@ -2930,7 +2921,7 @@ v18 = v8->uTextureSize; pContainer = (const char *)v17; v19 = malloc(v18); - fread(v19, 1u, (size_t)pOutTex, File); + fread(v19, 1u, (size_t)pOutTex, pFile); zlib::MemUnzip((void *)pContainer, &v8->uDecompressedSize, v19, v8->uTextureSize); v8->uTextureSize = *v16; free(v19); @@ -2976,7 +2967,7 @@ { v33 = pAllocator->AllocNamedChunk(v8->pPalette24, 0x300u, v8->pName); v8->pPalette24 = (unsigned __int8 *)v33; - fread(v33, 1u, 0x300u, File); + fread(v33, 1u, 0x300u, pFile); } else { @@ -2987,14 +2978,14 @@ v38 = 0; do { - fread((char *)&eTextureType + 3, 1u, 1u, File); - fread((char *)&pContainer + 3, 1u, 1u, File); - v39 = fread((char *)&pOutTex + 3, 1u, 1u, File); - LOWORD(v39) = (unsigned __int8)(BYTE3(eTextureType) >> (8 - LOBYTE(v5->uTextureRedBits))); - v8->pPalette16[v38] = v39 << (LOBYTE(v5->uTextureBlueBits) + LOBYTE(v5->uTextureGreenBits)); - LOWORD(v40) = (unsigned __int8)(BYTE3(pContainer) >> (8 - LOBYTE(v5->uTextureGreenBits))); - v8->pPalette16[v38] += v40 << v5->uTextureBlueBits; - v8->pPalette16[v38] += (unsigned __int8)(BYTE3(pOutTex) >> (8 - LOBYTE(v5->uTextureBlueBits))); + fread((char *)&eTextureType + 3, 1u, 1u, pFile); + fread((char *)&pContainer + 3, 1u, 1u, pFile); + v39 = fread((char *)&pOutTex + 3, 1u, 1u, pFile); + LOWORD(v39) = (unsigned __int8)(BYTE3(eTextureType) >> (8 - LOBYTE(uTextureRedBits))); + v8->pPalette16[v38] = v39 << (LOBYTE(uTextureBlueBits) + LOBYTE(uTextureGreenBits)); + LOWORD(v40) = (unsigned __int8)(BYTE3(pContainer) >> (8 - LOBYTE(uTextureGreenBits))); + v8->pPalette16[v38] += v40 << uTextureBlueBits; + v8->pPalette16[v38] += (unsigned __int8)(BYTE3(pOutTex) >> (8 - LOBYTE(uTextureBlueBits))); ++v38; } while ( v38 < 256 ); @@ -3120,50 +3111,57 @@ //----- (0040FB20) -------------------------------------------------------- unsigned int LODFile_IconsBitmaps::LoadTexture(const char *pContainer, enum TEXTURE_TYPE uTextureType) { - LODFile_IconsBitmaps *v3; // esi@1 - unsigned int v4; // edi@1 - Texture *v5; // ebx@2 + //LODFile_IconsBitmaps *v3; // esi@1 + //unsigned int v4; // edi@1 + //Texture *v5; // ebx@2 unsigned int v6; // ebx@8 const char *Sourcea; // [sp+14h] [bp+8h]@9 - v3 = this; - v4 = 0; + //v3 = this; + //v4 = 0; areWeLoadingTexture = 1; - if ( (signed int)this->uNumLoadedFiles <= 0 ) - { -LABEL_5: - if ( (signed int)v3->uNumLoadedFiles >= 1000 ) + + for (uint i = 0; i < uNumLoadedFiles; ++i) + if (!strcmpi(pContainer, pTextures[i].pName)) + return i; + +// if (!uNumLoadedFiles) +// { +//LABEL_5: + if (uNumLoadedFiles >= 1000) + { + Log::Warning(L"Maximum texture number exceeded"); AbortWithError(); - if ( v3->LoadTextureFromLOD(&v3->pTextures[v3->uNumLoadedFiles], pContainer, uTextureType) == -1 ) + } + if (LoadTextureFromLOD(&pTextures[uNumLoadedFiles], pContainer, uTextureType) == -1) { v6 = 0; - if ( (signed int)v3->uNumLoadedFiles > 0 ) + if (uNumLoadedFiles > 0) { - Sourcea = (const char *)v3->pTextures; + Sourcea = (const char *)pTextures; while ( _strcmpi(Sourcea, "pending") ) { Sourcea += 72; ++v6; - if ( (signed int)v6 >= (signed int)v3->uNumLoadedFiles ) + if (v6 >= uNumLoadedFiles) goto LABEL_15; } return v6; } LABEL_15: - v3->LoadTextureFromLOD(&v3->pTextures[v3->uNumLoadedFiles], "pending", uTextureType); + LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", uTextureType); } areWeLoadingTexture = 0; - ++v3->uNumLoadedFiles; - return v3->uNumLoadedFiles - 1; - } - v5 = this->pTextures; - while ( _strcmpi(v5->pName, pContainer) ) - { - ++v4; - ++v5; - if ( (signed int)v4 >= (signed int)v3->uNumLoadedFiles ) - goto LABEL_5; - } - return v4; + ++uNumLoadedFiles; + return uNumLoadedFiles - 1; +// } +// v5 = pTextures; +// while ( _strcmpi(v5->pName, pContainer) ) +// { +// ++v4; +// ++v5; +// if (v4 >= uNumLoadedFiles ) +// goto LABEL_5; +// } +// return v4; } -// 506128: using guessed type int areWeLoadingTexture; \ No newline at end of file
--- a/Might and Magic Trilogy.vcxproj Tue Oct 09 20:00:01 2012 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,288 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{4CB238C2-3039-4BF6-966A-1ED1285BE23B}</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <RootNamespace>MightandMagicTrilogy</RootNamespace> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <LinkIncremental>true</LinkIncremental> - <TargetName>$(ProjectName)</TargetName> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <LinkIncremental>false</LinkIncremental> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader> - </PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClCompile Include="Actor.cpp" /> - <ClCompile Include="AIL.cpp" /> - <ClCompile Include="Allocator.cpp" /> - <ClCompile Include="Arcomage.cpp" /> - <ClCompile Include="AudioPlayer.cpp" /> - <ClCompile Include="Bink_Smacker.cpp" /> - <ClCompile Include="BSPModel.cpp" /> - <ClCompile Include="Chest.cpp" /> - <ClCompile Include="DecalBuilder.cpp" /> - <ClCompile Include="Events.cpp" /> - <ClCompile Include="FrameTableInc.cpp" /> - <ClCompile Include="Game.cpp" /> - <ClCompile Include="GammaControl.cpp" /> - <ClCompile Include="GUIButton.cpp" /> - <ClCompile Include="GUIFont.cpp" /> - <ClCompile Include="GUIProgressBar.cpp" /> - <ClCompile Include="GUIWindow.cpp" /> - <ClCompile Include="Indoor.cpp" /> - <ClCompile Include="IndoorCamera.cpp" /> - <ClCompile Include="IndoorCameraD3D.cpp" /> - <ClCompile Include="Items.cpp" /> - <ClCompile Include="Keyboard.cpp" /> - <ClCompile Include="LayingItem.cpp" /> - <ClCompile Include="lib\zlib\adler32.c" /> - <ClCompile Include="lib\zlib\compress.c" /> - <ClCompile Include="lib\zlib\crc32.c" /> - <ClCompile Include="lib\zlib\deflate.c" /> - <ClCompile Include="lib\zlib\infblock.c" /> - <ClCompile Include="lib\zlib\infcodes.c" /> - <ClCompile Include="lib\zlib\inffast.c" /> - <ClCompile Include="lib\zlib\inflate.c" /> - <ClCompile Include="lib\zlib\inftrees.c" /> - <ClCompile Include="lib\zlib\infutil.c" /> - <ClCompile Include="lib\zlib\trees.c" /> - <ClCompile Include="lib\zlib\uncompr.c" /> - <ClCompile Include="lib\zlib\zutil.c" /> - <ClCompile Include="LightmapBuilder.cpp" /> - <ClCompile Include="LightsStack.cpp" /> - <ClCompile Include="LOD.cpp" /> - <ClCompile Include="Log.cpp" /> - <ClCompile Include="mm7_1.cpp"> - <RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MultiThreadedDebug</RuntimeLibrary> - </ClCompile> - <ClCompile Include="mm7_2.cpp" /> - <ClCompile Include="mm7_3.cpp" /> - <ClCompile Include="mm7_4.cpp" /> - <ClCompile Include="mm7_5.cpp" /> - <ClCompile Include="mm7_6.cpp" /> - <ClCompile Include="mm7_data.cpp" /> - <ClCompile Include="Monsters.cpp" /> - <ClCompile Include="Mouse.cpp" /> - <ClCompile Include="OSAPI.cpp" /> - <ClCompile Include="Outdoor.cpp" /> - <ClCompile Include="Overlays.cpp" /> - <ClCompile Include="PaletteManager.cpp" /> - <ClCompile Include="ParticleEngine.cpp" /> - <ClCompile Include="Party.cpp" /> - <ClCompile Include="Player.cpp" /> - <ClCompile Include="Random.cpp" /> - <ClCompile Include="Render.cpp" /> - <ClCompile Include="SaveLoad.cpp" /> - <ClCompile Include="Spells.cpp" /> - <ClCompile Include="Sprites.cpp" /> - <ClCompile Include="stru10.cpp" /> - <ClCompile Include="stru6.cpp" /> - <ClCompile Include="stru9.cpp" /> - <ClCompile Include="Texture.cpp" /> - <ClCompile Include="TileFrameTable.h" /> - <ClCompile Include="Time.cpp" /> - <ClCompile Include="VideoPlayer.cpp" /> - <ClCompile Include="Vis.cpp" /> - <ClCompile Include="Weather.cpp" /> - </ItemGroup> - <ItemGroup> - <ClInclude Include="Actor.h" /> - <ClInclude Include="AIL.h" /> - <ClInclude Include="Allocator.h" /> - <ClInclude Include="Arcomage.h" /> - <ClInclude Include="AudioPlayer.h" /> - <ClInclude Include="Autonotes.h" /> - <ClInclude Include="Awards.h" /> - <ClInclude Include="Bink_Smacker.h" /> - <ClInclude Include="BSPModel.h" /> - <ClInclude Include="Chest.h" /> - <ClInclude Include="CShow.h" /> - <ClInclude Include="DecalBuilder.h" /> - <ClInclude Include="DecorationList.h" /> - <ClInclude Include="Events.h" /> - <ClInclude Include="Events2D.h" /> - <ClInclude Include="FactionTable.h" /> - <ClInclude Include="FrameTableInc.h" /> - <ClInclude Include="Game.h" /> - <ClInclude Include="GammaControl.h" /> - <ClInclude Include="GUIButton.h" /> - <ClInclude Include="GUIFont.h" /> - <ClInclude Include="GUIProgressBar.h" /> - <ClInclude Include="GUIWindow.h" /> - <ClInclude Include="IconFrameTable.h" /> - <ClInclude Include="Indoor.h" /> - <ClInclude Include="IndoorCamera.h" /> - <ClInclude Include="IndoorCameraD3D.h" /> - <ClInclude Include="Indoor_stuff.h" /> - <ClInclude Include="lib\zlib\deflate.h" /> - <ClInclude Include="lib\zlib\infblock.h" /> - <ClInclude Include="lib\zlib\infcodes.h" /> - <ClInclude Include="lib\zlib\inffast.h" /> - <ClInclude Include="lib\zlib\inffixed.h" /> - <ClInclude Include="lib\zlib\inftrees.h" /> - <ClInclude Include="lib\zlib\infutil.h" /> - <ClInclude Include="lib\zlib\trees.h" /> - <ClInclude Include="lib\zlib\zconf.h" /> - <ClInclude Include="lib\zlib\zlib.h" /> - <ClInclude Include="lib\zlib\zutil.h" /> - <ClInclude Include="Log.h" /> - <ClInclude Include="OSAPI.h" /> - <ClInclude Include="Outdoor_stuff.h" /> - <ClInclude Include="Items.h" /> - <ClInclude Include="Keyboard.h" /> - <ClInclude Include="LayingItem.h" /> - <ClInclude Include="lib\legacy_dx\d3d.h" /> - <ClInclude Include="lib\legacy_dx\d3dcaps.h" /> - <ClInclude Include="lib\legacy_dx\d3drm.h" /> - <ClInclude Include="lib\legacy_dx\d3drmdef.h" /> - <ClInclude Include="lib\legacy_dx\d3drmobj.h" /> - <ClInclude Include="lib\legacy_dx\d3drmwin.h" /> - <ClInclude Include="lib\legacy_dx\d3dtypes.h" /> - <ClInclude Include="lib\legacy_dx\ddraw.h" /> - <ClInclude Include="lib\legacy_dx\dinput.h" /> - <ClInclude Include="lib\legacy_dx\dinputd.h" /> - <ClInclude Include="lib\legacy_dx\dmdls.h" /> - <ClInclude Include="lib\legacy_dx\dmerror.h" /> - <ClInclude Include="lib\legacy_dx\dmksctrl.h" /> - <ClInclude Include="lib\legacy_dx\dmplugin.h" /> - <ClInclude Include="lib\legacy_dx\dmusbuff.h" /> - <ClInclude Include="lib\legacy_dx\dmusicc.h" /> - <ClInclude Include="lib\legacy_dx\dmusicf.h" /> - <ClInclude Include="lib\legacy_dx\dmusici.h" /> - <ClInclude Include="lib\legacy_dx\dmusics.h" /> - <ClInclude Include="lib\legacy_dx\dsconf.h" /> - <ClInclude Include="lib\legacy_dx\dsound.h" /> - <ClInclude Include="lib\legacy_dx\dvoice.h" /> - <ClInclude Include="lib\legacy_dx\multimon.h" /> - <ClInclude Include="lib\legacy_dx\rmxfguid.h" /> - <ClInclude Include="lib\legacy_dx\rmxftmpl.h" /> - <ClInclude Include="lib\legacy_dx\strsafe.h" /> - <ClInclude Include="LightmapBuilder.h" /> - <ClInclude Include="Lights.h" /> - <ClInclude Include="LOD.h" /> - <ClInclude Include="MapInfo.h" /> - <ClInclude Include="Math.h" /> - <ClInclude Include="MM7.h" /> - <ClInclude Include="mm7_data.h" /> - <ClInclude Include="Monsters.h" /> - <ClInclude Include="Mouse.h" /> - <ClInclude Include="NPC.h" /> - <ClInclude Include="ObjectList.h" /> - <ClInclude Include="OSInfo.h" /> - <ClInclude Include="Outdoor.h" /> - <ClInclude Include="OutdoorCamera.h" /> - <ClInclude Include="Overlays.h" /> - <ClInclude Include="PaletteManager.h" /> - <ClInclude Include="ParticleEngine.h" /> - <ClInclude Include="Party.h" /> - <ClInclude Include="Player.h" /> - <ClInclude Include="PlayerFrameTable.h" /> - <ClInclude Include="Random.h" /> - <ClInclude Include="Render.h" /> - <ClInclude Include="SaveLoad.h" /> - <ClInclude Include="Spells.h" /> - <ClInclude Include="Sprites.h" /> - <ClInclude Include="StorylineTextTable.h" /> - <ClInclude Include="stru10.h" /> - <ClInclude Include="stru11.h" /> - <ClInclude Include="stru12.h" /> - <ClInclude Include="stru123.h" /> - <ClInclude Include="stru157.h" /> - <ClInclude Include="stru159.h" /> - <ClInclude Include="stru160.h" /> - <ClInclude Include="stru176.h" /> - <ClInclude Include="stru179.h" /> - <ClInclude Include="stru220.h" /> - <ClInclude Include="stru272.h" /> - <ClInclude Include="stru277.h" /> - <ClInclude Include="stru279.h" /> - <ClInclude Include="stru287.h" /> - <ClInclude Include="stru298.h" /> - <ClInclude Include="stru314.h" /> - <ClInclude Include="stru346.h" /> - <ClInclude Include="stru351.h" /> - <ClInclude Include="stru6.h" /> - <ClInclude Include="stru9.h" /> - <ClInclude Include="Texture.h" /> - <ClInclude Include="Time.h" /> - <ClInclude Include="TurnEngine.h" /> - <ClInclude Include="VectorTypes.h" /> - <ClInclude Include="VideoPlayer.h" /> - <ClInclude Include="Viewport.h" /> - <ClInclude Include="Vis.h" /> - <ClInclude Include="Weather.h" /> - </ItemGroup> - <ItemGroup> - <None Include="lib\legacy_dx\d3dvec.inl" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project> \ No newline at end of file
--- a/Outdoor.cpp Tue Oct 09 20:00:01 2012 +0600 +++ b/Outdoor.cpp Tue Oct 09 20:00:24 2012 +0600 @@ -1477,7 +1477,7 @@ v149 = (void *)(v20 != -1 ? &pBitmaps_LOD->pTextures[v20] : 0); auto pTex = (Texture *)v149; if (pTex) - pTex->palette = pPaletteManager->LoadPalette(pTex->palette); + pTex->palette_id2 = pPaletteManager->LoadPalette(pTex->palette_id1); goto LABEL_20; } pTextureFrameTable->LoadAnimationSequenceAndPalettes( @@ -1613,11 +1613,11 @@ v36 = v5->uSky_TextureID; v5->uMainTile_BitmapID = v35; if ( v36 != -1 ) - HIWORD(pBitmaps_LOD->pTextures[v36].palette) = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v36].palette); + pBitmaps_LOD->pTextures[v36].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v36].palette_id1); v37 = v5->uMainTile_BitmapID; if ( v37 != -1 ) - HIWORD(pBitmaps_LOD->pTextures[v37].palette) = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v37].palette); + pBitmaps_LOD->pTextures[v37].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v37].palette_id1); v5->_47F0E2(); pGameLoadingUI_ProgressBar->Progress(); @@ -1813,9 +1813,9 @@ LABEL_68: v63->uTextureID = v62; v145 = (signed __int16)v62 != -1 ? (int)&pBitmaps_LOD->pTextures[(signed __int16)v62] : 0; - v108 = ((signed __int16)v62 != -1 ? LOWORD(pBitmaps_LOD->pTextures[(signed __int16)v62].palette) : 36); + v108 = ((signed __int16)v62 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v62].palette_id1 : 36); if ((signed __int16)v62 != -1) - HIWORD(pBitmaps_LOD->pTextures[v62].palette) = pPaletteManager->LoadPalette(v108); + pBitmaps_LOD->pTextures[v62].palette_id2 = pPaletteManager->LoadPalette(v108); goto LABEL_69; } v108 = *(unsigned __int16 *)((char *)&v5->pBModels[v48].pFaces->uTextureID + (unsigned int)v149); @@ -2159,9 +2159,9 @@ v5->uMainTile_BitmapID = v99; if ( v99 != -1 ) { - v108 = *(short *)(v99 != -1 ? &pBitmaps_LOD->pTextures[v99].palette : (int *)36); + v108 = (v99 != -1 ? pBitmaps_LOD->pTextures[v99].palette_id1 : 36); if (v99 != -1) - HIWORD(pBitmaps_LOD->pTextures[v99].palette) = pPaletteManager->LoadPalette(v108); + pBitmaps_LOD->pTextures[v99].palette_id2 = pPaletteManager->LoadPalette(v108); } v5->_47F0E2(); LABEL_150: @@ -2188,9 +2188,9 @@ v5->uSky_TextureID = v101; if ( v101 != -1 ) { - v108 = *(short *)(v101 != -1 ? &pBitmaps_LOD->pTextures[v101].palette : (int *)36); + v108 = (v101 != -1 ? pBitmaps_LOD->pTextures[v101].palette_id1 : 36); if (v101 != -1) - HIWORD(pBitmaps_LOD->pTextures[v101].palette) = pPaletteManager->LoadPalette(v108); + pBitmaps_LOD->pTextures[v101].palette_id2 = pPaletteManager->LoadPalette(v108); } pPaletteManager->RecalculateAll(); pSoundList->_4A9A67(53, 0); @@ -2567,7 +2567,7 @@ { if ( v1 != -1 ? (int)v3 : 0 ) v3->uDecompressedSize = v2->pTerrain._47CB57((int)v3->pLevelOfDetail0, - HIWORD(v3->palette), + v3->palette_id2, v3->uTextureWidth * v3->uTextureHeight); ++v1; ++v3;
--- a/Render.cpp Tue Oct 09 20:00:01 2012 +0600 +++ b/Render.cpp Tue Oct 09 20:00:24 2012 +0600 @@ -127,8 +127,8 @@ IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1 v0 = false; - pRenderer->pRenderD3D->CreateTexture(64u, 64u, (IDirectDrawSurface **)&pSurface1, &pTexture1, 1u, 0, 32u); - pRenderer->pRenderD3D->CreateTexture(64u, 64u, (IDirectDrawSurface **)&pSurface2, &pTexture2, 1u, 0, 32u); + pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u); + pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u); ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1)); ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u)); @@ -647,7 +647,7 @@ && pParty->uCurrentHour < 0x15 || bUnderwater ) { - v2 = (stru148 *)*(short *)PaletteManager::Get_Mist_or_Red_LUT(HIWORD(array_77EC08[1999].pTexture->palette), 31, 1); + v2 = (stru148 *)*(short *)PaletteManager::Get_Mist_or_Red_LUT(array_77EC08[1999].pTexture->palette_id2, 31, 1); a1b = (unsigned int)v2; if ( (signed int)v9 <= 0 ) return (signed __int16)v2; @@ -4199,30 +4199,29 @@ //----- (0049E5D4) -------------------------------------------------------- -bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface **pOutSurface, IDirect3DTexture2 **pOutTexture, unsigned int bAlphaChannel, unsigned int bMipmaps, unsigned int uMinDeviceTexDim) +bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) { unsigned int v8; // edx@4 unsigned int v9; // ebx@5 unsigned int v10; // eax@5 DWORD v11; // edx@5 - int v12; // edx@7 + //int v12; // edx@7 DDSURFACEDESC2 ddsd2; // [sp+Ch] [bp-80h]@1 - RenderD3D *v15; // [sp+88h] [bp-4h]@1 - - v15 = this; + //RenderD3D *v15; // [sp+88h] [bp-4h]@1 + + //v15 = this; memset(&ddsd2, 0, 0x7Cu); ddsd2.dwSize = 0x7Cu; - ddsd2.dwFlags = 0x1007u; // DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT - ddsd2.ddsCaps.dwCaps = 0x1000u; // DDSCAPS_TEXTURE - ddsd2.ddsCaps.dwCaps2 = 0x10u; // DDSCAPS2_TEXTUREMANAGE + ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; + ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE; + ddsd2.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; ddsd2.dwHeight = uTextureHeight; ddsd2.dwWidth = uTextureWidth; if ( bMipmaps ) { if ( (signed int)uTextureHeight <= (signed int)uTextureWidth ) { - GetMaxMipLevels(uTextureHeight); // BUG actually v12 = GetMaxMipLevels - v8 = v12 - GetMaxMipLevels(uMinDeviceTexDim); + v8 = GetMaxMipLevels(uTextureHeight) - GetMaxMipLevels(uMinDeviceTexDim); LABEL_8: ddsd2.dwMipMapCount = v8; if ( !v8 ) @@ -4249,36 +4248,36 @@ ddsd2.dwMipMapCount = 1; } LABEL_11: - ddsd2.dwFlags = 0x21007u; // DDSD_MIPMAPCOUNT - ddsd2.ddsCaps.dwCaps = 0x401008u; // DDSCAPS_COMPLEX | DDSCAPS_MIPMAP + ddsd2.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_MIPMAPCOUNT; + ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP; LABEL_12: - ddsd2.ddpfPixelFormat.dwBBitMask = 0x1Fu; - ddsd2.ddpfPixelFormat.dwRGBBitCount = 0x10u; - ddsd2.ddpfPixelFormat.dwSize = 32; - if ( bAlphaChannel ) - { - ddsd2.ddpfPixelFormat.dwFlags = 0x41u; // DDPF_RGB | DDPF_ALPHAPIXELS - *(_QWORD *)&ddsd2.ddpfPixelFormat.dwRBitMask = 0x3E000007C00ui64; + ddsd2.ddpfPixelFormat.dwRGBBitCount = 16; + ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); + if (bAlphaChannel) + { + ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; + ddsd2.ddpfPixelFormat.dwRBitMask = 0x7C00; + ddsd2.ddpfPixelFormat.dwGBitMask = 0x03E0; + ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0x8000u; } else { - ddsd2.ddpfPixelFormat.dwFlags = 0x40u; // DDPF_RGB - *(_QWORD *)&ddsd2.ddpfPixelFormat.dwRBitMask = 0x7E00000F800ui64; + ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB; + ddsd2.ddpfPixelFormat.dwRBitMask = 0xF800; + ddsd2.ddpfPixelFormat.dwGBitMask = 0x07E0; + ddsd2.ddpfPixelFormat.dwBBitMask = 0x001F; ddsd2.ddpfPixelFormat.dwRGBAlphaBitMask = 0; } - if ( v15->pHost->CreateSurface(&ddsd2, (LPDIRECTDRAWSURFACE4 *)pOutSurface, 0) ) - return 0; - if ( (*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (LPVOID *)pOutTexture) ) - { - if ( *pOutSurface ) - { - (*pOutSurface)->Release(); - *pOutSurface = 0; - } - return 0; - } - return 1; + if (FAILED(pHost->CreateSurface(&ddsd2, pOutSurface, 0))) + return false; + if (FAILED((*pOutSurface)->QueryInterface(IID_IDirect3DTexture2, (void **)pOutTexture))) + { + (*pOutSurface)->Release(); + *pOutSurface = 0; + return false; + } + return true; } //----- (004A5190) -------------------------------------------------------- @@ -5686,19 +5685,11 @@ } } } -// 4E800C: using guessed type int bWinNT4_0; //----- (0049FFD7) -------------------------------------------------------- void Render::CreateSomeTexture() { - pRenderD3D->CreateTexture( - 64u, - 64u, - (IDirectDrawSurface **)&this->pSurface, - &this->pTexture, - 1u, - 0, - 32u); + pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32); } //----- (0049FFFB) -------------------------------------------------------- @@ -8761,15 +8752,15 @@ //----- (004A4DE1) -------------------------------------------------------- -int Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface **pOutSurface, IDirect3DTexture2 **pOutTexture) -{ - const char *v5; // ebx@1 - Render *v6; // edi@1 - HWLTexture *pHWLTexture; // esi@1 - signed int result; // eax@1 - IDirectDrawSurface **v9; // ebx@9 +bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) +{ + //const char *v5; // ebx@1 + //Render *v6; // edi@1 + //HWLTexture *pHWLTexture; // esi@1 + //signed int result; // eax@1 + //IDirectDrawSurface **v9; // ebx@9 IDirectDrawSurface4 *v10; // edi@11 - int v11; // ebx@11 + //int v11; // ebx@11 HRESULT v12; // eax@14 unsigned __int16 *v13; // ecx@19 unsigned __int16 *v14; // eax@19 @@ -8780,25 +8771,21 @@ DDSCAPS2 v19; // [sp+E8h] [bp-1Ch]@13 int v20; // [sp+100h] [bp-4h]@12 - v5 = pName; - v6 = this; - pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); - result = 0; + auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps); if ( pHWLTexture ) { - bMipMaps = *v5 == 72 && v5[1] == 68 && v5[2] == 87 && v5[3] == 84 && v5[4] == 82; - v9 = pOutSurface; + bMipMaps = !strncmp(pName, "HDWTR", 5); if ( !pRenderD3D->CreateTexture( pHWLTexture->uWidth, pHWLTexture->uHeight, pOutSurface, pOutTexture, - 1u, + true, bMipMaps, - v6->uMinDeviceTextureDim) ) + uMinDeviceTextureDim) ) Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); - v10 = (IDirectDrawSurface4 *)*v9; - v11 = 0; + v10 = *pOutSurface; + //v11 = 0; if ( bMipMaps ) { Dst._450DDE(); @@ -8806,9 +8793,9 @@ Dst._450DF1((const char *)dword_4EFCBC, (const char *)dword_4EFCBC); while ( 1 ) { - memset(&v19, v11, 0x10u); + memset(&v19, 0, 0x10u); v19.dwCaps = 0x401000u; // DDSCAPS_TEXTURE | DDSCAPS_MIPMAP - memset(&desc, v11, 0x7Cu); + memset(&desc, 0, 0x7Cu); desc.dwSize = 124; if ( LockSurface_DDraw4(v10, &desc, 0x21u) ) { @@ -8829,7 +8816,7 @@ if ( v10->GetAttachedSurface(&v19, (LPDIRECTDRAWSURFACE4 *)&pName) ) break; v10 = (IDirectDrawSurface4 *)pName; - v11 = 0; + //v11 = 0; } v20 = -1; //nullsub_1(); @@ -8871,9 +8858,9 @@ } free(pHWLTexture->pPixels); free(pHWLTexture); - result = 1; - } - return result; + return true; + } + return false; } //----- (004A5048) -------------------------------------------------------- @@ -11034,14 +11021,14 @@ //----- (004524D8) -------------------------------------------------------- HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) { - RenderHWLContainer *v3; // esi@1 + //RenderHWLContainer *v3; // esi@1 unsigned int v4; // eax@1 int v5; // ebx@2 int v6; // edi@3 - HWLTexture *result; // eax@8 - HWLTexture *pTex; // edi@9 - char *v9; // ebx@9 - unsigned __int16 *v10; // eax@9 + //HWLTexture *result; // eax@8 + //HWLTexture *pTex; // edi@9 + //char *v9; // ebx@9 + //unsigned __int16 *v10; // eax@9 int v11; // eax@13 int v12; // ecx@13 void *v13; // eax@13 @@ -11055,7 +11042,7 @@ int v21; // ecx@16 int v22; // eax@16 int v23; // esi@16 - char Str1[20]; // [sp+Ch] [bp-28h]@1 + //char Str1[20]; // [sp+Ch] [bp-28h]@1 unsigned int pSource; // [sp+20h] [bp-14h]@10 unsigned __int16 *v26; // [sp+24h] [bp-10h]@13 int v27; // [sp+28h] [bp-Ch]@14 @@ -11065,55 +11052,56 @@ void *pDestc; // [sp+3Ch] [bp+8h]@10 int pDestb; // [sp+3Ch] [bp+8h]@15 - v3 = this; - sprintf(Str1, "%s", pName); - v4 = v3->uNumItems; - if ( v4 && (v5 = 0, pDesta = v3->uNumItems, (signed int)v4 > 0) ) + //v3 = this; + //sprintf(Str1, "%s", pName); + v4 = uNumItems; + if ( v4 && (v5 = 0, pDesta = uNumItems, (signed int)v4 > 0) ) { while ( 1 ) { v6 = v5 + (pDesta - v5) / 2; - if ( !_strcmpi(Str1, v3->pSpriteNames[v6]) ) + if ( !_strcmpi(pName, pSpriteNames[v6]) ) break; - if ( _strcmpi(Str1, v3->pSpriteNames[v6]) <= 0 ) + if ( _strcmpi(pName, pSpriteNames[v6]) <= 0 ) pDesta = v5 + (pDesta - v5) / 2; else v5 = v6 + 1; if ( v5 >= pDesta ) - goto LABEL_8; + return false; } fseek(pFile, pSpriteOffsets[v6], SEEK_SET); - pTex = new HWLTexture; - fread(&DstBuf, 4u, 1u, v3->pFile); - fread(&pTex->field_18, 4u, 1u, v3->pFile); - fread(&pTex->field_1C, 4u, 1u, v3->pFile); - fread(&pTex->field_20, 4u, 1u, v3->pFile); - fread(&pTex->field_24, 4u, 1u, v3->pFile); - v9 = (char *)&pTex->uWidth; - fread(&pTex->uWidth, 4u, 1u, v3->pFile); - fread(&pTex->uHeight, 4u, 1u, v3->pFile); - fread(&pTex->field_30, 4u, 1u, v3->pFile); - fread(&pTex->field_34, 4u, 1u, v3->pFile); - v10 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; - pTex->pPixels = v10; + + auto pTex = new HWLTexture; + fread(&DstBuf, 4u, 1u, pFile); + fread(&pTex->field_18, 4u, 1u, pFile); + fread(&pTex->field_1C, 4u, 1u, pFile); + fread(&pTex->field_20, 4u, 1u, pFile); + fread(&pTex->field_24, 4u, 1u, pFile); + //v9 = (char *)&pTex->uWidth; + fread(&pTex->uWidth, 4u, 1u, pFile); + fread(&pTex->uHeight, 4u, 1u, pFile); + fread(&pTex->field_30, 4u, 1u, pFile); + fread(&pTex->field_34, 4u, 1u, pFile); + //v10 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; + pTex->pPixels = new unsigned __int16[pTex->uWidth * pTex->uHeight]; if ( DstBuf ) { pDestc = new char[DstBuf]; - fread(pDestc, 1u, DstBuf, v3->pFile); - pSource = 2 * *(unsigned int *)v9 * pTex->uHeight; + fread(pDestc, 1u, DstBuf, pFile); + pSource = 2 * pTex->uWidth * pTex->uHeight; zlib::MemUnzip(pTex->pPixels, &pSource, pDestc, DstBuf); delete [] pDestc; } else { - fread(v10, 2u, *(unsigned int *)v9 * pTex->uHeight, v3->pFile); - } - if ( v3->field_61A94_scale_hwls_to_half ) - { - v11 = (signed int)pTex->uHeight / 2; - v12 = *(unsigned int *)v9 / 2; + fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); + } + if ( field_61A94_scale_hwls_to_half ) + { + v11 = pTex->uHeight / 2; + v12 = pTex->uWidth / 2; pTex->uHeight = v11; - *(unsigned int *)v9 = v12; + pTex->uWidth = v12; v13 = new unsigned __int16[v12 * v11]; v28 = 0; v14 = pTex->uHeight == 0; @@ -11121,7 +11109,7 @@ v26 = (unsigned __int16 *)v13; if ( !(v15 | v14) ) { - v16 = *(unsigned int *)v9; + v16 = pTex->uWidth; v27 = 1; do { @@ -11140,26 +11128,26 @@ LOWORD(v21) = *(unsigned short *)v21; v23 = pDestb++ + v18; v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); - v16 = *(unsigned int *)v9; + v16 = pTex->uWidth; } - while ( pDestb < *(unsigned int *)v9 ); + while (pDestb < pTex->uWidth); } ++v28; v27 += 2; } while ( v28 < (signed int)pTex->uHeight ); } - free(pTex->pPixels); + delete [] pTex->pPixels; pTex->pPixels = v26; } - result = pTex; + return pTex; + //result = pTex; } else { -LABEL_8: - result = 0; - } - return result; +//LABEL_8: + return nullptr; + } } //----- (0045271F) --------------------------------------------------------
--- a/Render.h Tue Oct 09 20:00:01 2012 +0600 +++ b/Render.h Tue Oct 09 20:00:24 2012 +0600 @@ -200,7 +200,7 @@ unsigned int GetDeviceCaps(); void ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear); void Present(bool bForceBlit); - bool CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface **pOutSurface, IDirect3DTexture2 **pOutTexture, unsigned int bAlphaChannel, unsigned int bMipmaps, unsigned int uMinDeviceTexDim); + bool CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim); void HandleLostResources(); @@ -301,7 +301,7 @@ int _4A48E4(int a2, int a3, int a4, int a5, int a6); void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9); void _4A4CC9(struct stru6_stru1_indoor_sw_billboard *a1, int a2); - int LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface **pOutSurface, IDirect3DTexture2 **pOutTexture); + bool LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture); HWLTexture *MoveSpriteToDevice(Sprite *pSprite); void BeginScene(); void EndScene();
--- a/Sprites.h Tue Oct 09 20:00:01 2012 +0600 +++ b/Sprites.h Tue Oct 09 20:00:24 2012 +0600 @@ -9,7 +9,7 @@ const char *pName; int uPaletteID; - struct IDirectDrawSurface *pTextureSurface; + struct IDirectDrawSurface4 *pTextureSurface; struct IDirect3DTexture2 *pTexture; int uAreaX; int uAreaY;
--- a/Texture.cpp Tue Oct 09 20:00:01 2012 +0600 +++ b/Texture.cpp Tue Oct 09 20:00:24 2012 +0600 @@ -306,7 +306,7 @@ v3->pTextures[i].uTextureID = pBitmaps_LOD->LoadTexture(v3->pTextures[i].pTextureName, TEXTURE_DEFAULT); auto pTex = (v3->pTextures[i].uTextureID != -1 ? &pBitmaps_LOD->pTextures[v3->pTextures[i].uTextureID] : 0); if (pTex) - pTex->palette = pPaletteManager->LoadPalette(pTex->palette); + pTex->palette_id2 = pPaletteManager->LoadPalette(pTex->palette_id1); result = (unsigned int)v3->pTextures; if ( !(*(char *)(result + i * 20 + 18) & 1) ) break; @@ -402,34 +402,34 @@ //----- (0040F77C) -------------------------------------------------------- void Texture::Release() { - Texture *v1; // esi@1 - char v2; // zf@2 + if (this) + { + pName[0] = 0; - v1 = this; - if ( this ) - { - v2 = (pBits & 0x0400) == 0; - this->pName[0] = 0; - if ( v2 ) + if (pBits & 0x0400) { pAllocator->FreeChunk(pLevelOfDetail0); pAllocator->FreeChunk(pPalette16); pAllocator->FreeChunk(pPalette24); } - v1->pLevelOfDetail0 = 0; - v1->pLevelOfDetail1 = 0; - v1->pLevelOfDetail2 = 0; - v1->pLevelOfDetail3 = 0; - v1->pPalette16 = 0; - v1->pPalette24 = 0; - v1->uSizeOfMaxLevelOfDetail = 0; - v1->uTextureSize = 0; - v1->uTextureHeight = 0; - v1->uTextureWidth = 0; - v1->uHeightLn2 = 0; - v1->uWidthLn2 = 0; - v1->palette = 0; - LOWORD(v1->pBits) = 0; + + pLevelOfDetail0 = nullptr; + pLevelOfDetail1 = nullptr; + pLevelOfDetail2 = nullptr; + pLevelOfDetail3 = nullptr; + + pPalette16 = nullptr; + pPalette24 = nullptr; + + uSizeOfMaxLevelOfDetail = 0; + uTextureSize = 0; + uTextureHeight = 0; + uTextureWidth = 0; + uHeightLn2 = 0; + uWidthLn2 = 0; + palette_id1 = 0; + palette_id2 = 0; + pBits &= 0xFFFF0000; } } @@ -506,20 +506,21 @@ //----- (0040F5BE) -------------------------------------------------------- Texture::Texture() { - this->pName[0] = 0; - this->uSizeOfMaxLevelOfDetail = 0; - this->uTextureSize = 0; - this->uTextureHeight = 0; - this->uTextureWidth = 0; - this->uHeightLn2 = 0; - this->uWidthLn2 = 0; - this->palette = 0; - this->pLevelOfDetail0 = 0; - this->pLevelOfDetail3 = 0; - this->pLevelOfDetail2 = 0; - this->pLevelOfDetail1 = 0; - this->pPalette16 = 0; - this->pPalette24 = 0; + pName[0] = 0; + uSizeOfMaxLevelOfDetail = 0; + uTextureSize = 0; + uTextureHeight = 0; + uTextureWidth = 0; + uHeightLn2 = 0; + uWidthLn2 = 0; + palette_id1 = 0; + palette_id2 = 0; + pLevelOfDetail0 = 0; + pLevelOfDetail3 = 0; + pLevelOfDetail2 = 0; + pLevelOfDetail1 = 0; + pPalette16 = 0; + pPalette24 = 0; } //----- (0040F414) --------------------------------------------------------
--- a/Texture.h Tue Oct 09 20:00:01 2012 +0600 +++ b/Texture.h Tue Oct 09 20:00:24 2012 +0600 @@ -47,7 +47,8 @@ __int16 uHeightLn2; __int16 uWidthMinus1; __int16 uHeightMinus1; - int palette; + short palette_id1; + short palette_id2; unsigned int uDecompressedSize; int pBits; unsigned __int8 *pLevelOfDetail0;
--- a/mm7_1.cpp Tue Oct 09 20:00:01 2012 +0600 +++ b/mm7_1.cpp Tue Oct 09 20:00:24 2012 +0600 @@ -3110,7 +3110,7 @@ { v13 = &pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]]; v106.field_C = v115 + v106.uViewportY + v13->uBufferHeight; - v222 = v13->pTextureSurface; + v222 = (IDirectDrawSurface *)v13->pTextureSurface; memset(&Dst, 0, 0x64u); Dst.dwSize = 100; Dst.dwFillColor = 0;
--- a/mm7_2.cpp Tue Oct 09 20:00:01 2012 +0600 +++ b/mm7_2.cpp Tue Oct 09 20:00:24 2012 +0600 @@ -13097,7 +13097,7 @@ do { if ( pIndoor->pFaces[v12].uBitmapID != -1 ) - HIWORD(pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette) = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette); + pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id1); ++i; ++v12; } @@ -13863,7 +13863,7 @@ //----- (004637EB) -------------------------------------------------------- -signed int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam) +int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam) { unsigned int v4; // esi@1 Render *v5; // ecx@14 @@ -14080,10 +14080,13 @@ { if ( Msg == WM_WINDOWPOSCHANGED ) { - if ( pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer ) - { - BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0); - return DefWindowProcA(hWnd, Msg, wParam, v4); + if (pVideoPlayer) + { + if (pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer) + { + BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0); + return DefWindowProcA(hWnd, Msg, wParam, v4); + } } goto _def_wnd_proc; } @@ -15428,7 +15431,7 @@ pVideoPlayer = new VideoPlayer; pVideoPlayer->Initialize(); - BYTE1(dword_6BE364_game_settings_1) |= 0x40u; + dword_6BE364_game_settings_1 |= 0x4000; if ( uTurnSpeed ) { @@ -15449,7 +15452,7 @@ { uTurnSpeed = (unsigned int)uCPUSpeed < 0xC7 ? 128 : 64; } - return 1; + return true; } @@ -15467,7 +15470,7 @@ int v6; // ecx@6 int v7; // edx@7 ObjectDesc *v8; // eax@7 - signed int v9; // esi@8 + //signed int v9; // esi@8 signed int v10; // ebx@14 signed int v11; // esi@15 char pContainer[32]; // [sp+10h] [bp-Ch]@9 @@ -15537,13 +15540,12 @@ flt_6BE3A0 = 0.55000001f; MainMenuUI_Create(); pGame->pStru6Instance->LoadAnimations(); - v9 = 0; - do - { - sprintf(pContainer, "HDWTR%03u", v9); - pRenderer->pHDWaterBitmapIDs[v9++] = pBitmaps_LOD->LoadTexture(pContainer); - } - while ( v9 < 7 ); + + for (uint i = 0; i < 7; ++i) + { + sprintf(pContainer, "HDWTR%03u", i); + pRenderer->pHDWaterBitmapIDs[i] = pBitmaps_LOD->LoadTexture(pContainer); + } pNPCStats = new NPCStats; pNPCStats->Initialize();
--- a/mm7_3.cpp Tue Oct 09 20:00:01 2012 +0600 +++ b/mm7_3.cpp Tue Oct 09 20:00:24 2012 +0600 @@ -9673,7 +9673,7 @@ v4 = a2; if ( pParty->field_1613C ) { - result = PaletteManager::Get(HIWORD(a2->pTexture->palette)); + result = PaletteManager::Get(a2->pTexture->palette_id2); } else { @@ -9698,7 +9698,7 @@ a3a = 1; if ( pParty->field_1613C ) { - result = PaletteManager::Get(HIWORD(a1->pTexture->palette)); + result = PaletteManager::Get(a1->pTexture->palette_id2); } else { @@ -9709,7 +9709,7 @@ { if ( v6 != -1 || a4 != -1 ) { - v7 = HIWORD(v4->pTexture->palette); + v7 = v4->pTexture->palette_id2; } else { @@ -9720,7 +9720,7 @@ } else { - result = PaletteManager::Get_Dark_or_Red_LUT(HIWORD(v4->pTexture->palette), v6, a3a); + result = PaletteManager::Get_Dark_or_Red_LUT(v4->pTexture->palette_id2, v6, a3a); } } return result; @@ -9759,7 +9759,7 @@ a2a = 1; if ( pParty->field_1613C ) { - result = (char *)pPaletteManager->field_199600_palettes[HIWORD(a1->pTexture->palette)]; + result = (char *)pPaletteManager->field_199600_palettes[a1->pTexture->palette_id2]; } else { @@ -9769,14 +9769,14 @@ if ( v9 == 1 ) { if ( a3 != -1 || a4 != -1 ) - v7 = HIWORD(v4->pTexture->palette); + v7 = v4->pTexture->palette_id2; else v7 = 0; result = (char *)PaletteManager::_47C30E_get_palette(v7, a2a); } else { - result = (char *)PaletteManager::_47C33F_get_palette(HIWORD(v4->pTexture->palette), a2a); + result = (char *)PaletteManager::_47C33F_get_palette(v4->pTexture->palette_id2, a2a); } } return result; @@ -19198,7 +19198,7 @@ v12 = v2; if ( v2 != -1 ? (int)&pBitmaps_LOD->pTextures[v2] : 0 ) { - HIWORD(pBitmaps_LOD->pTextures[v2].palette) = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2].palette); + pBitmaps_LOD->pTextures[v2].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2].palette_id1); if ( uCurrentlyLoadedLevelType == 1 ) {
--- a/mm7_4.cpp Tue Oct 09 20:00:01 2012 +0600 +++ b/mm7_4.cpp Tue Oct 09 20:00:24 2012 +0600 @@ -1722,7 +1722,7 @@ { v2->pTiles[v3].uBitmapID = pBitmaps_LOD->LoadTexture(v4->pTileName); if ( v2->pTiles[v3].uBitmapID != -1 ) - HIWORD(pBitmaps_LOD->pTextures[v2->pTiles[v3].uBitmapID].palette) = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2->pTiles[v3].uBitmapID].palette); + pBitmaps_LOD->pTextures[v2->pTiles[v3].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2->pTiles[v3].uBitmapID].palette_id1); } ++i; } @@ -8692,7 +8692,7 @@ v50 = v10; sub_4AF412(); ++pBLVRenderParams->field_80; - v11 = sr_sub_47C24C_get_palette(v2, HIWORD(v4->palette), 0, 1); + v11 = sr_sub_47C24C_get_palette(v2, v4->palette_id2, 0, 1); v12 = stru_F8A590._viewport_space_y; v51 = v11; v60 = stru_F8A590._viewport_space_y;