Skip to content

Instantly share code, notes, and snippets.

@Lusamine
Created October 1, 2022 00:00
Show Gist options
  • Save Lusamine/e2780644ca8f62694225db9d50af3645 to your computer and use it in GitHub Desktop.
Save Lusamine/e2780644ca8f62694225db9d50af3645 to your computer and use it in GitHub Desktop.
__int32 __fastcall get_effectiveness_total(unsigned __int8 atk_type, unsigned __int16 def_type)
{
int attack_type; // w13
int defense_type1; // w10
int defense_type2; // w12
__int32 index1; // w0
int defense_type3; // w13
int index2; // w14
unsigned int v9; // w15
bool v10; // zf
int v12; // w14
int v13; // w16
int index3; // w8
unsigned int v15; // w9
bool v16; // zf
int v18; // w8
int v19; // w10
int v20; // w10
attack_type = atk_type;
defense_type1 = def_type & 0x1F;
defense_type2 = (def_type >> 5) & 0x1F;
index1 = 7;
if ( attack_type != 18 && defense_type1 != 18 )
{
index1 = 7;
switch ( effectiveness_table[18 * atk_type + (def_type & 0x1F)] )
{
case 0:
index1 = 8 * (is_inverse_battle != 0);
break;
case 2:
if ( is_inverse_battle )
index1 = 8;
else
index1 = 6;
break;
case 4:
break;
case 8:
if ( is_inverse_battle )
index1 = 6;
else
index1 = 8;
break;
default:
index1 = 0;
break;
}
}
defense_type3 = (def_type >> 10) & 0x1F;
if ( defense_type2 == 18 || defense_type2 == defense_type1 )
{
LABEL_35:
if ( defense_type3 == defense_type2 )
return index1;
goto LABEL_36;
}
if ( atk_type == 18 )
{
index2 = 7;
}
else
{
index2 = 7;
switch ( effectiveness_table[18 * atk_type + defense_type2] )
{
case 0:
index2 = 8 * (is_inverse_battle != 0);
break;
case 2:
if ( is_inverse_battle )
index2 = 8;
else
index2 = 6;
break;
case 4:
break;
case 8:
if ( is_inverse_battle )
index2 = 6;
else
index2 = 8;
break;
default:
index2 = 0;
break;
}
}
v9 = (dword_7103984A4C[index2] * dword_7103984A4C[index1]) >> 6;
if ( v9 >= 4096 )
v9 = 4096;
if ( v9 )
v10 = 1;
else
v10 = index1 == 0;
index1 = 0;
if ( v10 || index2 == 0 )
v12 = v9;
else
v12 = 1;
do
{
if ( index1 == 32 )
{
index1 = 0;
goto LABEL_35;
}
v13 = 1 << index1++;
}
while ( (v13 & v12) == 0 );
if ( index1 <= 12 )
goto LABEL_35;
index1 = 13;
if ( defense_type3 != defense_type2 )
{
LABEL_36:
if ( defense_type3 != 18 && defense_type3 != defense_type1 )
{
if ( atk_type == 18 )
{
index3 = 7;
}
else
{
v20 = effectiveness_table[18 * atk_type + defense_type3];
index3 = 7;
switch ( v20 )
{
case 0:
index3 = 8 * (is_inverse_battle != 0);
break;
case 2:
if ( is_inverse_battle )
index3 = 8;
else
index3 = 6;
break;
case 4:
break;
case 8:
if ( is_inverse_battle )
index3 = 6;
else
index3 = 8;
break;
default:
index3 = 0;
break;
}
}
v15 = (dword_7103984A4C[index3] * dword_7103984A4C[index1]) >> 6;
if ( v15 >= 4096 )
v15 = 4096;
if ( v15 )
v16 = 1;
else
v16 = index1 == 0;
index1 = 0;
if ( v16 || index3 == 0 )
v18 = v15;
else
v18 = 1;
do
{
if ( index1 == 32 )
return 0;
v19 = 1 << index1++;
}
while ( (v19 & v18) == 0 );
if ( index1 > 12 )
return 13;
}
}
return index1;
}
------
.text:000000710283E2A0 ; __int32 __fastcall get_effectiveness_total(unsigned __int8 atk_type, unsigned __int16 def_type)
.text:000000710283E2A0 get_effectiveness_total ; CODE XREF: sub_71007810FC+230↑p
.text:000000710283E2A0 ; select_judgment_type+B8↑p ...
.text:000000710283E2A0 ADRP X9, #is_inverse_battle@PAGE
.text:000000710283E2A4 LDRB W9, [X9,#is_inverse_battle@PAGEOFF]
.text:000000710283E2A8 AND W13, W0, #0xFF
.text:000000710283E2AC AND W11, W1, #0xFFFF
.text:000000710283E2B0 MOV W8, W0
.text:000000710283E2B4 AND W10, W1, #0x1F
.text:000000710283E2B8 UBFX W12, W11, #5, #5
.text:000000710283E2BC MOV W0, #7
.text:000000710283E2C0 CMP W13, #0x12
.text:000000710283E2C4 B.EQ loc_710283E348 ; jumptable 000000710283E308 case 4
.text:000000710283E2C8 CMP W10, #0x12
.text:000000710283E2CC B.EQ loc_710283E348 ; jumptable 000000710283E308 case 4
.text:000000710283E2D0 AND X13, X8, #0xFF
.text:000000710283E2D4 MOV W14, #0x12
.text:000000710283E2D8 ADRL X15, effectiveness_table
.text:000000710283E2E0 MADD X13, X13, X14, X15
.text:000000710283E2E4 LDRB W13, [X13,W10,UXTW]
.text:000000710283E2E8 CMP W13, #8 ; switch 9 cases
.text:000000710283E2EC B.HI def_710283E308 ; jumptable 000000710283E308 default case, cases 1,3,5-7
.text:000000710283E2F0 ADRL X14, jpt_710283E308
.text:000000710283E2F8 ADR X15, loc_710283E30C ; jumptable 000000710283E308 case 0
.text:000000710283E2FC LDRB W16, [X14,X13]
.text:000000710283E300 ADD X15, X15, X16,LSL#2
.text:000000710283E304 MOV W0, #7
.text:000000710283E308 BR X15 ; switch jump
.text:000000710283E30C ; ---------------------------------------------------------------------------
.text:000000710283E30C
.text:000000710283E30C loc_710283E30C ; CODE XREF: get_effectiveness_total+68↑j
.text:000000710283E30C ; DATA XREF: get_effectiveness_total+58↑o
.text:000000710283E30C CMP W9, #0 ; jumptable 000000710283E308 case 0
.text:000000710283E310 CSET W13, NE
.text:000000710283E314 LSL W0, W13, #3
.text:000000710283E318 B loc_710283E348 ; jumptable 000000710283E308 case 4
.text:000000710283E31C ; ---------------------------------------------------------------------------
.text:000000710283E31C
.text:000000710283E31C loc_710283E31C ; CODE XREF: get_effectiveness_total+68↑j
.text:000000710283E31C CMP W9, #0 ; jumptable 000000710283E308 case 2
.text:000000710283E320 MOV W13, #6
.text:000000710283E324 MOV W14, #8
.text:000000710283E328 CSEL W0, W14, W13, NE
.text:000000710283E32C B loc_710283E348 ; jumptable 000000710283E308 case 4
.text:000000710283E330 ; ---------------------------------------------------------------------------
.text:000000710283E330
.text:000000710283E330 loc_710283E330 ; CODE XREF: get_effectiveness_total+68↑j
.text:000000710283E330 CMP W9, #0 ; jumptable 000000710283E308 case 8
.text:000000710283E334 MOV W13, #8
.text:000000710283E338 MOV W14, #6
.text:000000710283E33C CSEL W0, W14, W13, NE
.text:000000710283E340 B loc_710283E348 ; jumptable 000000710283E308 case 4
.text:000000710283E344 ; ---------------------------------------------------------------------------
.text:000000710283E344
.text:000000710283E344 def_710283E308 ; CODE XREF: get_effectiveness_total+4C↑j
.text:000000710283E344 ; get_effectiveness_total+68↑j
.text:000000710283E344 MOV W0, WZR ; jumptable 000000710283E308 default case, cases 1,3,5-7
.text:000000710283E348
.text:000000710283E348 loc_710283E348 ; CODE XREF: get_effectiveness_total+24↑j
.text:000000710283E348 ; get_effectiveness_total+2C↑j ...
.text:000000710283E348 UBFX W13, W11, #0xA, #5 ; jumptable 000000710283E308 case 4
.text:000000710283E34C CMP W12, #0x12
.text:000000710283E350 ADRL X11, dword_7103984A4C
.text:000000710283E358 B.EQ loc_710283E428
.text:000000710283E35C CMP W12, W10
.text:000000710283E360 B.EQ loc_710283E428
.text:000000710283E364 AND W14, W8, #0xFF
.text:000000710283E368 CMP W14, #0x12
.text:000000710283E36C B.NE loc_710283E3D8
.text:000000710283E370 MOV W14, #7
.text:000000710283E374
.text:000000710283E374 loc_710283E374 ; CODE XREF: get_effectiveness_total+170↓j
.text:000000710283E374 ; get_effectiveness_total+180↓j ...
.text:000000710283E374 LDR W15, [X11,W0,UXTW#2] ; jumptable 000000710283E410 case 4
.text:000000710283E378 LDR W16, [X11,W14,UXTW#2]
.text:000000710283E37C MUL W15, W16, W15
.text:000000710283E380 MOV W16, #0x1000
.text:000000710283E384 LSR W15, W15, #6
.text:000000710283E388 CMP W15, #1,LSL#12
.text:000000710283E38C CSEL W15, W15, W16, CC
.text:000000710283E390 CMP W15, #0
.text:000000710283E394 CCMP W0, #0, #4, EQ
.text:000000710283E398 MOV W0, WZR
.text:000000710283E39C CCMP W14, #0, #4, NE
.text:000000710283E3A0 CSINC W14, W15, WZR, EQ
.text:000000710283E3A4 MOV W15, #1
.text:000000710283E3A8
.text:000000710283E3A8 loc_710283E3A8 ; CODE XREF: get_effectiveness_total+11C↓j
.text:000000710283E3A8 CMP W0, #0x20 ; ' '
.text:000000710283E3AC B.EQ loc_710283E424
.text:000000710283E3B0 LSL W16, W15, W0
.text:000000710283E3B4 ADD W0, W0, #1
.text:000000710283E3B8 TST W16, W14
.text:000000710283E3BC B.EQ loc_710283E3A8
.text:000000710283E3C0 CMP W0, #0xC
.text:000000710283E3C4 B.LS loc_710283E428
.text:000000710283E3C8 MOV W0, #0xD
.text:000000710283E3CC CMP W13, W12
.text:000000710283E3D0 B.NE loc_710283E430
.text:000000710283E3D4 B locret_710283E4A8
.text:000000710283E3D8 ; ---------------------------------------------------------------------------
.text:000000710283E3D8
.text:000000710283E3D8 loc_710283E3D8 ; CODE XREF: get_effectiveness_total+CC↑j
.text:000000710283E3D8 AND X14, X8, #0xFF
.text:000000710283E3DC MOV W15, #0x12
.text:000000710283E3E0 ADRL X16, effectiveness_table
.text:000000710283E3E8 MADD X14, X14, X15, X16
.text:000000710283E3EC LDRB W15, [X14,W12,UXTW]
.text:000000710283E3F0 CMP W15, #8 ; switch 9 cases
.text:000000710283E3F4 B.HI def_710283E410 ; jumptable 000000710283E410 default case, cases 1,3,5-7
.text:000000710283E3F8 ADRL X16, jpt_710283E410
.text:000000710283E400 ADR X17, loc_710283E374 ; jumptable 000000710283E410 case 4
.text:000000710283E404 LDRB W18, [X16,X15]
.text:000000710283E408 ADD X17, X17, X18,LSL#2
.text:000000710283E40C MOV W14, #7
.text:000000710283E410 BR X17 ; switch jump
.text:000000710283E414 ; ---------------------------------------------------------------------------
.text:000000710283E414
.text:000000710283E414 loc_710283E414 ; CODE XREF: get_effectiveness_total+170↑j
.text:000000710283E414 CMP W9, #0 ; jumptable 000000710283E410 case 0
.text:000000710283E418 CSET W14, NE
.text:000000710283E41C LSL W14, W14, #3
.text:000000710283E420 B loc_710283E374 ; jumptable 000000710283E410 case 4
.text:000000710283E424 ; ---------------------------------------------------------------------------
.text:000000710283E424
.text:000000710283E424 loc_710283E424 ; CODE XREF: get_effectiveness_total+10C↑j
.text:000000710283E424 MOV W0, WZR
.text:000000710283E428
.text:000000710283E428 loc_710283E428 ; CODE XREF: get_effectiveness_total+B8↑j
.text:000000710283E428 ; get_effectiveness_total+C0↑j ...
.text:000000710283E428 CMP W13, W12
.text:000000710283E42C B.EQ locret_710283E4A8
.text:000000710283E430
.text:000000710283E430 loc_710283E430 ; CODE XREF: get_effectiveness_total+130↑j
.text:000000710283E430 CMP W13, #0x12
.text:000000710283E434 B.EQ locret_710283E4A8
.text:000000710283E438 CMP W13, W10
.text:000000710283E43C B.EQ locret_710283E4A8
.text:000000710283E440 AND W10, W8, #0xFF
.text:000000710283E444 CMP W10, #0x12
.text:000000710283E448 B.NE loc_710283E4AC
.text:000000710283E44C MOV W8, #7
.text:000000710283E450
.text:000000710283E450 loc_710283E450 ; CODE XREF: get_effectiveness_total+244↓j
.text:000000710283E450 ; get_effectiveness_total+254↓j ...
.text:000000710283E450 LDR W9, [X11,W0,SXTW#2] ; jumptable 000000710283E4E4 case 4
.text:000000710283E454 LDR W10, [X11,W8,UXTW#2]
.text:000000710283E458 MUL W9, W10, W9
.text:000000710283E45C MOV W10, #0x1000
.text:000000710283E460 LSR W9, W9, #6
.text:000000710283E464 CMP W9, #1,LSL#12
.text:000000710283E468 CSEL W9, W9, W10, CC
.text:000000710283E46C CMP W9, #0
.text:000000710283E470 CCMP W0, #0, #4, EQ
.text:000000710283E474 MOV W0, WZR
.text:000000710283E478 CCMP W8, #0, #4, NE
.text:000000710283E47C CSINC W8, W9, WZR, EQ
.text:000000710283E480 MOV W9, #1
.text:000000710283E484
.text:000000710283E484 loc_710283E484 ; CODE XREF: get_effectiveness_total+1F8↓j
.text:000000710283E484 CMP W0, #0x20 ; ' '
.text:000000710283E488 B.EQ loc_710283E4F8
.text:000000710283E48C LSL W10, W9, W0
.text:000000710283E490 ADD W0, W0, #1
.text:000000710283E494 TST W10, W8
.text:000000710283E498 B.EQ loc_710283E484
.text:000000710283E49C CMP W0, #0xC
.text:000000710283E4A0 B.LS locret_710283E4A8
.text:000000710283E4A4 MOV W0, #0xD
.text:000000710283E4A8
.text:000000710283E4A8 locret_710283E4A8 ; CODE XREF: get_effectiveness_total+134↑j
.text:000000710283E4A8 ; get_effectiveness_total+18C↑j ...
.text:000000710283E4A8 RET
.text:000000710283E4AC ; ---------------------------------------------------------------------------
.text:000000710283E4AC
.text:000000710283E4AC loc_710283E4AC ; CODE XREF: get_effectiveness_total+1A8↑j
.text:000000710283E4AC AND X8, X8, #0xFF
.text:000000710283E4B0 MOV W10, #0x12
.text:000000710283E4B4 ADRL X12, effectiveness_table
.text:000000710283E4BC MADD X8, X8, X10, X12
.text:000000710283E4C0 LDRB W10, [X8,W13,UXTW]
.text:000000710283E4C4 CMP W10, #8 ; switch 9 cases
.text:000000710283E4C8 B.HI def_710283E4E4 ; jumptable 000000710283E4E4 default case, cases 1,3,5-7
.text:000000710283E4CC ADRL X12, jpt_710283E4E4
.text:000000710283E4D4 ADR X13, loc_710283E450 ; jumptable 000000710283E4E4 case 4
.text:000000710283E4D8 LDRB W14, [X12,X10]
.text:000000710283E4DC ADD X13, X13, X14,LSL#2
.text:000000710283E4E0 MOV W8, #7
.text:000000710283E4E4 BR X13 ; switch jump
.text:000000710283E4E8 ; ---------------------------------------------------------------------------
.text:000000710283E4E8
.text:000000710283E4E8 loc_710283E4E8 ; CODE XREF: get_effectiveness_total+244↑j
.text:000000710283E4E8 CMP W9, #0 ; jumptable 000000710283E4E4 case 0
.text:000000710283E4EC CSET W8, NE
.text:000000710283E4F0 LSL W8, W8, #3
.text:000000710283E4F4 B loc_710283E450 ; jumptable 000000710283E4E4 case 4
.text:000000710283E4F8 ; ---------------------------------------------------------------------------
.text:000000710283E4F8
.text:000000710283E4F8 loc_710283E4F8 ; CODE XREF: get_effectiveness_total+1E8↑j
.text:000000710283E4F8 MOV W0, WZR
.text:000000710283E4FC RET
.text:000000710283E500 ; ---------------------------------------------------------------------------
.text:000000710283E500
.text:000000710283E500 loc_710283E500 ; CODE XREF: get_effectiveness_total+170↑j
.text:000000710283E500 CMP W9, #0 ; jumptable 000000710283E410 case 2
.text:000000710283E504 MOV W14, #6
.text:000000710283E508 MOV W15, #8
.text:000000710283E50C CSEL W14, W15, W14, NE
.text:000000710283E510 B loc_710283E374 ; jumptable 000000710283E410 case 4
.text:000000710283E514 ; ---------------------------------------------------------------------------
.text:000000710283E514
.text:000000710283E514 loc_710283E514 ; CODE XREF: get_effectiveness_total+170↑j
.text:000000710283E514 CMP W9, #0 ; jumptable 000000710283E410 case 8
.text:000000710283E518 MOV W14, #8
.text:000000710283E51C MOV W15, #6
.text:000000710283E520 CSEL W14, W15, W14, NE
.text:000000710283E524 B loc_710283E374 ; jumptable 000000710283E410 case 4
.text:000000710283E528 ; ---------------------------------------------------------------------------
.text:000000710283E528
.text:000000710283E528 def_710283E4E4 ; CODE XREF: get_effectiveness_total+228↑j
.text:000000710283E528 ; get_effectiveness_total+244↑j
.text:000000710283E528 MOV W8, WZR ; jumptable 000000710283E4E4 default case, cases 1,3,5-7
.text:000000710283E52C B loc_710283E450 ; jumptable 000000710283E4E4 case 4
.text:000000710283E530 ; ---------------------------------------------------------------------------
.text:000000710283E530
.text:000000710283E530 loc_710283E530 ; CODE XREF: get_effectiveness_total+244↑j
.text:000000710283E530 CMP W9, #0 ; jumptable 000000710283E4E4 case 2
.text:000000710283E534 MOV W8, #6
.text:000000710283E538 MOV W9, #8
.text:000000710283E53C CSEL W8, W9, W8, NE
.text:000000710283E540 B loc_710283E450 ; jumptable 000000710283E4E4 case 4
.text:000000710283E544 ; ---------------------------------------------------------------------------
.text:000000710283E544
.text:000000710283E544 loc_710283E544 ; CODE XREF: get_effectiveness_total+244↑j
.text:000000710283E544 CMP W9, #0 ; jumptable 000000710283E4E4 case 8
.text:000000710283E548 MOV W8, #8
.text:000000710283E54C MOV W9, #6
.text:000000710283E550 CSEL W8, W9, W8, NE
.text:000000710283E554 B loc_710283E450 ; jumptable 000000710283E4E4 case 4
.text:000000710283E558 ; ---------------------------------------------------------------------------
.text:000000710283E558
.text:000000710283E558 def_710283E410 ; CODE XREF: get_effectiveness_total+154↑j
.text:000000710283E558 ; get_effectiveness_total+170↑j
.text:000000710283E558 MOV W14, WZR ; jumptable 000000710283E410 default case, cases 1,3,5-7
.text:000000710283E55C B loc_710283E374 ; jumptable 000000710283E410 case 4
.text:000000710283E55C ; End of function get_effectiveness_total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment