From 32f5b3f6853c399a3cb4e1dbd12ab81af7cd8c1f Mon Sep 17 00:00:00 2001 From: JustAnotherGuid <46401660+JustAnotherGuid@users.noreply.github.com> Date: Mon, 18 Mar 2019 01:17:07 +0100 Subject: [PATCH 1/8] Clean-up S_ScrollSBuy [binary exact] (#654) --- Source/stores.cpp | 51 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/Source/stores.cpp b/Source/stores.cpp index a00933485..268521e62 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -577,35 +577,36 @@ void __cdecl S_StartSmith() void __fastcall S_ScrollSBuy(int idx) { - int v1; // esi - int v2; // edi - char *v3; // esi - char *v4; // eax - int iclr; // [esp+Ch] [ebp-4h] + int y; + char clr; - v1 = idx; - v2 = 5; ClearSText(5, 21); - v3 = &smithitem[v1]._iMagical; stextup = 5; - do { - if (*((_DWORD *)v3 - 13) != -1) { - _LOBYTE(iclr) = COL_WHITE; - if (*v3) - _LOBYTE(iclr) = COL_BLUE; - if (!*((_DWORD *)v3 + 74)) - _LOBYTE(iclr) = COL_RED; - v4 = v3 + 65; - if (!*v3) - v4 = v3 + 1; - AddSText(20, v2, 0, v4, iclr, 1); - AddSTextVal(v2, *((_DWORD *)v3 + 35)); - PrintStoreItem((ItemStruct *)(v3 - 60), v2 + 1, iclr); - stextdown = v2; - v3 += 368; + + for (y = 5; y < 20; y += 4) { + if (smithitem[idx]._itype != -1) { + clr = COL_WHITE; + if (smithitem[idx]._iMagical) { + clr = COL_BLUE; + } + + if (!smithitem[idx]._iStatFlag) { + clr = COL_RED; + } + + if (smithitem[idx]._iMagical) { + AddSText(20, y, 0, smithitem[idx]._iIName, clr, 1); + } else { + AddSText(20, y, 0, smithitem[idx]._iName, clr, 1); + } + + AddSTextVal(y, smithitem[idx]._iIvalue); + PrintStoreItem(&smithitem[idx], y + 1, clr); + stextdown = y; + idx++; } - v2 += 4; - } while (v2 < 20); + } + if (!stext[stextsel]._ssel && stextsel != 22) stextsel = stextdown; } From 6ce2d9baaaf8aa2c5c1663d2e2a7d75792c67a88 Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 17 Mar 2019 13:40:37 +0100 Subject: [PATCH 2/8] missiles_process_charge bin exact --- Source/missiles.cpp | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 1b6887db6..889a72da2 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -5505,33 +5505,26 @@ void __cdecl ProcessMissiles() void __cdecl missiles_process_charge() { - int v0; // ebx - int i; // edi - int v2; // ecx - int v3; // esi - BOOLEAN v4; // zf - CMonster *v5; // eax - char v6; // dl - AnimStruct *v7; // eax - - v0 = nummissiles; - for (i = 0; i < v0; ++i) { - v2 = missileactive[i]; - v3 = missile[v2]._mimfnum; - v4 = missile[v2]._mitype == MIS_RHINO; - missile[v2]._miAnimData = misfiledata[0].mAnimData[v3 + 59 * _LOBYTE(missile[v2]._miAnimType)]; - if (v4) { - v5 = monster[missile[v2]._misource].MType; - v6 = v5->mtype; - if (v5->mtype < MT_HORNED || v6 > MT_OBLORD) { - if (v6 < MT_NSNAKE || v6 > MT_GSNAKE) - v7 = &v5->Anims[MA_WALK]; - else - v7 = &v5->Anims[MA_ATTACK]; + CMonster *mon; + AnimStruct *anim; + MissileStruct *mis; + int i, mi; + + for (i = 0; i < nummissiles; i++) { + mi = missileactive[i]; + mis = &missile[mi]; + mis->_miAnimData = misfiledata[mis->_miAnimType].mAnimData[mis->_mimfnum]; + if (mis->_mitype == MIS_RHINO) { + mon = monster[mis->_misource].MType; + if (mon->mtype >= MT_HORNED && mon->mtype <= MT_OBLORD) { + anim = &mon->Anims[MA_SPECIAL]; } else { - v7 = &v5->Anims[MA_SPECIAL]; + if (mon->mtype >= MT_NSNAKE && mon->mtype <= MT_GSNAKE) + anim = &mon->Anims[MA_ATTACK]; + else + anim = &mon->Anims[MA_WALK]; } - missile[v2]._miAnimData = v7->Data[v3]; + missile[mi]._miAnimData = anim->Data[mis->_mimfnum]; } } } From 068f19d52346bcddf75249e13fa7f4f09f3c6d12 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sun, 17 Mar 2019 20:56:38 -0500 Subject: [PATCH 3/8] Cleanup town_clear_x_buf (#669) --- Source/town.cpp | 188 +++++++++++++++++++++++++++++++----------------- Source/town.h | 4 +- 2 files changed, 126 insertions(+), 66 deletions(-) diff --git a/Source/town.cpp b/Source/town.cpp index 7aeec9a9c..94e44d7ba 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -2,83 +2,143 @@ #include "../types.h" -void __fastcall town_clear_upper_buf(unsigned char *a1) +void __fastcall town_clear_upper_buf(BYTE *pBuff) { - unsigned char *v1; // edi - signed int v2; // edx - signed int v3; // ebx - unsigned char *v4; // edi - signed int v5; // edx - signed int v6; // ebx - unsigned char *v7; // edi + /// ASSERT: assert(gpBuffer); - v1 = a1; - v2 = 30; - v3 = 1; - while (v1 >= gpBufEnd) { - v4 = &v1[v2]; - memset(v4, 0, 4 * v3); - v1 = &v4[4 * v3 - 832 + v2]; - if (!v2) { - v5 = 2; - v6 = 15; - do { - if (v1 < gpBufEnd) - break; - v7 = &v1[v5]; - memset(v7, 0, 4 * v6); - v1 = &v7[4 * v6-- - 832 + v5]; - v5 += 2; - } while (v5 != 32); - return; - } - v2 -= 2; - ++v3; +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov edi, pBuff + mov edx, 30 + mov ebx, 1 + xor eax, eax + label1: + cmp edi, gpBufEnd + jb label4 + add edi, edx + mov ecx, ebx + rep stosd + add edi, edx + sub edi, 768 + 64 + or edx, edx + jz label2 + sub edx, 2 + inc ebx + jmp label1 + label2: + mov edx, 2 + mov ebx, 15 + label3: + cmp edi, gpBufEnd + jb label4 + add edi, edx + mov ecx, ebx + rep stosd + add edi, edx + sub edi, 768 + 64 + dec ebx + add edx, 2 + cmp edx, 32 + jnz label3 + label4: + nop + } +#else + int i, j, k; + BYTE *dst; + + dst = pBuff; + + for(i = 30, j = 1; i >= 0 && dst >= gpBufEnd; i -= 2, j++, dst -= 768 + 64) { + dst += i; + for(k = 0; k < 4 * j; k++) + *dst++ = 0; + dst += i; } + for(i = 2, j = 15; i != 32 && dst >= gpBufEnd; i += 2, j--, dst -= 768 + 64) { + dst += i; + for(k = 0; k < 4 * j; k++) + *dst++ = 0; + dst += i; + } +#endif } // 69CF0C: using guessed type int gpBufEnd; -void __fastcall town_clear_low_buf(unsigned char *y_related) +void __fastcall town_clear_low_buf(BYTE *pBuff) { - unsigned char *v1; // edi - signed int v2; // edx - signed int i; // ebx - unsigned char *v4; // edi - unsigned char *v5; // edi - signed int v6; // edx - signed int v7; // ebx - unsigned char *v8; // edi - unsigned char *v9; // edi + /// ASSERT: assert(gpBuffer); + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov edi, pBuff + mov edx, 30 + mov ebx, 1 + xor eax, eax + label1: + cmp edi, gpBufEnd + jb label2 + add edi, 64 + jmp label3 + label2: + add edi, edx + mov ecx, ebx + rep stosd + add edi, edx + label3: + sub edi, 768 + 64 + or edx, edx + jz label4 + sub edx, 2 + inc ebx + jmp label1 + label4: + mov edx, 2 + mov ebx, 15 + label5: + cmp edi, gpBufEnd + jb label6 + add edi, 64 + jmp label7 + label6: + add edi, edx + mov ecx, ebx + rep stosd + add edi, edx + label7: + sub edi, 768 + 64 + dec ebx + add edx, 2 + cmp edx, 32 + jnz label5 + } +#else + int i, j, k; + BYTE *dst; - v1 = y_related; - v2 = 30; - for (i = 1;; ++i) { - if (v1 < gpBufEnd) { - v5 = &v1[v2]; - memset(v5, 0, 4 * i); - v4 = &v5[4 * i + v2]; + dst = pBuff; + + for(i = 30, j = 1; i >= 0; i -= 2, j++, dst -= 768 + 64) { + if(dst < gpBufEnd) { + dst += i; + for(k = 0; k < 4 * j; k++) + *dst++ = 0; + dst += i; } else { - v4 = v1 + 64; + dst += 64; } - v1 = v4 - 832; - if (!v2) - break; - v2 -= 2; } - v6 = 2; - v7 = 15; - do { - if (v1 < gpBufEnd) { - v9 = &v1[v6]; - memset(v9, 0, 4 * v7); - v8 = &v9[4 * v7 + v6]; + for(i = 2, j = 15; i != 32; i += 2, j--, dst -= 768 + 64) { + if(dst < gpBufEnd) { + dst += i; + for(k = 0; k < 4 * j; k++) + *dst++ = 0; + dst += i; } else { - v8 = v1 + 64; + dst += 64; } - v1 = v8 - 832; - --v7; - v6 += 2; - } while (v6 != 32); + } +#endif } // 69CF0C: using guessed type int gpBufEnd; diff --git a/Source/town.h b/Source/town.h index aed0f8576..a1bf7f2b7 100644 --- a/Source/town.h +++ b/Source/town.h @@ -2,8 +2,8 @@ #ifndef __TOWN_H__ #define __TOWN_H__ -void __fastcall town_clear_upper_buf(unsigned char *a1); -void __fastcall town_clear_low_buf(unsigned char *y_related); +void __fastcall town_clear_upper_buf(BYTE *pBuff); +void __fastcall town_clear_low_buf(BYTE *pBuff); void __fastcall town_draw_clipped_e_flag(BYTE *buffer, int x, int y, int sx, int sy); void __fastcall town_draw_clipped_town(BYTE *buffer, int x, int y, int sx, int sy, int some_flag); void __fastcall town_draw_lower(int x, int y, int sx, int sy, int a5, int some_flag); From fda317a24edf2e4b69b320943219068082bd3f6a Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 18 Mar 2019 03:23:24 +0100 Subject: [PATCH 4/8] Clean up storm/sound_update (#663) --- 3rdParty/Storm/Source/storm.cpp | 14 +++++++------- 3rdParty/Storm/Source/storm.h | 14 +++++++------- DiabloUI/connect.cpp | 2 +- DiabloUI/diabloui.h | 2 +- Source/effects.cpp | 29 ++++++++++------------------- Source/sound.cpp | 2 +- Source/sound.h | 2 +- 7 files changed, 28 insertions(+), 37 deletions(-) diff --git a/3rdParty/Storm/Source/storm.cpp b/3rdParty/Storm/Source/storm.cpp index 0ec510336..583be190c 100644 --- a/3rdParty/Storm/Source/storm.cpp +++ b/3rdParty/Storm/Source/storm.cpp @@ -64,13 +64,13 @@ int STORMAPI Ordinal224(int a1) rInt; BOOL STORMAPI SFileCloseArchive(HANDLE hArchive) rBool; BOOL STORMAPI SFileCloseFile(HANDLE hFile) rBool; -BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int a6, int a7) rBool; +BOOL STORMAPI SFileDdaBeginEx(HANDLE hFile, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int a6, int a7) rBool; BOOL STORMAPI SFileDdaDestroy() rBool; -BOOL STORMAPI SFileDdaEnd(HANDLE directsound) rBool; -BOOL STORMAPI SFileDdaGetPos(HANDLE directsound, int a2, int a3) rBool; +BOOL STORMAPI SFileDdaEnd(HANDLE hFile) rBool; +BOOL STORMAPI SFileDdaGetPos(HANDLE hFile, int *current, int *end) rBool; BOOL STORMAPI SFileDdaInitialize(HANDLE directsound) rBool; -BOOL STORMAPI SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume) rBool; +BOOL STORMAPI SFileDdaSetVolume(HANDLE hFile, signed int bigvolume, signed int volume) rBool; BOOL STORMAPI SFileDestroy() rBool; BOOL STORMAPI SFileGetFileArchive(HANDLE hFile, HANDLE *archive) rBool; @@ -96,7 +96,7 @@ BOOL STORMAPI SBltROP3Tiled(void *lpDstBuffer, RECT *lpDstRect, POINT *lpDstPt, BOOL STORMAPI SBmpDecodeImage(DWORD dwImgType, void *pSrcBuffer, DWORD dwSrcBuffersize, PALETTEENTRY *pPalette, void *pDstBuffer, DWORD dwDstBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) rBool; -BOOL STORMAPI SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, void *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *dwHeight, DWORD *pdwBpp) rBool; +BOOL STORMAPI SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) rBool; BOOL STORMAPI SBmpSaveImage(const char*, PALETTEENTRY*, void*, DWORD, DWORD, DWORD) rBool; HANDLE STORMAPI SBmpAllocLoadImage(const char *fileName, PALETTEENTRY *palette, void **buffer, int *width, int *height, int unused6, int unused7, void *(STORMAPI *allocFunction)(DWORD)) rPVoid; @@ -169,7 +169,7 @@ BOOL STORMAPI STransCreateI(void *pBuffer, int width, int height, int bpp, int a BOOL STORMAPI SVidDestroy() rBool; BOOL STORMAPI SVidGetSize(HANDLE video, int width, int height, int zero) rBool; BOOL STORMAPI SVidInitialize(HANDLE video) rBool; -BOOL STORMAPI SVidPlayBegin(char *filename, int arg4, int a3, int a4, int a5, int a6, HANDLE* video) rBool; +BOOL STORMAPI SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HANDLE *video) rBool; BOOL STORMAPI SVidPlayContinueSingle(HANDLE video, int a2, int a3) rBool; BOOL STORMAPI SVidPlayEnd(HANDLE video) rBool; @@ -246,6 +246,6 @@ void __stdcall SDlgSetCursor(HWND hWnd, HCURSOR a2, int a3, int *a4) rVoid; BOOL __stdcall SDlgSetTimer(int a1, int a2, int a3, void (__stdcall *a4)(int, int, int, int)) rBool; BOOL __stdcall SDlgKillTimer(int a1, int a2) rBool; BOOL __stdcall SDlgDrawBitmap(HWND hWnd, int a2, int a3, int a4, int a5, int a6, int a7) rBool; -BOOL __stdcall SDlgDialogBoxParam(HINSTANCE hInst, char *szDialog, int a3, WNDPROC func, int a5) rBool; +BOOL __stdcall SDlgDialogBoxParam(HINSTANCE hInst, char *szDialog, int hWnd, WNDPROC func, int selhero_is_good) rBool; BOOL __stdcall SGdiTextOut(void *pBuffer, int x, int y, int mask, char *str, int len) rBool; BOOL __stdcall SFileEnableDirectAccess(BOOL enable) rBool; diff --git a/3rdParty/Storm/Source/storm.h b/3rdParty/Storm/Source/storm.h index ab8f987c8..e5651a11a 100644 --- a/3rdParty/Storm/Source/storm.h +++ b/3rdParty/Storm/Source/storm.h @@ -470,13 +470,13 @@ int STORMAPI Ordinal224(int a1); BOOL STORMAPI SFileCloseArchive(HANDLE hArchive); BOOL STORMAPI SFileCloseFile(HANDLE hFile); -BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int a6, int a7); +BOOL STORMAPI SFileDdaBeginEx(HANDLE hFile, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int pan, int a7); BOOL STORMAPI SFileDdaDestroy(); -BOOL STORMAPI SFileDdaEnd(HANDLE directsound); -BOOL STORMAPI SFileDdaGetPos(HANDLE directsound, int a2, int a3); +BOOL STORMAPI SFileDdaEnd(HANDLE hFile); +BOOL STORMAPI SFileDdaGetPos(HANDLE hFile, int *current, int *end); BOOL STORMAPI SFileDdaInitialize(HANDLE directsound); -BOOL STORMAPI SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume); +BOOL STORMAPI SFileDdaSetVolume(HANDLE hFile, signed int bigvolume, signed int volume); BOOL STORMAPI SFileDestroy(); BOOL STORMAPI SFileGetFileArchive(HANDLE hFile, HANDLE *archive); @@ -594,7 +594,7 @@ STORMAPI SBmpLoadImage( const char *pszFileName, PALETTEENTRY *pPalette , - void *pBuffer, + BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, @@ -898,7 +898,7 @@ BOOL STORMAPI STransCreateI(void *pBuffer, int width, int height, int bpp, int a BOOL STORMAPI SVidDestroy(); BOOL STORMAPI SVidGetSize(HANDLE video, int width, int height, int zero); BOOL STORMAPI SVidInitialize(HANDLE video); -BOOL STORMAPI SVidPlayBegin(char *filename, int arg4, int a3, int a4, int a5, int a6, HANDLE* video); +BOOL STORMAPI SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HANDLE *video); BOOL STORMAPI SVidPlayContinueSingle(HANDLE video, int a2, int a3); BOOL STORMAPI SVidPlayEnd(HANDLE video); @@ -1308,7 +1308,7 @@ void __stdcall SDlgSetCursor(HWND hWnd, HCURSOR a2, int a3, int *a4); BOOL __stdcall SDlgSetTimer(int a1, int a2, int a3, void (__stdcall *a4)(int, int, int, int)); BOOL __stdcall SDlgKillTimer(int a1, int a2); BOOL __stdcall SDlgDrawBitmap(HWND hWnd, int a2, int a3, int a4, int a5, int a6, int a7); -BOOL __stdcall SDlgDialogBoxParam(HINSTANCE hInst, char *szDialog, int a3, WNDPROC func, int a5); +BOOL __stdcall SDlgDialogBoxParam(HINSTANCE hInst, char *szDialog, int hWnd, WNDPROC func, int selhero_is_good); BOOL __stdcall SGdiTextOut(void *pBuffer, int x, int y, int mask, char *str, int len); BOOL __stdcall SFileEnableDirectAccess(BOOL enable); diff --git a/DiabloUI/connect.cpp b/DiabloUI/connect.cpp index 1a23a6a80..f52e2853f 100644 --- a/DiabloUI/connect.cpp +++ b/DiabloUI/connect.cpp @@ -72,7 +72,7 @@ BOOL __cdecl Connect_LoadGFXAndStuff() // 100295C0: using guessed type int heroport_frames; // ref: 0x10003009 -BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, void *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) +BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) { BOOL result; // eax char pszFileName[260]; // [esp+8h] [ebp-104h] diff --git a/DiabloUI/diabloui.h b/DiabloUI/diabloui.h index 4a7768c5f..afc1bfa64 100644 --- a/DiabloUI/diabloui.h +++ b/DiabloUI/diabloui.h @@ -46,7 +46,7 @@ BOOL __stdcall UiSoundCallback(int a1, int type, int a3); void __stdcall UiMessageBoxCallback(HWND hWnd, char *lpText, LPCSTR lpCaption, UINT uType); BOOL __stdcall UiDrawDescCallback(int arg0, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8); BOOL __stdcall UiCreateGameCallback(int a1, int a2, int a3, int a4, int a5, int a6); -BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, void *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp); +BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp); int __stdcall UiSelectGame(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, _SNETVERSIONDATA *file_info, int *a6); int __stdcall UiSelectProvider(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, _SNETVERSIONDATA *file_info, int *type); BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, int mode, char *desc); diff --git a/Source/effects.cpp b/Source/effects.cpp index 3f1c64d41..bae460f44 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1145,27 +1145,18 @@ void __cdecl sound_stop() void __cdecl sound_update() { - //int v0; // ebp - //unsigned int v1; // ecx - // int v2; // eax - unsigned int v3; // [esp-Ch] [ebp-Ch] - unsigned int v4; // [esp-8h] [ebp-8h] - //int v5; // [esp-4h] [ebp-4h] - - if (gbSndInited) { - snd_update(0); - //v5 = v0; - //v4 = v1; - //v3 = v1; - if (sfx_stream) { - //_LOBYTE(v2) = SFileDdaGetPos(sfx_stream, (int)&v4, (int)&v3); - if (SFileDdaGetPos(sfx_stream, (int)&v4, (int)&v3)) { - if (v4 >= v3) - sfx_stop(); - } - } + int current, end; + + if (!gbSndInited) { + return; + } + + snd_update(FALSE); + if (sfx_stream != NULL && SFileDdaGetPos(sfx_stream, ¤t, &end) && current >= end) { + sfx_stop(); } } + // 415DBA: could not find valid save-restore pair for ebp void __cdecl effects_cleanup_sfx() diff --git a/Source/sound.cpp b/Source/sound.cpp index a7f894c15..b9ae59d05 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -4,7 +4,7 @@ LPDIRECTSOUNDBUFFER DSBs[8]; LPDIRECTSOUND sglpDS; -char gbSndInited; +BOOLEAN gbSndInited; int sglMusicVolume; int sglSoundVolume; HMODULE hDsound_dll; diff --git a/Source/sound.h b/Source/sound.h index 9ef9a2f2d..ffc0439f2 100644 --- a/Source/sound.h +++ b/Source/sound.h @@ -3,7 +3,7 @@ #define __SOUND_H__ extern IDirectSoundBuffer *DSBs[8]; -extern char gbSndInited; +extern BOOLEAN gbSndInited; extern HMODULE hDsound_dll; void __fastcall snd_update(BOOL bStopAll); From b209bebcaf566e768ef3a1fec82ca7f5fac01a15 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 18 Mar 2019 03:28:11 +0100 Subject: [PATCH 5/8] StoreStatOk bin exact (#670) --- Source/items.cpp | 17 ++++++++++------- Source/items.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index 707fecdb6..c2d166a13 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -4127,15 +4127,18 @@ void __fastcall UseItem(int p, int Mid, int spl) } } -BOOLEAN __fastcall StoreStatOk(ItemStruct *h) +BOOL __fastcall StoreStatOk(ItemStruct *h) { - BOOLEAN sf; // al + BOOL sf; + + sf = TRUE; + if (plr[myplr]._pStrength < h->_iMinStr) + sf = FALSE; + if (plr[myplr]._pMagic < h->_iMinMag) + sf = FALSE; + if (plr[myplr]._pDexterity < h->_iMinDex) + sf = FALSE; - sf = 1; - if (plr[myplr]._pStrength < h->_iMinStr - || plr[myplr]._pMagic < h->_iMinMag - || plr[myplr]._pDexterity < h->_iMinDex) - sf = 0; return sf; } diff --git a/Source/items.h b/Source/items.h index cd058139e..e8c86fbab 100644 --- a/Source/items.h +++ b/Source/items.h @@ -88,7 +88,7 @@ void __fastcall PrintItemMisc(ItemStruct *x); void __fastcall PrintItemDetails(ItemStruct *x); void __fastcall PrintItemDur(ItemStruct *x); void __fastcall UseItem(int p, int Mid, int spl); -BOOLEAN __fastcall StoreStatOk(ItemStruct *h); +BOOL __fastcall StoreStatOk(ItemStruct *h); BOOL __fastcall SmithItemOk(int i); int __fastcall RndSmithItem(int lvl); void __fastcall BubbleSwapItem(ItemStruct *a, ItemStruct *b); From ebd12dc9faa49ff14c596ff107b7e22651e6d18b Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Mon, 18 Mar 2019 00:36:50 -0500 Subject: [PATCH 6/8] Cleanup PrintQTextChr (#671) --- Source/minitext.cpp | 161 ++++++++++++++++++++++++++++++-------------- Source/minitext.h | 2 +- 2 files changed, 113 insertions(+), 50 deletions(-) diff --git a/Source/minitext.cpp b/Source/minitext.cpp index a7c7395f1..5838f7b52 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -94,59 +94,122 @@ void __cdecl DrawQTextBack() #include "asm_trans_rect.inc" } -void __fastcall PrintQTextChr(int screen_x, int screen_y, char *cel_buf, int frame) +void __fastcall PrintQTextChr(int sx, int sy, BYTE *pCelBuff, int nCel) { - char *v4; // ebx - char *v5; // esi - char *v6; // edi - int v7; // ebx - signed int v8; // edx - unsigned int v9; // eax - unsigned int v10; // ecx - char v11; // cf - unsigned int v12; // ecx - char *v13; // [esp+14h] [ebp-8h] - char *v14; // [esp+18h] [ebp-4h] + BYTE *dst, *pStart, *pEnd, *end, *tmp; - v13 = (char *)gpBuffer + screen_y_times_768[209]; - v14 = (char *)gpBuffer + screen_y_times_768[469]; - v4 = &cel_buf[4 * frame]; - v5 = &cel_buf[*(_DWORD *)v4]; - v6 = (char *)gpBuffer + screen_y_times_768[screen_y] + screen_x; - v7 = (int)&v5[*((_DWORD *)v4 + 1) - *(_DWORD *)v4]; - do { - v8 = 22; - do { - while (1) { - v9 = (unsigned char)*v5++; - if ((v9 & 0x80u) == 0) - break; - _LOBYTE(v9) = -(char)v9; - v6 += v9; - v8 -= v9; - if (!v8) - goto LABEL_15; - } - v8 -= v9; - if (v6 < v13 || v6 > v14) { - v5 += v9; - v6 += v9; - } else { - v10 = v9 >> 1; - if (!(v9 & 1) || (*v6 = *v5, ++v5, ++v6, v10)) { - v11 = v10 & 1; - v12 = v9 >> 2; - if (!v11 || (*(_WORD *)v6 = *(_WORD *)v5, v5 += 2, v6 += 2, v12)) { - qmemcpy(v6, v5, 4 * v12); - v5 += 4 * v12; - v6 += 4 * v12; + /// ASSERT: assert(gpBuffer); + + tmp = (BYTE *)gpBuffer; + dst = &tmp[sx + screen_y_times_768[sy]]; + pStart = &tmp[screen_y_times_768[209]]; + pEnd = &tmp[screen_y_times_768[469]]; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov ebx, pCelBuff + mov eax, nCel + shl eax, 2 + add ebx, eax + mov eax, [ebx+4] + sub eax, [ebx] + mov end, eax + mov esi, pCelBuff + add esi, [ebx] + mov edi, dst + mov ebx, end + add ebx, esi + label1: + mov edx, 22 + label2: + xor eax, eax + lodsb + or al, al + js label7 + sub edx, eax + cmp edi, pStart + jb label5 + cmp edi, pEnd + ja label5 + mov ecx, eax + shr ecx, 1 + jnb label3 + movsb + jecxz label6 + label3: + shr ecx, 1 + jnb label4 + movsw + jecxz label6 + label4: + rep movsd + jmp label6 + label5: + add esi, eax + add edi, eax + label6: + or edx, edx + jz label8 + jmp label2 + label7: + neg al + add edi, eax + sub edx, eax + jnz label2 + label8: + sub edi, 768 + 22 + cmp ebx, esi + jnz label1 + } +#else + int i; + BYTE width; + BYTE *src; + DWORD *pFrameTable; + + pFrameTable = (DWORD *)&pCelBuff[4 * nCel]; + src = &pCelBuff[pFrameTable[0]]; + end = &src[pFrameTable[1] - pFrameTable[0]]; + + for(; src != end; dst -= 768 + 22) { + for(i = 22; i;) { + width = *src++; + if(!(width & 0x80)) { + i -= width; + if(dst >= pStart && dst <= pEnd) { + if(width & 1) { + dst[0] = src[0]; + src++; + dst++; + } + width >>= 1; + if(width & 1) { + dst[0] = src[0]; + dst[1] = src[1]; + src += 2; + dst += 2; + } + width >>= 1; + for(; width; width--) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; + src += 4; + dst += 4; } + } else { + src += width; + dst += width; } + } else { + width = -(char)width; + dst += width; + i -= width; } - } while (v8); - LABEL_15: - v6 -= 790; - } while ((char *)v7 != v5); + } + } +#endif } void __cdecl DrawQText() @@ -211,7 +274,7 @@ void __cdecl DrawQText() if (*v0 == 10) ++v0; if (v10) - PrintQTextChr(screen_x, screen_y, (char *)pMedTextCels, v10); + PrintQTextChr(screen_x, screen_y, (BYTE *)pMedTextCels, v10); ++v9; screen_x += mfontkern[v10] + 2; v8 = *v9; diff --git a/Source/minitext.h b/Source/minitext.h index 8c7797047..fa27ae73c 100644 --- a/Source/minitext.h +++ b/Source/minitext.h @@ -14,7 +14,7 @@ void __cdecl FreeQuestText(); void __cdecl InitQuestText(); void __fastcall InitQTextMsg(int m); void __cdecl DrawQTextBack(); -void __fastcall PrintQTextChr(int screen_x, int screen_y, char *cel_buf, int frame); +void __fastcall PrintQTextChr(int sx, int sy, BYTE *pCelBuff, int nCel); void __cdecl DrawQText(); /* rdata */ From befd52c0039662ecd53f6f34640f1389d9bfb525 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Mon, 18 Mar 2019 08:28:38 -0500 Subject: [PATCH 7/8] Fix type for 'gpBuffer' (#672) --- Source/asm_trans_rect.inc | 2 +- Source/automap.cpp | 2 +- Source/capture.cpp | 2 +- Source/control.cpp | 13 +++--- Source/dx.cpp | 10 ++--- Source/dx.h | 2 +- Source/engine.cpp | 95 +++++++++++++++------------------------ Source/inv.cpp | 4 +- Source/items.cpp | 4 +- Source/minitext.cpp | 9 ++-- Source/scrollrt.cpp | 8 ++-- Source/town.cpp | 8 ++-- defs.h | 2 + structs.h | 16 ------- 14 files changed, 70 insertions(+), 107 deletions(-) diff --git a/Source/asm_trans_rect.inc b/Source/asm_trans_rect.inc index 643d62e73..12ef861a6 100644 --- a/Source/asm_trans_rect.inc +++ b/Source/asm_trans_rect.inc @@ -50,7 +50,7 @@ x2loop: #else // _MSC_VER && _M_IX86 { int row, col; - char *pix = &gpBuffer->row[TRANS_RECT_Y + TRANS_RECT_HEIGHT - 1].pixels[TRANS_RECT_X]; + BYTE *pix = &gpBuffer[SCREENXY(TRANS_RECT_X, TRANS_RECT_Y + TRANS_RECT_HEIGHT - 1)]; for (row = TRANS_RECT_HEIGHT >> 1; row != 0; row--) { for (col = TRANS_RECT_WIDTH >> 1; col != 0; col--) { *pix++ = 0; diff --git a/Source/automap.cpp b/Source/automap.cpp index e088e37e7..b5ab68b44 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -175,7 +175,7 @@ void __cdecl DrawAutomap() return; } - gpBufEnd = (unsigned char *)&gpBuffer->row[352]; + gpBufEnd = (unsigned char *)&gpBuffer[(352 + 160) * 768]; MapX = (ViewX - 16) >> 1; while (MapX + AutoMapXOfs < 0) diff --git a/Source/capture.cpp b/Source/capture.cpp index e47b9ebe2..fdb3ce54f 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -22,7 +22,7 @@ void __cdecl CaptureScreen() j_lock_buf_priv(2); success = CaptureHdr(hObject, 640, 480); if (success) { - success = CapturePix(hObject, 640, 480, 768, (BYTE *)gpBuffer->row[0].pixels); + success = CapturePix(hObject, 640, 480, 768, &gpBuffer[SCREENXY(0, 0)]); if (success) { success = CapturePal(hObject, palette); } diff --git a/Source/control.cpp b/Source/control.cpp index 9b57322eb..ebe526221 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -185,12 +185,11 @@ int SpellPages[6][7] = { void __fastcall DrawSpellCel(int xp, int yp, BYTE *Trans, int nCel, int w) { - BYTE *tmp, *dst, *tbl, *end; + BYTE *dst, *tbl, *end; /// ASSERT: assert(gpBuffer); - tmp = (BYTE *)gpBuffer; /* remove when fixed */ - dst = &tmp[screen_y_times_768[yp] + xp]; + dst = &gpBuffer[xp + screen_y_times_768[yp]]; tbl = SplTransTbl; #if (_MSC_VER >= 800) && (_MSC_VER <= 1200) @@ -844,7 +843,7 @@ void __fastcall DrawPanelBox(int x, int y, int w, int h, int sx, int sy) unsigned int v11; // ecx v6 = (char *)pBtmBuff + 640 * y + x; - v7 = &gpBuffer->row_unused_1[sy].col_unused_1[sx]; + v7 = (char *)&gpBuffer[768 * sy + sx]; v8 = h; do { v9 = w >> 1; @@ -870,7 +869,7 @@ void __fastcall SetFlaskHeight(char *buf, int min, int max, int c, int r) int v7; // edx v5 = &buf[88 * min]; - v6 = &gpBuffer->row_unused_1[r].col_unused_1[c]; + v6 = (char *)&gpBuffer[768 * r + c]; v7 = max - min; do { qmemcpy(v6, v5, 0x58u); @@ -2268,7 +2267,7 @@ void __cdecl RedBack() _LOWORD(v0) = v0 & 0xF400; v12 = v0 + 768 * 6; if (leveltype == DTYPE_HELL) { - v7 = gpBuffer->row[0].pixels; + v7 = (char *)&gpBuffer[SCREENXY(0, 0)]; _EBX = &pLightTbl[v12]; v9 = 352; do { @@ -2284,7 +2283,7 @@ void __cdecl RedBack() --v9; } while (v9); } else { - v1 = gpBuffer->row[0].pixels; + v1 = (char *)&gpBuffer[SCREENXY(0, 0)]; _EBX = &pLightTbl[v12]; v3 = 352; do { diff --git a/Source/dx.cpp b/Source/dx.cpp index c3f8add4d..76163720b 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -2,11 +2,11 @@ #include "../types.h" -Screen *sgpBackBuf; +BYTE *sgpBackBuf; LPDIRECTDRAW lpDDInterface; IDirectDrawPalette *lpDDPalette; // idb int sgdwLockCount; -Screen *gpBuffer; +BYTE *gpBuffer; IDirectDrawSurface *lpDDSBackBuf; IDirectDrawSurface *lpDDSPrimary; #ifdef _DEBUG @@ -128,7 +128,7 @@ void __cdecl dx_create_back_buffer() #else lpDDSPrimary->lpVtbl->Unlock(lpDDSPrimary, NULL); #endif - sgpBackBuf = (Screen *)DiabloAllocPtr(sizeof(Screen)); + sgpBackBuf = (BYTE *)DiabloAllocPtr(656 * 768); return; } if (error_code != DDERR_CANTLOCKSURFACE) @@ -238,7 +238,7 @@ void __cdecl lock_buf_priv() DDErrMsg(error_code, 235, "C:\\Src\\Diablo\\Source\\dx.cpp"); gpBufEnd += (int)ddsd.lpSurface; - gpBuffer = (Screen *)ddsd.lpSurface; + gpBuffer = (BYTE *)ddsd.lpSurface; sgdwLockCount++; } @@ -280,7 +280,7 @@ void __cdecl unlock_buf_priv() void __cdecl dx_cleanup() { - Screen *v0; // ecx + BYTE *v0; // ecx if (ghMainWnd) ShowWindow(ghMainWnd, SW_HIDE); diff --git a/Source/dx.h b/Source/dx.h index 8597def2d..e5ae74a8d 100644 --- a/Source/dx.h +++ b/Source/dx.h @@ -4,7 +4,7 @@ extern IDirectDraw *lpDDInterface; extern IDirectDrawPalette *lpDDPalette; // idb -extern Screen *gpBuffer; +extern BYTE *gpBuffer; extern IDirectDrawSurface *lpDDSBackBuf; extern IDirectDrawSurface *lpDDSPrimary; extern char gbBackBuf; // weak diff --git a/Source/engine.cpp b/Source/engine.cpp index 7bc1189d7..646e7c87b 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -119,7 +119,6 @@ void __fastcall CelDrawDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, void __fastcall CelDecodeOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) { - BYTE *tmp; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -129,11 +128,10 @@ void __fastcall CelDecodeOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(!pCelBuff) return; - tmp = (BYTE *)gpBuffer; pFrameTable = (DWORD *)pCelBuff; CelDrawDatOnly( - &tmp[sx + screen_y_times_768[sy]], + &gpBuffer[sx + screen_y_times_768[sy]], &pCelBuff[pFrameTable[nCel]], pFrameTable[nCel + 1] - pFrameTable[nCel], nWidth); @@ -162,7 +160,7 @@ void __fastcall CelDecDatOnly(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth) void __fastcall CelDrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int v1, v2, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -190,9 +188,8 @@ void __fastcall CelDrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWi else nDataSize -= v1; - tmp = (BYTE *)gpBuffer; CelDrawDatOnly( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[v1], nDataSize, nWidth); @@ -575,7 +572,7 @@ L_ODD: void __fastcall CelDecodeLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) { int nDataSize; - BYTE *pDecodeTo, *pRLEBytes, *tmp; + BYTE *pDecodeTo, *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -585,12 +582,11 @@ void __fastcall CelDecodeLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int if(!pCelBuff) return; - tmp = (BYTE *)gpBuffer; pFrameTable = (DWORD *)pCelBuff; nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; pRLEBytes = &pCelBuff[pFrameTable[nCel]]; - pDecodeTo = &tmp[sx + screen_y_times_768[sy]]; + pDecodeTo = &gpBuffer[sx + screen_y_times_768[sy]]; if(light_table_index) CelDecDatLightOnly(pDecodeTo, pRLEBytes, nDataSize, nWidth); @@ -602,7 +598,7 @@ void __fastcall CelDecodeLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int void __fastcall CelDecodeHdrLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize, v1, v2; - BYTE *pRLEBytes, *pDecodeTo, *tmp, *v9; + BYTE *pRLEBytes, *pDecodeTo, *v9; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -629,8 +625,7 @@ void __fastcall CelDecodeHdrLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, nDataSize = v1 - hdr; pRLEBytes = &v9[hdr]; - tmp = (BYTE *)gpBuffer; - pDecodeTo = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + pDecodeTo = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; if(light_table_index) CelDecDatLightOnly(pDecodeTo, pRLEBytes, nDataSize, nWidth); @@ -683,7 +678,7 @@ void __fastcall CelDecodeHdrLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, in void __fastcall CelDrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light) { int w, hdr, idx, nDataSize, v1; - BYTE *src, *dst, *tbl, *tmp, *pRLEBytes; + BYTE *src, *dst, *tbl, *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -709,8 +704,7 @@ void __fastcall CelDrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nDataSize = pFrameTable[1] - pFrameTable[0] - hdr; src = &pRLEBytes[hdr]; - tmp = (BYTE *)gpBuffer; - dst = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; idx = light4flag ? 1024 : 4096; if(light == 2) @@ -908,7 +902,7 @@ void __fastcall Cel2DecDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, void __fastcall Cel2DrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int v1, v2, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -936,9 +930,8 @@ void __fastcall Cel2DrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nW else nDataSize -= v1; - tmp = (BYTE *)gpBuffer; Cel2DecDatOnly( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[v1], nDataSize, nWidth); @@ -1351,7 +1344,7 @@ L_ODD: void __fastcall Cel2DecodeHdrLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize, v1; - BYTE *pRLEBytes, *pDecodeTo, *tmp, *v9; + BYTE *pRLEBytes, *pDecodeTo, *v9; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -1376,8 +1369,7 @@ void __fastcall Cel2DecodeHdrLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nDataSize = pFrameTable[1] - pFrameTable[0] - hdr; pRLEBytes = &v9[hdr]; - tmp = (BYTE *)gpBuffer; - pDecodeTo = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + pDecodeTo = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; if(light_table_index) Cel2DecDatLightOnly(pDecodeTo, pRLEBytes, nDataSize, nWidth); @@ -1426,7 +1418,7 @@ void __fastcall Cel2DecodeLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int void __fastcall Cel2DrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light) { int w, hdr, idx, nDataSize, v1; - BYTE *src, *dst, *tbl, *tmp, *pRLEBytes; + BYTE *src, *dst, *tbl, *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -1452,8 +1444,7 @@ void __fastcall Cel2DrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, in nDataSize = pFrameTable[1] - pFrameTable[0] - hdr; src = &pRLEBytes[hdr]; - tmp = (BYTE *)gpBuffer; - dst = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; idx = light4flag ? 1024 : 4096; if(light == 2) @@ -1665,7 +1656,7 @@ void __fastcall CelDecodeRect(BYTE *pBuff, int always_0, int hgt, int wdt, BYTE void __fastcall CelDecodeClr(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int w, hdr, nDataSize, v1; - BYTE *src, *dst, *tmp; + BYTE *src, *dst; /// ASSERT: assert(pCelBuff != NULL); if(!pCelBuff) @@ -1707,8 +1698,7 @@ void __fastcall CelDecodeClr(char col, int sx, int sy, BYTE *pCelBuff, int nCel, nDataSize -= hdr; src += hdr; - tmp = (BYTE *)gpBuffer; - dst = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; __asm { mov esi, src @@ -1773,8 +1763,7 @@ void __fastcall CelDecodeClr(char col, int sx, int sy, BYTE *pCelBuff, int nCel, src = &pRLEBytes[hdr]; end = &src[nDataSize]; - tmp = (BYTE *)gpBuffer; - dst = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; for(; src != end; dst -= 768 + nWidth) { for(w = nWidth; w;) { @@ -1804,7 +1793,7 @@ void __fastcall CelDecodeClr(char col, int sx, int sy, BYTE *pCelBuff, int nCel, void __fastcall CelDrawHdrClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int w, hdr, nDataSize, v1; - BYTE *src, *dst, *tmp; + BYTE *src, *dst; /// ASSERT: assert(pCelBuff != NULL); if(!pCelBuff) @@ -1846,8 +1835,7 @@ void __fastcall CelDrawHdrClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nC nDataSize -= hdr; src += hdr; - tmp = (BYTE *)gpBuffer; - dst = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; __asm { mov esi, src @@ -1937,8 +1925,7 @@ void __fastcall CelDrawHdrClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nC src = &pRLEBytes[hdr]; end = &src[nDataSize]; - tmp = (BYTE *)gpBuffer; - dst = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; for(; src != end; dst -= 768 + nWidth) { for(w = nWidth; w;) { @@ -2457,7 +2444,7 @@ void __fastcall Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel) void __fastcall Cl2DecodeFrm1(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -2485,9 +2472,8 @@ void __fastcall Cl2DecodeFrm1(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; Cl2DecDatFrm1( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth); @@ -2637,7 +2623,7 @@ void __fastcall Cl2DecDatFrm1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, i void __fastcall Cl2DecodeFrm2(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -2665,9 +2651,8 @@ void __fastcall Cl2DecodeFrm2(char col, int sx, int sy, BYTE *pCelBuff, int nCel if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; Cl2DecDatFrm2( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth, @@ -2839,7 +2824,7 @@ void __fastcall Cl2DecDatFrm2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, i void __fastcall Cl2DecodeFrm3(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light) { int hdr, idx, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -2873,9 +2858,8 @@ void __fastcall Cl2DecodeFrm3(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(light >= 4) idx += (light - 1) << 8; - tmp = (BYTE *)gpBuffer; Cl2DecDatLightTbl1( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth, @@ -3037,7 +3021,7 @@ void __fastcall Cl2DecDatLightTbl1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSi void __fastcall Cl2DecodeLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *pDecodeTo, *tmp; + BYTE *pRLEBytes, *pDecodeTo; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -3065,8 +3049,7 @@ void __fastcall Cl2DecodeLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; - pDecodeTo = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + pDecodeTo = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; if(light_table_index) Cl2DecDatLightTbl1(pDecodeTo, &pRLEBytes[hdr], nDataSize - hdr, nWidth, (BYTE *)&pLightTbl[light_table_index * 256]); @@ -3078,7 +3061,7 @@ void __fastcall Cl2DecodeLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int void __fastcall Cl2DecodeFrm4(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -3106,9 +3089,8 @@ void __fastcall Cl2DecodeFrm4(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; Cl2DecDatFrm4( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth); @@ -3272,7 +3254,7 @@ void __fastcall Cl2DecDatFrm4(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, i void __fastcall Cl2DecodeClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -3300,10 +3282,9 @@ void __fastcall Cl2DecodeClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCe if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; gpBufEnd -= 768; Cl2DecDatClrHL( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth, @@ -3489,7 +3470,7 @@ void __fastcall Cl2DecDatClrHL(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, void __fastcall Cl2DecodeFrm5(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light) { int hdr, idx, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -3523,9 +3504,8 @@ void __fastcall Cl2DecodeFrm5(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(light >= 4) idx += (light - 1) << 8; - tmp = (BYTE *)gpBuffer; Cl2DecDatLightTbl2( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth, @@ -3701,7 +3681,7 @@ void __fastcall Cl2DecDatLightTbl2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSi void __fastcall Cl2DecodeFrm6(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *pDecodeTo, *tmp; + BYTE *pRLEBytes, *pDecodeTo; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -3729,8 +3709,7 @@ void __fastcall Cl2DecodeFrm6(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; - pDecodeTo = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + pDecodeTo = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; if(light_table_index) Cl2DecDatLightTbl2(pDecodeTo, &pRLEBytes[hdr], nDataSize - hdr, nWidth, (BYTE *)&pLightTbl[light_table_index * 256]); diff --git a/Source/inv.cpp b/Source/inv.cpp index 9b92fee6a..403421673 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -281,8 +281,8 @@ void __cdecl DrawInv() CelDecodeHdrLightTrans( frame_width == INV_SLOT_SIZE_PX - ? (BYTE *)&gpBuffer->row[160].pixels[581] - : (BYTE *)&gpBuffer->row[160].pixels[567], + ? &gpBuffer[SCREENXY(581, 160)] + : &gpBuffer[SCREENXY(567, 160)], (BYTE *)pCursCels, frame, frame_width, 0, 8); cel_transparency_active = 0; diff --git a/Source/items.cpp b/Source/items.cpp index c2d166a13..fd19f153b 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3765,8 +3765,8 @@ void __fastcall DrawULine(int y) char *v2; // edi signed int v3; // edx - v1 = &gpBuffer->row[25].pixels[26]; - v2 = &gpBuffer->row_unused_1[0].pixels[screen_y_times_768[SStringY[y] + 198] + 26]; + v1 = (char *)&gpBuffer[SCREENXY(26, 25)]; + v2 = (char *)&gpBuffer[screen_y_times_768[SStringY[y] + 198] + 26 + 64]; v3 = 3; do { qmemcpy(v2, v1, 0x10A); /* find real fix */ diff --git a/Source/minitext.cpp b/Source/minitext.cpp index 5838f7b52..425b79ac0 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -96,14 +96,13 @@ void __cdecl DrawQTextBack() void __fastcall PrintQTextChr(int sx, int sy, BYTE *pCelBuff, int nCel) { - BYTE *dst, *pStart, *pEnd, *end, *tmp; + BYTE *dst, *pStart, *pEnd, *end; /// ASSERT: assert(gpBuffer); - tmp = (BYTE *)gpBuffer; - dst = &tmp[sx + screen_y_times_768[sy]]; - pStart = &tmp[screen_y_times_768[209]]; - pEnd = &tmp[screen_y_times_768[469]]; + dst = &gpBuffer[sx + screen_y_times_768[sy]]; + pStart = &gpBuffer[screen_y_times_768[209]]; + pEnd = &gpBuffer[screen_y_times_768[469]]; #if (_MSC_VER >= 800) && (_MSC_VER <= 1200) __asm { diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index d31d8d08a..dcfee5b53 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -2463,7 +2463,7 @@ void __fastcall DrawZoom(int x, int y) LABEL_24: v11 = (_WORD *)((char *)gpBuffer + a6b); v12 = (char *)gpBuffer + a5a; - v13 = &gpBuffer->row_unused_1[1].col_unused_1[a6b]; + v13 = (char *)&gpBuffer[a6b + 768]; v14 = 176; do { v15 = v19; @@ -2499,7 +2499,7 @@ void __cdecl ClearScreenBuffer() j_lock_buf_priv(3); for (i = 0; i < 480; i++) - memset(gpBuffer->row[i].pixels, 0, 640); + memset(&gpBuffer[SCREENXY(0, i)], 0, 640); j_unlock_buf_priv(3); } @@ -2627,7 +2627,7 @@ void __cdecl scrollrt_draw_cursor_back_buffer() if (sgdwCursWdt) { v1 = sgdwCursY; v2 = sgSaveBack; - v3 = &gpBuffer->row[sgdwCursY].pixels[sgdwCursX]; + v3 = (char *)&gpBuffer[SCREENXY(sgdwCursX, sgdwCursY)]; v4 = sgdwCursHgt; if (sgdwCursHgt) { v5 = sgdwCursHgt; @@ -2699,7 +2699,7 @@ void __cdecl scrollrt_draw_cursor_item() v14 = sgSaveBack; v6 = 1 - v3 + v5; sgdwCursHgt = v6; - v7 = &gpBuffer->row[v3].pixels[v2 & 0xFFFFFFFC]; + v7 = (char *)&gpBuffer[SCREENXY(v2 & 0xFFFFFFFC, v3)]; if (v6) { v8 = v6; do { diff --git a/Source/town.cpp b/Source/town.cpp index 94e44d7ba..c64689501 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -311,7 +311,7 @@ void __fastcall town_draw_lower(int x, int y, int sx, int sy, int a5, int some_f if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX && (level_cel_block = dPiece[x][y]) != 0) { v6 = sy; v7 = &screen_y_times_768[sy]; - a1 = (unsigned char *)&gpBuffer->row_unused_1[0].col_unused_1[*v7 + 32 + sx]; + a1 = (unsigned char *)&gpBuffer[*v7 + 32 + sx]; v25 = 1; v8 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y); do { @@ -770,7 +770,7 @@ void __fastcall town_draw_upper(int x, int y, int sx, int sy, int a5, int a6, in int v14; // esi int v15; // edi int v16; // eax - Screen *v17; // eax + BYTE *v17; // eax unsigned char *v18; // ebx char *v19; // edi int v20; // eax @@ -807,7 +807,7 @@ void __fastcall town_draw_upper(int x, int y, int sx, int sy, int a5, int a6, in v10 = v9 == 0; v11 = sy; if (!v10) { - a1 = (int *)&gpBuffer->row_unused_1[0].col_unused_1[sx + 32 + screen_y_times_768[sy]]; + a1 = (int *)&gpBuffer[sx + 32 + screen_y_times_768[sy]]; sxa = 0; v12 = &dpiece_defs_map_1[0][16 * gendung_get_dpiece_num_from_coord(x, y) + 1]; do { @@ -1164,7 +1164,7 @@ void __fastcall T_DrawZoom(int x, int y) LABEL_24: v11 = (_WORD *)((char *)gpBuffer + a5a); v12 = (char *)gpBuffer + a6b; - v13 = &gpBuffer->row_unused_1[1].col_unused_1[a5a]; + v13 = (char *)&gpBuffer[a5a + 768]; v14 = 176; do { v15 = v19; diff --git a/defs.h b/defs.h index 73729fd34..182830eee 100644 --- a/defs.h +++ b/defs.h @@ -83,6 +83,8 @@ #define PAL16_RED 224 #define PAL16_GRAY 240 +#define SCREENXY(x, y) ((x) + 64 + (((y) + 160) * 768)) + #ifndef INVALID_FILE_ATTRIBUTES #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) #endif diff --git a/structs.h b/structs.h index d70b2db20..24bb786b2 100644 --- a/structs.h +++ b/structs.h @@ -1187,22 +1187,6 @@ typedef struct DeadStruct { char _deadtrans; } DeadStruct; -////////////////////////////////////////////////// -// dx -////////////////////////////////////////////////// - -typedef struct ScreenRow { - char col_unused_1[64]; - char pixels[640]; - char col_unused_2[64]; -} ScreenRow; - -typedef struct Screen { /* create union for work data vs visible data */ - ScreenRow row_unused_1[160]; - ScreenRow row[480]; - ScreenRow row_unused_2[16]; -} Screen; - ////////////////////////////////////////////////// // diabloui ////////////////////////////////////////////////// From 1f809e5b31c319dc804f962511ab919245a43337 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Mon, 18 Mar 2019 08:29:49 -0500 Subject: [PATCH 8/8] Cleanup T_Fill Tile/Sector (#673) --- Source/town.cpp | 185 +++++++++++++++++++++++++++--------------------- 1 file changed, 106 insertions(+), 79 deletions(-) diff --git a/Source/town.cpp b/Source/town.cpp index c64689501..72d2340a7 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -1303,94 +1303,121 @@ void __cdecl town_init_dpiece_defs_map() // 5C3000: using guessed type int scr_pix_width; // 5C3004: using guessed type int scr_pix_height; -void __fastcall T_FillSector(unsigned char *P3Tiles, unsigned char *pSector, int xi, int yi, int w, int h) /* check 7 params: int AddSec */ +void __fastcall T_FillSector(unsigned char *P3Tiles, unsigned char *pSector, int xi, int yi, int w, int h) { - int v7; // ebx - int v8; // edx - int v9; // edi - int *v10; // ecx - int v11; // eax - unsigned char *v12; // esi - unsigned short v13; // ax - int v14; // eax - int v15; // [esp+4h] [ebp-14h] - int v16; // [esp+8h] [ebp-10h] - unsigned char *v17; // [esp+Ch] [ebp-Ch] - unsigned char *v18; // [esp+10h] [ebp-8h] - signed int v19; // [esp+14h] [ebp-4h] - int a4; // [esp+24h] [ebp+Ch] - int a6; // [esp+2Ch] [ebp+14h] + int i, j, xx, yy; + long v1, v2, v3, v4, ii; - v7 = h; - v17 = pSector; - v8 = yi; - v18 = P3Tiles; - v19 = 4; - if (h > 0) { - do { - v9 = w; - if (w > 0) { - v10 = &dPiece[1][v8 + 112 * xi]; - do { - v11 = *(unsigned short *)&v17[v19]; - if ((_WORD)v11) { - v12 = &v18[8 * (v11 - 1)]; - v13 = *(_WORD *)v12; - v12 += 2; - v14 = v13 + 1; - a4 = v14; - _LOWORD(v14) = *(_WORD *)v12; - v12 += 2; - a6 = ++v14; - _LOWORD(v14) = *(_WORD *)v12; - v16 = ++v14; - _LOWORD(v14) = *((_WORD *)v12 + 1); - v15 = v14 + 1; - } else { - a4 = 0; - a6 = 0; - v16 = 0; - v15 = 0; - } - v19 += 2; - *(v10 - 112) = a4; - *v10 = a6; - *(v10 - 111) = v16; - v10[1] = v15; - v10 += 224; - --v9; - } while (v9); + ii = 4; + yy = yi; + for(j = 0; j < h; j++) { + xx = xi; + for(i = 0; i < w; i++) { +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov esi, pSector + mov eax, ii + add esi, eax + xor eax, eax + lodsw + or eax, eax + jz label1 + dec eax + mov esi, P3Tiles + shl eax, 3 + add esi, eax + xor eax, eax + lodsw + inc eax + mov v1, eax + lodsw + inc eax + mov v2, eax + lodsw + inc eax + mov v3, eax + lodsw + inc eax + mov v4, eax + jmp label2 + label1: + mov v1, eax + mov v2, eax + mov v3, eax + mov v4, eax + label2: + nop } - v8 += 2; - --v7; - } while (v7); +#else + WORD *Map; + + Map = (WORD *)&pSector[ii]; + if(*Map) { + v1 = *((WORD *)&P3Tiles[(*Map-1)*8])+1; + v2 = *((WORD *)&P3Tiles[(*Map-1)*8]+1)+1; + v3 = *((WORD *)&P3Tiles[(*Map-1)*8]+2)+1; + v4 = *((WORD *)&P3Tiles[(*Map-1)*8]+3)+1; + } else { + v1 = 0; + v2 = 0; + v3 = 0; + v4 = 0; + } +#endif + dPiece[xx][yy] = v1; + dPiece[xx + 1][yy] = v2; + dPiece[xx][yy + 1] = v3; + dPiece[xx + 1][yy + 1] = v4; + xx += 2; + ii += 2; + } + yy += 2; } } void __fastcall T_FillTile(unsigned char *P3Tiles, int xx, int yy, int t) { - unsigned char *v4; // esi - unsigned short v5; // ax - int v6; // eax - int v7; // ST10_4 - int v8; // ST0C_4 - int v9; // ST08_4 + long v1, v2, v3, v4; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov eax, t + dec eax + mov esi, P3Tiles + shl eax, 3 + add esi, eax + xor eax, eax + lodsw + inc eax + mov v1, eax + lodsw + inc eax + mov v2, eax + lodsw + inc eax + mov v3, eax + lodsw + inc eax + mov v4, eax + jmp label1 + mov v1, eax + mov v2, eax + mov v3, eax + mov v4, eax + label1: + nop + } +#else + v1 = *((WORD *)&P3Tiles[(t-1)*8])+1; + v2 = *((WORD *)&P3Tiles[(t-1)*8]+1)+1; + v3 = *((WORD *)&P3Tiles[(t-1)*8]+2)+1; + v4 = *((WORD *)&P3Tiles[(t-1)*8]+3)+1; +#endif - v4 = &P3Tiles[8 * (t - 1)]; - v5 = *(_WORD *)v4; - v4 += 2; - v6 = v5 + 1; - v7 = v6; - _LOWORD(v6) = *(_WORD *)v4; - v4 += 2; - v8 = ++v6; - _LOWORD(v6) = *(_WORD *)v4; - v9 = ++v6; - _LOWORD(v6) = *((_WORD *)v4 + 1); - dPiece[xx][yy] = v7; - dPiece[xx + 1][yy] = v8; - dPiece[xx][yy + 1] = v9; - dPiece[xx + 1][yy + 1] = v6 + 1; + dPiece[xx][yy] = v1; + dPiece[xx + 1][yy] = v2; + dPiece[xx][yy + 1] = v3; + dPiece[xx + 1][yy + 1] = v4; } void __cdecl T_Pass3()