From b10b206efddf12124a2d24cff48b689183cbd98e Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Wed, 20 Mar 2019 20:19:44 -0500 Subject: [PATCH] Cleanup DRLG Pass3 (#719) --- Source/drlg_l2.cpp | 151 +++++++++++++++++++++------------------ Source/drlg_l3.cpp | 172 +++++++++++++++++++++++--------------------- Source/drlg_l4.cpp | 174 ++++++++++++++++++++++++--------------------- 3 files changed, 265 insertions(+), 232 deletions(-) diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index 6eb128e1b..2166b38b3 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -521,77 +521,86 @@ void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy) void __cdecl DRLG_L2Pass3() { - int v0; // eax - int *v1; // edx - int *v2; // eax - signed int v3; // ecx - signed int v4; // ebx - int *v5; // ecx - unsigned char *v6; // edx - unsigned short *v7; // esi - unsigned short v8; // ax - int v9; // eax - int v10; // ST24_4 - int v11; // ST20_4 - int v12; // ST1C_4 - signed int v13; // [esp+Ch] [ebp-1Ch] - int *v14; // [esp+10h] [ebp-18h] - int v15; // [esp+14h] [ebp-14h] - int v16; // [esp+18h] [ebp-10h] - int v17; // [esp+1Ch] [ebp-Ch] - int v18; // [esp+20h] [ebp-8h] - - v0 = *((unsigned short *)pMegaTiles + 44) + 1; - v18 = *((unsigned short *)pMegaTiles + 44) + 1; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 45); - v17 = ++v0; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 46); - v16 = ++v0; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 47); - v15 = v0 + 1; - v1 = dPiece[1]; - do { - v2 = v1; - v3 = 56; - do { - *(v2 - 112) = v18; - *v2 = v17; - *(v2 - 111) = v16; - v2[1] = v15; - v2 += 224; - --v3; - } while (v3); - v1 += 2; - } while ((signed int)v1 < (signed int)dPiece[2]); - v4 = 0; - v14 = &dPiece[17][16]; - do { - v5 = v14; - v6 = (unsigned char *)dungeon + v4; - v13 = 40; - do { - v7 = (unsigned short *)((char *)pMegaTiles + 8 * (*v6 - 1)); - v8 = *v7; - ++v7; - v9 = v8 + 1; - v10 = v9; - _LOWORD(v9) = *v7; - ++v7; - v11 = ++v9; - _LOWORD(v9) = *v7; - v12 = ++v9; - _LOWORD(v9) = v7[1]; - v6 += 40; - *(v5 - 112) = v10; - *v5 = v11; - *(v5 - 111) = v12; - v5[1] = v9 + 1; - v5 += 224; - --v13; - } while (v13); - v14 += 2; - ++v4; - } while (v4 < 40); + int i, j, xx, yy; + long v1, v2, v3, v4, lv; + + lv = 12-1; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov esi, pMegaTiles + mov eax, lv + 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 + } +#else + v1 = *((WORD *)&pMegaTiles[lv*8])+1; + v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1; + v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1; + v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1; +#endif + + for(j = 0; j < MAXDUNY; j += 2) { + for(i = 0; i < MAXDUNX; i += 2) { + dPiece[i][j] = v1; + dPiece[i+1][j] = v2; + dPiece[i][j+1] = v3; + dPiece[i+1][j+1] = v4; + } + } + + yy = 16; + for(j = 0; j < DMAXY; j++) { + xx = 16; + for(i = 0; i < DMAXX; i++) { + lv = (unsigned char)dungeon[i][j]-1; +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov esi, pMegaTiles + mov eax, lv + 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 + } +#else + v1 = *((WORD *)&pMegaTiles[lv*8])+1; + v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1; + v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1; + v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1; +#endif + dPiece[xx][yy] = v1; + dPiece[xx+1][yy] = v2; + dPiece[xx][yy+1] = v3; + dPiece[xx+1][yy+1] = v4; + xx += 2; + } + yy += 2; + } } void __fastcall LoadPreL2Dungeon(char *sFileName, int vx, int vy) diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index bea47fd4c..8cce4b5f5 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -2334,88 +2334,100 @@ BOOLEAN __fastcall WoodHorizR(int x, int j) void __cdecl DRLG_L3Pass3() { - int v0; // eax - int *v1; // esi - int *v2; // eax - signed int v3; // ecx - signed int v4; // ebx - int *v5; // ecx - unsigned char *v6; // edi - unsigned short *v7; // esi - unsigned short v8; // ax - int v9; // eax - signed int v10; // [esp+Ch] [ebp-1Ch] - int *v11; // [esp+10h] [ebp-18h] - int v12; // [esp+14h] [ebp-14h] - int v13; // [esp+18h] [ebp-10h] - int v14; // [esp+18h] [ebp-10h] - int v15; // [esp+1Ch] [ebp-Ch] - int v16; // [esp+1Ch] [ebp-Ch] - int v17; // [esp+20h] [ebp-8h] - int v18; // [esp+20h] [ebp-8h] - int v19; // [esp+24h] [ebp-4h] - int v20; // [esp+24h] [ebp-4h] - - v0 = *((unsigned short *)pMegaTiles + 28) + 1; - v19 = *((unsigned short *)pMegaTiles + 28) + 1; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 29); - v17 = ++v0; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 30); - v15 = ++v0; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 31); - v13 = v0 + 1; - v1 = dPiece[1]; - do { - v2 = v1; - v3 = 56; - do { - *(v2 - 112) = v19; - *v2 = v17; - *(v2 - 111) = v15; - v2[1] = v13; - v2 += 224; - --v3; - } while (v3); - v1 += 2; - } while ((signed int)v1 < (signed int)dPiece[2]); - v4 = 0; - v11 = &dPiece[17][16]; - do { - v5 = v11; - v6 = (unsigned char *)dungeon + v4; - v10 = 40; - do { - v12 = *v6 - 1; - if (v12 < 0) { - v20 = 0; - v18 = 0; - v16 = 0; - v14 = 0; + int i, j, xx, yy; + long v1, v2, v3, v4, lv; + + lv = 8-1; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov esi, pMegaTiles + mov eax, lv + 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 + } +#else + v1 = *((WORD *)&pMegaTiles[lv*8])+1; + v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1; + v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1; + v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1; +#endif + + for(j = 0; j < MAXDUNY; j += 2) { + for(i = 0; i < MAXDUNX; i += 2) { + dPiece[i][j] = v1; + dPiece[i+1][j] = v2; + dPiece[i][j+1] = v3; + dPiece[i+1][j+1] = v4; + } + } + + yy = 16; + for(j = 0; j < DMAXY; j++) { + xx = 16; + for(i = 0; i < DMAXX; i++) { + lv = (unsigned char)dungeon[i][j]-1; +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + if(lv >= 0) { + __asm { + mov esi, pMegaTiles + mov eax, lv + 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 + } } else { - v7 = (unsigned short *)((char *)pMegaTiles + 8 * v12); - v8 = *v7; - ++v7; - v9 = v8 + 1; - v20 = v9; - _LOWORD(v9) = *v7; - ++v7; - v18 = ++v9; - _LOWORD(v9) = *v7; - v16 = ++v9; - _LOWORD(v9) = v7[1]; - v14 = v9 + 1; + v1 = 0; + v2 = 0; + v3 = 0; + v4 = 0; } - v6 += 40; - *(v5 - 112) = v20; - *v5 = v18; - *(v5 - 111) = v16; - v5[1] = v14; - v5 += 224; - --v10; - } while (v10); - v11 += 2; - ++v4; - } while (v4 < 40); +#else + if(lv >= 0) { + v1 = *((WORD *)&pMegaTiles[lv*8])+1; + v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1; + v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1; + v4 = *((WORD *)&pMegaTiles[lv*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; + } + yy += 2; + } } void __fastcall LoadL3Dungeon(char *sFileName, int vx, int vy) diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index ab88f182f..69c0fd740 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -2856,86 +2856,98 @@ void __cdecl DRLG_L4Corners() void __cdecl DRLG_L4Pass3() { - int v0; // eax - int *v1; // esi - int *v2; // eax - signed int v3; // ecx - signed int v4; // ebx - int *v5; // ecx - unsigned char *v6; // edi - unsigned short *v7; // esi - unsigned short v8; // ax - int v9; // eax - signed int v10; // [esp+Ch] [ebp-1Ch] - int *v11; // [esp+10h] [ebp-18h] - int v12; // [esp+14h] [ebp-14h] - int v13; // [esp+18h] [ebp-10h] - int v14; // [esp+18h] [ebp-10h] - int v15; // [esp+1Ch] [ebp-Ch] - int v16; // [esp+1Ch] [ebp-Ch] - int v17; // [esp+20h] [ebp-8h] - int v18; // [esp+20h] [ebp-8h] - int v19; // [esp+24h] [ebp-4h] - int v20; // [esp+24h] [ebp-4h] - - v0 = *((unsigned short *)pMegaTiles + 116) + 1; - v19 = *((unsigned short *)pMegaTiles + 116) + 1; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 117); - v17 = ++v0; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 118); - v15 = ++v0; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 119); - v13 = v0 + 1; - v1 = dPiece[1]; - do { - v2 = v1; - v3 = 56; - do { - *(v2 - 112) = v19; - *v2 = v17; - *(v2 - 111) = v15; - v2[1] = v13; - v2 += 224; - --v3; - } while (v3); - v1 += 2; - } while ((signed int)v1 < (signed int)dPiece[2]); - v4 = 0; - v11 = &dPiece[17][16]; - do { - v5 = v11; - v6 = (unsigned char *)dungeon + v4; - v10 = 40; - do { - v12 = *v6 - 1; - if (v12 < 0) { - v20 = 0; - v18 = 0; - v16 = 0; - v14 = 0; + int i, j, xx, yy; + long v1, v2, v3, v4, lv; + + lv = 30-1; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov esi, pMegaTiles + mov eax, lv + 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 + } +#else + v1 = *((WORD *)&pMegaTiles[lv*8])+1; + v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1; + v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1; + v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1; +#endif + + for(j = 0; j < MAXDUNY; j += 2) { + for(i = 0; i < MAXDUNX; i += 2) { + dPiece[i][j] = v1; + dPiece[i+1][j] = v2; + dPiece[i][j+1] = v3; + dPiece[i+1][j+1] = v4; + } + } + + yy = 16; + for(j = 0; j < DMAXY; j++) { + xx = 16; + for(i = 0; i < DMAXX; i++) { + lv = (unsigned char)dungeon[i][j]-1; +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + if(lv >= 0) { + __asm { + mov esi, pMegaTiles + mov eax, lv + 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 + } } else { - v7 = (unsigned short *)((char *)pMegaTiles + 8 * v12); - v8 = *v7; - ++v7; - v9 = v8 + 1; - v20 = v9; - _LOWORD(v9) = *v7; - ++v7; - v18 = ++v9; - _LOWORD(v9) = *v7; - v16 = ++v9; - _LOWORD(v9) = v7[1]; - v14 = v9 + 1; - } - v6 += 40; - *(v5 - 112) = v20; - *v5 = v18; - *(v5 - 111) = v16; - v5[1] = v14; - v5 += 224; - --v10; - } while (v10); - v11 += 2; - ++v4; - } while (v4 < 40); + v1 = 0; + v2 = 0; + v3 = 0; + v4 = 0; + } +#else + if(lv >= 0) { + v1 = *((WORD *)&pMegaTiles[lv*8])+1; + v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1; + v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1; + v4 = *((WORD *)&pMegaTiles[lv*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; + } + yy += 2; + } }