### RAW ASSEMBLY INSTRUCTIONS:

glabel imgfx_appendGfx_mesh_grid
/* D41B4 8013DAB4 27BDFFB0 */  addiu     $sp, $sp, -0x50
/* D41B8 8013DAB8 AFB40038 */  sw        $s4, 0x38($sp)
/* D41BC 8013DABC 0080A02D */  daddu     $s4, $a0, $zero
/* D41C0 8013DAC0 AFBF004C */  sw        $ra, 0x4C($sp)
/* D41C4 8013DAC4 AFBE0048 */  sw        $fp, 0x48($sp)
/* D41C8 8013DAC8 AFB70044 */  sw        $s7, 0x44($sp)
/* D41CC 8013DACC AFB60040 */  sw        $s6, 0x40($sp)
/* D41D0 8013DAD0 AFB5003C */  sw        $s5, 0x3C($sp)
/* D41D4 8013DAD4 AFB30034 */  sw        $s3, 0x34($sp)
/* D41D8 8013DAD8 AFB20030 */  sw        $s2, 0x30($sp)
/* D41DC 8013DADC AFB1002C */  sw        $s1, 0x2C($sp)
/* D41E0 8013DAE0 AFB00028 */  sw        $s0, 0x28($sp)
/* D41E4 8013DAE4 AFA50054 */  sw        $a1, 0x54($sp)
/* D41E8 8013DAE8 8E820014 */  lw        $v0, 0x14($s4)
/* D41EC 8013DAEC 30420020 */  andi      $v0, $v0, 0x20
/* D41F0 8013DAF0 14400030 */  bnez      $v0, .L8013DBB4
/* D41F4 8013DAF4 3C03E300 */   lui      $v1, (0xE3001001 >> 16)
/* D41F8 8013DAF8 34631001 */  ori       $v1, $v1, (0xE3001001 & 0xFFFF)
/* D41FC 8013DAFC 3C06F500 */  lui       $a2, (0xF5000100 >> 16)
/* D4200 8013DB00 34C60100 */  ori       $a2, $a2, (0xF5000100 & 0xFFFF)
/* D4204 8013DB04 3C070703 */  lui       $a3, (0x703C000 >> 16)
/* D4208 8013DB08 3C04800A */  lui       $a0, %hi(gMainGfxPos)
/* D420C 8013DB0C 2484A66C */  addiu     $a0, $a0, %lo(gMainGfxPos)
/* D4210 8013DB10 8C820000 */  lw        $v0, 0x0($a0)
/* D4214 8013DB14 34E7C000 */  ori       $a3, $a3, (0x703C000 & 0xFFFF)
/* D4218 8013DB18 0040282D */  daddu     $a1, $v0, $zero
/* D421C 8013DB1C 24420008 */  addiu     $v0, $v0, 0x8
/* D4220 8013DB20 AC820000 */  sw        $v0, 0x0($a0)
/* D4224 8013DB24 ACA30000 */  sw        $v1, 0x0($a1)
/* D4228 8013DB28 34038000 */  ori       $v1, $zero, 0x8000
/* D422C 8013DB2C ACA30004 */  sw        $v1, 0x4($a1)
/* D4230 8013DB30 24430008 */  addiu     $v1, $v0, 0x8
/* D4234 8013DB34 AC830000 */  sw        $v1, 0x0($a0)
/* D4238 8013DB38 3C058015 */  lui       $a1, %hi(ImgFXCurrentTexturePtr)
/* D423C 8013DB3C 8CA5EE10 */  lw        $a1, %lo(ImgFXCurrentTexturePtr)($a1)
/* D4240 8013DB40 3C03FD10 */  lui       $v1, (0xFD100000 >> 16)
/* D4244 8013DB44 AC430000 */  sw        $v1, 0x0($v0)
/* D4248 8013DB48 24430010 */  addiu     $v1, $v0, 0x10
/* D424C 8013DB4C AC830000 */  sw        $v1, 0x0($a0)
/* D4250 8013DB50 8CA50004 */  lw        $a1, 0x4($a1)
/* D4254 8013DB54 3C03E800 */  lui       $v1, (0xE8000000 >> 16)
/* D4258 8013DB58 AC430008 */  sw        $v1, 0x8($v0)
/* D425C 8013DB5C 24430018 */  addiu     $v1, $v0, 0x18
/* D4260 8013DB60 AC40000C */  sw        $zero, 0xC($v0)
/* D4264 8013DB64 AC830000 */  sw        $v1, 0x0($a0)
/* D4268 8013DB68 3C030700 */  lui       $v1, (0x7000000 >> 16)
/* D426C 8013DB6C AC430014 */  sw        $v1, 0x14($v0)
/* D4270 8013DB70 24430020 */  addiu     $v1, $v0, 0x20
/* D4274 8013DB74 AC460010 */  sw        $a2, 0x10($v0)
/* D4278 8013DB78 AC830000 */  sw        $v1, 0x0($a0)
/* D427C 8013DB7C 3C03E600 */  lui       $v1, (0xE6000000 >> 16)
/* D4280 8013DB80 AC430018 */  sw        $v1, 0x18($v0)
/* D4284 8013DB84 24430028 */  addiu     $v1, $v0, 0x28
/* D4288 8013DB88 AC40001C */  sw        $zero, 0x1C($v0)
/* D428C 8013DB8C AC830000 */  sw        $v1, 0x0($a0)
/* D4290 8013DB90 3C03F000 */  lui       $v1, (0xF0000000 >> 16)
/* D4294 8013DB94 AC430020 */  sw        $v1, 0x20($v0)
/* D4298 8013DB98 24430030 */  addiu     $v1, $v0, 0x30
/* D429C 8013DB9C AC470024 */  sw        $a3, 0x24($v0)
/* D42A0 8013DBA0 AC830000 */  sw        $v1, 0x0($a0)
/* D42A4 8013DBA4 3C03E700 */  lui       $v1, (0xE7000000 >> 16)
/* D42A8 8013DBA8 AC430028 */  sw        $v1, 0x28($v0)
/* D42AC 8013DBAC AC40002C */  sw        $zero, 0x2C($v0)
/* D42B0 8013DBB0 AC450004 */  sw        $a1, 0x4($v0)
.L8013DBB4:
/* D42B4 8013DBB4 92820004 */  lbu       $v0, 0x4($s4)
/* D42B8 8013DBB8 968E0008 */  lhu       $t6, 0x8($s4)
/* D42BC 8013DBBC 104001C0 */  beqz      $v0, .L8013E2C0
/* D42C0 8013DBC0 0000A82D */   daddu    $s5, $zero, $zero
/* D42C4 8013DBC4 3C10800A */  lui       $s0, %hi(gMainGfxPos)
/* D42C8 8013DBC8 2610A66C */  addiu     $s0, $s0, %lo(gMainGfxPos)
/* D42CC 8013DBCC 3C1EF540 */  lui       $fp, (0xF5400000 >> 16)
/* D42D0 8013DBD0 3C17F200 */  lui       $s7, (0xF2000000 >> 16)
.L8013DBD4:
/* D42D4 8013DBD4 92830003 */  lbu       $v1, 0x3($s4)
/* D42D8 8013DBD8 106001B4 */  beqz      $v1, .L8013E2AC
/* D42DC 8013DBDC 0000902D */   daddu    $s2, $zero, $zero
/* D42E0 8013DBE0 24630001 */  addiu     $v1, $v1, 0x1
.L8013DBE4:
/* D42E4 8013DBE4 02A30018 */  mult      $s5, $v1
/* D42E8 8013DBE8 00004012 */  mflo      $t0
/* D42EC 8013DBEC 26A20001 */  addiu     $v0, $s5, 0x1
/* D42F0 8013DBF0 00000000 */  nop
/* D42F4 8013DBF4 00430018 */  mult      $v0, $v1
/* D42F8 8013DBF8 01C81021 */  addu      $v0, $t6, $t0
/* D42FC 8013DBFC 00528821 */  addu      $s1, $v0, $s2
/* D4300 8013DC00 262F0001 */  addiu     $t7, $s1, 0x1
/* D4304 8013DC04 00001812 */  mflo      $v1
/* D4308 8013DC08 01C31021 */  addu      $v0, $t6, $v1
/* D430C 8013DC0C 0052B021 */  addu      $s6, $v0, $s2
/* D4310 8013DC10 8E830014 */  lw        $v1, 0x14($s4)
/* D4314 8013DC14 30620020 */  andi      $v0, $v1, 0x20
/* D4318 8013DC18 14400173 */  bnez      $v0, .L8013E1E8
/* D431C 8013DC1C 26D30001 */   addiu    $s3, $s6, 0x1
/* D4320 8013DC20 3C028015 */  lui       $v0, %hi(gSpriteShadingProfile)
/* D4324 8013DC24 8C421328 */  lw        $v0, %lo(gSpriteShadingProfile)($v0)
/* D4328 8013DC28 94420000 */  lhu       $v0, 0x0($v0)
/* D432C 8013DC2C 30420001 */  andi      $v0, $v0, 0x1
/* D4330 8013DC30 504000E9 */  beql      $v0, $zero, .L8013DFD8
/* D4334 8013DC34 3C08070A */   lui      $t0, (0x70A0280 >> 16)
/* D4338 8013DC38 3C028015 */  lui       $v0, %hi(ImgFXInstances)
/* D433C 8013DC3C 8C426954 */  lw        $v0, %lo(ImgFXInstances)($v0)
/* D4340 8013DC40 90420000 */  lbu       $v0, 0x0($v0)
/* D4344 8013DC44 104000E3 */  beqz      $v0, .L8013DFD4
/* D4348 8013DC48 3C020018 */   lui      $v0, (0x180000 >> 16)
/* D434C 8013DC4C 00621024 */  and       $v0, $v1, $v0
/* D4350 8013DC50 504000E1 */  beql      $v0, $zero, .L8013DFD8
/* D4354 8013DC54 3C08070A */   lui      $t0, (0x70A0280 >> 16)
/* D4358 8013DC58 92830002 */  lbu       $v1, 0x2($s4)
/* D435C 8013DC5C 10600005 */  beqz      $v1, .L8013DC74
/* D4360 8013DC60 24020002 */   addiu    $v0, $zero, 0x2
/* D4364 8013DC64 10620003 */  beq       $v1, $v0, .L8013DC74
/* D4368 8013DC68 24020007 */   addiu    $v0, $zero, 0x7
/* D436C 8013DC6C 146200DA */  bne       $v1, $v0, .L8013DFD8
/* D4370 8013DC70 3C08070A */   lui      $t0, (0x70A0280 >> 16)
.L8013DC74:
/* D4374 8013DC74 3C08070A */  lui       $t0, (0x70A0280 >> 16)
/* D4378 8013DC78 35080280 */  ori       $t0, $t0, (0x70A0280 & 0xFFFF)
/* D437C 8013DC7C 3C09010A */  lui       $t1, (0x10A0280 >> 16)
/* D4380 8013DC80 35290280 */  ori       $t1, $t1, (0x10A0280 & 0xFFFF)
/* D4384 8013DC84 3C0B001A */  lui       $t3, (0x1A0280 >> 16)
/* D4388 8013DC88 356B0280 */  ori       $t3, $t3, (0x1A0280 & 0xFFFF)
/* D438C 8013DC8C 3C0AF510 */  lui       $t2, (0xF5100900 >> 16)
/* D4390 8013DC90 354A0900 */  ori       $t2, $t2, (0xF5100900 & 0xFFFF)
/* D4394 8013DC94 3C0C020F */  lui       $t4, (0x20FC000 >> 16)
/* D4398 8013DC98 358CC000 */  ori       $t4, $t4, (0x20FC000 & 0xFFFF)
/* D439C 8013DC9C 8E050000 */  lw        $a1, 0x0($s0)
/* D43A0 8013DCA0 3C048015 */  lui       $a0, %hi(ImgFXCurrentTexturePtr)
/* D43A4 8013DCA4 8C84EE10 */  lw        $a0, %lo(ImgFXCurrentTexturePtr)($a0)
/* D43A8 8013DCA8 00A0302D */  daddu     $a2, $a1, $zero
/* D43AC 8013DCAC 24A50008 */  addiu     $a1, $a1, 0x8
/* D43B0 8013DCB0 AE050000 */  sw        $a1, 0x0($s0)
/* D43B4 8013DCB4 94820008 */  lhu       $v0, 0x8($a0)
/* D43B8 8013DCB8 24A30008 */  addiu     $v1, $a1, 0x8
/* D43BC 8013DCBC AE030000 */  sw        $v1, 0x0($s0)
/* D43C0 8013DCC0 3C03FD48 */  lui       $v1, (0xFD480000 >> 16)
/* D43C4 8013DCC4 00021042 */  srl       $v0, $v0, 1
/* D43C8 8013DCC8 2442FFFF */  addiu     $v0, $v0, -0x1
/* D43CC 8013DCCC 30420FFF */  andi      $v0, $v0, 0xFFF
/* D43D0 8013DCD0 00431025 */  or        $v0, $v0, $v1
/* D43D4 8013DCD4 ACC20000 */  sw        $v0, 0x0($a2)
/* D43D8 8013DCD8 8C830000 */  lw        $v1, 0x0($a0)
/* D43DC 8013DCDC 24A20010 */  addiu     $v0, $a1, 0x10
/* D43E0 8013DCE0 AE020000 */  sw        $v0, 0x0($s0)
/* D43E4 8013DCE4 3C028015 */  lui       $v0, %hi(imgfx_vtxBuf)
/* D43E8 8013DCE8 8C426950 */  lw        $v0, %lo(imgfx_vtxBuf)($v0)
/* D43EC 8013DCEC 00133900 */  sll       $a3, $s3, 4
/* D43F0 8013DCF0 00E23821 */  addu      $a3, $a3, $v0
/* D43F4 8013DCF4 ACC30004 */  sw        $v1, 0x4($a2)
/* D43F8 8013DCF8 00113100 */  sll       $a2, $s1, 4
/* D43FC 8013DCFC 00C23021 */  addu      $a2, $a2, $v0
/* D4400 8013DD00 94E20008 */  lhu       $v0, 0x8($a3)
/* D4404 8013DD04 94C40008 */  lhu       $a0, 0x8($a2)
/* D4408 8013DD08 24A30018 */  addiu     $v1, $a1, 0x18
/* D440C 8013DD0C AE030000 */  sw        $v1, 0x0($s0)
/* D4410 8013DD10 3C03E600 */  lui       $v1, (0xE6000000 >> 16)
/* D4414 8013DD14 ACA30008 */  sw        $v1, 0x8($a1)
/* D4418 8013DD18 3C03F548 */  lui       $v1, (0xF5480000 >> 16)
/* D441C 8013DD1C ACA80004 */  sw        $t0, 0x4($a1)
/* D4420 8013DD20 ACA0000C */  sw        $zero, 0xC($a1)
/* D4424 8013DD24 00021400 */  sll       $v0, $v0, 16
/* D4428 8013DD28 00021543 */  sra       $v0, $v0, 21
/* D442C 8013DD2C 00042400 */  sll       $a0, $a0, 16
/* D4430 8013DD30 00042543 */  sra       $a0, $a0, 21
/* D4434 8013DD34 00441023 */  subu      $v0, $v0, $a0
/* D4438 8013DD38 00021043 */  sra       $v0, $v0, 1
/* D443C 8013DD3C 24420007 */  addiu     $v0, $v0, 0x7
/* D4440 8013DD40 000210C3 */  sra       $v0, $v0, 3
/* D4444 8013DD44 304201FF */  andi      $v0, $v0, 0x1FF
/* D4448 8013DD48 00021240 */  sll       $v0, $v0, 9
/* D444C 8013DD4C 00431025 */  or        $v0, $v0, $v1
/* D4450 8013DD50 ACA20000 */  sw        $v0, 0x0($a1)
/* D4454 8013DD54 24A20020 */  addiu     $v0, $a1, 0x20
/* D4458 8013DD58 94C30008 */  lhu       $v1, 0x8($a2)
/* D445C 8013DD5C 3C04F400 */  lui       $a0, (0xF4000000 >> 16)
/* D4460 8013DD60 AE020000 */  sw        $v0, 0x0($s0)
/* D4464 8013DD64 94C2000A */  lhu       $v0, 0xA($a2)
/* D4468 8013DD68 00031C00 */  sll       $v1, $v1, 16
/* D446C 8013DD6C 00031D43 */  sra       $v1, $v1, 21
/* D4470 8013DD70 2463FF00 */  addiu     $v1, $v1, -0x100
/* D4474 8013DD74 00031840 */  sll       $v1, $v1, 1
/* D4478 8013DD78 30630FFF */  andi      $v1, $v1, 0xFFF
/* D447C 8013DD7C 00031B00 */  sll       $v1, $v1, 12
/* D4480 8013DD80 00021400 */  sll       $v0, $v0, 16
/* D4484 8013DD84 00021543 */  sra       $v0, $v0, 21
/* D4488 8013DD88 2442FF00 */  addiu     $v0, $v0, -0x100
/* D448C 8013DD8C 00021080 */  sll       $v0, $v0, 2
/* D4490 8013DD90 30420FFF */  andi      $v0, $v0, 0xFFF
/* D4494 8013DD94 00441025 */  or        $v0, $v0, $a0
/* D4498 8013DD98 00621825 */  or        $v1, $v1, $v0
/* D449C 8013DD9C ACA30010 */  sw        $v1, 0x10($a1)
/* D44A0 8013DDA0 94E20008 */  lhu       $v0, 0x8($a3)
/* D44A4 8013DDA4 94E3000A */  lhu       $v1, 0xA($a3)
/* D44A8 8013DDA8 3C04E700 */  lui       $a0, (0xE7000000 >> 16)
/* D44AC 8013DDAC ACA40018 */  sw        $a0, 0x18($a1)
/* D44B0 8013DDB0 3C040700 */  lui       $a0, (0x7000000 >> 16)
/* D44B4 8013DDB4 ACA0001C */  sw        $zero, 0x1C($a1)
/* D44B8 8013DDB8 00021400 */  sll       $v0, $v0, 16
/* D44BC 8013DDBC 00021543 */  sra       $v0, $v0, 21
/* D44C0 8013DDC0 2442FEFF */  addiu     $v0, $v0, -0x101
/* D44C4 8013DDC4 00021040 */  sll       $v0, $v0, 1
/* D44C8 8013DDC8 30420FFF */  andi      $v0, $v0, 0xFFF
/* D44CC 8013DDCC 00021300 */  sll       $v0, $v0, 12
/* D44D0 8013DDD0 00031C00 */  sll       $v1, $v1, 16
/* D44D4 8013DDD4 00031D43 */  sra       $v1, $v1, 21
/* D44D8 8013DDD8 2463FEFF */  addiu     $v1, $v1, -0x101
/* D44DC 8013DDDC 00031880 */  sll       $v1, $v1, 2
/* D44E0 8013DDE0 30630FFF */  andi      $v1, $v1, 0xFFF
/* D44E4 8013DDE4 00641825 */  or        $v1, $v1, $a0
/* D44E8 8013DDE8 00431025 */  or        $v0, $v0, $v1
/* D44EC 8013DDEC ACA20014 */  sw        $v0, 0x14($a1)
/* D44F0 8013DDF0 94E20008 */  lhu       $v0, 0x8($a3)
/* D44F4 8013DDF4 94C40008 */  lhu       $a0, 0x8($a2)
/* D44F8 8013DDF8 24A30028 */  addiu     $v1, $a1, 0x28
/* D44FC 8013DDFC AE030000 */  sw        $v1, 0x0($s0)
/* D4500 8013DE00 ACA90024 */  sw        $t1, 0x24($a1)
/* D4504 8013DE04 00021400 */  sll       $v0, $v0, 16
/* D4508 8013DE08 00021543 */  sra       $v0, $v0, 21
/* D450C 8013DE0C 00042400 */  sll       $a0, $a0, 16
/* D4510 8013DE10 00042543 */  sra       $a0, $a0, 21
/* D4514 8013DE14 00441023 */  subu      $v0, $v0, $a0
/* D4518 8013DE18 00021043 */  sra       $v0, $v0, 1
/* D451C 8013DE1C 24420007 */  addiu     $v0, $v0, 0x7
/* D4520 8013DE20 000210C3 */  sra       $v0, $v0, 3
/* D4524 8013DE24 304201FF */  andi      $v0, $v0, 0x1FF
/* D4528 8013DE28 00021240 */  sll       $v0, $v0, 9
/* D452C 8013DE2C 005E1025 */  or        $v0, $v0, $fp
/* D4530 8013DE30 ACA20020 */  sw        $v0, 0x20($a1)
/* D4534 8013DE34 24A20030 */  addiu     $v0, $a1, 0x30
/* D4538 8013DE38 94C30008 */  lhu       $v1, 0x8($a2)
/* D453C 8013DE3C 3C040100 */  lui       $a0, (0x1000000 >> 16)
/* D4540 8013DE40 AE020000 */  sw        $v0, 0x0($s0)
/* D4544 8013DE44 94C2000A */  lhu       $v0, 0xA($a2)
/* D4548 8013DE48 000318C2 */  srl       $v1, $v1, 3
/* D454C 8013DE4C 30630FFC */  andi      $v1, $v1, 0xFFC
/* D4550 8013DE50 00031B00 */  sll       $v1, $v1, 12
/* D4554 8013DE54 000210C2 */  srl       $v0, $v0, 3
/* D4558 8013DE58 30420FFC */  andi      $v0, $v0, 0xFFC
/* D455C 8013DE5C 00571025 */  or        $v0, $v0, $s7
/* D4560 8013DE60 00621825 */  or        $v1, $v1, $v0
/* D4564 8013DE64 24A20038 */  addiu     $v0, $a1, 0x38
/* D4568 8013DE68 ACA30028 */  sw        $v1, 0x28($a1)
/* D456C 8013DE6C AE020000 */  sw        $v0, 0x0($s0)
/* D4570 8013DE70 94E30008 */  lhu       $v1, 0x8($a3)
/* D4574 8013DE74 24A20040 */  addiu     $v0, $a1, 0x40
/* D4578 8013DE78 AE020000 */  sw        $v0, 0x0($s0)
/* D457C 8013DE7C 94E2000A */  lhu       $v0, 0xA($a3)
/* D4580 8013DE80 00031C00 */  sll       $v1, $v1, 16
/* D4584 8013DE84 00031D43 */  sra       $v1, $v1, 21
/* D4588 8013DE88 2463FFFF */  addiu     $v1, $v1, -0x1
/* D458C 8013DE8C 00031880 */  sll       $v1, $v1, 2
/* D4590 8013DE90 30630FFF */  andi      $v1, $v1, 0xFFF
/* D4594 8013DE94 00031B00 */  sll       $v1, $v1, 12
/* D4598 8013DE98 00021400 */  sll       $v0, $v0, 16
/* D459C 8013DE9C 00021543 */  sra       $v0, $v0, 21
/* D45A0 8013DEA0 2442FFFF */  addiu     $v0, $v0, -0x1
/* D45A4 8013DEA4 00021080 */  sll       $v0, $v0, 2
/* D45A8 8013DEA8 30420FFF */  andi      $v0, $v0, 0xFFF
/* D45AC 8013DEAC 00441025 */  or        $v0, $v0, $a0
/* D45B0 8013DEB0 00621825 */  or        $v1, $v1, $v0
/* D45B4 8013DEB4 ACA3002C */  sw        $v1, 0x2C($a1)
/* D45B8 8013DEB8 94E20008 */  lhu       $v0, 0x8($a3)
/* D45BC 8013DEBC 94C40008 */  lhu       $a0, 0x8($a2)
/* D45C0 8013DEC0 24A30048 */  addiu     $v1, $a1, 0x48
/* D45C4 8013DEC4 AE030000 */  sw        $v1, 0x0($s0)
/* D45C8 8013DEC8 3C030200 */  lui       $v1, (0x2000000 >> 16)
/* D45CC 8013DECC ACAB0034 */  sw        $t3, 0x34($a1)
/* D45D0 8013DED0 ACAA0038 */  sw        $t2, 0x38($a1)
/* D45D4 8013DED4 ACA3003C */  sw        $v1, 0x3C($a1)
/* D45D8 8013DED8 ACB70040 */  sw        $s7, 0x40($a1)
/* D45DC 8013DEDC ACAC0044 */  sw        $t4, 0x44($a1)
/* D45E0 8013DEE0 00021400 */  sll       $v0, $v0, 16
/* D45E4 8013DEE4 00021543 */  sra       $v0, $v0, 21
/* D45E8 8013DEE8 00042400 */  sll       $a0, $a0, 16
/* D45EC 8013DEEC 00042543 */  sra       $a0, $a0, 21
/* D45F0 8013DEF0 00441023 */  subu      $v0, $v0, $a0
/* D45F4 8013DEF4 00021043 */  sra       $v0, $v0, 1
/* D45F8 8013DEF8 24420007 */  addiu     $v0, $v0, 0x7
/* D45FC 8013DEFC 000210C3 */  sra       $v0, $v0, 3
/* D4600 8013DF00 304201FF */  andi      $v0, $v0, 0x1FF
/* D4604 8013DF04 00021240 */  sll       $v0, $v0, 9
/* D4608 8013DF08 005E1025 */  or        $v0, $v0, $fp
/* D460C 8013DF0C ACA20030 */  sw        $v0, 0x30($a1)
/* D4610 8013DF10 92830002 */  lbu       $v1, 0x2($s4)
/* D4614 8013DF14 24020002 */  addiu     $v0, $zero, 0x2
/* D4618 8013DF18 10620009 */  beq       $v1, $v0, .L8013DF40
/* D461C 8013DF1C 240D00FF */   addiu    $t5, $zero, 0xFF
/* D4620 8013DF20 28620003 */  slti      $v0, $v1, 0x3
/* D4624 8013DF24 1440000A */  bnez      $v0, .L8013DF50
/* D4628 8013DF28 00111100 */   sll      $v0, $s1, 4
/* D462C 8013DF2C 24020007 */  addiu     $v0, $zero, 0x7
/* D4630 8013DF30 10620006 */  beq       $v1, $v0, .L8013DF4C
/* D4634 8013DF34 00111100 */   sll      $v0, $s1, 4
/* D4638 8013DF38 0804F7D4 */  j         .L8013DF50
/* D463C 8013DF3C 00000000 */   nop
.L8013DF40:
/* D4640 8013DF40 8E8D0038 */  lw        $t5, 0x38($s4)
/* D4644 8013DF44 0804F7D4 */  j         .L8013DF50
/* D4648 8013DF48 00111100 */   sll      $v0, $s1, 4
.L8013DF4C:
/* D464C 8013DF4C 240DFFFF */  addiu     $t5, $zero, -0x1
.L8013DF50:
/* D4650 8013DF50 3C048015 */  lui       $a0, %hi(imgfx_vtxBuf)
/* D4654 8013DF54 8C846950 */  lw        $a0, %lo(imgfx_vtxBuf)($a0)
/* D4658 8013DF58 00131900 */  sll       $v1, $s3, 4
/* D465C 8013DF5C 00441021 */  addu      $v0, $v0, $a0
/* D4660 8013DF60 00641821 */  addu      $v1, $v1, $a0
/* D4664 8013DF64 94450008 */  lhu       $a1, 0x8($v0)
/* D4668 8013DF68 9446000A */  lhu       $a2, 0xA($v0)
/* D466C 8013DF6C 94670008 */  lhu       $a3, 0x8($v1)
/* D4670 8013DF70 9462000A */  lhu       $v0, 0xA($v1)
/* D4674 8013DF74 8FA40054 */  lw        $a0, 0x54($sp)
/* D4678 8013DF78 AFAD0014 */  sw        $t5, 0x14($sp)
/* D467C 8013DF7C 00021400 */  sll       $v0, $v0, 16
/* D4680 8013DF80 00021543 */  sra       $v0, $v0, 21
/* D4684 8013DF84 2442FF00 */  addiu     $v0, $v0, -0x100
/* D4688 8013DF88 00052C00 */  sll       $a1, $a1, 16
/* D468C 8013DF8C 00052D43 */  sra       $a1, $a1, 21
/* D4690 8013DF90 00063400 */  sll       $a2, $a2, 16
/* D4694 8013DF94 00063543 */  sra       $a2, $a2, 21
/* D4698 8013DF98 00073C00 */  sll       $a3, $a3, 16
/* D469C 8013DF9C 00073D43 */  sra       $a3, $a3, 21
/* D46A0 8013DFA0 24A5FF00 */  addiu     $a1, $a1, -0x100
/* D46A4 8013DFA4 24C6FF00 */  addiu     $a2, $a2, -0x100
/* D46A8 8013DFA8 AFA20010 */  sw        $v0, 0x10($sp)
/* D46AC 8013DFAC 8E820078 */  lw        $v0, 0x78($s4)
/* D46B0 8013DFB0 24E7FF00 */  addiu     $a3, $a3, -0x100
/* D46B4 8013DFB4 AFAE0020 */  sw        $t6, 0x20($sp)
/* D46B8 8013DFB8 AFAF0024 */  sw        $t7, 0x24($sp)
/* D46BC 8013DFBC 0C052071 */  jal       create_shading_palette
/* D46C0 8013DFC0 AFA20018 */   sw       $v0, 0x18($sp)
/* D46C4 8013DFC4 8FAE0020 */  lw        $t6, 0x20($sp)
/* D46C8 8013DFC8 8FAF0024 */  lw        $t7, 0x24($sp)
/* D46CC 8013DFCC 0804F87B */  j         .L8013E1EC
/* D46D0 8013DFD0 3C020100 */   lui      $v0, (0x1001002 >> 16)
.L8013DFD4:
/* D46D4 8013DFD4 3C08070A */  lui       $t0, (0x70A0280 >> 16)
.L8013DFD8:
/* D46D8 8013DFD8 35080280 */  ori       $t0, $t0, (0x70A0280 & 0xFFFF)
/* D46DC 8013DFDC 3C09000A */  lui       $t1, (0xA0280 >> 16)
/* D46E0 8013DFE0 35290280 */  ori       $t1, $t1, (0xA0280 & 0xFFFF)
/* D46E4 8013DFE4 8E050000 */  lw        $a1, 0x0($s0)
/* D46E8 8013DFE8 3C048015 */  lui       $a0, %hi(ImgFXCurrentTexturePtr)
/* D46EC 8013DFEC 8C84EE10 */  lw        $a0, %lo(ImgFXCurrentTexturePtr)($a0)
/* D46F0 8013DFF0 00A0302D */  daddu     $a2, $a1, $zero
/* D46F4 8013DFF4 24A50008 */  addiu     $a1, $a1, 0x8
/* D46F8 8013DFF8 AE050000 */  sw        $a1, 0x0($s0)
/* D46FC 8013DFFC 94820008 */  lhu       $v0, 0x8($a0)
/* D4700 8013E000 24A30008 */  addiu     $v1, $a1, 0x8
/* D4704 8013E004 AE030000 */  sw        $v1, 0x0($s0)
/* D4708 8013E008 3C03FD48 */  lui       $v1, (0xFD480000 >> 16)
/* D470C 8013E00C 00021042 */  srl       $v0, $v0, 1
/* D4710 8013E010 2442FFFF */  addiu     $v0, $v0, -0x1
/* D4714 8013E014 30420FFF */  andi      $v0, $v0, 0xFFF
/* D4718 8013E018 00431025 */  or        $v0, $v0, $v1
/* D471C 8013E01C ACC20000 */  sw        $v0, 0x0($a2)
/* D4720 8013E020 8C830000 */  lw        $v1, 0x0($a0)
/* D4724 8013E024 24A20010 */  addiu     $v0, $a1, 0x10
/* D4728 8013E028 AE020000 */  sw        $v0, 0x0($s0)
/* D472C 8013E02C 3C028015 */  lui       $v0, %hi(imgfx_vtxBuf)
/* D4730 8013E030 8C426950 */  lw        $v0, %lo(imgfx_vtxBuf)($v0)
/* D4734 8013E034 00133900 */  sll       $a3, $s3, 4
/* D4738 8013E038 00E23821 */  addu      $a3, $a3, $v0
/* D473C 8013E03C ACC30004 */  sw        $v1, 0x4($a2)
/* D4740 8013E040 00113100 */  sll       $a2, $s1, 4
/* D4744 8013E044 00C23021 */  addu      $a2, $a2, $v0
/* D4748 8013E048 94E20008 */  lhu       $v0, 0x8($a3)
/* D474C 8013E04C 94C40008 */  lhu       $a0, 0x8($a2)
/* D4750 8013E050 24A30018 */  addiu     $v1, $a1, 0x18
/* D4754 8013E054 AE030000 */  sw        $v1, 0x0($s0)
/* D4758 8013E058 3C03E600 */  lui       $v1, (0xE6000000 >> 16)
/* D475C 8013E05C ACA30008 */  sw        $v1, 0x8($a1)
/* D4760 8013E060 3C03F548 */  lui       $v1, (0xF5480000 >> 16)
/* D4764 8013E064 ACA80004 */  sw        $t0, 0x4($a1)
/* D4768 8013E068 ACA0000C */  sw        $zero, 0xC($a1)
/* D476C 8013E06C 00021400 */  sll       $v0, $v0, 16
/* D4770 8013E070 00021543 */  sra       $v0, $v0, 21
/* D4774 8013E074 00042400 */  sll       $a0, $a0, 16
/* D4778 8013E078 00042543 */  sra       $a0, $a0, 21
/* D477C 8013E07C 00441023 */  subu      $v0, $v0, $a0
/* D4780 8013E080 00021043 */  sra       $v0, $v0, 1
/* D4784 8013E084 24420007 */  addiu     $v0, $v0, 0x7
/* D4788 8013E088 000210C3 */  sra       $v0, $v0, 3
/* D478C 8013E08C 304201FF */  andi      $v0, $v0, 0x1FF
/* D4790 8013E090 00021240 */  sll       $v0, $v0, 9
/* D4794 8013E094 00431025 */  or        $v0, $v0, $v1
/* D4798 8013E098 ACA20000 */  sw        $v0, 0x0($a1)
/* D479C 8013E09C 24A20020 */  addiu     $v0, $a1, 0x20
/* D47A0 8013E0A0 94C30008 */  lhu       $v1, 0x8($a2)
/* D47A4 8013E0A4 3C04F400 */  lui       $a0, (0xF4000000 >> 16)
/* D47A8 8013E0A8 AE020000 */  sw        $v0, 0x0($s0)
/* D47AC 8013E0AC 94C2000A */  lhu       $v0, 0xA($a2)
/* D47B0 8013E0B0 00031C00 */  sll       $v1, $v1, 16
/* D47B4 8013E0B4 00031D43 */  sra       $v1, $v1, 21
/* D47B8 8013E0B8 2463FF00 */  addiu     $v1, $v1, -0x100
/* D47BC 8013E0BC 00031840 */  sll       $v1, $v1, 1
/* D47C0 8013E0C0 30630FFF */  andi      $v1, $v1, 0xFFF
/* D47C4 8013E0C4 00031B00 */  sll       $v1, $v1, 12
/* D47C8 8013E0C8 00021400 */  sll       $v0, $v0, 16
/* D47CC 8013E0CC 00021543 */  sra       $v0, $v0, 21
/* D47D0 8013E0D0 2442FF00 */  addiu     $v0, $v0, -0x100
/* D47D4 8013E0D4 00021080 */  sll       $v0, $v0, 2
/* D47D8 8013E0D8 30420FFF */  andi      $v0, $v0, 0xFFF
/* D47DC 8013E0DC 00441025 */  or        $v0, $v0, $a0
/* D47E0 8013E0E0 00621825 */  or        $v1, $v1, $v0
/* D47E4 8013E0E4 ACA30010 */  sw        $v1, 0x10($a1)
/* D47E8 8013E0E8 94E20008 */  lhu       $v0, 0x8($a3)
/* D47EC 8013E0EC 94E3000A */  lhu       $v1, 0xA($a3)
/* D47F0 8013E0F0 3C04E700 */  lui       $a0, (0xE7000000 >> 16)
/* D47F4 8013E0F4 ACA40018 */  sw        $a0, 0x18($a1)
/* D47F8 8013E0F8 3C040700 */  lui       $a0, (0x7000000 >> 16)
/* D47FC 8013E0FC ACA0001C */  sw        $zero, 0x1C($a1)
/* D4800 8013E100 00021400 */  sll       $v0, $v0, 16
/* D4804 8013E104 00021543 */  sra       $v0, $v0, 21
/* D4808 8013E108 2442FEFF */  addiu     $v0, $v0, -0x101
/* D480C 8013E10C 00021040 */  sll       $v0, $v0, 1
/* D4810 8013E110 30420FFF */  andi      $v0, $v0, 0xFFF
/* D4814 8013E114 00021300 */  sll       $v0, $v0, 12
/* D4818 8013E118 00031C00 */  sll       $v1, $v1, 16
/* D481C 8013E11C 00031D43 */  sra       $v1, $v1, 21
/* D4820 8013E120 2463FEFF */  addiu     $v1, $v1, -0x101
/* D4824 8013E124 00031880 */  sll       $v1, $v1, 2
/* D4828 8013E128 30630FFF */  andi      $v1, $v1, 0xFFF
/* D482C 8013E12C 00641825 */  or        $v1, $v1, $a0
/* D4830 8013E130 00431025 */  or        $v0, $v0, $v1
/* D4834 8013E134 ACA20014 */  sw        $v0, 0x14($a1)
/* D4838 8013E138 94E20008 */  lhu       $v0, 0x8($a3)
/* D483C 8013E13C 94C40008 */  lhu       $a0, 0x8($a2)
/* D4840 8013E140 24A30028 */  addiu     $v1, $a1, 0x28
/* D4844 8013E144 AE030000 */  sw        $v1, 0x0($s0)
/* D4848 8013E148 ACA90024 */  sw        $t1, 0x24($a1)
/* D484C 8013E14C 00021400 */  sll       $v0, $v0, 16
/* D4850 8013E150 00021543 */  sra       $v0, $v0, 21
/* D4854 8013E154 00042400 */  sll       $a0, $a0, 16
/* D4858 8013E158 00042543 */  sra       $a0, $a0, 21
/* D485C 8013E15C 00441023 */  subu      $v0, $v0, $a0
/* D4860 8013E160 00021043 */  sra       $v0, $v0, 1
/* D4864 8013E164 24420007 */  addiu     $v0, $v0, 0x7
/* D4868 8013E168 000210C3 */  sra       $v0, $v0, 3
/* D486C 8013E16C 304201FF */  andi      $v0, $v0, 0x1FF
/* D4870 8013E170 00021240 */  sll       $v0, $v0, 9
/* D4874 8013E174 005E1025 */  or        $v0, $v0, $fp
/* D4878 8013E178 ACA20020 */  sw        $v0, 0x20($a1)
/* D487C 8013E17C 94C30008 */  lhu       $v1, 0x8($a2)
/* D4880 8013E180 24A20030 */  addiu     $v0, $a1, 0x30
/* D4884 8013E184 AE020000 */  sw        $v0, 0x0($s0)
/* D4888 8013E188 94C2000A */  lhu       $v0, 0xA($a2)
/* D488C 8013E18C 000318C2 */  srl       $v1, $v1, 3
/* D4890 8013E190 30630FFC */  andi      $v1, $v1, 0xFFC
/* D4894 8013E194 00031B00 */  sll       $v1, $v1, 12
/* D4898 8013E198 000210C2 */  srl       $v0, $v0, 3
/* D489C 8013E19C 30420FFC */  andi      $v0, $v0, 0xFFC
/* D48A0 8013E1A0 00571025 */  or        $v0, $v0, $s7
/* D48A4 8013E1A4 00621825 */  or        $v1, $v1, $v0
/* D48A8 8013E1A8 ACA30028 */  sw        $v1, 0x28($a1)
/* D48AC 8013E1AC 94E30008 */  lhu       $v1, 0x8($a3)
/* D48B0 8013E1B0 94E2000A */  lhu       $v0, 0xA($a3)
/* D48B4 8013E1B4 00031C00 */  sll       $v1, $v1, 16
/* D48B8 8013E1B8 00031D43 */  sra       $v1, $v1, 21
/* D48BC 8013E1BC 2463FFFF */  addiu     $v1, $v1, -0x1
/* D48C0 8013E1C0 00031880 */  sll       $v1, $v1, 2
/* D48C4 8013E1C4 30630FFF */  andi      $v1, $v1, 0xFFF
/* D48C8 8013E1C8 00031B00 */  sll       $v1, $v1, 12
/* D48CC 8013E1CC 00021400 */  sll       $v0, $v0, 16
/* D48D0 8013E1D0 00021543 */  sra       $v0, $v0, 21
/* D48D4 8013E1D4 2442FFFF */  addiu     $v0, $v0, -0x1
/* D48D8 8013E1D8 00021080 */  sll       $v0, $v0, 2
/* D48DC 8013E1DC 30420FFF */  andi      $v0, $v0, 0xFFF
/* D48E0 8013E1E0 00621825 */  or        $v1, $v1, $v0
/* D48E4 8013E1E4 ACA3002C */  sw        $v1, 0x2C($a1)
.L8013E1E8:
/* D48E8 8013E1E8 3C020100 */  lui       $v0, (0x1001002 >> 16)
.L8013E1EC:
/* D48EC 8013E1EC 34421002 */  ori       $v0, $v0, (0x1001002 & 0xFFFF)
/* D48F0 8013E1F0 3C060100 */  lui       $a2, (0x1001004 >> 16)
/* D48F4 8013E1F4 34C61004 */  ori       $a2, $a2, (0x1001004 & 0xFFFF)
/* D48F8 8013E1F8 3C070100 */  lui       $a3, (0x1001006 >> 16)
/* D48FC 8013E1FC 34E71006 */  ori       $a3, $a3, (0x1001006 & 0xFFFF)
/* D4900 8013E200 3C080100 */  lui       $t0, (0x1001008 >> 16)
/* D4904 8013E204 35081008 */  ori       $t0, $t0, (0x1001008 & 0xFFFF)
/* D4908 8013E208 3C0A0600 */  lui       $t2, (0x6000402 >> 16)
/* D490C 8013E20C 354A0402 */  ori       $t2, $t2, (0x6000402 & 0xFFFF)
/* D4910 8013E210 8E030000 */  lw        $v1, 0x0($s0)
/* D4914 8013E214 3C090002 */  lui       $t1, (0x20406 >> 16)
/* D4918 8013E218 0060282D */  daddu     $a1, $v1, $zero
/* D491C 8013E21C 24630008 */  addiu     $v1, $v1, 0x8
/* D4920 8013E220 AE030000 */  sw        $v1, 0x0($s0)
/* D4924 8013E224 3C048015 */  lui       $a0, %hi(imgfx_vtxBuf)
/* D4928 8013E228 8C846950 */  lw        $a0, %lo(imgfx_vtxBuf)($a0)
/* D492C 8013E22C 35290406 */  ori       $t1, $t1, (0x20406 & 0xFFFF)
/* D4930 8013E230 ACA20000 */  sw        $v0, 0x0($a1)
/* D4934 8013E234 00111100 */  sll       $v0, $s1, 4
/* D4938 8013E238 00821021 */  addu      $v0, $a0, $v0
/* D493C 8013E23C ACA20004 */  sw        $v0, 0x4($a1)
/* D4940 8013E240 24620008 */  addiu     $v0, $v1, 0x8
/* D4944 8013E244 AE020000 */  sw        $v0, 0x0($s0)
/* D4948 8013E248 000F1100 */  sll       $v0, $t7, 4
/* D494C 8013E24C 00821021 */  addu      $v0, $a0, $v0
/* D4950 8013E250 AC620004 */  sw        $v0, 0x4($v1)
/* D4954 8013E254 24620010 */  addiu     $v0, $v1, 0x10
/* D4958 8013E258 AC660000 */  sw        $a2, 0x0($v1)
/* D495C 8013E25C AE020000 */  sw        $v0, 0x0($s0)
/* D4960 8013E260 00161100 */  sll       $v0, $s6, 4
/* D4964 8013E264 00821021 */  addu      $v0, $a0, $v0
/* D4968 8013E268 AC62000C */  sw        $v0, 0xC($v1)
/* D496C 8013E26C 24620018 */  addiu     $v0, $v1, 0x18
/* D4970 8013E270 AC670008 */  sw        $a3, 0x8($v1)
/* D4974 8013E274 AE020000 */  sw        $v0, 0x0($s0)
/* D4978 8013E278 00131100 */  sll       $v0, $s3, 4
/* D497C 8013E27C 00822021 */  addu      $a0, $a0, $v0
/* D4980 8013E280 24620020 */  addiu     $v0, $v1, 0x20
/* D4984 8013E284 AC680010 */  sw        $t0, 0x10($v1)
/* D4988 8013E288 AC640014 */  sw        $a0, 0x14($v1)
/* D498C 8013E28C AE020000 */  sw        $v0, 0x0($s0)
/* D4990 8013E290 AC6A0018 */  sw        $t2, 0x18($v1)
/* D4994 8013E294 AC69001C */  sw        $t1, 0x1C($v1)
/* D4998 8013E298 92830003 */  lbu       $v1, 0x3($s4)
/* D499C 8013E29C 26520001 */  addiu     $s2, $s2, 0x1
/* D49A0 8013E2A0 0243102A */  slt       $v0, $s2, $v1
/* D49A4 8013E2A4 5440FE4F */  bnel      $v0, $zero, .L8013DBE4
/* D49A8 8013E2A8 24630001 */   addiu    $v1, $v1, 0x1
.L8013E2AC:
/* D49AC 8013E2AC 92820004 */  lbu       $v0, 0x4($s4)
/* D49B0 8013E2B0 26B50001 */  addiu     $s5, $s5, 0x1
/* D49B4 8013E2B4 02A2102A */  slt       $v0, $s5, $v0
/* D49B8 8013E2B8 1440FE46 */  bnez      $v0, .L8013DBD4
/* D49BC 8013E2BC 00000000 */   nop
.L8013E2C0:
/* D49C0 8013E2C0 8FBF004C */  lw        $ra, 0x4C($sp)
/* D49C4 8013E2C4 8FBE0048 */  lw        $fp, 0x48($sp)
/* D49C8 8013E2C8 8FB70044 */  lw        $s7, 0x44($sp)
/* D49CC 8013E2CC 8FB60040 */  lw        $s6, 0x40($sp)
/* D49D0 8013E2D0 8FB5003C */  lw        $s5, 0x3C($sp)
/* D49D4 8013E2D4 8FB40038 */  lw        $s4, 0x38($sp)
/* D49D8 8013E2D8 8FB30034 */  lw        $s3, 0x34($sp)
/* D49DC 8013E2DC 8FB20030 */  lw        $s2, 0x30($sp)
/* D49E0 8013E2E0 8FB1002C */  lw        $s1, 0x2C($sp)
/* D49E4 8013E2E4 8FB00028 */  lw        $s0, 0x28($sp)
/* D49E8 8013E2E8 03E00008 */  jr        $ra
/* D49EC 8013E2EC 27BD0050 */   addiu    $sp, $sp, 0x50

### DECOMPILED C INSTRUCTIONS:

void imgfx_appendGfx_mesh_grid(ImgFXState* state, Matrix4f mtx) {
    s32 i, j;
    s32 firstVtxIdx;

    if (!(state->flags & IMGFX_FLAG_SKIP_TEX_SETUP)) {
        gDPSetTextureLUT(gMainGfxPos++, G_TT_RGBA16);
        gDPLoadTLUT_pal16(gMainGfxPos++, 0, ImgFXCurrentTexturePtr->tex.palette);
    }

    firstVtxIdx = state->firstVtxIdx;
    for (i = 0; i < state->subdivY; i++) {
        for (j = 0; j < state->subdivX; j++) {
            s32 ulIdx = firstVtxIdx + i * (state->subdivX + 1) + j;
            s32 urIdx = firstVtxIdx + i * (state->subdivX + 1) + j + 1;
            s32 llIdx = firstVtxIdx + (i + 1) * (state->subdivX + 1) + j;
            s32 lrIdx = firstVtxIdx + (i + 1) * (state->subdivX + 1) + j + 1;
            if (!(state->flags & IMGFX_FLAG_SKIP_TEX_SETUP)) {
                if ((gSpriteShadingProfile->flags & 1) &&
                    (*ImgFXInstances)[0].arrayIdx != 0 &&
                    (state->flags & (IMGFX_FLAG_100000 | IMGFX_FLAG_80000)) &&
                    (state->renderType == IMGFX_RENDER_DEFAULT
                    || state->renderType == IMGFX_RENDER_MULTIPLY_ALPHA
                    || state->renderType == IMGFX_RENDER_MULTIPLY_SHADE_ALPHA)) {
                    s32 alpha = 255;
                    gDPScrollMultiTile2_4b(gMainGfxPos++,
                        ImgFXCurrentTexturePtr->tex.raster, G_IM_FMT_CI,
                        ImgFXCurrentTexturePtr->tex.width, ImgFXCurrentTexturePtr->tex.height, // img size
                        (imgfx_vtxBuf[ulIdx].v.tc[0] >> 5) - 0x100, (imgfx_vtxBuf[ulIdx].v.tc[1] >> 5) - 0x100, // top left
                        (imgfx_vtxBuf[lrIdx].v.tc[0] >> 5) - 0x100 - 1, (imgfx_vtxBuf[lrIdx].v.tc[1] >> 5) - 0x100 - 1, // bottom right
                        0, // palette
                        G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, // clamp wrap mirror
                        8, 8, // mask
                        G_TX_NOLOD, G_TX_NOLOD, // shift,
                        0x100, 0x100); // scroll
                    gDPSetTile(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0x0100, 2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
                    gDPSetTileSize(gMainGfxPos++, 2, 0, 0, 63 << 2, 0);
                    switch (state->renderType) {
                        case IMGFX_RENDER_DEFAULT:
                            alpha = 255;
                            break;
                        case IMGFX_RENDER_MULTIPLY_ALPHA:
                            alpha = state->ints.color.a;
                            break;
                        case IMGFX_RENDER_MULTIPLY_SHADE_ALPHA:
                            alpha = -1;
                            break;

                    }
                    create_shading_palette(mtx,
                                           (imgfx_vtxBuf[ulIdx].v.tc[0] >> 5) - 0x100, (imgfx_vtxBuf[ulIdx].v.tc[1] >> 5) - 0x100,
                                           (imgfx_vtxBuf[lrIdx].v.tc[0] >> 5) - 0x100, (imgfx_vtxBuf[lrIdx].v.tc[1] >> 5) - 0x100,
                                           alpha, state->otherModeL);
                } else {
                    gDPScrollTextureTile_4b(gMainGfxPos++,
                        ImgFXCurrentTexturePtr->tex.raster, G_IM_FMT_CI,
                        ImgFXCurrentTexturePtr->tex.width, ImgFXCurrentTexturePtr->tex.height, // img size
                        (imgfx_vtxBuf[ulIdx].v.tc[0] >> 5) - 0x100, (imgfx_vtxBuf[ulIdx].v.tc[1] >> 5) - 0x100, // top left
                        (imgfx_vtxBuf[lrIdx].v.tc[0] >> 5) - 0x100 - 1, (imgfx_vtxBuf[lrIdx].v.tc[1] >> 5) - 0x100 - 1, // bottom right
                        0, // palette
                        G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, // clamp wrap mirror
                        8, 8, // mask
                        G_TX_NOLOD, G_TX_NOLOD, // shift,
                        0x100, 0x100); // scroll
                }
            }

            gSPVertex(gMainGfxPos++, &imgfx_vtxBuf[ulIdx], 1, 0);
            gSPVertex(gMainGfxPos++, &imgfx_vtxBuf[urIdx], 1, 1);
            gSPVertex(gMainGfxPos++, &imgfx_vtxBuf[llIdx], 1, 2);
            gSPVertex(gMainGfxPos++, &imgfx_vtxBuf[lrIdx], 1, 3);
            gSP2Triangles(gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
        }
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

dlabel func_802AA688_7B2028
/* 41F418 802AA688 27BDFFD0 */  addiu     $sp, $sp, -0x30
/* 41F41C 802AA68C AFB40020 */  sw        $s4, 0x20($sp)
/* 41F420 802AA690 3C14800E */  lui       $s4, %hi(gBattleStatus)
D_802AA694_7B2034:
/* 41F424 802AA694 2694C070 */  addiu     $s4, $s4, %lo(gBattleStatus)
/* 41F428 802AA698 AFBF0028 */  sw        $ra, 0x28($sp)
/* 41F42C 802AA69C AFB50024 */  sw        $s5, 0x24($sp)
/* 41F430 802AA6A0 AFB3001C */  sw        $s3, 0x1C($sp)
/* 41F434 802AA6A4 AFB20018 */  sw        $s2, 0x18($sp)
/* 41F438 802AA6A8 AFB10014 */  sw        $s1, 0x14($sp)
/* 41F43C 802AA6AC AFB00010 */  sw        $s0, 0x10($sp)
/* 41F440 802AA6B0 8E820000 */  lw        $v0, 0x0($s4)
/* 41F444 802AA6B4 3C030008 */  lui       $v1, (0x80000 >> 16)
/* 41F448 802AA6B8 00431024 */  and       $v0, $v0, $v1
D_802AA6BC_7B205C:
/* 41F44C 802AA6BC 14400004 */  bnez      $v0, .L802AA6D0_7B2070
/* 41F450 802AA6C0 3C02F7FF */   lui      $v0, (0xF7FFFFFF >> 16)
/* 41F454 802AA6C4 8E9200D8 */  lw        $s2, 0xD8($s4)
/* 41F458 802AA6C8 080AA9B6 */  j         .L802AA6D8_7B2078
/* 41F45C 802AA6CC 3442FFFF */   ori      $v0, $v0, (0xF7FFFFFF & 0xFFFF)
.L802AA6D0_7B2070:
/* 41F460 802AA6D0 8E9200DC */  lw        $s2, 0xDC($s4)
/* 41F464 802AA6D4 3442FFFF */  ori       $v0, $v0, (0xF7FFFFFF & 0xFFFF)
.L802AA6D8_7B2078:
/* 41F468 802AA6D8 8253040C */  lb        $s3, 0x40C($s2)
/* 41F46C 802AA6DC 8E430000 */  lw        $v1, 0x0($s2)
D_802AA6E0_7B2080:
/* 41F470 802AA6E0 82500425 */  lb        $s0, 0x425($s2)
/* 41F474 802AA6E4 00621824 */  and       $v1, $v1, $v0
D_802AA6E8_7B2088:
/* 41F478 802AA6E8 AE430000 */  sw        $v1, 0x0($s2)
/* 41F47C 802AA6EC 3C03800E */  lui       $v1, %hi(gBattleSubState)
/* 41F480 802AA6F0 8C63C4DC */  lw        $v1, %lo(gBattleSubState)($v1)
/* 41F484 802AA6F4 24020001 */  addiu     $v0, $zero, 0x1
/* 41F488 802AA6F8 10620085 */  beq       $v1, $v0, .L802AA910_7B22B0
/* 41F48C 802AA6FC 2655040D */   addiu    $s5, $s2, 0x40D
D_802AA700_7B20A0:
/* 41F490 802AA700 28620002 */  slti      $v0, $v1, 0x2
/* 41F494 802AA704 50400005 */  beql      $v0, $zero, .L802AA71C_7B20BC
/* 41F498 802AA708 24020002 */   addiu    $v0, $zero, 0x2
/* 41F49C 802AA70C 10600009 */  beqz      $v1, .L802AA734_7B20D4
D_802AA710_7B20B0:
/* 41F4A0 802AA710 24040015 */   addiu    $a0, $zero, 0x15
/* 41F4A4 802AA714 080AAB2D */  j         .L802AACB4_7B2654
/* 41F4A8 802AA718 00000000 */   nop
.L802AA71C_7B20BC:
/* 41F4AC 802AA71C 106200D7 */  beq       $v1, $v0, .L802AAA7C_7B241C
/* 41F4B0 802AA720 2402000A */   addiu    $v0, $zero, 0xA
/* 41F4B4 802AA724 1062011B */  beq       $v1, $v0, .L802AAB94_7B2534
D_802AA728_7B20C8:
/* 41F4B8 802AA728 00000000 */   nop
/* 41F4BC 802AA72C 080AAB2D */  j         .L802AACB4_7B2654
/* 41F4C0 802AA730 00000000 */   nop
.L802AA734_7B20D4:
/* 41F4C4 802AA734 240200FF */  addiu     $v0, $zero, 0xFF
D_802AA738_7B20D8:
/* 41F4C8 802AA738 3C01802B */  lui       $at, %hi(D_802ACC64)
/* 41F4CC 802AA73C AC22CC64 */  sw        $v0, %lo(D_802ACC64)($at)
/* 41F4D0 802AA740 2402FF9C */  addiu     $v0, $zero, -0x64
/* 41F4D4 802AA744 3C10800E */  lui       $s0, %hi(gBattleStatus)
/* 41F4D8 802AA748 2610C070 */  addiu     $s0, $s0, %lo(gBattleStatus)
/* 41F4DC 802AA74C 3C01802B */  lui       $at, %hi(D_802ACC68)
D_802AA750_7B20F0:
/* 41F4E0 802AA750 AC22CC68 */  sw        $v0, %lo(D_802ACC68)($at)
/* 41F4E4 802AA754 8E020000 */  lw        $v0, 0x0($s0)
/* 41F4E8 802AA758 2403FFFD */  addiu     $v1, $zero, -0x3
/* 41F4EC 802AA75C 00431024 */  and       $v0, $v0, $v1
D_802AA760_7B2100:
/* 41F4F0 802AA760 0C03A752 */  jal       is_ability_active
/* 41F4F4 802AA764 AE020000 */   sw       $v0, 0x0($s0)
/* 41F4F8 802AA768 10400005 */  beqz      $v0, .L802AA780_7B2120
/* 41F4FC 802AA76C 3C030008 */   lui      $v1, (0x80000 >> 16)
/* 41F500 802AA770 8E020000 */  lw        $v0, 0x0($s0)
/* 41F504 802AA774 00431024 */  and       $v0, $v0, $v1
D_802AA778_7B2118:
/* 41F508 802AA778 1040000D */  beqz      $v0, .L802AA7B0_7B2150
/* 41F50C 802AA77C 00000000 */   nop
.L802AA780_7B2120:
/* 41F510 802AA780 8683017C */  lh        $v1, 0x17C($s4)
/* 41F514 802AA784 1060000A */  beqz      $v1, .L802AA7B0_7B2150
D_802AA788_7B2128:
/* 41F518 802AA788 00031080 */   sll      $v0, $v1, 2
/* 41F51C 802AA78C 00431021 */  addu      $v0, $v0, $v1
/* 41F520 802AA790 00021080 */  sll       $v0, $v0, 2
/* 41F524 802AA794 3C048009 */  lui       $a0, %hi(D_8008F073)
/* 41F528 802AA798 00822021 */  addu      $a0, $a0, $v0
/* 41F52C 802AA79C 8084F073 */  lb        $a0, %lo(D_8008F073)($a0)
D_802AA7A0_7B2140:
/* 41F530 802AA7A0 04800003 */  bltz      $a0, .L802AA7B0_7B2150
/* 41F534 802AA7A4 2484002E */   addiu    $a0, $a0, 0x2E
/* 41F538 802AA7A8 0C093E58 */  jal       func_8024F960
/* 41F53C 802AA7AC 2405003C */   addiu    $a1, $zero, 0x3C
.L802AA7B0_7B2150:
/* 41F540 802AA7B0 0C098C0B */  jal       func_8026302C
/* 41F544 802AA7B4 0240202D */   daddu    $a0, $s2, $zero
/* 41F548 802AA7B8 8E820184 */  lw        $v0, 0x184($s4)
/* 41F54C 802AA7BC 8253040C */  lb        $s3, 0x40C($s2)
/* 41F550 802AA7C0 30420001 */  andi      $v0, $v0, 0x1
/* 41F554 802AA7C4 10400018 */  beqz      $v0, .L802AA828_7B21C8
D_802AA7C8_7B2168:
/* 41F558 802AA7C8 00000000 */   nop
/* 41F55C 802AA7CC 2655040D */  addiu     $s5, $s2, 0x40D
/* 41F560 802AA7D0 1A600015 */  blez      $s3, .L802AA828_7B21C8
/* 41F564 802AA7D4 0000802D */   daddu    $s0, $zero, $zero
D_802AA7D8_7B2178:
/* 41F568 802AA7D8 02B01021 */  addu      $v0, $s5, $s0
.L802AA7DC_7B217C:
/* 41F56C 802AA7DC 80430000 */  lb        $v1, 0x0($v0)
/* 41F570 802AA7E0 00031080 */  sll       $v0, $v1, 2
/* 41F574 802AA7E4 00431021 */  addu      $v0, $v0, $v1
/* 41F578 802AA7E8 00021080 */  sll       $v0, $v0, 2
/* 41F57C 802AA7EC 2442022C */  addiu     $v0, $v0, 0x22C
D_802AA7F0_7B2190:
/* 41F580 802AA7F0 02428821 */  addu      $s1, $s2, $v0
/* 41F584 802AA7F4 0C09A75B */  jal       get_actor
/* 41F588 802AA7F8 86240000 */   lh       $a0, 0x0($s1)
/* 41F58C 802AA7FC 86250002 */  lh        $a1, 0x2($s1)
D_802AA800_7B21A0:
/* 41F590 802AA800 0C099117 */  jal       get_actor_part
/* 41F594 802AA804 0040202D */   daddu    $a0, $v0, $zero
/* 41F598 802AA808 8C420000 */  lw        $v0, 0x0($v0)
/* 41F59C 802AA80C 30420008 */  andi      $v0, $v0, 0x8
/* 41F5A0 802AA810 54400005 */  bnel      $v0, $zero, .L802AA828_7B21C8
/* 41F5A4 802AA814 A2500425 */   sb       $s0, 0x425($s2)
D_802AA818_7B21B8:
/* 41F5A8 802AA818 26100001 */  addiu     $s0, $s0, 0x1
/* 41F5AC 802AA81C 0213102A */  slt       $v0, $s0, $s3
/* 41F5B0 802AA820 1440FFEE */  bnez      $v0, .L802AA7DC_7B217C
/* 41F5B4 802AA824 02B01021 */   addu     $v0, $s5, $s0
.L802AA828_7B21C8:
/* 41F5B8 802AA828 8E820184 */  lw        $v0, 0x184($s4)
/* 41F5BC 802AA82C 04410015 */  bgez      $v0, .L802AA884_7B2224
/* 41F5C0 802AA830 3C030008 */   lui      $v1, (0x80000 >> 16)
/* 41F5C4 802AA834 3C04800E */  lui       $a0, %hi(gBattleStatus)
/* 41F5C8 802AA838 2484C070 */  addiu     $a0, $a0, %lo(gBattleStatus)
/* 41F5CC 802AA83C 8C820000 */  lw        $v0, 0x0($a0)
/* 41F5D0 802AA840 00431024 */  and       $v0, $v0, $v1
D_802AA844_7B21E4:
/* 41F5D4 802AA844 14400006 */  bnez      $v0, D_802AA860_7B2200
/* 41F5D8 802AA848 00000000 */   nop
.L802AA84C_7B21EC:
/* 41F5DC 802AA84C 8683006E */  lh        $v1, 0x6E($s4)
D_802AA850_7B21F0:
/* 41F5E0 802AA850 3C01800E */  lui       $at, %hi(gBattleSubState)
/* 41F5E4 802AA854 AC23C4DC */  sw        $v1, %lo(gBattleSubState)($at)
/* 41F5E8 802AA858 080AAACE */  j         .L802AAB38_7B24D8
D_802AA85C_7B21FC:
/* 41F5EC 802AA85C 00000000 */   nop
D_802AA860_7B2200:
/* 41F5F0 802AA860 8C820004 */  lw        $v0, 0x4($a0)
/* 41F5F4 802AA864 8683006E */  lh        $v1, 0x6E($s4)
/* 41F5F8 802AA868 30420040 */  andi      $v0, $v0, 0x40
/* 41F5FC 802AA86C 3C01800E */  lui       $at, %hi(gBattleSubState)
/* 41F600 802AA870 AC23C4DC */  sw        $v1, %lo(gBattleSubState)($at)
/* 41F604 802AA874 104000C1 */  beqz      $v0, .L802AAB7C_7B251C
D_802AA878_7B2218:
/* 41F608 802AA878 00000000 */   nop
/* 41F60C 802AA87C 080AAADB */  j         .L802AAB6C_7B250C
D_802AA880_7B2220:
/* 41F610 802AA880 00000000 */   nop
.L802AA884_7B2224:
/* 41F614 802AA884 16600009 */  bnez      $s3, .L802AA8AC_7B224C
D_802AA888_7B2228:
/* 41F618 802AA888 00000000 */   nop
/* 41F61C 802AA88C 3C04800E */  lui       $a0, %hi(gBattleStatus)
/* 41F620 802AA890 2484C070 */  addiu     $a0, $a0, %lo(gBattleStatus)
/* 41F624 802AA894 8C820000 */  lw        $v0, 0x0($a0)
/* 41F628 802AA898 00431024 */  and       $v0, $v0, $v1
/* 41F62C 802AA89C 1040FFEB */  beqz      $v0, .L802AA84C_7B21EC
D_802AA8A0_7B2240:
/* 41F630 802AA8A0 00000000 */   nop
/* 41F634 802AA8A4 080AAA18 */  j         D_802AA860_7B2200
/* 41F638 802AA8A8 00000000 */   nop
.L802AA8AC_7B224C:
/* 41F63C 802AA8AC 1A600013 */  blez      $s3, .L802AA8FC_7B229C
/* 41F640 802AA8B0 0000802D */   daddu    $s0, $zero, $zero
D_802AA8B4_7B2254:
/* 41F644 802AA8B4 3C12802B */  lui       $s2, %hi(D_802ACC70)
/* 41F648 802AA8B8 2652CC70 */  addiu     $s2, $s2, %lo(D_802ACC70)
.L802AA8BC_7B225C:
/* 41F64C 802AA8BC 3C048008 */  lui       $a0, %hi(HES_HandPointDownLoop)
/* 41F650 802AA8C0 2484FF20 */  addiu     $a0, $a0, %lo(HES_HandPointDownLoop)
/* 41F654 802AA8C4 0C050529 */  jal       hud_element_create
D_802AA8C8_7B2268:
/* 41F658 802AA8C8 26100001 */   addiu    $s0, $s0, 0x1
/* 41F65C 802AA8CC 0040882D */  daddu     $s1, $v0, $zero
/* 41F660 802AA8D0 AE510000 */  sw        $s1, 0x0($s2)
/* 41F664 802AA8D4 0220202D */  daddu     $a0, $s1, $zero
/* 41F668 802AA8D8 0C051277 */  jal       hud_element_set_render_depth
/* 41F66C 802AA8DC 0000282D */   daddu    $a1, $zero, $zero
jtbl_802AA8E0_7B2280:
/* 41F670 802AA8E0 0220202D */  daddu     $a0, $s1, $zero
/* 41F674 802AA8E4 0000282D */  daddu     $a1, $zero, $zero
/* 41F678 802AA8E8 0C051261 */  jal       hud_element_set_render_pos
/* 41F67C 802AA8EC 2406FF9C */   addiu    $a2, $zero, -0x64
D_802AA8F0_7B2290:
/* 41F680 802AA8F0 0213102A */  slt       $v0, $s0, $s3
/* 41F684 802AA8F4 1440FFF1 */  bnez      $v0, .L802AA8BC_7B225C
/* 41F688 802AA8F8 26520004 */   addiu    $s2, $s2, 0x4
.L802AA8FC_7B229C:
/* 41F68C 802AA8FC 24020001 */  addiu     $v0, $zero, 0x1
/* 41F690 802AA900 3C01800E */  lui       $at, %hi(gBattleSubState)
/* 41F694 802AA904 AC22C4DC */  sw        $v0, %lo(gBattleSubState)($at)
/* 41F698 802AA908 080AAB2D */  j         .L802AACB4_7B2654
/* 41F69C 802AA90C 00000000 */   nop
.L802AA910_7B22B0:
/* 41F6A0 802AA910 3C03802B */  lui       $v1, %hi(D_802ACC68)
/* 41F6A4 802AA914 2463CC68 */  addiu     $v1, $v1, %lo(D_802ACC68)
D_802AA918_7B22B8:
/* 41F6A8 802AA918 8C620000 */  lw        $v0, 0x0($v1)
/* 41F6AC 802AA91C 04410004 */  bgez      $v0, .L802AA930_7B22D0
/* 41F6B0 802AA920 24420014 */   addiu    $v0, $v0, 0x14
/* 41F6B4 802AA924 18400002 */  blez      $v0, .L802AA930_7B22D0
/* 41F6B8 802AA928 AC620000 */   sw       $v0, 0x0($v1)
/* 41F6BC 802AA92C AC600000 */  sw        $zero, 0x0($v1)
.L802AA930_7B22D0:
/* 41F6C0 802AA930 8E830214 */  lw        $v1, 0x214($s4)
/* 41F6C4 802AA934 30624000 */  andi      $v0, $v1, 0x4000
/* 41F6C8 802AA938 10400008 */  beqz      $v0, .L802AA95C_7B22FC
/* 41F6CC 802AA93C 30628000 */   andi     $v0, $v1, 0x8000
D_802AA940_7B22E0:
/* 41F6D0 802AA940 0C05272D */  jal       sfx_play_sound
/* 41F6D4 802AA944 240400CA */   addiu    $a0, $zero, 0xCA
/* 41F6D8 802AA948 2402000A */  addiu     $v0, $zero, 0xA
/* 41F6DC 802AA94C 3C01800E */  lui       $at, %hi(gBattleSubState)
/* 41F6E0 802AA950 AC22C4DC */  sw        $v0, %lo(gBattleSubState)($at)
/* 41F6E4 802AA954 080AAB2D */  j         .L802AACB4_7B2654
/* 41F6E8 802AA958 00000000 */   nop
.L802AA95C_7B22FC:
/* 41F6EC 802AA95C 1040000E */  beqz      $v0, .L802AA998_7B2338
/* 41F6F0 802AA960 00000000 */   nop
/* 41F6F4 802AA964 0C05272D */  jal       sfx_play_sound
D_802AA968_7B2308:
/* 41F6F8 802AA968 240400C9 */   addiu    $a0, $zero, 0xC9
/* 41F6FC 802AA96C 24020008 */  addiu     $v0, $zero, 0x8
/* 41F700 802AA970 3C01802B */  lui       $at, %hi(D_802ACC60)
/* 41F704 802AA974 AC22CC60 */  sw        $v0, %lo(D_802ACC60)($at)
/* 41F708 802AA978 24020004 */  addiu     $v0, $zero, 0x4
/* 41F70C 802AA97C 3C01802B */  lui       $at, %hi(D_802ACC6C)
/* 41F710 802AA980 AC22CC6C */  sw        $v0, %lo(D_802ACC6C)($at)
/* 41F714 802AA984 24020002 */  addiu     $v0, $zero, 0x2
/* 41F718 802AA988 3C01800E */  lui       $at, %hi(gBattleSubState)
/* 41F71C 802AA98C AC22C4DC */  sw        $v0, %lo(gBattleSubState)($at)
D_802AA990_7B2330:
/* 41F720 802AA990 080AAB2D */  j         .L802AACB4_7B2654
/* 41F724 802AA994 00000000 */   nop
.L802AA998_7B2338:
/* 41F728 802AA998 3C04800E */  lui       $a0, %hi(gBattleStatus)
/* 41F72C 802AA99C 2484C070 */  addiu     $a0, $a0, %lo(gBattleStatus)
/* 41F730 802AA9A0 8C830000 */  lw        $v1, 0x0($a0)
/* 41F734 802AA9A4 8E820210 */  lw        $v0, 0x210($s4)
/* 41F738 802AA9A8 34630002 */  ori       $v1, $v1, 0x2
/* 41F73C 802AA9AC 30422010 */  andi      $v0, $v0, 0x2010
/* 41F740 802AA9B0 10400005 */  beqz      $v0, .L802AA9C8_7B2368
/* 41F744 802AA9B4 AC830000 */   sw       $v1, 0x0($a0)
D_802AA9B8_7B2358:
/* 41F748 802AA9B8 2402FFFD */  addiu     $v0, $zero, -0x3
/* 41F74C 802AA9BC 00621024 */  and       $v0, $v1, $v0
/* 41F750 802AA9C0 080AAB2D */  j         .L802AACB4_7B2654
/* 41F754 802AA9C4 AC820000 */   sw       $v0, 0x0($a0)
.L802AA9C8_7B2368:
/* 41F758 802AA9C8 8E820184 */  lw        $v0, 0x184($s4)
/* 41F75C 802AA9CC 30420001 */  andi      $v0, $v0, 0x1
/* 41F760 802AA9D0 104000B8 */  beqz      $v0, .L802AACB4_7B2654
/* 41F764 802AA9D4 3C020004 */   lui      $v0, (0x40000 >> 16)
/* 41F768 802AA9D8 8E830218 */  lw        $v1, 0x218($s4)
/* 41F76C 802AA9DC 00621024 */  and       $v0, $v1, $v0
D_802AA9E0_7B2380:
/* 41F770 802AA9E0 10400002 */  beqz      $v0, .L802AA9EC_7B238C
/* 41F774 802AA9E4 0200202D */   daddu    $a0, $s0, $zero
/* 41F778 802AA9E8 2610FFFF */  addiu     $s0, $s0, -0x1
.L802AA9EC_7B238C:
/* 41F77C 802AA9EC 3C020008 */  lui       $v0, (0x80000 >> 16)
/* 41F780 802AA9F0 00621024 */  and       $v0, $v1, $v0
/* 41F784 802AA9F4 54400001 */  bnel      $v0, $zero, .L802AA9FC_7B239C
/* 41F788 802AA9F8 26100001 */   addiu    $s0, $s0, 0x1
.L802AA9FC_7B239C:
/* 41F78C 802AA9FC 06020001 */  bltzl     $s0, .L802AAA04_7B23A4
D_802AAA00_7B23A0:
/* 41F790 802AAA00 2670FFFF */   addiu    $s0, $s3, -0x1
.L802AAA04_7B23A4:
/* 41F794 802AAA04 0213102A */  slt       $v0, $s0, $s3
D_802AAA08_7B23A8:
/* 41F798 802AAA08 50400001 */  beql      $v0, $zero, .L802AAA10_7B23B0
/* 41F79C 802AAA0C 0000802D */   daddu    $s0, $zero, $zero
.L802AAA10_7B23B0:
/* 41F7A0 802AAA10 12040018 */  beq       $s0, $a0, .L802AAA74_7B2414
/* 41F7A4 802AAA14 02B01021 */   addu     $v0, $s5, $s0
/* 41F7A8 802AAA18 80430000 */  lb        $v1, 0x0($v0)
/* 41F7AC 802AAA1C 00031080 */  sll       $v0, $v1, 2
/* 41F7B0 802AAA20 00431021 */  addu      $v0, $v0, $v1
/* 41F7B4 802AAA24 00021080 */  sll       $v0, $v0, 2
/* 41F7B8 802AAA28 00528821 */  addu      $s1, $v0, $s2
/* 41F7BC 802AAA2C 0C09A75B */  jal       get_actor
D_802AAA30_7B23D0:
/* 41F7C0 802AAA30 8624022C */   lh       $a0, 0x22C($s1)
/* 41F7C4 802AAA34 8C420000 */  lw        $v0, 0x0($v0)
/* 41F7C8 802AAA38 3C11802B */  lui       $s1, %hi(D_802ACC70)
/* 41F7CC 802AAA3C 8E31CC70 */  lw        $s1, %lo(D_802ACC70)($s1)
/* 41F7D0 802AAA40 30420800 */  andi      $v0, $v0, 0x800
/* 41F7D4 802AAA44 10400005 */  beqz      $v0, .L802AAA5C_7B23FC
/* 41F7D8 802AAA48 0220202D */   daddu    $a0, $s1, $zero
/* 41F7DC 802AAA4C 3C058008 */  lui       $a1, %hi(HES_HandPointLeftLoop)
/* 41F7E0 802AAA50 24A50208 */  addiu     $a1, $a1, %lo(HES_HandPointLeftLoop)
/* 41F7E4 802AAA54 080AAA99 */  j         .L802AAA64_7B2404
/* 41F7E8 802AAA58 00000000 */   nop
.L802AAA5C_7B23FC:
/* 41F7EC 802AAA5C 3C058008 */  lui       $a1, %hi(HES_HandPointDownLoop)
/* 41F7F0 802AAA60 24A5FF20 */  addiu     $a1, $a1, %lo(HES_HandPointDownLoop)
.L802AAA64_7B2404:
/* 41F7F4 802AAA64 0C0511FF */  jal       hud_element_set_script
/* 41F7F8 802AAA68 00000000 */   nop
/* 41F7FC 802AAA6C 0C05272D */  jal       sfx_play_sound
/* 41F800 802AAA70 240400C7 */   addiu    $a0, $zero, 0xC7
.L802AAA74_7B2414:
/* 41F804 802AAA74 080AAB2D */  j         .L802AACB4_7B2654
D_802AAA78_7B2418:
/* 41F808 802AAA78 A2500425 */   sb       $s0, 0x425($s2)
.L802AAA7C_7B241C:
/* 41F80C 802AAA7C 3C04800E */  lui       $a0, %hi(gBattleStatus)
/* 41F810 802AAA80 2484C070 */  addiu     $a0, $a0, %lo(gBattleStatus)
/* 41F814 802AAA84 8C820000 */  lw        $v0, 0x0($a0)
/* 41F818 802AAA88 2403FFFD */  addiu     $v1, $zero, -0x3
/* 41F81C 802AAA8C 00431024 */  and       $v0, $v0, $v1
/* 41F820 802AAA90 AC820000 */  sw        $v0, 0x0($a0)
/* 41F824 802AAA94 82420425 */  lb        $v0, 0x425($s2)
/* 41F828 802AAA98 02A21021 */  addu      $v0, $s5, $v0
/* 41F82C 802AAA9C 80430000 */  lb        $v1, 0x0($v0)
/* 41F830 802AAAA0 00031080 */  sll       $v0, $v1, 2
/* 41F834 802AAAA4 00431021 */  addu      $v0, $v0, $v1
/* 41F838 802AAAA8 00021080 */  sll       $v0, $v0, 2
/* 41F83C 802AAAAC 2442022C */  addiu     $v0, $v0, 0x22C
/* 41F840 802AAAB0 02428821 */  addu      $s1, $s2, $v0
/* 41F844 802AAAB4 96220000 */  lhu       $v0, 0x0($s1)
/* 41F848 802AAAB8 A6420428 */  sh        $v0, 0x428($s2)
/* 41F84C 802AAABC 92220003 */  lbu       $v0, 0x3($s1)
D_802AAAC0_7B2460:
/* 41F850 802AAAC0 0000802D */  daddu     $s0, $zero, $zero
/* 41F854 802AAAC4 1A60000C */  blez      $s3, .L802AAAF8_7B2498
/* 41F858 802AAAC8 A2420426 */   sb       $v0, 0x426($s2)
/* 41F85C 802AAACC 3C11802B */  lui       $s1, %hi(D_802ACC70)
D_802AAAD0_7B2470:
/* 41F860 802AAAD0 2631CC70 */  addiu     $s1, $s1, %lo(D_802ACC70)
.L802AAAD4_7B2474:
/* 41F864 802AAAD4 8E240000 */  lw        $a0, 0x0($s1)
/* 41F868 802AAAD8 26310004 */  addiu     $s1, $s1, 0x4
/* 41F86C 802AAADC 0C05123D */  jal       hud_element_free
D_802AAAE0_7B2480:
/* 41F870 802AAAE0 26100001 */   addiu    $s0, $s0, 0x1
/* 41F874 802AAAE4 0213102A */  slt       $v0, $s0, $s3
/* 41F878 802AAAE8 1440FFFA */  bnez      $v0, .L802AAAD4_7B2474
/* 41F87C 802AAAEC 00000000 */   nop
/* 41F880 802AAAF0 3C04800E */  lui       $a0, %hi(gBattleStatus)
/* 41F884 802AAAF4 2484C070 */  addiu     $a0, $a0, %lo(gBattleStatus)
.L802AAAF8_7B2498:
/* 41F888 802AAAF8 8C820000 */  lw        $v0, 0x0($a0)
/* 41F88C 802AAAFC 3C030008 */  lui       $v1, (0x80000 >> 16)
/* 41F890 802AAB00 00431024 */  and       $v0, $v0, $v1
/* 41F894 802AAB04 14400012 */  bnez      $v0, .L802AAB50_7B24F0
/* 41F898 802AAB08 00000000 */   nop
/* 41F89C 802AAB0C 8C820004 */  lw        $v0, 0x4($a0)
/* 41F8A0 802AAB10 8683006E */  lh        $v1, 0x6E($s4)
/* 41F8A4 802AAB14 30420040 */  andi      $v0, $v0, 0x40
/* 41F8A8 802AAB18 3C01800E */  lui       $at, %hi(gBattleSubState)
/* 41F8AC 802AAB1C AC23C4DC */  sw        $v1, %lo(gBattleSubState)($at)
D_802AAB20_7B24C0:
/* 41F8B0 802AAB20 10400005 */  beqz      $v0, .L802AAB38_7B24D8
/* 41F8B4 802AAB24 00000000 */   nop
/* 41F8B8 802AAB28 0C0AA6D1 */  jal       func_802A9B44_7B14E4
/* 41F8BC 802AAB2C 00000000 */   nop
/* 41F8C0 802AAB30 080AAAD0 */  j         .L802AAB40_7B24E0
/* 41F8C4 802AAB34 00000000 */   nop
.L802AAB38_7B24D8:
/* 41F8C8 802AAB38 0C0A9662 */  jal       func_802A5988_7AD328
/* 41F8CC 802AAB3C 00000000 */   nop
.L802AAB40_7B24E0:
/* 41F8D0 802AAB40 0C090464 */  jal       func_80241190
/* 41F8D4 802AAB44 24040012 */   addiu    $a0, $zero, 0x12
/* 41F8D8 802AAB48 080AAB2D */  j         .L802AACB4_7B2654
/* 41F8DC 802AAB4C 00000000 */   nop
.L802AAB50_7B24F0:
/* 41F8E0 802AAB50 8C820004 */  lw        $v0, 0x4($a0)
/* 41F8E4 802AAB54 8683006E */  lh        $v1, 0x6E($s4)
/* 41F8E8 802AAB58 30420040 */  andi      $v0, $v0, 0x40
/* 41F8EC 802AAB5C 3C01800E */  lui       $at, %hi(gBattleSubState)
/* 41F8F0 802AAB60 AC23C4DC */  sw        $v1, %lo(gBattleSubState)($at)
/* 41F8F4 802AAB64 10400005 */  beqz      $v0, .L802AAB7C_7B251C
/* 41F8F8 802AAB68 00000000 */   nop
.L802AAB6C_7B250C:
/* 41F8FC 802AAB6C 0C0AA82E */  jal       func_802AA0B8_7B1A58
/* 41F900 802AAB70 00000000 */   nop
/* 41F904 802AAB74 080AAAE1 */  j         .L802AAB84_7B2524
/* 41F908 802AAB78 00000000 */   nop
.L802AAB7C_7B251C:
/* 41F90C 802AAB7C 0C0AA072 */  jal       func_802A81C8_7AFB68
/* 41F910 802AAB80 00000000 */   nop
.L802AAB84_7B2524:
/* 41F914 802AAB84 0C090464 */  jal       func_80241190
/* 41F918 802AAB88 24040013 */   addiu    $a0, $zero, 0x13
/* 41F91C 802AAB8C 080AAB2D */  j         .L802AACB4_7B2654
/* 41F920 802AAB90 00000000 */   nop
.L802AAB94_7B2534:
/* 41F924 802AAB94 1A60000A */  blez      $s3, D_802AABC0_7B2560
/* 41F928 802AAB98 0000802D */   daddu    $s0, $zero, $zero
/* 41F92C 802AAB9C 3C11802B */  lui       $s1, %hi(D_802ACC70)
D_802AABA0_7B2540:
/* 41F930 802AABA0 2631CC70 */  addiu     $s1, $s1, %lo(D_802ACC70)
.L802AABA4_7B2544:
/* 41F934 802AABA4 8E240000 */  lw        $a0, 0x0($s1)
/* 41F938 802AABA8 26310004 */  addiu     $s1, $s1, 0x4
/* 41F93C 802AABAC 0C05123D */  jal       hud_element_free
/* 41F940 802AABB0 26100001 */   addiu    $s0, $s0, 0x1
/* 41F944 802AABB4 0213102A */  slt       $v0, $s0, $s3
/* 41F948 802AABB8 1440FFFA */  bnez      $v0, .L802AABA4_7B2544
/* 41F94C 802AABBC 00000000 */   nop
D_802AABC0_7B2560:
/* 41F950 802AABC0 3C030001 */  lui       $v1, (0x10002 >> 16)
/* 41F954 802AABC4 3C10800E */  lui       $s0, %hi(gBattleStatus)
/* 41F958 802AABC8 2610C070 */  addiu     $s0, $s0, %lo(gBattleStatus)
/* 41F95C 802AABCC 8E020000 */  lw        $v0, 0x0($s0)
/* 41F960 802AABD0 34630002 */  ori       $v1, $v1, (0x10002 & 0xFFFF)
/* 41F964 802AABD4 00431025 */  or        $v0, $v0, $v1
/* 41F968 802AABD8 AE020000 */  sw        $v0, 0x0($s0)
/* 41F96C 802AABDC 8E420000 */  lw        $v0, 0x0($s2)
/* 41F970 802AABE0 3C030800 */  lui       $v1, (0x8000000 >> 16)
/* 41F974 802AABE4 00431025 */  or        $v0, $v0, $v1
/* 41F978 802AABE8 AE420000 */  sw        $v0, 0x0($s2)
/* 41F97C 802AABEC 82820088 */  lb        $v0, 0x88($s4)
/* 41F980 802AABF0 1040000C */  beqz      $v0, .L802AAC24_7B25C4
/* 41F984 802AABF4 3C030008 */   lui      $v1, (0x80000 >> 16)
/* 41F988 802AABF8 0C090464 */  jal       func_80241190
/* 41F98C 802AABFC 2404000D */   addiu    $a0, $zero, 0xD
/* 41F990 802AAC00 8E020004 */  lw        $v0, 0x4($s0)
/* 41F994 802AAC04 8683006C */  lh        $v1, 0x6C($s4)
/* 41F998 802AAC08 30420040 */  andi      $v0, $v0, 0x40
/* 41F99C 802AAC0C 3C01800E */  lui       $at, %hi(gBattleSubState)
/* 41F9A0 802AAC10 AC23C4DC */  sw        $v1, %lo(gBattleSubState)($at)
/* 41F9A4 802AAC14 10400014 */  beqz      $v0, .L802AAC68_7B2608
/* 41F9A8 802AAC18 00000000 */   nop
/* 41F9AC 802AAC1C 080AAB16 */  j         .L802AAC58_7B25F8
/* 41F9B0 802AAC20 00000000 */   nop
.L802AAC24_7B25C4:
/* 41F9B4 802AAC24 8E020000 */  lw        $v0, 0x0($s0)
/* 41F9B8 802AAC28 00431024 */  and       $v0, $v0, $v1
/* 41F9BC 802AAC2C 14400012 */  bnez      $v0, .L802AAC78_7B2618
/* 41F9C0 802AAC30 00000000 */   nop
/* 41F9C4 802AAC34 0C090464 */  jal       func_80241190
/* 41F9C8 802AAC38 2404000D */   addiu    $a0, $zero, 0xD
/* 41F9CC 802AAC3C 8E020004 */  lw        $v0, 0x4($s0)
/* 41F9D0 802AAC40 8683006C */  lh        $v1, 0x6C($s4)
/* 41F9D4 802AAC44 30420040 */  andi      $v0, $v0, 0x40
/* 41F9D8 802AAC48 3C01800E */  lui       $at, %hi(gBattleSubState)
/* 41F9DC 802AAC4C AC23C4DC */  sw        $v1, %lo(gBattleSubState)($at)
/* 41F9E0 802AAC50 10400005 */  beqz      $v0, .L802AAC68_7B2608
/* 41F9E4 802AAC54 00000000 */   nop
.L802AAC58_7B25F8:
/* 41F9E8 802AAC58 0C0AA6D1 */  jal       func_802A9B44_7B14E4
/* 41F9EC 802AAC5C 00000000 */   nop
/* 41F9F0 802AAC60 080AAB2D */  j         .L802AACB4_7B2654
/* 41F9F4 802AAC64 00000000 */   nop
.L802AAC68_7B2608:
/* 41F9F8 802AAC68 0C0A9662 */  jal       func_802A5988_7AD328
/* 41F9FC 802AAC6C 00000000 */   nop
/* 41FA00 802AAC70 080AAB2D */  j         .L802AACB4_7B2654
/* 41FA04 802AAC74 00000000 */   nop
.L802AAC78_7B2618:
/* 41FA08 802AAC78 0C090464 */  jal       func_80241190
/* 41FA0C 802AAC7C 2404000E */   addiu    $a0, $zero, 0xE
/* 41FA10 802AAC80 8E020004 */  lw        $v0, 0x4($s0)
/* 41FA14 802AAC84 8683006C */  lh        $v1, 0x6C($s4)
/* 41FA18 802AAC88 30420040 */  andi      $v0, $v0, 0x40
/* 41FA1C 802AAC8C 3C01800E */  lui       $at, %hi(gBattleSubState)
/* 41FA20 802AAC90 AC23C4DC */  sw        $v1, %lo(gBattleSubState)($at)
/* 41FA24 802AAC94 10400005 */  beqz      $v0, .L802AACAC_7B264C
/* 41FA28 802AAC98 00000000 */   nop
/* 41FA2C 802AAC9C 0C0AA82E */  jal       func_802AA0B8_7B1A58
/* 41FA30 802AACA0 00000000 */   nop
/* 41FA34 802AACA4 080AAB2D */  j         .L802AACB4_7B2654
/* 41FA38 802AACA8 00000000 */   nop
.L802AACAC_7B264C:
/* 41FA3C 802AACAC 0C0AA072 */  jal       func_802A81C8_7AFB68
/* 41FA40 802AACB0 00000000 */   nop
.L802AACB4_7B2654:
/* 41FA44 802AACB4 8FBF0028 */  lw        $ra, 0x28($sp)
/* 41FA48 802AACB8 8FB50024 */  lw        $s5, 0x24($sp)
/* 41FA4C 802AACBC 8FB40020 */  lw        $s4, 0x20($sp)
/* 41FA50 802AACC0 8FB3001C */  lw        $s3, 0x1C($sp)
/* 41FA54 802AACC4 8FB20018 */  lw        $s2, 0x18($sp)
/* 41FA58 802AACC8 8FB10014 */  lw        $s1, 0x14($sp)
/* 41FA5C 802AACCC 8FB00010 */  lw        $s0, 0x10($sp)
/* 41FA60 802AACD0 03E00008 */  jr        $ra
/* 41FA64 802AACD4 27BD0030 */   addiu    $sp, $sp, 0x30

### DECOMPILED C INSTRUCTIONS:

void btl_state_update_select_target(void) {
    BattleStatus* battleStatus = &gBattleStatus;
    Actor* actor;
    s32 targetListLength;
    s32 selectedTargetIndex;
    s32 id;
    s8* targetIndexList;
    SelectableTarget* target;
    s32 i;

    if (!(gBattleStatus.flags1 & BS_FLAGS1_PARTNER_ACTING)) {
        actor = battleStatus->playerActor;
    } else {
        actor = battleStatus->partnerActor;
    }
    targetListLength = actor->targetListLength;
    selectedTargetIndex = actor->selectedTargetIndex;

    actor->flags &= ~ACTOR_FLAG_8000000;
    targetIndexList = actor->targetIndexList;
    switch (gBattleSubState) {
        case BTL_SUBSTATE_SELECT_TARGET_INIT:
            D_802ACC64 = 255;
            D_802ACC68 = -100;
            gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
            if (!is_ability_active(ABILITY_BERSERKER) || (gBattleStatus.flags1 & BS_FLAGS1_PARTNER_ACTING)) {
                if (battleStatus->selectedMoveID != MOVE_NONE) {
                    s8 actionTip = gMoveTable[battleStatus->selectedMoveID].actionTip;

                    if (actionTip >= 0) {
                        btl_show_battle_message(BTL_MSG_ACTION_TIP_00 + actionTip, 60);
                    }
                }
            }
            player_create_target_list(actor);
            targetListLength = actor->targetListLength;
            if (battleStatus->currentTargetListFlags & TARGET_FLAG_ENEMY) {
                targetIndexList = actor->targetIndexList;
                for (i = 0; i < targetListLength; i++) {
                    target = &actor->targetData[targetIndexList[i]];
                    if (get_actor_part(get_actor(target->actorID), target->partID)->flags & ACTOR_PART_FLAG_8) {
                        actor->selectedTargetIndex = i;
                        break;
                    }
                }
            }

            if (battleStatus->currentTargetListFlags & TARGET_FLAG_80000000) {
                if (!(gBattleStatus.flags1 & BS_FLAGS1_PARTNER_ACTING)) {
                    gBattleSubState = battleStatus->acceptTargetMenuSubstate;
                    if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) {
                        btl_state_update_player_menu();
                    } else {
                        btl_state_update_player_menu();
                    }
                    btl_set_state(BATTLE_STATE_PLAYER_MOVE);
                } else {
                    gBattleSubState = battleStatus->acceptTargetMenuSubstate;
                    if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) {
                        btl_state_update_twink_menu();
                    } else {
                        btl_state_update_partner_menu();
                    }
                    btl_set_state(BATTLE_STATE_PARTNER_MOVE);
                }
                return;
            }

            if (targetListLength == 0) {
                if (!(gBattleStatus.flags1 & BS_FLAGS1_PARTNER_ACTING)) {
                    gBattleSubState = battleStatus->acceptTargetMenuSubstate;
                    if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) {
                        btl_state_update_player_menu();
                    } else {
                        btl_state_update_player_menu();
                    }
                    btl_set_state(BATTLE_STATE_PLAYER_MOVE);
                } else {
                    gBattleSubState = battleStatus->acceptTargetMenuSubstate;
                    if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) {
                        btl_state_update_twink_menu();
                    } else {
                        btl_state_update_partner_menu();
                    }
                    btl_set_state(BATTLE_STATE_PARTNER_MOVE);
                }
                return;
            }

            for (i = 0; i < targetListLength; i++) {
                id = hud_element_create(&HES_HandPointDownLoop);
                D_802ACC70[i] = id;
                hud_element_set_render_depth(id, 0);
                hud_element_set_render_pos(id, 0, -100);
            }
            gBattleSubState = BTL_SUBSTATE_SELECT_TARGET_CHOOSE;
            break;
        case BTL_SUBSTATE_SELECT_TARGET_CHOOSE:
            if (D_802ACC68 < 0) {
                D_802ACC68 += 20;
                if (D_802ACC68 > 0) {
                    D_802ACC68 = 0;
                }
            }

            if (battleStatus->currentButtonsPressed & BUTTON_B) {
                sfx_play_sound(SOUND_MENU_BACK);
                gBattleSubState = BTL_SUBSTATE_SELECT_TARGET_CANCEL;
                break;
            }

            if (battleStatus->currentButtonsPressed & BUTTON_A) {
                sfx_play_sound(SOUND_MENU_NEXT);
                D_802ACC60 = 8;
                D_802ACC6C = 4;
                gBattleSubState = BTL_SUBSTATE_SELECT_TARGET_DONE;
                break;
            }

            gBattleStatus.flags1 |= BS_FLAGS1_MENU_OPEN;
            if (battleStatus->currentButtonsDown & (BUTTON_Z | BUTTON_R)) {
                gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
                break;
            }

            if (battleStatus->currentTargetListFlags & TARGET_FLAG_ENEMY) {
                s32 oldSelectedTargetIndex = selectedTargetIndex;

                if (battleStatus->currentButtonsHeld & BUTTON_STICK_LEFT) {
                    selectedTargetIndex--;
                }
                if (battleStatus->currentButtonsHeld & BUTTON_STICK_RIGHT) {
                    selectedTargetIndex++;
                }
                if (selectedTargetIndex < 0) {
                    selectedTargetIndex = targetListLength - 1;
                }
                if (selectedTargetIndex >= targetListLength) {
                    selectedTargetIndex = 0;
                }
                if (selectedTargetIndex != oldSelectedTargetIndex) {
                    s32 actorFlags;

                    target = &actor->targetData[targetIndexList[selectedTargetIndex]];
                    actorFlags = get_actor(target->actorID)->flags;
                    id = D_802ACC70[0];

                    if (actorFlags & ACTOR_FLAG_UPSIDE_DOWN) {
                        hud_element_set_script(id, &HES_HandPointLeftLoop);
                    } else {
                        hud_element_set_script(id, &HES_HandPointDownLoop);
                    }
                    sfx_play_sound(SOUND_MENU_CHANGE_SELECTION);
                }
                actor->selectedTargetIndex = selectedTargetIndex;
            }
            break;
        case BTL_SUBSTATE_SELECT_TARGET_DONE:
            gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
            target = &actor->targetData[targetIndexList[actor->selectedTargetIndex]];
            actor->targetActorID = target->actorID;
            actor->targetPartIndex = target->partID;
            for (i = 0; i < targetListLength; i++) {
                hud_element_free(D_802ACC70[i]);
            }

            if (!(gBattleStatus.flags1 & BS_FLAGS1_PARTNER_ACTING)) {
                gBattleSubState = battleStatus->acceptTargetMenuSubstate;
                if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) {
                    btl_state_update_peach_menu();
                } else {
                    btl_state_update_player_menu();
                }
                btl_set_state(BATTLE_STATE_PLAYER_MOVE);
            } else {
                gBattleSubState = battleStatus->acceptTargetMenuSubstate;
                if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) {
                    btl_state_update_twink_menu();
                } else {
                    btl_state_update_partner_menu();
                }
                btl_set_state(BATTLE_STATE_PARTNER_MOVE);
            }
            break;
        case BTL_SUBSTATE_SELECT_TARGET_CANCEL:
            for (i = 0; i < targetListLength; i++) {
                hud_element_free(D_802ACC70[i]);
            }
            gBattleStatus.flags1 |= BS_FLAGS1_10000 | BS_FLAGS1_MENU_OPEN;
            actor->flags |= ACTOR_FLAG_8000000;

            if (battleStatus->itemUsesLeft != 0) {
                btl_set_state(BATTLE_STATE_PLAYER_MENU);
                gBattleSubState = battleStatus->cancelTargetMenuSubstate;
                if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) {
                    btl_state_update_peach_menu();
                } else {
                    btl_state_update_player_menu();
                }
            } else if (!(gBattleStatus.flags1 & BS_FLAGS1_PARTNER_ACTING)) {
                btl_set_state(BATTLE_STATE_PLAYER_MENU);
                gBattleSubState = battleStatus->cancelTargetMenuSubstate;
                if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) {
                    btl_state_update_peach_menu();
                } else {
                    btl_state_update_player_menu();
                }
            } else {
                btl_set_state(BATTLE_STATE_PARTNER_MENU);
                gBattleSubState = battleStatus->cancelTargetMenuSubstate;
                if (gBattleStatus.flags2 & BS_FLAGS2_PEACH_BATTLE) {
                    btl_state_update_twink_menu();
                } else {
                    btl_state_update_partner_menu();
                }
            }
            break;
    }
}