From 5ed7a29e223a0c544ee703ff7bdfc1e2571ff247 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Wed, 29 Aug 2018 00:28:00 -0500 Subject: [PATCH 01/10] render.cpp -> implement memset/memcpy --- Source/render.cpp | 700 +++++++++++++--------------------------------- 1 file changed, 188 insertions(+), 512 deletions(-) diff --git a/Source/render.cpp b/Source/render.cpp index 263252b1e..d59b8a0eb 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -2282,14 +2282,9 @@ LABEL_129: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; xx_32 -= 2; @@ -2310,14 +2305,9 @@ LABEL_129: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; yy_32 += 2; @@ -2336,11 +2326,12 @@ LABEL_129: xx_32 = 30; while ( tmp_pbDst >= (char *)gpBufEnd ) { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -2357,11 +2348,12 @@ LABEL_129: { if ( tmp_pbDst < (char *)gpBufEnd ) break; - for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - yy_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)yy_32) & 2 ) { @@ -2396,14 +2388,9 @@ LABEL_129: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; xx_32 -= 2; @@ -2445,11 +2432,12 @@ LABEL_129: xx_32 = 30; while ( tmp_pbDst >= (char *)gpBufEnd ) { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -2944,13 +2932,8 @@ LABEL_208: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; if ( !xx_32 ) @@ -2969,13 +2952,8 @@ LABEL_208: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; yy_32 += 2; @@ -3003,13 +2981,8 @@ LABEL_208: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; if ( !xx_32 ) @@ -3027,13 +3000,8 @@ LABEL_208: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst = &tmp_pbDst[yy_32 - 800]; yy_32 += 2; @@ -3063,13 +3031,8 @@ LABEL_208: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; if ( !xx_32 ) @@ -3118,13 +3081,8 @@ LABEL_208: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; if ( !xx_32 ) @@ -3175,7 +3133,6 @@ void __fastcall drawUpperScreen(unsigned char *pbDst) unsigned int chk_sh_and; // ecx MAPDST unsigned int n_draw_shift; // ecx MAPDST signed int i; // edx MAPDST - signed int j; // ecx MAPDST if ( cel_transparency_active ) { @@ -3224,16 +3181,9 @@ LABEL_22: { if ( tmp_pbDst < gpBufEnd ) break; - j = 8; - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --j; - } - while ( j ); - tmp_pbDst -= 800; + qmemcpy(tmp_pbDst, pdung_cels, 32); + pdung_cels += 32; + tmp_pbDst -= 768; --i; } while ( i ); @@ -3280,14 +3230,9 @@ LABEL_22: if ( !n_draw_shift ) continue; } - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } while ( yy_32 ); LABEL_133: @@ -3315,14 +3260,9 @@ LABEL_133: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; xx_32 -= 2; @@ -3343,14 +3283,9 @@ LABEL_133: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; yy_32 += 2; @@ -3369,11 +3304,12 @@ LABEL_133: xx_32 = 30; while ( tmp_pbDst >= gpBufEnd ) { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -3390,11 +3326,12 @@ LABEL_133: { if ( tmp_pbDst < gpBufEnd ) break; - for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - yy_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)yy_32) & 2 ) { @@ -3429,14 +3366,9 @@ LABEL_133: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; xx_32 -= 2; @@ -3447,16 +3379,9 @@ LABEL_133: { if ( tmp_pbDst < gpBufEnd ) break; - j = 8; - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --j; - } - while ( j ); - tmp_pbDst -= 800; + qmemcpy(tmp_pbDst, pdung_cels, 32); + pdung_cels += 32; + tmp_pbDst -= 768; --i; } while ( i ); @@ -3473,11 +3398,12 @@ LABEL_133: xx_32 = 30; while ( tmp_pbDst >= gpBufEnd ) { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -3494,16 +3420,9 @@ LABEL_133: { if ( tmp_pbDst < gpBufEnd ) break; - j = 8; - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --j; - } - while ( j ); - tmp_pbDst -= 800; + qmemcpy(tmp_pbDst, pdung_cels, 32); + pdung_cels += 32; + tmp_pbDst -= 768; --i; } while ( i ); @@ -3882,15 +3801,8 @@ LABEL_58: { if ( tmp_pbDst < gpBufEnd ) break; - j = 8; - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --j; - } - while ( j ); - tmp_pbDst -= 800; + memset(tmp_pbDst, 0, 32); + tmp_pbDst -= 768; --i; } while ( i ); @@ -3937,13 +3849,8 @@ LABEL_58: if ( !n_draw_shift ) continue; } - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } while ( yy_32 ); LABEL_205: @@ -3970,13 +3877,8 @@ LABEL_205: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; if ( !xx_32 ) @@ -3995,13 +3897,8 @@ LABEL_205: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; yy_32 += 2; @@ -4029,13 +3926,8 @@ LABEL_205: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; if ( !xx_32 ) @@ -4053,13 +3945,8 @@ LABEL_205: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst = &tmp_pbDst[yy_32 - 800]; yy_32 += 2; @@ -4089,13 +3976,8 @@ LABEL_205: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; if ( !xx_32 ) @@ -4105,15 +3987,8 @@ LABEL_205: { if ( tmp_pbDst < gpBufEnd ) break; - j = 8; - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --j; - } - while ( j ); - tmp_pbDst -= 800; + memset(tmp_pbDst, 0, 32); + tmp_pbDst -= 768; --i; } while ( i ); @@ -4139,13 +4014,8 @@ LABEL_205: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; if ( !xx_32 ) @@ -4155,15 +4025,8 @@ LABEL_205: { if ( tmp_pbDst < gpBufEnd ) break; - j = 8; - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --j; - } - while ( j ); - tmp_pbDst -= 800; + memset(tmp_pbDst, 0, 32); + tmp_pbDst -= 768; --i; } while ( i ); @@ -6720,13 +6583,8 @@ LABEL_252: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -6752,13 +6610,8 @@ LABEL_252: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -6789,13 +6642,8 @@ LABEL_252: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -6821,13 +6669,8 @@ LABEL_252: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -6859,13 +6702,8 @@ LABEL_252: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -6924,13 +6762,8 @@ LABEL_252: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -7547,14 +7380,9 @@ LABEL_162: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; yy_32 += 2; @@ -7579,14 +7407,9 @@ LABEL_162: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; xx_32 -= 2; @@ -7612,11 +7435,12 @@ LABEL_162: do { LABEL_175: - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -7646,11 +7470,12 @@ LABEL_180: } do { - for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - yy_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)yy_32) & 2 ) { @@ -7726,14 +7551,9 @@ LABEL_198: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; xx_32 -= 2; @@ -7794,11 +7614,12 @@ LABEL_217: } do { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -7880,22 +7701,10 @@ void __fastcall drawLowerScreen(unsigned char *pbDst) do { if ( tmp_pbDst < gpBufEnd ) - { - j = 8; - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --j; - } - while ( j ); - } + memset(tmp_pbDst, 0, 32); else - { pdung_cels += 32; - tmp_pbDst += 32; - } - tmp_pbDst -= 800; + tmp_pbDst -= 768; --i; } while ( i ); @@ -7943,13 +7752,8 @@ void __fastcall drawLowerScreen(unsigned char *pbDst) } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } } @@ -7985,13 +7789,8 @@ LABEL_232: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -8017,13 +7816,8 @@ LABEL_232: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -8054,13 +7848,8 @@ LABEL_232: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -8086,13 +7875,8 @@ LABEL_232: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -8124,13 +7908,8 @@ LABEL_232: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -8146,22 +7925,10 @@ LABEL_232: do { if ( tmp_pbDst < gpBufEnd ) - { - j = 8; - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --j; - } - while ( j ); - } + memset(tmp_pbDst, 0, 32); else - { pdung_cels += 32; - tmp_pbDst += 32; - } - tmp_pbDst -= 800; + tmp_pbDst -= 768; --i; } while ( i ); @@ -8184,13 +7951,8 @@ LABEL_232: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + memset(tmp_pbDst, 0, 4 * n_draw_shift); + tmp_pbDst += 4 * n_draw_shift; } } else @@ -8207,22 +7969,10 @@ LABEL_232: do { if ( tmp_pbDst < gpBufEnd ) - { - j = 8; - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --j; - } - while ( j ); - } + memset(tmp_pbDst, 0, 32); else - { pdung_cels += 32; - tmp_pbDst += 32; - } - tmp_pbDst -= 800; + tmp_pbDst -= 768; --i; } while ( i ); @@ -8635,23 +8385,9 @@ LABEL_116: do { if ( tmp_pbDst < gpBufEnd ) - { - j = 8; - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --j; - } - while ( j ); - } - else - { - pdung_cels += 32; - tmp_pbDst += 32; - } - tmp_pbDst -= 800; + qmemcpy(tmp_pbDst, pdung_cels, 32); + pdung_cels += 32; + tmp_pbDst -= 768; --i; } while ( i ); @@ -8700,14 +8436,9 @@ LABEL_116: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } } } @@ -8762,14 +8493,9 @@ LABEL_153: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } yy_32 += 2; tmp_pbDst -= 800; @@ -8794,14 +8520,9 @@ LABEL_153: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; xx_32 -= 2; @@ -8827,11 +8548,12 @@ LABEL_153: do { LABEL_166: - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -8861,11 +8583,12 @@ LABEL_171: } do { - for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - yy_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)yy_32) & 2 ) { @@ -8898,23 +8621,9 @@ LABEL_189: do { if ( tmp_pbDst < gpBufEnd ) - { - j = 8; - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --j; - } - while ( j ); - } - else - { - pdung_cels += 32; - tmp_pbDst += 32; - } - tmp_pbDst -= 800; + qmemcpy(tmp_pbDst, pdung_cels, 32); + pdung_cels += 32; + tmp_pbDst -= 768; --i; } while ( i ); @@ -8937,14 +8646,9 @@ LABEL_189: } if ( n_draw_shift ) { - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --n_draw_shift; - } - while ( n_draw_shift ); + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } tmp_pbDst -= 800; xx_32 -= 2; @@ -8970,23 +8674,9 @@ LABEL_205: do { if ( tmp_pbDst < gpBufEnd ) - { - j = 8; - do - { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; - --j; - } - while ( j ); - } - else - { - pdung_cels += 32; - tmp_pbDst += 32; - } - tmp_pbDst -= 800; + qmemcpy(tmp_pbDst, pdung_cels, 32); + pdung_cels += 32; + tmp_pbDst -= 768; --i; } while ( i ); @@ -8999,11 +8689,12 @@ LABEL_205: } do { - for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) + n_draw_shift = (unsigned int)(32 - xx_32) >> 2; + if ( n_draw_shift ) { - *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; - pdung_cels += 4; - tmp_pbDst += 4; + qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); + pdung_cels += 4 * n_draw_shift; + tmp_pbDst += 4 * n_draw_shift; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -9024,7 +8715,6 @@ void __fastcall world_draw_black_tile(unsigned char *pbDst) unsigned char *tmp_pbDst; // edi MAPDST signed int xx_32; // edx signed int i; // ebx MAPDST - signed int j; // ecx MAPDST signed int yy_32; // edx tmp_pbDst = pbDst; @@ -9032,15 +8722,8 @@ void __fastcall world_draw_black_tile(unsigned char *pbDst) for ( i = 1; ; ++i ) { tmp_pbDst += xx_32; - j = i; - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --j; - } - while ( j ); - tmp_pbDst = &tmp_pbDst[xx_32 - 832]; + memset(tmp_pbDst, 0, 4 * i); + tmp_pbDst = &tmp_pbDst[4 * i - 832 + xx_32]; if ( !xx_32 ) break; xx_32 -= 2; @@ -9050,15 +8733,8 @@ void __fastcall world_draw_black_tile(unsigned char *pbDst) do { tmp_pbDst += yy_32; - j = i; - do - { - *(_DWORD *)tmp_pbDst = 0; - tmp_pbDst += 4; - --j; - } - while ( j ); - tmp_pbDst = &tmp_pbDst[yy_32 - 832]; + memset(tmp_pbDst, 0, 4 * i); + tmp_pbDst = &tmp_pbDst[4 * i - 832 + yy_32]; --i; yy_32 += 2; } From 296f8b0e2b5c62f7a42821444b2c6f76ccc8fec6 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Wed, 29 Aug 2018 01:53:43 -0500 Subject: [PATCH 02/10] render.cpp -> optimized for speed --- Diablo.dsp | 1 + 1 file changed, 1 insertion(+) diff --git a/Diablo.dsp b/Diablo.dsp index 9b84140fa..4a63b3b99 100644 --- a/Diablo.dsp +++ b/Diablo.dsp @@ -358,6 +358,7 @@ SOURCE=.\Source\wave.cpp # Begin Source File SOURCE=.\Source\render.cpp +# ADD CPP /O2 # End Source File # End Group # Begin Group "Resource Files" From 21d611439f3cd8cf7dd34b04799b23b4655800a6 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Fri, 31 Aug 2018 23:36:48 -0500 Subject: [PATCH 03/10] Remove temp debug now that bugs are gone --- types.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/types.h b/types.h index cb0cdd4e3..ebf72d336 100644 --- a/types.h +++ b/types.h @@ -44,10 +44,6 @@ #include "3rdParty/Storm/Source/storm.h" #include "3rdParty/PKWare/pkware.h" -// temporarily enable debug features for all builds -#ifndef _DEBUG -#define _DEBUG -#endif // If defined, use copy protection [Default -> Defined] //#define COPYPROT // If defined, don't reload for debuggers [Default -> Undefined] From 9f206691b01845a733fc1340be3a52a76f59b085 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Fri, 31 Aug 2018 23:55:42 -0500 Subject: [PATCH 04/10] render.cpp -> undo memset/memcpy (#186) --- Diablo.dsp | 1 - Source/render.cpp | 700 +++++++++++++++++++++++++++++++++------------- 2 files changed, 512 insertions(+), 189 deletions(-) diff --git a/Diablo.dsp b/Diablo.dsp index 4a63b3b99..9b84140fa 100644 --- a/Diablo.dsp +++ b/Diablo.dsp @@ -358,7 +358,6 @@ SOURCE=.\Source\wave.cpp # Begin Source File SOURCE=.\Source\render.cpp -# ADD CPP /O2 # End Source File # End Group # Begin Group "Resource Files" diff --git a/Source/render.cpp b/Source/render.cpp index d59b8a0eb..263252b1e 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -2282,9 +2282,14 @@ LABEL_129: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; xx_32 -= 2; @@ -2305,9 +2310,14 @@ LABEL_129: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; yy_32 += 2; @@ -2326,12 +2336,11 @@ LABEL_129: xx_32 = 30; while ( tmp_pbDst >= (char *)gpBufEnd ) { - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -2348,12 +2357,11 @@ LABEL_129: { if ( tmp_pbDst < (char *)gpBufEnd ) break; - n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)yy_32) & 2 ) { @@ -2388,9 +2396,14 @@ LABEL_129: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; xx_32 -= 2; @@ -2432,12 +2445,11 @@ LABEL_129: xx_32 = 30; while ( tmp_pbDst >= (char *)gpBufEnd ) { - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -2932,8 +2944,13 @@ LABEL_208: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; if ( !xx_32 ) @@ -2952,8 +2969,13 @@ LABEL_208: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; yy_32 += 2; @@ -2981,8 +3003,13 @@ LABEL_208: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; if ( !xx_32 ) @@ -3000,8 +3027,13 @@ LABEL_208: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst = &tmp_pbDst[yy_32 - 800]; yy_32 += 2; @@ -3031,8 +3063,13 @@ LABEL_208: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; if ( !xx_32 ) @@ -3081,8 +3118,13 @@ LABEL_208: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; if ( !xx_32 ) @@ -3133,6 +3175,7 @@ void __fastcall drawUpperScreen(unsigned char *pbDst) unsigned int chk_sh_and; // ecx MAPDST unsigned int n_draw_shift; // ecx MAPDST signed int i; // edx MAPDST + signed int j; // ecx MAPDST if ( cel_transparency_active ) { @@ -3181,9 +3224,16 @@ LABEL_22: { if ( tmp_pbDst < gpBufEnd ) break; - qmemcpy(tmp_pbDst, pdung_cels, 32); - pdung_cels += 32; - tmp_pbDst -= 768; + j = 8; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --j; + } + while ( j ); + tmp_pbDst -= 800; --i; } while ( i ); @@ -3230,9 +3280,14 @@ LABEL_22: if ( !n_draw_shift ) continue; } - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } while ( yy_32 ); LABEL_133: @@ -3260,9 +3315,14 @@ LABEL_133: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; xx_32 -= 2; @@ -3283,9 +3343,14 @@ LABEL_133: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; yy_32 += 2; @@ -3304,12 +3369,11 @@ LABEL_133: xx_32 = 30; while ( tmp_pbDst >= gpBufEnd ) { - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -3326,12 +3390,11 @@ LABEL_133: { if ( tmp_pbDst < gpBufEnd ) break; - n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)yy_32) & 2 ) { @@ -3366,9 +3429,14 @@ LABEL_133: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; xx_32 -= 2; @@ -3379,9 +3447,16 @@ LABEL_133: { if ( tmp_pbDst < gpBufEnd ) break; - qmemcpy(tmp_pbDst, pdung_cels, 32); - pdung_cels += 32; - tmp_pbDst -= 768; + j = 8; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --j; + } + while ( j ); + tmp_pbDst -= 800; --i; } while ( i ); @@ -3398,12 +3473,11 @@ LABEL_133: xx_32 = 30; while ( tmp_pbDst >= gpBufEnd ) { - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -3420,9 +3494,16 @@ LABEL_133: { if ( tmp_pbDst < gpBufEnd ) break; - qmemcpy(tmp_pbDst, pdung_cels, 32); - pdung_cels += 32; - tmp_pbDst -= 768; + j = 8; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --j; + } + while ( j ); + tmp_pbDst -= 800; --i; } while ( i ); @@ -3801,8 +3882,15 @@ LABEL_58: { if ( tmp_pbDst < gpBufEnd ) break; - memset(tmp_pbDst, 0, 32); - tmp_pbDst -= 768; + j = 8; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --j; + } + while ( j ); + tmp_pbDst -= 800; --i; } while ( i ); @@ -3849,8 +3937,13 @@ LABEL_58: if ( !n_draw_shift ) continue; } - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } while ( yy_32 ); LABEL_205: @@ -3877,8 +3970,13 @@ LABEL_205: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; if ( !xx_32 ) @@ -3897,8 +3995,13 @@ LABEL_205: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; yy_32 += 2; @@ -3926,8 +4029,13 @@ LABEL_205: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; if ( !xx_32 ) @@ -3945,8 +4053,13 @@ LABEL_205: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst = &tmp_pbDst[yy_32 - 800]; yy_32 += 2; @@ -3976,8 +4089,13 @@ LABEL_205: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; if ( !xx_32 ) @@ -3987,8 +4105,15 @@ LABEL_205: { if ( tmp_pbDst < gpBufEnd ) break; - memset(tmp_pbDst, 0, 32); - tmp_pbDst -= 768; + j = 8; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --j; + } + while ( j ); + tmp_pbDst -= 800; --i; } while ( i ); @@ -4014,8 +4139,13 @@ LABEL_205: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; if ( !xx_32 ) @@ -4025,8 +4155,15 @@ LABEL_205: { if ( tmp_pbDst < gpBufEnd ) break; - memset(tmp_pbDst, 0, 32); - tmp_pbDst -= 768; + j = 8; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --j; + } + while ( j ); + tmp_pbDst -= 800; --i; } while ( i ); @@ -6583,8 +6720,13 @@ LABEL_252: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -6610,8 +6752,13 @@ LABEL_252: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -6642,8 +6789,13 @@ LABEL_252: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -6669,8 +6821,13 @@ LABEL_252: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -6702,8 +6859,13 @@ LABEL_252: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -6762,8 +6924,13 @@ LABEL_252: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -7380,9 +7547,14 @@ LABEL_162: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; yy_32 += 2; @@ -7407,9 +7579,14 @@ LABEL_162: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; xx_32 -= 2; @@ -7435,12 +7612,11 @@ LABEL_162: do { LABEL_175: - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -7470,12 +7646,11 @@ LABEL_180: } do { - n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)yy_32) & 2 ) { @@ -7551,9 +7726,14 @@ LABEL_198: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; xx_32 -= 2; @@ -7614,12 +7794,11 @@ LABEL_217: } do { - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -7701,10 +7880,22 @@ void __fastcall drawLowerScreen(unsigned char *pbDst) do { if ( tmp_pbDst < gpBufEnd ) - memset(tmp_pbDst, 0, 32); + { + j = 8; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --j; + } + while ( j ); + } else + { pdung_cels += 32; - tmp_pbDst -= 768; + tmp_pbDst += 32; + } + tmp_pbDst -= 800; --i; } while ( i ); @@ -7752,8 +7943,13 @@ void __fastcall drawLowerScreen(unsigned char *pbDst) } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } } @@ -7789,8 +7985,13 @@ LABEL_232: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -7816,8 +8017,13 @@ LABEL_232: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -7848,8 +8054,13 @@ LABEL_232: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -7875,8 +8086,13 @@ LABEL_232: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -7908,8 +8124,13 @@ LABEL_232: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -7925,10 +8146,22 @@ LABEL_232: do { if ( tmp_pbDst < gpBufEnd ) - memset(tmp_pbDst, 0, 32); + { + j = 8; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --j; + } + while ( j ); + } else + { pdung_cels += 32; - tmp_pbDst -= 768; + tmp_pbDst += 32; + } + tmp_pbDst -= 800; --i; } while ( i ); @@ -7951,8 +8184,13 @@ LABEL_232: } if ( n_draw_shift ) { - memset(tmp_pbDst, 0, 4 * n_draw_shift); - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } else @@ -7969,10 +8207,22 @@ LABEL_232: do { if ( tmp_pbDst < gpBufEnd ) - memset(tmp_pbDst, 0, 32); + { + j = 8; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --j; + } + while ( j ); + } else + { pdung_cels += 32; - tmp_pbDst -= 768; + tmp_pbDst += 32; + } + tmp_pbDst -= 800; --i; } while ( i ); @@ -8385,9 +8635,23 @@ LABEL_116: do { if ( tmp_pbDst < gpBufEnd ) - qmemcpy(tmp_pbDst, pdung_cels, 32); - pdung_cels += 32; - tmp_pbDst -= 768; + { + j = 8; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --j; + } + while ( j ); + } + else + { + pdung_cels += 32; + tmp_pbDst += 32; + } + tmp_pbDst -= 800; --i; } while ( i ); @@ -8436,9 +8700,14 @@ LABEL_116: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } } } @@ -8493,9 +8762,14 @@ LABEL_153: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } yy_32 += 2; tmp_pbDst -= 800; @@ -8520,9 +8794,14 @@ LABEL_153: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; xx_32 -= 2; @@ -8548,12 +8827,11 @@ LABEL_153: do { LABEL_166: - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -8583,12 +8861,11 @@ LABEL_171: } do { - n_draw_shift = (unsigned int)(32 - yy_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - yy_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)yy_32) & 2 ) { @@ -8621,9 +8898,23 @@ LABEL_189: do { if ( tmp_pbDst < gpBufEnd ) - qmemcpy(tmp_pbDst, pdung_cels, 32); - pdung_cels += 32; - tmp_pbDst -= 768; + { + j = 8; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --j; + } + while ( j ); + } + else + { + pdung_cels += 32; + tmp_pbDst += 32; + } + tmp_pbDst -= 800; --i; } while ( i ); @@ -8646,9 +8937,14 @@ LABEL_189: } if ( n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --n_draw_shift; + } + while ( n_draw_shift ); } tmp_pbDst -= 800; xx_32 -= 2; @@ -8674,9 +8970,23 @@ LABEL_205: do { if ( tmp_pbDst < gpBufEnd ) - qmemcpy(tmp_pbDst, pdung_cels, 32); - pdung_cels += 32; - tmp_pbDst -= 768; + { + j = 8; + do + { + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; + --j; + } + while ( j ); + } + else + { + pdung_cels += 32; + tmp_pbDst += 32; + } + tmp_pbDst -= 800; --i; } while ( i ); @@ -8689,12 +8999,11 @@ LABEL_205: } do { - n_draw_shift = (unsigned int)(32 - xx_32) >> 2; - if ( n_draw_shift ) + for ( n_draw_shift = (unsigned int)(32 - xx_32) >> 2; n_draw_shift; --n_draw_shift ) { - qmemcpy(tmp_pbDst, pdung_cels, 4 * n_draw_shift); - pdung_cels += 4 * n_draw_shift; - tmp_pbDst += 4 * n_draw_shift; + *(_DWORD *)tmp_pbDst = *(_DWORD *)pdung_cels; + pdung_cels += 4; + tmp_pbDst += 4; } if ( (32 - (_BYTE)xx_32) & 2 ) { @@ -8715,6 +9024,7 @@ void __fastcall world_draw_black_tile(unsigned char *pbDst) unsigned char *tmp_pbDst; // edi MAPDST signed int xx_32; // edx signed int i; // ebx MAPDST + signed int j; // ecx MAPDST signed int yy_32; // edx tmp_pbDst = pbDst; @@ -8722,8 +9032,15 @@ void __fastcall world_draw_black_tile(unsigned char *pbDst) for ( i = 1; ; ++i ) { tmp_pbDst += xx_32; - memset(tmp_pbDst, 0, 4 * i); - tmp_pbDst = &tmp_pbDst[4 * i - 832 + xx_32]; + j = i; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --j; + } + while ( j ); + tmp_pbDst = &tmp_pbDst[xx_32 - 832]; if ( !xx_32 ) break; xx_32 -= 2; @@ -8733,8 +9050,15 @@ void __fastcall world_draw_black_tile(unsigned char *pbDst) do { tmp_pbDst += yy_32; - memset(tmp_pbDst, 0, 4 * i); - tmp_pbDst = &tmp_pbDst[4 * i - 832 + yy_32]; + j = i; + do + { + *(_DWORD *)tmp_pbDst = 0; + tmp_pbDst += 4; + --j; + } + while ( j ); + tmp_pbDst = &tmp_pbDst[yy_32 - 832]; --i; yy_32 += 2; } From 0a1dcc5c0f7b44391bec6008bc84bfeb94c62739 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sat, 1 Sep 2018 00:38:30 -0500 Subject: [PATCH 05/10] Update missiles.cpp --- Source/missiles.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index a19d23d41..afdc1b20a 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -585,7 +585,7 @@ void __fastcall GetDamageAmt(int i, int *mind, int *maxd) *mind = v14; } v16 = maxd; - v5 = 2 * plr[myplr]._pLevel + 40; // BUG_FIX: 2 * (plr[myplr]._pLevel + 20) + 4 + v5 = 2 * plr[myplr]._pLevel + 40; /// BUGFIX: set to `2 * (plr[myplr]._pLevel + 20) + 4` *maxd = v5; if ( v4 <= 0 ) return; @@ -712,7 +712,7 @@ LABEL_43: *mind = v24; } v16 = maxd; - v5 = 2 * plr[myplr]._pLevel + 40; // BUG_FIX: 2 * (plr[myplr]._pLevel + 20) + 4 + v5 = 2 * plr[myplr]._pLevel + 40; /// BUGFIX: set to `2 * (plr[myplr]._pLevel + 20) + 4` *maxd = v5; if ( v4 <= 0 ) return; From 1120c0780d83e23a0b4ededd91cb240f32c3bed9 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sat, 1 Sep 2018 00:38:59 -0500 Subject: [PATCH 06/10] Update sound.cpp --- Source/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/sound.cpp b/Source/sound.cpp index 7142b3280..45e0b3060 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -367,7 +367,7 @@ void __fastcall sound_create_primary_buffer(int music_track) a2.cbSize = 0; } a2.nChannels = 2; - a2.nBlockAlign = 2 * a2.wBitsPerSample / 8; // a2.nChannels * x / 8 (BUG_FIX: per MSDN) + a2.nBlockAlign = 2 * a2.wBitsPerSample / 8; /// BUGFIX: should be `a2.nChannels * a2.wBitsPerSample / 8` a2.nAvgBytesPerSec = a2.nSamplesPerSec * a2.nBlockAlign; sglpDSB->SetFormat(&a2); } From 704380756d57ab168e1e206ed743efa6099fe043 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sat, 1 Sep 2018 00:40:03 -0500 Subject: [PATCH 07/10] Update player.h --- Source/player.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/player.h b/Source/player.h index 50eed7df3..627f48be4 100644 --- a/Source/player.h +++ b/Source/player.h @@ -20,7 +20,7 @@ extern int deathdelay; // weak extern int plr_dframe_size; // idb void __cdecl player_cpp_init(); -void __fastcall player_init_cl2_hdrs(char *src, char *dst); +void __fastcall SetPlayerGPtrs(char *pData, char *pAnim); /* unsigned char *+** */ void __fastcall LoadPlrGFX(int pnum, int gfxflag); void __fastcall InitPlayerGFX(int pnum); void __fastcall InitPlrGFXMem(int pnum); From 3b90e564297ae189fba712f89d47c54b3f099381 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sat, 1 Sep 2018 00:41:07 -0500 Subject: [PATCH 08/10] Update player.cpp --- Source/player.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/player.cpp b/Source/player.cpp index 03ab072c4..5bc577ab7 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -111,18 +111,18 @@ struct player_cpp_init // 47F204: using guessed type int player_inf; // 68643C: using guessed type int player_cpp_init_value; -void __fastcall player_init_cl2_hdrs(char *src, char *dst) +void __fastcall SetPlayerGPtrs(char *pData, char *pAnim) { char *v2; // eax int v3; // esi signed int v4; // edx - v2 = dst; - v3 = src - dst; + v2 = pAnim; + v3 = pData - pAnim; v4 = 8; do { - *(_DWORD *)v2 = (unsigned int)&src[*(_DWORD *)&v2[v3]]; + *(_DWORD *)v2 = (unsigned int)&pData[*(_DWORD *)&v2[v3]]; v2 += 4; --v4; } @@ -236,7 +236,7 @@ LABEL_27: LABEL_37: sprintf(arglist, "PlrGFX\\%s\\%s\\%s%s.CL2", v17, v15, v15, v19); LoadFileWithMem(arglist, v6); - player_init_cl2_hdrs((char *)v6, v7); + SetPlayerGPtrs((char *)v6, v7); v3->_pGFXLoad |= v18; v5 = leveltype; goto LABEL_38; @@ -816,7 +816,7 @@ LABEL_28: plr[v4]._pSplLvl[1] = 2; plr[v4]._pSplHotKey[0] = -1; plr[v4]._pSplHotKey[1] = -1; - plr[v4]._pSplHotKey[2] = -1; + plr[v4]._pSplHotKey[2] = -1; /// BUGFIX: clear all 4 hotkeys instead of 3 (demo leftover) if ( v19 ) { if ( v19 == 1 ) @@ -2341,7 +2341,7 @@ void __fastcall StartPlayerKill(int pnum, int earflag) PlaySfxLoc(v5, plr[v3 / 0x54D8].WorldX, plr[v3 / 0x54D8].WorldY); goto LABEL_18; } - PlaySfxLoc(PS_DEAD, plr[v3 / 0x54D8].WorldX, plr[v3 / 0x54D8].WorldY); /* BUG_FIX: uses wrong sound, should use PS_WARR71 */ + PlaySfxLoc(PS_DEAD, plr[v3 / 0x54D8].WorldX, plr[v3 / 0x54D8].WorldY); /// BUGFIX: uses Black Knight death sound, should use `PS_WARR71` LABEL_18: if ( plr[v3 / 0x54D8]._pgfxnum ) { From f49117c95a8e596efe5dfc5158274a0cd2a273fc Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sat, 1 Sep 2018 00:43:12 -0500 Subject: [PATCH 09/10] Update monster.cpp --- Source/monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 888330ba4..ecc70231f 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -7512,7 +7512,7 @@ void __cdecl ProcessMonsters() if ( v11 ) { v16 = monster[v1]._msquelch; - if ( v16 && monster[v1]._mAi != MT_DIABLO ) /* BUG_FIX: change '_mAi' to 'MType->mtype' */ + if ( v16 && monster[v1]._mAi != MT_DIABLO ) /// BUGFIX: test `MT_DIABLO` with 'MType->mtype' instead of '_mAi' monster[v1]._msquelch = v16 - 1; } else From 56d57d61c544261d848f9f7d2411d94b9e82e850 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sat, 1 Sep 2018 01:36:52 -0500 Subject: [PATCH 10/10] Update player.cpp --- Source/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/player.cpp b/Source/player.cpp index 5bc577ab7..08d9df8be 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -2341,7 +2341,7 @@ void __fastcall StartPlayerKill(int pnum, int earflag) PlaySfxLoc(v5, plr[v3 / 0x54D8].WorldX, plr[v3 / 0x54D8].WorldY); goto LABEL_18; } - PlaySfxLoc(PS_DEAD, plr[v3 / 0x54D8].WorldX, plr[v3 / 0x54D8].WorldY); /// BUGFIX: uses Black Knight death sound, should use `PS_WARR71` + PlaySfxLoc(PS_DEAD, plr[v3 / 0x54D8].WorldX, plr[v3 / 0x54D8].WorldY); /// BUGFIX: should use `PS_WARR71` like other classes LABEL_18: if ( plr[v3 / 0x54D8]._pgfxnum ) {