### RAW ASSEMBLY INSTRUCTIONS:

glabel effect_65_update
/* 3D0748 E00CA248 27BDFFD8 */  addiu     $sp, $sp, -0x28
/* 3D074C E00CA24C AFBF0018 */  sw        $ra, 0x18($sp)
/* 3D0750 E00CA250 AFB10014 */  sw        $s1, 0x14($sp)
/* 3D0754 E00CA254 AFB00010 */  sw        $s0, 0x10($sp)
/* 3D0758 E00CA258 F7B40020 */  sdc1      $f20, 0x20($sp)
/* 3D075C E00CA25C 8C830000 */  lw        $v1, 0x0($a0)
/* 3D0760 E00CA260 8C90000C */  lw        $s0, 0xC($a0)
/* 3D0764 E00CA264 30620010 */  andi      $v0, $v1, 0x10
/* 3D0768 E00CA268 8E050000 */  lw        $a1, 0x0($s0)
/* 3D076C E00CA26C 10400005 */  beqz      $v0, .LE00CA284
/* 3D0770 E00CA270 2402FFEF */   addiu    $v0, $zero, -0x11
/* 3D0774 E00CA274 00621024 */  and       $v0, $v1, $v0
/* 3D0778 E00CA278 AC820000 */  sw        $v0, 0x0($a0)
/* 3D077C E00CA27C 24020010 */  addiu     $v0, $zero, 0x10
/* 3D0780 E00CA280 AE020010 */  sw        $v0, 0x10($s0)
.LE00CA284:
/* 3D0784 E00CA284 8E030010 */  lw        $v1, 0x10($s0)
/* 3D0788 E00CA288 286203E8 */  slti      $v0, $v1, 0x3E8
/* 3D078C E00CA28C 10400002 */  beqz      $v0, .LE00CA298
/* 3D0790 E00CA290 2462FFFF */   addiu    $v0, $v1, -0x1
/* 3D0794 E00CA294 AE020010 */  sw        $v0, 0x10($s0)
.LE00CA298:
/* 3D0798 E00CA298 8E020014 */  lw        $v0, 0x14($s0)
/* 3D079C E00CA29C 8E030010 */  lw        $v1, 0x10($s0)
/* 3D07A0 E00CA2A0 24420001 */  addiu     $v0, $v0, 0x1
/* 3D07A4 E00CA2A4 04610005 */  bgez      $v1, .LE00CA2BC
/* 3D07A8 E00CA2A8 AE020014 */   sw       $v0, 0x14($s0)
/* 3D07AC E00CA2AC 0C080128 */  jal       shim_remove_effect
/* 3D07B0 E00CA2B0 00000000 */   nop
/* 3D07B4 E00CA2B4 0803291B */  j         .LE00CA46C
/* 3D07B8 E00CA2B8 00000000 */   nop
.LE00CA2BC:
/* 3D07BC E00CA2BC 0040882D */  daddu     $s1, $v0, $zero
/* 3D07C0 E00CA2C0 28620010 */  slti      $v0, $v1, 0x10
/* 3D07C4 E00CA2C4 10400002 */  beqz      $v0, .LE00CA2D0
/* 3D07C8 E00CA2C8 00031100 */   sll      $v0, $v1, 4
/* 3D07CC E00CA2CC AE020024 */  sw        $v0, 0x24($s0)
.LE00CA2D0:
/* 3D07D0 E00CA2D0 24020003 */  addiu     $v0, $zero, 0x3
/* 3D07D4 E00CA2D4 14A20020 */  bne       $a1, $v0, .LE00CA358
/* 3D07D8 E00CA2D8 3C028888 */   lui      $v0, (0x88888889 >> 16)
/* 3D07DC E00CA2DC 0C080138 */  jal       shim_rand_int
/* 3D07E0 E00CA2E0 2404000A */   addiu    $a0, $zero, 0xA
/* 3D07E4 E00CA2E4 2442FFFB */  addiu     $v0, $v0, -0x5
/* 3D07E8 E00CA2E8 C6000044 */  lwc1      $f0, 0x44($s0)
/* 3D07EC E00CA2EC 44821000 */  mtc1      $v0, $f2
/* 3D07F0 E00CA2F0 00000000 */  nop
/* 3D07F4 E00CA2F4 468010A0 */  cvt.s.w   $f2, $f2
/* 3D07F8 E00CA2F8 46020000 */  add.s     $f0, $f0, $f2
/* 3D07FC E00CA2FC 2404000A */  addiu     $a0, $zero, 0xA
/* 3D0800 E00CA300 0C080138 */  jal       shim_rand_int
/* 3D0804 E00CA304 E6000044 */   swc1     $f0, 0x44($s0)
/* 3D0808 E00CA308 2442FFFB */  addiu     $v0, $v0, -0x5
/* 3D080C E00CA30C 44820000 */  mtc1      $v0, $f0
/* 3D0810 E00CA310 00000000 */  nop
/* 3D0814 E00CA314 46800020 */  cvt.s.w   $f0, $f0
/* 3D0818 E00CA318 C6020048 */  lwc1      $f2, 0x48($s0)
/* 3D081C E00CA31C C6060038 */  lwc1      $f6, 0x38($s0)
/* 3D0820 E00CA320 46001080 */  add.s     $f2, $f2, $f0
/* 3D0824 E00CA324 C6000044 */  lwc1      $f0, 0x44($s0)
/* 3D0828 E00CA328 C6040040 */  lwc1      $f4, 0x40($s0)
/* 3D082C E00CA32C 46003180 */  add.s     $f6, $f6, $f0
/* 3D0830 E00CA330 C600004C */  lwc1      $f0, 0x4C($s0)
/* 3D0834 E00CA334 46002100 */  add.s     $f4, $f4, $f0
/* 3D0838 E00CA338 E6020048 */  swc1      $f2, 0x48($s0)
/* 3D083C E00CA33C C602003C */  lwc1      $f2, 0x3C($s0)
/* 3D0840 E00CA340 C6000048 */  lwc1      $f0, 0x48($s0)
/* 3D0844 E00CA344 46001080 */  add.s     $f2, $f2, $f0
/* 3D0848 E00CA348 E6060038 */  swc1      $f6, 0x38($s0)
/* 3D084C E00CA34C E6040040 */  swc1      $f4, 0x40($s0)
/* 3D0850 E00CA350 E602003C */  swc1      $f2, 0x3C($s0)
/* 3D0854 E00CA354 3C028888 */  lui       $v0, (0x88888889 >> 16)
.LE00CA358:
/* 3D0858 E00CA358 8E0402A8 */  lw        $a0, 0x2A8($s0)
/* 3D085C E00CA35C 34428889 */  ori       $v0, $v0, (0x88888889 & 0xFFFF)
/* 3D0860 E00CA360 00820018 */  mult      $a0, $v0
/* 3D0864 E00CA364 C6080038 */  lwc1      $f8, 0x38($s0)
/* 3D0868 E00CA368 C606003C */  lwc1      $f6, 0x3C($s0)
/* 3D086C E00CA36C C60A0040 */  lwc1      $f10, 0x40($s0)
/* 3D0870 E00CA370 00041FC3 */  sra       $v1, $a0, 31
/* 3D0874 E00CA374 00003010 */  mfhi      $a2
/* 3D0878 E00CA378 00C41021 */  addu      $v0, $a2, $a0
/* 3D087C E00CA37C 00021103 */  sra       $v0, $v0, 4
/* 3D0880 E00CA380 00431823 */  subu      $v1, $v0, $v1
/* 3D0884 E00CA384 00031100 */  sll       $v0, $v1, 4
/* 3D0888 E00CA388 00431023 */  subu      $v0, $v0, $v1
/* 3D088C E00CA38C 00021040 */  sll       $v0, $v0, 1
/* 3D0890 E00CA390 00821823 */  subu      $v1, $a0, $v0
/* 3D0894 E00CA394 00031080 */  sll       $v0, $v1, 2
/* 3D0898 E00CA398 02021021 */  addu      $v0, $s0, $v0
/* 3D089C E00CA39C C4420050 */  lwc1      $f2, 0x50($v0)
/* 3D08A0 E00CA3A0 C44000C8 */  lwc1      $f0, 0xC8($v0)
/* 3D08A4 E00CA3A4 C44C0140 */  lwc1      $f12, 0x140($v0)
/* 3D08A8 E00CA3A8 46024032 */  c.eq.s    $f8, $f2
/* 3D08AC E00CA3AC 00000000 */  nop
/* 3D08B0 E00CA3B0 45000009 */  bc1f      .LE00CA3D8
/* 3D08B4 E00CA3B4 00031880 */   sll      $v1, $v1, 2
/* 3D08B8 E00CA3B8 46003032 */  c.eq.s    $f6, $f0
/* 3D08BC E00CA3BC 00000000 */  nop
/* 3D08C0 E00CA3C0 45000005 */  bc1f      .LE00CA3D8
/* 3D08C4 E00CA3C4 00000000 */   nop
/* 3D08C8 E00CA3C8 460C5032 */  c.eq.s    $f10, $f12
/* 3D08CC E00CA3CC 00000000 */  nop
/* 3D08D0 E00CA3D0 45010026 */  bc1t      .LE00CA46C
/* 3D08D4 E00CA3D4 00000000 */   nop
.LE00CA3D8:
/* 3D08D8 E00CA3D8 02031821 */  addu      $v1, $s0, $v1
/* 3D08DC E00CA3DC 8E0202A8 */  lw        $v0, 0x2A8($s0)
/* 3D08E0 E00CA3E0 C47402AC */  lwc1      $f20, 0x2AC($v1)
/* 3D08E4 E00CA3E4 24420001 */  addiu     $v0, $v0, 0x1
/* 3D08E8 E00CA3E8 AE0202A8 */  sw        $v0, 0x2A8($s0)
/* 3D08EC E00CA3EC 2842001E */  slti      $v0, $v0, 0x1E
/* 3D08F0 E00CA3F0 50400001 */  beql      $v0, $zero, .LE00CA3F8
/* 3D08F4 E00CA3F4 AE0002A8 */   sw       $zero, 0x2A8($s0)
.LE00CA3F8:
/* 3D08F8 E00CA3F8 46024101 */  sub.s     $f4, $f8, $f2
/* 3D08FC E00CA3FC 46042102 */  mul.s     $f4, $f4, $f4
/* 3D0900 E00CA400 00000000 */  nop
/* 3D0904 E00CA404 46003001 */  sub.s     $f0, $f6, $f0
/* 3D0908 E00CA408 46000002 */  mul.s     $f0, $f0, $f0
/* 3D090C E00CA40C 00000000 */  nop
/* 3D0910 E00CA410 8E0302A8 */  lw        $v1, 0x2A8($s0)
/* 3D0914 E00CA414 460C5081 */  sub.s     $f2, $f10, $f12
/* 3D0918 E00CA418 00031080 */  sll       $v0, $v1, 2
/* 3D091C E00CA41C 46021082 */  mul.s     $f2, $f2, $f2
/* 3D0920 E00CA420 00000000 */  nop
/* 3D0924 E00CA424 02028021 */  addu      $s0, $s0, $v0
/* 3D0928 E00CA428 24020001 */  addiu     $v0, $zero, 0x1
/* 3D092C E00CA42C AE020230 */  sw        $v0, 0x230($s0)
/* 3D0930 E00CA430 E6080050 */  swc1      $f8, 0x50($s0)
/* 3D0934 E00CA434 46002100 */  add.s     $f4, $f4, $f0
/* 3D0938 E00CA438 E60600C8 */  swc1      $f6, 0xC8($s0)
/* 3D093C E00CA43C 44800000 */  mtc1      $zero, $f0
/* 3D0940 E00CA440 46022300 */  add.s     $f12, $f4, $f2
/* 3D0944 E00CA444 E60A0140 */  swc1      $f10, 0x140($s0)
/* 3D0948 E00CA448 46006032 */  c.eq.s    $f12, $f0
/* 3D094C E00CA44C 00000000 */  nop
/* 3D0950 E00CA450 45010004 */  bc1t      .LE00CA464
/* 3D0954 E00CA454 AE1101B8 */   sw       $s1, 0x1B8($s0)
/* 3D0958 E00CA458 0C080154 */  jal       shim_sqrtf
/* 3D095C E00CA45C 00000000 */   nop
/* 3D0960 E00CA460 46000306 */  mov.s     $f12, $f0
.LE00CA464:
/* 3D0964 E00CA464 460CA000 */  add.s     $f0, $f20, $f12
/* 3D0968 E00CA468 E60002AC */  swc1      $f0, 0x2AC($s0)
.LE00CA46C:
/* 3D096C E00CA46C 8FBF0018 */  lw        $ra, 0x18($sp)
/* 3D0970 E00CA470 8FB10014 */  lw        $s1, 0x14($sp)
/* 3D0974 E00CA474 8FB00010 */  lw        $s0, 0x10($sp)
/* 3D0978 E00CA478 D7B40020 */  ldc1      $f20, 0x20($sp)
/* 3D097C E00CA47C 03E00008 */  jr        $ra
/* 3D0980 E00CA480 27BD0028 */   addiu    $sp, $sp, 0x28

### DECOMPILED C INSTRUCTIONS:

void effect_65_update(EffectInstance* effect) {
    Effect65FXData* data = effect->data.unk_65;
    s32 variation = data->variation;
    s32 lifeTime;
    f32 pathLength;
    f32 posX;
    f32 posY;
    f32 posZ;
    f32 lastPointX;
    f32 lastPointY;
    f32 lastPointZ;
    f32 dist;
    s32 idx;

    if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
        effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
        data->timeLeft = 16;
    }

    if (data->timeLeft < 1000) {
        data->timeLeft--;
    }

    data->lifeTime++;
    if (data->timeLeft < 0) {
        shim_remove_effect(effect);
        return;
    }

    lifeTime = data->lifeTime;

    if (data->timeLeft < 16) {
        data->alpha = data->timeLeft * 16;
    }

    if (variation == 3) {
        data->pathJitterX += shim_rand_int(10) - 5;
        data->pathJitterY += shim_rand_int(10) - 5;
        data->pos.x += data->pathJitterX;
        data->pos.y += data->pathJitterY;
        data->pos.z += data->pathJitterZ;
    }

    idx = data->lastPointIndex % MAX_POINTS;

    posX = data->pos.x;
    posY = data->pos.y;
    posZ = data->pos.z;

    lastPointX = data->pathX[idx];
    lastPointY = data->pathY[idx];
    lastPointZ = data->pathZ[idx];

    if (posX != lastPointX || posY != lastPointY || posZ != lastPointZ) {
        // add new point to the trajectory
        pathLength = data->pathLength[idx];

        data->lastPointIndex++;
        if (data->lastPointIndex >= MAX_POINTS) {
            data->lastPointIndex = 0;
        }

        idx = data->lastPointIndex;

        data->pathPointEnabled[idx] = TRUE;
        data->pathX[idx] = posX;
        data->pathY[idx] = posY;
        data->pathZ[idx] = posZ;
        data->pathTimestamp[idx] = lifeTime;

        dist = SQ(posX - lastPointX) + SQ(posY - lastPointY) + SQ(posZ - lastPointZ);
        if (dist != 0.0f) {
            dist = shim_sqrtf(dist);
        }

        data->pathLength[idx] = pathLength + dist;
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel func_802C39F8
/* E83A8 802C39F8 27BDFFD8 */  addiu     $sp, $sp, -0x28
/* E83AC 802C39FC AFB10014 */  sw        $s1, 0x14($sp)
/* E83B0 802C3A00 0080882D */  daddu     $s1, $a0, $zero
/* E83B4 802C3A04 AFB20018 */  sw        $s2, 0x18($sp)
/* E83B8 802C3A08 00A0902D */  daddu     $s2, $a1, $zero
/* E83BC 802C3A0C AFB3001C */  sw        $s3, 0x1C($sp)
/* E83C0 802C3A10 00C0982D */  daddu     $s3, $a2, $zero
/* E83C4 802C3A14 3C04802E */  lui       $a0, %hi(gCurrentScriptListPtr)
/* E83C8 802C3A18 8C84A890 */  lw        $a0, %lo(gCurrentScriptListPtr)($a0)
/* E83CC 802C3A1C 0000182D */  daddu     $v1, $zero, $zero
/* E83D0 802C3A20 AFBF0024 */  sw        $ra, 0x24($sp)
/* E83D4 802C3A24 AFB40020 */  sw        $s4, 0x20($sp)
/* E83D8 802C3A28 AFB00010 */  sw        $s0, 0x10($sp)
.L802C3A2C:
/* E83DC 802C3A2C 8C820000 */  lw        $v0, 0x0($a0)
/* E83E0 802C3A30 10400006 */  beqz      $v0, .L802C3A4C
/* E83E4 802C3A34 28620080 */   slti     $v0, $v1, 0x80
/* E83E8 802C3A38 24630001 */  addiu     $v1, $v1, 0x1
/* E83EC 802C3A3C 28620080 */  slti      $v0, $v1, 0x80
/* E83F0 802C3A40 1440FFFA */  bnez      $v0, .L802C3A2C
/* E83F4 802C3A44 24840004 */   addiu    $a0, $a0, 0x4
/* E83F8 802C3A48 28620080 */  slti      $v0, $v1, 0x80
.L802C3A4C:
/* E83FC 802C3A4C 54400003 */  bnel      $v0, $zero, .L802C3A5C
/* E8400 802C3A50 24040168 */   addiu    $a0, $zero, 0x168
.L802C3A54:
/* E8404 802C3A54 080B0E95 */  j         .L802C3A54
/* E8408 802C3A58 00000000 */   nop
.L802C3A5C:
/* E840C 802C3A5C 0C00AB39 */  jal       heap_malloc
/* E8410 802C3A60 0060A02D */   daddu    $s4, $v1, $zero
/* E8414 802C3A64 00142080 */  sll       $a0, $s4, 2
/* E8418 802C3A68 3C03802E */  lui       $v1, %hi(gCurrentScriptListPtr)
/* E841C 802C3A6C 8C63A890 */  lw        $v1, %lo(gCurrentScriptListPtr)($v1)
/* E8420 802C3A70 3C05802E */  lui       $a1, %hi(gNumScripts)
/* E8424 802C3A74 24A5A488 */  addiu     $a1, $a1, %lo(gNumScripts)
/* E8428 802C3A78 00832021 */  addu      $a0, $a0, $v1
/* E842C 802C3A7C 8CA30000 */  lw        $v1, 0x0($a1)
/* E8430 802C3A80 0040802D */  daddu     $s0, $v0, $zero
/* E8434 802C3A84 AC900000 */  sw        $s0, 0x0($a0)
/* E8438 802C3A88 24630001 */  addiu     $v1, $v1, 0x1
/* E843C 802C3A8C 16000003 */  bnez      $s0, .L802C3A9C
/* E8440 802C3A90 ACA30000 */   sw       $v1, 0x0($a1)
.L802C3A94:
/* E8444 802C3A94 080B0EA5 */  j         .L802C3A94
/* E8448 802C3A98 00000000 */   nop
.L802C3A9C:
/* E844C 802C3A9C 36620001 */  ori       $v0, $s3, 0x1
/* E8450 802C3AA0 A2020000 */  sb        $v0, 0x0($s0)
/* E8454 802C3AA4 AE120008 */  sw        $s2, 0x8($s0)
/* E8458 802C3AA8 AE12015C */  sw        $s2, 0x15C($s0)
/* E845C 802C3AAC AE120164 */  sw        $s2, 0x164($s0)
/* E8460 802C3AB0 A2000002 */  sb        $zero, 0x2($s0)
/* E8464 802C3AB4 AE000060 */  sw        $zero, 0x60($s0)
/* E8468 802C3AB8 AE000064 */  sw        $zero, 0x64($s0)
/* E846C 802C3ABC AE11006C */  sw        $s1, 0x6C($s0)
/* E8470 802C3AC0 AE000068 */  sw        $zero, 0x68($s0)
/* E8474 802C3AC4 92220003 */  lbu       $v0, 0x3($s1)
/* E8478 802C3AC8 3C04802E */  lui       $a0, %hi(gStaticScriptCounter)
/* E847C 802C3ACC 24849CA0 */  addiu     $a0, $a0, %lo(gStaticScriptCounter)
/* E8480 802C3AD0 A2020003 */  sb        $v0, 0x3($s0)
/* E8484 802C3AD4 8C820000 */  lw        $v0, 0x0($a0)
/* E8488 802C3AD8 AE020144 */  sw        $v0, 0x144($s0)
/* E848C 802C3ADC 8E230148 */  lw        $v1, 0x148($s1)
/* E8490 802C3AE0 24420001 */  addiu     $v0, $v0, 0x1
/* E8494 802C3AE4 AC820000 */  sw        $v0, 0x0($a0)
/* E8498 802C3AE8 AE030148 */  sw        $v1, 0x148($s0)
/* E849C 802C3AEC 8E23014C */  lw        $v1, 0x14C($s1)
/* E84A0 802C3AF0 2402FFFF */  addiu     $v0, $zero, -0x1
/* E84A4 802C3AF4 A2020006 */  sb        $v0, 0x6($s0)
/* E84A8 802C3AF8 A2020007 */  sb        $v0, 0x7($s0)
/* E84AC 802C3AFC AE03014C */  sw        $v1, 0x14C($s0)
/* E84B0 802C3B00 92220004 */  lbu       $v0, 0x4($s1)
/* E84B4 802C3B04 0220282D */  daddu     $a1, $s1, $zero
/* E84B8 802C3B08 AE000160 */  sw        $zero, 0x160($s0)
/* E84BC 802C3B0C A2020004 */  sb        $v0, 0x4($s0)
/* E84C0 802C3B10 8E22013C */  lw        $v0, 0x13C($s1)
/* E84C4 802C3B14 3C01802E */  lui       $at, %hi(gGlobalTimeSpace)
/* E84C8 802C3B18 C4209CA8 */  lwc1      $f0, %lo(gGlobalTimeSpace)($at)
/* E84CC 802C3B1C 0200202D */  daddu     $a0, $s0, $zero
/* E84D0 802C3B20 AE02013C */  sw        $v0, 0x13C($s0)
/* E84D4 802C3B24 8E220140 */  lw        $v0, 0x140($s1)
/* E84D8 802C3B28 0000182D */  daddu     $v1, $zero, $zero
/* E84DC 802C3B2C E6000150 */  swc1      $f0, 0x150($s0)
/* E84E0 802C3B30 AE000154 */  sw        $zero, 0x154($s0)
/* E84E4 802C3B34 AE000158 */  sw        $zero, 0x158($s0)
/* E84E8 802C3B38 AE020140 */  sw        $v0, 0x140($s0)
.L802C3B3C:
/* E84EC 802C3B3C 8CA20084 */  lw        $v0, 0x84($a1)
/* E84F0 802C3B40 24A50004 */  addiu     $a1, $a1, 0x4
/* E84F4 802C3B44 24630001 */  addiu     $v1, $v1, 0x1
/* E84F8 802C3B48 AC820084 */  sw        $v0, 0x84($a0)
/* E84FC 802C3B4C 28620010 */  slti      $v0, $v1, 0x10
/* E8500 802C3B50 1440FFFA */  bnez      $v0, .L802C3B3C
/* E8504 802C3B54 24840004 */   addiu    $a0, $a0, 0x4
/* E8508 802C3B58 0000182D */  daddu     $v1, $zero, $zero
/* E850C 802C3B5C 0220202D */  daddu     $a0, $s1, $zero
/* E8510 802C3B60 0200282D */  daddu     $a1, $s0, $zero
.L802C3B64:
/* E8514 802C3B64 8C8200C4 */  lw        $v0, 0xC4($a0)
/* E8518 802C3B68 24840004 */  addiu     $a0, $a0, 0x4
/* E851C 802C3B6C 24630001 */  addiu     $v1, $v1, 0x1
/* E8520 802C3B70 ACA200C4 */  sw        $v0, 0xC4($a1)
/* E8524 802C3B74 28620003 */  slti      $v0, $v1, 0x3
/* E8528 802C3B78 1440FFFA */  bnez      $v0, .L802C3B64
/* E852C 802C3B7C 24A50004 */   addiu    $a1, $a1, 0x4
/* E8530 802C3B80 0C0B0C52 */  jal       find_script_labels
/* E8534 802C3B84 0200202D */   daddu    $a0, $s0, $zero
/* E8538 802C3B88 3C02802E */  lui       $v0, %hi(gIsUpdatingScripts)
/* E853C 802C3B8C 8C429CA4 */  lw        $v0, %lo(gIsUpdatingScripts)($v0)
/* E8540 802C3B90 1040000E */  beqz      $v0, .L802C3BCC
/* E8544 802C3B94 00000000 */   nop
/* E8548 802C3B98 3C05802E */  lui       $a1, %hi(gScriptListCount)
/* E854C 802C3B9C 24A5AC98 */  addiu     $a1, $a1, %lo(gScriptListCount)
/* E8550 802C3BA0 8CA20000 */  lw        $v0, 0x0($a1)
/* E8554 802C3BA4 00022080 */  sll       $a0, $v0, 2
/* E8558 802C3BA8 3C01802E */  lui       $at, %hi(gScriptIndexList)
/* E855C 802C3BAC 00240821 */  addu      $at, $at, $a0
/* E8560 802C3BB0 AC34A898 */  sw        $s4, %lo(gScriptIndexList)($at)
/* E8564 802C3BB4 8E030144 */  lw        $v1, 0x144($s0)
/* E8568 802C3BB8 24420001 */  addiu     $v0, $v0, 0x1
/* E856C 802C3BBC ACA20000 */  sw        $v0, 0x0($a1)
/* E8570 802C3BC0 3C01802E */  lui       $at, %hi(gScriptIdList)
/* E8574 802C3BC4 00240821 */  addu      $at, $at, $a0
/* E8578 802C3BC8 AC23AA98 */  sw        $v1, %lo(gScriptIdList)($at)
.L802C3BCC:
/* E857C 802C3BCC 3C03802E */  lui       $v1, %hi(gStaticScriptCounter)
/* E8580 802C3BD0 24639CA0 */  addiu     $v1, $v1, %lo(gStaticScriptCounter)
/* E8584 802C3BD4 8C620000 */  lw        $v0, 0x0($v1)
/* E8588 802C3BD8 14400002 */  bnez      $v0, .L802C3BE4
/* E858C 802C3BDC 24020001 */   addiu    $v0, $zero, 0x1
/* E8590 802C3BE0 AC620000 */  sw        $v0, 0x0($v1)
.L802C3BE4:
/* E8594 802C3BE4 0C0B0CE4 */  jal       suspend_frozen_scripts
/* E8598 802C3BE8 0200202D */   daddu    $a0, $s0, $zero
/* E859C 802C3BEC 0200102D */  daddu     $v0, $s0, $zero
/* E85A0 802C3BF0 8FBF0024 */  lw        $ra, 0x24($sp)
/* E85A4 802C3BF4 8FB40020 */  lw        $s4, 0x20($sp)
/* E85A8 802C3BF8 8FB3001C */  lw        $s3, 0x1C($sp)
/* E85AC 802C3BFC 8FB20018 */  lw        $s2, 0x18($sp)
/* E85B0 802C3C00 8FB10014 */  lw        $s1, 0x14($sp)
/* E85B4 802C3C04 8FB00010 */  lw        $s0, 0x10($sp)
/* E85B8 802C3C08 03E00008 */  jr        $ra
/* E85BC 802C3C0C 27BD0028 */   addiu    $sp, $sp, 0x28

### DECOMPILED C INSTRUCTIONS:

Evt* func_802C39F8(Evt* parentScript, Bytecode* nextLine, s32 newState) {
    Evt* child;
    s32 curScriptIndex;
    s32 i;
    s32 scriptListCount;

    for (i = 0; i < MAX_SCRIPTS; i++) {
        if ((*gCurrentScriptListPtr)[i] == NULL) {
            break;
        }
    }

    ASSERT(i < MAX_SCRIPTS);
    curScriptIndex = i;

    (*gCurrentScriptListPtr)[curScriptIndex] = child = heap_malloc(sizeof(*child));
    gNumScripts++;
    ASSERT(child != NULL);

    child->stateFlags = newState | EVT_FLAG_ACTIVE;
    child->ptrNextLine = nextLine;
    child->ptrFirstLine = nextLine;
    child->ptrCurrentLine = nextLine;
    child->currentOpcode = EVT_OP_INTERNAL_FETCH;
    child->userData = NULL;
    child->blockingParent = NULL;
    child->parentScript = parentScript;
    child->childScript = NULL;
    child->priority = parentScript->priority;
    child->id = gStaticScriptCounter++;
    child->owner1.actorID = parentScript->owner1.actorID;
    child->owner2.npcID = parentScript->owner2.npcID;
    child->loopDepth = -1;
    child->switchDepth = -1;
    child->groupFlags = parentScript->groupFlags;
    child->ptrSavedPos = NULL;
    child->array = parentScript->array;
    child->flagArray = parentScript->flagArray;
    child->timeScale = gGlobalTimeSpace;
    child->frameCounter = 0.0f;
    child->unk_158 = 0;

    scriptListCount = 0;

    for (i = 0; i < ARRAY_COUNT(child->varTable); i++) {
        child->varTable[i] = parentScript->varTable[i];
    }

    for (i = 0; i < ARRAY_COUNT(child->varFlags); i++) {
        child->varFlags[i] = parentScript->varFlags[i];
    }

    find_script_labels(child);
    if (gIsUpdatingScripts) {
        scriptListCount = gScriptListCount++;
        gScriptIndexList[scriptListCount] = curScriptIndex;
        gScriptIdList[scriptListCount] = child->id;
    }

    if (gStaticScriptCounter == 0) {
        gStaticScriptCounter = 1;
    }

    suspend_frozen_scripts(child);
    return child;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel player_test_lateral_overlap
/* 780B4 800DEC04 27BDFF58 */  addiu     $sp, $sp, -0xA8
/* 780B8 800DEC08 AFB40078 */  sw        $s4, 0x78($sp)
/* 780BC 800DEC0C 0080A02D */  daddu     $s4, $a0, $zero
/* 780C0 800DEC10 AFB20070 */  sw        $s2, 0x70($sp)
/* 780C4 800DEC14 00C0902D */  daddu     $s2, $a2, $zero
/* 780C8 800DEC18 AFB00068 */  sw        $s0, 0x68($sp)
/* 780CC 800DEC1C 00E0802D */  daddu     $s0, $a3, $zero
/* 780D0 800DEC20 AFB30074 */  sw        $s3, 0x74($sp)
/* 780D4 800DEC24 AFBF007C */  sw        $ra, 0x7C($sp)
/* 780D8 800DEC28 AFB1006C */  sw        $s1, 0x6C($sp)
/* 780DC 800DEC2C F7BC00A0 */  sdc1      $f28, 0xA0($sp)
/* 780E0 800DEC30 F7BA0098 */  sdc1      $f26, 0x98($sp)
/* 780E4 800DEC34 F7B80090 */  sdc1      $f24, 0x90($sp)
/* 780E8 800DEC38 F7B60088 */  sdc1      $f22, 0x88($sp)
/* 780EC 800DEC3C F7B40080 */  sdc1      $f20, 0x80($sp)
/* 780F0 800DEC40 84A200B2 */  lh        $v0, 0xB2($a1)
/* 780F4 800DEC44 3C013F00 */  lui       $at, (0x3F000000 >> 16)
/* 780F8 800DEC48 44810000 */  mtc1      $at, $f0
/* 780FC 800DEC4C 8FB100B8 */  lw        $s1, 0xB8($sp)
/* 78100 800DEC50 C7B400BC */  lwc1      $f20, 0xBC($sp)
/* 78104 800DEC54 44821000 */  mtc1      $v0, $f2
/* 78108 800DEC58 00000000 */  nop
/* 7810C 800DEC5C 468010A0 */  cvt.s.w   $f2, $f2
/* 78110 800DEC60 8CA20000 */  lw        $v0, 0x0($a1)
/* 78114 800DEC64 46001702 */  mul.s     $f28, $f2, $f0
/* 78118 800DEC68 00000000 */  nop
/* 7811C 800DEC6C 30420006 */  andi      $v0, $v0, 0x6
/* 78120 800DEC70 1440000B */  bnez      $v0, .L800DECA0
/* 78124 800DEC74 2413FFFF */   addiu    $s3, $zero, -0x1
/* 78128 800DEC78 84A200B0 */  lh        $v0, 0xB0($a1)
/* 7812C 800DEC7C 3C013E92 */  lui       $at, (0x3E926E98 >> 16)
/* 78130 800DEC80 34216E98 */  ori       $at, $at, (0x3E926E98 & 0xFFFF)
/* 78134 800DEC84 44811000 */  mtc1      $at, $f2
/* 78138 800DEC88 44820000 */  mtc1      $v0, $f0
/* 7813C 800DEC8C 00000000 */  nop
/* 78140 800DEC90 46800020 */  cvt.s.w   $f0, $f0
/* 78144 800DEC94 46020582 */  mul.s     $f22, $f0, $f2
/* 78148 800DEC98 08037B2A */  j         .L800DECA8
/* 7814C 800DEC9C 00000000 */   nop
.L800DECA0:
/* 78150 800DECA0 3C013F80 */  lui       $at, (0x3F800000 >> 16)
/* 78154 800DECA4 4481B000 */  mtc1      $at, $f22
.L800DECA8:
/* 78158 800DECA8 3C0140C9 */  lui       $at, (0x40C90FD0 >> 16)
/* 7815C 800DECAC 34210FD0 */  ori       $at, $at, (0x40C90FD0 & 0xFFFF)
/* 78160 800DECB0 44810000 */  mtc1      $at, $f0
/* 78164 800DECB4 C7AC00C0 */  lwc1      $f12, 0xC0($sp)
/* 78168 800DECB8 46006302 */  mul.s     $f12, $f12, $f0
/* 7816C 800DECBC 00000000 */  nop
/* 78170 800DECC0 27A50038 */  addiu     $a1, $sp, 0x38
/* 78174 800DECC4 3C0143B4 */  lui       $at, (0x43B40000 >> 16)
/* 78178 800DECC8 44810000 */  mtc1      $at, $f0
/* 7817C 800DECCC 27A6003C */  addiu     $a2, $sp, 0x3C
/* 78180 800DECD0 0C00A82D */  jal       sin_cos_rad
/* 78184 800DECD4 46006303 */   div.s    $f12, $f12, $f0
/* 78188 800DECD8 461CA080 */  add.s     $f2, $f20, $f28
/* 7818C 800DECDC C7A0003C */  lwc1      $f0, 0x3C($sp)
/* 78190 800DECE0 46000007 */  neg.s     $f0, $f0
/* 78194 800DECE4 E7A0003C */  swc1      $f0, 0x3C($sp)
/* 78198 800DECE8 E7A2004C */  swc1      $f2, 0x4C($sp)
/* 7819C 800DECEC C7A20038 */  lwc1      $f2, 0x38($sp)
/* 781A0 800DECF0 C6040000 */  lwc1      $f4, 0x0($s0)
/* 781A4 800DECF4 27A20040 */  addiu     $v0, $sp, 0x40
/* 781A8 800DECF8 AFA2001C */  sw        $v0, 0x1C($sp)
/* 781AC 800DECFC 27A20044 */  addiu     $v0, $sp, 0x44
/* 781B0 800DED00 AFA20020 */  sw        $v0, 0x20($sp)
/* 781B4 800DED04 27A20048 */  addiu     $v0, $sp, 0x48
/* 781B8 800DED08 AFA20024 */  sw        $v0, 0x24($sp)
/* 781BC 800DED0C 27A2004C */  addiu     $v0, $sp, 0x4C
/* 781C0 800DED10 AFA20028 */  sw        $v0, 0x28($sp)
/* 781C4 800DED14 27A20050 */  addiu     $v0, $sp, 0x50
/* 781C8 800DED18 AFA2002C */  sw        $v0, 0x2C($sp)
/* 781CC 800DED1C 27A20054 */  addiu     $v0, $sp, 0x54
/* 781D0 800DED20 AFA20030 */  sw        $v0, 0x30($sp)
/* 781D4 800DED24 27A20058 */  addiu     $v0, $sp, 0x58
/* 781D8 800DED28 AFA00014 */  sw        $zero, 0x14($sp)
/* 781DC 800DED2C E7A00018 */  swc1      $f0, 0x18($sp)
/* 781E0 800DED30 AFA20034 */  sw        $v0, 0x34($sp)
/* 781E4 800DED34 46162100 */  add.s     $f4, $f4, $f22
/* 781E8 800DED38 E7A20010 */  swc1      $f2, 0x10($sp)
/* 781EC 800DED3C 8E450000 */  lw        $a1, 0x0($s2)
/* 781F0 800DED40 8E270000 */  lw        $a3, 0x0($s1)
/* 781F4 800DED44 44062000 */  mfc1      $a2, $f4
/* 781F8 800DED48 0C037B97 */  jal       player_raycast_general
/* 781FC 800DED4C 0280202D */   daddu    $a0, $s4, $zero
/* 78200 800DED50 0040802D */  daddu     $s0, $v0, $zero
/* 78204 800DED54 24020003 */  addiu     $v0, $zero, 0x3
/* 78208 800DED58 16820004 */  bne       $s4, $v0, .L800DED6C
/* 7820C 800DED5C 00000000 */   nop
/* 78210 800DED60 4480C000 */  mtc1      $zero, $f24
/* 78214 800DED64 08037B61 */  j         .L800DED84
/* 78218 800DED68 4600C686 */   mov.s    $f26, $f24
.L800DED6C:
/* 7821C 800DED6C C7A00038 */  lwc1      $f0, 0x38($sp)
/* 78220 800DED70 4600A682 */  mul.s     $f26, $f20, $f0
/* 78224 800DED74 00000000 */  nop
/* 78228 800DED78 C7A0003C */  lwc1      $f0, 0x3C($sp)
/* 7822C 800DED7C 4600A602 */  mul.s     $f24, $f20, $f0
/* 78230 800DED80 00000000 */  nop
.L800DED84:
/* 78234 800DED84 06000021 */  bltz      $s0, .L800DEE0C
/* 78238 800DED88 00000000 */   nop
/* 7823C 800DED8C 461CA080 */  add.s     $f2, $f20, $f28
/* 78240 800DED90 C7B6004C */  lwc1      $f22, 0x4C($sp)
/* 78244 800DED94 4602B03E */  c.le.s    $f22, $f2
/* 78248 800DED98 00000000 */  nop
/* 7824C 800DED9C 4500001B */  bc1f      .L800DEE0C
/* 78250 800DEDA0 27A4005C */   addiu    $a0, $sp, 0x5C
/* 78254 800DEDA4 4602B581 */  sub.s     $f22, $f22, $f2
/* 78258 800DEDA8 4406D000 */  mfc1      $a2, $f26
/* 7825C 800DEDAC C7B40038 */  lwc1      $f20, 0x38($sp)
/* 78260 800DEDB0 4407C000 */  mfc1      $a3, $f24
/* 78264 800DEDB4 C7A2003C */  lwc1      $f2, 0x3C($sp)
/* 78268 800DEDB8 4614B502 */  mul.s     $f20, $f22, $f20
/* 7826C 800DEDBC 00000000 */  nop
/* 78270 800DEDC0 C7A00050 */  lwc1      $f0, 0x50($sp)
/* 78274 800DEDC4 27A50060 */  addiu     $a1, $sp, 0x60
/* 78278 800DEDC8 E7A00010 */  swc1      $f0, 0x10($sp)
/* 7827C 800DEDCC C7A00058 */  lwc1      $f0, 0x58($sp)
/* 78280 800DEDD0 4602B582 */  mul.s     $f22, $f22, $f2
/* 78284 800DEDD4 00000000 */  nop
/* 78288 800DEDD8 0C037CFF */  jal       player_get_slip_vector
/* 7828C 800DEDDC E7A00014 */   swc1     $f0, 0x14($sp)
/* 78290 800DEDE0 C7A0005C */  lwc1      $f0, 0x5C($sp)
/* 78294 800DEDE4 4600A500 */  add.s     $f20, $f20, $f0
/* 78298 800DEDE8 C6400000 */  lwc1      $f0, 0x0($s2)
/* 7829C 800DEDEC 46140000 */  add.s     $f0, $f0, $f20
/* 782A0 800DEDF0 E6400000 */  swc1      $f0, 0x0($s2)
/* 782A4 800DEDF4 C7A00060 */  lwc1      $f0, 0x60($sp)
/* 782A8 800DEDF8 4600B580 */  add.s     $f22, $f22, $f0
/* 782AC 800DEDFC C6200000 */  lwc1      $f0, 0x0($s1)
/* 782B0 800DEE00 46160000 */  add.s     $f0, $f0, $f22
/* 782B4 800DEE04 0200982D */  daddu     $s3, $s0, $zero
/* 782B8 800DEE08 E6200000 */  swc1      $f0, 0x0($s1)
.L800DEE0C:
/* 782BC 800DEE0C C6400000 */  lwc1      $f0, 0x0($s2)
/* 782C0 800DEE10 461A0000 */  add.s     $f0, $f0, $f26
/* 782C4 800DEE14 E6400000 */  swc1      $f0, 0x0($s2)
/* 782C8 800DEE18 C6200000 */  lwc1      $f0, 0x0($s1)
/* 782CC 800DEE1C 46180000 */  add.s     $f0, $f0, $f24
/* 782D0 800DEE20 0260102D */  daddu     $v0, $s3, $zero
/* 782D4 800DEE24 E6200000 */  swc1      $f0, 0x0($s1)
/* 782D8 800DEE28 8FBF007C */  lw        $ra, 0x7C($sp)
/* 782DC 800DEE2C 8FB40078 */  lw        $s4, 0x78($sp)
/* 782E0 800DEE30 8FB30074 */  lw        $s3, 0x74($sp)
/* 782E4 800DEE34 8FB20070 */  lw        $s2, 0x70($sp)
/* 782E8 800DEE38 8FB1006C */  lw        $s1, 0x6C($sp)
/* 782EC 800DEE3C 8FB00068 */  lw        $s0, 0x68($sp)
/* 782F0 800DEE40 D7BC00A0 */  ldc1      $f28, 0xA0($sp)
/* 782F4 800DEE44 D7BA0098 */  ldc1      $f26, 0x98($sp)
/* 782F8 800DEE48 D7B80090 */  ldc1      $f24, 0x90($sp)
/* 782FC 800DEE4C D7B60088 */  ldc1      $f22, 0x88($sp)
/* 78300 800DEE50 D7B40080 */  ldc1      $f20, 0x80($sp)
/* 78304 800DEE54 03E00008 */  jr        $ra
/* 78308 800DEE58 27BD00A8 */   addiu    $sp, $sp, 0xA8

### DECOMPILED C INSTRUCTIONS:

s32 player_test_lateral_overlap(s32 mode, PlayerStatus* playerStatus, f32* x, f32* y, f32* z, f32 length, f32 yaw) {
    f32 sinTheta;
    f32 cosTheta;
    f32 hitX;
    f32 hitY;
    f32 hitZ;
    f32 hitDepth;
    f32 hitNx;
    f32 hitNy;
    f32 hitNz;
    f32 slipDx;
    f32 slipDz;
    f32 depthDiff;
    f32 radius;
    f32 originalDepth;
    s32 hitID;
    f32 height;
    f32 targetDx;
    f32 targetDz;
    f32 dx;
    f32 dz;
    s32 ret;

    radius = playerStatus->colliderDiameter * 0.5f;
    ret = NO_COLLIDER;

    if (!(playerStatus->flags & (PS_FLAG_FALLING | PS_FLAG_JUMPING))) {
        height = playerStatus->colliderHeight * 0.286f;
    } else {
        height = 1.0f;
    }

    sin_cos_rad(DEG_TO_RAD(yaw), &sinTheta, &cosTheta);
    cosTheta = -cosTheta;
    hitDepth = length + radius;
    hitID = player_raycast_general(mode, *x, *y + height, *z, sinTheta, 0, cosTheta, &hitX, &hitY, &hitZ, &hitDepth, &hitNx, &hitNy, &hitNz);

    if (mode == 3) {
        targetDx = 0.0f;
        targetDz = 0.0f;
    } else {
        targetDx = length * sinTheta;
        targetDz = length * cosTheta;
    }

    if (hitID >= 0) {
        originalDepth = length + radius;
        if (hitDepth <= originalDepth) {
            depthDiff = hitDepth - originalDepth;
            dx = depthDiff * sinTheta;
            dz = depthDiff * cosTheta;

            player_get_slip_vector(&slipDx, &slipDz, targetDx, targetDz, hitNx, hitNz);
            *x += dx + slipDx;
            *z += dz + slipDz;
            ret = hitID;
        }
    }

    *x += targetDx;
    *z += targetDz;
    return ret;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel load_obfuscation_shims
/* 8560 8002D160 27BDFFC0 */  addiu     $sp, $sp, -0x40
/* 8564 8002D164 AFB60030 */  sw        $s6, 0x30($sp)
/* 8568 8002D168 3C16759A */  lui       $s6, %hi(D_7599F6D8)
/* 856C 8002D16C 26D6F6D8 */  addiu     $s6, $s6, %lo(D_7599F6D8)
/* 8570 8002D170 AFB5002C */  sw        $s5, 0x2C($sp)
/* 8574 8002D174 3C15F79E */  lui       $s5, %hi(D_F79DDD0F)
/* 8578 8002D178 26B5DD0F */  addiu     $s5, $s5, %lo(D_F79DDD0F)
/* 857C 8002D17C AFB30024 */  sw        $s3, 0x24($sp)
/* 8580 8002D180 3C130B11 */  lui       $s3, (0xB112D28 >> 16)
/* 8584 8002D184 36732D28 */  ori       $s3, $s3, (0xB112D28 & 0xFFFF)
/* 8588 8002D188 AFB00018 */  sw        $s0, 0x18($sp)
/* 858C 8002D18C 0000802D */  daddu     $s0, $zero, $zero
/* 8590 8002D190 3C05B000 */  lui       $a1, (0xB0000D10 >> 16)
/* 8594 8002D194 34A50D10 */  ori       $a1, $a1, (0xB0000D10 & 0xFFFF)
/* 8598 8002D198 3C04800A */  lui       $a0, %hi(nuPiCartHandle)
/* 859C 8002D19C 8C84A638 */  lw        $a0, %lo(nuPiCartHandle)($a0)
/* 85A0 8002D1A0 27A60010 */  addiu     $a2, $sp, 0x10
/* 85A4 8002D1A4 AFB20020 */  sw        $s2, 0x20($sp)
/* 85A8 8002D1A8 0200902D */  daddu     $s2, $s0, $zero
/* 85AC 8002D1AC AFB40028 */  sw        $s4, 0x28($sp)
/* 85B0 8002D1B0 3C148006 */  lui       $s4, %hi(osEPiReadIo)
/* 85B4 8002D1B4 26940DC0 */  addiu     $s4, $s4, %lo(osEPiReadIo)
/* 85B8 8002D1B8 AFBF003C */  sw        $ra, 0x3C($sp)
/* 85BC 8002D1BC AFBE0038 */  sw        $fp, 0x38($sp)
/* 85C0 8002D1C0 AFB70034 */  sw        $s7, 0x34($sp)
/* 85C4 8002D1C4 0280F809 */  jalr      $s4
/* 85C8 8002D1C8 AFB1001C */   sw       $s1, 0x1C($sp)
/* 85CC 8002D1CC 3C110031 */  lui       $s1, %hi(D_316D90)
/* 85D0 8002D1D0 26316D90 */  addiu     $s1, $s1, %lo(D_316D90)
/* 85D4 8002D1D4 8FA20010 */  lw        $v0, 0x10($sp)
/* 85D8 8002D1D8 3C030031 */  lui       $v1, %hi(D_316F30)
/* 85DC 8002D1DC 24636F30 */  addiu     $v1, $v1, %lo(D_316F30)
/* 85E0 8002D1E0 02629823 */  subu      $s3, $s3, $v0
/* 85E4 8002D1E4 0223102B */  sltu      $v0, $s1, $v1
/* 85E8 8002D1E8 1040002B */  beqz      $v0, .L8002D298
/* 85EC 8002D1EC 241E0003 */   addiu    $fp, $zero, 0x3
/* 85F0 8002D1F0 0060B82D */  daddu     $s7, $v1, $zero
.L8002D1F4:
/* 85F4 8002D1F4 0220282D */  daddu     $a1, $s1, $zero
/* 85F8 8002D1F8 3C04800A */  lui       $a0, %hi(nuPiCartHandle)
/* 85FC 8002D1FC 8C84A638 */  lw        $a0, %lo(nuPiCartHandle)($a0)
/* 8600 8002D200 0280F809 */  jalr      $s4
/* 8604 8002D204 27A60010 */   addiu    $a2, $sp, 0x10
/* 8608 8002D208 8FA30010 */  lw        $v1, 0x10($sp)
/* 860C 8002D20C 2407000F */  addiu     $a3, $zero, 0xF
/* 8610 8002D210 3065FFFF */  andi      $a1, $v1, 0xFFFF
/* 8614 8002D214 00032402 */  srl       $a0, $v1, 16
/* 8618 8002D218 00A41021 */  addu      $v0, $a1, $a0
/* 861C 8002D21C 02028021 */  addu      $s0, $s0, $v0
/* 8620 8002D220 00121682 */  srl       $v0, $s2, 26
/* 8624 8002D224 14470010 */  bne       $v0, $a3, .L8002D268
/* 8628 8002D228 00031682 */   srl      $v0, $v1, 26
/* 862C 8002D22C 24070009 */  addiu     $a3, $zero, 0x9
/* 8630 8002D230 50470004 */  beql      $v0, $a3, .L8002D244
/* 8634 8002D234 00031542 */   srl      $v0, $v1, 21
/* 8638 8002D238 24070023 */  addiu     $a3, $zero, 0x23
/* 863C 8002D23C 1447000A */  bne       $v0, $a3, .L8002D268
/* 8640 8002D240 00031542 */   srl      $v0, $v1, 21
.L8002D244:
/* 8644 8002D244 3043001F */  andi      $v1, $v0, 0x1F
/* 8648 8002D248 00121402 */  srl       $v0, $s2, 16
/* 864C 8002D24C 3042001F */  andi      $v0, $v0, 0x1F
/* 8650 8002D250 14620005 */  bne       $v1, $v0, .L8002D268
/* 8654 8002D254 3082001F */   andi     $v0, $a0, 0x1F
/* 8658 8002D258 14620003 */  bne       $v1, $v0, .L8002D268
/* 865C 8002D25C 3242FFFF */   andi     $v0, $s2, 0xFFFF
/* 8660 8002D260 02058023 */  subu      $s0, $s0, $a1
/* 8664 8002D264 02028023 */  subu      $s0, $s0, $v0
.L8002D268:
/* 8668 8002D268 8FA40010 */  lw        $a0, 0x10($sp)
/* 866C 8002D26C 00041682 */  srl       $v0, $a0, 26
/* 8670 8002D270 145E0006 */  bne       $v0, $fp, .L8002D28C
/* 8674 8002D274 26310004 */   addiu    $s1, $s1, 0x4
/* 8678 8002D278 3083FFFF */  andi      $v1, $a0, 0xFFFF
/* 867C 8002D27C 00041402 */  srl       $v0, $a0, 16
/* 8680 8002D280 3042FC00 */  andi      $v0, $v0, 0xFC00
/* 8684 8002D284 00621821 */  addu      $v1, $v1, $v0
/* 8688 8002D288 02038023 */  subu      $s0, $s0, $v1
.L8002D28C:
/* 868C 8002D28C 0237102B */  sltu      $v0, $s1, $s7
/* 8690 8002D290 1440FFD8 */  bnez      $v0, .L8002D1F4
/* 8694 8002D294 0080902D */   daddu    $s2, $a0, $zero
.L8002D298:
/* 8698 8002D298 3C02FFD5 */  lui       $v0, (0xFFD5B14A >> 16)
/* 869C 8002D29C 3442B14A */  ori       $v0, $v0, (0xFFD5B14A & 0xFFFF)
/* 86A0 8002D2A0 02021021 */  addu      $v0, $s0, $v0
/* 86A4 8002D2A4 02621023 */  subu      $v0, $s3, $v0
/* 86A8 8002D2A8 02C2B021 */  addu      $s6, $s6, $v0
/* 86AC 8002D2AC 3C1318F4 */  lui       $s3, (0x18F414AB >> 16)
/* 86B0 8002D2B0 367314AB */  ori       $s3, $s3, (0x18F414AB & 0xFFFF)
/* 86B4 8002D2B4 0000802D */  daddu     $s0, $zero, $zero
/* 86B8 8002D2B8 3C05B000 */  lui       $a1, (0xB0000E38 >> 16)
/* 86BC 8002D2BC 34A50E38 */  ori       $a1, $a1, (0xB0000E38 & 0xFFFF)
/* 86C0 8002D2C0 27A60014 */  addiu     $a2, $sp, 0x14
/* 86C4 8002D2C4 3C04800A */  lui       $a0, %hi(nuPiCartHandle)
/* 86C8 8002D2C8 8C84A638 */  lw        $a0, %lo(nuPiCartHandle)($a0)
/* 86CC 8002D2CC 3C148006 */  lui       $s4, %hi(osEPiReadIo)
/* 86D0 8002D2D0 26940DC0 */  addiu     $s4, $s4, %lo(osEPiReadIo)
/* 86D4 8002D2D4 0280F809 */  jalr      $s4
/* 86D8 8002D2D8 0200902D */   daddu    $s2, $s0, $zero
/* 86DC 8002D2DC 3C110031 */  lui       $s1, %hi(D_316F30)
/* 86E0 8002D2E0 26316F30 */  addiu     $s1, $s1, %lo(D_316F30)
/* 86E4 8002D2E4 8FA20014 */  lw        $v0, 0x14($sp)
/* 86E8 8002D2E8 3C030031 */  lui       $v1, %hi(D_317020)
/* 86EC 8002D2EC 24637020 */  addiu     $v1, $v1, %lo(D_317020)
/* 86F0 8002D2F0 02629823 */  subu      $s3, $s3, $v0
/* 86F4 8002D2F4 0223102B */  sltu      $v0, $s1, $v1
/* 86F8 8002D2F8 1040002B */  beqz      $v0, .L8002D3A8
/* 86FC 8002D2FC 241E0003 */   addiu    $fp, $zero, 0x3
/* 8700 8002D300 0060B82D */  daddu     $s7, $v1, $zero
.L8002D304:
/* 8704 8002D304 0220282D */  daddu     $a1, $s1, $zero
/* 8708 8002D308 3C04800A */  lui       $a0, %hi(nuPiCartHandle)
/* 870C 8002D30C 8C84A638 */  lw        $a0, %lo(nuPiCartHandle)($a0)
/* 8710 8002D310 0280F809 */  jalr      $s4
/* 8714 8002D314 27A60014 */   addiu    $a2, $sp, 0x14
/* 8718 8002D318 8FA30014 */  lw        $v1, 0x14($sp)
/* 871C 8002D31C 2407000F */  addiu     $a3, $zero, 0xF
/* 8720 8002D320 3065FFFF */  andi      $a1, $v1, 0xFFFF
/* 8724 8002D324 00032402 */  srl       $a0, $v1, 16
/* 8728 8002D328 00A41021 */  addu      $v0, $a1, $a0
/* 872C 8002D32C 02028021 */  addu      $s0, $s0, $v0
/* 8730 8002D330 00121682 */  srl       $v0, $s2, 26
/* 8734 8002D334 14470010 */  bne       $v0, $a3, .L8002D378
/* 8738 8002D338 00031682 */   srl      $v0, $v1, 26
/* 873C 8002D33C 24070009 */  addiu     $a3, $zero, 0x9
/* 8740 8002D340 50470004 */  beql      $v0, $a3, .L8002D354
/* 8744 8002D344 00031542 */   srl      $v0, $v1, 21
/* 8748 8002D348 24070023 */  addiu     $a3, $zero, 0x23
/* 874C 8002D34C 1447000A */  bne       $v0, $a3, .L8002D378
/* 8750 8002D350 00031542 */   srl      $v0, $v1, 21
.L8002D354:
/* 8754 8002D354 3043001F */  andi      $v1, $v0, 0x1F
/* 8758 8002D358 00121402 */  srl       $v0, $s2, 16
/* 875C 8002D35C 3042001F */  andi      $v0, $v0, 0x1F
/* 8760 8002D360 14620005 */  bne       $v1, $v0, .L8002D378
/* 8764 8002D364 3082001F */   andi     $v0, $a0, 0x1F
/* 8768 8002D368 14620003 */  bne       $v1, $v0, .L8002D378
/* 876C 8002D36C 3242FFFF */   andi     $v0, $s2, 0xFFFF
/* 8770 8002D370 02058023 */  subu      $s0, $s0, $a1
/* 8774 8002D374 02028023 */  subu      $s0, $s0, $v0
.L8002D378:
/* 8778 8002D378 8FA40014 */  lw        $a0, 0x14($sp)
/* 877C 8002D37C 00041682 */  srl       $v0, $a0, 26
/* 8780 8002D380 145E0006 */  bne       $v0, $fp, .L8002D39C
/* 8784 8002D384 26310004 */   addiu    $s1, $s1, 0x4
/* 8788 8002D388 3083FFFF */  andi      $v1, $a0, 0xFFFF
/* 878C 8002D38C 00041402 */  srl       $v0, $a0, 16
/* 8790 8002D390 3042FC00 */  andi      $v0, $v0, 0xFC00
/* 8794 8002D394 00621821 */  addu      $v1, $v1, $v0
/* 8798 8002D398 02038023 */  subu      $s0, $s0, $v1
.L8002D39C:
/* 879C 8002D39C 0237102B */  sltu      $v0, $s1, $s7
/* 87A0 8002D3A0 1440FFD8 */  bnez      $v0, .L8002D304
/* 87A4 8002D3A4 0080902D */   daddu    $s2, $a0, $zero
.L8002D3A8:
/* 87A8 8002D3A8 3C04FFF1 */  lui       $a0, (0xFFF12BE4 >> 16)
/* 87AC 8002D3AC 34842BE4 */  ori       $a0, $a0, (0xFFF12BE4 & 0xFFFF)
/* 87B0 8002D3B0 02042021 */  addu      $a0, $s0, $a0
/* 87B4 8002D3B4 02642023 */  subu      $a0, $s3, $a0
/* 87B8 8002D3B8 02A42021 */  addu      $a0, $s5, $a0
/* 87BC 8002D3BC 3C050031 */  lui       $a1, %hi(D_317020)
/* 87C0 8002D3C0 24A57020 */  addiu     $a1, $a1, %lo(D_317020)
/* 87C4 8002D3C4 0C00A5CF */  jal       dma_copy
/* 87C8 8002D3C8 02C0302D */   daddu    $a2, $s6, $zero
/* 87CC 8002D3CC 8FBF003C */  lw        $ra, 0x3C($sp)
/* 87D0 8002D3D0 8FBE0038 */  lw        $fp, 0x38($sp)
/* 87D4 8002D3D4 8FB70034 */  lw        $s7, 0x34($sp)
/* 87D8 8002D3D8 8FB60030 */  lw        $s6, 0x30($sp)
/* 87DC 8002D3DC 8FB5002C */  lw        $s5, 0x2C($sp)
/* 87E0 8002D3E0 8FB40028 */  lw        $s4, 0x28($sp)
/* 87E4 8002D3E4 8FB30024 */  lw        $s3, 0x24($sp)
/* 87E8 8002D3E8 8FB20020 */  lw        $s2, 0x20($sp)
/* 87EC 8002D3EC 8FB1001C */  lw        $s1, 0x1C($sp)
/* 87F0 8002D3F0 8FB00018 */  lw        $s0, 0x18($sp)
/* 87F4 8002D3F4 03E00008 */  jr        $ra
/* 87F8 8002D3F8 27BD0040 */   addiu    $sp, $sp, 0x40
/* 87FC 8002D3FC 00000000 */  nop

### DECOMPILED C INSTRUCTIONS:

void load_obfuscation_shims(void) {
    // no-op since in shiftable builds, we bypass the obfuscation
}


### RAW ASSEMBLY INSTRUCTIONS:

dlabel func_80252D40
/* 181620 80252D40 27BDFFD8 */  addiu     $sp, $sp, -0x28
/* 181624 80252D44 AFB20018 */  sw        $s2, 0x18($sp)
/* 181628 80252D48 0080902D */  daddu     $s2, $a0, $zero
/* 18162C 80252D4C AFBF0020 */  sw        $ra, 0x20($sp)
D_80252D50:
/* 181630 80252D50 AFB3001C */  sw        $s3, 0x1C($sp)
/* 181634 80252D54 AFB10014 */  sw        $s1, 0x14($sp)
/* 181638 80252D58 AFB00010 */  sw        $s0, 0x10($sp)
/* 18163C 80252D5C 8E50000C */  lw        $s0, 0xC($s2)
/* 181640 80252D60 3C11800E */  lui       $s1, %hi(gBattleStatus)
/* 181644 80252D64 2631C070 */  addiu     $s1, $s1, %lo(gBattleStatus)
dgb_01_D_80252D68_C105E8:
/* 181648 80252D68 8E130000 */  lw        $s3, 0x0($s0)
/* 18164C 80252D6C 26100004 */  addiu     $s0, $s0, 0x4
/* 181650 80252D70 8E020000 */  lw        $v0, 0x0($s0)
/* 181654 80252D74 26100004 */  addiu     $s0, $s0, 0x4
/* 181658 80252D78 AE20018C */  sw        $zero, 0x18C($s1)
/* 18165C 80252D7C AE220188 */  sw        $v0, 0x188($s1)
/* 181660 80252D80 8E020000 */  lw        $v0, 0x0($s0)
/* 181664 80252D84 26100004 */  addiu     $s0, $s0, 0x4
/* 181668 80252D88 AE220190 */  sw        $v0, 0x190($s1)
/* 18166C 80252D8C 8E050000 */  lw        $a1, 0x0($s0)
/* 181670 80252D90 0C0B1EAF */  jal       evt_get_variable
dgb_01_D_80252D94_C10614:
/* 181674 80252D94 26100004 */   addiu    $s0, $s0, 0x4
/* 181678 80252D98 A622017E */  sh        $v0, 0x17E($s1)
/* 18167C 80252D9C 8E100000 */  lw        $s0, 0x0($s0)
/* 181680 80252DA0 24020030 */  addiu     $v0, $zero, 0x30
/* 181684 80252DA4 32030030 */  andi      $v1, $s0, 0x30
/* 181688 80252DA8 54620004 */  bnel      $v1, $v0, .L80252DBC
/* 18168C 80252DAC 32020010 */   andi     $v0, $s0, 0x10
/* 181690 80252DB0 8E220000 */  lw        $v0, 0x0($s1)
/* 181694 80252DB4 08094B7F */  j         .L80252DFC
/* 181698 80252DB8 34420030 */   ori      $v0, $v0, 0x30
.L80252DBC:
/* 18169C 80252DBC 10400004 */  beqz      $v0, .L80252DD0
dgb_01_D_80252DC0_C10640:
/* 1816A0 80252DC0 2403FFDF */   addiu    $v1, $zero, -0x21
/* 1816A4 80252DC4 8E220000 */  lw        $v0, 0x0($s1)
/* 1816A8 80252DC8 08094B7E */  j         .L80252DF8
/* 1816AC 80252DCC 34420010 */   ori      $v0, $v0, 0x10
.L80252DD0:
/* 1816B0 80252DD0 32020020 */  andi      $v0, $s0, 0x20
/* 1816B4 80252DD4 10400005 */  beqz      $v0, dgb_01_D_80252DEC_C1066C
/* 1816B8 80252DD8 2403FFEF */   addiu    $v1, $zero, -0x11
/* 1816BC 80252DDC 8E220000 */  lw        $v0, 0x0($s1)
/* 1816C0 80252DE0 00431024 */  and       $v0, $v0, $v1
/* 1816C4 80252DE4 08094B7F */  j         .L80252DFC
/* 1816C8 80252DE8 34420020 */   ori      $v0, $v0, 0x20
dgb_01_D_80252DEC_C1066C:
/* 1816CC 80252DEC 8E220000 */  lw        $v0, 0x0($s1)
/* 1816D0 80252DF0 00431024 */  and       $v0, $v0, $v1
/* 1816D4 80252DF4 2403FFDF */  addiu     $v1, $zero, -0x21
.L80252DF8:
/* 1816D8 80252DF8 00431024 */  and       $v0, $v0, $v1
.L80252DFC:
/* 1816DC 80252DFC AE220000 */  sw        $v0, 0x0($s1)
/* 1816E0 80252E00 32020040 */  andi      $v0, $s0, 0x40
/* 1816E4 80252E04 10400007 */  beqz      $v0, .L80252E24
/* 1816E8 80252E08 2404FFBF */   addiu    $a0, $zero, -0x41
/* 1816EC 80252E0C 3C03800E */  lui       $v1, %hi(gBattleStatus)
/* 1816F0 80252E10 2463C070 */  addiu     $v1, $v1, %lo(gBattleStatus)
/* 1816F4 80252E14 8C620000 */  lw        $v0, 0x0($v1)
dgb_01_D_80252E18_C10698:
/* 1816F8 80252E18 34420040 */  ori       $v0, $v0, 0x40
/* 1816FC 80252E1C 08094B8E */  j         .L80252E38
/* 181700 80252E20 AC620000 */   sw       $v0, 0x0($v1)
.L80252E24:
/* 181704 80252E24 3C02800E */  lui       $v0, %hi(gBattleStatus)
/* 181708 80252E28 2442C070 */  addiu     $v0, $v0, %lo(gBattleStatus)
/* 18170C 80252E2C 8C430000 */  lw        $v1, 0x0($v0)
/* 181710 80252E30 00641824 */  and       $v1, $v1, $a0
/* 181714 80252E34 AC430000 */  sw        $v1, 0x0($v0)
.L80252E38:
/* 181718 80252E38 32020200 */  andi      $v0, $s0, 0x200
/* 18171C 80252E3C 10400007 */  beqz      $v0, .L80252E5C
/* 181720 80252E40 2404FDFF */   addiu    $a0, $zero, -0x201
dgb_01_D_80252E44_C106C4:
/* 181724 80252E44 3C03800E */  lui       $v1, %hi(gBattleStatus)
/* 181728 80252E48 2463C070 */  addiu     $v1, $v1, %lo(gBattleStatus)
/* 18172C 80252E4C 8C620000 */  lw        $v0, 0x0($v1)
/* 181730 80252E50 34420200 */  ori       $v0, $v0, 0x200
D_80252E54:
/* 181734 80252E54 08094B9C */  j         dgb_01_D_80252E70_C106F0
/* 181738 80252E58 AC620000 */   sw       $v0, 0x0($v1)
.L80252E5C:
/* 18173C 80252E5C 3C02800E */  lui       $v0, %hi(gBattleStatus)
/* 181740 80252E60 2442C070 */  addiu     $v0, $v0, %lo(gBattleStatus)
/* 181744 80252E64 8C430000 */  lw        $v1, 0x0($v0)
/* 181748 80252E68 00641824 */  and       $v1, $v1, $a0
/* 18174C 80252E6C AC430000 */  sw        $v1, 0x0($v0)
dgb_01_D_80252E70_C106F0:
/* 181750 80252E70 32020080 */  andi      $v0, $s0, 0x80
/* 181754 80252E74 10400007 */  beqz      $v0, .L80252E94
/* 181758 80252E78 2404FF7F */   addiu    $a0, $zero, -0x81
/* 18175C 80252E7C 3C03800E */  lui       $v1, %hi(gBattleStatus)
/* 181760 80252E80 2463C070 */  addiu     $v1, $v1, %lo(gBattleStatus)
/* 181764 80252E84 8C620000 */  lw        $v0, 0x0($v1)
/* 181768 80252E88 34420080 */  ori       $v0, $v0, 0x80
D_80252E8C:
/* 18176C 80252E8C 08094BAA */  j         .L80252EA8
/* 181770 80252E90 AC620000 */   sw       $v0, 0x0($v1)
.L80252E94:
/* 181774 80252E94 3C02800E */  lui       $v0, %hi(gBattleStatus)
/* 181778 80252E98 2442C070 */  addiu     $v0, $v0, %lo(gBattleStatus)
dgb_01_D_80252E9C_C1071C:
/* 18177C 80252E9C 8C430000 */  lw        $v1, 0x0($v0)
/* 181780 80252EA0 00641824 */  and       $v1, $v1, $a0
/* 181784 80252EA4 AC430000 */  sw        $v1, 0x0($v0)
.L80252EA8:
/* 181788 80252EA8 0C09A75B */  jal       get_actor
/* 18178C 80252EAC 8E440148 */   lw       $a0, 0x148($s2)
D_80252EB0:
/* 181790 80252EB0 94430428 */  lhu       $v1, 0x428($v0)
/* 181794 80252EB4 A62301A0 */  sh        $v1, 0x1A0($s1)
/* 181798 80252EB8 92230193 */  lbu       $v1, 0x193($s1)
/* 18179C 80252EBC 90420426 */  lbu       $v0, 0x426($v0)
/* 1817A0 80252EC0 A2230194 */  sb        $v1, 0x194($s1)
/* 1817A4 80252EC4 306300FF */  andi      $v1, $v1, 0xFF
dgb_01_D_80252EC8_C10748:
/* 1817A8 80252EC8 A22201A2 */  sb        $v0, 0x1A2($s1)
/* 1817AC 80252ECC 240200FF */  addiu     $v0, $zero, 0xFF
/* 1817B0 80252ED0 50620001 */  beql      $v1, $v0, .L80252ED8
/* 1817B4 80252ED4 A2200194 */   sb       $zero, 0x194($s1)
.L80252ED8:
/* 1817B8 80252ED8 8E220190 */  lw        $v0, 0x190($s1)
/* 1817BC 80252EDC 30420F00 */  andi      $v0, $v0, 0xF00
/* 1817C0 80252EE0 00021203 */  sra       $v0, $v0, 8
/* 1817C4 80252EE4 0C094574 */  jal       func_802515D0
/* 1817C8 80252EE8 A2220195 */   sb       $v0, 0x195($s1)
/* 1817CC 80252EEC 04400006 */  bltz      $v0, .L80252F08
/* 1817D0 80252EF0 0240202D */   daddu    $a0, $s2, $zero
dgb_01_D_80252EF4_C10774:
/* 1817D4 80252EF4 0260282D */  daddu     $a1, $s3, $zero
/* 1817D8 80252EF8 0C0B2026 */  jal       evt_set_variable
/* 1817DC 80252EFC 0040302D */   daddu    $a2, $v0, $zero
/* 1817E0 80252F00 08094BC3 */  j         .L80252F0C
/* 1817E4 80252F04 24020002 */   addiu    $v0, $zero, 0x2
.L80252F08:
/* 1817E8 80252F08 240200FF */  addiu     $v0, $zero, 0xFF
.L80252F0C:
/* 1817EC 80252F0C 8FBF0020 */  lw        $ra, 0x20($sp)
/* 1817F0 80252F10 8FB3001C */  lw        $s3, 0x1C($sp)
/* 1817F4 80252F14 8FB20018 */  lw        $s2, 0x18($sp)
/* 1817F8 80252F18 8FB10014 */  lw        $s1, 0x14($sp)
/* 1817FC 80252F1C 8FB00010 */  lw        $s0, 0x10($sp)
dgb_01_D_80252F20_C107A0:
/* 181800 80252F20 03E00008 */  jr        $ra
/* 181804 80252F24 27BD0028 */   addiu    $sp, $sp, 0x28
/* 181808 80252F28 00000000 */  nop
/* 18180C 80252F2C 00000000 */  nop

### DECOMPILED C INSTRUCTIONS:

ApiStatus ItemCheckHit(Evt* script, s32 isInitialCall) {
    BattleStatus* battleStatus = &gBattleStatus;
    Bytecode* args = script->ptrReadPos;
    s32 hitResultVarOut = *args++;
    s32 flags;
    Actor* actor;
    HitResult hitResult;

    battleStatus->currentAttackElement = *args++;
    battleStatus->currentAttackEventSuppression = 0;
    battleStatus->currentAttackStatus = *args++;
    battleStatus->currentAttackDamage = evt_get_variable(script, *args++);
    flags = *args++;

    if ((flags & (BS_FLAGS1_10 | BS_FLAGS1_SP_EVT_ACTIVE)) == (BS_FLAGS1_10 | BS_FLAGS1_SP_EVT_ACTIVE)) {
        gBattleStatus.flags1 |= BS_FLAGS1_10 | BS_FLAGS1_SP_EVT_ACTIVE;
    } else if (flags & BS_FLAGS1_10) {
        gBattleStatus.flags1 |= BS_FLAGS1_10;
        gBattleStatus.flags1 &= ~BS_FLAGS1_SP_EVT_ACTIVE;
    } else if (flags & BS_FLAGS1_SP_EVT_ACTIVE) {
        gBattleStatus.flags1 &= ~BS_FLAGS1_10;
        gBattleStatus.flags1 |= BS_FLAGS1_SP_EVT_ACTIVE;
    } else {
        gBattleStatus.flags1 &= ~BS_FLAGS1_10;
        gBattleStatus.flags1 &= ~BS_FLAGS1_SP_EVT_ACTIVE;
    }

    if (flags & BS_FLAGS1_40) {
        gBattleStatus.flags1 |= BS_FLAGS1_40;
    } else {
        gBattleStatus.flags1 &= ~BS_FLAGS1_40;
    }

    if (flags & BS_FLAGS1_200) {
        gBattleStatus.flags1 |= BS_FLAGS1_200;
    } else {
        gBattleStatus.flags1 &= ~BS_FLAGS1_200;
    }

    if (flags & BS_FLAGS1_80) {
        gBattleStatus.flags1 |= BS_FLAGS1_80;
    } else {
        gBattleStatus.flags1 &= ~BS_FLAGS1_80;
    }

    actor = get_actor(script->owner1.actorID);
    battleStatus->currentTargetID = actor->targetActorID;
    battleStatus->currentTargetPart = actor->targetPartIndex;
    battleStatus->statusChance = battleStatus->currentAttackStatus;

    if (battleStatus->statusChance == STATUS_KEY_NEVER) {
        battleStatus->statusChance = 0;
    }

    battleStatus->statusDuration = (battleStatus->currentAttackStatus & 0xF00) >> 8;

    hitResult = calc_item_check_hit();
    if (hitResult < 0) {
        return ApiStatus_FINISH;
    }

    evt_set_variable(script, hitResultVarOut, hitResult);

    return ApiStatus_DONE2;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel set_action_state
/* 7F254 800E5DA4 27BDFFE0 */  addiu     $sp, $sp, -0x20
/* 7F258 800E5DA8 AFB00010 */  sw        $s0, 0x10($sp)
/* 7F25C 800E5DAC 3C108011 */  lui       $s0, %hi(gPlayerStatus)
/* 7F260 800E5DB0 2610EFC8 */  addiu     $s0, $s0, %lo(gPlayerStatus)
/* 7F264 800E5DB4 AFBF0018 */  sw        $ra, 0x18($sp)
/* 7F268 800E5DB8 AFB10014 */  sw        $s1, 0x14($sp)
/* 7F26C 800E5DBC 8E030000 */  lw        $v1, 0x0($s0)
/* 7F270 800E5DC0 30620200 */  andi      $v0, $v1, 0x200
/* 7F274 800E5DC4 10400005 */  beqz      $v0, .L800E5DDC
/* 7F278 800E5DC8 0080882D */   daddu    $s1, $a0, $zero
/* 7F27C 800E5DCC 2402FDFF */  addiu     $v0, $zero, -0x201
/* 7F280 800E5DD0 00621024 */  and       $v0, $v1, $v0
/* 7F284 800E5DD4 0C038069 */  jal       enable_player_input
/* 7F288 800E5DD8 AE020000 */   sw       $v0, 0x0($s0)
.L800E5DDC:
/* 7F28C 800E5DDC 8E040004 */  lw        $a0, 0x4($s0)
/* 7F290 800E5DE0 30824000 */  andi      $v0, $a0, 0x4000
/* 7F294 800E5DE4 1040000C */  beqz      $v0, .L800E5E18
/* 7F298 800E5DE8 2A22000C */   slti     $v0, $s1, 0xC
/* 7F29C 800E5DEC 10400059 */  beqz      $v0, .L800E5F54
/* 7F2A0 800E5DF0 00000000 */   nop
/* 7F2A4 800E5DF4 06200057 */  bltz      $s1, .L800E5F54
/* 7F2A8 800E5DF8 3C038000 */   lui      $v1, (0x80000000 >> 16)
/* 7F2AC 800E5DFC 920200B4 */  lbu       $v0, 0xB4($s0)
/* 7F2B0 800E5E00 A20200B5 */  sb        $v0, 0xB5($s0)
/* 7F2B4 800E5E04 8E020000 */  lw        $v0, 0x0($s0)
/* 7F2B8 800E5E08 A21100B4 */  sb        $s1, 0xB4($s0)
/* 7F2BC 800E5E0C 00431025 */  or        $v0, $v0, $v1
/* 7F2C0 800E5E10 080397D5 */  j         .L800E5F54
/* 7F2C4 800E5E14 AE020000 */   sw       $v0, 0x0($s0)
.L800E5E18:
/* 7F2C8 800E5E18 24020015 */  addiu     $v0, $zero, 0x15
/* 7F2CC 800E5E1C 12220003 */  beq       $s1, $v0, .L800E5E2C
/* 7F2D0 800E5E20 24020017 */   addiu    $v0, $zero, 0x17
/* 7F2D4 800E5E24 1622001A */  bne       $s1, $v0, .L800E5E90
/* 7F2D8 800E5E28 24020011 */   addiu    $v0, $zero, 0x11
.L800E5E2C:
/* 7F2DC 800E5E2C 820300BF */  lb        $v1, 0xBF($s0)
/* 7F2E0 800E5E30 24020003 */  addiu     $v0, $zero, 0x3
/* 7F2E4 800E5E34 50620001 */  beql      $v1, $v0, .L800E5E3C
/* 7F2E8 800E5E38 24110015 */   addiu    $s1, $zero, 0x15
.L800E5E3C:
/* 7F2EC 800E5E3C 3C028011 */  lui       $v0, %hi(gPlayerData)
/* 7F2F0 800E5E40 2442F290 */  addiu     $v0, $v0, %lo(gPlayerData)
/* 7F2F4 800E5E44 90430012 */  lbu       $v1, 0x12($v0)
/* 7F2F8 800E5E48 2462FFF9 */  addiu     $v0, $v1, -0x7
/* 7F2FC 800E5E4C 2C420002 */  sltiu     $v0, $v0, 0x2
/* 7F300 800E5E50 14400005 */  bnez      $v0, .L800E5E68
/* 7F304 800E5E54 00031600 */   sll      $v0, $v1, 24
/* 7F308 800E5E58 00021603 */  sra       $v0, $v0, 24
/* 7F30C 800E5E5C 24030004 */  addiu     $v1, $zero, 0x4
/* 7F310 800E5E60 1443000B */  bne       $v0, $v1, .L800E5E90
/* 7F314 800E5E64 24020011 */   addiu    $v0, $zero, 0x11
.L800E5E68:
/* 7F318 800E5E68 3C028011 */  lui       $v0, %hi(gPartnerStatus)
/* 7F31C 800E5E6C 8042EBB0 */  lb        $v0, %lo(gPartnerStatus)($v0)
/* 7F320 800E5E70 10400006 */  beqz      $v0, .L800E5E8C
/* 7F324 800E5E74 34830004 */   ori      $v1, $a0, 0x4
/* 7F328 800E5E78 8E020000 */  lw        $v0, 0x0($s0)
/* 7F32C 800E5E7C AE030004 */  sw        $v1, 0x4($s0)
/* 7F330 800E5E80 34420800 */  ori       $v0, $v0, 0x800
/* 7F334 800E5E84 080397D5 */  j         .L800E5F54
/* 7F338 800E5E88 AE020000 */   sw       $v0, 0x0($s0)
.L800E5E8C:
/* 7F33C 800E5E8C 24020011 */  addiu     $v0, $zero, 0x11
.L800E5E90:
/* 7F340 800E5E90 16220007 */  bne       $s1, $v0, .L800E5EB0
/* 7F344 800E5E94 2403BFFF */   addiu    $v1, $zero, -0x4001
/* 7F348 800E5E98 8E020000 */  lw        $v0, 0x0($s0)
/* 7F34C 800E5E9C A6000012 */  sh        $zero, 0x12($s0)
/* 7F350 800E5EA0 34420010 */  ori       $v0, $v0, 0x10
/* 7F354 800E5EA4 AE020000 */  sw        $v0, 0x0($s0)
/* 7F358 800E5EA8 00431024 */  and       $v0, $v0, $v1
/* 7F35C 800E5EAC AE020000 */  sw        $v0, 0x0($s0)
.L800E5EB0:
/* 7F360 800E5EB0 920200B4 */  lbu       $v0, 0xB4($s0)
/* 7F364 800E5EB4 A20200B5 */  sb        $v0, 0xB5($s0)
/* 7F368 800E5EB8 2402001F */  addiu     $v0, $zero, 0x1F
/* 7F36C 800E5EBC 52220001 */  beql      $s1, $v0, .L800E5EC4
/* 7F370 800E5EC0 A20000B5 */   sb       $zero, 0xB5($s0)
.L800E5EC4:
/* 7F374 800E5EC4 2402001B */  addiu     $v0, $zero, 0x1B
/* 7F378 800E5EC8 16220004 */  bne       $s1, $v0, .L800E5EDC
/* 7F37C 800E5ECC 00000000 */   nop
/* 7F380 800E5ED0 8E020004 */  lw        $v0, 0x4($s0)
/* 7F384 800E5ED4 34420004 */  ori       $v0, $v0, 0x4
/* 7F388 800E5ED8 AE020004 */  sw        $v0, 0x4($s0)
.L800E5EDC:
/* 7F38C 800E5EDC 8E030000 */  lw        $v1, 0x0($s0)
/* 7F390 800E5EE0 3C028000 */  lui       $v0, (0x80000000 >> 16)
/* 7F394 800E5EE4 A21100B4 */  sb        $s1, 0xB4($s0)
/* 7F398 800E5EE8 00622825 */  or        $a1, $v1, $v0
/* 7F39C 800E5EEC 820300B4 */  lb        $v1, 0xB4($s0)
/* 7F3A0 800E5EF0 2402001A */  addiu     $v0, $zero, 0x1A
/* 7F3A4 800E5EF4 10620017 */  beq       $v1, $v0, .L800E5F54
/* 7F3A8 800E5EF8 AE050000 */   sw       $a1, 0x0($s0)
/* 7F3AC 800E5EFC 3C02FFFD */  lui       $v0, (0xFFFDFFFF >> 16)
/* 7F3B0 800E5F00 3442FFFF */  ori       $v0, $v0, (0xFFFDFFFF & 0xFFFF)
/* 7F3B4 800E5F04 3C04FFFE */  lui       $a0, (0xFFFEFFFF >> 16)
/* 7F3B8 800E5F08 3484FFFF */  ori       $a0, $a0, (0xFFFEFFFF & 0xFFFF)
/* 7F3BC 800E5F0C 00A21024 */  and       $v0, $a1, $v0
/* 7F3C0 800E5F10 3C038011 */  lui       $v1, %hi(gPlayerSpinState)
/* 7F3C4 800E5F14 2463F250 */  addiu     $v1, $v1, %lo(gPlayerSpinState)
/* 7F3C8 800E5F18 AE020000 */  sw        $v0, 0x0($s0)
/* 7F3CC 800E5F1C 8E020004 */  lw        $v0, 0x4($s0)
/* 7F3D0 800E5F20 8C630030 */  lw        $v1, 0x30($v1)
/* 7F3D4 800E5F24 00441024 */  and       $v0, $v0, $a0
/* 7F3D8 800E5F28 10600003 */  beqz      $v1, .L800E5F38
/* 7F3DC 800E5F2C AE020004 */   sw       $v0, 0x4($s0)
/* 7F3E0 800E5F30 0C05271B */  jal       sfx_stop_sound
/* 7F3E4 800E5F34 0060202D */   daddu    $a0, $v1, $zero
.L800E5F38:
/* 7F3E8 800E5F38 8E0200D8 */  lw        $v0, 0xD8($s0)
/* 7F3EC 800E5F3C 10400005 */  beqz      $v0, .L800E5F54
/* 7F3F0 800E5F40 00000000 */   nop
/* 7F3F4 800E5F44 8C43000C */  lw        $v1, 0xC($v0)
/* 7F3F8 800E5F48 2402000A */  addiu     $v0, $zero, 0xA
/* 7F3FC 800E5F4C AC620024 */  sw        $v0, 0x24($v1)
/* 7F400 800E5F50 AE0000D8 */  sw        $zero, 0xD8($s0)
.L800E5F54:
/* 7F404 800E5F54 8FBF0018 */  lw        $ra, 0x18($sp)
/* 7F408 800E5F58 8FB10014 */  lw        $s1, 0x14($sp)
/* 7F40C 800E5F5C 8FB00010 */  lw        $s0, 0x10($sp)
/* 7F410 800E5F60 03E00008 */  jr        $ra
/* 7F414 800E5F64 27BD0020 */   addiu    $sp, $sp, 0x20

### DECOMPILED C INSTRUCTIONS:

void set_action_state(s32 actionState) {
    PlayerStatus* playerStatus = &gPlayerStatus;
    PlayerData* playerData = &gPlayerData;
    PlayerSpinState* spinState = &gPlayerSpinState;

    if (playerStatus->flags & PS_FLAG_SPECIAL_JUMP) {
        playerStatus->flags &= ~PS_FLAG_SPECIAL_JUMP;
        enable_player_input();
    }

    if (playerStatus->animFlags & PA_FLAG_8BIT_MARIO) {
        // TODO figure this out
#ifdef NON_EQUIVALENT
        if (
            actionState == ACTION_STATE_IDLE || actionState == ACTION_STATE_WALK ||
            actionState == ACTION_STATE_RUN || actionState == ACTION_STATE_JUMP ||
            actionState == ACTION_STATE_BOUNCE || actionState == ACTION_STATE_HOP ||
            actionState == ACTION_STATE_LAUNCH || actionState == ACTION_STATE_LANDING_ON_SWITCH ||
            actionState == ACTION_STATE_FALLING || actionState == ACTION_STATE_STEP_DOWN ||
            actionState == ACTION_STATE_LAND || actionState == ACTION_STATE_STEP_DOWN_LAND
        ) {
#else
        if (actionState < ACTION_STATE_TALK)
            if (actionState >= 0) {
#endif
            playerStatus->prevActionState = playerStatus->actionState;
            playerStatus->actionState = actionState;
            playerStatus->flags |= PS_FLAG_ACTION_STATE_CHANGED;
        }
        return;
    }

    if (actionState == ACTION_STATE_HIT_FIRE || actionState == ACTION_STATE_HIT_LAVA) {
        s8 partner;

        if (playerStatus->hazardType == HAZARD_TYPE_FIRE_BAR) {
            actionState = ACTION_STATE_HIT_FIRE;
        }

        // Whilst Sushie, Lakilester, or Parakarry's ability is active, hazards have no effect.
        partner = playerData->currentPartner;

        if (partner == PARTNER_SUSHIE || partner == PARTNER_LAKILESTER || partner == PARTNER_PARAKARRY) {
            if (gPartnerStatus.partnerActionState != PARTNER_ACTION_NONE) {
                playerStatus->animFlags |= PA_FLAG_INTERRUPT_USE_PARTNER;
                playerStatus->flags |= PS_FLAG_HIT_FIRE;
                return;
            }
        }
    }

    if (actionState == ACTION_STATE_SLIDING) {
        playerStatus->flags |= PS_FLAG_SLIDING;
        playerStatus->moveFrames = 0;
        playerStatus->flags &= ~PS_FLAG_CUTSCENE_MOVEMENT;
    }

    playerStatus->prevActionState = playerStatus->actionState;
    if (actionState == ACTION_STATE_USE_TWEESTER) {
        playerStatus->prevActionState = ACTION_STATE_IDLE;
    }

    if (actionState == ACTION_STATE_ENEMY_FIRST_STRIKE) {
        playerStatus->animFlags |= PA_FLAG_INTERRUPT_USE_PARTNER;
    }
    playerStatus->actionState = actionState;
    playerStatus->flags |= PS_FLAG_ACTION_STATE_CHANGED;

    if (playerStatus->actionState == ACTION_STATE_SPIN) {
        return;
    }

    playerStatus->flags &= ~PS_FLAG_SPINNING;
    playerStatus->animFlags &= ~PA_FLAG_SPINNING;

    if (spinState->spinSoundID != 0) {
        sfx_stop_sound(spinState->spinSoundID);
    }

    if (playerStatus->specialDecorationEffect != NULL) {
        playerStatus->specialDecorationEffect->data.spin->timeLeft = 10;
        playerStatus->specialDecorationEffect = NULL;
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel start_script_in_group
/* E7F80 802C35D0 27BDFFD0 */  addiu     $sp, $sp, -0x30
/* E7F84 802C35D4 AFB10014 */  sw        $s1, 0x14($sp)
/* E7F88 802C35D8 0080882D */  daddu     $s1, $a0, $zero
/* E7F8C 802C35DC AFB40020 */  sw        $s4, 0x20($sp)
/* E7F90 802C35E0 00A0A02D */  daddu     $s4, $a1, $zero
/* E7F94 802C35E4 AFB3001C */  sw        $s3, 0x1C($sp)
/* E7F98 802C35E8 00C0982D */  daddu     $s3, $a2, $zero
/* E7F9C 802C35EC AFB50024 */  sw        $s5, 0x24($sp)
/* E7FA0 802C35F0 00E0A82D */  daddu     $s5, $a3, $zero
/* E7FA4 802C35F4 3C03802E */  lui       $v1, %hi(gCurrentScriptListPtr)
/* E7FA8 802C35F8 8C63A890 */  lw        $v1, %lo(gCurrentScriptListPtr)($v1)
/* E7FAC 802C35FC 0000282D */  daddu     $a1, $zero, $zero
/* E7FB0 802C3600 AFBF0028 */  sw        $ra, 0x28($sp)
/* E7FB4 802C3604 AFB20018 */  sw        $s2, 0x18($sp)
/* E7FB8 802C3608 AFB00010 */  sw        $s0, 0x10($sp)
.L802C360C:
/* E7FBC 802C360C 8C620000 */  lw        $v0, 0x0($v1)
/* E7FC0 802C3610 10400006 */  beqz      $v0, .L802C362C
/* E7FC4 802C3614 28A20080 */   slti     $v0, $a1, 0x80
/* E7FC8 802C3618 24A50001 */  addiu     $a1, $a1, 0x1
/* E7FCC 802C361C 28A20080 */  slti      $v0, $a1, 0x80
/* E7FD0 802C3620 1440FFFA */  bnez      $v0, .L802C360C
/* E7FD4 802C3624 24630004 */   addiu    $v1, $v1, 0x4
/* E7FD8 802C3628 28A20080 */  slti      $v0, $a1, 0x80
.L802C362C:
/* E7FDC 802C362C 14400003 */  bnez      $v0, .L802C363C
/* E7FE0 802C3630 24040168 */   addiu    $a0, $zero, 0x168
.L802C3634:
/* E7FE4 802C3634 080B0D8D */  j         .L802C3634
/* E7FE8 802C3638 00000000 */   nop
.L802C363C:
/* E7FEC 802C363C 0C00AB39 */  jal       heap_malloc
/* E7FF0 802C3640 00A0902D */   daddu    $s2, $a1, $zero
/* E7FF4 802C3644 00122080 */  sll       $a0, $s2, 2
/* E7FF8 802C3648 3C03802E */  lui       $v1, %hi(gCurrentScriptListPtr)
/* E7FFC 802C364C 8C63A890 */  lw        $v1, %lo(gCurrentScriptListPtr)($v1)
/* E8000 802C3650 3C05802E */  lui       $a1, %hi(gNumScripts)
/* E8004 802C3654 24A5A488 */  addiu     $a1, $a1, %lo(gNumScripts)
/* E8008 802C3658 00832021 */  addu      $a0, $a0, $v1
/* E800C 802C365C 8CA30000 */  lw        $v1, 0x0($a1)
/* E8010 802C3660 0040802D */  daddu     $s0, $v0, $zero
/* E8014 802C3664 AC900000 */  sw        $s0, 0x0($a0)
/* E8018 802C3668 24630001 */  addiu     $v1, $v1, 0x1
/* E801C 802C366C 16000003 */  bnez      $s0, .L802C367C
/* E8020 802C3670 ACA30000 */   sw       $v1, 0x0($a1)
.L802C3674:
/* E8024 802C3674 080B0D9D */  j         .L802C3674
/* E8028 802C3678 00000000 */   nop
.L802C367C:
/* E802C 802C367C 36620001 */  ori       $v0, $s3, 0x1
/* E8030 802C3680 3C03802E */  lui       $v1, %hi(gStaticScriptCounter)
/* E8034 802C3684 24639CA0 */  addiu     $v1, $v1, %lo(gStaticScriptCounter)
/* E8038 802C3688 A2020000 */  sb        $v0, 0x0($s0)
/* E803C 802C368C A2000002 */  sb        $zero, 0x2($s0)
/* E8040 802C3690 A2140003 */  sb        $s4, 0x3($s0)
/* E8044 802C3694 8C620000 */  lw        $v0, 0x0($v1)
/* E8048 802C3698 2405000F */  addiu     $a1, $zero, 0xF
/* E804C 802C369C AE020144 */  sw        $v0, 0x144($s0)
/* E8050 802C36A0 24420001 */  addiu     $v0, $v0, 0x1
/* E8054 802C36A4 AC620000 */  sw        $v0, 0x0($v1)
/* E8058 802C36A8 2402FFFF */  addiu     $v0, $zero, -0x1
/* E805C 802C36AC A2020006 */  sb        $v0, 0x6($s0)
/* E8060 802C36B0 A2020007 */  sb        $v0, 0x7($s0)
/* E8064 802C36B4 A2150004 */  sb        $s5, 0x4($s0)
/* E8068 802C36B8 3C01802E */  lui       $at, %hi(gGlobalTimeSpace)
/* E806C 802C36BC C4209CA8 */  lwc1      $f0, %lo(gGlobalTimeSpace)($at)
/* E8070 802C36C0 2603003C */  addiu     $v1, $s0, 0x3C
/* E8074 802C36C4 AE110008 */  sw        $s1, 0x8($s0)
/* E8078 802C36C8 AE11015C */  sw        $s1, 0x15C($s0)
/* E807C 802C36CC AE110164 */  sw        $s1, 0x164($s0)
/* E8080 802C36D0 AE000060 */  sw        $zero, 0x60($s0)
/* E8084 802C36D4 AE000064 */  sw        $zero, 0x64($s0)
/* E8088 802C36D8 AE000068 */  sw        $zero, 0x68($s0)
/* E808C 802C36DC AE00006C */  sw        $zero, 0x6C($s0)
/* E8090 802C36E0 AE020148 */  sw        $v0, 0x148($s0)
/* E8094 802C36E4 AE02014C */  sw        $v0, 0x14C($s0)
/* E8098 802C36E8 AE000160 */  sw        $zero, 0x160($s0)
/* E809C 802C36EC AE000154 */  sw        $zero, 0x154($s0)
/* E80A0 802C36F0 AE000158 */  sw        $zero, 0x158($s0)
/* E80A4 802C36F4 E6000150 */  swc1      $f0, 0x150($s0)
.L802C36F8:
/* E80A8 802C36F8 AC600084 */  sw        $zero, 0x84($v1)
/* E80AC 802C36FC 24A5FFFF */  addiu     $a1, $a1, -0x1
/* E80B0 802C3700 04A1FFFD */  bgez      $a1, .L802C36F8
/* E80B4 802C3704 2463FFFC */   addiu    $v1, $v1, -0x4
/* E80B8 802C3708 24050002 */  addiu     $a1, $zero, 0x2
/* E80BC 802C370C 26020008 */  addiu     $v0, $s0, 0x8
.L802C3710:
/* E80C0 802C3710 AC4000C4 */  sw        $zero, 0xC4($v0)
/* E80C4 802C3714 24A5FFFF */  addiu     $a1, $a1, -0x1
/* E80C8 802C3718 04A1FFFD */  bgez      $a1, .L802C3710
/* E80CC 802C371C 2442FFFC */   addiu    $v0, $v0, -0x4
/* E80D0 802C3720 0C0B0C52 */  jal       find_script_labels
/* E80D4 802C3724 0200202D */   daddu    $a0, $s0, $zero
/* E80D8 802C3728 3C02802E */  lui       $v0, %hi(gIsUpdatingScripts)
/* E80DC 802C372C 8C429CA4 */  lw        $v0, %lo(gIsUpdatingScripts)($v0)
/* E80E0 802C3730 10400012 */  beqz      $v0, .L802C377C
/* E80E4 802C3734 00000000 */   nop
/* E80E8 802C3738 92020000 */  lbu       $v0, 0x0($s0)
/* E80EC 802C373C 30420020 */  andi      $v0, $v0, 0x20
/* E80F0 802C3740 1040000E */  beqz      $v0, .L802C377C
/* E80F4 802C3744 00000000 */   nop
/* E80F8 802C3748 3C05802E */  lui       $a1, %hi(gScriptListCount)
/* E80FC 802C374C 24A5AC98 */  addiu     $a1, $a1, %lo(gScriptListCount)
/* E8100 802C3750 8CA20000 */  lw        $v0, 0x0($a1)
/* E8104 802C3754 00022080 */  sll       $a0, $v0, 2
/* E8108 802C3758 3C01802E */  lui       $at, %hi(gScriptIndexList)
/* E810C 802C375C 00240821 */  addu      $at, $at, $a0
/* E8110 802C3760 AC32A898 */  sw        $s2, %lo(gScriptIndexList)($at)
/* E8114 802C3764 8E030144 */  lw        $v1, 0x144($s0)
/* E8118 802C3768 24420001 */  addiu     $v0, $v0, 0x1
/* E811C 802C376C ACA20000 */  sw        $v0, 0x0($a1)
/* E8120 802C3770 3C01802E */  lui       $at, %hi(gScriptIdList)
/* E8124 802C3774 00240821 */  addu      $at, $at, $a0
/* E8128 802C3778 AC23AA98 */  sw        $v1, %lo(gScriptIdList)($at)
.L802C377C:
/* E812C 802C377C 0C0B0CE4 */  jal       suspend_frozen_scripts
/* E8130 802C3780 0200202D */   daddu    $a0, $s0, $zero
/* E8134 802C3784 3C03802E */  lui       $v1, %hi(gStaticScriptCounter)
/* E8138 802C3788 24639CA0 */  addiu     $v1, $v1, %lo(gStaticScriptCounter)
/* E813C 802C378C 8C620000 */  lw        $v0, 0x0($v1)
/* E8140 802C3790 14400004 */  bnez      $v0, .L802C37A4
/* E8144 802C3794 0200102D */   daddu    $v0, $s0, $zero
/* E8148 802C3798 24020001 */  addiu     $v0, $zero, 0x1
/* E814C 802C379C AC620000 */  sw        $v0, 0x0($v1)
/* E8150 802C37A0 0200102D */  daddu     $v0, $s0, $zero
.L802C37A4:
/* E8154 802C37A4 8FBF0028 */  lw        $ra, 0x28($sp)
/* E8158 802C37A8 8FB50024 */  lw        $s5, 0x24($sp)
/* E815C 802C37AC 8FB40020 */  lw        $s4, 0x20($sp)
/* E8160 802C37B0 8FB3001C */  lw        $s3, 0x1C($sp)
/* E8164 802C37B4 8FB20018 */  lw        $s2, 0x18($sp)
/* E8168 802C37B8 8FB10014 */  lw        $s1, 0x14($sp)
/* E816C 802C37BC 8FB00010 */  lw        $s0, 0x10($sp)
/* E8170 802C37C0 03E00008 */  jr        $ra
/* E8174 802C37C4 27BD0030 */   addiu    $sp, $sp, 0x30

### DECOMPILED C INSTRUCTIONS:

Evt* start_script_in_group(EvtScript* source, u8 priority, u8 flags, u8 groupFlags) {
    Evt* newScript;
    s32 scriptListCount;
    s32 i;
    s32 curScriptIndex;
    s32* tempCounter;
    s32* numScripts;

    for (i = 0; i < MAX_SCRIPTS; i++) {
        if ((*gCurrentScriptListPtr)[i] == NULL) {
            break;
        }
    }

    ASSERT(i < MAX_SCRIPTS);
    curScriptIndex = i;

    (*gCurrentScriptListPtr)[curScriptIndex] = newScript = heap_malloc(sizeof(*newScript));
    numScripts = &gNumScripts;
    (*numScripts)++;
    ASSERT(newScript != NULL);

    // Some of this function is surely macros. I think we'll learn more as we do others in this file. -Ethan
    do {
        newScript->stateFlags = flags | EVT_FLAG_ACTIVE;
        newScript->currentOpcode = EVT_OP_INTERNAL_FETCH;
        newScript->priority = priority;
        newScript->id = gStaticScriptCounter++;
        newScript->ptrNextLine = (Bytecode*)source;
        newScript->ptrFirstLine = (Bytecode*)source;
        newScript->ptrCurrentLine = (Bytecode*)source;
        newScript->userData = 0;
        newScript->blockingParent = 0;
        newScript->childScript = 0;
        newScript->parentScript = 0;
        newScript->owner1.actorID = -1;
        newScript->owner2.npcID = -1;
        newScript->loopDepth = -1;
        newScript->switchDepth = -1;
        newScript->groupFlags = groupFlags;
        newScript->ptrSavedPos = 0;
        newScript->frameCounter = 0.0f;
        newScript->unk_158 = 0;
        newScript->timeScale = gGlobalTimeSpace;
        scriptListCount = 0;

        for (i = 0; i < ARRAY_COUNT(newScript->varTable); i++) {
            newScript->varTable[i] = 0;
        }
        for (i = 0; i < ARRAY_COUNT(newScript->varFlags); i++) {
            newScript->varFlags[i] = 0;
        }

        find_script_labels(newScript);

        if (gIsUpdatingScripts && (newScript->stateFlags & EVT_FLAG_RUN_IMMEDIATELY)) {
            scriptListCount = gScriptListCount++;
            gScriptIndexList[scriptListCount] = curScriptIndex;
            gScriptIdList[scriptListCount] = newScript->id;
        }
    } while (0);

    suspend_frozen_scripts(newScript);

    tempCounter = &gStaticScriptCounter;
    if (*tempCounter == 0) {
        *tempCounter = 1;
    }

    return newScript;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel spr_component_update
/* 1007CC 802DD6DC 27BDFFD0 */  addiu     $sp, $sp, -0x30
/* 1007D0 802DD6E0 AFB50024 */  sw        $s5, 0x24($sp)
/* 1007D4 802DD6E4 8FB50040 */  lw        $s5, 0x40($sp)
/* 1007D8 802DD6E8 AFB3001C */  sw        $s3, 0x1C($sp)
/* 1007DC 802DD6EC 00A0982D */  daddu     $s3, $a1, $zero
/* 1007E0 802DD6F0 AFB10014 */  sw        $s1, 0x14($sp)
/* 1007E4 802DD6F4 00C0882D */  daddu     $s1, $a2, $zero
/* 1007E8 802DD6F8 AFB40020 */  sw        $s4, 0x20($sp)
/* 1007EC 802DD6FC AFB00010 */  sw        $s0, 0x10($sp)
/* 1007F0 802DD700 0260802D */  daddu     $s0, $s3, $zero
/* 1007F4 802DD704 AFBF0028 */  sw        $ra, 0x28($sp)
/* 1007F8 802DD708 AFB20018 */  sw        $s2, 0x18($sp)
/* 1007FC 802DD70C 3C01802E */  lui       $at, %hi(SpriteUpdateNotifyValue)
/* 100800 802DD710 AC24FEAC */  sw        $a0, %lo(SpriteUpdateNotifyValue)($at)
/* 100804 802DD714 8E030000 */  lw        $v1, 0x0($s0)
/* 100808 802DD718 2402FFFF */  addiu     $v0, $zero, -0x1
/* 10080C 802DD71C 1062000E */  beq       $v1, $v0, .L802DD758
/* 100810 802DD720 00E0A02D */   daddu    $s4, $a3, $zero
/* 100814 802DD724 0040902D */  daddu     $s2, $v0, $zero
.L802DD728:
/* 100818 802DD728 8E040000 */  lw        $a0, 0x0($s0)
/* 10081C 802DD72C 8E250000 */  lw        $a1, 0x0($s1)
/* 100820 802DD730 0C0B7447 */  jal       spr_component_update_commands
/* 100824 802DD734 26100004 */   addiu    $s0, $s0, 0x4
/* 100828 802DD738 8E220000 */  lw        $v0, 0x0($s1)
/* 10082C 802DD73C 54520001 */  bnel      $v0, $s2, .L802DD744
/* 100830 802DD740 26310004 */   addiu    $s1, $s1, 0x4
.L802DD744:
/* 100834 802DD744 8E020000 */  lw        $v0, 0x0($s0)
/* 100838 802DD748 1452FFF7 */  bne       $v0, $s2, .L802DD728
/* 10083C 802DD74C 2402FFFF */   addiu    $v0, $zero, -0x1
/* 100840 802DD750 0260802D */  daddu     $s0, $s3, $zero
/* 100844 802DD754 8E030000 */  lw        $v1, 0x0($s0)
.L802DD758:
/* 100848 802DD758 1062000A */  beq       $v1, $v0, .L802DD784
/* 10084C 802DD75C 0040882D */   daddu    $s1, $v0, $zero
.L802DD760:
/* 100850 802DD760 8E040000 */  lw        $a0, 0x0($s0)
/* 100854 802DD764 26100004 */  addiu     $s0, $s0, 0x4
/* 100858 802DD768 0260282D */  daddu     $a1, $s3, $zero
/* 10085C 802DD76C 0280302D */  daddu     $a2, $s4, $zero
/* 100860 802DD770 0C0B758D */  jal       spr_component_update_finish
/* 100864 802DD774 02A0382D */   daddu    $a3, $s5, $zero
/* 100868 802DD778 8E020000 */  lw        $v0, 0x0($s0)
/* 10086C 802DD77C 1451FFF8 */  bne       $v0, $s1, .L802DD760
/* 100870 802DD780 00000000 */   nop
.L802DD784:
/* 100874 802DD784 3C02802E */  lui       $v0, %hi(SpriteUpdateNotifyValue)
/* 100878 802DD788 8C42FEAC */  lw        $v0, %lo(SpriteUpdateNotifyValue)($v0)
/* 10087C 802DD78C 8FBF0028 */  lw        $ra, 0x28($sp)
/* 100880 802DD790 8FB50024 */  lw        $s5, 0x24($sp)
/* 100884 802DD794 8FB40020 */  lw        $s4, 0x20($sp)
/* 100888 802DD798 8FB3001C */  lw        $s3, 0x1C($sp)
/* 10088C 802DD79C 8FB20018 */  lw        $s2, 0x18($sp)
/* 100890 802DD7A0 8FB10014 */  lw        $s1, 0x14($sp)
/* 100894 802DD7A4 8FB00010 */  lw        $s0, 0x10($sp)
/* 100898 802DD7A8 03E00008 */  jr        $ra
/* 10089C 802DD7AC 27BD0030 */   addiu    $sp, $sp, 0x30

### DECOMPILED C INSTRUCTIONS:

void spr_component_update_commands(SpriteComponent* comp, SpriteAnimComponent* anim) {
    f32 posX, posY, posZ;
    f32 rotX, rotY, rotZ;
    f32 scaleX, scaleY, scaleZ;
    s32 changedFlags;

    u16* bufPos;
    u16* gotoPos;
    s32 cmdValue;

    if (comp->initialized) {
        scaleZ = 1.0f;
        scaleY = 1.0f;
        scaleX = 1.0f;
        changedFlags = 0;

        bufPos = comp->readPos;
        gotoPos = (u16*) -1;

        comp->waitTime -= spr_animUpdateTimeScale;

        while (comp->waitTime <= 0.0f) {
            // overflow check
            if (bufPos >= &anim->cmdList[anim->cmdListSize / 2]) {
                bufPos = anim->cmdList;
                break;
            }

            switch (*bufPos & 0xF000) {
                // 0VVV
                // Wait
                case 0x0000:
                    comp->waitTime = *bufPos++ & 0xFFF;
                    if (comp->waitTime == 0.0f) {
                        comp->waitTime = 4095.0f;
                    }
                    comp->posOffset.z = 0.0f;
                    comp->posOffset.y = 0.0f;
                    comp->posOffset.x = 0.0f;
                    comp->rotation.z = 0;
                    comp->rotation.y = 0;
                    comp->rotation.x = 0;
                    comp->scale.z = 1.0f;
                    comp->scale.y = 1.0f;
                    comp->scale.x = 1.0f;
                    break;
                // 2VVV
                // Goto -- jump to another position in the list
                case 0x2000:
                    bufPos = &anim->cmdList[spr_unpack_signed_12bit(*bufPos)];
                    if (bufPos == gotoPos) {
                        bufPos = anim->cmdList;
                        comp->waitTime = 1.0f;
                    }
                    gotoPos = bufPos;
                    break;
                // 1VVV
                // SetImage -- FFF is valid value for "no image"
                case 0x1000:
                    cmdValue = *bufPos++ & 0xFFF;
                    if (cmdValue != 0xFFF) {
                        comp->currentRaster = cmdValue;
                    } else {
                        comp->currentRaster = -1;
                    }
                    comp->currentPalette = -1;
                    break;
                // 6VVV
                // SetPalette -- FFF to clear
                case 0x6000:
                    cmdValue = *bufPos++ & 0xFFF;
                    if (cmdValue != 0xFFF) {
                        comp->currentPalette = cmdValue;
                    } else {
                        comp->currentPalette = -1;
                    }
                    break;
                // 8VUU
                // SetProperty
                // 81-XX parent to component XX
                // 82-YY set notify value to YY
                case 0x8000:
                    cmdValue = *bufPos++;
                    switch (cmdValue & 0xF00) {
                        case 0x100: // set parent
                            comp->properties = (comp->properties & 0xFFFF0000) | cmdValue;
                            break;
                        case 0x200: // set notify value
                            SpriteUpdateNotifyValue = cmdValue & 0xFF;
                            comp->properties = (comp->properties & 0xFF00FFFF) | (SpriteUpdateNotifyValue << 0x10);
                            break;
                    }
                    break;
                // 3VVV XXXX YYYY ZZZZ
                // SetPosition -- what does the flag do?
                case 0x3000:
                    switch (*bufPos++ & 0xF) {
                        case 0:
                        case 1:
                            posX = spr_unpack_signed_16bit(*bufPos++);
                            posY = spr_unpack_signed_16bit(*bufPos++);
                            posZ = spr_unpack_signed_16bit(*bufPos++);
                            changedFlags |= 1;
                            break;
                    }
                    break;
                // 4XXX YYYY ZZZZ
                // SetRotation (euler angles)
                case 0x4000:
                    rotX = spr_unpack_signed_12bit(*bufPos++);
                    rotY = spr_unpack_signed_16bit(*bufPos++);
                    rotZ = spr_unpack_signed_16bit(*bufPos++);
                    changedFlags |= 2;
                    break;
                // 5VVV UUUU
                // SetScale (%)
                case 0x5000:
                    switch (*bufPos++ & 0xF) {
                        case 0:
                            scaleZ = *bufPos++ / 100.0f;
                            scaleY = scaleZ;
                            scaleX = scaleZ;
                            break;
                        case 1:
                            scaleX = *bufPos++ / 100.0f;
                            break;
                        case 2:
                            scaleY = *bufPos++ / 100.0f;
                            break;
                        case 3:
                            scaleZ = *bufPos++ / 100.0f;
                            break;
                    }
                    changedFlags |= 4;
                    break;
                // 7VVV UUUU
                // Loop -- VV iterations jumping back to UUUU
                case 0x7000:
                    if (comp->loopCounter != 0) {
                        comp->loopCounter--;
                        if (comp->loopCounter == 0) {
                            bufPos += 2;
                            break;
                        }
                    } else {
                        comp->loopCounter = bufPos[1];
                    }
                    bufPos = &anim->cmdList[spr_unpack_signed_12bit(*bufPos)];
                    break;
                // invalid command
                default:
                    bufPos = anim->cmdList;
                    comp->waitTime = 1.0f;
                    break;
            }
        } // end loop

        comp->readPos = bufPos;
        if (changedFlags & 1) {
            comp->posOffset.x = posX;
            comp->posOffset.y = posY;
            comp->posOffset.z = posZ;
        }
        if (changedFlags & 2) {
            comp->rotation.x = rotX;
            comp->rotation.y = rotY;
            comp->rotation.z = rotZ;
        }
        if (changedFlags & 4) {
            comp->scale.x = scaleX;
            comp->scale.y = scaleY;
            comp->scale.z = scaleZ;
        }
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel calc_player_test_enemy
/* 1A0034 80271754 27BDFFD0 */  addiu     $sp, $sp, -0x30
/* 1A0038 80271758 AFB20020 */  sw        $s2, 0x20($sp)
/* 1A003C 8027175C 3C12800E */  lui       $s2, %hi(gBattleStatus)
/* 1A0040 80271760 2652C070 */  addiu     $s2, $s2, %lo(gBattleStatus)
/* 1A0044 80271764 AFBF002C */  sw        $ra, 0x2C($sp)
/* 1A0048 80271768 AFB40028 */  sw        $s4, 0x28($sp)
/* 1A004C 8027176C AFB30024 */  sw        $s3, 0x24($sp)
/* 1A0050 80271770 AFB1001C */  sw        $s1, 0x1C($sp)
/* 1A0054 80271774 AFB00018 */  sw        $s0, 0x18($sp)
/* 1A0058 80271778 964201A0 */  lhu       $v0, 0x1A0($s2)
/* 1A005C 8027177C 864401A0 */  lh        $a0, 0x1A0($s2)
/* 1A0060 80271780 924301A2 */  lbu       $v1, 0x1A2($s2)
/* 1A0064 80271784 8E5400D8 */  lw        $s4, 0xD8($s2)
/* 1A0068 80271788 825101A2 */  lb        $s1, 0x1A2($s2)
/* 1A006C 8027178C A64201A4 */  sh        $v0, 0x1A4($s2)
/* 1A0070 80271790 0C09A75B */  jal       get_actor
/* 1A0074 80271794 A24301A6 */   sb       $v1, 0x1A6($s2)
/* 1A0078 80271798 0040982D */  daddu     $s3, $v0, $zero
/* 1A007C 8027179C 12600060 */  beqz      $s3, .L80271920
/* 1A0080 802717A0 2690000C */   addiu    $s0, $s4, 0xC
/* 1A0084 802717A4 0260202D */  daddu     $a0, $s3, $zero
/* 1A0088 802717A8 0C099117 */  jal       get_actor_part
/* 1A008C 802717AC 0220282D */   daddu    $a1, $s1, $zero
/* 1A0090 802717B0 0040882D */  daddu     $s1, $v0, $zero
/* 1A0094 802717B4 16200003 */  bnez      $s1, .L802717C4
/* 1A0098 802717B8 00000000 */   nop
.L802717BC:
/* 1A009C 802717BC 0809C5EF */  j         .L802717BC
/* 1A00A0 802717C0 00000000 */   nop
.L802717C4:
/* 1A00A4 802717C4 8E24007C */  lw        $a0, 0x7C($s1)
/* 1A00A8 802717C8 30820020 */  andi      $v0, $a0, 0x20
/* 1A00AC 802717CC 14400055 */  bnez      $v0, .L80271924
/* 1A00B0 802717D0 24020006 */   addiu    $v0, $zero, 0x6
/* 1A00B4 802717D4 82630218 */  lb        $v1, 0x218($s3)
/* 1A00B8 802717D8 2402000E */  addiu     $v0, $zero, 0xE
/* 1A00BC 802717DC 10620007 */  beq       $v1, $v0, .L802717FC
/* 1A00C0 802717E0 30820800 */   andi     $v0, $a0, 0x800
/* 1A00C4 802717E4 10400007 */  beqz      $v0, .L80271804
/* 1A00C8 802717E8 00000000 */   nop
/* 1A00CC 802717EC 8E420188 */  lw        $v0, 0x188($s2)
/* 1A00D0 802717F0 30420800 */  andi      $v0, $v0, 0x800
/* 1A00D4 802717F4 14400003 */  bnez      $v0, .L80271804
/* 1A00D8 802717F8 00000000 */   nop
.L802717FC:
/* 1A00DC 802717FC 0809C649 */  j         .L80271924
/* 1A00E0 80271800 24020006 */   addiu    $v0, $zero, 0x6
.L80271804:
/* 1A00E4 80271804 82630214 */  lb        $v1, 0x214($s3)
/* 1A00E8 80271808 2402000C */  addiu     $v0, $zero, 0xC
/* 1A00EC 8027180C 14620009 */  bne       $v1, $v0, .L80271834
/* 1A00F0 80271810 2404010C */   addiu    $a0, $zero, 0x10C
/* 1A00F4 80271814 C6000014 */  lwc1      $f0, 0x14($s0)
/* 1A00F8 80271818 E7A00010 */  swc1      $f0, 0x10($sp)
/* 1A00FC 8027181C 8E06000C */  lw        $a2, 0xC($s0)
/* 1A0100 80271820 8E070010 */  lw        $a3, 0x10($s0)
/* 1A0104 80271824 0C052757 */  jal       sfx_play_sound_at_position
/* 1A0108 80271828 0000282D */   daddu    $a1, $zero, $zero
/* 1A010C 8027182C 0809C649 */  j         .L80271924
/* 1A0110 80271830 24020008 */   addiu    $v0, $zero, 0x8
.L80271834:
/* 1A0114 80271834 8E420188 */  lw        $v0, 0x188($s2)
/* 1A0118 80271838 30420080 */  andi      $v0, $v0, 0x80
/* 1A011C 8027183C 10400012 */  beqz      $v0, .L80271888
/* 1A0120 80271840 3C031000 */   lui      $v1, (0x10000080 >> 16)
/* 1A0124 80271844 8E22007C */  lw        $v0, 0x7C($s1)
/* 1A0128 80271848 30420010 */  andi      $v0, $v0, 0x10
/* 1A012C 8027184C 1040000E */  beqz      $v0, .L80271888
/* 1A0130 80271850 0280202D */   daddu    $a0, $s4, $zero
/* 1A0134 80271854 0C099CAB */  jal       player_team_is_ability_active
/* 1A0138 80271858 24050002 */   addiu    $a1, $zero, 0x2
/* 1A013C 8027185C 1440000A */  bnez      $v0, .L80271888
/* 1A0140 80271860 3C031000 */   lui      $v1, (0x10000080 >> 16)
/* 1A0144 80271864 C6000014 */  lwc1      $f0, 0x14($s0)
/* 1A0148 80271868 24040108 */  addiu     $a0, $zero, 0x108
/* 1A014C 8027186C E7A00010 */  swc1      $f0, 0x10($sp)
/* 1A0150 80271870 8E06000C */  lw        $a2, 0xC($s0)
/* 1A0154 80271874 8E070010 */  lw        $a3, 0x10($s0)
/* 1A0158 80271878 0C052757 */  jal       sfx_play_sound_at_position
/* 1A015C 8027187C 0000282D */   daddu    $a1, $zero, $zero
/* 1A0160 80271880 0809C649 */  j         .L80271924
/* 1A0164 80271884 24020004 */   addiu    $v0, $zero, 0x4
.L80271888:
/* 1A0168 80271888 8E420188 */  lw        $v0, 0x188($s2)
/* 1A016C 8027188C 34630080 */  ori       $v1, $v1, (0x10000080 & 0xFFFF)
/* 1A0170 80271890 00431024 */  and       $v0, $v0, $v1
/* 1A0174 80271894 1440001B */  bnez      $v0, .L80271904
/* 1A0178 80271898 3C030001 */   lui      $v1, (0x10000 >> 16)
/* 1A017C 8027189C 8E22007C */  lw        $v0, 0x7C($s1)
/* 1A0180 802718A0 00431024 */  and       $v0, $v0, $v1
/* 1A0184 802718A4 10400017 */  beqz      $v0, .L80271904
/* 1A0188 802718A8 00000000 */   nop
/* 1A018C 802718AC 8E42018C */  lw        $v0, 0x18C($s2)
/* 1A0190 802718B0 30420004 */  andi      $v0, $v0, 0x4
/* 1A0194 802718B4 14400013 */  bnez      $v0, .L80271904
/* 1A0198 802718B8 0280202D */   daddu    $a0, $s4, $zero
/* 1A019C 802718BC 0C099CAB */  jal       player_team_is_ability_active
/* 1A01A0 802718C0 24050002 */   addiu    $a1, $zero, 0x2
/* 1A01A4 802718C4 1440000F */  bnez      $v0, .L80271904
/* 1A01A8 802718C8 24040108 */   addiu    $a0, $zero, 0x108
/* 1A01AC 802718CC C6000014 */  lwc1      $f0, 0x14($s0)
/* 1A01B0 802718D0 E7A00010 */  swc1      $f0, 0x10($sp)
/* 1A01B4 802718D4 8E06000C */  lw        $a2, 0xC($s0)
/* 1A01B8 802718D8 8E070010 */  lw        $a3, 0x10($s0)
/* 1A01BC 802718DC 0C052757 */  jal       sfx_play_sound_at_position
/* 1A01C0 802718E0 0000282D */   daddu    $a1, $zero, $zero
/* 1A01C4 802718E4 24040001 */  addiu     $a0, $zero, 0x1
/* 1A01C8 802718E8 0C09CCEA */  jal       dispatch_damage_event_player_1
/* 1A01CC 802718EC 2405002A */   addiu    $a1, $zero, 0x2A
/* 1A01D0 802718F0 0260202D */  daddu     $a0, $s3, $zero
/* 1A01D4 802718F4 0C09DC58 */  jal       dispatch_event_actor
/* 1A01D8 802718F8 2405001B */   addiu    $a1, $zero, 0x1B
/* 1A01DC 802718FC 0809C649 */  j         .L80271924
/* 1A01E0 80271900 2402FFFF */   addiu    $v0, $zero, -0x1
.L80271904:
/* 1A01E4 80271904 82820212 */  lb        $v0, 0x212($s4)
/* 1A01E8 80271908 2404000B */  addiu     $a0, $zero, 0xB
/* 1A01EC 8027190C 10440005 */  beq       $v0, $a0, .L80271924
/* 1A01F0 80271910 0000102D */   daddu    $v0, $zero, $zero
/* 1A01F4 80271914 82630212 */  lb        $v1, 0x212($s3)
/* 1A01F8 80271918 10640002 */  beq       $v1, $a0, .L80271924
/* 1A01FC 8027191C 24020007 */   addiu    $v0, $zero, 0x7
.L80271920:
/* 1A0200 80271920 0000102D */  daddu     $v0, $zero, $zero
.L80271924:
/* 1A0204 80271924 8FBF002C */  lw        $ra, 0x2C($sp)
/* 1A0208 80271928 8FB40028 */  lw        $s4, 0x28($sp)
/* 1A020C 8027192C 8FB30024 */  lw        $s3, 0x24($sp)
/* 1A0210 80271930 8FB20020 */  lw        $s2, 0x20($sp)
/* 1A0214 80271934 8FB1001C */  lw        $s1, 0x1C($sp)
/* 1A0218 80271938 8FB00018 */  lw        $s0, 0x18($sp)
/* 1A021C 8027193C 03E00008 */  jr        $ra
/* 1A0220 80271940 27BD0030 */   addiu    $sp, $sp, 0x30

### DECOMPILED C INSTRUCTIONS:

HitResult calc_player_test_enemy(void) {
    BattleStatus* battleStatus = &gBattleStatus;
    Actor* player = battleStatus->playerActor;
    ActorState* state = &player->state;
    s32 targetActorID = battleStatus->currentTargetID;
    s32 targetPartIdx = battleStatus->currentTargetPart;
    Actor* target;
    ActorPart* targetPart;

    battleStatus->currentTargetID2 = battleStatus->currentTargetID;
    battleStatus->currentTargetPart2 = battleStatus->currentTargetPart;

    target = get_actor(targetActorID);
    if (target == NULL) {
        return HIT_RESULT_HIT;
    }

    targetPart = get_actor_part(target, targetPartIdx);
    ASSERT(targetPart != NULL);

    if (targetPart->eventFlags & ACTOR_EVENT_FLAG_ILLUSORY) {
        return HIT_RESULT_MISS;
    }

    if (target->transparentStatus == STATUS_KEY_TRANSPARENT
        || (targetPart->eventFlags & ACTOR_EVENT_FLAG_800)
        && !(battleStatus->currentAttackElement & DAMAGE_TYPE_QUAKE))
    {
        return HIT_RESULT_MISS;
    }

    if (target->stoneStatus == STATUS_KEY_STONE) {
        sfx_play_sound_at_position(SOUND_IMMUNE, SOUND_SPACE_MODE_0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
        return HIT_RESULT_IMMUNE;
    }

    if ((battleStatus->currentAttackElement & DAMAGE_TYPE_JUMP)
        && (targetPart->eventFlags & ACTOR_EVENT_FLAG_SPIKY_TOP)
        && !player_team_is_ability_active(player, ABILITY_SPIKE_SHIELD))
    {
        sfx_play_sound_at_position(SOUND_108, SOUND_SPACE_MODE_0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
        return HIT_RESULT_LANDED_ON_SPIKE;
    }

    if (!(battleStatus->currentAttackElement & (DAMAGE_TYPE_NO_CONTACT | DAMAGE_TYPE_JUMP))
        && (targetPart->eventFlags & ACTOR_EVENT_FLAG_SPIKY_FRONT)
        && (!(battleStatus->currentAttackEventSuppression & SUPPRESS_EVENT_SPIKY_FRONT)
        && !player_team_is_ability_active(player, ABILITY_SPIKE_SHIELD)))
    {
        sfx_play_sound_at_position(SOUND_108, SOUND_SPACE_MODE_0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
        dispatch_damage_event_player_1(1, EVENT_SPIKE_CONTACT);
        dispatch_event_actor(target, EVENT_SPIKE_TAUNT);
        return HIT_RESULT_BACKFIRE;
    }

    if (player->staticStatus != STATUS_KEY_STATIC && target->staticStatus == STATUS_KEY_STATIC) {
        return HIT_RESULT_HIT_STATIC;
    }

    return HIT_RESULT_HIT;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel throw_spiny_main
/* 3CF3A0 E00C8000 27BDFF90 */  addiu     $sp, $sp, -0x70
/* 3CF3A4 E00C8004 F7B40040 */  sdc1      $f20, 0x40($sp)
/* 3CF3A8 E00C8008 4485A000 */  mtc1      $a1, $f20
/* 3CF3AC E00C800C F7B60048 */  sdc1      $f22, 0x48($sp)
/* 3CF3B0 E00C8010 4486B000 */  mtc1      $a2, $f22
/* 3CF3B4 E00C8014 F7B80050 */  sdc1      $f24, 0x50($sp)
/* 3CF3B8 E00C8018 4487C000 */  mtc1      $a3, $f24
/* 3CF3BC E00C801C F7BA0058 */  sdc1      $f26, 0x58($sp)
/* 3CF3C0 E00C8020 C7BA0080 */  lwc1      $f26, 0x80($sp)
/* 3CF3C4 E00C8024 F7BC0060 */  sdc1      $f28, 0x60($sp)
/* 3CF3C8 E00C8028 C7BC0084 */  lwc1      $f28, 0x84($sp)
/* 3CF3CC E00C802C AFB30034 */  sw        $s3, 0x34($sp)
/* 3CF3D0 E00C8030 0080982D */  daddu     $s3, $a0, $zero
/* 3CF3D4 E00C8034 F7BE0068 */  sdc1      $f30, 0x68($sp)
/* 3CF3D8 E00C8038 C7BE0088 */  lwc1      $f30, 0x88($sp)
/* 3CF3DC E00C803C 27A40010 */  addiu     $a0, $sp, 0x10
/* 3CF3E0 E00C8040 AFB1002C */  sw        $s1, 0x2C($sp)
/* 3CF3E4 E00C8044 8FB10090 */  lw        $s1, 0x90($sp)
/* 3CF3E8 E00C8048 3C02E00D */  lui       $v0, %hi(throw_spiny_init)
/* 3CF3EC E00C804C 24428218 */  addiu     $v0, $v0, %lo(throw_spiny_init)
/* 3CF3F0 E00C8050 AFA20018 */  sw        $v0, 0x18($sp)
/* 3CF3F4 E00C8054 3C02E00D */  lui       $v0, %hi(throw_spiny_update)
/* 3CF3F8 E00C8058 24428220 */  addiu     $v0, $v0, %lo(throw_spiny_update)
/* 3CF3FC E00C805C AFA2001C */  sw        $v0, 0x1C($sp)
/* 3CF400 E00C8060 3C02E00D */  lui       $v0, %hi(throw_spiny_render)
/* 3CF404 E00C8064 24428404 */  addiu     $v0, $v0, %lo(throw_spiny_render)
/* 3CF408 E00C8068 AFA20020 */  sw        $v0, 0x20($sp)
/* 3CF40C E00C806C 24020064 */  addiu     $v0, $zero, 0x64
/* 3CF410 E00C8070 AFBF0038 */  sw        $ra, 0x38($sp)
/* 3CF414 E00C8074 AFB20030 */  sw        $s2, 0x30($sp)
/* 3CF418 E00C8078 AFB00028 */  sw        $s0, 0x28($sp)
/* 3CF41C E00C807C AFA00010 */  sw        $zero, 0x10($sp)
/* 3CF420 E00C8080 AFA00024 */  sw        $zero, 0x24($sp)
/* 3CF424 E00C8084 0C080124 */  jal       shim_create_effect_instance
/* 3CF428 E00C8088 AFA20014 */   sw       $v0, 0x14($sp)
/* 3CF42C E00C808C 2404006C */  addiu     $a0, $zero, 0x6C
/* 3CF430 E00C8090 24030001 */  addiu     $v1, $zero, 0x1
/* 3CF434 E00C8094 0040902D */  daddu     $s2, $v0, $zero
/* 3CF438 E00C8098 0C08012C */  jal       shim_general_heap_malloc
/* 3CF43C E00C809C AE430008 */   sw       $v1, 0x8($s2)
/* 3CF440 E00C80A0 0040802D */  daddu     $s0, $v0, $zero
/* 3CF444 E00C80A4 16000003 */  bnez      $s0, .LE00C80B4
/* 3CF448 E00C80A8 AE42000C */   sw       $v0, 0xC($s2)
.LE00C80AC:
/* 3CF44C E00C80AC 0803202B */  j         .LE00C80AC
/* 3CF450 E00C80B0 00000000 */   nop
.LE00C80B4:
/* 3CF454 E00C80B4 AE130000 */  sw        $s3, 0x0($s0)
/* 3CF458 E00C80B8 1E200003 */  bgtz      $s1, .LE00C80C8
/* 3CF45C E00C80BC AE00002C */   sw       $zero, 0x2C($s0)
/* 3CF460 E00C80C0 08032033 */  j         .LE00C80CC
/* 3CF464 E00C80C4 240203E8 */   addiu    $v0, $zero, 0x3E8
.LE00C80C8:
/* 3CF468 E00C80C8 2622003C */  addiu     $v0, $s1, 0x3C
.LE00C80CC:
/* 3CF46C E00C80CC AE020028 */  sw        $v0, 0x28($s0)
/* 3CF470 E00C80D0 240200FF */  addiu     $v0, $zero, 0xFF
/* 3CF474 E00C80D4 44913000 */  mtc1      $s1, $f6
/* 3CF478 E00C80D8 00000000 */  nop
/* 3CF47C E00C80DC 468031A1 */  cvt.d.w   $f6, $f6
/* 3CF480 E00C80E0 4616E201 */  sub.s     $f8, $f28, $f22
/* 3CF484 E00C80E4 44912000 */  mtc1      $s1, $f4
/* 3CF488 E00C80E8 00000000 */  nop
/* 3CF48C E00C80EC 46802120 */  cvt.s.w   $f4, $f4
/* 3CF490 E00C80F0 3C01E00D */  lui       $at, (0xE00D0000 >> 16)
/* 3CF494 E00C80F4 D4208730 */  ldc1      $f0, -0x78D0($at)
/* 3CF498 E00C80F8 4618F081 */  sub.s     $f2, $f30, $f24
/* 3CF49C E00C80FC AE110068 */  sw        $s1, 0x68($s0)
/* 3CF4A0 E00C8100 AE02003C */  sw        $v0, 0x3C($s0)
/* 3CF4A4 E00C8104 46203182 */  mul.d     $f6, $f6, $f0
/* 3CF4A8 E00C8108 00000000 */  nop
/* 3CF4AC E00C810C E6140010 */  swc1      $f20, 0x10($s0)
/* 3CF4B0 E00C8110 E6160014 */  swc1      $f22, 0x14($s0)
/* 3CF4B4 E00C8114 E6180018 */  swc1      $f24, 0x18($s0)
/* 3CF4B8 E00C8118 E61A001C */  swc1      $f26, 0x1C($s0)
/* 3CF4BC E00C811C E61C0020 */  swc1      $f28, 0x20($s0)
/* 3CF4C0 E00C8120 E61E0024 */  swc1      $f30, 0x24($s0)
/* 3CF4C4 E00C8124 E6140004 */  swc1      $f20, 0x4($s0)
/* 3CF4C8 E00C8128 4614D001 */  sub.s     $f0, $f26, $f20
/* 3CF4CC E00C812C 46041083 */  div.s     $f2, $f2, $f4
/* 3CF4D0 E00C8130 E602004C */  swc1      $f2, 0x4C($s0)
/* 3CF4D4 E00C8134 44801000 */  mtc1      $zero, $f2
/* 3CF4D8 E00C8138 46040003 */  div.s     $f0, $f0, $f4
/* 3CF4DC E00C813C E6000044 */  swc1      $f0, 0x44($s0)
/* 3CF4E0 E00C8140 46044003 */  div.s     $f0, $f8, $f4
/* 3CF4E4 E00C8144 46000021 */  cvt.d.s   $f0, $f0
/* 3CF4E8 E00C8148 46260001 */  sub.d     $f0, $f0, $f6
/* 3CF4EC E00C814C E6160008 */  swc1      $f22, 0x8($s0)
/* 3CF4F0 E00C8150 E618000C */  swc1      $f24, 0xC($s0)
/* 3CF4F4 E00C8154 4602403C */  c.lt.s    $f8, $f2
/* 3CF4F8 E00C8158 46200020 */  cvt.s.d   $f0, $f0
/* 3CF4FC E00C815C 45000004 */  bc1f      .LE00C8170
/* 3CF500 E00C8160 E6000048 */   swc1     $f0, 0x48($s0)
/* 3CF504 E00C8164 24020001 */  addiu     $v0, $zero, 0x1
/* 3CF508 E00C8168 0803205D */  j         .LE00C8174
/* 3CF50C E00C816C AE020064 */   sw       $v0, 0x64($s0)
.LE00C8170:
/* 3CF510 E00C8170 AE000064 */  sw        $zero, 0x64($s0)
.LE00C8174:
/* 3CF514 E00C8174 24040168 */  addiu     $a0, $zero, 0x168
/* 3CF518 E00C8178 C7A0008C */  lwc1      $f0, 0x8C($sp)
/* 3CF51C E00C817C 24020046 */  addiu     $v0, $zero, 0x46
/* 3CF520 E00C8180 AE020030 */  sw        $v0, 0x30($s0)
/* 3CF524 E00C8184 240200B4 */  addiu     $v0, $zero, 0xB4
/* 3CF528 E00C8188 AE020034 */  sw        $v0, 0x34($s0)
/* 3CF52C E00C818C 24020078 */  addiu     $v0, $zero, 0x78
/* 3CF530 E00C8190 AE020038 */  sw        $v0, 0x38($s0)
/* 3CF534 E00C8194 0C080138 */  jal       shim_rand_int
/* 3CF538 E00C8198 E6000040 */   swc1     $f0, 0x40($s0)
/* 3CF53C E00C819C 2404000A */  addiu     $a0, $zero, 0xA
/* 3CF540 E00C81A0 44820000 */  mtc1      $v0, $f0
/* 3CF544 E00C81A4 00000000 */  nop
/* 3CF548 E00C81A8 46800020 */  cvt.s.w   $f0, $f0
/* 3CF54C E00C81AC 0C080138 */  jal       shim_rand_int
/* 3CF550 E00C81B0 E6000050 */   swc1     $f0, 0x50($s0)
/* 3CF554 E00C81B4 24430005 */  addiu     $v1, $v0, 0x5
/* 3CF558 E00C81B8 0240102D */  daddu     $v0, $s2, $zero
/* 3CF55C E00C81BC 44830000 */  mtc1      $v1, $f0
/* 3CF560 E00C81C0 00000000 */  nop
/* 3CF564 E00C81C4 46800020 */  cvt.s.w   $f0, $f0
/* 3CF568 E00C81C8 E6000054 */  swc1      $f0, 0x54($s0)
/* 3CF56C E00C81CC 3C013F80 */  lui       $at, (0x3F800000 >> 16)
/* 3CF570 E00C81D0 44810000 */  mtc1      $at, $f0
/* 3CF574 E00C81D4 2403FFFF */  addiu     $v1, $zero, -0x1
/* 3CF578 E00C81D8 AE030060 */  sw        $v1, 0x60($s0)
/* 3CF57C E00C81DC E6000058 */  swc1      $f0, 0x58($s0)
/* 3CF580 E00C81E0 E600005C */  swc1      $f0, 0x5C($s0)
/* 3CF584 E00C81E4 8FBF0038 */  lw        $ra, 0x38($sp)
/* 3CF588 E00C81E8 8FB30034 */  lw        $s3, 0x34($sp)
/* 3CF58C E00C81EC 8FB20030 */  lw        $s2, 0x30($sp)
/* 3CF590 E00C81F0 8FB1002C */  lw        $s1, 0x2C($sp)
/* 3CF594 E00C81F4 8FB00028 */  lw        $s0, 0x28($sp)
/* 3CF598 E00C81F8 D7BE0068 */  ldc1      $f30, 0x68($sp)
/* 3CF59C E00C81FC D7BC0060 */  ldc1      $f28, 0x60($sp)
/* 3CF5A0 E00C8200 D7BA0058 */  ldc1      $f26, 0x58($sp)
/* 3CF5A4 E00C8204 D7B80050 */  ldc1      $f24, 0x50($sp)
/* 3CF5A8 E00C8208 D7B60048 */  ldc1      $f22, 0x48($sp)
/* 3CF5AC E00C820C D7B40040 */  ldc1      $f20, 0x40($sp)
/* 3CF5B0 E00C8210 03E00008 */  jr        $ra
/* 3CF5B4 E00C8214 27BD0070 */   addiu    $sp, $sp, 0x70

### DECOMPILED C INSTRUCTIONS:

EffectInstance* throw_spiny_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7, s32 time) {
    EffectBlueprint bp;
    EffectBlueprint* bpPtr = &bp;
    EffectInstance* effect;
    ThrowSpinyFXData* spinyObject;
    s32 numParts = 1;
    f32 temp_f4, temp_f8, gravity;

    bp.init = throw_spiny_init;
    bp.update = throw_spiny_update;
    bp.renderWorld = throw_spiny_render;
    bp.unk_00 = 0;
    bp.renderUI = NULL;
    bp.effectID = EFFECT_THROW_SPINY;

    effect = (EffectInstance*)shim_create_effect_instance(bpPtr);
    effect->numParts = numParts;
    spinyObject = effect->data.throwSpiny = shim_general_heap_malloc(numParts * sizeof(*spinyObject));
    ASSERT(effect->data.throwSpiny != NULL);
    spinyObject->unk_00 = arg0;
    spinyObject->lifeDuration = 0;

    if (time <= 0) {
        spinyObject->life = 1000;
    } else {
        spinyObject->life = time + 60;
    }

    temp_f8 = arg5 - arg2;
    temp_f4 = time;
    gravity = (temp_f8 / temp_f4) - (time * -0.10000000149011612); //TODO: fix this weird number
    spinyObject->timeUntilFall = time;
    spinyObject->rgba = 255;
    spinyObject->unk_10 = arg1;
    spinyObject->unk_14 = arg2;
    spinyObject->unk_18 = arg3;
    spinyObject->unk_1C = arg4;
    spinyObject->unk_20 = arg5;
    spinyObject->unk_24 = arg6;
    spinyObject->unk_44 = (arg4 - arg1) / temp_f4;
    spinyObject->unk_4C = (arg6 - arg3) / temp_f4;
    spinyObject->pos.x = arg1;
    spinyObject->pos.y = arg2;
    spinyObject->pos.z = arg3;
    spinyObject->gravity = gravity;

    if (temp_f8 < 0.0f) {
        spinyObject->unk_64 = 1;
    } else {
        spinyObject->unk_64 = 0;
    }

    spinyObject->unk_40 = arg7;
    spinyObject->unk_30 = 70;
    spinyObject->unk_34 = 180;
    spinyObject->unk_38 = 120;
    spinyObject->yaw = shim_rand_int(360);
    spinyObject->rotationSpeed = shim_rand_int(10) + 5;
    spinyObject->state = -1;
    spinyObject->xScale = 1.0f;
    spinyObject->yScale = 1.0f;
    return effect;
}