Browse Source

Stop relying on buffer padding in cursor rendering

Follow-up to #1173
pull/1465/head
Gleb Mazovetskiy 5 years ago
parent
commit
db3eaacfcf
  1. 20
      Source/scrollrt.cpp

20
Source/scrollrt.cpp

@ -12,8 +12,8 @@ namespace devilution {
*/ */
int light_table_index; int light_table_index;
DWORD sgdwCursWdtOld; DWORD sgdwCursWdtOld;
DWORD sgdwCursX; int sgdwCursX;
DWORD sgdwCursY; int sgdwCursY;
/** /**
* Lower bound of back buffer. * Lower bound of back buffer.
*/ */
@ -26,8 +26,8 @@ DWORD sgdwCursHgt;
* frameType := block & 0x7000 >> 12 * frameType := block & 0x7000 >> 12
*/ */
DWORD level_cel_block; DWORD level_cel_block;
DWORD sgdwCursXOld; int sgdwCursXOld;
DWORD sgdwCursYOld; int sgdwCursYOld;
bool AutoMapShowItems; bool AutoMapShowItems;
/** /**
* Specifies the type of arches to render. * Specifies the type of arches to render.
@ -107,8 +107,7 @@ void ClearCursor() // CODE_FIX: this was supposed to be in cursor.cpp
static void BlitCursor(BYTE *dst, int dst_pitch, BYTE *src, int src_pitch) static void BlitCursor(BYTE *dst, int dst_pitch, BYTE *src, int src_pitch)
{ {
const int h = std::min(sgdwCursY + 1, sgdwCursHgt); for (int i = 0; i < sgdwCursHgt; ++i, src += src_pitch, dst += dst_pitch) {
for (int i = 0; i < h; ++i, src += src_pitch, dst += dst_pitch) {
memcpy(dst, src, sgdwCursWdt); memcpy(dst, src, sgdwCursWdt);
} }
} }
@ -180,6 +179,15 @@ static void scrollrt_draw_cursor_item(CelOutputBuffer out)
sgdwCursHgt -= sgdwCursY; sgdwCursHgt -= sgdwCursY;
sgdwCursHgt++; sgdwCursHgt++;
if (sgdwCursX < 0) {
sgdwCursWdt -= sgdwCursX;
sgdwCursX = 0;
}
if (sgdwCursY < 0) {
sgdwCursHgt -= sgdwCursY;
sgdwCursY = 0;
}
BlitCursor(sgSaveBack, sgdwCursWdt, out.at(sgdwCursX, sgdwCursY), out.pitch()); BlitCursor(sgSaveBack, sgdwCursWdt, out.at(sgdwCursX, sgdwCursY), out.pitch());
mx++; mx++;

Loading…
Cancel
Save