### RAW ASSEMBLY INSTRUCTIONS:

glabel imgfx_appendGfx_mesh_basic
/* D36A8 8013CFA8 27BDFFA8 */  addiu     $sp, $sp, -0x58
/* D36AC 8013CFAC AFB10034 */  sw        $s1, 0x34($sp)
/* D36B0 8013CFB0 0080882D */  daddu     $s1, $a0, $zero
/* D36B4 8013CFB4 AFBF0054 */  sw        $ra, 0x54($sp)
/* D36B8 8013CFB8 AFBE0050 */  sw        $fp, 0x50($sp)
/* D36BC 8013CFBC AFB7004C */  sw        $s7, 0x4C($sp)
/* D36C0 8013CFC0 AFB60048 */  sw        $s6, 0x48($sp)
/* D36C4 8013CFC4 AFB50044 */  sw        $s5, 0x44($sp)
/* D36C8 8013CFC8 AFB40040 */  sw        $s4, 0x40($sp)
/* D36CC 8013CFCC AFB3003C */  sw        $s3, 0x3C($sp)
/* D36D0 8013CFD0 AFB20038 */  sw        $s2, 0x38($sp)
/* D36D4 8013CFD4 AFB00030 */  sw        $s0, 0x30($sp)
/* D36D8 8013CFD8 AFA5005C */  sw        $a1, 0x5C($sp)
/* D36DC 8013CFDC 8E220014 */  lw        $v0, 0x14($s1)
/* D36E0 8013CFE0 30420020 */  andi      $v0, $v0, 0x20
/* D36E4 8013CFE4 14400030 */  bnez      $v0, .L8013D0A8
/* D36E8 8013CFE8 3C03E300 */   lui      $v1, (0xE3001001 >> 16)
/* D36EC 8013CFEC 34631001 */  ori       $v1, $v1, (0xE3001001 & 0xFFFF)
/* D36F0 8013CFF0 3C06F500 */  lui       $a2, (0xF5000100 >> 16)
/* D36F4 8013CFF4 34C60100 */  ori       $a2, $a2, (0xF5000100 & 0xFFFF)
/* D36F8 8013CFF8 3C070703 */  lui       $a3, (0x703C000 >> 16)
/* D36FC 8013CFFC 3C04800A */  lui       $a0, %hi(gMainGfxPos)
/* D3700 8013D000 2484A66C */  addiu     $a0, $a0, %lo(gMainGfxPos)
/* D3704 8013D004 8C820000 */  lw        $v0, 0x0($a0)
/* D3708 8013D008 34E7C000 */  ori       $a3, $a3, (0x703C000 & 0xFFFF)
/* D370C 8013D00C 0040282D */  daddu     $a1, $v0, $zero
/* D3710 8013D010 24420008 */  addiu     $v0, $v0, 0x8
/* D3714 8013D014 AC820000 */  sw        $v0, 0x0($a0)
/* D3718 8013D018 ACA30000 */  sw        $v1, 0x0($a1)
/* D371C 8013D01C 34038000 */  ori       $v1, $zero, 0x8000
/* D3720 8013D020 ACA30004 */  sw        $v1, 0x4($a1)
/* D3724 8013D024 24430008 */  addiu     $v1, $v0, 0x8
/* D3728 8013D028 AC830000 */  sw        $v1, 0x0($a0)
/* D372C 8013D02C 3C058015 */  lui       $a1, %hi(ImgFXCurrentTexturePtr)
/* D3730 8013D030 8CA5EE10 */  lw        $a1, %lo(ImgFXCurrentTexturePtr)($a1)
/* D3734 8013D034 3C03FD10 */  lui       $v1, (0xFD100000 >> 16)
/* D3738 8013D038 AC430000 */  sw        $v1, 0x0($v0)
/* D373C 8013D03C 24430010 */  addiu     $v1, $v0, 0x10
/* D3740 8013D040 AC830000 */  sw        $v1, 0x0($a0)
/* D3744 8013D044 8CA50004 */  lw        $a1, 0x4($a1)
/* D3748 8013D048 3C03E800 */  lui       $v1, (0xE8000000 >> 16)
/* D374C 8013D04C AC430008 */  sw        $v1, 0x8($v0)
/* D3750 8013D050 24430018 */  addiu     $v1, $v0, 0x18
/* D3754 8013D054 AC40000C */  sw        $zero, 0xC($v0)
/* D3758 8013D058 AC830000 */  sw        $v1, 0x0($a0)
/* D375C 8013D05C 3C030700 */  lui       $v1, (0x7000000 >> 16)
/* D3760 8013D060 AC430014 */  sw        $v1, 0x14($v0)
/* D3764 8013D064 24430020 */  addiu     $v1, $v0, 0x20
/* D3768 8013D068 AC460010 */  sw        $a2, 0x10($v0)
/* D376C 8013D06C AC830000 */  sw        $v1, 0x0($a0)
/* D3770 8013D070 3C03E600 */  lui       $v1, (0xE6000000 >> 16)
/* D3774 8013D074 AC430018 */  sw        $v1, 0x18($v0)
/* D3778 8013D078 24430028 */  addiu     $v1, $v0, 0x28
/* D377C 8013D07C AC40001C */  sw        $zero, 0x1C($v0)
/* D3780 8013D080 AC830000 */  sw        $v1, 0x0($a0)
/* D3784 8013D084 3C03F000 */  lui       $v1, (0xF0000000 >> 16)
/* D3788 8013D088 AC430020 */  sw        $v1, 0x20($v0)
/* D378C 8013D08C 24430030 */  addiu     $v1, $v0, 0x30
/* D3790 8013D090 AC470024 */  sw        $a3, 0x24($v0)
/* D3794 8013D094 AC830000 */  sw        $v1, 0x0($a0)
/* D3798 8013D098 3C03E700 */  lui       $v1, (0xE7000000 >> 16)
/* D379C 8013D09C AC430028 */  sw        $v1, 0x28($v0)
/* D37A0 8013D0A0 AC40002C */  sw        $zero, 0x2C($v0)
/* D37A4 8013D0A4 AC450004 */  sw        $a1, 0x4($v0)
.L8013D0A8:
/* D37A8 8013D0A8 96350008 */  lhu       $s5, 0x8($s1)
/* D37AC 8013D0AC 3C180018 */  lui       $t8, (0x180000 >> 16)
/* D37B0 8013D0B0 24160002 */  addiu     $s6, $zero, 0x2
/* D37B4 8013D0B4 3C10800A */  lui       $s0, %hi(gMainGfxPos)
/* D37B8 8013D0B8 2610A66C */  addiu     $s0, $s0, %lo(gMainGfxPos)
/* D37BC 8013D0BC 3C1EE700 */  lui       $fp, (0xE7000000 >> 16)
/* D37C0 8013D0C0 3C19800B */  lui       $t9, %hi(gCameras)
/* D37C4 8013D0C4 27391D80 */  addiu     $t9, $t9, %lo(gCameras)
/* D37C8 8013D0C8 3C13DC08 */  lui       $s3, (0xDC080008 >> 16)
/* D37CC 8013D0CC 36730008 */  ori       $s3, $s3, (0xDC080008 & 0xFFFF)
/* D37D0 8013D0D0 3C178015 */  lui       $s7, %hi(D_8014EE50)
/* D37D4 8013D0D4 26F7EE50 */  addiu     $s7, $s7, %lo(D_8014EE50)
/* D37D8 8013D0D8 3C14E200 */  lui       $s4, (0xE200001C >> 16)
/* D37DC 8013D0DC 3694001C */  ori       $s4, $s4, (0xE200001C & 0xFFFF)
/* D37E0 8013D0E0 00159100 */  sll       $s2, $s5, 4
.L8013D0E4:
/* D37E4 8013D0E4 3C048015 */  lui       $a0, %hi(imgfx_vtxBuf)
/* D37E8 8013D0E8 8C846950 */  lw        $a0, %lo(imgfx_vtxBuf)($a0)
/* D37EC 8013D0EC 02442021 */  addu      $a0, $s2, $a0
/* D37F0 8013D0F0 94820008 */  lhu       $v0, 0x8($a0)
/* D37F4 8013D0F4 9483000A */  lhu       $v1, 0xA($a0)
/* D37F8 8013D0F8 00021400 */  sll       $v0, $v0, 16
/* D37FC 8013D0FC 00021543 */  sra       $v0, $v0, 21
/* D3800 8013D100 244CFF00 */  addiu     $t4, $v0, -0x100
/* D3804 8013D104 00031C00 */  sll       $v1, $v1, 16
/* D3808 8013D108 00031D43 */  sra       $v1, $v1, 21
/* D380C 8013D10C 246FFF00 */  addiu     $t7, $v1, -0x100
/* D3810 8013D110 94820038 */  lhu       $v0, 0x38($a0)
/* D3814 8013D114 9483003A */  lhu       $v1, 0x3A($a0)
/* D3818 8013D118 8E240014 */  lw        $a0, 0x14($s1)
/* D381C 8013D11C 00021400 */  sll       $v0, $v0, 16
/* D3820 8013D120 00021543 */  sra       $v0, $v0, 21
/* D3824 8013D124 244DFF00 */  addiu     $t5, $v0, -0x100
/* D3828 8013D128 00031C00 */  sll       $v1, $v1, 16
/* D382C 8013D12C 00031D43 */  sra       $v1, $v1, 21
/* D3830 8013D130 30820020 */  andi      $v0, $a0, 0x20
/* D3834 8013D134 14400200 */  bnez      $v0, .L8013D938
/* D3838 8013D138 246EFF00 */   addiu    $t6, $v1, -0x100
/* D383C 8013D13C 3C028015 */  lui       $v0, %hi(gSpriteShadingProfile)
/* D3840 8013D140 8C421328 */  lw        $v0, %lo(gSpriteShadingProfile)($v0)
/* D3844 8013D144 94420000 */  lhu       $v0, 0x0($v0)
/* D3848 8013D148 30420001 */  andi      $v0, $v0, 0x1
/* D384C 8013D14C 104000FE */  beqz      $v0, .L8013D548
/* D3850 8013D150 3C06070A */   lui      $a2, (0x70A0280 >> 16)
/* D3854 8013D154 92220000 */  lbu       $v0, 0x0($s1)
/* D3858 8013D158 104000FB */  beqz      $v0, .L8013D548
/* D385C 8013D15C 00981024 */   and      $v0, $a0, $t8
/* D3860 8013D160 104000FA */  beqz      $v0, .L8013D54C
/* D3864 8013D164 34C60280 */   ori      $a2, $a2, (0x70A0280 & 0xFFFF)
/* D3868 8013D168 92230002 */  lbu       $v1, 0x2($s1)
/* D386C 8013D16C 10600008 */  beqz      $v1, .L8013D190
/* D3870 8013D170 3C07070A */   lui      $a3, (0x70A0280 >> 16)
/* D3874 8013D174 10760006 */  beq       $v1, $s6, .L8013D190
/* D3878 8013D178 2402000F */   addiu    $v0, $zero, 0xF
/* D387C 8013D17C 10620004 */  beq       $v1, $v0, .L8013D190
/* D3880 8013D180 24020007 */   addiu    $v0, $zero, 0x7
/* D3884 8013D184 146200F0 */  bne       $v1, $v0, .L8013D548
/* D3888 8013D188 3C06070A */   lui      $a2, (0x70A0280 >> 16)
/* D388C 8013D18C 3C07070A */  lui       $a3, (0x70A0280 >> 16)
.L8013D190:
/* D3890 8013D190 34E70280 */  ori       $a3, $a3, (0x70A0280 & 0xFFFF)
/* D3894 8013D194 3C08010A */  lui       $t0, (0x10A0280 >> 16)
/* D3898 8013D198 35080280 */  ori       $t0, $t0, (0x10A0280 & 0xFFFF)
/* D389C 8013D19C 3C0A001A */  lui       $t2, (0x1A0280 >> 16)
/* D38A0 8013D1A0 354A0280 */  ori       $t2, $t2, (0x1A0280 & 0xFFFF)
/* D38A4 8013D1A4 3C09F510 */  lui       $t1, (0xF5100900 >> 16)
/* D38A8 8013D1A8 35290900 */  ori       $t1, $t1, (0xF5100900 & 0xFFFF)
/* D38AC 8013D1AC 3C0B020F */  lui       $t3, (0x20FC000 >> 16)
/* D38B0 8013D1B0 356BC000 */  ori       $t3, $t3, (0x20FC000 & 0xFFFF)
/* D38B4 8013D1B4 AFAA0028 */  sw        $t2, 0x28($sp)
/* D38B8 8013D1B8 8E050000 */  lw        $a1, 0x0($s0)
/* D38BC 8013D1BC 3C0AF200 */  lui       $t2, (0xF2000000 >> 16)
/* D38C0 8013D1C0 00A0302D */  daddu     $a2, $a1, $zero
/* D38C4 8013D1C4 24A50008 */  addiu     $a1, $a1, 0x8
/* D38C8 8013D1C8 24A20008 */  addiu     $v0, $a1, 0x8
/* D38CC 8013D1CC AE050000 */  sw        $a1, 0x0($s0)
/* D38D0 8013D1D0 AE020000 */  sw        $v0, 0x0($s0)
/* D38D4 8013D1D4 24A20010 */  addiu     $v0, $a1, 0x10
/* D38D8 8013D1D8 AE020000 */  sw        $v0, 0x0($s0)
/* D38DC 8013D1DC 24A20018 */  addiu     $v0, $a1, 0x18
/* D38E0 8013D1E0 AE020000 */  sw        $v0, 0x0($s0)
/* D38E4 8013D1E4 24A20020 */  addiu     $v0, $a1, 0x20
/* D38E8 8013D1E8 AE020000 */  sw        $v0, 0x0($s0)
/* D38EC 8013D1EC 24A20028 */  addiu     $v0, $a1, 0x28
/* D38F0 8013D1F0 AE020000 */  sw        $v0, 0x0($s0)
/* D38F4 8013D1F4 24A20030 */  addiu     $v0, $a1, 0x30
/* D38F8 8013D1F8 AE020000 */  sw        $v0, 0x0($s0)
/* D38FC 8013D1FC 3C048015 */  lui       $a0, %hi(ImgFXCurrentTexturePtr)
/* D3900 8013D200 8C84EE10 */  lw        $a0, %lo(ImgFXCurrentTexturePtr)($a0)
/* D3904 8013D204 24A20038 */  addiu     $v0, $a1, 0x38
/* D3908 8013D208 AE020000 */  sw        $v0, 0x0($s0)
/* D390C 8013D20C 94820008 */  lhu       $v0, 0x8($a0)
/* D3910 8013D210 24A30040 */  addiu     $v1, $a1, 0x40
/* D3914 8013D214 AE030000 */  sw        $v1, 0x0($s0)
/* D3918 8013D218 3C03FD48 */  lui       $v1, (0xFD480000 >> 16)
/* D391C 8013D21C 00021042 */  srl       $v0, $v0, 1
/* D3920 8013D220 2442FFFF */  addiu     $v0, $v0, -0x1
/* D3924 8013D224 30420FFF */  andi      $v0, $v0, 0xFFF
/* D3928 8013D228 00431025 */  or        $v0, $v0, $v1
/* D392C 8013D22C ACC20000 */  sw        $v0, 0x0($a2)
/* D3930 8013D230 8C830000 */  lw        $v1, 0x0($a0)
/* D3934 8013D234 24A20048 */  addiu     $v0, $a1, 0x48
/* D3938 8013D238 AE020000 */  sw        $v0, 0x0($s0)
/* D393C 8013D23C 3C02F548 */  lui       $v0, (0xF5480000 >> 16)
/* D3940 8013D240 3C04F400 */  lui       $a0, (0xF4000000 >> 16)
/* D3944 8013D244 ACC30004 */  sw        $v1, 0x4($a2)
/* D3948 8013D248 01AC3023 */  subu      $a2, $t5, $t4
/* D394C 8013D24C 00063043 */  sra       $a2, $a2, 1
/* D3950 8013D250 24C60007 */  addiu     $a2, $a2, 0x7
/* D3954 8013D254 000630C3 */  sra       $a2, $a2, 3
/* D3958 8013D258 30C601FF */  andi      $a2, $a2, 0x1FF
/* D395C 8013D25C 00063240 */  sll       $a2, $a2, 9
/* D3960 8013D260 00C21025 */  or        $v0, $a2, $v0
/* D3964 8013D264 ACA20000 */  sw        $v0, 0x0($a1)
/* D3968 8013D268 3C02E600 */  lui       $v0, (0xE6000000 >> 16)
/* D396C 8013D26C 000C1840 */  sll       $v1, $t4, 1
/* D3970 8013D270 30630FFF */  andi      $v1, $v1, 0xFFF
/* D3974 8013D274 00031B00 */  sll       $v1, $v1, 12
/* D3978 8013D278 ACA20008 */  sw        $v0, 0x8($a1)
/* D397C 8013D27C 000F1080 */  sll       $v0, $t7, 2
/* D3980 8013D280 30420FFF */  andi      $v0, $v0, 0xFFF
/* D3984 8013D284 00441025 */  or        $v0, $v0, $a0
/* D3988 8013D288 00621825 */  or        $v1, $v1, $v0
/* D398C 8013D28C ACA30010 */  sw        $v1, 0x10($a1)
/* D3990 8013D290 25A3FFFF */  addiu     $v1, $t5, -0x1
/* D3994 8013D294 00031840 */  sll       $v1, $v1, 1
/* D3998 8013D298 30630FFF */  andi      $v1, $v1, 0xFFF
/* D399C 8013D29C 00031B00 */  sll       $v1, $v1, 12
/* D39A0 8013D2A0 25C2FFFF */  addiu     $v0, $t6, -0x1
/* D39A4 8013D2A4 00021080 */  sll       $v0, $v0, 2
/* D39A8 8013D2A8 30420FFF */  andi      $v0, $v0, 0xFFF
/* D39AC 8013D2AC 3C040700 */  lui       $a0, (0x7000000 >> 16)
/* D39B0 8013D2B0 00441025 */  or        $v0, $v0, $a0
/* D39B4 8013D2B4 00621825 */  or        $v1, $v1, $v0
/* D39B8 8013D2B8 3C02F540 */  lui       $v0, (0xF5400000 >> 16)
/* D39BC 8013D2BC 00C23025 */  or        $a2, $a2, $v0
/* D39C0 8013D2C0 ACA30014 */  sw        $v1, 0x14($a1)
/* D39C4 8013D2C4 25830100 */  addiu     $v1, $t4, 0x100
/* D39C8 8013D2C8 00031880 */  sll       $v1, $v1, 2
/* D39CC 8013D2CC 30630FFF */  andi      $v1, $v1, 0xFFF
/* D39D0 8013D2D0 00031B00 */  sll       $v1, $v1, 12
/* D39D4 8013D2D4 25E20100 */  addiu     $v0, $t7, 0x100
/* D39D8 8013D2D8 00021080 */  sll       $v0, $v0, 2
/* D39DC 8013D2DC 30420FFF */  andi      $v0, $v0, 0xFFF
/* D39E0 8013D2E0 004A1025 */  or        $v0, $v0, $t2
/* D39E4 8013D2E4 00621825 */  or        $v1, $v1, $v0
/* D39E8 8013D2E8 ACA30028 */  sw        $v1, 0x28($a1)
/* D39EC 8013D2EC 25A300FF */  addiu     $v1, $t5, 0xFF
/* D39F0 8013D2F0 00031880 */  sll       $v1, $v1, 2
/* D39F4 8013D2F4 30630FFF */  andi      $v1, $v1, 0xFFF
/* D39F8 8013D2F8 00031B00 */  sll       $v1, $v1, 12
/* D39FC 8013D2FC 25C200FF */  addiu     $v0, $t6, 0xFF
/* D3A00 8013D300 00021080 */  sll       $v0, $v0, 2
/* D3A04 8013D304 30420FFF */  andi      $v0, $v0, 0xFFF
/* D3A08 8013D308 3C040100 */  lui       $a0, (0x1000000 >> 16)
/* D3A0C 8013D30C 00441025 */  or        $v0, $v0, $a0
/* D3A10 8013D310 00621825 */  or        $v1, $v1, $v0
/* D3A14 8013D314 ACA70004 */  sw        $a3, 0x4($a1)
/* D3A18 8013D318 ACA0000C */  sw        $zero, 0xC($a1)
/* D3A1C 8013D31C ACBE0018 */  sw        $fp, 0x18($a1)
/* D3A20 8013D320 ACA0001C */  sw        $zero, 0x1C($a1)
/* D3A24 8013D324 ACA60020 */  sw        $a2, 0x20($a1)
/* D3A28 8013D328 ACA80024 */  sw        $t0, 0x24($a1)
/* D3A2C 8013D32C ACA3002C */  sw        $v1, 0x2C($a1)
/* D3A30 8013D330 ACA60030 */  sw        $a2, 0x30($a1)
/* D3A34 8013D334 8FAA0028 */  lw        $t2, 0x28($sp)
/* D3A38 8013D338 3C020200 */  lui       $v0, (0x2000000 >> 16)
/* D3A3C 8013D33C ACAA0034 */  sw        $t2, 0x34($a1)
/* D3A40 8013D340 3C0AF200 */  lui       $t2, (0xF2000000 >> 16)
/* D3A44 8013D344 ACA90038 */  sw        $t1, 0x38($a1)
/* D3A48 8013D348 ACA2003C */  sw        $v0, 0x3C($a1)
/* D3A4C 8013D34C ACAA0040 */  sw        $t2, 0x40($a1)
/* D3A50 8013D350 ACAB0044 */  sw        $t3, 0x44($a1)
/* D3A54 8013D354 92230002 */  lbu       $v1, 0x2($s1)
/* D3A58 8013D358 10760008 */  beq       $v1, $s6, .L8013D37C
/* D3A5C 8013D35C 240800FF */   addiu    $t0, $zero, 0xFF
/* D3A60 8013D360 28620003 */  slti      $v0, $v1, 0x3
/* D3A64 8013D364 14400008 */  bnez      $v0, .L8013D388
/* D3A68 8013D368 24020007 */   addiu    $v0, $zero, 0x7
/* D3A6C 8013D36C 10620005 */  beq       $v1, $v0, .L8013D384
/* D3A70 8013D370 2402000F */   addiu    $v0, $zero, 0xF
/* D3A74 8013D374 14620004 */  bne       $v1, $v0, .L8013D388
/* D3A78 8013D378 00000000 */   nop
.L8013D37C:
/* D3A7C 8013D37C 0804F4E2 */  j         .L8013D388
/* D3A80 8013D380 8E280038 */   lw       $t0, 0x38($s1)
.L8013D384:
/* D3A84 8013D384 2408FFFF */  addiu     $t0, $zero, -0x1
.L8013D388:
/* D3A88 8013D388 3C028015 */  lui       $v0, %hi(gSpriteShadingProfile)
/* D3A8C 8013D38C 8C421328 */  lw        $v0, %lo(gSpriteShadingProfile)($v0)
/* D3A90 8013D390 94420000 */  lhu       $v0, 0x0($v0)
/* D3A94 8013D394 30420002 */  andi      $v0, $v0, 0x2
/* D3A98 8013D398 1040005E */  beqz      $v0, .L8013D514
/* D3A9C 8013D39C 0180282D */   daddu    $a1, $t4, $zero
/* D3AA0 8013D3A0 3C028015 */  lui       $v0, %hi(ImgFXInstances)
/* D3AA4 8013D3A4 8C426954 */  lw        $v0, %lo(ImgFXInstances)($v0)
/* D3AA8 8013D3A8 90420000 */  lbu       $v0, 0x0($v0)
/* D3AAC 8013D3AC 1040005A */  beqz      $v0, .L8013D518
/* D3AB0 8013D3B0 01E0302D */   daddu    $a2, $t7, $zero
/* D3AB4 8013D3B4 8E220014 */  lw        $v0, 0x14($s1)
/* D3AB8 8013D3B8 00581024 */  and       $v0, $v0, $t8
/* D3ABC 8013D3BC 50400057 */  beql      $v0, $zero, .L8013D51C
/* D3AC0 8013D3C0 AFAE0010 */   sw       $t6, 0x10($sp)
/* D3AC4 8013D3C4 3C03800A */  lui       $v1, %hi(gCurrentCamID)
/* D3AC8 8013D3C8 8463A634 */  lh        $v1, %lo(gCurrentCamID)($v1)
/* D3ACC 8013D3CC 00031080 */  sll       $v0, $v1, 2
/* D3AD0 8013D3D0 00431021 */  addu      $v0, $v0, $v1
/* D3AD4 8013D3D4 00021080 */  sll       $v0, $v0, 2
/* D3AD8 8013D3D8 00431023 */  subu      $v0, $v0, $v1
/* D3ADC 8013D3DC 000218C0 */  sll       $v1, $v0, 3
/* D3AE0 8013D3E0 00431021 */  addu      $v0, $v0, $v1
/* D3AE4 8013D3E4 3C038007 */  lui       $v1, %hi(gGameStatusPtr)
/* D3AE8 8013D3E8 8C63419C */  lw        $v1, %lo(gGameStatusPtr)($v1)
/* D3AEC 8013D3EC 000210C0 */  sll       $v0, $v0, 3
/* D3AF0 8013D3F0 80630070 */  lb        $v1, 0x70($v1)
/* D3AF4 8013D3F4 14760008 */  bne       $v1, $s6, .L8013D418
/* D3AF8 8013D3F8 00592021 */   addu     $a0, $v0, $t9
/* D3AFC 8013D3FC 8E020000 */  lw        $v0, 0x0($s0)
/* D3B00 8013D400 0040182D */  daddu     $v1, $v0, $zero
/* D3B04 8013D404 24420008 */  addiu     $v0, $v0, 0x8
/* D3B08 8013D408 AE020000 */  sw        $v0, 0x0($s0)
/* D3B0C 8013D40C AC730000 */  sw        $s3, 0x0($v1)
/* D3B10 8013D410 0804F50D */  j         .L8013D434
/* D3B14 8013D414 AC770004 */   sw       $s7, 0x4($v1)
.L8013D418:
/* D3B18 8013D418 8E020000 */  lw        $v0, 0x0($s0)
/* D3B1C 8013D41C 0040182D */  daddu     $v1, $v0, $zero
/* D3B20 8013D420 24420008 */  addiu     $v0, $v0, 0x8
/* D3B24 8013D424 AE020000 */  sw        $v0, 0x0($s0)
/* D3B28 8013D428 248200B0 */  addiu     $v0, $a0, 0xB0
/* D3B2C 8013D42C AC730000 */  sw        $s3, 0x0($v1)
/* D3B30 8013D430 AC620004 */  sw        $v0, 0x4($v1)
.L8013D434:
/* D3B34 8013D434 8E050000 */  lw        $a1, 0x0($s0)
/* D3B38 8013D438 00A0202D */  daddu     $a0, $a1, $zero
/* D3B3C 8013D43C 24A50008 */  addiu     $a1, $a1, 0x8
/* D3B40 8013D440 AE050000 */  sw        $a1, 0x0($s0)
/* D3B44 8013D444 AC940000 */  sw        $s4, 0x0($a0)
/* D3B48 8013D448 8E220078 */  lw        $v0, 0x78($s1)
/* D3B4C 8013D44C 3C030C08 */  lui       $v1, (0xC080000 >> 16)
/* D3B50 8013D450 00431025 */  or        $v0, $v0, $v1
/* D3B54 8013D454 AC820004 */  sw        $v0, 0x4($a0)
/* D3B58 8013D458 2402FFFF */  addiu     $v0, $zero, -0x1
/* D3B5C 8013D45C 15020009 */  bne       $t0, $v0, .L8013D484
/* D3B60 8013D460 3C03FCFF */   lui      $v1, (0xFCFFD5FF >> 16)
/* D3B64 8013D464 3C02FCFF */  lui       $v0, (0xFCFFC5FF >> 16)
/* D3B68 8013D468 3442C5FF */  ori       $v0, $v0, (0xFCFFC5FF & 0xFFFF)
/* D3B6C 8013D46C 24A30008 */  addiu     $v1, $a1, 0x8
/* D3B70 8013D470 AE030000 */  sw        $v1, 0x0($s0)
/* D3B74 8013D474 ACA20000 */  sw        $v0, 0x0($a1)
/* D3B78 8013D478 2402FFF8 */  addiu     $v0, $zero, -0x8
/* D3B7C 8013D47C 0804F52D */  j         .L8013D4B4
/* D3B80 8013D480 ACA20004 */   sw       $v0, 0x4($a1)
.L8013D484:
/* D3B84 8013D484 3463D5FF */  ori       $v1, $v1, (0xFCFFD5FF & 0xFFFF)
/* D3B88 8013D488 24A20008 */  addiu     $v0, $a1, 0x8
/* D3B8C 8013D48C AE020000 */  sw        $v0, 0x0($s0)
/* D3B90 8013D490 3C02FB00 */  lui       $v0, (0xFB000000 >> 16)
/* D3B94 8013D494 ACA20000 */  sw        $v0, 0x0($a1)
/* D3B98 8013D498 310200FF */  andi      $v0, $t0, 0xFF
/* D3B9C 8013D49C ACA20004 */  sw        $v0, 0x4($a1)
/* D3BA0 8013D4A0 24A20010 */  addiu     $v0, $a1, 0x10
/* D3BA4 8013D4A4 AE020000 */  sw        $v0, 0x0($s0)
/* D3BA8 8013D4A8 2402FFF8 */  addiu     $v0, $zero, -0x8
/* D3BAC 8013D4AC ACA30008 */  sw        $v1, 0x8($a1)
/* D3BB0 8013D4B0 ACA2000C */  sw        $v0, 0xC($a1)
.L8013D4B4:
/* D3BB4 8013D4B4 3C050100 */  lui       $a1, (0x1004008 >> 16)
/* D3BB8 8013D4B8 34A54008 */  ori       $a1, $a1, (0x1004008 & 0xFFFF)
/* D3BBC 8013D4BC 3C070600 */  lui       $a3, (0x6000402 >> 16)
/* D3BC0 8013D4C0 34E70402 */  ori       $a3, $a3, (0x6000402 & 0xFFFF)
/* D3BC4 8013D4C4 3C060002 */  lui       $a2, (0x20406 >> 16)
/* D3BC8 8013D4C8 34C60406 */  ori       $a2, $a2, (0x20406 & 0xFFFF)
/* D3BCC 8013D4CC 8E030000 */  lw        $v1, 0x0($s0)
/* D3BD0 8013D4D0 3C028015 */  lui       $v0, %hi(imgfx_vtxBuf)
/* D3BD4 8013D4D4 8C426950 */  lw        $v0, %lo(imgfx_vtxBuf)($v0)
/* D3BD8 8013D4D8 0060202D */  daddu     $a0, $v1, $zero
/* D3BDC 8013D4DC 24630008 */  addiu     $v1, $v1, 0x8
/* D3BE0 8013D4E0 00521021 */  addu      $v0, $v0, $s2
/* D3BE4 8013D4E4 AE030000 */  sw        $v1, 0x0($s0)
/* D3BE8 8013D4E8 AC820004 */  sw        $v0, 0x4($a0)
/* D3BEC 8013D4EC 24620008 */  addiu     $v0, $v1, 0x8
/* D3BF0 8013D4F0 AC850000 */  sw        $a1, 0x0($a0)
/* D3BF4 8013D4F4 AE020000 */  sw        $v0, 0x0($s0)
/* D3BF8 8013D4F8 24620010 */  addiu     $v0, $v1, 0x10
/* D3BFC 8013D4FC AC670000 */  sw        $a3, 0x0($v1)
/* D3C00 8013D500 AC660004 */  sw        $a2, 0x4($v1)
/* D3C04 8013D504 AE020000 */  sw        $v0, 0x0($s0)
/* D3C08 8013D508 AC7E0008 */  sw        $fp, 0x8($v1)
/* D3C0C 8013D50C AC60000C */  sw        $zero, 0xC($v1)
/* D3C10 8013D510 0180282D */  daddu     $a1, $t4, $zero
.L8013D514:
/* D3C14 8013D514 01E0302D */  daddu     $a2, $t7, $zero
.L8013D518:
/* D3C18 8013D518 AFAE0010 */  sw        $t6, 0x10($sp)
.L8013D51C:
/* D3C1C 8013D51C AFA80014 */  sw        $t0, 0x14($sp)
/* D3C20 8013D520 8E220078 */  lw        $v0, 0x78($s1)
/* D3C24 8013D524 8FA4005C */  lw        $a0, 0x5C($sp)
/* D3C28 8013D528 01A0382D */  daddu     $a3, $t5, $zero
/* D3C2C 8013D52C AFB80020 */  sw        $t8, 0x20($sp)
/* D3C30 8013D530 AFB90024 */  sw        $t9, 0x24($sp)
/* D3C34 8013D534 0C052071 */  jal       create_shading_palette
/* D3C38 8013D538 AFA20018 */   sw       $v0, 0x18($sp)
/* D3C3C 8013D53C 8FB80020 */  lw        $t8, 0x20($sp)
/* D3C40 8013D540 0804F64E */  j         .L8013D938
/* D3C44 8013D544 8FB90024 */   lw       $t9, 0x24($sp)
.L8013D548:
/* D3C48 8013D548 34C60280 */  ori       $a2, $a2, (0x70A0280 & 0xFFFF)
.L8013D54C:
/* D3C4C 8013D54C 3C07000A */  lui       $a3, (0xA0280 >> 16)
/* D3C50 8013D550 34E70280 */  ori       $a3, $a3, (0xA0280 & 0xFFFF)
/* D3C54 8013D554 8E080000 */  lw        $t0, 0x0($s0)
/* D3C58 8013D558 3C0AF200 */  lui       $t2, (0xF2000000 >> 16)
/* D3C5C 8013D55C 0100282D */  daddu     $a1, $t0, $zero
/* D3C60 8013D560 25080008 */  addiu     $t0, $t0, 0x8
/* D3C64 8013D564 25020008 */  addiu     $v0, $t0, 0x8
/* D3C68 8013D568 AE080000 */  sw        $t0, 0x0($s0)
/* D3C6C 8013D56C AE020000 */  sw        $v0, 0x0($s0)
/* D3C70 8013D570 25020010 */  addiu     $v0, $t0, 0x10
/* D3C74 8013D574 AE020000 */  sw        $v0, 0x0($s0)
/* D3C78 8013D578 3C048015 */  lui       $a0, %hi(ImgFXCurrentTexturePtr)
/* D3C7C 8013D57C 8C84EE10 */  lw        $a0, %lo(ImgFXCurrentTexturePtr)($a0)
/* D3C80 8013D580 25020018 */  addiu     $v0, $t0, 0x18
/* D3C84 8013D584 AE020000 */  sw        $v0, 0x0($s0)
/* D3C88 8013D588 94820008 */  lhu       $v0, 0x8($a0)
/* D3C8C 8013D58C 25030020 */  addiu     $v1, $t0, 0x20
/* D3C90 8013D590 AE030000 */  sw        $v1, 0x0($s0)
/* D3C94 8013D594 3C03FD48 */  lui       $v1, (0xFD480000 >> 16)
/* D3C98 8013D598 00021042 */  srl       $v0, $v0, 1
/* D3C9C 8013D59C 2442FFFF */  addiu     $v0, $v0, -0x1
/* D3CA0 8013D5A0 30420FFF */  andi      $v0, $v0, 0xFFF
/* D3CA4 8013D5A4 00431025 */  or        $v0, $v0, $v1
/* D3CA8 8013D5A8 ACA20000 */  sw        $v0, 0x0($a1)
/* D3CAC 8013D5AC 8C830000 */  lw        $v1, 0x0($a0)
/* D3CB0 8013D5B0 25020028 */  addiu     $v0, $t0, 0x28
/* D3CB4 8013D5B4 AE020000 */  sw        $v0, 0x0($s0)
/* D3CB8 8013D5B8 3C02F548 */  lui       $v0, (0xF5480000 >> 16)
/* D3CBC 8013D5BC 3C04F400 */  lui       $a0, (0xF4000000 >> 16)
/* D3CC0 8013D5C0 ACA30004 */  sw        $v1, 0x4($a1)
/* D3CC4 8013D5C4 01AC2823 */  subu      $a1, $t5, $t4
/* D3CC8 8013D5C8 00052843 */  sra       $a1, $a1, 1
/* D3CCC 8013D5CC 24A50007 */  addiu     $a1, $a1, 0x7
/* D3CD0 8013D5D0 000528C3 */  sra       $a1, $a1, 3
/* D3CD4 8013D5D4 30A501FF */  andi      $a1, $a1, 0x1FF
/* D3CD8 8013D5D8 00052A40 */  sll       $a1, $a1, 9
/* D3CDC 8013D5DC 00A21025 */  or        $v0, $a1, $v0
/* D3CE0 8013D5E0 AD020000 */  sw        $v0, 0x0($t0)
/* D3CE4 8013D5E4 3C02E600 */  lui       $v0, (0xE6000000 >> 16)
/* D3CE8 8013D5E8 000C1840 */  sll       $v1, $t4, 1
/* D3CEC 8013D5EC 30630FFF */  andi      $v1, $v1, 0xFFF
/* D3CF0 8013D5F0 00031B00 */  sll       $v1, $v1, 12
/* D3CF4 8013D5F4 AD020008 */  sw        $v0, 0x8($t0)
/* D3CF8 8013D5F8 000F1080 */  sll       $v0, $t7, 2
/* D3CFC 8013D5FC 30420FFF */  andi      $v0, $v0, 0xFFF
/* D3D00 8013D600 00441025 */  or        $v0, $v0, $a0
/* D3D04 8013D604 00621825 */  or        $v1, $v1, $v0
/* D3D08 8013D608 AD030010 */  sw        $v1, 0x10($t0)
/* D3D0C 8013D60C 25A3FFFF */  addiu     $v1, $t5, -0x1
/* D3D10 8013D610 00031840 */  sll       $v1, $v1, 1
/* D3D14 8013D614 30630FFF */  andi      $v1, $v1, 0xFFF
/* D3D18 8013D618 00031B00 */  sll       $v1, $v1, 12
/* D3D1C 8013D61C 25C2FFFF */  addiu     $v0, $t6, -0x1
/* D3D20 8013D620 00021080 */  sll       $v0, $v0, 2
/* D3D24 8013D624 30420FFF */  andi      $v0, $v0, 0xFFF
/* D3D28 8013D628 3C040700 */  lui       $a0, (0x7000000 >> 16)
/* D3D2C 8013D62C 00441025 */  or        $v0, $v0, $a0
/* D3D30 8013D630 00621825 */  or        $v1, $v1, $v0
/* D3D34 8013D634 3C02F540 */  lui       $v0, (0xF5400000 >> 16)
/* D3D38 8013D638 00A22825 */  or        $a1, $a1, $v0
/* D3D3C 8013D63C AD030014 */  sw        $v1, 0x14($t0)
/* D3D40 8013D640 25830100 */  addiu     $v1, $t4, 0x100
/* D3D44 8013D644 00031880 */  sll       $v1, $v1, 2
/* D3D48 8013D648 30630FFF */  andi      $v1, $v1, 0xFFF
/* D3D4C 8013D64C 00031B00 */  sll       $v1, $v1, 12
/* D3D50 8013D650 25E20100 */  addiu     $v0, $t7, 0x100
/* D3D54 8013D654 00021080 */  sll       $v0, $v0, 2
/* D3D58 8013D658 30420FFF */  andi      $v0, $v0, 0xFFF
/* D3D5C 8013D65C 004A1025 */  or        $v0, $v0, $t2
/* D3D60 8013D660 00621825 */  or        $v1, $v1, $v0
/* D3D64 8013D664 AD030028 */  sw        $v1, 0x28($t0)
/* D3D68 8013D668 25A300FF */  addiu     $v1, $t5, 0xFF
/* D3D6C 8013D66C 00031880 */  sll       $v1, $v1, 2
/* D3D70 8013D670 30630FFF */  andi      $v1, $v1, 0xFFF
/* D3D74 8013D674 00031B00 */  sll       $v1, $v1, 12
/* D3D78 8013D678 25C200FF */  addiu     $v0, $t6, 0xFF
/* D3D7C 8013D67C 00021080 */  sll       $v0, $v0, 2
/* D3D80 8013D680 30420FFF */  andi      $v0, $v0, 0xFFF
/* D3D84 8013D684 3C048015 */  lui       $a0, %hi(gSpriteShadingProfile)
/* D3D88 8013D688 8C841328 */  lw        $a0, %lo(gSpriteShadingProfile)($a0)
/* D3D8C 8013D68C 00621825 */  or        $v1, $v1, $v0
/* D3D90 8013D690 AD060004 */  sw        $a2, 0x4($t0)
/* D3D94 8013D694 AD00000C */  sw        $zero, 0xC($t0)
/* D3D98 8013D698 AD1E0018 */  sw        $fp, 0x18($t0)
/* D3D9C 8013D69C AD00001C */  sw        $zero, 0x1C($t0)
/* D3DA0 8013D6A0 AD050020 */  sw        $a1, 0x20($t0)
/* D3DA4 8013D6A4 AD070024 */  sw        $a3, 0x24($t0)
/* D3DA8 8013D6A8 AD03002C */  sw        $v1, 0x2C($t0)
/* D3DAC 8013D6AC 94830000 */  lhu       $v1, 0x0($a0)
/* D3DB0 8013D6B0 25020030 */  addiu     $v0, $t0, 0x30
/* D3DB4 8013D6B4 30630002 */  andi      $v1, $v1, 0x2
/* D3DB8 8013D6B8 106000D8 */  beqz      $v1, .L8013DA1C
/* D3DBC 8013D6BC AE020000 */   sw       $v0, 0x0($s0)
/* D3DC0 8013D6C0 92220000 */  lbu       $v0, 0x0($s1)
/* D3DC4 8013D6C4 1040009C */  beqz      $v0, .L8013D938
/* D3DC8 8013D6C8 00000000 */   nop
/* D3DCC 8013D6CC 8E220014 */  lw        $v0, 0x14($s1)
/* D3DD0 8013D6D0 00581024 */  and       $v0, $v0, $t8
/* D3DD4 8013D6D4 10400098 */  beqz      $v0, .L8013D938
/* D3DD8 8013D6D8 240900FF */   addiu    $t1, $zero, 0xFF
/* D3DDC 8013D6DC 3C03800A */  lui       $v1, %hi(gCurrentCamID)
/* D3DE0 8013D6E0 8463A634 */  lh        $v1, %lo(gCurrentCamID)($v1)
/* D3DE4 8013D6E4 00031080 */  sll       $v0, $v1, 2
/* D3DE8 8013D6E8 00431021 */  addu      $v0, $v0, $v1
/* D3DEC 8013D6EC 00021080 */  sll       $v0, $v0, 2
/* D3DF0 8013D6F0 00431023 */  subu      $v0, $v0, $v1
/* D3DF4 8013D6F4 000218C0 */  sll       $v1, $v0, 3
/* D3DF8 8013D6F8 00431021 */  addu      $v0, $v0, $v1
/* D3DFC 8013D6FC 3C038007 */  lui       $v1, %hi(gGameStatusPtr)
/* D3E00 8013D700 8C63419C */  lw        $v1, %lo(gGameStatusPtr)($v1)
/* D3E04 8013D704 000210C0 */  sll       $v0, $v0, 3
/* D3E08 8013D708 80630070 */  lb        $v1, 0x70($v1)
/* D3E0C 8013D70C 14760006 */  bne       $v1, $s6, .L8013D728
/* D3E10 8013D710 00592021 */   addu     $a0, $v0, $t9
/* D3E14 8013D714 25020038 */  addiu     $v0, $t0, 0x38
/* D3E18 8013D718 AE020000 */  sw        $v0, 0x0($s0)
/* D3E1C 8013D71C AD130030 */  sw        $s3, 0x30($t0)
/* D3E20 8013D720 0804F5CF */  j         .L8013D73C
/* D3E24 8013D724 AD170034 */   sw       $s7, 0x34($t0)
.L8013D728:
/* D3E28 8013D728 25020038 */  addiu     $v0, $t0, 0x38
/* D3E2C 8013D72C AE020000 */  sw        $v0, 0x0($s0)
/* D3E30 8013D730 248200B0 */  addiu     $v0, $a0, 0xB0
/* D3E34 8013D734 AD130030 */  sw        $s3, 0x30($t0)
/* D3E38 8013D738 AD020034 */  sw        $v0, 0x34($t0)
.L8013D73C:
/* D3E3C 8013D73C 240200FF */  addiu     $v0, $zero, 0xFF
/* D3E40 8013D740 55220005 */  bnel      $t1, $v0, .L8013D758
/* D3E44 8013D744 3C020050 */   lui      $v0, (0x504A50 >> 16)
/* D3E48 8013D748 3C020055 */  lui       $v0, (0x554A50 >> 16)
/* D3E4C 8013D74C 8E030000 */  lw        $v1, 0x0($s0)
/* D3E50 8013D750 0804F5D8 */  j         .L8013D760
/* D3E54 8013D754 34423078 */   ori      $v0, $v0, (0x553078 & 0xFFFF)
.L8013D758:
/* D3E58 8013D758 8E030000 */  lw        $v1, 0x0($s0)
/* D3E5C 8013D75C 34424A50 */  ori       $v0, $v0, (0x554A50 & 0xFFFF)
.L8013D760:
/* D3E60 8013D760 0060202D */  daddu     $a0, $v1, $zero
/* D3E64 8013D764 24630008 */  addiu     $v1, $v1, 0x8
/* D3E68 8013D768 AE030000 */  sw        $v1, 0x0($s0)
/* D3E6C 8013D76C AC940000 */  sw        $s4, 0x0($a0)
/* D3E70 8013D770 AC820004 */  sw        $v0, 0x4($a0)
/* D3E74 8013D774 92230002 */  lbu       $v1, 0x2($s1)
/* D3E78 8013D778 1076000F */  beq       $v1, $s6, .L8013D7B8
/* D3E7C 8013D77C 28620003 */   slti     $v0, $v1, 0x3
/* D3E80 8013D780 10400005 */  beqz      $v0, .L8013D798
/* D3E84 8013D784 24020007 */   addiu    $v0, $zero, 0x7
/* D3E88 8013D788 10600009 */  beqz      $v1, .L8013D7B0
/* D3E8C 8013D78C 2402FFFF */   addiu    $v0, $zero, -0x1
/* D3E90 8013D790 0804F5F3 */  j         .L8013D7CC
/* D3E94 8013D794 00000000 */   nop
.L8013D798:
/* D3E98 8013D798 1062000A */  beq       $v1, $v0, .L8013D7C4
/* D3E9C 8013D79C 2402000F */   addiu    $v0, $zero, 0xF
/* D3EA0 8013D7A0 10620005 */  beq       $v1, $v0, .L8013D7B8
/* D3EA4 8013D7A4 2402FFFF */   addiu    $v0, $zero, -0x1
/* D3EA8 8013D7A8 0804F5F3 */  j         .L8013D7CC
/* D3EAC 8013D7AC 00000000 */   nop
.L8013D7B0:
/* D3EB0 8013D7B0 0804F5F2 */  j         .L8013D7C8
/* D3EB4 8013D7B4 240900FF */   addiu    $t1, $zero, 0xFF
.L8013D7B8:
/* D3EB8 8013D7B8 8E290038 */  lw        $t1, 0x38($s1)
/* D3EBC 8013D7BC 0804F5F3 */  j         .L8013D7CC
/* D3EC0 8013D7C0 2402FFFF */   addiu    $v0, $zero, -0x1
.L8013D7C4:
/* D3EC4 8013D7C4 2409FFFF */  addiu     $t1, $zero, -0x1
.L8013D7C8:
/* D3EC8 8013D7C8 2402FFFF */  addiu     $v0, $zero, -0x1
.L8013D7CC:
/* D3ECC 8013D7CC 1522000C */  bne       $t1, $v0, .L8013D800
/* D3ED0 8013D7D0 3C06FCFF */   lui      $a2, (0xFCFFD3FF >> 16)
/* D3ED4 8013D7D4 3C05FCFF */  lui       $a1, (0xFCFFC3FF >> 16)
/* D3ED8 8013D7D8 34A5C3FF */  ori       $a1, $a1, (0xFCFFC3FF & 0xFFFF)
/* D3EDC 8013D7DC 3C04FF87 */  lui       $a0, (0xFF87FFFF >> 16)
/* D3EE0 8013D7E0 8E020000 */  lw        $v0, 0x0($s0)
/* D3EE4 8013D7E4 3484FFFF */  ori       $a0, $a0, (0xFF87FFFF & 0xFFFF)
/* D3EE8 8013D7E8 0040182D */  daddu     $v1, $v0, $zero
/* D3EEC 8013D7EC 24420008 */  addiu     $v0, $v0, 0x8
/* D3EF0 8013D7F0 AE020000 */  sw        $v0, 0x0($s0)
/* D3EF4 8013D7F4 AC650000 */  sw        $a1, 0x0($v1)
/* D3EF8 8013D7F8 0804F60F */  j         .L8013D83C
/* D3EFC 8013D7FC AC640004 */   sw       $a0, 0x4($v1)
.L8013D800:
/* D3F00 8013D800 34C6D3FF */  ori       $a2, $a2, (0xFCFFD3FF & 0xFFFF)
/* D3F04 8013D804 3C05FFA7 */  lui       $a1, (0xFFA7FFFF >> 16)
/* D3F08 8013D808 34A5FFFF */  ori       $a1, $a1, (0xFFA7FFFF & 0xFFFF)
/* D3F0C 8013D80C 8E030000 */  lw        $v1, 0x0($s0)
/* D3F10 8013D810 3C02FB00 */  lui       $v0, (0xFB000000 >> 16)
/* D3F14 8013D814 0060202D */  daddu     $a0, $v1, $zero
/* D3F18 8013D818 24630008 */  addiu     $v1, $v1, 0x8
/* D3F1C 8013D81C AE030000 */  sw        $v1, 0x0($s0)
/* D3F20 8013D820 AC820000 */  sw        $v0, 0x0($a0)
/* D3F24 8013D824 312200FF */  andi      $v0, $t1, 0xFF
/* D3F28 8013D828 AC820004 */  sw        $v0, 0x4($a0)
/* D3F2C 8013D82C 24620008 */  addiu     $v0, $v1, 0x8
/* D3F30 8013D830 AE020000 */  sw        $v0, 0x0($s0)
/* D3F34 8013D834 AC660000 */  sw        $a2, 0x0($v1)
/* D3F38 8013D838 AC650004 */  sw        $a1, 0x4($v1)
.L8013D83C:
/* D3F3C 8013D83C 3C040100 */  lui       $a0, (0x1004008 >> 16)
/* D3F40 8013D840 34844008 */  ori       $a0, $a0, (0x1004008 & 0xFFFF)
/* D3F44 8013D844 3C060600 */  lui       $a2, (0x6000402 >> 16)
/* D3F48 8013D848 34C60402 */  ori       $a2, $a2, (0x6000402 & 0xFFFF)
/* D3F4C 8013D84C 3C050002 */  lui       $a1, (0x20406 >> 16)
/* D3F50 8013D850 34A50406 */  ori       $a1, $a1, (0x20406 & 0xFFFF)
/* D3F54 8013D854 8E070000 */  lw        $a3, 0x0($s0)
/* D3F58 8013D858 3C028015 */  lui       $v0, %hi(imgfx_vtxBuf)
/* D3F5C 8013D85C 8C426950 */  lw        $v0, %lo(imgfx_vtxBuf)($v0)
/* D3F60 8013D860 00E0182D */  daddu     $v1, $a3, $zero
/* D3F64 8013D864 24E70008 */  addiu     $a3, $a3, 0x8
/* D3F68 8013D868 00521021 */  addu      $v0, $v0, $s2
/* D3F6C 8013D86C AE070000 */  sw        $a3, 0x0($s0)
/* D3F70 8013D870 AC620004 */  sw        $v0, 0x4($v1)
/* D3F74 8013D874 24E20008 */  addiu     $v0, $a3, 0x8
/* D3F78 8013D878 AC640000 */  sw        $a0, 0x0($v1)
/* D3F7C 8013D87C AE020000 */  sw        $v0, 0x0($s0)
/* D3F80 8013D880 24E20010 */  addiu     $v0, $a3, 0x10
/* D3F84 8013D884 ACE60000 */  sw        $a2, 0x0($a3)
/* D3F88 8013D888 ACE50004 */  sw        $a1, 0x4($a3)
/* D3F8C 8013D88C AE020000 */  sw        $v0, 0x0($s0)
/* D3F90 8013D890 240200FF */  addiu     $v0, $zero, 0xFF
/* D3F94 8013D894 ACFE0008 */  sw        $fp, 0x8($a3)
/* D3F98 8013D898 15220004 */  bne       $t1, $v0, .L8013D8AC
/* D3F9C 8013D89C ACE0000C */   sw       $zero, 0xC($a3)
/* D3FA0 8013D8A0 3C030055 */  lui       $v1, (0x553078 >> 16)
/* D3FA4 8013D8A4 0804F62D */  j         .L8013D8B4
/* D3FA8 8013D8A8 34633078 */   ori      $v1, $v1, (0x553078 & 0xFFFF)
.L8013D8AC:
/* D3FAC 8013D8AC 3C030050 */  lui       $v1, (0x504A50 >> 16)
/* D3FB0 8013D8B0 34634A50 */  ori       $v1, $v1, (0x504A50 & 0xFFFF)
.L8013D8B4:
/* D3FB4 8013D8B4 24E20018 */  addiu     $v0, $a3, 0x18
/* D3FB8 8013D8B8 AE020000 */  sw        $v0, 0x0($s0)
/* D3FBC 8013D8BC ACF40010 */  sw        $s4, 0x10($a3)
/* D3FC0 8013D8C0 ACE30014 */  sw        $v1, 0x14($a3)
/* D3FC4 8013D8C4 3C056464 */  lui       $a1, (0x646464FF >> 16)
/* D3FC8 8013D8C8 34A564FF */  ori       $a1, $a1, (0x646464FF & 0xFFFF)
/* D3FCC 8013D8CC 3C07FC40 */  lui       $a3, (0xFC40FE81 >> 16)
/* D3FD0 8013D8D0 34E7FE81 */  ori       $a3, $a3, (0xFC40FE81 & 0xFFFF)
/* D3FD4 8013D8D4 3C0655FC */  lui       $a2, (0x55FCF279 >> 16)
/* D3FD8 8013D8D8 34C6F279 */  ori       $a2, $a2, (0x55FCF279 & 0xFFFF)
/* D3FDC 8013D8DC 3C08E300 */  lui       $t0, (0xE3001801 >> 16)
/* D3FE0 8013D8E0 35081801 */  ori       $t0, $t0, (0xE3001801 & 0xFFFF)
/* D3FE4 8013D8E4 8E030000 */  lw        $v1, 0x0($s0)
/* D3FE8 8013D8E8 3C02FB00 */  lui       $v0, (0xFB000000 >> 16)
/* D3FEC 8013D8EC 0060202D */  daddu     $a0, $v1, $zero
/* D3FF0 8013D8F0 24630008 */  addiu     $v1, $v1, 0x8
/* D3FF4 8013D8F4 AE030000 */  sw        $v1, 0x0($s0)
/* D3FF8 8013D8F8 AC820000 */  sw        $v0, 0x0($a0)
/* D3FFC 8013D8FC 24620008 */  addiu     $v0, $v1, 0x8
/* D4000 8013D900 AC850004 */  sw        $a1, 0x4($a0)
/* D4004 8013D904 AE020000 */  sw        $v0, 0x0($s0)
/* D4008 8013D908 3C02FA00 */  lui       $v0, (0xFA000000 >> 16)
/* D400C 8013D90C AC620000 */  sw        $v0, 0x0($v1)
/* D4010 8013D910 312200FF */  andi      $v0, $t1, 0xFF
/* D4014 8013D914 AC620004 */  sw        $v0, 0x4($v1)
/* D4018 8013D918 24620010 */  addiu     $v0, $v1, 0x10
/* D401C 8013D91C AE020000 */  sw        $v0, 0x0($s0)
/* D4020 8013D920 24620018 */  addiu     $v0, $v1, 0x18
/* D4024 8013D924 AC670008 */  sw        $a3, 0x8($v1)
/* D4028 8013D928 AC66000C */  sw        $a2, 0xC($v1)
/* D402C 8013D92C AE020000 */  sw        $v0, 0x0($s0)
/* D4030 8013D930 AC680010 */  sw        $t0, 0x10($v1)
/* D4034 8013D934 AC600014 */  sw        $zero, 0x14($v1)
.L8013D938:
/* D4038 8013D938 3C028015 */  lui       $v0, %hi(gSpriteShadingProfile)
/* D403C 8013D93C 8C421328 */  lw        $v0, %lo(gSpriteShadingProfile)($v0)
/* D4040 8013D940 94420000 */  lhu       $v0, 0x0($v0)
/* D4044 8013D944 30420002 */  andi      $v0, $v0, 0x2
/* D4048 8013D948 10400035 */  beqz      $v0, .L8013DA20
/* D404C 8013D94C 3C050100 */   lui      $a1, (0x1004008 >> 16)
/* D4050 8013D950 3C028015 */  lui       $v0, %hi(ImgFXInstances)
/* D4054 8013D954 8C426954 */  lw        $v0, %lo(ImgFXInstances)($v0)
/* D4058 8013D958 90420000 */  lbu       $v0, 0x0($v0)
/* D405C 8013D95C 10400031 */  beqz      $v0, .L8013DA24
/* D4060 8013D960 34A54008 */   ori      $a1, $a1, (0x1004008 & 0xFFFF)
/* D4064 8013D964 8E220014 */  lw        $v0, 0x14($s1)
/* D4068 8013D968 00581024 */  and       $v0, $v0, $t8
/* D406C 8013D96C 1040002C */  beqz      $v0, .L8013DA20
/* D4070 8013D970 3C050100 */   lui      $a1, (0x1004008 >> 16)
/* D4074 8013D974 3C03800A */  lui       $v1, %hi(gCurrentCamID)
/* D4078 8013D978 8463A634 */  lh        $v1, %lo(gCurrentCamID)($v1)
/* D407C 8013D97C 3C058007 */  lui       $a1, %hi(gGameStatusPtr)
/* D4080 8013D980 8CA5419C */  lw        $a1, %lo(gGameStatusPtr)($a1)
/* D4084 8013D984 00031080 */  sll       $v0, $v1, 2
/* D4088 8013D988 00431021 */  addu      $v0, $v0, $v1
/* D408C 8013D98C 00021080 */  sll       $v0, $v0, 2
/* D4090 8013D990 00431023 */  subu      $v0, $v0, $v1
/* D4094 8013D994 000218C0 */  sll       $v1, $v0, 3
/* D4098 8013D998 00431021 */  addu      $v0, $v0, $v1
/* D409C 8013D99C 000210C0 */  sll       $v0, $v0, 3
/* D40A0 8013D9A0 80A30070 */  lb        $v1, 0x70($a1)
/* D40A4 8013D9A4 14760016 */  bne       $v1, $s6, .L8013DA00
/* D40A8 8013D9A8 00592021 */   addu     $a0, $v0, $t9
/* D40AC 8013D9AC 8E020000 */  lw        $v0, 0x0($s0)
/* D40B0 8013D9B0 3C048015 */  lui       $a0, %hi(D_8014EE40)
/* D40B4 8013D9B4 2484EE40 */  addiu     $a0, $a0, %lo(D_8014EE40)
/* D40B8 8013D9B8 0040182D */  daddu     $v1, $v0, $zero
/* D40BC 8013D9BC 24420008 */  addiu     $v0, $v0, 0x8
/* D40C0 8013D9C0 AE020000 */  sw        $v0, 0x0($s0)
/* D40C4 8013D9C4 AC730000 */  sw        $s3, 0x0($v1)
/* D40C8 8013D9C8 AC640004 */  sw        $a0, 0x4($v1)
/* D40CC 8013D9CC 90A20082 */  lbu       $v0, 0x82($a1)
/* D40D0 8013D9D0 94830008 */  lhu       $v1, 0x8($a0)
/* D40D4 8013D9D4 00021600 */  sll       $v0, $v0, 24
/* D40D8 8013D9D8 00021603 */  sra       $v0, $v0, 24
/* D40DC 8013D9DC 00621821 */  addu      $v1, $v1, $v0
/* D40E0 8013D9E0 A6E30008 */  sh        $v1, 0x8($s7)
/* D40E4 8013D9E4 90A20083 */  lbu       $v0, 0x83($a1)
/* D40E8 8013D9E8 9483000A */  lhu       $v1, 0xA($a0)
/* D40EC 8013D9EC 00021600 */  sll       $v0, $v0, 24
/* D40F0 8013D9F0 00021603 */  sra       $v0, $v0, 24
/* D40F4 8013D9F4 00621821 */  addu      $v1, $v1, $v0
/* D40F8 8013D9F8 0804F687 */  j         .L8013DA1C
/* D40FC 8013D9FC A6E3000A */   sh       $v1, 0xA($s7)
.L8013DA00:
/* D4100 8013DA00 8E020000 */  lw        $v0, 0x0($s0)
/* D4104 8013DA04 0040182D */  daddu     $v1, $v0, $zero
/* D4108 8013DA08 24420008 */  addiu     $v0, $v0, 0x8
/* D410C 8013DA0C AE020000 */  sw        $v0, 0x0($s0)
/* D4110 8013DA10 248200A0 */  addiu     $v0, $a0, 0xA0
/* D4114 8013DA14 AC730000 */  sw        $s3, 0x0($v1)
/* D4118 8013DA18 AC620004 */  sw        $v0, 0x4($v1)
.L8013DA1C:
/* D411C 8013DA1C 3C050100 */  lui       $a1, (0x1004008 >> 16)
.L8013DA20:
/* D4120 8013DA20 34A54008 */  ori       $a1, $a1, (0x1004008 & 0xFFFF)
.L8013DA24:
/* D4124 8013DA24 3C070600 */  lui       $a3, (0x6000402 >> 16)
/* D4128 8013DA28 34E70402 */  ori       $a3, $a3, (0x6000402 & 0xFFFF)
/* D412C 8013DA2C 3C060002 */  lui       $a2, (0x20406 >> 16)
/* D4130 8013DA30 34C60406 */  ori       $a2, $a2, (0x20406 & 0xFFFF)
/* D4134 8013DA34 8E030000 */  lw        $v1, 0x0($s0)
/* D4138 8013DA38 3C028015 */  lui       $v0, %hi(imgfx_vtxBuf)
/* D413C 8013DA3C 8C426950 */  lw        $v0, %lo(imgfx_vtxBuf)($v0)
/* D4140 8013DA40 0060202D */  daddu     $a0, $v1, $zero
/* D4144 8013DA44 24630008 */  addiu     $v1, $v1, 0x8
/* D4148 8013DA48 00521021 */  addu      $v0, $v0, $s2
/* D414C 8013DA4C AE030000 */  sw        $v1, 0x0($s0)
/* D4150 8013DA50 AC820004 */  sw        $v0, 0x4($a0)
/* D4154 8013DA54 24620008 */  addiu     $v0, $v1, 0x8
/* D4158 8013DA58 AC850000 */  sw        $a1, 0x0($a0)
/* D415C 8013DA5C AE020000 */  sw        $v0, 0x0($s0)
/* D4160 8013DA60 AC670000 */  sw        $a3, 0x0($v1)
/* D4164 8013DA64 AC660004 */  sw        $a2, 0x4($v1)
/* D4168 8013DA68 9623000A */  lhu       $v1, 0xA($s1)
/* D416C 8013DA6C 26A20003 */  addiu     $v0, $s5, 0x3
/* D4170 8013DA70 0043102A */  slt       $v0, $v0, $v1
/* D4174 8013DA74 10400003 */  beqz      $v0, .L8013DA84
/* D4178 8013DA78 26520020 */   addiu    $s2, $s2, 0x20
/* D417C 8013DA7C 0804F439 */  j         .L8013D0E4
/* D4180 8013DA80 26B50002 */   addiu    $s5, $s5, 0x2
.L8013DA84:
/* D4184 8013DA84 8FBF0054 */  lw        $ra, 0x54($sp)
/* D4188 8013DA88 8FBE0050 */  lw        $fp, 0x50($sp)
/* D418C 8013DA8C 8FB7004C */  lw        $s7, 0x4C($sp)
/* D4190 8013DA90 8FB60048 */  lw        $s6, 0x48($sp)
/* D4194 8013DA94 8FB50044 */  lw        $s5, 0x44($sp)
/* D4198 8013DA98 8FB40040 */  lw        $s4, 0x40($sp)
/* D419C 8013DA9C 8FB3003C */  lw        $s3, 0x3C($sp)
/* D41A0 8013DAA0 8FB20038 */  lw        $s2, 0x38($sp)
/* D41A4 8013DAA4 8FB10034 */  lw        $s1, 0x34($sp)
/* D41A8 8013DAA8 8FB00030 */  lw        $s0, 0x30($sp)
/* D41AC 8013DAAC 03E00008 */  jr        $ra
/* D41B0 8013DAB0 27BD0058 */   addiu    $sp, $sp, 0x58

### DECOMPILED C INSTRUCTIONS:

void imgfx_appendGfx_mesh_basic(ImgFXState* state, Matrix4f mtx) {
    s32 i;

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

    i = state->firstVtxIdx;

    while (TRUE) {
        Camera* cam;
        s32 uls = (imgfx_vtxBuf[i + 0].v.tc[0] >> 0x5) - 256;
        s32 ult = (imgfx_vtxBuf[i + 0].v.tc[1] >> 0x5) - 256;
        s32 lrs = (imgfx_vtxBuf[i + 3].v.tc[0] >> 0x5) - 256;
        s32 lrt = (imgfx_vtxBuf[i + 3].v.tc[1] >> 0x5) - 256;
        s32 someFlags = IMGFX_FLAG_100000 | IMGFX_FLAG_80000;
        s32 alpha;
        s32 alpha2;

        if (!(state->flags & IMGFX_FLAG_SKIP_TEX_SETUP)) {
            if ((gSpriteShadingProfile->flags & 1)
                && (state->arrayIdx != 0)
                && (state->flags & someFlags)
                && (   state->renderType == IMGFX_RENDER_DEFAULT
                    || state->renderType == IMGFX_RENDER_MULTIPLY_ALPHA
                    || state->renderType == IMGFX_RENDER_OVERLAY_RGBA
                    || state->renderType == IMGFX_RENDER_MULTIPLY_SHADE_ALPHA)
            ) {
                gDPScrollMultiTile2_4b(gMainGfxPos++,
                    ImgFXCurrentTexturePtr->tex.raster, G_IM_FMT_CI,
                    ImgFXCurrentTexturePtr->tex.width, ImgFXCurrentTexturePtr->tex.height, // img size
                    uls, ult, // top left
                    lrs - 1, lrt - 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, 0x100, 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, 252, 0);

                alpha = 255;
                switch (state->renderType) {
                    case IMGFX_RENDER_DEFAULT:
                        break;
                    case IMGFX_RENDER_MULTIPLY_ALPHA:
                    case IMGFX_RENDER_OVERLAY_RGBA:
                        alpha = state->ints.color.a;
                        break;
                    case IMGFX_RENDER_MULTIPLY_SHADE_ALPHA:
                        alpha = -1;
                        break;
                }

                if ((gSpriteShadingProfile->flags & 2) && ((*ImgFXInstances)[0].arrayIdx != 0) && (state->flags & someFlags)) {
                    cam = &gCameras[gCurrentCamID];

                    if (gGameStatusPtr->isBattle == 2) {
                        gSPViewport(gMainGfxPos++, &D_8014EE50);
                    } else {
                        gSPViewport(gMainGfxPos++, &cam->vpAlt);
                    }

                    gDPSetRenderMode(gMainGfxPos++, G_RM_PASS, state->otherModeL);

                    if (alpha == -1) {
                        gDPSetCombineMode(gMainGfxPos++, PM_CC_0D, PM_CC_0C);
                    } else {
                        gDPSetEnvColor(gMainGfxPos++, 0, 0, 0, alpha);
                        gDPSetCombineMode(gMainGfxPos++, PM_CC_0B, PM_CC_0C);
                    }

                    gSPVertex(gMainGfxPos++, &imgfx_vtxBuf[i], 4, 0);
                    gSP2Triangles(gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
                    gDPPipeSync(gMainGfxPos++);
                }
                create_shading_palette(mtx, uls, ult, lrs, lrt, alpha, state->otherModeL);
            } else {
                gDPScrollTextureTile_4b(gMainGfxPos++,
                    ImgFXCurrentTexturePtr->tex.raster, G_IM_FMT_CI,
                    ImgFXCurrentTexturePtr->tex.width, ImgFXCurrentTexturePtr->tex.height, // img size
                    uls, ult, // top left
                    lrs - 1, lrt - 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

                if ((gSpriteShadingProfile->flags & 2) && state->arrayIdx != 0 && (state->flags & someFlags)) {
                    alpha2 = 255;
                    cam = &gCameras[gCurrentCamID];

                    if (gGameStatusPtr->isBattle == 2) {
                        gSPViewport(gMainGfxPos++, &D_8014EE50);
                    } else {
                        gSPViewport(gMainGfxPos++, &cam->vpAlt);
                    }

                    if (alpha2 == 255) {
                        gDPSetRenderMode(gMainGfxPos++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2);
                    } else {
                        gDPSetRenderMode(gMainGfxPos++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2);
                    }

                    switch (state->renderType) {
                        case IMGFX_RENDER_DEFAULT:
                            alpha2 = 255;
                            break;
                        case IMGFX_RENDER_MULTIPLY_ALPHA:
                        case IMGFX_RENDER_OVERLAY_RGBA:
                            alpha2 = state->ints.color.a;
                            break;
                        case IMGFX_RENDER_MULTIPLY_SHADE_ALPHA:
                            alpha2 = -1;
                            break;
                    }

                    if (alpha2 == -1) {
                        gDPSetCombineLERP(gMainGfxPos++, 0, 0, 0, 0, SHADE, 0, TEXEL0, 0, 0, 0, 0, 0, SHADE, 0, TEXEL0, 0);
                    } else {
                        gDPSetEnvColor(gMainGfxPos++, 0, 0, 0, alpha2);
                        gDPSetCombineMode(gMainGfxPos++, PM_CC_0A, PM_CC_0A);
                    }

                    gSPVertex(gMainGfxPos++, &imgfx_vtxBuf[i], 4, 0);
                    gSP2Triangles(gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
                    gDPPipeSync(gMainGfxPos++);

                    if (alpha2 == 255) {
                        gDPSetRenderMode(gMainGfxPos++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2);
                    } else {
                        gDPSetRenderMode(gMainGfxPos++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2);
                    }

                    gDPSetEnvColor(gMainGfxPos++, 100, 100, 100, 255);
                    gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, alpha2);
                    gDPSetCombineLERP(gMainGfxPos++, SHADE, ENVIRONMENT, TEXEL0, TEXEL0, 0, 0, 0, TEXEL0, SHADE, ENVIRONMENT, TEXEL0, TEXEL0, 0, 0, 0, TEXEL0);
                    gDPSetColorDither(gMainGfxPos++, G_CD_MAGICSQ);
                }
            }
        }

        if ((gSpriteShadingProfile->flags & 2) && (*ImgFXInstances)[0].arrayIdx != 0 && (state->flags & someFlags)) {
            cam = &gCameras[gCurrentCamID];
            if (gGameStatusPtr->isBattle == 2) {
                gSPViewport(gMainGfxPos++, &D_8014EE40);
                D_8014EE50.vp.vtrans[0] = D_8014EE40.vp.vtrans[0] + gGameStatusPtr->unk_82;
                D_8014EE50.vp.vtrans[1] = D_8014EE40.vp.vtrans[1] + gGameStatusPtr->unk_83;
            } else {
                gSPViewport(gMainGfxPos++, &cam->vp);
            }
        }

        gSPVertex(gMainGfxPos++, &imgfx_vtxBuf[i], 4, 0);
        gSP2Triangles(gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);

        if (i + 3 >= state->lastVtxIdx) {
            break;
        }

        i += 2;
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel _update_message
/* B9F98 80123898 27BDFFE0 */  addiu     $sp, $sp, -0x20
/* B9F9C 8012389C AFB00010 */  sw        $s0, 0x10($sp)
/* B9FA0 801238A0 0080802D */  daddu     $s0, $a0, $zero
/* B9FA4 801238A4 AFBF0018 */  sw        $ra, 0x18($sp)
/* B9FA8 801238A8 AFB10014 */  sw        $s1, 0x14($sp)
/* B9FAC 801238AC 96020452 */  lhu       $v0, 0x452($s0)
/* B9FB0 801238B0 24420001 */  addiu     $v0, $v0, 0x1
/* B9FB4 801238B4 A6020452 */  sh        $v0, 0x452($s0)
/* B9FB8 801238B8 3042FFFF */  andi      $v0, $v0, 0xFFFF
/* B9FBC 801238BC 2C420E10 */  sltiu     $v0, $v0, 0xE10
/* B9FC0 801238C0 50400001 */  beql      $v0, $zero, .L801238C8
/* B9FC4 801238C4 A6000452 */   sh       $zero, 0x452($s0)
.L801238C8:
/* B9FC8 801238C8 8602050A */  lh        $v0, 0x50A($s0)
/* B9FCC 801238CC 3C014064 */  lui       $at, (0x40640000 >> 16)
/* B9FD0 801238D0 44811800 */  mtc1      $at, $f3
/* B9FD4 801238D4 44801000 */  mtc1      $zero, $f2
/* B9FD8 801238D8 44820000 */  mtc1      $v0, $f0
/* B9FDC 801238DC 00000000 */  nop
/* B9FE0 801238E0 46800020 */  cvt.s.w   $f0, $f0
/* B9FE4 801238E4 46000021 */  cvt.d.s   $f0, $f0
/* B9FE8 801238E8 46220001 */  sub.d     $f0, $f0, $f2
/* B9FEC 801238EC 3C018015 */  lui       $at, %hi(D_80150370)
/* B9FF0 801238F0 D4220370 */  ldc1      $f2, %lo(D_80150370)($at)
/* B9FF4 801238F4 3C014050 */  lui       $at, (0x40500000 >> 16)
/* B9FF8 801238F8 44812800 */  mtc1      $at, $f5
/* B9FFC 801238FC 44802000 */  mtc1      $zero, $f4
/* BA000 80123900 46220003 */  div.d     $f0, $f0, $f2
/* BA004 80123904 46240000 */  add.d     $f0, $f0, $f4
/* BA008 80123908 46200120 */  cvt.s.d   $f4, $f0
/* BA00C 8012390C 3C014014 */  lui       $at, (0x40140000 >> 16)
/* BA010 80123910 44810800 */  mtc1      $at, $f1
/* BA014 80123914 44800000 */  mtc1      $zero, $f0
/* BA018 80123918 460020A1 */  cvt.d.s   $f2, $f4
/* BA01C 8012391C 4620103C */  c.lt.d    $f2, $f0
/* BA020 80123920 00000000 */  nop
/* BA024 80123924 45000005 */  bc1f      .L8012393C
/* BA028 80123928 00000000 */   nop
/* BA02C 8012392C 3C0140A0 */  lui       $at, (0x40A00000 >> 16)
/* BA030 80123930 44812000 */  mtc1      $at, $f4
/* BA034 80123934 08048E57 */  j         .L8012395C
/* BA038 80123938 00000000 */   nop
.L8012393C:
/* BA03C 8012393C 3C018015 */  lui       $at, %hi(D_80150378)
/* BA040 80123940 D4200378 */  ldc1      $f0, %lo(D_80150378)($at)
/* BA044 80123944 4622003C */  c.lt.d    $f0, $f2
/* BA048 80123948 00000000 */  nop
/* BA04C 8012394C 45000003 */  bc1f      .L8012395C
/* BA050 80123950 00000000 */   nop
/* BA054 80123954 3C0142F4 */  lui       $at, (0x42F40000 >> 16)
/* BA058 80123958 44812000 */  mtc1      $at, $f4
.L8012395C:
/* BA05C 8012395C 3C014F00 */  lui       $at, (0x4F000000 >> 16)
/* BA060 80123960 44810000 */  mtc1      $at, $f0
/* BA064 80123964 00000000 */  nop
/* BA068 80123968 4604003E */  c.le.s    $f0, $f4
/* BA06C 8012396C 00000000 */  nop
/* BA070 80123970 45010005 */  bc1t      .L80123988
/* BA074 80123974 2604051A */   addiu    $a0, $s0, 0x51A
/* BA078 80123978 4600218D */  trunc.w.s $f6, $f4
/* BA07C 8012397C 44033000 */  mfc1      $v1, $f6
/* BA080 80123980 08048E69 */  j         .L801239A4
/* BA084 80123984 A0830000 */   sb       $v1, 0x0($a0)
.L80123988:
/* BA088 80123988 46002001 */  sub.s     $f0, $f4, $f0
/* BA08C 8012398C 3C028000 */  lui       $v0, (0x80000000 >> 16)
/* BA090 80123990 4600018D */  trunc.w.s $f6, $f0
/* BA094 80123994 44033000 */  mfc1      $v1, $f6
/* BA098 80123998 00000000 */  nop
/* BA09C 8012399C 00621825 */  or        $v1, $v1, $v0
/* BA0A0 801239A0 A0830000 */  sb        $v1, 0x0($a0)
.L801239A4:
/* BA0A4 801239A4 8E0604FC */  lw        $a2, 0x4FC($s0)
/* BA0A8 801239A8 30C20040 */  andi      $v0, $a2, 0x40
/* BA0AC 801239AC 144001F1 */  bnez      $v0, .L80124174
/* BA0B0 801239B0 0000882D */   daddu    $s1, $zero, $zero
/* BA0B4 801239B4 30C20030 */  andi      $v0, $a2, 0x30
/* BA0B8 801239B8 144000F3 */  bnez      $v0, .L80123D88
/* BA0BC 801239BC 30C20020 */   andi     $v0, $a2, 0x20
/* BA0C0 801239C0 920304F8 */  lbu       $v1, 0x4F8($s0)
/* BA0C4 801239C4 24020007 */  addiu     $v0, $zero, 0x7
/* BA0C8 801239C8 1062008D */  beq       $v1, $v0, .L80123C00
/* BA0CC 801239CC 34078000 */   ori      $a3, $zero, 0x8000
/* BA0D0 801239D0 28620008 */  slti      $v0, $v1, 0x8
/* BA0D4 801239D4 10400005 */  beqz      $v0, .L801239EC
/* BA0D8 801239D8 24020005 */   addiu    $v0, $zero, 0x5
/* BA0DC 801239DC 1062000A */  beq       $v1, $v0, .L80123A08
/* BA0E0 801239E0 3C020008 */   lui      $v0, (0x80000 >> 16)
/* BA0E4 801239E4 08048F72 */  j         .L80123DC8
/* BA0E8 801239E8 00000000 */   nop
.L801239EC:
/* BA0EC 801239EC 24020008 */  addiu     $v0, $zero, 0x8
/* BA0F0 801239F0 106200D9 */  beq       $v1, $v0, .L80123D58
/* BA0F4 801239F4 2402000C */   addiu    $v0, $zero, 0xC
/* BA0F8 801239F8 1062004F */  beq       $v1, $v0, .L80123B38
/* BA0FC 801239FC 00000000 */   nop
/* BA100 80123A00 08048F72 */  j         .L80123DC8
/* BA104 80123A04 00000000 */   nop
.L80123A08:
/* BA108 80123A08 00C21024 */  and       $v0, $a2, $v0
/* BA10C 80123A0C 54400001 */  bnel      $v0, $zero, .L80123A14
/* BA110 80123A10 34078004 */   ori      $a3, $zero, 0x8004
.L80123A14:
/* BA114 80123A14 3C038007 */  lui       $v1, %hi(gGameStatusPtr)
/* BA118 80123A18 2463419C */  addiu     $v1, $v1, %lo(gGameStatusPtr)
/* BA11C 80123A1C 8C640000 */  lw        $a0, 0x0($v1)
/* BA120 80123A20 8C850010 */  lw        $a1, 0x10($a0)
/* BA124 80123A24 00E51024 */  and       $v0, $a3, $a1
/* BA128 80123A28 14400005 */  bnez      $v0, .L80123A40
/* BA12C 80123A2C 00000000 */   nop
/* BA130 80123A30 8C820000 */  lw        $v0, 0x0($a0)
/* BA134 80123A34 30424000 */  andi      $v0, $v0, 0x4000
/* BA138 80123A38 1040002F */  beqz      $v0, .L80123AF8
/* BA13C 80123A3C 30A22000 */   andi     $v0, $a1, 0x2000
.L80123A40:
/* BA140 80123A40 8E0404FC */  lw        $a0, 0x4FC($s0)
/* BA144 80123A44 24020004 */  addiu     $v0, $zero, 0x4
/* BA148 80123A48 A20204F8 */  sb        $v0, 0x4F8($s0)
/* BA14C 80123A4C A600000E */  sh        $zero, 0xE($s0)
/* BA150 80123A50 8C630000 */  lw        $v1, 0x0($v1)
/* BA154 80123A54 34820004 */  ori       $v0, $a0, 0x4
/* BA158 80123A58 AE0204FC */  sw        $v0, 0x4FC($s0)
/* BA15C 80123A5C 8C620010 */  lw        $v0, 0x10($v1)
/* BA160 80123A60 30428004 */  andi      $v0, $v0, 0x8004
/* BA164 80123A64 10400003 */  beqz      $v0, .L80123A74
/* BA168 80123A68 00000000 */   nop
/* BA16C 80123A6C 08048EB7 */  j         .L80123ADC
/* BA170 80123A70 24110001 */   addiu    $s1, $zero, 0x1
.L80123A74:
/* BA174 80123A74 9603000C */  lhu       $v1, 0xC($s0)
/* BA178 80123A78 8E020000 */  lw        $v0, 0x0($s0)
/* BA17C 80123A7C 00431021 */  addu      $v0, $v0, $v1
/* BA180 80123A80 90430000 */  lbu       $v1, 0x0($v0)
/* BA184 80123A84 240200FD */  addiu     $v0, $zero, 0xFD
/* BA188 80123A88 1062000F */  beq       $v1, $v0, .L80123AC8
/* BA18C 80123A8C 34820104 */   ori      $v0, $a0, 0x104
/* BA190 80123A90 92030455 */  lbu       $v1, 0x455($s0)
/* BA194 80123A94 14600008 */  bnez      $v1, .L80123AB8
/* BA198 80123A98 AE0204FC */   sw       $v0, 0x4FC($s0)
/* BA19C 80123A9C 9603000C */  lhu       $v1, 0xC($s0)
/* BA1A0 80123AA0 8E020000 */  lw        $v0, 0x0($s0)
/* BA1A4 80123AA4 00431021 */  addu      $v0, $v0, $v1
/* BA1A8 80123AA8 90430000 */  lbu       $v1, 0x0($v0)
/* BA1AC 80123AAC 240200C3 */  addiu     $v0, $zero, 0xC3
/* BA1B0 80123AB0 5062000B */  beql      $v1, $v0, .L80123AE0
/* BA1B4 80123AB4 240400CC */   addiu    $a0, $zero, 0xCC
.L80123AB8:
/* BA1B8 80123AB8 34820184 */  ori       $v0, $a0, 0x184
/* BA1BC 80123ABC AE0204FC */  sw        $v0, 0x4FC($s0)
/* BA1C0 80123AC0 08048EB8 */  j         .L80123AE0
/* BA1C4 80123AC4 240400CC */   addiu    $a0, $zero, 0xCC
.L80123AC8:
/* BA1C8 80123AC8 92020508 */  lbu       $v0, 0x508($s0)
/* BA1CC 80123ACC 2442FFFF */  addiu     $v0, $v0, -0x1
/* BA1D0 80123AD0 2C420004 */  sltiu     $v0, $v0, 0x4
/* BA1D4 80123AD4 104000BC */  beqz      $v0, .L80123DC8
/* BA1D8 80123AD8 00000000 */   nop
.L80123ADC:
/* BA1DC 80123ADC 240400C9 */  addiu     $a0, $zero, 0xC9
.L80123AE0:
/* BA1E0 80123AE0 0000282D */  daddu     $a1, $zero, $zero
/* BA1E4 80123AE4 00A0302D */  daddu     $a2, $a1, $zero
/* BA1E8 80123AE8 0C0526AE */  jal       sfx_play_sound_with_params
/* BA1EC 80123AEC 00A0382D */   daddu    $a3, $a1, $zero
/* BA1F0 80123AF0 08048F72 */  j         .L80123DC8
/* BA1F4 80123AF4 00000000 */   nop
.L80123AF8:
/* BA1F8 80123AF8 104000B3 */  beqz      $v0, .L80123DC8
/* BA1FC 80123AFC 3C020004 */   lui      $v0, (0x40000 >> 16)
/* BA200 80123B00 00C21024 */  and       $v0, $a2, $v0
/* BA204 80123B04 144000B0 */  bnez      $v0, .L80123DC8
/* BA208 80123B08 00000000 */   nop
/* BA20C 80123B0C 92020486 */  lbu       $v0, 0x486($s0)
/* BA210 80123B10 104000AD */  beqz      $v0, .L80123DC8
/* BA214 80123B14 240400CD */   addiu    $a0, $zero, 0xCD
/* BA218 80123B18 0000282D */  daddu     $a1, $zero, $zero
/* BA21C 80123B1C 00A0302D */  daddu     $a2, $a1, $zero
/* BA220 80123B20 92020486 */  lbu       $v0, 0x486($s0)
/* BA224 80123B24 2403000B */  addiu     $v1, $zero, 0xB
/* BA228 80123B28 A20304F8 */  sb        $v1, 0x4F8($s0)
/* BA22C 80123B2C A60004CC */  sh        $zero, 0x4CC($s0)
/* BA230 80123B30 08048EF2 */  j         .L80123BC8
/* BA234 80123B34 2442FFFF */   addiu    $v0, $v0, -0x1
.L80123B38:
/* BA238 80123B38 3C028007 */  lui       $v0, %hi(gGameStatusPtr)
/* BA23C 80123B3C 8C42419C */  lw        $v0, %lo(gGameStatusPtr)($v0)
/* BA240 80123B40 8C430010 */  lw        $v1, 0x10($v0)
/* BA244 80123B44 30624000 */  andi      $v0, $v1, 0x4000
/* BA248 80123B48 10400008 */  beqz      $v0, .L80123B6C
/* BA24C 80123B4C 240400CC */   addiu    $a0, $zero, 0xCC
/* BA250 80123B50 0000282D */  daddu     $a1, $zero, $zero
/* BA254 80123B54 00A0302D */  daddu     $a2, $a1, $zero
/* BA258 80123B58 92020486 */  lbu       $v0, 0x486($s0)
/* BA25C 80123B5C 2403000B */  addiu     $v1, $zero, 0xB
/* BA260 80123B60 A20304F8 */  sb        $v1, 0x4F8($s0)
/* BA264 80123B64 08048EF2 */  j         .L80123BC8
/* BA268 80123B68 A60004CC */   sh       $zero, 0x4CC($s0)
.L80123B6C:
/* BA26C 80123B6C 30622000 */  andi      $v0, $v1, 0x2000
/* BA270 80123B70 1040000C */  beqz      $v0, .L80123BA4
/* BA274 80123B74 30628000 */   andi     $v0, $v1, 0x8000
/* BA278 80123B78 92020487 */  lbu       $v0, 0x487($s0)
/* BA27C 80123B7C 10400092 */  beqz      $v0, .L80123DC8
/* BA280 80123B80 240400CD */   addiu    $a0, $zero, 0xCD
/* BA284 80123B84 0000282D */  daddu     $a1, $zero, $zero
/* BA288 80123B88 00A0302D */  daddu     $a2, $a1, $zero
/* BA28C 80123B8C 92020487 */  lbu       $v0, 0x487($s0)
/* BA290 80123B90 2403000B */  addiu     $v1, $zero, 0xB
/* BA294 80123B94 A20304F8 */  sb        $v1, 0x4F8($s0)
/* BA298 80123B98 A60004CC */  sh        $zero, 0x4CC($s0)
/* BA29C 80123B9C 08048EF2 */  j         .L80123BC8
/* BA2A0 80123BA0 2442FFFF */   addiu    $v0, $v0, -0x1
.L80123BA4:
/* BA2A4 80123BA4 10400088 */  beqz      $v0, .L80123DC8
/* BA2A8 80123BA8 240400CE */   addiu    $a0, $zero, 0xCE
/* BA2AC 80123BAC 0000282D */  daddu     $a1, $zero, $zero
/* BA2B0 80123BB0 00A0302D */  daddu     $a2, $a1, $zero
/* BA2B4 80123BB4 92020487 */  lbu       $v0, 0x487($s0)
/* BA2B8 80123BB8 2403000B */  addiu     $v1, $zero, 0xB
/* BA2BC 80123BBC A20304F8 */  sb        $v1, 0x4F8($s0)
/* BA2C0 80123BC0 A60004CC */  sh        $zero, 0x4CC($s0)
/* BA2C4 80123BC4 24420001 */  addiu     $v0, $v0, 0x1
.L80123BC8:
/* BA2C8 80123BC8 A2020487 */  sb        $v0, 0x487($s0)
/* BA2CC 80123BCC 304200FF */  andi      $v0, $v0, 0xFF
/* BA2D0 80123BD0 00021040 */  sll       $v0, $v0, 1
/* BA2D4 80123BD4 02021021 */  addu      $v0, $s0, $v0
/* BA2D8 80123BD8 94430488 */  lhu       $v1, 0x488($v0)
/* BA2DC 80123BDC 8E020460 */  lw        $v0, 0x460($s0)
/* BA2E0 80123BE0 00A0382D */  daddu     $a3, $a1, $zero
/* BA2E4 80123BE4 00431023 */  subu      $v0, $v0, $v1
/* BA2E8 80123BE8 04420001 */  bltzl     $v0, .L80123BF0
/* BA2EC 80123BEC 00021023 */   negu     $v0, $v0
.L80123BF0:
/* BA2F0 80123BF0 0C0526AE */  jal       sfx_play_sound_with_params
/* BA2F4 80123BF4 A60204C8 */   sh       $v0, 0x4C8($s0)
/* BA2F8 80123BF8 08048F72 */  j         .L80123DC8
/* BA2FC 80123BFC 00000000 */   nop
.L80123C00:
/* BA300 80123C00 3C028007 */  lui       $v0, %hi(gGameStatusPtr)
/* BA304 80123C04 8C42419C */  lw        $v0, %lo(gGameStatusPtr)($v0)
/* BA308 80123C08 8C440010 */  lw        $a0, 0x10($v0)
/* BA30C 80123C0C 30828000 */  andi      $v0, $a0, 0x8000
/* BA310 80123C10 1040000E */  beqz      $v0, .L80123C4C
/* BA314 80123C14 0000282D */   daddu    $a1, $zero, $zero
/* BA318 80123C18 240400C9 */  addiu     $a0, $zero, 0xC9
/* BA31C 80123C1C 00A0302D */  daddu     $a2, $a1, $zero
/* BA320 80123C20 00A0382D */  daddu     $a3, $a1, $zero
/* BA324 80123C24 24020001 */  addiu     $v0, $zero, 0x1
/* BA328 80123C28 A20204E9 */  sb        $v0, 0x4E9($s0)
/* BA32C 80123C2C 24020004 */  addiu     $v0, $zero, 0x4
/* BA330 80123C30 A20204F8 */  sb        $v0, 0x4F8($s0)
/* BA334 80123C34 8E0204FC */  lw        $v0, 0x4FC($s0)
/* BA338 80123C38 3C030002 */  lui       $v1, (0x20000 >> 16)
/* BA33C 80123C3C A20004ED */  sb        $zero, 0x4ED($s0)
/* BA340 80123C40 00431025 */  or        $v0, $v0, $v1
/* BA344 80123C44 08048F50 */  j         .L80123D40
/* BA348 80123C48 AE0204FC */   sw       $v0, 0x4FC($s0)
.L80123C4C:
/* BA34C 80123C4C 920504EA */  lbu       $a1, 0x4EA($s0)
/* BA350 80123C50 240200FF */  addiu     $v0, $zero, 0xFF
/* BA354 80123C54 30A300FF */  andi      $v1, $a1, 0xFF
/* BA358 80123C58 10620019 */  beq       $v1, $v0, .L80123CC0
/* BA35C 80123C5C 30824000 */   andi     $v0, $a0, 0x4000
/* BA360 80123C60 10400017 */  beqz      $v0, .L80123CC0
/* BA364 80123C64 00000000 */   nop
/* BA368 80123C68 920204CE */  lbu       $v0, 0x4CE($s0)
/* BA36C 80123C6C 0062102B */  sltu      $v0, $v1, $v0
/* BA370 80123C70 54400003 */  bnel      $v0, $zero, .L80123C80
/* BA374 80123C74 A20504EE */   sb       $a1, 0x4EE($s0)
/* BA378 80123C78 920204E8 */  lbu       $v0, 0x4E8($s0)
/* BA37C 80123C7C A20204EE */  sb        $v0, 0x4EE($s0)
.L80123C80:
/* BA380 80123C80 240400CA */  addiu     $a0, $zero, 0xCA
/* BA384 80123C84 0000282D */  daddu     $a1, $zero, $zero
/* BA388 80123C88 00A0302D */  daddu     $a2, $a1, $zero
/* BA38C 80123C8C 920304EA */  lbu       $v1, 0x4EA($s0)
/* BA390 80123C90 24020001 */  addiu     $v0, $zero, 0x1
/* BA394 80123C94 A20204E9 */  sb        $v0, 0x4E9($s0)
/* BA398 80123C98 24020004 */  addiu     $v0, $zero, 0x4
/* BA39C 80123C9C A20204F8 */  sb        $v0, 0x4F8($s0)
/* BA3A0 80123CA0 8E0204FC */  lw        $v0, 0x4FC($s0)
/* BA3A4 80123CA4 00A0382D */  daddu     $a3, $a1, $zero
/* BA3A8 80123CA8 A20004ED */  sb        $zero, 0x4ED($s0)
/* BA3AC 80123CAC A20304E8 */  sb        $v1, 0x4E8($s0)
/* BA3B0 80123CB0 3C030002 */  lui       $v1, (0x20000 >> 16)
/* BA3B4 80123CB4 00431025 */  or        $v0, $v0, $v1
/* BA3B8 80123CB8 08048F50 */  j         .L80123D40
/* BA3BC 80123CBC AE0204FC */   sw       $v0, 0x4FC($s0)
.L80123CC0:
/* BA3C0 80123CC0 3C028007 */  lui       $v0, %hi(gGameStatusPtr)
/* BA3C4 80123CC4 8C42419C */  lw        $v0, %lo(gGameStatusPtr)($v0)
/* BA3C8 80123CC8 8C430020 */  lw        $v1, 0x20($v0)
/* BA3CC 80123CCC 3C020002 */  lui       $v0, (0x20000 >> 16)
/* BA3D0 80123CD0 00621024 */  and       $v0, $v1, $v0
/* BA3D4 80123CD4 1040000B */  beqz      $v0, .L80123D04
/* BA3D8 80123CD8 3C020001 */   lui      $v0, (0x10000 >> 16)
/* BA3DC 80123CDC 920204CE */  lbu       $v0, 0x4CE($s0)
/* BA3E0 80123CE0 920304E8 */  lbu       $v1, 0x4E8($s0)
/* BA3E4 80123CE4 2442FFFF */  addiu     $v0, $v0, -0x1
/* BA3E8 80123CE8 10620017 */  beq       $v1, $v0, .L80123D48
/* BA3EC 80123CEC 240400C7 */   addiu    $a0, $zero, 0xC7
/* BA3F0 80123CF0 0000282D */  daddu     $a1, $zero, $zero
/* BA3F4 80123CF4 00A0302D */  daddu     $a2, $a1, $zero
/* BA3F8 80123CF8 00A0382D */  daddu     $a3, $a1, $zero
/* BA3FC 80123CFC 08048F4B */  j         .L80123D2C
/* BA400 80123D00 24620001 */   addiu    $v0, $v1, 0x1
.L80123D04:
/* BA404 80123D04 00621024 */  and       $v0, $v1, $v0
/* BA408 80123D08 1040000F */  beqz      $v0, .L80123D48
/* BA40C 80123D0C 00000000 */   nop
/* BA410 80123D10 920204E8 */  lbu       $v0, 0x4E8($s0)
/* BA414 80123D14 1040000C */  beqz      $v0, .L80123D48
/* BA418 80123D18 240400C7 */   addiu    $a0, $zero, 0xC7
/* BA41C 80123D1C 0000282D */  daddu     $a1, $zero, $zero
/* BA420 80123D20 00A0302D */  daddu     $a2, $a1, $zero
/* BA424 80123D24 00A0382D */  daddu     $a3, $a1, $zero
/* BA428 80123D28 2442FFFF */  addiu     $v0, $v0, -0x1
.L80123D2C:
/* BA42C 80123D2C A20204EC */  sb        $v0, 0x4EC($s0)
/* BA430 80123D30 24020008 */  addiu     $v0, $zero, 0x8
/* BA434 80123D34 A20204F8 */  sb        $v0, 0x4F8($s0)
/* BA438 80123D38 24020001 */  addiu     $v0, $zero, 0x1
/* BA43C 80123D3C A20204ED */  sb        $v0, 0x4ED($s0)
.L80123D40:
/* BA440 80123D40 0C0526AE */  jal       sfx_play_sound_with_params
/* BA444 80123D44 00000000 */   nop
.L80123D48:
/* BA448 80123D48 920304F8 */  lbu       $v1, 0x4F8($s0)
/* BA44C 80123D4C 24020008 */  addiu     $v0, $zero, 0x8
/* BA450 80123D50 1462001D */  bne       $v1, $v0, .L80123DC8
/* BA454 80123D54 00000000 */   nop
.L80123D58:
/* BA458 80123D58 920204ED */  lbu       $v0, 0x4ED($s0)
/* BA45C 80123D5C 24420001 */  addiu     $v0, $v0, 0x1
/* BA460 80123D60 A20204ED */  sb        $v0, 0x4ED($s0)
/* BA464 80123D64 304200FF */  andi      $v0, $v0, 0xFF
/* BA468 80123D68 2C420005 */  sltiu     $v0, $v0, 0x5
/* BA46C 80123D6C 14400016 */  bnez      $v0, .L80123DC8
/* BA470 80123D70 24020007 */   addiu    $v0, $zero, 0x7
/* BA474 80123D74 920304EC */  lbu       $v1, 0x4EC($s0)
/* BA478 80123D78 A20204F8 */  sb        $v0, 0x4F8($s0)
/* BA47C 80123D7C A20304E8 */  sb        $v1, 0x4E8($s0)
/* BA480 80123D80 08048F72 */  j         .L80123DC8
/* BA484 80123D84 A20304EE */   sb       $v1, 0x4EE($s0)
.L80123D88:
/* BA488 80123D88 1440000F */  bnez      $v0, .L80123DC8
/* BA48C 80123D8C 24020005 */   addiu    $v0, $zero, 0x5
/* BA490 80123D90 920304F8 */  lbu       $v1, 0x4F8($s0)
/* BA494 80123D94 1462000C */  bne       $v1, $v0, .L80123DC8
/* BA498 80123D98 00000000 */   nop
/* BA49C 80123D9C 3C028007 */  lui       $v0, %hi(gGameStatusPtr)
/* BA4A0 80123DA0 8C42419C */  lw        $v0, %lo(gGameStatusPtr)($v0)
/* BA4A4 80123DA4 8C420010 */  lw        $v0, 0x10($v0)
/* BA4A8 80123DA8 30428000 */  andi      $v0, $v0, 0x8000
/* BA4AC 80123DAC 10400006 */  beqz      $v0, .L80123DC8
/* BA4B0 80123DB0 24020004 */   addiu    $v0, $zero, 0x4
/* BA4B4 80123DB4 8E0304FC */  lw        $v1, 0x4FC($s0)
/* BA4B8 80123DB8 A20204F8 */  sb        $v0, 0x4F8($s0)
/* BA4BC 80123DBC A600000E */  sh        $zero, 0xE($s0)
/* BA4C0 80123DC0 34630004 */  ori       $v1, $v1, 0x4
/* BA4C4 80123DC4 AE0304FC */  sw        $v1, 0x4FC($s0)
.L80123DC8:
/* BA4C8 80123DC8 8E0304FC */  lw        $v1, 0x4FC($s0)
/* BA4CC 80123DCC 30620004 */  andi      $v0, $v1, 0x4
/* BA4D0 80123DD0 1040000B */  beqz      $v0, .L80123E00
/* BA4D4 80123DD4 0000282D */   daddu    $a1, $zero, $zero
/* BA4D8 80123DD8 3C028007 */  lui       $v0, %hi(gGameStatusPtr)
/* BA4DC 80123DDC 8C42419C */  lw        $v0, %lo(gGameStatusPtr)($v0)
/* BA4E0 80123DE0 8C420000 */  lw        $v0, 0x0($v0)
/* BA4E4 80123DE4 30428000 */  andi      $v0, $v0, 0x8000
/* BA4E8 80123DE8 14400006 */  bnez      $v0, .L80123E04
/* BA4EC 80123DEC 0200202D */   daddu    $a0, $s0, $zero
/* BA4F0 80123DF0 2402FFFB */  addiu     $v0, $zero, -0x5
/* BA4F4 80123DF4 00621024 */  and       $v0, $v1, $v0
/* BA4F8 80123DF8 AE0204FC */  sw        $v0, 0x4FC($s0)
/* BA4FC 80123DFC 0000282D */  daddu     $a1, $zero, $zero
.L80123E00:
/* BA500 80123E00 0200202D */  daddu     $a0, $s0, $zero
.L80123E04:
/* BA504 80123E04 84820474 */  lh        $v0, 0x474($a0)
/* BA508 80123E08 94830474 */  lhu       $v1, 0x474($a0)
/* BA50C 80123E0C 18400003 */  blez      $v0, .L80123E1C
/* BA510 80123E10 24A50001 */   addiu    $a1, $a1, 0x1
/* BA514 80123E14 2462FFFF */  addiu     $v0, $v1, -0x1
/* BA518 80123E18 A4820474 */  sh        $v0, 0x474($a0)
.L80123E1C:
/* BA51C 80123E1C 28A20004 */  slti      $v0, $a1, 0x4
/* BA520 80123E20 1440FFF8 */  bnez      $v0, .L80123E04
/* BA524 80123E24 24840002 */   addiu    $a0, $a0, 0x2
/* BA528 80123E28 920204F8 */  lbu       $v0, 0x4F8($s0)
/* BA52C 80123E2C 2443FFFF */  addiu     $v1, $v0, -0x1
/* BA530 80123E30 2C62000E */  sltiu     $v0, $v1, 0xE
/* BA534 80123E34 104000CF */  beqz      $v0, .L80124174
/* BA538 80123E38 00031080 */   sll      $v0, $v1, 2
/* BA53C 80123E3C 3C018015 */  lui       $at, %hi(jtbl_80150380)
/* BA540 80123E40 00220821 */  addu      $at, $at, $v0
/* BA544 80123E44 8C220380 */  lw        $v0, %lo(jtbl_80150380)($at)
/* BA548 80123E48 00400008 */  jr        $v0
/* BA54C 80123E4C 00000000 */   nop
glabel .L80123E50
/* BA550 80123E50 3C028007 */  lui       $v0, %hi(gGameStatusPtr)
/* BA554 80123E54 8C42419C */  lw        $v0, %lo(gGameStatusPtr)($v0)
/* BA558 80123E58 8C430010 */  lw        $v1, 0x10($v0)
/* BA55C 80123E5C 8C420000 */  lw        $v0, 0x0($v0)
/* BA560 80123E60 30638000 */  andi      $v1, $v1, 0x8000
/* BA564 80123E64 30424000 */  andi      $v0, $v0, 0x4000
/* BA568 80123E68 00621825 */  or        $v1, $v1, $v0
/* BA56C 80123E6C 1060000B */  beqz      $v1, .L80123E9C
/* BA570 80123E70 24020001 */   addiu    $v0, $zero, 0x1
/* BA574 80123E74 8E0304FC */  lw        $v1, 0x4FC($s0)
/* BA578 80123E78 30620030 */  andi      $v0, $v1, 0x30
/* BA57C 80123E7C 14400007 */  bnez      $v0, .L80123E9C
/* BA580 80123E80 24020001 */   addiu    $v0, $zero, 0x1
/* BA584 80123E84 322200FF */  andi      $v0, $s1, 0xFF
/* BA588 80123E88 14400004 */  bnez      $v0, .L80123E9C
/* BA58C 80123E8C 24020001 */   addiu    $v0, $zero, 0x1
/* BA590 80123E90 34620100 */  ori       $v0, $v1, 0x100
/* BA594 80123E94 AE0204FC */  sw        $v0, 0x4FC($s0)
glabel .L80123E98
/* BA598 80123E98 24020001 */  addiu     $v0, $zero, 0x1
.L80123E9C:
/* BA59C 80123E9C 920304F8 */  lbu       $v1, 0x4F8($s0)
/* BA5A0 80123EA0 9205045F */  lbu       $a1, 0x45F($s0)
/* BA5A4 80123EA4 14620003 */  bne       $v1, $v0, .L80123EB4
/* BA5A8 80123EA8 24020004 */   addiu    $v0, $zero, 0x4
/* BA5AC 80123EAC 08048FBE */  j         .L80123EF8
/* BA5B0 80123EB0 A20204F8 */   sb       $v0, 0x4F8($s0)
.L80123EB4:
/* BA5B4 80123EB4 8E0304FC */  lw        $v1, 0x4FC($s0)
/* BA5B8 80123EB8 30620100 */  andi      $v0, $v1, 0x100
/* BA5BC 80123EBC 10400003 */  beqz      $v0, .L80123ECC
/* BA5C0 80123EC0 30620004 */   andi     $v0, $v1, 0x4
/* BA5C4 80123EC4 08048FBE */  j         .L80123EF8
/* BA5C8 80123EC8 2405000C */   addiu    $a1, $zero, 0xC
.L80123ECC:
/* BA5CC 80123ECC 1440000B */  bnez      $v0, .L80123EFC
/* BA5D0 80123ED0 30620030 */   andi     $v0, $v1, 0x30
/* BA5D4 80123ED4 14400009 */  bnez      $v0, .L80123EFC
/* BA5D8 80123ED8 00000000 */   nop
/* BA5DC 80123EDC 3C028007 */  lui       $v0, %hi(gGameStatusPtr)
/* BA5E0 80123EE0 8C42419C */  lw        $v0, %lo(gGameStatusPtr)($v0)
/* BA5E4 80123EE4 8C420000 */  lw        $v0, 0x0($v0)
/* BA5E8 80123EE8 30428000 */  andi      $v0, $v0, 0x8000
/* BA5EC 80123EEC 10400003 */  beqz      $v0, .L80123EFC
/* BA5F0 80123EF0 00000000 */   nop
/* BA5F4 80123EF4 24050006 */  addiu     $a1, $zero, 0x6
.L80123EF8:
/* BA5F8 80123EF8 A600000E */  sh        $zero, 0xE($s0)
.L80123EFC:
/* BA5FC 80123EFC 9602000E */  lhu       $v0, 0xE($s0)
/* BA600 80123F00 10400005 */  beqz      $v0, .L80123F18
/* BA604 80123F04 2442FFFF */   addiu    $v0, $v0, -0x1
/* BA608 80123F08 A602000E */  sh        $v0, 0xE($s0)
/* BA60C 80123F0C 3042FFFF */  andi      $v0, $v0, 0xFFFF
/* BA610 80123F10 14400098 */  bnez      $v0, .L80124174
/* BA614 80123F14 00000000 */   nop
.L80123F18:
/* BA618 80123F18 0200202D */  daddu     $a0, $s0, $zero
/* BA61C 80123F1C 0C04915C */  jal       msg_copy_to_print_buffer
/* BA620 80123F20 0000302D */   daddu    $a2, $zero, $zero
/* BA624 80123F24 0804905D */  j         .L80124174
/* BA628 80123F28 00000000 */   nop
glabel .L80123F2C
/* BA62C 80123F2C 3C028007 */  lui       $v0, %hi(gGameStatusPtr)
/* BA630 80123F30 8C42419C */  lw        $v0, %lo(gGameStatusPtr)($v0)
/* BA634 80123F34 8C420010 */  lw        $v0, 0x10($v0)
/* BA638 80123F38 3042C000 */  andi      $v0, $v0, 0xC000
/* BA63C 80123F3C 10400006 */  beqz      $v0, .L80123F58
/* BA640 80123F40 00000000 */   nop
/* BA644 80123F44 8E0304FC */  lw        $v1, 0x4FC($s0)
/* BA648 80123F48 30620030 */  andi      $v0, $v1, 0x30
/* BA64C 80123F4C 14400002 */  bnez      $v0, .L80123F58
/* BA650 80123F50 34620100 */   ori      $v0, $v1, 0x100
/* BA654 80123F54 AE0204FC */  sw        $v0, 0x4FC($s0)
.L80123F58:
/* BA658 80123F58 92030464 */  lbu       $v1, 0x464($s0)
/* BA65C 80123F5C 8E020460 */  lw        $v0, 0x460($s0)
/* BA660 80123F60 8E0404FC */  lw        $a0, 0x4FC($s0)
/* BA664 80123F64 00431821 */  addu      $v1, $v0, $v1
/* BA668 80123F68 30820100 */  andi      $v0, $a0, 0x100
/* BA66C 80123F6C 1440000A */  bnez      $v0, .L80123F98
/* BA670 80123F70 AE030460 */   sw       $v1, 0x460($s0)
/* BA674 80123F74 30820014 */  andi      $v0, $a0, 0x14
/* BA678 80123F78 14400009 */  bnez      $v0, .L80123FA0
/* BA67C 80123F7C 00000000 */   nop
/* BA680 80123F80 3C028007 */  lui       $v0, %hi(gGameStatusPtr)
/* BA684 80123F84 8C42419C */  lw        $v0, %lo(gGameStatusPtr)($v0)
/* BA688 80123F88 8C420000 */  lw        $v0, 0x0($v0)
/* BA68C 80123F8C 30428000 */  andi      $v0, $v0, 0x8000
/* BA690 80123F90 10400003 */  beqz      $v0, .L80123FA0
/* BA694 80123F94 00000000 */   nop
.L80123F98:
/* BA698 80123F98 24620006 */  addiu     $v0, $v1, 0x6
/* BA69C 80123F9C AE020460 */  sw        $v0, 0x460($s0)
.L80123FA0:
/* BA6A0 80123FA0 96030466 */  lhu       $v1, 0x466($s0)
/* BA6A4 80123FA4 8E020460 */  lw        $v0, 0x460($s0)
/* BA6A8 80123FA8 0043102A */  slt       $v0, $v0, $v1
/* BA6AC 80123FAC 14400071 */  bnez      $v0, .L80124174
/* BA6B0 80123FB0 24020004 */   addiu    $v0, $zero, 0x4
/* BA6B4 80123FB4 A20204F8 */  sb        $v0, 0x4F8($s0)
/* BA6B8 80123FB8 8E0204FC */  lw        $v0, 0x4FC($s0)
/* BA6BC 80123FBC AE030460 */  sw        $v1, 0x460($s0)
/* BA6C0 80123FC0 92030508 */  lbu       $v1, 0x508($s0)
/* BA6C4 80123FC4 34420004 */  ori       $v0, $v0, 0x4
/* BA6C8 80123FC8 2463FFF9 */  addiu     $v1, $v1, -0x7
/* BA6CC 80123FCC 2C630002 */  sltiu     $v1, $v1, 0x2
/* BA6D0 80123FD0 14600008 */  bnez      $v1, .L80123FF4
/* BA6D4 80123FD4 AE0204FC */   sw       $v0, 0x4FC($s0)
/* BA6D8 80123FD8 9603000C */  lhu       $v1, 0xC($s0)
/* BA6DC 80123FDC 8E020000 */  lw        $v0, 0x0($s0)
/* BA6E0 80123FE0 00431021 */  addu      $v0, $v0, $v1
/* BA6E4 80123FE4 90430000 */  lbu       $v1, 0x0($v0)
/* BA6E8 80123FE8 240200F1 */  addiu     $v0, $zero, 0xF1
/* BA6EC 80123FEC 14620003 */  bne       $v1, $v0, .L80123FFC
/* BA6F0 80123FF0 24020005 */   addiu    $v0, $zero, 0x5
.L80123FF4:
/* BA6F4 80123FF4 08049000 */  j         .L80124000
/* BA6F8 80123FF8 A600000E */   sh       $zero, 0xE($s0)
.L80123FFC:
/* BA6FC 80123FFC A602000E */  sh        $v0, 0xE($s0)
.L80124000:
/* BA700 80124000 92020486 */  lbu       $v0, 0x486($s0)
/* BA704 80124004 96030462 */  lhu       $v1, 0x462($s0)
/* BA708 80124008 00021040 */  sll       $v0, $v0, 1
/* BA70C 8012400C 02021021 */  addu      $v0, $s0, $v0
/* BA710 80124010 0804905D */  j         .L80124174
/* BA714 80124014 A4430488 */   sh       $v1, 0x488($v0)
glabel .L80124018
/* BA718 80124018 960204CC */  lhu       $v0, 0x4CC($s0)
/* BA71C 8012401C 92030487 */  lbu       $v1, 0x487($s0)
/* BA720 80124020 24420001 */  addiu     $v0, $v0, 0x1
/* BA724 80124024 00031840 */  sll       $v1, $v1, 1
/* BA728 80124028 02031821 */  addu      $v1, $s0, $v1
/* BA72C 8012402C A60204CC */  sh        $v0, 0x4CC($s0)
/* BA730 80124030 94620488 */  lhu       $v0, 0x488($v1)
/* BA734 80124034 8E030460 */  lw        $v1, 0x460($s0)
/* BA738 80124038 00621823 */  subu      $v1, $v1, $v0
/* BA73C 8012403C 960204C8 */  lhu       $v0, 0x4C8($s0)
/* BA740 80124040 04620001 */  bltzl     $v1, .L80124048
/* BA744 80124044 00031823 */   negu     $v1, $v1
.L80124048:
/* BA748 80124048 2C420011 */  sltiu     $v0, $v0, 0x11
/* BA74C 8012404C 10400008 */  beqz      $v0, .L80124070
/* BA750 80124050 24040002 */   addiu    $a0, $zero, 0x2
/* BA754 80124054 00031400 */  sll       $v0, $v1, 16
/* BA758 80124058 00021C03 */  sra       $v1, $v0, 16
/* BA75C 8012405C 2862000F */  slti      $v0, $v1, 0xF
/* BA760 80124060 10400018 */  beqz      $v0, .L801240C4
/* BA764 80124064 28620009 */   slti     $v0, $v1, 0x9
/* BA768 80124068 08049033 */  j         .L801240CC
/* BA76C 8012406C 00000000 */   nop
.L80124070:
/* BA770 80124070 00031400 */  sll       $v0, $v1, 16
/* BA774 80124074 00021C03 */  sra       $v1, $v0, 16
/* BA778 80124078 28620061 */  slti      $v0, $v1, 0x61
/* BA77C 8012407C 14400003 */  bnez      $v0, .L8012408C
/* BA780 80124080 28620031 */   slti     $v0, $v1, 0x31
/* BA784 80124084 08049035 */  j         .L801240D4
/* BA788 80124088 2404000A */   addiu    $a0, $zero, 0xA
.L8012408C:
/* BA78C 8012408C 14400003 */  bnez      $v0, .L8012409C
/* BA790 80124090 28620018 */   slti     $v0, $v1, 0x18
/* BA794 80124094 08049035 */  j         .L801240D4
/* BA798 80124098 24040009 */   addiu    $a0, $zero, 0x9
.L8012409C:
/* BA79C 8012409C 14400003 */  bnez      $v0, .L801240AC
/* BA7A0 801240A0 28620010 */   slti     $v0, $v1, 0x10
/* BA7A4 801240A4 08049035 */  j         .L801240D4
/* BA7A8 801240A8 24040007 */   addiu    $a0, $zero, 0x7
.L801240AC:
/* BA7AC 801240AC 14400003 */  bnez      $v0, .L801240BC
/* BA7B0 801240B0 28620008 */   slti     $v0, $v1, 0x8
/* BA7B4 801240B4 08049035 */  j         .L801240D4
/* BA7B8 801240B8 24040005 */   addiu    $a0, $zero, 0x5
.L801240BC:
/* BA7BC 801240BC 14400003 */  bnez      $v0, .L801240CC
/* BA7C0 801240C0 28620005 */   slti     $v0, $v1, 0x5
.L801240C4:
/* BA7C4 801240C4 08049035 */  j         .L801240D4
/* BA7C8 801240C8 24040004 */   addiu    $a0, $zero, 0x4
.L801240CC:
/* BA7CC 801240CC 50400001 */  beql      $v0, $zero, .L801240D4
/* BA7D0 801240D0 24040003 */   addiu    $a0, $zero, 0x3
.L801240D4:
/* BA7D4 801240D4 92020487 */  lbu       $v0, 0x487($s0)
/* BA7D8 801240D8 8E030460 */  lw        $v1, 0x460($s0)
/* BA7DC 801240DC A60404CA */  sh        $a0, 0x4CA($s0)
/* BA7E0 801240E0 00021040 */  sll       $v0, $v0, 1
/* BA7E4 801240E4 02021021 */  addu      $v0, $s0, $v0
/* BA7E8 801240E8 94420488 */  lhu       $v0, 0x488($v0)
/* BA7EC 801240EC 0043102A */  slt       $v0, $v0, $v1
/* BA7F0 801240F0 5040000E */  beql      $v0, $zero, .L8012412C
/* BA7F4 801240F4 00831821 */   addu     $v1, $a0, $v1
/* BA7F8 801240F8 92020487 */  lbu       $v0, 0x487($s0)
/* BA7FC 801240FC 00641823 */  subu      $v1, $v1, $a0
/* BA800 80124100 AE030460 */  sw        $v1, 0x460($s0)
/* BA804 80124104 00021040 */  sll       $v0, $v0, 1
/* BA808 80124108 02021021 */  addu      $v0, $s0, $v0
/* BA80C 8012410C 94420488 */  lhu       $v0, 0x488($v0)
/* BA810 80124110 0043182A */  slt       $v1, $v0, $v1
/* BA814 80124114 14600017 */  bnez      $v1, .L80124174
/* BA818 80124118 00000000 */   nop
/* BA81C 8012411C AE020460 */  sw        $v0, 0x460($s0)
/* BA820 80124120 2402000C */  addiu     $v0, $zero, 0xC
/* BA824 80124124 0804905D */  j         .L80124174
/* BA828 80124128 A20204F8 */   sb       $v0, 0x4F8($s0)
.L8012412C:
/* BA82C 8012412C 92020487 */  lbu       $v0, 0x487($s0)
/* BA830 80124130 AE030460 */  sw        $v1, 0x460($s0)
/* BA834 80124134 00021040 */  sll       $v0, $v0, 1
/* BA838 80124138 02021021 */  addu      $v0, $s0, $v0
/* BA83C 8012413C 94420488 */  lhu       $v0, 0x488($v0)
/* BA840 80124140 0062182A */  slt       $v1, $v1, $v0
/* BA844 80124144 1460000B */  bnez      $v1, .L80124174
/* BA848 80124148 00000000 */   nop
/* BA84C 8012414C 92040487 */  lbu       $a0, 0x487($s0)
/* BA850 80124150 92030486 */  lbu       $v1, 0x486($s0)
/* BA854 80124154 AE020460 */  sw        $v0, 0x460($s0)
/* BA858 80124158 2402000C */  addiu     $v0, $zero, 0xC
/* BA85C 8012415C 14830005 */  bne       $a0, $v1, .L80124174
/* BA860 80124160 A20204F8 */   sb       $v0, 0x4F8($s0)
/* BA864 80124164 24020005 */  addiu     $v0, $zero, 0x5
/* BA868 80124168 A20204F8 */  sb        $v0, 0x4F8($s0)
/* BA86C 8012416C A200047C */  sb        $zero, 0x47C($s0)
/* BA870 80124170 A600047E */  sh        $zero, 0x47E($s0)
glabel .L80124174
/* BA874 80124174 8E0204FC */  lw        $v0, 0x4FC($s0)
/* BA878 80124178 30420001 */  andi      $v0, $v0, 0x1
/* BA87C 8012417C 1040001B */  beqz      $v0, .L801241EC
/* BA880 80124180 00000000 */   nop
/* BA884 80124184 8E040544 */  lw        $a0, 0x544($s0)
/* BA888 80124188 A20004F8 */  sb        $zero, 0x4F8($s0)
/* BA88C 8012418C 10800003 */  beqz      $a0, .L8012419C
/* BA890 80124190 AE0004FC */   sw       $zero, 0x4FC($s0)
/* BA894 80124194 0C00AB1E */  jal       general_heap_free
/* BA898 80124198 00000000 */   nop
.L8012419C:
/* BA89C 8012419C 8E040548 */  lw        $a0, 0x548($s0)
/* BA8A0 801241A0 10800003 */  beqz      $a0, .L801241B0
/* BA8A4 801241A4 00000000 */   nop
/* BA8A8 801241A8 0C00AB1E */  jal       general_heap_free
/* BA8AC 801241AC 00000000 */   nop
.L801241B0:
/* BA8B0 801241B0 8E04054C */  lw        $a0, 0x54C($s0)
/* BA8B4 801241B4 10800003 */  beqz      $a0, .L801241C4
/* BA8B8 801241B8 00000000 */   nop
/* BA8BC 801241BC 0C00AB1E */  jal       general_heap_free
/* BA8C0 801241C0 00000000 */   nop
.L801241C4:
/* BA8C4 801241C4 8E040550 */  lw        $a0, 0x550($s0)
/* BA8C8 801241C8 10800003 */  beqz      $a0, .L801241D8
/* BA8CC 801241CC 00000000 */   nop
/* BA8D0 801241D0 0C00AB1E */  jal       general_heap_free
/* BA8D4 801241D4 00000000 */   nop
.L801241D8:
/* BA8D8 801241D8 8E030504 */  lw        $v1, 0x504($s0)
/* BA8DC 801241DC 10600003 */  beqz      $v1, .L801241EC
/* BA8E0 801241E0 24020001 */   addiu    $v0, $zero, 0x1
/* BA8E4 801241E4 AC620000 */  sw        $v0, 0x0($v1)
/* BA8E8 801241E8 AE000504 */  sw        $zero, 0x504($s0)
.L801241EC:
/* BA8EC 801241EC 920204F8 */  lbu       $v0, 0x4F8($s0)
/* BA8F0 801241F0 8FBF0018 */  lw        $ra, 0x18($sp)
/* BA8F4 801241F4 8FB10014 */  lw        $s1, 0x14($sp)
/* BA8F8 801241F8 8FB00010 */  lw        $s0, 0x10($sp)
/* BA8FC 801241FC 03E00008 */  jr        $ra
/* BA900 80124200 27BD0020 */   addiu    $sp, $sp, 0x20

### DECOMPILED C INSTRUCTIONS:

s32 _update_message(MessagePrintState* printer) {
    f32 speechPan;
    u8 cond;
    s32 buttons;
    s16 endPosDist;
    s16 lineIncAmt;
    s32 charsToPrint;
    s32 i;

    printer->effectFrameCounter++;
    if (printer->effectFrameCounter >= 3600) {
        printer->effectFrameCounter = 0;
    }

    speechPan = (((f32)printer->initOpenPos.x - (SCREEN_WIDTH / 2.0)) / 3.8) + 64.0;
    if (speechPan < 5.0) {
        speechPan = 5.0f;
    } else if (speechPan > 122.0) {
        speechPan = 122.0f;
    }
    printer->speechPan = speechPan;

    cond = FALSE;
    if (!(printer->stateFlags & MSG_STATE_FLAG_40)) {
        if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10))) {
            s32 buttons = BUTTON_A;

            switch (printer->windowState) {
                case MSG_WINDOW_STATE_WAITING:
                    if (printer->stateFlags & MSG_STATE_FLAG_80000) {
                        buttons = BUTTON_A | BUTTON_C_DOWN;
                    }
                    if ((buttons & gGameStatusPtr->pressedButtons[0]) || (gGameStatusPtr->currentButtons[0] & BUTTON_B)) {
                        printer->windowState = MSG_WINDOW_STATE_PRINTING;
                        printer->currentPrintDelay = 0;
                        printer->stateFlags |= MSG_STATE_FLAG_4;
                        if (gGameStatusPtr->pressedButtons[0] & (BUTTON_A | BUTTON_C_DOWN)) {
                            cond = TRUE;
                            sfx_play_sound_with_params(SOUND_MENU_NEXT, 0, 0, 0);
                        } else if (printer->srcBuffer[printer->srcBufferPos] != MSG_CHAR_READ_END) {
                            printer->stateFlags |= MSG_STATE_FLAG_PRINT_QUICKLY | MSG_STATE_FLAG_4;
                            if (printer->fontVariant != 0 || printer->srcBuffer[printer->srcBufferPos] != MSG_CHAR_UNK_C3) {
                                printer->stateFlags |= MSG_STATE_FLAG_PRINT_QUICKLY | MSG_STATE_FLAG_80 | MSG_STATE_FLAG_4;
                            }
                            sfx_play_sound_with_params(SOUND_CC, 0, 0, 0);
                        } else if (printer->style == MSG_STYLE_RIGHT ||
                                   printer->style == MSG_STYLE_LEFT ||
                                   printer->style == MSG_STYLE_CENTER ||
                                   printer->style == MSG_STYLE_TATTLE)
                        {
                            sfx_play_sound_with_params(SOUND_MENU_NEXT, 0, 0, 0);
                        }
                    } else if ((gGameStatusPtr->pressedButtons[0] & BUTTON_Z) &&
                               !(printer->stateFlags & MSG_STATE_FLAG_40000) &&
                               (printer->currentLine != 0))
                    {
                        printer->windowState = MSG_WINDOW_STATE_B;
                        printer->unk_4CC = 0;
                        printer->unkArraySize = printer->currentLine - 1;
                        printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
                        sfx_play_sound_with_params(SOUND_CD, 0, 0, 0);
                    }
                    break;
                case MSG_WINDOW_STATE_C:
                    if (gGameStatusPtr->pressedButtons[0] & BUTTON_B) {
                        printer->windowState = MSG_WINDOW_STATE_B;
                        printer->unk_4CC = 0;
                        printer->unkArraySize = printer->currentLine;
                        printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
                        sfx_play_sound_with_params(SOUND_CC, 0, 0, 0);
                    } else if (gGameStatusPtr->pressedButtons[0] & BUTTON_Z) {
                        if (printer->unkArraySize > 0) {
                            printer->windowState = MSG_WINDOW_STATE_B;
                            printer->unk_4CC = 0;
                            printer->unkArraySize--;
                            printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
                            sfx_play_sound_with_params(SOUND_CD, 0, 0, 0);
                        }
                    } else {
                        if (gGameStatusPtr->pressedButtons[0] & BUTTON_A) {
                            printer->windowState = MSG_WINDOW_STATE_B;
                            printer->unk_4CC = 0;
                            printer->unkArraySize++;
                            printer->unk_4C8 = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
                            sfx_play_sound_with_params(SOUND_CE, 0, 0, 0);
                        }
                    }
                    break;
                case MSG_WINDOW_STATE_WAITING_FOR_CHOICE:
                    if (gGameStatusPtr->pressedButtons[0] & BUTTON_A) {
                        printer->madeChoice = 1;
                        printer->windowState = MSG_WINDOW_STATE_PRINTING;
                        printer->scrollingTime = 0;
                        printer->stateFlags |= MSG_STATE_FLAG_20000;
                        sfx_play_sound_with_params(SOUND_MENU_NEXT, 0, 0, 0);
                    } else if (printer->cancelOption != 0xFF && (gGameStatusPtr->pressedButtons[0] & BUTTON_B)) {
                        if (printer->cancelOption >= printer->maxOption) {
                            printer->selectedOption = printer->currentOption;
                        } else {
                            printer->selectedOption = printer->cancelOption;
                        }
                        printer->madeChoice = 1;
                        printer->windowState = MSG_WINDOW_STATE_PRINTING;
                        printer->scrollingTime = 0;
                        printer->currentOption = printer->cancelOption;
                        printer->stateFlags |= MSG_STATE_FLAG_20000;
                        sfx_play_sound_with_params(SOUND_MENU_BACK, 0, 0, 0);
                    } else if (gGameStatusPtr->heldButtons[0] & BUTTON_STICK_DOWN) {
                        if (printer->currentOption != printer->maxOption - 1) {
                            printer->targetOption = printer->currentOption + 1;
                            printer->windowState = MSG_WINDOW_STATE_SCROLLING_BACK;
                            printer->scrollingTime = 1;
                            sfx_play_sound_with_params(SOUND_MENU_CHANGE_SELECTION, 0, 0, 0);
                        }
                    } else if (gGameStatusPtr->heldButtons[0] & BUTTON_STICK_UP) {
                        if (printer->currentOption != 0) {
                            printer->targetOption = printer->currentOption - 1;
                            printer->windowState = MSG_WINDOW_STATE_SCROLLING_BACK;
                            printer->scrollingTime = 1;
                            sfx_play_sound_with_params(SOUND_MENU_CHANGE_SELECTION, 0, 0, 0);
                        }
                    }

                    if (printer->windowState != MSG_WINDOW_STATE_SCROLLING_BACK) {
                        break;
                    }
                case MSG_WINDOW_STATE_SCROLLING_BACK:
                    printer->scrollingTime++;
                    if (printer->scrollingTime >= 5) {
                        printer->windowState = MSG_WINDOW_STATE_WAITING_FOR_CHOICE;
                        printer->currentOption = printer->targetOption;
                        printer->selectedOption = printer->currentOption;
                    }
                    break;
            }
        } else if (!(printer->stateFlags & MSG_STATE_FLAG_20) &&
                    printer->windowState == MSG_WINDOW_STATE_WAITING &&
                    (gGameStatusPtr->pressedButtons[0] & BUTTON_A))
        {
            printer->windowState = MSG_WINDOW_STATE_PRINTING;
            printer->currentPrintDelay = 0;
            printer->stateFlags |= MSG_STATE_FLAG_4;
        }

        if (printer->stateFlags & MSG_STATE_FLAG_4 && !(gGameStatusPtr->currentButtons[0] & BUTTON_A)) {
            printer->stateFlags &= ~MSG_STATE_FLAG_4;
        }

        for (i = 0; i < ARRAY_COUNT(printer->animTimers); i++) {
            if (printer->animTimers[i] > 0) {
                printer->animTimers[i]--;
            }
        }

        switch (printer->windowState) {
            case MSG_WINDOW_STATE_PRINTING:
                if ((gGameStatusPtr->pressedButtons[0] & BUTTON_A) | (gGameStatusPtr->currentButtons[0] & BUTTON_B)) {
                    if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10)) && !cond) {
                        printer->stateFlags |= MSG_STATE_FLAG_PRINT_QUICKLY;

                    }
                }
            // fallthrough
            case MSG_WINDOW_STATE_INIT:
                charsToPrint = printer->charsPerChunk;
                if (printer->windowState == MSG_WINDOW_STATE_INIT) {
                    printer->windowState = MSG_WINDOW_STATE_PRINTING;
                    printer->currentPrintDelay = 0;
                } else if (printer->stateFlags & MSG_STATE_FLAG_PRINT_QUICKLY) {
                    charsToPrint = 12;
                    printer->currentPrintDelay = 0;
                } else if (!(printer->stateFlags & MSG_STATE_FLAG_4)) {
                    if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10)) &&
                        (gGameStatusPtr->currentButtons[0] & BUTTON_A))
                    {
                        charsToPrint = 6;
                        printer->currentPrintDelay = 0;
                    }
                }
                if ((printer->currentPrintDelay == 0) || --printer->currentPrintDelay == 0) {
                    msg_copy_to_print_buffer(printer, charsToPrint, 0);
                }
                break;
            case MSG_WINDOW_STATE_SCROLLING:
                if (gGameStatusPtr->pressedButtons[0] & (BUTTON_A | BUTTON_B)) {
                    if (!(printer->stateFlags & (MSG_STATE_FLAG_20 | MSG_STATE_FLAG_10))) {
                        printer->stateFlags |= MSG_STATE_FLAG_PRINT_QUICKLY;
                    }
                }
                printer->curLinePos += printer->unk_464;
                if ((printer->stateFlags & MSG_STATE_FLAG_PRINT_QUICKLY) ||
                    (!(printer->stateFlags & (MSG_STATE_FLAG_10 | MSG_STATE_FLAG_4)) &&
                    (gGameStatusPtr->currentButtons[0] & BUTTON_A)))
                {
                    printer->curLinePos += 6;
                }

                if (printer->curLinePos >= printer->nextLinePos) {
                    printer->windowState = MSG_WINDOW_STATE_PRINTING;
                    printer->curLinePos = printer->nextLinePos;
                    printer->stateFlags |= MSG_STATE_FLAG_4;

                    if (printer->style == MSG_STYLE_SIGN ||
                        printer->style == MSG_STYLE_LAMPPOST ||
                        printer->srcBuffer[printer->srcBufferPos] == MSG_CHAR_READ_WAIT)
                    {
                        printer->currentPrintDelay = 0;
                    } else {
                        printer->currentPrintDelay = 5;
                    }
                    printer->lineEndPos[printer->currentLine] = printer->curLinePos;
                }
                break;
            case MSG_WINDOW_STATE_B:
                printer->unk_4CC += 1;
                endPosDist = abs(printer->curLinePos - printer->lineEndPos[printer->unkArraySize]);
                lineIncAmt = 2;

                if (printer->unk_4C8 <= 16) {
                    if (endPosDist >= 15) {
                        lineIncAmt = 4;
                    } else if (endPosDist >= 9) {
                        lineIncAmt = 3;
                    }
                } else if (endPosDist > 96) {
                    lineIncAmt = 10;
                } else if (endPosDist > 48) {
                    lineIncAmt = 9;
                } else if (endPosDist >= 24) {
                    lineIncAmt = 7;
                } else if (endPosDist >= 16) {
                    lineIncAmt = 5;
                } else if (endPosDist >= 8) {
                    lineIncAmt = 4;
                } else if (endPosDist > 4) {
                    lineIncAmt = 3;
                }

                printer->unk_4CA = lineIncAmt;

                if (printer->lineEndPos[printer->unkArraySize] < printer->curLinePos) {
                    printer->curLinePos -= printer->unk_4CA;
                    if (printer->lineEndPos[printer->unkArraySize] >= printer->curLinePos) {
                        printer->curLinePos = printer->lineEndPos[printer->unkArraySize];
                        printer->windowState = MSG_WINDOW_STATE_C;
                    }
                } else {
                    printer->curLinePos += printer->unk_4CA;
                    if (printer->curLinePos >= printer->lineEndPos[printer->unkArraySize]) {
                        printer->curLinePos = printer->lineEndPos[printer->unkArraySize];
                        printer->windowState = MSG_WINDOW_STATE_C;
                        if (printer->unkArraySize == printer->currentLine) {
                            printer->windowState = MSG_WINDOW_STATE_WAITING;
                            printer->rewindArrowAnimState = REWIND_ARROW_STATE_INIT;
                            printer->rewindArrowCounter = 0;
                        }
                    }
                }
                break;
            case MSG_WINDOW_STATE_OPENING:
            case MSG_WINDOW_STATE_CLOSING:
            case MSG_WINDOW_STATE_WAITING:
            case MSG_WINDOW_STATE_WAITING_FOR_CHOICE:
            case MSG_WINDOW_STATE_SCROLLING_BACK:
            case MSG_WINDOW_STATE_VIEWING_PREV:
            case MSG_WINDOW_STATE_A:
            case MSG_WINDOW_STATE_C:
            case MSG_WINDOW_STATE_D:
            case MSG_WINDOW_STATE_E:
                break;
        }
    }

    if (printer->stateFlags & MSG_STATE_FLAG_1) {
        printer->windowState = MSG_WINDOW_STATE_DONE;
        printer->stateFlags = 0;
        if (printer->letterBackgroundImg != NULL) {
            general_heap_free(printer->letterBackgroundImg);
        }
        if (printer->letterBackgroundPal != NULL) {
            general_heap_free(printer->letterBackgroundPal);
        }
        if (printer->letterContentImg != NULL) {
            general_heap_free(printer->letterContentImg);
        }
        if (printer->letterContentPal != NULL) {
            general_heap_free(printer->letterContentPal);
        }
        if (printer->closedWritebackBool != NULL) {
            *printer->closedWritebackBool = TRUE;
            printer->closedWritebackBool = NULL;
        }
    }

    return printer->windowState;
}