Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Lusamine/0bf5cbd93c3526f5d0de7f7c8b7a262c to your computer and use it in GitHub Desktop.
Save Lusamine/0bf5cbd93c3526f5d0de7f7c8b7a262c to your computer and use it in GitHub Desktop.
__int32 __fastcall Dpr_Battle_Logic_Capture__calcCaptureIndicator(Dpr_Battle_Logic_Capture_JudgeParam_o *param)
{
__int64 (__fastcall ***get_value_function)(_QWORD); // x19
__int64 (__fastcall ***v2)(_QWORD); // x23
__int64 v4; // x21
__int64 xoro_state; // x22
__int64 captureValueCoef; // x26
unsigned int v7; // w24
unsigned int target_max_hp; // w27
unsigned int hp_mod; // w8
float v10; // s1
unsigned __int64 v11; // x28
__int64 *v12; // x0
unsigned __int8 v13; // w8
__int16 v14; // w0
int v15; // w25
int ballCaptureRatio; // w21
int v17; // w20
unsigned __int8 poke_level; // w0
unsigned int PokeSick; // w8
int v20; // w8
unsigned __int64 v21; // x11
unsigned int ZukanCapturedCount; // w8
__int64 v24; // x8
unsigned int m_weight; // w8
int v26; // w8
int v27; // w9
int v28; // w8
bool v29; // cc
int v30; // w8
__int64 *v32; // [xsp+8h] [xbp-8h]
v2 = (__int64 (__fastcall ***)(_QWORD))param->field_10;
get_value_function = (__int64 (__fastcall ***)(_QWORD))param->get_value_function;
v4 = param->field_0;
xoro_state = param->xoro_state;
captureValueCoef = param->captureValueCoef;
v7 = (unsigned __int16)param->field_20;
target_max_hp = 3 * (unsigned __int16)(*get_value_function)[34](get_value_function);
hp_mod = target_max_hp - 2 * (unsigned __int16)(*get_value_function)[33](get_value_function);
v10 = 0.5;
if ( !hp_mod )
v10 = -0.5;
LODWORD(v11) = (int)(float)(v10 + (float)(hp_mod << 12));
if ( Dpr_Battle_Logic_MainModule__GetSetupStatusFlag(v4, 4LL) )
{
ZukanCapturedCount = *(_DWORD *)((char *)&param[1].field_0 + 2);
if ( ZukanCapturedCount <= 600 )
{
if ( ZukanCapturedCount <= 450 )
{
if ( ZukanCapturedCount <= 300 )
{
if ( ZukanCapturedCount <= 150 )
{
v29 = ZukanCapturedCount > 30;
v24 = 1229LL;
if ( v29 )
v24 = 2048LL;
}
else
{
v24 = 2867LL;
}
}
else
{
v24 = 3277LL;
}
}
else
{
v24 = 3686LL;
}
}
else
{
v24 = 4096LL;
}
v11 = (unsigned __int64)(v24 * (int)v11 + 2048) >> 12;
}
v12 = (__int64 *)(*get_value_function[5])(get_value_function + 5);
v13 = atomic_load((unsigned __int8 *)&qword_710434ECB8);
if ( (v13 & 1) == 0 )
{
v32 = v12;
v30 = _cxa_guard_acquire_0(&qword_710434ECB8);
v12 = v32;
if ( v30 )
{
qword_710434ECB0 = (__int64)sub_710185F8D4();
_cxa_guard_release_0(&qword_710434ECB8);
v12 = v32;
}
}
if ( v12 )
{
while ( v12 != &qword_710434ECB0 )
{
v12 = (__int64 *)*v12;
if ( !v12 )
goto LABEL_9;
}
v14 = sub_71010E4034((__int64)get_value_function);
v15 = (unsigned __int8)sub_71017B849C(v14, *((_WORD *)get_value_function + 884));// species catch rate
if ( sub_7101410B5C(v4) )
{
m_weight = (unsigned __int16)(*get_value_function)[100](get_value_function);
if ( m_weight >= 1000 )
{
if ( m_weight >= 3000 )
v27 = 30;
else
v27 = 20;
if ( m_weight >= 2000 )
v26 = v27;
else
v26 = 0;
}
else
{
v26 = -20;
}
v28 = v26 + v15;
if ( v28 <= 1 )
v15 = 1;
else
v15 = v28;
}
LODWORD(v11) = v15 * v11; // (species_catch_rate + heavy_ball_mod) * hp_component
}
LABEL_9:
ballCaptureRatio = sub_71017B84D4(v4, xoro_state, v2, get_value_function, v7);
v17 = (unsigned int)((unsigned __int64)((((((int)v11 * (__int64)ballCaptureRatio) << 20) + 0x80000000LL) >> 32)
* (int)get_badge_capture_modifier((__int64)param)
+ 2048) >> 12)
/ target_max_hp;
poke_level = (*get_value_function)[35](get_value_function);
if ( poke_level <= 13u ) // Low level bonus
v17 = (36 - 2 * poke_level) * v17 / 10;
PokeSick = (unsigned __int16)(*get_value_function)[70](get_value_function);
if ( PokeSick <= 5 )
{
v20 = 1 << PokeSick;
v21 = (unsigned __int64)(10240LL * v17 + 2048) >> 12;
if ( (v20 & 0xC) == 0 )
LODWORD(v21) = v17;
if ( (v20 & 0x32) != 0 )
v17 = (unsigned __int64)(6144LL * v17 + 2048) >> 12;
else
v17 = v21;
}
return (unsigned __int64)(v17 * captureValueCoef + 2048) >> 12;
}
=====
.text:00000071017B8184
.text:00000071017B8184 ; =============== S U B R O U T I N E =======================================
.text:00000071017B8184
.text:00000071017B8184 ; Attributes: bp-based frame
.text:00000071017B8184
.text:00000071017B8184 ; __int32 __fastcall Dpr_Battle_Logic_Capture__calcCaptureIndicator(Dpr_Battle_Logic_Capture_JudgeParam_o *param)
.text:00000071017B8184 Dpr.Battle.Logic.Capture$$calcCaptureIndicator
.text:00000071017B8184 ; CODE XREF: Dpr.Battle.Logic.Capture$$JudgeCapture+44↑p
.text:00000071017B8184
.text:00000071017B8184 var_8 = -8
.text:00000071017B8184 var_s0 = 0
.text:00000071017B8184 var_s10 = 0x10
.text:00000071017B8184 var_s20 = 0x20
.text:00000071017B8184 var_s30 = 0x30
.text:00000071017B8184 var_s40 = 0x40
.text:00000071017B8184 var_s50 = 0x50
.text:00000071017B8184
.text:00000071017B8184 SUB SP, SP, #0x70
.text:00000071017B8188 STP X29, X30, [SP,#0x10+var_s0]
.text:00000071017B818C ADD X29, SP, #0x10
.text:00000071017B8190 STP X28, X27, [SP,#0x10+var_s10]
.text:00000071017B8194 STP X26, X25, [SP,#0x10+var_s20]
.text:00000071017B8198 STP X24, X23, [SP,#0x10+var_s30]
.text:00000071017B819C STP X22, X21, [SP,#0x10+var_s40]
.text:00000071017B81A0 STP X20, X19, [SP,#0x10+var_s50]
.text:00000071017B81A4 LDP X23, X19, [X0,#0x10]
.text:00000071017B81A8 MOV X20, X0
.text:00000071017B81AC LDP X21, X22, [X0]
.text:00000071017B81B0 LDRSW X26, [X0,#0x24]
.text:00000071017B81B4 LDR X8, [X19]
.text:00000071017B81B8 LDR X8, [X8,#0x110]
.text:00000071017B81BC LDRH W24, [X0,#0x20]
.text:00000071017B81C0 MOV X0, X19
.text:00000071017B81C4 BLR X8
.text:00000071017B81C8 AND W8, W0, #0xFFFF
.text:00000071017B81CC LSL W8, W8, #1
.text:00000071017B81D0 ADD W27, W8, W0,UXTH
.text:00000071017B81D4 LDR X8, [X19]
.text:00000071017B81D8 LDR X8, [X8,#0x108]
.text:00000071017B81DC MOV X0, X19
.text:00000071017B81E0 BLR X8
.text:00000071017B81E4 SUB W8, W27, W0,UXTH#1
.text:00000071017B81E8 MOV X0, X21 ; a1
.text:00000071017B81EC LSL W9, W8, #0xC
.text:00000071017B81F0 UCVTF S0, W9
.text:00000071017B81F4 FMOV S1, #0.5
.text:00000071017B81F8 FMOV S2, #-0.5
.text:00000071017B81FC CMP W8, #0
.text:00000071017B8200 FCSEL S1, S2, S1, EQ
.text:00000071017B8204 FADD S0, S1, S0
.text:00000071017B8208 MOV W1, #4 ; a2
.text:00000071017B820C FCVTZS W28, S0
.text:00000071017B8210 BL Dpr.Battle.Logic.MainModule$$GetSetupStatusFlag
.text:00000071017B8214 TBNZ W0, #0, loc_71017B8398
.text:00000071017B8218
.text:00000071017B8218 loc_71017B8218 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+234↓j
.text:00000071017B8218 MOV X25, X19
.text:00000071017B821C LDR X8, [X25,#0x28]!
.text:00000071017B8220 LDR X8, [X8]
.text:00000071017B8224 MOV X0, X25
.text:00000071017B8228 BLR X8
.text:00000071017B822C ADRP X8, #off_7104320CE8@PAGE
.text:00000071017B8230 LDR X8, [X8,#off_7104320CE8@PAGEOFF]
.text:00000071017B8234 LDARB W8, [X8]
.text:00000071017B8238 TBZ W8, #0, loc_71017B8458
.text:00000071017B823C
.text:00000071017B823C loc_71017B823C ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+2F0↓j
.text:00000071017B823C ; Dpr.Battle.Logic.Capture$$calcCaptureIndicator+314↓j
.text:00000071017B823C CBZ X0, loc_71017B8288
.text:00000071017B8240 ADRP X8, #off_7104320CF0@PAGE
.text:00000071017B8244 LDR X8, [X8,#off_7104320CF0@PAGEOFF]
.text:00000071017B8248
.text:00000071017B8248 loc_71017B8248 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+2B8↓j
.text:00000071017B8248 CMP X0, X8
.text:00000071017B824C B.NE loc_71017B8438
.text:00000071017B8250 SUB X0, X25, #0x28 ; '('
.text:00000071017B8254 BL sub_71010E4034
.text:00000071017B8258 LDRH W1, [X25,#0x6C0]
.text:00000071017B825C BL sub_71017B849C
.text:00000071017B8260 MOV X1, #0xADA42D85
.text:00000071017B8268 AND W25, W0, #0xFF
.text:00000071017B826C MOVK X1, #0x6A2A,LSL#32
.text:00000071017B8270 MOVK X1, #0x78E8,LSL#48
.text:00000071017B8274 MOV X0, X21
.text:00000071017B8278 MOV W2, W24
.text:00000071017B827C BL sub_7101410B5C
.text:00000071017B8280 TBNZ W0, #0, loc_71017B83BC
.text:00000071017B8284
.text:00000071017B8284 loc_71017B8284 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+290↓j
.text:00000071017B8284 MUL W28, W25, W28
.text:00000071017B8288
.text:00000071017B8288 loc_71017B8288 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator:loc_71017B823C↑j
.text:00000071017B8288 ; Dpr.Battle.Logic.Capture$$calcCaptureIndicator+2BC↓j
.text:00000071017B8288 MOV X0, X21
.text:00000071017B828C MOV X1, X22
.text:00000071017B8290 MOV X2, X23
.text:00000071017B8294 MOV X3, X19
.text:00000071017B8298 MOV W4, W24
.text:00000071017B829C BL sub_71017B84D4
.text:00000071017B82A0 MOV W21, W0
.text:00000071017B82A4 MOV X0, X20
.text:00000071017B82A8 BL get_badge_capture_modifier
.text:00000071017B82AC SMULL X8, W28, W21
.text:00000071017B82B0 MOV W9, #0x80000000
.text:00000071017B82B4 MOV X10, #0x800
.text:00000071017B82B8 ADD X8, X9, X8,LSL#20
.text:00000071017B82BC SXTW X9, W0
.text:00000071017B82C0 MOV X0, X19
.text:00000071017B82C4 ASR X8, X8, #0x20 ; ' '
.text:00000071017B82C8 MADD X8, X8, X9, X10
.text:00000071017B82CC LDR X9, [X19]
.text:00000071017B82D0 LDR X9, [X9,#0x118]
.text:00000071017B82D4 LSR X8, X8, #0xC
.text:00000071017B82D8 UDIV W20, W8, W27
.text:00000071017B82DC BLR X9
.text:00000071017B82E0 AND W8, W0, #0xFF
.text:00000071017B82E4 CMP W8, #0xD
.text:00000071017B82E8 B.HI loc_71017B8310
.text:00000071017B82EC MOV W8, #0x24 ; '$'
.text:00000071017B82F0 SUB W8, W8, W0,UXTB#1
.text:00000071017B82F4 MUL W8, W8, W20
.text:00000071017B82F8 MOV W9, #0x66666667
.text:00000071017B8300 SMULL X8, W8, W9
.text:00000071017B8304 LSR X9, X8, #0x3F ; '?'
.text:00000071017B8308 ASR X8, X8, #0x22 ; '"'
.text:00000071017B830C ADD W20, W8, W9
.text:00000071017B8310
.text:00000071017B8310 loc_71017B8310 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+164↑j
.text:00000071017B8310 LDR X8, [X19]
.text:00000071017B8314 MOV X0, X19
.text:00000071017B8318 LDR X8, [X8,#0x230]
.text:00000071017B831C BLR X8
.text:00000071017B8320 AND W8, W0, #0xFFFF
.text:00000071017B8324 CMP W8, #5
.text:00000071017B8328 B.HI loc_71017B8368
.text:00000071017B832C MOV W11, #0x2800
.text:00000071017B8330 MOV W10, #0x1800
.text:00000071017B8334 SMULL X11, W20, W11
.text:00000071017B8338 SMULL X10, W20, W10
.text:00000071017B833C MOV W9, #1
.text:00000071017B8340 LSL W8, W9, W8
.text:00000071017B8344 MOV W9, #0x32 ; '2'
.text:00000071017B8348 TST W8, #0xC
.text:00000071017B834C ADD X11, X11, #0x800
.text:00000071017B8350 ADD X10, X10, #0x800
.text:00000071017B8354 LSR X11, X11, #0xC
.text:00000071017B8358 LSR X10, X10, #0xC
.text:00000071017B835C CSEL W11, W11, W20, NE
.text:00000071017B8360 TST W8, W9
.text:00000071017B8364 CSEL W20, W10, W11, NE
.text:00000071017B8368
.text:00000071017B8368 loc_71017B8368 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+1A4↑j
.text:00000071017B8368 SXTW X8, W20
.text:00000071017B836C MOV X9, #0x800
.text:00000071017B8370 MADD X8, X8, X26, X9
.text:00000071017B8374 LDP X20, X19, [SP,#0x10+var_s50]
.text:00000071017B8378 LSR X0, X8, #0xC
.text:00000071017B837C LDP X22, X21, [SP,#0x10+var_s40]
.text:00000071017B8380 LDP X24, X23, [SP,#0x10+var_s30]
.text:00000071017B8384 LDP X26, X25, [SP,#0x10+var_s20]
.text:00000071017B8388 LDP X28, X27, [SP,#0x10+var_s10]
.text:00000071017B838C LDP X29, X30, [SP,#0x10+var_s0]
.text:00000071017B8390 ADD SP, SP, #0x70 ; 'p'
.text:00000071017B8394 RET
.text:00000071017B8398 ; ---------------------------------------------------------------------------
.text:00000071017B8398
.text:00000071017B8398 loc_71017B8398 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+90↑j
.text:00000071017B8398 LDR W8, [X20,#0x2C]
.text:00000071017B839C CMP W8, #0x258
.text:00000071017B83A0 B.LS loc_71017B83E0
.text:00000071017B83A4 MOV W8, #0x1000
.text:00000071017B83A8
.text:00000071017B83A8 loc_71017B83A8 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+268↓j
.text:00000071017B83A8 ; Dpr.Battle.Logic.Capture$$calcCaptureIndicator+2A0↓j ...
.text:00000071017B83A8 SXTW X9, W28
.text:00000071017B83AC MOV X10, #0x800
.text:00000071017B83B0 MADD X8, X8, X9, X10
.text:00000071017B83B4 LSR X28, X8, #0xC
.text:00000071017B83B8 B loc_71017B8218
.text:00000071017B83BC ; ---------------------------------------------------------------------------
.text:00000071017B83BC
.text:00000071017B83BC loc_71017B83BC ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+FC↑j
.text:00000071017B83BC LDR X8, [X19]
.text:00000071017B83C0 MOV X0, X19
.text:00000071017B83C4 LDR X8, [X8,#0x320]
.text:00000071017B83C8 BLR X8
.text:00000071017B83CC AND W8, W0, #0xFFFF
.text:00000071017B83D0 CMP W8, #0x3E8
.text:00000071017B83D4 B.CS loc_71017B83F0
.text:00000071017B83D8 MOV W8, #0xFFFFFFEC
.text:00000071017B83DC B loc_71017B8408
.text:00000071017B83E0 ; ---------------------------------------------------------------------------
.text:00000071017B83E0
.text:00000071017B83E0 loc_71017B83E0 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+21C↑j
.text:00000071017B83E0 CMP W8, #0x1C2
.text:00000071017B83E4 B.LS loc_71017B8418
.text:00000071017B83E8 MOV W8, #0xE66
.text:00000071017B83EC B loc_71017B83A8
.text:00000071017B83F0 ; ---------------------------------------------------------------------------
.text:00000071017B83F0
.text:00000071017B83F0 loc_71017B83F0 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+250↑j
.text:00000071017B83F0 CMP W8, #0xBB8
.text:00000071017B83F4 MOV W9, #0x1E
.text:00000071017B83F8 MOV W10, #0x14
.text:00000071017B83FC CSEL W9, W10, W9, CC
.text:00000071017B8400 CMP W8, #0x7D0
.text:00000071017B8404 CSEL W8, WZR, W9, CC
.text:00000071017B8408
.text:00000071017B8408 loc_71017B8408 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+258↑j
.text:00000071017B8408 ADD W8, W8, W25
.text:00000071017B840C CMP W8, #1
.text:00000071017B8410 CSINC W25, W8, WZR, GT
.text:00000071017B8414 B loc_71017B8284
.text:00000071017B8418 ; ---------------------------------------------------------------------------
.text:00000071017B8418
.text:00000071017B8418 loc_71017B8418 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+260↑j
.text:00000071017B8418 CMP W8, #0x12C
.text:00000071017B841C B.LS loc_71017B8428
.text:00000071017B8420 MOV W8, #0xCCD
.text:00000071017B8424 B loc_71017B83A8
.text:00000071017B8428 ; ---------------------------------------------------------------------------
.text:00000071017B8428
.text:00000071017B8428 loc_71017B8428 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+298↑j
.text:00000071017B8428 CMP W8, #0x96
.text:00000071017B842C B.LS loc_71017B8444
.text:00000071017B8430 MOV W8, #0xB33
.text:00000071017B8434 B loc_71017B83A8
.text:00000071017B8438 ; ---------------------------------------------------------------------------
.text:00000071017B8438
.text:00000071017B8438 loc_71017B8438 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+C8↑j
.text:00000071017B8438 LDR X0, [X0]
.text:00000071017B843C CBNZ X0, loc_71017B8248
.text:00000071017B8440 B loc_71017B8288
.text:00000071017B8444 ; ---------------------------------------------------------------------------
.text:00000071017B8444
.text:00000071017B8444 loc_71017B8444 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+2A8↑j
.text:00000071017B8444 CMP W8, #0x1E
.text:00000071017B8448 MOV W8, #0x4CD
.text:00000071017B844C MOV W9, #0x800
.text:00000071017B8450 CSEL X8, X9, X8, HI
.text:00000071017B8454 B loc_71017B83A8
.text:00000071017B8458 ; ---------------------------------------------------------------------------
.text:00000071017B8458
.text:00000071017B8458 loc_71017B8458 ; CODE XREF: Dpr.Battle.Logic.Capture$$calcCaptureIndicator+B4↑j
.text:00000071017B8458 ADRP X8, #off_7104320CE8@PAGE
.text:00000071017B845C LDR X8, [X8,#off_7104320CE8@PAGEOFF]
.text:00000071017B8460 STR X0, [SP,#0x10+var_8]
.text:00000071017B8464 MOV X0, X8 ; __guard *
.text:00000071017B8468 BL __cxa_guard_acquire_0
.text:00000071017B846C MOV W8, W0
.text:00000071017B8470 LDR X0, [SP,#0x10+var_8]
.text:00000071017B8474 CBZ W8, loc_71017B823C
.text:00000071017B8478 BL sub_710185F8D4
.text:00000071017B847C ADRP X8, #off_7104320CF0@PAGE
.text:00000071017B8480 LDR X8, [X8,#off_7104320CF0@PAGEOFF]
.text:00000071017B8484 STR X0, [X8]
.text:00000071017B8488 ADRP X0, #off_7104320CE8@PAGE
.text:00000071017B848C LDR X0, [X0,#off_7104320CE8@PAGEOFF] ; __guard *
.text:00000071017B8490 BL __cxa_guard_release_0
.text:00000071017B8494 LDR X0, [SP,#0x10+var_8]
.text:00000071017B8498 B loc_71017B823C
.text:00000071017B8498 ; End of function Dpr.Battle.Logic.Capture$$calcCaptureIndicator
.text:00000071017B8498
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment