Mercurial > mm7
changeset 1184:a90dc4aee8f4
arcomage refactoring continued
author | Gloval |
---|---|
date | Thu, 06 Jun 2013 08:33:43 +0400 |
parents | fa30ea497e94 |
children | 24454b5c9268 |
files | Arcomage.cpp Arcomage.h mm7_5.cpp |
diffstat | 3 files changed, 281 insertions(+), 249 deletions(-) [+] |
line wrap: on
line diff
--- a/Arcomage.cpp Thu Jun 06 00:58:07 2013 +0400 +++ b/Arcomage.cpp Thu Jun 06 08:33:43 2013 +0400 @@ -102,8 +102,8 @@ {100, 300, 50, 50, 5, 3, 5, 20, 10, 20, 0} }; - - +#define SIG_trpg 0x67707274 +#define SIG_xxxx 0x78787878 ArcomageGame *pArcomageGame = new ArcomageGame; ArcomageCard pCards[87]; @@ -111,7 +111,7 @@ Acromage_st1 struct_st1[10]; -stru272 array_4FAC10[10]; +stru272 array_4FABD0[10]; @@ -168,7 +168,204 @@ return a1->x >= pXYZW->x && a1->x <= pXYZW->z && (v2 = a1->y, v2 >= pXYZW->y) && v2 <= pXYZW->w; } - +//----- (0040DFD1) -------------------------------------------------------- +void stru272_stru0::_40DFD1(stru272_stru0 *a1) + { + stru272_stru0 *v2; // eax@1 + v2 = (stru272_stru0 *)malloc(0x5Cu); + a1 = v2; + v2->signature = SIG_trpg; + v2->field_8 = 0; + v2->field_30 = 0.0; + v2->field_58 = 0; + v2->field_59 = 0; + } + +//----- (0040DFFE) -------------------------------------------------------- +int stru272_stru0::_40DFFE() + { + + if ( this->signature == SIG_trpg ) + { + this->signature = SIG_xxxx; + free(this); + return 0; + } + else + return 2; + + } + +//----- (0040E01A) -------------------------------------------------------- +int stru272_stru0::_40E01A(int a2) + { + signed int result; // eax@2 + + auto a1 = this; + if ( a1->signature == SIG_trpg ) + { + a1->field_4 = *(int *)(a2 + 32); + a1->field_C = *(int *)a2 << 16; + a1->field_10 = *(int *)(a2 + 4) << 16; + a1->field_14 = *(int *)(a2 + 8) << 16; + a1->field_18 = *(int *)(a2 + 12) << 16; + a1->field_1C = *(int *)(a2 + 16); + a1->field_20 = *(int *)(a2 + 20); + a1->field_24 = *(int *)(a2 + 24); + a1->field_28 = *(float *)(a2 + 28) * 65536.0; + LODWORD(a1->field_2C) = *(int *)(a2 + 36); + a1->field_34 = (signed __int64)(*(float *)(a2 + 40) * 65536.0); + a1->field_38 = (signed __int64)(*(float *)(a2 + 44) * 65536.0); + a1->field_3C = *(int *)(a2 + 48); + a1->field_40 = *(int *)(a2 + 52); +// a1->field_54 = *(int *)(a2 + 56); + a1->field_59 = 1; + result = 0; + } + else + { + result = 2; + } + return result; + } + +//----- (0040E0F5) -------------------------------------------------------- +int stru272_stru0::_40E0F5(char a2, char a3) + { + signed int result; // eax@2 + int v4; // edx@7 + int v5; // eax@7 + + auto a1 = this; + if ( a1->signature == SIG_trpg) + { + if ( a2 ) + { + a1->field_8 = 0; + a1->field_30 = 0.0; + } + if ( a1->field_59 && a3 ) + { + v4 = a1->field_4; + // v5 = a1->field_54; + do + { + *(int *)v5 = 0; + v5 += 28; + --v4; + } + while ( v4 ); + a1->field_58 = 0; + } + result = 0; + } + else + { + result = 2; + } + return result; + } + +//----- (0040E133) -------------------------------------------------------- +int stru272_stru0::_40E133() + { + stru272_stru0 *v1; // edi@1 + int v3; // ST18_4@3 + double v4; // st7@3 + double v5; // st6@4 + char v6; // bl@8 + int v7; // esi@8 + int v8; // ecx@10 + signed int v9; // eax@10 + int v10; // ecx@10 + signed int v11; // eax@10 + signed int v12; // edx@12 + signed int v13; // edx@12 + int v14; // [sp+8h] [bp-10h]@8 + int v15; // [sp+Ch] [bp-Ch]@8 + float v16; // [sp+14h] [bp-4h]@3 + + v1 = this; + if ( this->signature != SIG_trpg ) + return 2; + v3 = this->field_8; + v16 = this->field_30; + v4 = (double)v3; + if ( v3 > 0 ) + { + v5 = v16 + this->field_2C; + v16 = v5; + if ( v5 > v4 ) + v16 = v4; + } + if ( v16 >= 1.0 || this->field_58 ) + { + v6 = 0; + // v7 = this->field_54; + v14 = (signed __int64)this->field_28; + v15 = this->field_4; + while ( *(int *)v7 <= 0 ) + { + if ( v16 >= 1.0 ) + { + *(int *)v7 = v1->field_3C + rand() % (v1->field_40 - v1->field_3C + 1); + *(int *)(v7 + 20) = (rand() % 17 - 8) << 16; + *(int *)(v7 + 24) = (rand() % 17 - 8) << 16; + v12 = v1->field_C + rand() % (v1->field_14 - 1 - v1->field_C + 1); + *(int *)(v7 + 12) = v12; + *(int *)(v7 + 4) = v12 >> 16; + v16 = v16 - 1.0; + v13 = v1->field_10 + rand() % (v1->field_18 - 1 - v1->field_10 + 1); + *(int *)(v7 + 16) = v13; + *(int *)(v7 + 8) = v13 >> 16; + --v1->field_8; + goto LABEL_13; + } +LABEL_14: + v7 += 28; + --v15; + if ( !v15 ) + { + v1->field_58 = v6; + v1->field_30 = v16; + return 0; + } + } + v8 = *(int *)(v7 + 20); + --*(int *)v7; + v9 = v8 + *(int *)(v7 + 12); + v10 = v14 + *(int *)(v7 + 24); + *(int *)(v7 + 12) = v9; + *(int *)(v7 + 4) = v9 >> 16; + v11 = v10 + *(int *)(v7 + 16); + *(int *)(v7 + 24) = v10; + *(int *)(v7 + 16) = v11; + *(int *)(v7 + 8) = v11 >> 16; +LABEL_13: + v6 = 1; + goto LABEL_14; + } + return 0; + } + +//----- (0040E2A7) -------------------------------------------------------- +int stru272_stru0::_40E2A7() + { + int result; // eax@2 + + if ( this->signature == SIG_trpg ) + { + if ( this->field_8 <= 0 ) + result = this->field_58 != 0 ? 2 : 0; + else + result = 1; + } + else + { + result = 3; + } + return result; + } //----- (0040DFAF) -------------------------------------------------------- @@ -1370,14 +1567,11 @@ } pVideoPlayer->BinkUpdatePalette(dword_4FAA28); - /*v3 = array_4FAC10; - do - { - v3->ptr_0->_40E0F5(1, 1); - v3->ptr_0->_40DFFE(); - ++v3; - } - while ( (signed int)v3 < (signed int)&unk_5052C8 );*/ + for(int i=0; i<10; ++i) + { + array_4FABD0[i].field_40->_40E0F5(1,1); + array_4FABD0[i].field_40->_40DFFE(); + } pArcomageGame->pGameBackground.Release(); pArcomageGame->pSprites.Release(); @@ -1567,7 +1761,7 @@ *v7 = 1; dword_505314[v4] = dword_505554[v6]; result = byte_5054E8[v6]; - array_4FAC10[9].field_4[v4++ + 4232] = result;//затирает pArcomageGame + //array_4FABD0[9].field_4[v4++ + 4232] = result;//затирает pArcomageGame } while ( v4 < 108 ); dword_4FABC8 = 0; @@ -1616,11 +1810,11 @@ am_40A198(); v2 = dword_4FABC8; } - if ( !array_4FAC10[9].field_4[v2 + 4232] ) + /*if ( !array_4FABD0[9].field_4[v2 + 4232] ) { v3 = dword_505314[v2]; v5 = 1; - } + }*/ ++v2; dword_4FABC8 = v2; } @@ -2054,7 +2248,7 @@ am_EndScene(); am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); am_40B76F(v1); - v2 = (stru272_stru0 **)array_4FAC10; + v2 = (stru272_stru0 **)array_4FABD0; do { if ( *((unsigned char *)v2 - 64) ) @@ -2132,7 +2326,7 @@ } v0 += 4268; } - while ( v0 < (signed int)&array_4FAC10[9].field_4[4201] ); + while ( v0 < 1);//(signed int)&array_4FABD0[9].field_4[4201] ); } //----- (0040AB0A) -------------------------------------------------------- @@ -5342,7 +5536,7 @@ v2 = a2; v3 = a1; v4 = byte_4FABD0; - v12 = (stru272_stru0 **)array_4FAC10; + v12 = (stru272_stru0 **)array_4FABD0; while ( *v4 ) { result = (*v12)->_40E2A7(); @@ -5374,7 +5568,7 @@ dword_4FABDC[v6 / 4] = v3->x + 20; dword_4FABD8[v6 / 4] = v3->y - 20; dword_4FABE0[v6 / 4] = v3->y + 20; - v7 = array_4FAC10[v6 / 0x10AC].ptr_0; + // v7 = array_4FABD0[v6 / 0x10AC] dword_4FABE4[v6 / 4] = -60; dword_4FABE8[v6 / 4] = 60; dword_4FABEC[v6 / 4] = 180; @@ -5385,12 +5579,12 @@ dword_4FAC00[v6 / 4] = 0x41000000u; dword_4FAC04[v6 / 4] = 5; dword_4FAC08[v6 / 4] = 15; - dword_4FAC0C[v6 / 4] = (int)array_4FAC10[v6 / 0x10AC].field_4; + dword_4FAC0C[v6 / 4] = (int)array_4FABD0[v6 / 0x10AC].field_4; v7->_40E01A((int)((char *)&unk_4FABD4 + v6)); if ( 10 * v2 > 150 ) v2 = 15; - v8 = array_4FAC10[v6 / 0x10AC].ptr_0; - if ( v8->field_0 != 0x67707274 ) +// v8 = array_4FABD0[v6 / 0x10AC].ptr_0; + if ( v8->signature != SIG_trpg ) return 2; if ( !v8->field_59 ) return 3; @@ -5402,13 +5596,13 @@ v8->field_4C = 0; v8->field_48 = 0; v8->field_50 = 0; - v10 = v8->field_54; + /*v10 = v8->field_54; do { - *(unsigned int *)v10 = 0; - v10 += 28; - --v9; - } + *(unsigned int *)v10 = 0; + v10 += 28; + --v9; + }*/ while ( v9 ); return 0; } @@ -5739,14 +5933,10 @@ for (int i=0; i<12; ++i) am_sounds[i] = pSoundList->LoadSound(v4++, 0); - //v5 = array_4FAC10; - //do - //{ - // v5->_40DFD1(); - // ++v5; - //} - //while ( (signed int)v5 < 10 );//(signed int)&unk_5052C8 ); - + + for (int i=0; i<10; ++i) + array_4FABD0[i].field_40->_40DFD1(array_4FABD0[i].field_40); + dword_4FABBC = -1; amuint_4FAA4C = -1; byte_4FAA74 = 0;
--- a/Arcomage.h Thu Jun 06 00:58:07 2013 +0400 +++ b/Arcomage.h Thu Jun 06 08:33:43 2013 +0400 @@ -199,19 +199,31 @@ extern ArcomagePlayer am_Players[2]; - +#pragma pack(push, 1) +struct stru272_stru1 + { + int field_0; + int field_4; + int field_8; + int field_C; + int field_10; + int field_14; + int field_18; + }; +#pragma pack(pop) /* 270 */ #pragma pack(push, 1) struct stru272_stru0 // ARCOMAGE stuff { + static void _40DFD1(stru272_stru0 *a1); int _40DFFE(); int _40E01A(int a2); int _40E0F5(char a2, char a3); int _40E133(); int _40E2A7(); - int field_0; + int signature; int field_4; int field_8; int field_C; @@ -232,7 +244,7 @@ int field_48; int field_4C; int field_50; - int field_54; + stru272_stru1 * field_54; char field_58; char field_59; char field_5A; @@ -242,15 +254,48 @@ /* 266 */ +//#pragma pack(push, 1) +//struct stru272 +//{ +// void _40DFD1(); +// +// struct stru272_stru0 *ptr_0; +// char field_4[4264]; +//}; +//#pragma pack(pop) + + + + + + #pragma pack(push, 1) struct stru272 -{ - void _40DFD1(); - - struct stru272_stru0 *ptr_0; - char field_4[4264]; -}; + { + char field_0; + char field_1; + char field_2; + char field_3; + int field_4; + int field_8; + int field_C; + int field_10; + int field_14; + int field_18; + int field_1C; + float field_20f; + int field_24; + float field_28f; + float field_2Cf; + float field_30f; + int field_34; + int field_38; + int field_3C; + stru272_stru0 *field_40; + stru272_stru1 field_44[150]; + }; #pragma pack(pop) -extern stru272 array_4FAC10[10]; \ No newline at end of file + +extern stru272 array_4FABD0[10]; \ No newline at end of file
--- a/mm7_5.cpp Thu Jun 06 00:58:07 2013 +0400 +++ b/mm7_5.cpp Thu Jun 06 08:33:43 2013 +0400 @@ -9034,210 +9034,7 @@ } // 40DFA7: using guessed type int __stdcall retzero_sub_40DFA7(int); -//----- (0040DFD1) -------------------------------------------------------- -void stru272::_40DFD1() -{ - stru272 *v1; // esi@1 - stru272_stru0 *v2; // eax@1 - - v1 = this; - v2 = (stru272_stru0 *)malloc(0x5Cu); - v1->ptr_0 = v2; - v2->field_0 = 0x67707274u; - v1->ptr_0->field_8 = 0; - v1->ptr_0->field_30 = 0.0; - v1->ptr_0->field_58 = 0; - v1->ptr_0->field_59 = 0; -} - -//----- (0040DFFE) -------------------------------------------------------- -int stru272_stru0::_40DFFE() -{ - signed int result; // eax@2 - - if ( this->field_0 == 0x67707274 ) - { - this->field_0 = 0x78787878u; - free(this); - result = 0; - } - else - { - result = 2; - } - return result; -} - -//----- (0040E01A) -------------------------------------------------------- -int stru272_stru0::_40E01A(int a2) -{ - signed int result; // eax@2 - - auto a1 = this; - if ( a1->field_0 == 0x67707274 ) - { - a1->field_4 = *(int *)(a2 + 32); - a1->field_C = *(int *)a2 << 16; - a1->field_10 = *(int *)(a2 + 4) << 16; - a1->field_14 = *(int *)(a2 + 8) << 16; - a1->field_18 = *(int *)(a2 + 12) << 16; - a1->field_1C = *(int *)(a2 + 16); - a1->field_20 = *(int *)(a2 + 20); - a1->field_24 = *(int *)(a2 + 24); - a1->field_28 = *(float *)(a2 + 28) * 65536.0; - LODWORD(a1->field_2C) = *(int *)(a2 + 36); - a1->field_34 = (signed __int64)(*(float *)(a2 + 40) * 65536.0); - a1->field_38 = (signed __int64)(*(float *)(a2 + 44) * 65536.0); - a1->field_3C = *(int *)(a2 + 48); - a1->field_40 = *(int *)(a2 + 52); - a1->field_54 = *(int *)(a2 + 56); - a1->field_59 = 1; - result = 0; - } - else - { - result = 2; - } - return result; -} - -//----- (0040E0F5) -------------------------------------------------------- -int stru272_stru0::_40E0F5(char a2, char a3) -{ - signed int result; // eax@2 - int v4; // edx@7 - int v5; // eax@7 - - auto a1 = this; - if ( a1->field_0 == 0x67707274 ) - { - if ( a2 ) - { - a1->field_8 = 0; - a1->field_30 = 0.0; - } - if ( a1->field_59 && a3 ) - { - v4 = a1->field_4; - v5 = a1->field_54; - do - { - *(int *)v5 = 0; - v5 += 28; - --v4; - } - while ( v4 ); - a1->field_58 = 0; - } - result = 0; - } - else - { - result = 2; - } - return result; -} - -//----- (0040E133) -------------------------------------------------------- -int stru272_stru0::_40E133() -{ - stru272_stru0 *v1; // edi@1 - int v3; // ST18_4@3 - double v4; // st7@3 - double v5; // st6@4 - char v6; // bl@8 - int v7; // esi@8 - int v8; // ecx@10 - signed int v9; // eax@10 - int v10; // ecx@10 - signed int v11; // eax@10 - signed int v12; // edx@12 - signed int v13; // edx@12 - int v14; // [sp+8h] [bp-10h]@8 - int v15; // [sp+Ch] [bp-Ch]@8 - float v16; // [sp+14h] [bp-4h]@3 - - v1 = this; - if ( this->field_0 != 0x67707274 ) - return 2; - v3 = this->field_8; - v16 = this->field_30; - v4 = (double)v3; - if ( v3 > 0 ) - { - v5 = v16 + this->field_2C; - v16 = v5; - if ( v5 > v4 ) - v16 = v4; - } - if ( v16 >= 1.0 || this->field_58 ) - { - v6 = 0; - v7 = this->field_54; - v14 = (signed __int64)this->field_28; - v15 = this->field_4; - while ( *(int *)v7 <= 0 ) - { - if ( v16 >= 1.0 ) - { - *(int *)v7 = v1->field_3C + rand() % (v1->field_40 - v1->field_3C + 1); - *(int *)(v7 + 20) = (rand() % 17 - 8) << 16; - *(int *)(v7 + 24) = (rand() % 17 - 8) << 16; - v12 = v1->field_C + rand() % (v1->field_14 - 1 - v1->field_C + 1); - *(int *)(v7 + 12) = v12; - *(int *)(v7 + 4) = v12 >> 16; - v16 = v16 - 1.0; - v13 = v1->field_10 + rand() % (v1->field_18 - 1 - v1->field_10 + 1); - *(int *)(v7 + 16) = v13; - *(int *)(v7 + 8) = v13 >> 16; - --v1->field_8; - goto LABEL_13; - } -LABEL_14: - v7 += 28; - --v15; - if ( !v15 ) - { - v1->field_58 = v6; - v1->field_30 = v16; - return 0; - } - } - v8 = *(int *)(v7 + 20); - --*(int *)v7; - v9 = v8 + *(int *)(v7 + 12); - v10 = v14 + *(int *)(v7 + 24); - *(int *)(v7 + 12) = v9; - *(int *)(v7 + 4) = v9 >> 16; - v11 = v10 + *(int *)(v7 + 16); - *(int *)(v7 + 24) = v10; - *(int *)(v7 + 16) = v11; - *(int *)(v7 + 8) = v11 >> 16; -LABEL_13: - v6 = 1; - goto LABEL_14; - } - return 0; -} - -//----- (0040E2A7) -------------------------------------------------------- -int stru272_stru0::_40E2A7() -{ - int result; // eax@2 - - if ( this->field_0 == 0x67707274 ) - { - if ( this->field_8 <= 0 ) - result = this->field_58 != 0 ? 2 : 0; - else - result = 1; - } - else - { - result = 3; - } - return result; -} + //----- (0040F82D) -------------------------------------------------------- void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue)