Skip to content

Commit

Permalink
Fixes for 0.99.401
Browse files Browse the repository at this point in the history
Add new paletted logo.
Fix FNV1a seed.
  • Loading branch information
bolrog committed Apr 1, 2021
1 parent fc34bef commit 64ade10
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 852 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
**/Debug/
**/Release/
*_cso.h
publish/
35 changes: 16 additions & 19 deletions src/d2dx/D2DXContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "GlideHelpers.h"
#include "Simd.h"
#include "Utils.h"
#include "dx_raw.h"
#include "dx256_bmp.h"

using namespace d2dx;
using namespace DirectX::PackedVector;
Expand Down Expand Up @@ -872,39 +872,36 @@ void D2DXContext::PrepareLogoTextureBatch()
return;
}

uint32_t hash = fnv_32a_buf((void*)dx_raw, sizeof(uint32_t) * 81 * 40, FNV1_32A_INIT);
const uint8_t* srcPixels = dx_logo256 + 0x436;
const uint32_t* palette = (const uint32_t*)(dx_logo256 + 0x36);

_d3d11Context->SetPalette(15, palette);

uint32_t hash = fnv_32a_buf((void*)srcPixels, sizeof(uint8_t) * 81 * 40, FNV1_32A_INIT);

uint8_t* data = _sideTmuMemory.items;

_logoTextureBatch.SetTextureStartAddress(0);
_logoTextureBatch.SetTextureHash(hash);
_logoTextureBatch.SetTextureSize(128, 128);
_logoTextureBatch.SetTextureCategory(TextureCategory::TitleScreen);
_logoTextureBatch.SetIsRgba(true);
_logoTextureBatch.SetIsRgba(false);
_logoTextureBatch.SetPrimitiveType(PrimitiveType::Triangles);
_logoTextureBatch.SetAlphaBlend(AlphaBlend::SrcAlphaInvSrcAlpha);
_logoTextureBatch.SetIsChromaKeyEnabled(true);
_logoTextureBatch.SetRgbCombine(RgbCombine::ColorMultipliedByTexture);
_logoTextureBatch.SetAlphaCombine(AlphaCombine::One);
_logoTextureBatch.SetCategory(BatchCategory::UiElement);
_logoTextureBatch.SetPaletteIndex(15);
_logoTextureBatch.SetVertexCount(6);

memset(data, 0, _logoTextureBatch.GetTextureMemSize());

const uint32_t* pSrc32 = (const uint32_t*)dx_raw;
uint32_t* pDst32 = (uint32_t*)data;

for (int32_t y = 0; y < 40; ++y)
for (int32_t y = 0; y < 41; ++y)
{
for (int32_t x = 0; x < 81; ++x)
for (int32_t x = 0; x < 80; ++x)
{
uint32_t c = *pSrc32++;
uint32_t r = (c & 0x00FF0000) >> 16;
uint32_t b = c & 0x000000FF;
c &= 0xFF00FF00;
c |= r;
c |= b << 16;
pDst32[x + y * 128] = c;
data[x + (40-y) * 128] = *srcPixels++;
}
}
}
Expand All @@ -925,10 +922,10 @@ void D2DXContext::InsertLogoOnTitleScreen()
const float y = (float)(_d3d11Context->GetGameHeight() - 50 - 16);
const uint32_t color = 0xFFFFa090;

Vertex vertex0(x, y, 0, 0, color, RgbCombine::ColorMultipliedByTexture, AlphaCombine::One, true, textureCacheLocation.ArrayIndex, 0);
Vertex vertex1(x + 80, y, 80, 0, color, RgbCombine::ColorMultipliedByTexture, AlphaCombine::One, true, textureCacheLocation.ArrayIndex, 0);
Vertex vertex2(x + 80, y + 41, 80, 41, color, RgbCombine::ColorMultipliedByTexture, AlphaCombine::One, true, textureCacheLocation.ArrayIndex, 0);
Vertex vertex3(x, y + 41, 0, 41, color, RgbCombine::ColorMultipliedByTexture, AlphaCombine::One, true, textureCacheLocation.ArrayIndex, 0);
Vertex vertex0(x, y, 0, 0, color, RgbCombine::ColorMultipliedByTexture, AlphaCombine::One, true, textureCacheLocation.ArrayIndex, 15);
Vertex vertex1(x + 80, y, 80, 0, color, RgbCombine::ColorMultipliedByTexture, AlphaCombine::One, true, textureCacheLocation.ArrayIndex, 15);
Vertex vertex2(x + 80, y + 41, 80, 41, color, RgbCombine::ColorMultipliedByTexture, AlphaCombine::One, true, textureCacheLocation.ArrayIndex, 15);
Vertex vertex3(x, y + 41, 0, 41, color, RgbCombine::ColorMultipliedByTexture, AlphaCombine::One, true, textureCacheLocation.ArrayIndex, 15);

assert((_frames[_currentFrameIndex]._vertexCount + 6) < _frames[_currentFrameIndex]._vertices.capacity);
int32_t vertexWriteIndex = _frames[_currentFrameIndex]._vertexCount;
Expand Down
2 changes: 1 addition & 1 deletion src/d2dx/d2dx.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@
<ClInclude Include="..\..\thirdparty\glide3\sst1init.h" />
<ClInclude Include="..\..\thirdparty\glide3\SST1VID.H" />
<ClInclude Include="D2DXDetours.h" />
<ClInclude Include="dx_raw.h" />
<ClInclude Include="Buffer.h" />
<ClInclude Include="dx256_bmp.h" />
<ClInclude Include="TextureCache.h" />
<ClInclude Include="D3D11Context.h" />
<ClInclude Include="Batch.h" />
Expand Down
2 changes: 1 addition & 1 deletion src/d2dx/d2dx.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<ClCompile Include="D2DXDetours.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="dx_raw.h" />
<ClInclude Include="Buffer.h" />
<ClInclude Include="TextureCache.h" />
<ClInclude Include="D3D11Context.h" />
Expand Down Expand Up @@ -95,6 +94,7 @@
<Filter>thirdparty\detours</Filter>
</ClInclude>
<ClInclude Include="D2DXDetours.h" />
<ClInclude Include="dx256_bmp.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="d2dx.rc" />
Expand Down
2 changes: 1 addition & 1 deletion src/d2dx/d2dx.vcxproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>C:\games\Diablo II\Game.exe</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>-ns -3dfx -w -gxskiplogo</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>-ns -3dfx -w</LocalDebuggerCommandArguments>
<LocalDebuggerWorkingDirectory>C:\games\Diablo II\</LocalDebuggerWorkingDirectory>
<LocalDebuggerDebuggerType>NativeOnly</LocalDebuggerDebuggerType>
</PropertyGroup>
Expand Down
Loading

0 comments on commit 64ade10

Please sign in to comment.