Skip to content

Instantly share code, notes, and snippets.

@Lusamine
Created October 1, 2022 00:01
Show Gist options
  • Save Lusamine/8c56de82800ea68c1fcfbcfa7eaa3ada to your computer and use it in GitHub Desktop.
Save Lusamine/8c56de82800ea68c1fcfbcfa7eaa3ada to your computer and use it in GitHub Desktop.
unsigned __int8 __fastcall effectiveness_to_modifier_index(unsigned __int8 atk_type, unsigned __int8 def_type)
{
int v2; // w9
unsigned __int8 result; // w0
v2 = atk_type;
result = 7;
if ( v2 != 18 && def_type != 18 )
{
result = 7;
switch ( effectiveness_table[18 * atk_type + def_type] )
{
case 0:
result = 8 * (is_inverse_battle != 0);
break;
case 2:
if ( is_inverse_battle )
result = 8;
else
result = 6;
break;
case 4:
return result;
case 8:
if ( is_inverse_battle )
result = 6;
else
result = 8;
break;
default:
result = 0;
break;
}
}
return result;
}
------
.text:000000710283E1F0 ; unsigned __int8 __fastcall get_effectiveness_single(unsigned __int8 atk_type, unsigned __int8 def_type)
.text:000000710283E1F0 get_effectiveness_single ; CODE XREF: select_judgment_type+148↑p
.text:000000710283E1F0 ; select_judgment_type+254↑p
.text:000000710283E1F0 AND W9, W0, #0xFF
.text:000000710283E1F4 MOV W8, W0
.text:000000710283E1F8 MOV W0, #7
.text:000000710283E1FC CMP W9, #0x12
.text:000000710283E200 B.EQ locret_710283E26C ; jumptable 000000710283E254 case 4
.text:000000710283E204 AND W9, W1, #0xFF
.text:000000710283E208 CMP W9, #0x12
.text:000000710283E20C B.EQ locret_710283E26C ; jumptable 000000710283E254 case 4
.text:000000710283E210 AND X8, X8, #0xFF
.text:000000710283E214 MOV W10, #0x12
.text:000000710283E218 ADRL X11, effectiveness_table
.text:000000710283E220 MADD X8, X8, X10, X11
.text:000000710283E224 AND X9, X1, #0xFF
.text:000000710283E228 LDRB W8, [X8,X9]
.text:000000710283E22C CMP W8, #8 ; switch 9 cases
.text:000000710283E230 B.HI def_710283E254 ; jumptable 000000710283E254 default case, cases 1,3,5-7
.text:000000710283E234 ADRP X9, #is_inverse_battle@PAGE
.text:000000710283E238 LDRB W9, [X9,#is_inverse_battle@PAGEOFF]
.text:000000710283E23C ADRL X10, jpt_710283E254
.text:000000710283E244 ADR X11, loc_710283E258 ; jumptable 000000710283E254 case 0
.text:000000710283E248 LDRB W12, [X10,X8]
.text:000000710283E24C ADD X11, X11, X12,LSL#2
.text:000000710283E250 MOV W0, #7
.text:000000710283E254 BR X11 ; switch jump
.text:000000710283E258 ; ---------------------------------------------------------------------------
.text:000000710283E258
.text:000000710283E258 loc_710283E258 ; CODE XREF: get_effectiveness_single+64↑j
.text:000000710283E258 ; DATA XREF: get_effectiveness_single+54↑o
.text:000000710283E258 CMP W9, #0 ; jumptable 000000710283E254 case 0
.text:000000710283E25C CSET W8, NE
.text:000000710283E260 LSL W0, W8, #3
.text:000000710283E264 RET
.text:000000710283E268 ; ---------------------------------------------------------------------------
.text:000000710283E268
.text:000000710283E268 def_710283E254 ; CODE XREF: get_effectiveness_single+40↑j
.text:000000710283E268 ; get_effectiveness_single+64↑j
.text:000000710283E268 MOV W0, WZR ; jumptable 000000710283E254 default case, cases 1,3,5-7
.text:000000710283E26C
.text:000000710283E26C locret_710283E26C ; CODE XREF: get_effectiveness_single+10↑j
.text:000000710283E26C ; get_effectiveness_single+1C↑j ...
.text:000000710283E26C RET ; jumptable 000000710283E254 case 4
.text:000000710283E270 ; ---------------------------------------------------------------------------
.text:000000710283E270
.text:000000710283E270 loc_710283E270 ; CODE XREF: get_effectiveness_single+64↑j
.text:000000710283E270 CMP W9, #0 ; jumptable 000000710283E254 case 2
.text:000000710283E274 MOV W8, #6
.text:000000710283E278 MOV W9, #8
.text:000000710283E27C CSEL W0, W9, W8, NE
.text:000000710283E280 RET
.text:000000710283E284 ; ---------------------------------------------------------------------------
.text:000000710283E284
.text:000000710283E284 loc_710283E284 ; CODE XREF: get_effectiveness_single+64↑j
.text:000000710283E284 CMP W9, #0 ; jumptable 000000710283E254 case 8
.text:000000710283E288 MOV W8, #8
.text:000000710283E28C MOV W9, #6
.text:000000710283E290 CSEL W0, W9, W8, NE
.text:000000710283E294 RET
.text:000000710283E294 ; End of function get_effectiveness_single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment