Skip to content

Commit

Permalink
Don't update extra pixels in byte aligned texture
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed May 9, 2024
1 parent 0d5dcaa commit 3054a05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 7010
#define BUILD_NUMBER 7011
32 changes: 10 additions & 22 deletions ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4814,18 +4814,12 @@ void m_IDirectDrawSurfaceX::LockEmuLock(LPRECT lpDestRect, LPDDSURFACEDESC2 lpDD
DWORD InPitch = EmuLock.Pitch;
BYTE* OutAddr = EmuLock.Mem.data();
DWORD OutPitch = EmuLock.NewPitch;
if (InPitch == OutPitch)
size_t MemWidth = (EmuLock.BBP / 8) * EmuLock.Width;
for (DWORD x = 0; x < EmuLock.Height; x++)
{
memcpy(OutAddr, InAddr, OutPitch * EmuLock.Height);
}
else
{
for (DWORD x = 0; x < EmuLock.Height; x++)
{
memcpy(OutAddr, InAddr, OutPitch);
InAddr += InPitch;
OutAddr += OutPitch;
}
memcpy(OutAddr, InAddr, MemWidth);
InAddr += InPitch;
OutAddr += OutPitch;
}

// Mark as byte align locked
Expand All @@ -4843,18 +4837,12 @@ void m_IDirectDrawSurfaceX::UnlockEmuLock()
DWORD InPitch = EmuLock.NewPitch;
BYTE* OutAddr = (BYTE*)EmuLock.Addr;
DWORD OutPitch = EmuLock.Pitch;
if (InPitch == OutPitch)
size_t MemWidth = (EmuLock.BBP / 8) * EmuLock.Width;
for (DWORD x = 0; x < EmuLock.Height; x++)
{
memcpy(OutAddr, InAddr, OutPitch * EmuLock.Height);
}
else
{
for (DWORD x = 0; x < EmuLock.Height; x++)
{
memcpy(OutAddr, InAddr, OutPitch);
InAddr += InPitch;
OutAddr += OutPitch;
}
memcpy(OutAddr, InAddr, MemWidth);
InAddr += InPitch;
OutAddr += OutPitch;
}

EmuLock.Locked = false;
Expand Down

0 comments on commit 3054a05

Please sign in to comment.