__int16 __cdecl npcs_to_coins() { __int64 unknown_mixed_var; // qax@1 __int16 v1; // bp@1 int npc_baseindex; // esi@4 int unknown_var; // ecx@6 int currentNPC_ptr; // esi@6 char isNpc_varUnknown; // zf@6 unsigned int spriteGFXIndex2; // edi@8 unsigned int spriteGFXIndex3; // ebp@14 unsigned int spriteGFXIndex4; // ebx@16 unsigned int spriteGFXIndex5; // edi@18 __int16 spriteGFXIndex6; // ax@21 bool v11; // ebx@25 unsigned int spriteGFXIndex10; // edi@27 __int16 spriteGFXIndex7; // ax@30 int v14; // ebx@32 int spriteGFXIndex8; // edi@34 __int16 spriteGFXIndex; // ax@37 __int16 v17; // fps@56 int v18; // eax@57 __int16 v19; // fps@60 __int16 spriteGFXIndex9; // ax@65 int v22; // [sp+0h] [bp-2Ch]@60 int is14value; // [sp+4h] [bp-28h]@5 __int16 npccount; // [sp+16h] [bp-16h]@1 int is11value; // [sp+18h] [bp-14h]@1 int oldcount; // [sp+1Ch] [bp-10h]@1 int is0value2; // [sp+20h] [bp-Ch]@1 int is0value1; // [sp+24h] [bp-8h]@1 int possAddr0x3f800000; // [sp+28h] [bp-4h]@1 LOWORD(unknown_mixed_var) = HIWORD(dword_B25958); v1 = 0; is11value = 0; is0value1 = 0; is0value2 = 0; possAddr0x3f800000 = 0; npccount = HIWORD(dword_B25958); oldcount = 1; if ( HIWORD(dword_B25958) >= 1 ) { while ( 1 ) { npc_baseindex = (signed __int16)oldcount + 128; if ( (unsigned int)npc_baseindex >= 0x1409 ) _vbaGenerateBoundsError(is14value); HIDWORD(unknown_mixed_var) = npc_ptr; unknown_var = 43 * npc_baseindex; WORD1(unknown_mixed_var) = -1; // WORD1 same as HIWORD isNpc_varUnknown = *(_WORD *)(npc_ptr + 344 * npc_baseindex + 292) == -1;// 344 = offset per index currentNPC_ptr = npc_ptr + 344 * npc_baseindex; if ( isNpc_varUnknown && *(_WORD *)(currentNPC_ptr + 100) == v1 )// is not a generator and isUnknownVar { spriteGFXIndex2 = *(_WORD *)(currentNPC_ptr + 226); if ( spriteGFXIndex2 >= maxGFXIndex ) _vbaGenerateBoundsError(is14value); WORD1(unknown_mixed_var) = HIWORD(dword_B25CDC); if ( *(_WORD *)(dword_B25CDC + 2 * spriteGFXIndex2) == v1 && *(_WORD *)(currentNPC_ptr + 64) == v1 && *(_WORD *)(currentNPC_ptr + 290) == v1 && *(_WORD *)(currentNPC_ptr + 70) == v1 ) { spriteGFXIndex3 = *(_WORD *)(currentNPC_ptr + 226); if ( spriteGFXIndex3 >= maxGFXIndex ) _vbaGenerateBoundsError(is14value); spriteGFXIndex4 = *(_WORD *)(currentNPC_ptr + 226); if ( spriteGFXIndex4 >= maxGFXIndex ) _vbaGenerateBoundsError(is14value); spriteGFXIndex5 = *(_WORD *)(currentNPC_ptr + 226); if ( spriteGFXIndex5 >= maxGFXIndex ) _vbaGenerateBoundsError(is14value); v11 = *(_WORD *)(dword_B25C88 + 2 * spriteGFXIndex5) != 0 | (*(_WORD *)(dword_B25E64 + 2 * spriteGFXIndex3) != 0 | *(_WORD *)(dword_B25E48 + 2 * spriteGFXIndex4) != 0) != 0 || (spriteGFXIndex6 = *(_WORD *)(currentNPC_ptr + 226), spriteGFXIndex6 == 265) || spriteGFXIndex6 == 13 || spriteGFXIndex6 == 108 || spriteGFXIndex6 == 26; spriteGFXIndex10 = *(_WORD *)(currentNPC_ptr + 226); if ( spriteGFXIndex10 >= maxGFXIndex ) _vbaGenerateBoundsError(is14value); v14 = v11 | *(_WORD *)(dword_B25F0C + 2 * spriteGFXIndex10) != 0 || (spriteGFXIndex7 = *(_WORD *)(currentNPC_ptr + 226), spriteGFXIndex7 == 91) || spriteGFXIndex7 == 171; spriteGFXIndex8 = *(_WORD *)(currentNPC_ptr + 226); if ( spriteGFXIndex8 >= (unsigned int)maxGFXIndex ) _vbaGenerateBoundsError(is14value); unknown_var = dword_B25CC0; WORD3(unknown_mixed_var) = 0; *(_DWORD *)((char *)&unknown_mixed_var + 2) = HIWORD(v14); if ( v14 | *(_WORD *)(dword_B25CC0 + 2 * spriteGFXIndex8) != 0 || (spriteGFXIndex = *(_WORD *)(currentNPC_ptr + 226), spriteGFXIndex == 56) || spriteGFXIndex == 60 || spriteGFXIndex == 62 || spriteGFXIndex == 64 || spriteGFXIndex == 66 || spriteGFXIndex == 104 || (LOWORD(unknown_var) = *(_WORD *)(currentNPC_ptr + 310), (_WORD)unknown_var == -1) && (spriteGFXIndex == 30 || spriteGFXIndex == 17) || spriteGFXIndex == 291 || spriteGFXIndex == 292 || spriteGFXIndex == 266 || spriteGFXIndex == 57 || spriteGFXIndex == 58 || spriteGFXIndex >= 78 && spriteGFXIndex <= 83 || spriteGFXIndex == 91 || spriteGFXIndex == 260 || spriteGFXIndex == 259 ) // probably npc checks { spriteGFXIndex9 = *(_WORD *)(currentNPC_ptr + 226); if ( spriteGFXIndex9 == 197 || spriteGFXIndex9 == 260 || spriteGFXIndex9 == 259 ) *(_WORD *)(currentNPC_ptr + 292) = 0; } else // do coins switch? { // ypos + 32 UNDEF(v17); *(double *)(currentNPC_ptr + 128) = *(double *)(currentNPC_ptr + 128) + 32.0; if ( v17 & 0xD ) goto LABEL_74; is0value2 = 0; is0value1 = 0; possAddr0x3f800000 = 1065353216; // possible address? is11value = 11; v18 = sub_9E7380(&is11value, currentNPC_ptr + 120, &possAddr0x3f800000, &is0value1, &is0value2);// npcptr+120 = xpos is14value = 14; LODWORD(unknown_mixed_var) = sub_A73FD0(v18, v14, spriteGFXIndex8, currentNPC_ptr, (int)&is14value); LOWORD(unknown_mixed_var) = Coins + 1; if ( __SETO__(Coins, -1) ) { OnError: _vbaErrorOverflow(unknown_var, HIDWORD(unknown_mixed_var)); JUMPOUT(unk_A3C98B); } ++Coins; if ( (_WORD)unknown_mixed_var >= 100 ) { if ( *(float *)&Lifes >= 99.0 ) { Coins = 99; } else { v22 = 15; UNDEF(v19); *(float *)&Lifes = *(float *)&Lifes + 1.0; LOWORD(unknown_mixed_var) = v19; if ( v19 & 0xD ) LABEL_74: JUMPOUT(*(unsigned int *)loc_40BA6C); sub_A73FD0(unknown_mixed_var, v14, spriteGFXIndex8, currentNPC_ptr, (int)&v22); if ( __SETO__(Coins, 100) ) goto OnError; Coins -= 100; } } WORD1(unknown_mixed_var) = 0; *(_WORD *)(currentNPC_ptr + 290) = 9; *(_DWORD *)(currentNPC_ptr + 136) = 0; *(_DWORD *)(currentNPC_ptr + 140) = 0; *(_WORD *)(currentNPC_ptr + 292) = 0; } } } else { if ( *(_WORD *)(currentNPC_ptr + 100) == -1 ) { *(_WORD *)(currentNPC_ptr + 290) = 9; *(_WORD *)(currentNPC_ptr + 64) = -1; } } LOWORD(unknown_mixed_var) = oldcount + 1; if ( __SETO__(oldcount, -1) ) goto OnError; oldcount = unknown_mixed_var; if ( (_WORD)unknown_mixed_var > npccount )// Do until we finished all npcs break; v1 = 0; } } return unknown_mixed_var; }