### RAW ASSEMBLY INSTRUCTIONS:

dlabel func_802A2910_7AA2B0
/* 4176A0 802A2910 3C02802B */  lui       $v0, %hi(BattleMenu_Moves_OptionCount)
/* 4176A4 802A2914 8C42D4A4 */  lw        $v0, %lo(BattleMenu_Moves_OptionCount)($v0)
/* 4176A8 802A2918 27BDFFE0 */  addiu     $sp, $sp, -0x20
/* 4176AC 802A291C AFB00010 */  sw        $s0, 0x10($sp)
/* 4176B0 802A2920 0000802D */  daddu     $s0, $zero, $zero
/* 4176B4 802A2924 AFBF0018 */  sw        $ra, 0x18($sp)
D_802A2928_7AA2C8:
/* 4176B8 802A2928 1840000F */  blez      $v0, .L802A2968_7AA308
/* 4176BC 802A292C AFB10014 */   sw       $s1, 0x14($sp)
/* 4176C0 802A2930 3C11802B */  lui       $s1, %hi(BattleMenu_Moves_OptionIDs)
/* 4176C4 802A2934 2631D128 */  addiu     $s1, $s1, %lo(BattleMenu_Moves_OptionIDs)
/* 4176C8 802A2938 240500FF */  addiu     $a1, $zero, 0xFF
.L802A293C_7AA2DC:
/* 4176CC 802A293C 00A0302D */  daddu     $a2, $a1, $zero
/* 4176D0 802A2940 00A0382D */  daddu     $a3, $a1, $zero
/* 4176D4 802A2944 8E240000 */  lw        $a0, 0x0($s1)
/* 4176D8 802A2948 0C0513BF */  jal       hud_element_set_tint
/* 4176DC 802A294C 26310004 */   addiu    $s1, $s1, 0x4
/* 4176E0 802A2950 3C02802B */  lui       $v0, %hi(BattleMenu_Moves_OptionCount)
/* 4176E4 802A2954 8C42D4A4 */  lw        $v0, %lo(BattleMenu_Moves_OptionCount)($v0)
/* 4176E8 802A2958 26100001 */  addiu     $s0, $s0, 0x1
/* 4176EC 802A295C 0202102A */  slt       $v0, $s0, $v0
/* 4176F0 802A2960 1440FFF6 */  bnez      $v0, .L802A293C_7AA2DC
/* 4176F4 802A2964 240500FF */   addiu    $a1, $zero, 0xFF
.L802A2968_7AA308:
/* 4176F8 802A2968 240500FF */  addiu     $a1, $zero, 0xFF
/* 4176FC 802A296C 00A0302D */  daddu     $a2, $a1, $zero
/* 417700 802A2970 3C04802B */  lui       $a0, %hi(BattleMenu_Moves_CursorID)
/* 417704 802A2974 8C84D118 */  lw        $a0, %lo(BattleMenu_Moves_CursorID)($a0)
/* 417708 802A2978 0C0513BF */  jal       hud_element_set_tint
/* 41770C 802A297C 00A0382D */   daddu    $a3, $a1, $zero
/* 417710 802A2980 240500FF */  addiu     $a1, $zero, 0xFF
/* 417714 802A2984 00A0302D */  daddu     $a2, $a1, $zero
/* 417718 802A2988 3C04802B */  lui       $a0, %hi(BattleMenu_Moves_UpArrowID)
/* 41771C 802A298C 8C84D11C */  lw        $a0, %lo(BattleMenu_Moves_UpArrowID)($a0)
/* 417720 802A2990 0C0513BF */  jal       hud_element_set_tint
/* 417724 802A2994 00A0382D */   daddu    $a3, $a1, $zero
/* 417728 802A2998 240500FF */  addiu     $a1, $zero, 0xFF
/* 41772C 802A299C 00A0302D */  daddu     $a2, $a1, $zero
/* 417730 802A29A0 3C04802B */  lui       $a0, %hi(BattleMenu_Moves_DownArrowID)
/* 417734 802A29A4 8C84D120 */  lw        $a0, %lo(BattleMenu_Moves_DownArrowID)($a0)
/* 417738 802A29A8 0C0513BF */  jal       hud_element_set_tint
/* 41773C 802A29AC 00A0382D */   daddu    $a3, $a1, $zero
/* 417740 802A29B0 240500FF */  addiu     $a1, $zero, 0xFF
/* 417744 802A29B4 00A0302D */  daddu     $a2, $a1, $zero
/* 417748 802A29B8 3C04802B */  lui       $a0, %hi(BattleMenu_Moves_TitleID)
/* 41774C 802A29BC 8C84D188 */  lw        $a0, %lo(BattleMenu_Moves_TitleID)($a0)
/* 417750 802A29C0 0C0513BF */  jal       hud_element_set_tint
/* 417754 802A29C4 00A0382D */   daddu    $a3, $a1, $zero
/* 417758 802A29C8 3C02802B */  lui       $v0, %hi(BattleMenu_Moves_OptionCount)
/* 41775C 802A29CC 8C42D4A4 */  lw        $v0, %lo(BattleMenu_Moves_OptionCount)($v0)
D_802A29D0_7AA370:
/* 417760 802A29D0 1840000F */  blez      $v0, .L802A2A10_7AA3B0
/* 417764 802A29D4 0000802D */   daddu    $s0, $zero, $zero
/* 417768 802A29D8 3C11802B */  lui       $s1, %hi(BattleMenu_Moves_OptionCostUnitIDs)
/* 41776C 802A29DC 2631D190 */  addiu     $s1, $s1, %lo(BattleMenu_Moves_OptionCostUnitIDs)
/* 417770 802A29E0 240500FF */  addiu     $a1, $zero, 0xFF
.L802A29E4_7AA384:
/* 417774 802A29E4 00A0302D */  daddu     $a2, $a1, $zero
/* 417778 802A29E8 00A0382D */  daddu     $a3, $a1, $zero
/* 41777C 802A29EC 8E240000 */  lw        $a0, 0x0($s1)
D_802A29F0_7AA390:
/* 417780 802A29F0 0C0513BF */  jal       hud_element_set_tint
/* 417784 802A29F4 26310004 */   addiu    $s1, $s1, 0x4
/* 417788 802A29F8 3C02802B */  lui       $v0, %hi(BattleMenu_Moves_OptionCount)
/* 41778C 802A29FC 8C42D4A4 */  lw        $v0, %lo(BattleMenu_Moves_OptionCount)($v0)
/* 417790 802A2A00 26100001 */  addiu     $s0, $s0, 0x1
/* 417794 802A2A04 0202102A */  slt       $v0, $s0, $v0
/* 417798 802A2A08 5440FFF6 */  bnel      $v0, $zero, .L802A29E4_7AA384
/* 41779C 802A2A0C 240500FF */   addiu    $a1, $zero, 0xFF
.L802A2A10_7AA3B0:
/* 4177A0 802A2A10 3C04802B */  lui       $a0, %hi(BattleMenu_Moves_CursorID)
/* 4177A4 802A2A14 8C84D118 */  lw        $a0, %lo(BattleMenu_Moves_CursorID)($a0)
/* 4177A8 802A2A18 3C058010 */  lui       $a1, %hi(HES_AnimatedHandPointer)
/* 4177AC 802A2A1C 24A54A28 */  addiu     $a1, $a1, %lo(HES_AnimatedHandPointer)
/* 4177B0 802A2A20 0C0511FF */  jal       hud_element_set_script
/* 4177B4 802A2A24 00000000 */   nop
/* 4177B8 802A2A28 24040001 */  addiu     $a0, $zero, 0x1
/* 4177BC 802A2A2C 0C051F9F */  jal       set_window_update
D_802A2A30_7AA3D0:
/* 4177C0 802A2A30 24050005 */   addiu    $a1, $zero, 0x5
/* 4177C4 802A2A34 3C02802B */  lui       $v0, %hi(BattleMenu_UsingSpiritsSubmenu)
/* 4177C8 802A2A38 8C42D4A0 */  lw        $v0, %lo(BattleMenu_UsingSpiritsSubmenu)($v0)
/* 4177CC 802A2A3C 54400006 */  bnel      $v0, $zero, .L802A2A58_7AA3F8
/* 4177D0 802A2A40 24040004 */   addiu    $a0, $zero, 0x4
/* 4177D4 802A2A44 24040002 */  addiu     $a0, $zero, 0x2
/* 4177D8 802A2A48 0C051F9F */  jal       set_window_update
/* 4177DC 802A2A4C 24050005 */   addiu    $a1, $zero, 0x5
/* 4177E0 802A2A50 080A8A99 */  j         .L802A2A64_7AA404
/* 4177E4 802A2A54 24040003 */   addiu    $a0, $zero, 0x3
.L802A2A58_7AA3F8:
/* 4177E8 802A2A58 0C051F9F */  jal       set_window_update
/* 4177EC 802A2A5C 24050005 */   addiu    $a1, $zero, 0x5
/* 4177F0 802A2A60 24040005 */  addiu     $a0, $zero, 0x5
.L802A2A64_7AA404:
/* 4177F4 802A2A64 0C051F9F */  jal       set_window_update
/* 4177F8 802A2A68 24050005 */   addiu    $a1, $zero, 0x5
/* 4177FC 802A2A6C 24040008 */  addiu     $a0, $zero, 0x8
/* 417800 802A2A70 0C051F9F */  jal       set_window_update
/* 417804 802A2A74 24050001 */   addiu    $a1, $zero, 0x1
/* 417808 802A2A78 2402000A */  addiu     $v0, $zero, 0xA
/* 41780C 802A2A7C 8FBF0018 */  lw        $ra, 0x18($sp)
/* 417810 802A2A80 8FB10014 */  lw        $s1, 0x14($sp)
/* 417814 802A2A84 8FB00010 */  lw        $s0, 0x10($sp)
/* 417818 802A2A88 24030001 */  addiu     $v1, $zero, 0x1
/* 41781C 802A2A8C 3C01802B */  lui       $at, %hi(BattleMenu_Moves_TextColor)
/* 417820 802A2A90 A422D114 */  sh        $v0, %lo(BattleMenu_Moves_TextColor)($at)
/* 417824 802A2A94 240200FF */  addiu     $v0, $zero, 0xFF
/* 417828 802A2A98 3C01802B */  lui       $at, %hi(D_802AD10F)
/* 41782C 802A2A9C A023D10F */  sb        $v1, %lo(D_802AD10F)($at)
/* 417830 802A2AA0 3C01802B */  lui       $at, %hi(BattleMenu_Moves_TextAlpha)
/* 417834 802A2AA4 A422D116 */  sh        $v0, %lo(BattleMenu_Moves_TextAlpha)($at)
/* 417838 802A2AA8 3C01802B */  lui       $at, %hi(battle_menu_moveState)
/* 41783C 802A2AAC A023D108 */  sb        $v1, %lo(battle_menu_moveState)($at)
/* 417840 802A2AB0 03E00008 */  jr        $ra
/* 417844 802A2AB4 27BD0020 */   addiu    $sp, $sp, 0x20

### DECOMPILED C INSTRUCTIONS:

void func_802A2910(void) {
    s32* moveOptionIconIDs;
    s32* moveOptionCostUnitIconIDs;
    s32 i;

    moveOptionIconIDs = BattleMenu_Moves_OptionIDs;

    for (i = 0; i < BattleMenu_Moves_OptionCount; i++) {
        hud_element_set_tint(moveOptionIconIDs[i], 255, 255, 255);
    }

    hud_element_set_tint(BattleMenu_Moves_CursorID, 255, 255, 255);
    hud_element_set_tint(BattleMenu_Moves_UpArrowID, 255, 255, 255);
    hud_element_set_tint(BattleMenu_Moves_DownArrowID, 255, 255, 255);
    hud_element_set_tint(BattleMenu_Moves_TitleID, 255, 255, 255);

    moveOptionCostUnitIconIDs = BattleMenu_Moves_OptionCostUnitIDs;

    for (i = 0; i < BattleMenu_Moves_OptionCount; i++) {
        hud_element_set_tint(moveOptionCostUnitIconIDs[i], 255, 255, 255);
    }

    hud_element_set_script(BattleMenu_Moves_CursorID, &HES_AnimatedHandPointer);
    set_window_update(WINDOW_ID_1, WINDOW_UPDATE_TRANSPARENT);

    if (!BattleMenu_UsingSpiritsSubmenu) {
        set_window_update(WINDOW_ID_2, WINDOW_UPDATE_TRANSPARENT);
        set_window_update(WINDOW_ID_3, WINDOW_UPDATE_TRANSPARENT);
    } else {
        set_window_update(WINDOW_ID_4, WINDOW_UPDATE_TRANSPARENT);
        set_window_update(WINDOW_ID_5, WINDOW_UPDATE_TRANSPARENT);
    }

    set_window_update(WINDOW_ID_8, WINDOW_UPDATE_SHOW);
    BattleMenu_Moves_TextColor = MSG_PAL_STANDARD;
    D_802AD10F = 1;
    BattleMenu_Moves_TextAlpha = 255;
    battle_menu_moveState = BTL_SUBMENU_MOVES_STATE_UNK_1;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel hide_popup_menu
/* 8A860 800F13B0 3C028011 */  lui       $v0, %hi(PopupNotBattle)
/* 8A864 800F13B4 8042D68E */  lb        $v0, %lo(PopupNotBattle)($v0)
/* 8A868 800F13B8 27BDFFE0 */  addiu     $sp, $sp, -0x20
/* 8A86C 800F13BC AFBF0018 */  sw        $ra, 0x18($sp)
/* 8A870 800F13C0 AFB10014 */  sw        $s1, 0x14($sp)
/* 8A874 800F13C4 1040001A */  beqz      $v0, .L800F1430
/* 8A878 800F13C8 AFB00010 */   sw       $s0, 0x10($sp)
/* 8A87C 800F13CC 3C028011 */  lui       $v0, %hi(gPopupMenu)
/* 8A880 800F13D0 8C42D69C */  lw        $v0, %lo(gPopupMenu)($v0)
/* 8A884 800F13D4 8C430318 */  lw        $v1, 0x318($v0)
/* 8A888 800F13D8 2C62000E */  sltiu     $v0, $v1, 0xE
/* 8A88C 800F13DC 10400012 */  beqz      $v0, .L800F1428
/* 8A890 800F13E0 00031080 */   sll      $v0, $v1, 2
/* 8A894 800F13E4 3C018011 */  lui       $at, %hi(jtbl_8010C330)
/* 8A898 800F13E8 00220821 */  addu      $at, $at, $v0
/* 8A89C 800F13EC 8C22C330 */  lw        $v0, %lo(jtbl_8010C330)($at)
/* 8A8A0 800F13F0 00400008 */  jr        $v0
/* 8A8A4 800F13F4 00000000 */   nop
glabel .L800F13F8
/* 8A8A8 800F13F8 2404000E */  addiu     $a0, $zero, 0xE
/* 8A8AC 800F13FC 3C108014 */  lui       $s0, %hi(basic_hidden_window_update)
/* 8A8B0 800F1400 26107574 */  addiu     $s0, $s0, %lo(basic_hidden_window_update)
/* 8A8B4 800F1404 0C051F9F */  jal       set_window_update
/* 8A8B8 800F1408 0200282D */   daddu    $a1, $s0, $zero
/* 8A8BC 800F140C 0803C506 */  j         .L800F1418
/* 8A8C0 800F1410 24040013 */   addiu    $a0, $zero, 0x13
glabel .L800F1414
/* 8A8C4 800F1414 2404000E */  addiu     $a0, $zero, 0xE
.L800F1418:
/* 8A8C8 800F1418 3C058014 */  lui       $a1, %hi(basic_hidden_window_update)
/* 8A8CC 800F141C 24A57574 */  addiu     $a1, $a1, %lo(basic_hidden_window_update)
/* 8A8D0 800F1420 0C051F9F */  jal       set_window_update
/* 8A8D4 800F1424 00000000 */   nop
.L800F1428:
/* 8A8D8 800F1428 0803C51D */  j         .L800F1474
/* 8A8DC 800F142C 24040015 */   addiu    $a0, $zero, 0x15
.L800F1430:
/* 8A8E0 800F1430 3C028011 */  lui       $v0, %hi(gPopupMenu)
/* 8A8E4 800F1434 8C42D69C */  lw        $v0, %lo(gPopupMenu)($v0)
/* 8A8E8 800F1438 8C430318 */  lw        $v1, 0x318($v0)
/* 8A8EC 800F143C 2C62000E */  sltiu     $v0, $v1, 0xE
/* 8A8F0 800F1440 1040000E */  beqz      $v0, .L800F147C
/* 8A8F4 800F1444 00031080 */   sll      $v0, $v1, 2
/* 8A8F8 800F1448 3C018011 */  lui       $at, %hi(jtbl_8010C368)
/* 8A8FC 800F144C 00220821 */  addu      $at, $at, $v0
/* 8A900 800F1450 8C22C368 */  lw        $v0, %lo(jtbl_8010C368)($at)
/* 8A904 800F1454 00400008 */  jr        $v0
/* 8A908 800F1458 00000000 */   nop
glabel .L800F145C
/* 8A90C 800F145C 2404000E */  addiu     $a0, $zero, 0xE
/* 8A910 800F1460 0C051F9F */  jal       set_window_update
/* 8A914 800F1464 24050002 */   addiu    $a1, $zero, 0x2
/* 8A918 800F1468 0803C51D */  j         .L800F1474
/* 8A91C 800F146C 24040013 */   addiu    $a0, $zero, 0x13
glabel .L800F1470
/* 8A920 800F1470 2404000E */  addiu     $a0, $zero, 0xE
.L800F1474:
/* 8A924 800F1474 0C051F9F */  jal       set_window_update
/* 8A928 800F1478 24050002 */   addiu    $a1, $zero, 0x2
.L800F147C:
/* 8A92C 800F147C 3C118011 */  lui       $s1, %hi(gPopupMenu)
/* 8A930 800F1480 2631D69C */  addiu     $s1, $s1, %lo(gPopupMenu)
/* 8A934 800F1484 8E220000 */  lw        $v0, 0x0($s1)
/* 8A938 800F1488 8C430318 */  lw        $v1, 0x318($v0)
/* 8A93C 800F148C 24020003 */  addiu     $v0, $zero, 0x3
/* 8A940 800F1490 14620008 */  bne       $v1, $v0, .L800F14B4
/* 8A944 800F1494 24040010 */   addiu    $a0, $zero, 0x10
/* 8A948 800F1498 3C108014 */  lui       $s0, %hi(basic_hidden_window_update)
/* 8A94C 800F149C 26107574 */  addiu     $s0, $s0, %lo(basic_hidden_window_update)
/* 8A950 800F14A0 0C051F9F */  jal       set_window_update
/* 8A954 800F14A4 0200282D */   daddu    $a1, $s0, $zero
/* 8A958 800F14A8 24040014 */  addiu     $a0, $zero, 0x14
/* 8A95C 800F14AC 0C051F9F */  jal       set_window_update
/* 8A960 800F14B0 0200282D */   daddu    $a1, $s0, $zero
.L800F14B4:
/* 8A964 800F14B4 8E220000 */  lw        $v0, 0x0($s1)
/* 8A968 800F14B8 8C430318 */  lw        $v1, 0x318($v0)
/* 8A96C 800F14BC 24020004 */  addiu     $v0, $zero, 0x4
/* 8A970 800F14C0 14620005 */  bne       $v1, $v0, .L800F14D8
/* 8A974 800F14C4 00000000 */   nop
/* 8A978 800F14C8 3C058014 */  lui       $a1, %hi(basic_hidden_window_update)
/* 8A97C 800F14CC 24A57574 */  addiu     $a1, $a1, %lo(basic_hidden_window_update)
/* 8A980 800F14D0 0C051F9F */  jal       set_window_update
/* 8A984 800F14D4 24040012 */   addiu    $a0, $zero, 0x12
.L800F14D8:
/* 8A988 800F14D8 8E220000 */  lw        $v0, 0x0($s1)
/* 8A98C 800F14DC 8C430318 */  lw        $v1, 0x318($v0)
/* 8A990 800F14E0 24020005 */  addiu     $v0, $zero, 0x5
/* 8A994 800F14E4 14620008 */  bne       $v1, $v0, .L800F1508
/* 8A998 800F14E8 24040010 */   addiu    $a0, $zero, 0x10
/* 8A99C 800F14EC 3C108014 */  lui       $s0, %hi(basic_hidden_window_update)
/* 8A9A0 800F14F0 26107574 */  addiu     $s0, $s0, %lo(basic_hidden_window_update)
/* 8A9A4 800F14F4 0C051F9F */  jal       set_window_update
/* 8A9A8 800F14F8 0200282D */   daddu    $a1, $s0, $zero
/* 8A9AC 800F14FC 24040014 */  addiu     $a0, $zero, 0x14
/* 8A9B0 800F1500 0C051F9F */  jal       set_window_update
/* 8A9B4 800F1504 0200282D */   daddu    $a1, $s0, $zero
.L800F1508:
/* 8A9B8 800F1508 3C038011 */  lui       $v1, %hi(D_8010D692)
/* 8A9BC 800F150C 8063D692 */  lb        $v1, %lo(D_8010D692)($v1)
/* 8A9C0 800F1510 8FBF0018 */  lw        $ra, 0x18($sp)
/* 8A9C4 800F1514 8FB10014 */  lw        $s1, 0x14($sp)
/* 8A9C8 800F1518 8FB00010 */  lw        $s0, 0x10($sp)
/* 8A9CC 800F151C 2402000A */  addiu     $v0, $zero, 0xA
/* 8A9D0 800F1520 3C018011 */  lui       $at, %hi(gPopupState)
/* 8A9D4 800F1524 AC22D640 */  sw        $v0, %lo(gPopupState)($at)
/* 8A9D8 800F1528 3C018011 */  lui       $at, %hi(D_8010D644)
/* 8A9DC 800F152C AC23D644 */  sw        $v1, %lo(D_8010D644)($at)
/* 8A9E0 800F1530 03E00008 */  jr        $ra
/* 8A9E4 800F1534 27BD0020 */   addiu    $sp, $sp, 0x20

### DECOMPILED C INSTRUCTIONS:

void hide_popup_menu(void) {
    if (PopupNotBattle) {
        switch (gPopupMenu->popupType) {
            case POPUP_MENU_USE_ITEM:
            case POPUP_MENU_SWITCH_PARTNER:
            case POPUP_MENU_THROW_AWAY_ITEM:
            case POPUP_MENU_TRADE_FOR_BADGE:
            case POPUP_MENU_UPGRADE_PARTNER:
            case POPUP_MENU_SELL_ITEM:
            case POPUP_MENU_CHECK_ITEM:
            case POPUP_MENU_CLAIM_ITEM:
            case POPUP_MENU_READ_LETTER:
            case POPUP_MENU_TAKE_FROM_CHEST:
            case POPUP_MENU_USEKEY:
                set_window_update(WINDOW_ID_14, (s32) basic_hidden_window_update);
                set_window_update(WINDOW_ID_19, (s32) basic_hidden_window_update);
                break;
            case POPUP_MENU_READ_DIARY_PAGE:
            case POPUP_MENU_READ_POSTCARD:
            case POPUP_MENU_POST_OFFICE:
                set_window_update(WINDOW_ID_14, (s32) basic_hidden_window_update);
                break;
        }
        set_window_update(WINDOW_ID_21, WINDOW_UPDATE_HIDE);
    } else {
        switch (gPopupMenu->popupType) {
            case POPUP_MENU_USE_ITEM:
            case POPUP_MENU_SWITCH_PARTNER:
            case POPUP_MENU_THROW_AWAY_ITEM:
            case POPUP_MENU_TRADE_FOR_BADGE:
            case POPUP_MENU_UPGRADE_PARTNER:
            case POPUP_MENU_SELL_ITEM:
            case POPUP_MENU_CHECK_ITEM:
            case POPUP_MENU_CLAIM_ITEM:
            case POPUP_MENU_READ_LETTER:
            case POPUP_MENU_TAKE_FROM_CHEST:
            case POPUP_MENU_USEKEY:
                set_window_update(WINDOW_ID_14, WINDOW_UPDATE_HIDE);
                set_window_update(WINDOW_ID_19, WINDOW_UPDATE_HIDE);
                break;
            case POPUP_MENU_READ_DIARY_PAGE:
            case POPUP_MENU_READ_POSTCARD:
            case POPUP_MENU_POST_OFFICE:
                set_window_update(WINDOW_ID_14, WINDOW_UPDATE_HIDE);
                break;
        }
    }

    if (gPopupMenu->popupType == POPUP_MENU_TRADE_FOR_BADGE) {
        set_window_update(WINDOW_ID_16, (s32) basic_hidden_window_update);
        set_window_update(WINDOW_ID_CURRENCY_COUNTER, (s32) basic_hidden_window_update);
    }
    if (gPopupMenu->popupType == POPUP_MENU_UPGRADE_PARTNER) {
        set_window_update(WINDOW_ID_18, (s32) basic_hidden_window_update);
    }
    if (gPopupMenu->popupType == POPUP_MENU_SELL_ITEM) {
        set_window_update(WINDOW_ID_16, (s32) basic_hidden_window_update);
        set_window_update(WINDOW_ID_CURRENCY_COUNTER, (s32) basic_hidden_window_update);
    }
    gPopupState = POPUP_STATE_10;
    D_8010D644 = D_8010D692;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel state_step_exit_file_select
/* 10F40 80035B40 27BDFFE8 */  addiu     $sp, $sp, -0x18
/* 10F44 80035B44 AFBF0014 */  sw        $ra, 0x14($sp)
/* 10F48 80035B48 0C0912F1 */  jal       func_80244BC4
/* 10F4C 80035B4C AFB00010 */   sw       $s0, 0x10($sp)
/* 10F50 80035B50 3C03800A */  lui       $v1, %hi(D_800A0931)
/* 10F54 80035B54 80630931 */  lb        $v1, %lo(D_800A0931)($v1)
/* 10F58 80035B58 0040802D */  daddu     $s0, $v0, $zero
/* 10F5C 80035B5C 2C620007 */  sltiu     $v0, $v1, 0x7
/* 10F60 80035B60 10400069 */  beqz      $v0, .L80035D08
/* 10F64 80035B64 00031080 */   sll      $v0, $v1, 2
/* 10F68 80035B68 3C01800A */  lui       $at, %hi(jtbl_80098300)
/* 10F6C 80035B6C 00220821 */  addu      $at, $at, $v0
/* 10F70 80035B70 8C228300 */  lw        $v0, %lo(jtbl_80098300)($at)
/* 10F74 80035B74 00400008 */  jr        $v0
/* 10F78 80035B78 00000000 */   nop
glabel .L80035B7C
/* 10F7C 80035B7C 0000282D */  daddu     $a1, $zero, $zero
/* 10F80 80035B80 2404002C */  addiu     $a0, $zero, 0x2C
/* 10F84 80035B84 0080382D */  daddu     $a3, $a0, $zero
/* 10F88 80035B88 2406FFFF */  addiu     $a2, $zero, -0x1
/* 10F8C 80035B8C 3C038016 */  lui       $v1, %hi(D_8015A2D0)
/* 10F90 80035B90 2463A2D0 */  addiu     $v1, $v1, %lo(D_8015A2D0)
.L80035B94:
/* 10F94 80035B94 80620003 */  lb        $v0, 0x3($v1)
/* 10F98 80035B98 10470003 */  beq       $v0, $a3, .L80035BA8
/* 10F9C 80035B9C 00000000 */   nop
/* 10FA0 80035BA0 54460005 */  bnel      $v0, $a2, .L80035BB8
/* 10FA4 80035BA4 24840001 */   addiu    $a0, $a0, 0x1
.L80035BA8:
/* 10FA8 80035BA8 90620000 */  lbu       $v0, 0x0($v1)
/* 10FAC 80035BAC 30420008 */  andi      $v0, $v0, 0x8
/* 10FB0 80035BB0 00A22821 */  addu      $a1, $a1, $v0
/* 10FB4 80035BB4 24840001 */  addiu     $a0, $a0, 0x1
.L80035BB8:
/* 10FB8 80035BB8 28820040 */  slti      $v0, $a0, 0x40
/* 10FBC 80035BBC 1440FFF5 */  bnez      $v0, .L80035B94
/* 10FC0 80035BC0 24630020 */   addiu    $v1, $v1, 0x20
/* 10FC4 80035BC4 14A00050 */  bnez      $a1, .L80035D08
/* 10FC8 80035BC8 24020001 */   addiu    $v0, $zero, 0x1
/* 10FCC 80035BCC 3C01800A */  lui       $at, %hi(D_800A0931)
/* 10FD0 80035BD0 A0220931 */  sb        $v0, %lo(D_800A0931)($at)
/* 10FD4 80035BD4 0800D742 */  j         .L80035D08
/* 10FD8 80035BD8 00000000 */   nop
glabel .L80035BDC
/* 10FDC 80035BDC 12000008 */  beqz      $s0, .L80035C00
/* 10FE0 80035BE0 24020002 */   addiu    $v0, $zero, 0x2
/* 10FE4 80035BE4 3C04800A */  lui       $a0, %hi(D_800A0932)
/* 10FE8 80035BE8 24840932 */  addiu     $a0, $a0, %lo(D_800A0932)
/* 10FEC 80035BEC 0C04E0AB */  jal       update_exit_map_screen_overlay
/* 10FF0 80035BF0 00000000 */   nop
/* 10FF4 80035BF4 00021400 */  sll       $v0, $v0, 16
/* 10FF8 80035BF8 10400043 */  beqz      $v0, .L80035D08
/* 10FFC 80035BFC 24020002 */   addiu    $v0, $zero, 0x2
.L80035C00:
/* 11000 80035C00 3C01800A */  lui       $at, %hi(D_800A0931)
/* 11004 80035C04 A0220931 */  sb        $v0, %lo(D_800A0931)($at)
/* 11008 80035C08 0800D742 */  j         .L80035D08
/* 1100C 80035C0C 00000000 */   nop
glabel .L80035C10
/* 11010 80035C10 0C0912C0 */  jal       func_80244B00
/* 11014 80035C14 00000000 */   nop
/* 11018 80035C18 0C051FB1 */  jal       set_windows_visible
/* 1101C 80035C1C 0000202D */   daddu    $a0, $zero, $zero
/* 11020 80035C20 24020003 */  addiu     $v0, $zero, 0x3
/* 11024 80035C24 3C01800A */  lui       $at, %hi(D_800A0931)
/* 11028 80035C28 A0220931 */  sb        $v0, %lo(D_800A0931)($at)
glabel .L80035C2C
/* 1102C 80035C2C 0C009C22 */  jal       set_time_freeze_mode
/* 11030 80035C30 0000202D */   daddu    $a0, $zero, $zero
/* 11034 80035C34 1600000B */  bnez      $s0, .L80035C64
/* 11038 80035C38 2402000A */   addiu    $v0, $zero, 0xA
/* 1103C 80035C3C 0C00CD3C */  jal       set_game_mode
/* 11040 80035C40 24040002 */   addiu    $a0, $zero, 0x2
/* 11044 80035C44 3C04FFFE */  lui       $a0, (0xFFFEFFFF >> 16)
/* 11048 80035C48 3C03800A */  lui       $v1, %hi(gOverrideFlags)
/* 1104C 80035C4C 2463A650 */  addiu     $v1, $v1, %lo(gOverrideFlags)
/* 11050 80035C50 8C620000 */  lw        $v0, 0x0($v1)
/* 11054 80035C54 3484FFFF */  ori       $a0, $a0, (0xFFFEFFFF & 0xFFFF)
/* 11058 80035C58 00441024 */  and       $v0, $v0, $a0
/* 1105C 80035C5C 0800D742 */  j         .L80035D08
/* 11060 80035C60 AC620000 */   sw       $v0, 0x0($v1)
.L80035C64:
/* 11064 80035C64 3C01800A */  lui       $at, %hi(D_800A0930)
/* 11068 80035C68 A0220930 */  sb        $v0, %lo(D_800A0930)($at)
/* 1106C 80035C6C 24020004 */  addiu     $v0, $zero, 0x4
/* 11070 80035C70 3C01800A */  lui       $at, %hi(D_800A0931)
/* 11074 80035C74 A0220931 */  sb        $v0, %lo(D_800A0931)($at)
/* 11078 80035C78 0800D742 */  j         .L80035D08
/* 1107C 80035C7C 00000000 */   nop
glabel .L80035C80
/* 11080 80035C80 3C10800A */  lui       $s0, %hi(D_800A0930)
/* 11084 80035C84 26100930 */  addiu     $s0, $s0, %lo(D_800A0930)
/* 11088 80035C88 82020000 */  lb        $v0, 0x0($s0)
/* 1108C 80035C8C 92030000 */  lbu       $v1, 0x0($s0)
/* 11090 80035C90 18400003 */  blez      $v0, .L80035CA0
/* 11094 80035C94 2462FFFF */   addiu    $v0, $v1, -0x1
/* 11098 80035C98 0800D742 */  j         .L80035D08
/* 1109C 80035C9C A2020000 */   sb       $v0, 0x0($s0)
.L80035CA0:
/* 110A0 80035CA0 3C014000 */  lui       $at, (0x40000000 >> 16)
/* 110A4 80035CA4 44816000 */  mtc1      $at, $f12
/* 110A8 80035CA8 0C00AFB7 */  jal       set_curtain_scale_goal
/* 110AC 80035CAC 00000000 */   nop
/* 110B0 80035CB0 2402000A */  addiu     $v0, $zero, 0xA
/* 110B4 80035CB4 A2020000 */  sb        $v0, 0x0($s0)
/* 110B8 80035CB8 24020005 */  addiu     $v0, $zero, 0x5
/* 110BC 80035CBC 3C01800A */  lui       $at, %hi(D_800A0931)
/* 110C0 80035CC0 A0220931 */  sb        $v0, %lo(D_800A0931)($at)
/* 110C4 80035CC4 0800D742 */  j         .L80035D08
/* 110C8 80035CC8 00000000 */   nop
glabel .L80035CCC
/* 110CC 80035CCC 3C04800A */  lui       $a0, %hi(D_800A0930)
/* 110D0 80035CD0 24840930 */  addiu     $a0, $a0, %lo(D_800A0930)
/* 110D4 80035CD4 80820000 */  lb        $v0, 0x0($a0)
/* 110D8 80035CD8 90830000 */  lbu       $v1, 0x0($a0)
/* 110DC 80035CDC 18400003 */  blez      $v0, .L80035CEC
/* 110E0 80035CE0 2462FFFF */   addiu    $v0, $v1, -0x1
/* 110E4 80035CE4 0800D742 */  j         .L80035D08
/* 110E8 80035CE8 A0820000 */   sb       $v0, 0x0($a0)
.L80035CEC:
/* 110EC 80035CEC 24020006 */  addiu     $v0, $zero, 0x6
/* 110F0 80035CF0 3C01800A */  lui       $at, %hi(D_800A0931)
/* 110F4 80035CF4 A0220931 */  sb        $v0, %lo(D_800A0931)($at)
/* 110F8 80035CF8 0800D742 */  j         .L80035D08
/* 110FC 80035CFC 00000000 */   nop
glabel .L80035D00
/* 11100 80035D00 0C00CD3C */  jal       set_game_mode
/* 11104 80035D04 24040007 */   addiu    $a0, $zero, 0x7
.L80035D08:
/* 11108 80035D08 8FBF0014 */  lw        $ra, 0x14($sp)
/* 1110C 80035D0C 8FB00010 */  lw        $s0, 0x10($sp)
/* 11110 80035D10 03E00008 */  jr        $ra
/* 11114 80035D14 27BD0018 */   addiu    $sp, $sp, 0x18

### DECOMPILED C INSTRUCTIONS:

void state_step_exit_file_select(void) {
    s32 temp_s0 = func_80244BC4();
    s32 flagSum;
    s32 i;

    switch (D_800A0931) {
        case 0:
            flagSum = 0;

            for (i = 44; i < ARRAY_COUNT(gWindows); i++) {
                Window* window = &gWindows[i];

                if (window->parent == WINDOW_ID_FILEMENU_MAIN || window->parent == -1) {
                    flagSum += window->flags & WINDOW_FLAG_INITIAL_ANIMATION;
                }
            }

            if (flagSum == 0) {
                D_800A0931 = 1;
            }
            break;
        case 1:
            if (temp_s0 == 0 || update_exit_map_screen_overlay(D_800A0932) != 0) {
                D_800A0931 = 2;
            }
            break;
        case 2:
            filemenu_cleanup();
            set_windows_visible(WINDOW_GROUP_ALL);
            D_800A0931 = 3;
        case 3:
            set_time_freeze_mode(TIME_FREEZE_NORMAL);
            if (temp_s0 == 0) {
                set_game_mode(GAME_MODE_TITLE_SCREEN);
                gOverrideFlags &= ~GLOBAL_OVERRIDES_WINDOWS_IN_FRONT_OF_CURTAINS;
            } else {
                D_800A0930 = 10;
                D_800A0931 = 4;
            }
            break;
        case 4:
            if (D_800A0930 > 0) {
                D_800A0930--;
            } else {
                set_curtain_scale_goal(2.0f);
                D_800A0930 = 10;
                D_800A0931 = 5;
            }
            break;
        case 5:
            if (D_800A0930 > 0) {
                D_800A0930--;
            } else {
                D_800A0931 = 6;
            }
            break;
        case 6:
            set_game_mode(GAME_MODE_WORLD);
            break;
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel func_80054AA0
/* 2FEA0 80054AA0 3C028008 */  lui       $v0, %hi(gSynDriverPtr)
/* 2FEA4 80054AA4 8C428E54 */  lw        $v0, %lo(gSynDriverPtr)($v0)
/* 2FEA8 80054AA8 27BDFF80 */  addiu     $sp, $sp, -0x80
/* 2FEAC 80054AAC AFB60070 */  sw        $s6, 0x70($sp)
/* 2FEB0 80054AB0 0080B02D */  daddu     $s6, $a0, $zero
/* 2FEB4 80054AB4 AFB30064 */  sw        $s3, 0x64($sp)
/* 2FEB8 80054AB8 00A0982D */  daddu     $s3, $a1, $zero
/* 2FEBC 80054ABC AFB40068 */  sw        $s4, 0x68($sp)
/* 2FEC0 80054AC0 27B40018 */  addiu     $s4, $sp, 0x18
/* 2FEC4 80054AC4 AFBE0078 */  sw        $fp, 0x78($sp)
/* 2FEC8 80054AC8 0000F02D */  daddu     $fp, $zero, $zero
/* 2FECC 80054ACC AFB1005C */  sw        $s1, 0x5C($sp)
/* 2FED0 80054AD0 2411000B */  addiu     $s1, $zero, 0xB
/* 2FED4 80054AD4 AFB20060 */  sw        $s2, 0x60($sp)
/* 2FED8 80054AD8 24120001 */  addiu     $s2, $zero, 0x1
/* 2FEDC 80054ADC AFBF007C */  sw        $ra, 0x7C($sp)
/* 2FEE0 80054AE0 AFB70074 */  sw        $s7, 0x74($sp)
/* 2FEE4 80054AE4 AFB5006C */  sw        $s5, 0x6C($sp)
/* 2FEE8 80054AE8 AFB00058 */  sw        $s0, 0x58($sp)
/* 2FEEC 80054AEC AFA60088 */  sw        $a2, 0x88($sp)
/* 2FEF0 80054AF0 AFA7008C */  sw        $a3, 0x8C($sp)
/* 2FEF4 80054AF4 8C570018 */  lw        $s7, 0x18($v0)
/* 2FEF8 80054AF8 2402000B */  addiu     $v0, $zero, 0xB
.L80054AFC:
/* 2FEFC 80054AFC 1222000A */  beq       $s1, $v0, .L80054B28
/* 2FF00 80054B00 2E22000C */   sltiu    $v0, $s1, 0xC
/* 2FF04 80054B04 54400042 */  bnel      $v0, $zero, .L80054C10
/* 2FF08 80054B08 0000902D */   daddu    $s2, $zero, $zero
/* 2FF0C 80054B0C 24020015 */  addiu     $v0, $zero, 0x15
/* 2FF10 80054B10 12220015 */  beq       $s1, $v0, .L80054B68
/* 2FF14 80054B14 2402001F */   addiu    $v0, $zero, 0x1F
/* 2FF18 80054B18 52220035 */  beql      $s1, $v0, .L80054BF0
/* 2FF1C 80054B1C AFA00010 */   sw       $zero, 0x10($sp)
/* 2FF20 80054B20 08015304 */  j         .L80054C10
/* 2FF24 80054B24 0000902D */   daddu    $s2, $zero, $zero
.L80054B28:
/* 2FF28 80054B28 27A50018 */  addiu     $a1, $sp, 0x18
/* 2FF2C 80054B2C 8EC40000 */  lw        $a0, 0x0($s6)
/* 2FF30 80054B30 0C015380 */  jal       au_read_rom
/* 2FF34 80054B34 24060040 */   addiu    $a2, $zero, 0x40
/* 2FF38 80054B38 96830000 */  lhu       $v1, 0x0($s4)
/* 2FF3C 80054B3C 2402424B */  addiu     $v0, $zero, 0x424B
/* 2FF40 80054B40 54620033 */  bnel      $v1, $v0, .L80054C10
/* 2FF44 80054B44 0000902D */   daddu    $s2, $zero, $zero
/* 2FF48 80054B48 8E820004 */  lw        $v0, 0x4($s4)
/* 2FF4C 80054B4C 1040002F */  beqz      $v0, .L80054C0C
/* 2FF50 80054B50 24024352 */   addiu    $v0, $zero, 0x4352
/* 2FF54 80054B54 9683000C */  lhu       $v1, 0xC($s4)
/* 2FF58 80054B58 5462002D */  bnel      $v1, $v0, .L80054C10
/* 2FF5C 80054B5C 0000902D */   daddu    $s2, $zero, $zero
/* 2FF60 80054B60 08015304 */  j         .L80054C10
/* 2FF64 80054B64 24110015 */   addiu    $s1, $zero, 0x15
.L80054B68:
/* 2FF68 80054B68 16600005 */  bnez      $s3, .L80054B80
/* 2FF6C 80054B6C 02E0202D */   daddu    $a0, $s7, $zero
/* 2FF70 80054B70 8E860004 */  lw        $a2, 0x4($s4)
/* 2FF74 80054B74 0C015FE4 */  jal       alHeapAlloc
/* 2FF78 80054B78 24050001 */   addiu    $a1, $zero, 0x1
/* 2FF7C 80054B7C 0040982D */  daddu     $s3, $v0, $zero
.L80054B80:
/* 2FF80 80054B80 8EC40000 */  lw        $a0, 0x0($s6)
/* 2FF84 80054B84 8E860004 */  lw        $a2, 0x4($s4)
/* 2FF88 80054B88 0C015380 */  jal       au_read_rom
/* 2FF8C 80054B8C 0260282D */   daddu    $a1, $s3, $zero
/* 2FF90 80054B90 8FA4008C */  lw        $a0, 0x8C($sp)
/* 2FF94 80054B94 8FA50088 */  lw        $a1, 0x88($sp)
/* 2FF98 80054B98 0C0151D1 */  jal       au_get_BK_instruments
/* 2FF9C 80054B9C 0000802D */   daddu    $s0, $zero, $zero
/* 2FFA0 80054BA0 0040A82D */  daddu     $s5, $v0, $zero
/* 2FFA4 80054BA4 02A0182D */  daddu     $v1, $s5, $zero
/* 2FFA8 80054BA8 0200282D */  daddu     $a1, $s0, $zero
/* 2FFAC 80054BAC 0280202D */  daddu     $a0, $s4, $zero
.L80054BB0:
/* 2FFB0 80054BB0 94820012 */  lhu       $v0, 0x12($a0)
/* 2FFB4 80054BB4 10400004 */  beqz      $v0, .L80054BC8
/* 2FFB8 80054BB8 00531021 */   addu     $v0, $v0, $s3
/* 2FFBC 80054BBC 26100001 */  addiu     $s0, $s0, 0x1
/* 2FFC0 80054BC0 080152F3 */  j         .L80054BCC
/* 2FFC4 80054BC4 AC620000 */   sw       $v0, 0x0($v1)
.L80054BC8:
/* 2FFC8 80054BC8 AC600000 */  sw        $zero, 0x0($v1)
.L80054BCC:
/* 2FFCC 80054BCC 24630004 */  addiu     $v1, $v1, 0x4
/* 2FFD0 80054BD0 24A50001 */  addiu     $a1, $a1, 0x1
/* 2FFD4 80054BD4 2CA20010 */  sltiu     $v0, $a1, 0x10
/* 2FFD8 80054BD8 1440FFF5 */  bnez      $v0, .L80054BB0
/* 2FFDC 80054BDC 24840002 */   addiu    $a0, $a0, 0x2
/* 2FFE0 80054BE0 5200000B */  beql      $s0, $zero, .L80054C10
/* 2FFE4 80054BE4 0000902D */   daddu    $s2, $zero, $zero
/* 2FFE8 80054BE8 08015304 */  j         .L80054C10
/* 2FFEC 80054BEC 2411001F */   addiu    $s1, $zero, 0x1F
.L80054BF0:
/* 2FFF0 80054BF0 0260202D */  daddu     $a0, $s3, $zero
/* 2FFF4 80054BF4 0260282D */  daddu     $a1, $s3, $zero
/* 2FFF8 80054BF8 02A0302D */  daddu     $a2, $s5, $zero
/* 2FFFC 80054BFC 0C01527E */  jal       au_swizzle_BK_instruments
/* 30000 80054C00 24070010 */   addiu    $a3, $zero, 0x10
/* 30004 80054C04 08015304 */  j         .L80054C10
/* 30008 80054C08 0000882D */   daddu    $s1, $zero, $zero
.L80054C0C:
/* 3000C 80054C0C 0000902D */  daddu     $s2, $zero, $zero
.L80054C10:
/* 30010 80054C10 1640FFBA */  bnez      $s2, .L80054AFC
/* 30014 80054C14 2402000B */   addiu    $v0, $zero, 0xB
/* 30018 80054C18 0260102D */  daddu     $v0, $s3, $zero
/* 3001C 80054C1C 8FBF007C */  lw        $ra, 0x7C($sp)
/* 30020 80054C20 8FBE0078 */  lw        $fp, 0x78($sp)
/* 30024 80054C24 8FB70074 */  lw        $s7, 0x74($sp)
/* 30028 80054C28 8FB60070 */  lw        $s6, 0x70($sp)
/* 3002C 80054C2C 8FB5006C */  lw        $s5, 0x6C($sp)
/* 30030 80054C30 8FB40068 */  lw        $s4, 0x68($sp)
/* 30034 80054C34 8FB30064 */  lw        $s3, 0x64($sp)
/* 30038 80054C38 8FB20060 */  lw        $s2, 0x60($sp)
/* 3003C 80054C3C 8FB1005C */  lw        $s1, 0x5C($sp)
/* 30040 80054C40 8FB00058 */  lw        $s0, 0x58($sp)
/* 30044 80054C44 03E00008 */  jr        $ra
/* 30048 80054C48 27BD0080 */   addiu    $sp, $sp, 0x80

### DECOMPILED C INSTRUCTIONS:

s32* func_80054AA0(s32* bkFileOffset, void* vaddr, s32 bankIndex, s32 bankGroup) {
    ALHeap* heap = gSynDriverPtr->heap;
    BKHeader localHeader;
    void* fileData = vaddr;
    BKHeader* header = &localHeader;
    InstrumentGroup* group;
    Instrument* instruments;
    Instrument** inst;
    u32 instrCount;
    u32 readState;
    s32 keepReading;

    u32 i;
    s32 swizzleArg;
    swizzleArg = 0;
    readState = BK_READ_FETCH_HEADER;
    keepReading = TRUE;

    while (keepReading) {
        switch (readState) {
            case BK_READ_DONE:
                keepReading = FALSE;
                break;
            case BK_READ_FETCH_HEADER:
                au_read_rom(*bkFileOffset, &localHeader, sizeof(localHeader));
                if (header->signature != AL_HEADER_SIG_BK) {
                    keepReading = FALSE;
                } else if (header->size == 0) {
                    keepReading = FALSE;
                } else if (header->format != AL_HEADER_SIG_CR) {
                    keepReading = FALSE;
                } else {
                    readState = BK_READ_FETCH_DATA;
                }
                break;
            case BK_READ_FETCH_DATA:
                if (fileData == NULL) {
                    fileData = alHeapAlloc(heap, 1, header->size);
                }
                au_read_rom(*bkFileOffset, fileData, header->size);

                instrCount = 0;
                group = au_get_BK_instruments(bankGroup, bankIndex);
                inst = (*group);
                for(i = 0; i < ARRAY_COUNT(header->instruments); inst++, i++) {
                    u16 instOffset = header->instruments[i];
                    if(instOffset != 0) {
                        instrCount++;
                        *inst = AU_FILE_RELATIVE(fileData, instOffset);
                    } else {
                        *inst =  NULL;
                    }
                }

                if (instrCount != 0) {
                    readState = BK_READ_SWIZZLE;
                } else {
                    keepReading = FALSE;
                }
                break;
            case BK_READ_SWIZZLE:
                au_swizzle_BK_instruments((s32)fileData, fileData, *group, 0x10U, swizzleArg);
                readState = BK_READ_DONE;
                break;
            default:
                keepReading = FALSE;
                break;
        }
    }
    return fileData;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel osPfsInitPak
/* 44590 80069190 27BDFF90 */  addiu     $sp, $sp, -0x70
/* 44594 80069194 AFB20060 */  sw        $s2, 0x60($sp)
/* 44598 80069198 00809021 */  addu      $s2, $a0, $zero
/* 4459C 8006919C AFB1005C */  sw        $s1, 0x5C($sp)
/* 445A0 800691A0 00A08821 */  addu      $s1, $a1, $zero
/* 445A4 800691A4 AFB30064 */  sw        $s3, 0x64($sp)
/* 445A8 800691A8 00C09821 */  addu      $s3, $a2, $zero
/* 445AC 800691AC AFBF0068 */  sw        $ra, 0x68($sp)
/* 445B0 800691B0 0C019771 */  jal       __osSiGetAccess
/* 445B4 800691B4 AFB00058 */   sw       $s0, 0x58($sp)
/* 445B8 800691B8 02402021 */  addu      $a0, $s2, $zero
/* 445BC 800691BC 0C01A530 */  jal       __osPfsGetStatus
/* 445C0 800691C0 02602821 */   addu     $a1, $s3, $zero
/* 445C4 800691C4 0C01978C */  jal       __osSiRelAccess
/* 445C8 800691C8 00408021 */   addu     $s0, $v0, $zero
/* 445CC 800691CC 16000067 */  bnez      $s0, .L8006936C
/* 445D0 800691D0 02001021 */   addu     $v0, $s0, $zero
/* 445D4 800691D4 02202021 */  addu      $a0, $s1, $zero
/* 445D8 800691D8 AE320004 */  sw        $s2, 0x4($s1)
/* 445DC 800691DC AE330008 */  sw        $s3, 0x8($s1)
/* 445E0 800691E0 0C01A4E2 */  jal       osPfsCheckRamArea
/* 445E4 800691E4 AE200000 */   sw       $zero, 0x0($s1)
/* 445E8 800691E8 00408021 */  addu      $s0, $v0, $zero
/* 445EC 800691EC 1600005F */  bnez      $s0, .L8006936C
/* 445F0 800691F0 02202021 */   addu     $a0, $s1, $zero
/* 445F4 800691F4 0C01A5B4 */  jal       __osPfsSelectBank
/* 445F8 800691F8 00002821 */   addu     $a1, $zero, $zero
/* 445FC 800691FC 00408021 */  addu      $s0, $v0, $zero
/* 44600 80069200 1600005A */  bnez      $s0, .L8006936C
/* 44604 80069204 24060001 */   addiu    $a2, $zero, 0x1
/* 44608 80069208 8E240004 */  lw        $a0, 0x4($s1)
/* 4460C 8006920C 8E250008 */  lw        $a1, 0x8($s1)
/* 44610 80069210 0C01A874 */  jal       __osContRamRead
/* 44614 80069214 27A70010 */   addiu    $a3, $sp, 0x10
/* 44618 80069218 00408021 */  addu      $s0, $v0, $zero
/* 4461C 8006921C 16000053 */  bnez      $s0, .L8006936C
/* 44620 80069220 27A40010 */   addiu    $a0, $sp, 0x10
/* 44624 80069224 27A50050 */  addiu     $a1, $sp, 0x50
/* 44628 80069228 0C01A5DD */  jal       __osIdCheckSum
/* 4462C 8006922C 27A60052 */   addiu    $a2, $sp, 0x52
/* 44630 80069230 97A3002C */  lhu       $v1, 0x2C($sp)
/* 44634 80069234 97A20050 */  lhu       $v0, 0x50($sp)
/* 44638 80069238 14620005 */  bne       $v1, $v0, .L80069250
/* 4463C 8006923C 27B20010 */   addiu    $s2, $sp, 0x10
/* 44640 80069240 97A3002E */  lhu       $v1, 0x2E($sp)
/* 44644 80069244 97A20052 */  lhu       $v0, 0x52($sp)
/* 44648 80069248 1062000B */  beq       $v1, $v0, .L80069278
/* 4464C 8006924C 00000000 */   nop
.L80069250:
/* 44650 80069250 02202021 */  addu      $a0, $s1, $zero
/* 44654 80069254 0C01A6A9 */  jal       __osCheckPackId
/* 44658 80069258 02402821 */   addu     $a1, $s2, $zero
/* 4465C 8006925C 00408021 */  addu      $s0, $v0, $zero
/* 44660 80069260 12000005 */  beqz      $s0, .L80069278
/* 44664 80069264 00000000 */   nop
/* 44668 80069268 8E230000 */  lw        $v1, 0x0($s1)
/* 4466C 8006926C 34630004 */  ori       $v1, $v1, 0x4
/* 44670 80069270 0801A4DB */  j         .L8006936C
/* 44674 80069274 AE230000 */   sw       $v1, 0x0($s1)
.L80069278:
/* 44678 80069278 96420018 */  lhu       $v0, 0x18($s2)
/* 4467C 8006927C 30420001 */  andi      $v0, $v0, 0x1
/* 44680 80069280 14400015 */  bnez      $v0, .L800692D8
/* 44684 80069284 02402021 */   addu     $a0, $s2, $zero
/* 44688 80069288 02202021 */  addu      $a0, $s1, $zero
/* 4468C 8006928C 02402821 */  addu      $a1, $s2, $zero
/* 44690 80069290 27B20030 */  addiu     $s2, $sp, 0x30
/* 44694 80069294 0C01A5EE */  jal       __osRepairPackId
/* 44698 80069298 02403021 */   addu     $a2, $s2, $zero
/* 4469C 8006929C 00408021 */  addu      $s0, $v0, $zero
/* 446A0 800692A0 12000007 */  beqz      $s0, .L800692C0
/* 446A4 800692A4 2402000A */   addiu    $v0, $zero, 0xA
/* 446A8 800692A8 16020030 */  bne       $s0, $v0, .L8006936C
/* 446AC 800692AC 02001021 */   addu     $v0, $s0, $zero
/* 446B0 800692B0 8E220000 */  lw        $v0, 0x0($s1)
/* 446B4 800692B4 34420004 */  ori       $v0, $v0, 0x4
/* 446B8 800692B8 0801A4DA */  j         .L80069368
/* 446BC 800692BC AE220000 */   sw       $v0, 0x0($s1)
.L800692C0:
/* 446C0 800692C0 97A20048 */  lhu       $v0, 0x48($sp)
/* 446C4 800692C4 30420001 */  andi      $v0, $v0, 0x1
/* 446C8 800692C8 14400003 */  bnez      $v0, .L800692D8
/* 446CC 800692CC 02402021 */   addu     $a0, $s2, $zero
/* 446D0 800692D0 0801A4DB */  j         .L8006936C
/* 446D4 800692D4 2402000B */   addiu    $v0, $zero, 0xB
.L800692D8:
/* 446D8 800692D8 2625000C */  addiu     $a1, $s1, 0xC
/* 446DC 800692DC 0C019194 */  jal       bcopy
/* 446E0 800692E0 24060020 */   addiu    $a2, $zero, 0x20
/* 446E4 800692E4 8E240004 */  lw        $a0, 0x4($s1)
/* 446E8 800692E8 8E250008 */  lw        $a1, 0x8($s1)
/* 446EC 800692EC 9242001B */  lbu       $v0, 0x1B($s2)
/* 446F0 800692F0 24060007 */  addiu     $a2, $zero, 0x7
/* 446F4 800692F4 AE22004C */  sw        $v0, 0x4C($s1)
/* 446F8 800692F8 9243001A */  lbu       $v1, 0x1A($s2)
/* 446FC 800692FC 2627002C */  addiu     $a3, $s1, 0x2C
/* 44700 80069300 24020010 */  addiu     $v0, $zero, 0x10
/* 44704 80069304 AE220050 */  sw        $v0, 0x50($s1)
/* 44708 80069308 24020008 */  addiu     $v0, $zero, 0x8
/* 4470C 8006930C AE220054 */  sw        $v0, 0x54($s1)
/* 44710 80069310 A2230064 */  sb        $v1, 0x64($s1)
/* 44714 80069314 92220064 */  lbu       $v0, 0x64($s1)
/* 44718 80069318 00031840 */  sll       $v1, $v1, 1
/* 4471C 8006931C 24630003 */  addiu     $v1, $v1, 0x3
/* 44720 80069320 AE230060 */  sw        $v1, 0x60($s1)
/* 44724 80069324 92230064 */  lbu       $v1, 0x64($s1)
/* 44728 80069328 24420001 */  addiu     $v0, $v0, 0x1
/* 4472C 8006932C 000210C0 */  sll       $v0, $v0, 3
/* 44730 80069330 000318C0 */  sll       $v1, $v1, 3
/* 44734 80069334 AE220058 */  sw        $v0, 0x58($s1)
/* 44738 80069338 00431021 */  addu      $v0, $v0, $v1
/* 4473C 8006933C 0C01A874 */  jal       __osContRamRead
/* 44740 80069340 AE22005C */   sw       $v0, 0x5C($s1)
/* 44744 80069344 00408021 */  addu      $s0, $v0, $zero
/* 44748 80069348 16000008 */  bnez      $s0, .L8006936C
/* 4474C 8006934C 02001021 */   addu     $v0, $s0, $zero
/* 44750 80069350 0C01B308 */  jal       osPfsChecker
/* 44754 80069354 02202021 */   addu     $a0, $s1, $zero
/* 44758 80069358 8E230000 */  lw        $v1, 0x0($s1)
/* 4475C 8006935C 34630001 */  ori       $v1, $v1, 0x1
/* 44760 80069360 0801A4DB */  j         .L8006936C
/* 44764 80069364 AE230000 */   sw       $v1, 0x0($s1)
.L80069368:
/* 44768 80069368 02001021 */  addu      $v0, $s0, $zero
.L8006936C:
/* 4476C 8006936C 8FBF0068 */  lw        $ra, 0x68($sp)
/* 44770 80069370 8FB30064 */  lw        $s3, 0x64($sp)
/* 44774 80069374 8FB20060 */  lw        $s2, 0x60($sp)
/* 44778 80069378 8FB1005C */  lw        $s1, 0x5C($sp)
/* 4477C 8006937C 8FB00058 */  lw        $s0, 0x58($sp)
/* 44780 80069380 03E00008 */  jr        $ra
/* 44784 80069384 27BD0070 */   addiu    $sp, $sp, 0x70

### DECOMPILED C INSTRUCTIONS:

s32 osPfsInitPak(OSMesgQueue *queue, OSPfs *pfs, int channel) {
    int k;
    s32 ret;
    u16 sum;
    u16 isum;
    u8 temp[BLOCKSIZE];
    __OSPackId *id;
    __OSPackId newid;
    PFS_GET_STATUS;
    pfs->queue = queue;
    pfs->channel = channel;
    pfs->status = 0;
    ERRCK(osPfsCheckRamArea(pfs));
    ERRCK(__osPfsSelectBank(pfs, 0));
    ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, (u8*)temp));
    __osIdCheckSum((u16*)temp, &sum, &isum);
    id = (__OSPackId *)temp;
    if (id->checksum != sum || id->inverted_checksum != isum) {
        ret = __osCheckPackId(pfs, id);
        if (ret != 0) {
            pfs->status |= PFS_ID_BROKEN;
            return ret;
        }
    }
    if ((id->deviceid & 1) == 0) {
        ret = __osRepairPackId(pfs, id, &newid);
        if (ret != 0) {
            if (ret == PFS_ERR_ID_FATAL) {
                pfs->status |= PFS_ID_BROKEN;
            }
            return ret;
        }
        id = &newid;
        if ((id->deviceid & 1) == 0) {
            return PFS_ERR_DEVICE;
        }
    }
    bcopy(id, pfs->id, ARRAY_COUNT(pfs->id));
    pfs->version = id->version;
    pfs->banks = id->banks;
    pfs->inode_start_page = pfs->banks * 2 + 3;
    pfs->dir_size = 0x10;
    pfs->inode_table = 8;
    pfs->minode_table = (pfs->banks + 1) * PFS_ONE_PAGE;
    pfs->dir_table = pfs->minode_table + pfs->banks * PFS_ONE_PAGE;
    ERRCK(__osContRamRead(pfs->queue, pfs->channel, 7, pfs->label));
    ret = osPfsChecker(pfs);
    pfs->status |= PFS_INITIALIZED;
    return ret;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel corrupted
/* 485D8 8006D1D8 00052C03 */  sra       $a1, $a1, 16
/* 485DC 8006D1DC 27BDFFC0 */  addiu     $sp, $sp, -0x40
/* 485E0 8006D1E0 AFB40028 */  sw        $s4, 0x28($sp)
/* 485E4 8006D1E4 0080A021 */  addu      $s4, $a0, $zero
/* 485E8 8006D1E8 AFB1001C */  sw        $s1, 0x1C($sp)
/* 485EC 8006D1EC 00C08821 */  addu      $s1, $a2, $zero
/* 485F0 8006D1F0 AFB20020 */  sw        $s2, 0x20($sp)
/* 485F4 8006D1F4 00009021 */  addu      $s2, $zero, $zero
/* 485F8 8006D1F8 AFB00018 */  sw        $s0, 0x18($sp)
/* 485FC 8006D1FC 00008021 */  addu      $s0, $zero, $zero
/* 48600 8006D200 30A300FF */  andi      $v1, $a1, 0xFF
/* 48604 8006D204 00031882 */  srl       $v1, $v1, 2
/* 48608 8006D208 30A5FFFF */  andi      $a1, $a1, 0xFFFF
/* 4860C 8006D20C 00053202 */  srl       $a2, $a1, 8
/* 48610 8006D210 30C20007 */  andi      $v0, $a2, 0x7
/* 48614 8006D214 AFBF0038 */  sw        $ra, 0x38($sp)
/* 48618 8006D218 AFB70034 */  sw        $s7, 0x34($sp)
/* 4861C 8006D21C AFB60030 */  sw        $s6, 0x30($sp)
/* 48620 8006D220 AFB5002C */  sw        $s5, 0x2C($sp)
/* 48624 8006D224 AFB30024 */  sw        $s3, 0x24($sp)
/* 48628 8006D228 92840064 */  lbu       $a0, 0x64($s4)
/* 4862C 8006D22C 00021140 */  sll       $v0, $v0, 5
/* 48630 8006D230 10800037 */  beqz      $a0, .L8006D310
/* 48634 8006D234 0062B821 */   addu     $s7, $v1, $v0
/* 48638 8006D238 00A0A821 */  addu      $s5, $a1, $zero
/* 4863C 8006D23C 00C0B021 */  addu      $s6, $a2, $zero
/* 48640 8006D240 324700FF */  andi      $a3, $s2, 0xFF
.L8006D244:
/* 48644 8006D244 14E00002 */  bnez      $a3, .L8006D250
/* 48648 8006D248 24130001 */   addiu    $s3, $zero, 0x1
/* 4864C 8006D24C 8E930060 */  lw        $s3, 0x60($s4)
.L8006D250:
/* 48650 8006D250 10F60007 */  beq       $a3, $s6, .L8006D270
/* 48654 8006D254 02371021 */   addu     $v0, $s1, $s7
/* 48658 8006D258 90420101 */  lbu       $v0, 0x101($v0)
/* 4865C 8006D25C 30E30007 */  andi      $v1, $a3, 0x7
/* 48660 8006D260 00621007 */  srav      $v0, $v0, $v1
/* 48664 8006D264 30420001 */  andi      $v0, $v0, 0x1
/* 48668 8006D268 10400023 */  beqz      $v0, .L8006D2F8
/* 4866C 8006D26C 00000000 */   nop
.L8006D270:
/* 48670 8006D270 92220100 */  lbu       $v0, 0x100($s1)
/* 48674 8006D274 10E2000C */  beq       $a3, $v0, .L8006D2A8
/* 48678 8006D278 02802021 */   addu     $a0, $s4, $zero
/* 4867C 8006D27C 02202821 */  addu      $a1, $s1, $zero
/* 48680 8006D280 0C01A7A3 */  jal       __osPfsRWInode
/* 48684 8006D284 00003021 */   addu     $a2, $zero, $zero
/* 48688 8006D288 00402021 */  addu      $a0, $v0, $zero
/* 4868C 8006D28C 0004182B */  sltu      $v1, $zero, $a0
/* 48690 8006D290 38820003 */  xori      $v0, $a0, 0x3
/* 48694 8006D294 0002102B */  sltu      $v0, $zero, $v0
/* 48698 8006D298 00621824 */  and       $v1, $v1, $v0
/* 4869C 8006D29C 1460001D */  bnez      $v1, .L8006D314
/* 486A0 8006D2A0 00801021 */   addu     $v0, $a0, $zero
/* 486A4 8006D2A4 A2320100 */  sb        $s2, 0x100($s1)
.L8006D2A8:
/* 486A8 8006D2A8 02602821 */  addu      $a1, $s3, $zero
/* 486AC 8006D2AC 2A020002 */  slti      $v0, $s0, 0x2
/* 486B0 8006D2B0 28A30080 */  slti      $v1, $a1, 0x80
/* 486B4 8006D2B4 00431024 */  and       $v0, $v0, $v1
/* 486B8 8006D2B8 1040000C */  beqz      $v0, .L8006D2EC
/* 486BC 8006D2BC 00051040 */   sll      $v0, $a1, 1
/* 486C0 8006D2C0 00512021 */  addu      $a0, $v0, $s1
.L8006D2C4:
/* 486C4 8006D2C4 94820000 */  lhu       $v0, 0x0($a0)
/* 486C8 8006D2C8 24A50001 */  addiu     $a1, $a1, 0x1
/* 486CC 8006D2CC 28A30080 */  slti      $v1, $a1, 0x80
/* 486D0 8006D2D0 00551026 */  xor       $v0, $v0, $s5
/* 486D4 8006D2D4 2C420001 */  sltiu     $v0, $v0, 0x1
/* 486D8 8006D2D8 02028021 */  addu      $s0, $s0, $v0
/* 486DC 8006D2DC 2A020002 */  slti      $v0, $s0, 0x2
/* 486E0 8006D2E0 00431024 */  and       $v0, $v0, $v1
/* 486E4 8006D2E4 1440FFF7 */  bnez      $v0, .L8006D2C4
/* 486E8 8006D2E8 24840002 */   addiu    $a0, $a0, 0x2
.L8006D2EC:
/* 486EC 8006D2EC 2A020002 */  slti      $v0, $s0, 0x2
/* 486F0 8006D2F0 10400008 */  beqz      $v0, .L8006D314
/* 486F4 8006D2F4 24020002 */   addiu    $v0, $zero, 0x2
.L8006D2F8:
/* 486F8 8006D2F8 92830064 */  lbu       $v1, 0x64($s4)
/* 486FC 8006D2FC 26520001 */  addiu     $s2, $s2, 0x1
/* 48700 8006D300 324200FF */  andi      $v0, $s2, 0xFF
/* 48704 8006D304 0043102B */  sltu      $v0, $v0, $v1
/* 48708 8006D308 1440FFCE */  bnez      $v0, .L8006D244
/* 4870C 8006D30C 324700FF */   andi     $a3, $s2, 0xFF
.L8006D310:
/* 48710 8006D310 02001021 */  addu      $v0, $s0, $zero
.L8006D314:
/* 48714 8006D314 8FBF0038 */  lw        $ra, 0x38($sp)
/* 48718 8006D318 8FB70034 */  lw        $s7, 0x34($sp)
/* 4871C 8006D31C 8FB60030 */  lw        $s6, 0x30($sp)
/* 48720 8006D320 8FB5002C */  lw        $s5, 0x2C($sp)
/* 48724 8006D324 8FB40028 */  lw        $s4, 0x28($sp)
/* 48728 8006D328 8FB30024 */  lw        $s3, 0x24($sp)
/* 4872C 8006D32C 8FB20020 */  lw        $s2, 0x20($sp)
/* 48730 8006D330 8FB1001C */  lw        $s1, 0x1C($sp)
/* 48734 8006D334 8FB00018 */  lw        $s0, 0x18($sp)
/* 48738 8006D338 03E00008 */  jr        $ra
/* 4873C 8006D33C 27BD0040 */   addiu    $sp, $sp, 0x40

### DECOMPILED C INSTRUCTIONS:

    if ((ret = corrupted_init(pfs, &cache)) != 0) {
        return ret;
    }

    for (j = 0; j < pfs->dir_size; j++) {
        if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tempDir)) != 0) {
            return ret;
        }
        if ((tempDir.company_code != 0) || (tempDir.game_code != 0)) {
            if ((tempDir.company_code == 0) || (tempDir.game_code == 0)) {
                cc = -1;
            } else {
                next = tempDir.start_page;
                cl = cc = 0;
                bank = 255;

                while (CHECK_IPAGE(next)) {
                    if (bank != next.inode_t.bank) {
                        bank = next.inode_t.bank;
                        if (prevBank != bank) {
                            ret = __osPfsRWInode(pfs, &tempInode, PFS_READ, bank);
                            prevBank = bank;
                        }
                        if ((ret != 0) && (ret != PFS_ERR_INCONSISTENT)) {
                            return ret;
                        }
                    }
                    if ((cc = corrupted(pfs, next, &cache) - cl) != 0) {
                        break;
                    }
                    cl = 1;
                    next = tempInode.inode_page[next.inode_t.page];
                }
            }
            if ((cc != 0) || (next.ipage != PFS_EOF)) {
                bzero(&tempDir, sizeof(__OSDir));
                if (pfs->activebank != 0) {
                    if ((ret = __osPfsSelectBank(pfs, 0)) != 0) {
                        return ret;
                    }
                }
                if ((ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tempDir, 0)) != 0) {
                    return ret;
                }

                fixed++;
            }
        }
    }

    for (j = 0; j < pfs->dir_size; j++) {
        if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tempDir)) != 0) {
            return ret;
        }

        if ((tempDir.company_code != 0) && (tempDir.game_code != 0) &&
            (tempDir.start_page.ipage >= (u16)pfs->inode_start_page)) { // cast required
            nextNodeInFile[j].ipage = tempDir.start_page.ipage;
        } else {
            nextNodeInFile[j].ipage = 0;
        }
    }

    for (bank = 0; bank < pfs->banks; bank++) {
        ret = __osPfsRWInode(pfs, &tempInode, PFS_READ, bank);
        if ((ret != 0) && (ret != PFS_ERR_INCONSISTENT)) {
            return (ret);
        }
        offset = ((bank > PFS_ID_BANK_256K) ? 1 : pfs->inode_start_page);
        for (j = 0; j < offset; j++) {
            checkedInode.inode_page[j].ipage = tempInode.inode_page[j].ipage;
        }
        for (; j < PFS_INODE_SIZE_PER_PAGE; j++) {
            checkedInode.inode_page[j].ipage = PFS_PAGE_NOT_USED;
        }

        for (j = 0; j < pfs->dir_size; j++) {
            while (nextNodeInFile[j].inode_t.bank == bank &&
                   nextNodeInFile[j].ipage >= (u16)pfs->inode_start_page) { // cast required
                u8 val;
                val = nextNodeInFile[j].inode_t.page;
                nextNodeInFile[j] = checkedInode.inode_page[val] = tempInode.inode_page[val];
            }
        }
        if ((ret = __osPfsRWInode(pfs, &checkedInode, PFS_WRITE, bank)) != 0) {
            return ret;
        }
    }

    if (fixed != 0) {
        pfs->status |= PFS_CORRUPTED;
    } else {
        pfs->status &= ~PFS_CORRUPTED;
    }
    return 0;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel appendGfx_msg_prim_rect
/* C3108 8012CA08 0080502D */  daddu     $t2, $a0, $zero
/* C310C 8012CA0C 00A0582D */  daddu     $t3, $a1, $zero
/* C3110 8012CA10 3C09800A */  lui       $t1, %hi(gMainGfxPos)
/* C3114 8012CA14 2529A66C */  addiu     $t1, $t1, %lo(gMainGfxPos)
/* C3118 8012CA18 3C02E700 */  lui       $v0, (0xE7000000 >> 16)
/* C311C 8012CA1C 8D280000 */  lw        $t0, 0x0($t1)
/* C3120 8012CA20 97AF0012 */  lhu       $t7, 0x12($sp)
/* C3124 8012CA24 97B80016 */  lhu       $t8, 0x16($sp)
/* C3128 8012CA28 97AD001A */  lhu       $t5, 0x1A($sp)
/* C312C 8012CA2C 97AE001E */  lhu       $t6, 0x1E($sp)
/* C3130 8012CA30 0100182D */  daddu     $v1, $t0, $zero
/* C3134 8012CA34 25080008 */  addiu     $t0, $t0, 0x8
/* C3138 8012CA38 AD280000 */  sw        $t0, 0x0($t1)
/* C313C 8012CA3C AC620000 */  sw        $v0, 0x0($v1)
/* C3140 8012CA40 AC600004 */  sw        $zero, 0x4($v1)
/* C3144 8012CA44 30E300FF */  andi      $v1, $a3, 0xFF
/* C3148 8012CA48 240200FF */  addiu     $v0, $zero, 0xFF
/* C314C 8012CA4C 1462000A */  bne       $v1, $v0, .L8012CA78
/* C3150 8012CA50 00C0602D */   daddu    $t4, $a2, $zero
/* C3154 8012CA54 3C04FCFF */  lui       $a0, (0xFCFFFFFF >> 16)
/* C3158 8012CA58 3484FFFF */  ori       $a0, $a0, (0xFCFFFFFF & 0xFFFF)
/* C315C 8012CA5C 3C03FFFD */  lui       $v1, (0xFFFDFCFE >> 16)
/* C3160 8012CA60 3463FCFE */  ori       $v1, $v1, (0xFFFDFCFE & 0xFFFF)
/* C3164 8012CA64 25020008 */  addiu     $v0, $t0, 0x8
/* C3168 8012CA68 AD220000 */  sw        $v0, 0x0($t1)
/* C316C 8012CA6C AD040000 */  sw        $a0, 0x0($t0)
/* C3170 8012CA70 0804B2AE */  j         .L8012CAB8
/* C3174 8012CA74 AD030004 */   sw       $v1, 0x4($t0)
.L8012CA78:
/* C3178 8012CA78 3C05E200 */  lui       $a1, (0xE200001C >> 16)
/* C317C 8012CA7C 34A5001C */  ori       $a1, $a1, (0xE200001C & 0xFFFF)
/* C3180 8012CA80 3C030050 */  lui       $v1, (0x504240 >> 16)
/* C3184 8012CA84 34634240 */  ori       $v1, $v1, (0x504240 & 0xFFFF)
/* C3188 8012CA88 3C06FCFF */  lui       $a2, (0xFCFFFFFF >> 16)
/* C318C 8012CA8C 34C6FFFF */  ori       $a2, $a2, (0xFCFFFFFF & 0xFFFF)
/* C3190 8012CA90 3C04FFFD */  lui       $a0, (0xFFFDF6FB >> 16)
/* C3194 8012CA94 3484F6FB */  ori       $a0, $a0, (0xFFFDF6FB & 0xFFFF)
/* C3198 8012CA98 25020008 */  addiu     $v0, $t0, 0x8
/* C319C 8012CA9C AD220000 */  sw        $v0, 0x0($t1)
/* C31A0 8012CAA0 25020010 */  addiu     $v0, $t0, 0x10
/* C31A4 8012CAA4 AD050000 */  sw        $a1, 0x0($t0)
/* C31A8 8012CAA8 AD030004 */  sw        $v1, 0x4($t0)
/* C31AC 8012CAAC AD220000 */  sw        $v0, 0x0($t1)
/* C31B0 8012CAB0 AD060008 */  sw        $a2, 0x8($t0)
/* C31B4 8012CAB4 AD04000C */  sw        $a0, 0xC($t0)
.L8012CAB8:
/* C31B8 8012CAB8 3C06E200 */  lui       $a2, (0xE200001C >> 16)
/* C31BC 8012CABC 34C6001C */  ori       $a2, $a2, (0xE200001C & 0xFFFF)
/* C31C0 8012CAC0 3C050F0A */  lui       $a1, (0xF0A7008 >> 16)
/* C31C4 8012CAC4 3C09800A */  lui       $t1, %hi(gMainGfxPos)
/* C31C8 8012CAC8 2529A66C */  addiu     $t1, $t1, %lo(gMainGfxPos)
/* C31CC 8012CACC 34A57008 */  ori       $a1, $a1, (0xF0A7008 & 0xFFFF)
/* C31D0 8012CAD0 3C02FA00 */  lui       $v0, (0xFA000000 >> 16)
/* C31D4 8012CAD4 8D280000 */  lw        $t0, 0x0($t1)
/* C31D8 8012CAD8 000A1E00 */  sll       $v1, $t2, 24
/* C31DC 8012CADC 0100202D */  daddu     $a0, $t0, $zero
/* C31E0 8012CAE0 25080008 */  addiu     $t0, $t0, 0x8
/* C31E4 8012CAE4 AD280000 */  sw        $t0, 0x0($t1)
/* C31E8 8012CAE8 AC820000 */  sw        $v0, 0x0($a0)
/* C31EC 8012CAEC 316200FF */  andi      $v0, $t3, 0xFF
/* C31F0 8012CAF0 00021400 */  sll       $v0, $v0, 16
/* C31F4 8012CAF4 00621825 */  or        $v1, $v1, $v0
/* C31F8 8012CAF8 318200FF */  andi      $v0, $t4, 0xFF
/* C31FC 8012CAFC 00021200 */  sll       $v0, $v0, 8
/* C3200 8012CB00 00621825 */  or        $v1, $v1, $v0
/* C3204 8012CB04 30E200FF */  andi      $v0, $a3, 0xFF
/* C3208 8012CB08 00621825 */  or        $v1, $v1, $v0
/* C320C 8012CB0C 25020008 */  addiu     $v0, $t0, 0x8
/* C3210 8012CB10 AC830004 */  sw        $v1, 0x4($a0)
/* C3214 8012CB14 31A403FF */  andi      $a0, $t5, 0x3FF
/* C3218 8012CB18 00042380 */  sll       $a0, $a0, 14
/* C321C 8012CB1C AD220000 */  sw        $v0, 0x0($t1)
/* C3220 8012CB20 31C203FF */  andi      $v0, $t6, 0x3FF
/* C3224 8012CB24 00021080 */  sll       $v0, $v0, 2
/* C3228 8012CB28 3C03F600 */  lui       $v1, (0xF6000000 >> 16)
/* C322C 8012CB2C 00431025 */  or        $v0, $v0, $v1
/* C3230 8012CB30 00822025 */  or        $a0, $a0, $v0
/* C3234 8012CB34 31E303FF */  andi      $v1, $t7, 0x3FF
/* C3238 8012CB38 00031B80 */  sll       $v1, $v1, 14
/* C323C 8012CB3C 330203FF */  andi      $v0, $t8, 0x3FF
/* C3240 8012CB40 00021080 */  sll       $v0, $v0, 2
/* C3244 8012CB44 00621825 */  or        $v1, $v1, $v0
/* C3248 8012CB48 25020010 */  addiu     $v0, $t0, 0x10
/* C324C 8012CB4C AD040000 */  sw        $a0, 0x0($t0)
/* C3250 8012CB50 AD030004 */  sw        $v1, 0x4($t0)
/* C3254 8012CB54 AD220000 */  sw        $v0, 0x0($t1)
/* C3258 8012CB58 3C038015 */  lui       $v1, %hi(msg_drawState)
/* C325C 8012CB5C 8C635D74 */  lw        $v1, %lo(msg_drawState)($v1)
/* C3260 8012CB60 3C02E700 */  lui       $v0, (0xE7000000 >> 16)
/* C3264 8012CB64 AD020008 */  sw        $v0, 0x8($t0)
/* C3268 8012CB68 25020018 */  addiu     $v0, $t0, 0x18
/* C326C 8012CB6C AD00000C */  sw        $zero, 0xC($t0)
/* C3270 8012CB70 AD220000 */  sw        $v0, 0x0($t1)
/* C3274 8012CB74 AD060010 */  sw        $a2, 0x10($t0)
/* C3278 8012CB78 AD050014 */  sw        $a1, 0x14($t0)
/* C327C 8012CB7C 90630029 */  lbu       $v1, 0x29($v1)
/* C3280 8012CB80 10600005 */  beqz      $v1, .L8012CB98
/* C3284 8012CB84 24020001 */   addiu    $v0, $zero, 0x1
/* C3288 8012CB88 1062000C */  beq       $v1, $v0, .L8012CBBC
/* C328C 8012CB8C 3C06FCFF */   lui      $a2, (0xFCFFFFFF >> 16)
/* C3290 8012CB90 0804B2F7 */  j         .L8012CBDC
/* C3294 8012CB94 34C6FFFF */   ori      $a2, $a2, (0xFCFFFFFF & 0xFFFF)
.L8012CB98:
/* C3298 8012CB98 3C04FCFF */  lui       $a0, (0xFCFFFFFF >> 16)
/* C329C 8012CB9C 3484FFFF */  ori       $a0, $a0, (0xFCFFFFFF & 0xFFFF)
/* C32A0 8012CBA0 3C03FFFC */  lui       $v1, (0xFFFCF279 >> 16)
/* C32A4 8012CBA4 3463F279 */  ori       $v1, $v1, (0xFFFCF279 & 0xFFFF)
/* C32A8 8012CBA8 25020020 */  addiu     $v0, $t0, 0x20
/* C32AC 8012CBAC AD220000 */  sw        $v0, 0x0($t1)
/* C32B0 8012CBB0 AD040018 */  sw        $a0, 0x18($t0)
/* C32B4 8012CBB4 03E00008 */  jr        $ra
/* C32B8 8012CBB8 AD03001C */   sw       $v1, 0x1C($t0)
.L8012CBBC:
/* C32BC 8012CBBC 3C02FC11 */  lui       $v0, (0xFC11FE23 >> 16)
/* C32C0 8012CBC0 3442FE23 */  ori       $v0, $v0, (0xFC11FE23 & 0xFFFF)
/* C32C4 8012CBC4 25030020 */  addiu     $v1, $t0, 0x20
/* C32C8 8012CBC8 AD230000 */  sw        $v1, 0x0($t1)
/* C32CC 8012CBCC AD020018 */  sw        $v0, 0x18($t0)
/* C32D0 8012CBD0 2402F3F9 */  addiu     $v0, $zero, -0xC07
/* C32D4 8012CBD4 03E00008 */  jr        $ra
/* C32D8 8012CBD8 AD02001C */   sw       $v0, 0x1C($t0)
.L8012CBDC:
/* C32DC 8012CBDC 3C05FFFC */  lui       $a1, (0xFFFCF279 >> 16)
/* C32E0 8012CBE0 3C04800A */  lui       $a0, %hi(gMainGfxPos)
/* C32E4 8012CBE4 2484A66C */  addiu     $a0, $a0, %lo(gMainGfxPos)
/* C32E8 8012CBE8 8C820000 */  lw        $v0, 0x0($a0)
/* C32EC 8012CBEC 34A5F279 */  ori       $a1, $a1, (0xFFFCF279 & 0xFFFF)
/* C32F0 8012CBF0 0040182D */  daddu     $v1, $v0, $zero
/* C32F4 8012CBF4 24420008 */  addiu     $v0, $v0, 0x8
/* C32F8 8012CBF8 AC820000 */  sw        $v0, 0x0($a0)
/* C32FC 8012CBFC AC660000 */  sw        $a2, 0x0($v1)
/* C3300 8012CC00 03E00008 */  jr        $ra
/* C3304 8012CC04 AC650004 */   sw       $a1, 0x4($v1)

### DECOMPILED C INSTRUCTIONS:

void appendGfx_msg_prim_rect(u8 r, u8 g, u8 b, u8 a, u16 ulX, u16 ulY, u16 lrX, u16 lrY) {
    gDPPipeSync(gMainGfxPos++);

    if (a == 255) {
        gDPSetCombineMode(gMainGfxPos++, PM_CC_08, PM_CC_08);
    } else {
        gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
        gDPSetCombineMode(gMainGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
    }

    gDPSetPrimColor(gMainGfxPos++, 0, 0, r, g, b, a);
    gDPFillRectangle(gMainGfxPos++, ulX, ulY, lrX, lrY);
    gDPPipeSync(gMainGfxPos++);
    gDPSetRenderMode(gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);

    switch (msg_drawState->unk_29) {
        case 0:
            gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
            break;
        case 1:
            gDPSetCombineMode(gMainGfxPos++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM);
            break;
        default:
            gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
            break;
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel shimmer_burst_main
/* 3740B0 E0070000 27BDFFA8 */  addiu     $sp, $sp, -0x58
/* 3740B4 E0070004 F7B40040 */  sdc1      $f20, 0x40($sp)
/* 3740B8 E0070008 4485A000 */  mtc1      $a1, $f20
/* 3740BC E007000C F7B60048 */  sdc1      $f22, 0x48($sp)
/* 3740C0 E0070010 4486B000 */  mtc1      $a2, $f22
/* 3740C4 E0070014 AFB30034 */  sw        $s3, 0x34($sp)
/* 3740C8 E0070018 0080982D */  daddu     $s3, $a0, $zero
/* 3740CC E007001C F7B80050 */  sdc1      $f24, 0x50($sp)
/* 3740D0 E0070020 4487C000 */  mtc1      $a3, $f24
/* 3740D4 E0070024 27A40010 */  addiu     $a0, $sp, 0x10
/* 3740D8 E0070028 AFB20030 */  sw        $s2, 0x30($sp)
/* 3740DC E007002C 8FB2006C */  lw        $s2, 0x6C($sp)
/* 3740E0 E0070030 3C02E007 */  lui       $v0, %hi(shimmer_burst_init)
/* 3740E4 E0070034 244201EC */  addiu     $v0, $v0, %lo(shimmer_burst_init)
/* 3740E8 E0070038 AFA20018 */  sw        $v0, 0x18($sp)
/* 3740EC E007003C 3C02E007 */  lui       $v0, %hi(shimmer_burst_update)
/* 3740F0 E0070040 244201F4 */  addiu     $v0, $v0, %lo(shimmer_burst_update)
/* 3740F4 E0070044 AFA2001C */  sw        $v0, 0x1C($sp)
/* 3740F8 E0070048 3C02E007 */  lui       $v0, %hi(shimmer_burst_render)
/* 3740FC E007004C 244206F0 */  addiu     $v0, $v0, %lo(shimmer_burst_render)
/* 374100 E0070050 AFA20020 */  sw        $v0, 0x20($sp)
/* 374104 E0070054 24020038 */  addiu     $v0, $zero, 0x38
/* 374108 E0070058 AFBF0038 */  sw        $ra, 0x38($sp)
/* 37410C E007005C AFB1002C */  sw        $s1, 0x2C($sp)
/* 374110 E0070060 AFB00028 */  sw        $s0, 0x28($sp)
/* 374114 E0070064 AFA00010 */  sw        $zero, 0x10($sp)
/* 374118 E0070068 AFA00024 */  sw        $zero, 0x24($sp)
/* 37411C E007006C 0C080124 */  jal       shim_create_effect_instance
/* 374120 E0070070 AFA20014 */   sw       $v0, 0x14($sp)
/* 374124 E0070074 240419BC */  addiu     $a0, $zero, 0x19BC
/* 374128 E0070078 2411003D */  addiu     $s1, $zero, 0x3D
/* 37412C E007007C 0040802D */  daddu     $s0, $v0, $zero
/* 374130 E0070080 0C08012C */  jal       shim_general_heap_malloc
/* 374134 E0070084 AE110008 */   sw       $s1, 0x8($s0)
/* 374138 E0070088 0040182D */  daddu     $v1, $v0, $zero
/* 37413C E007008C 14600003 */  bnez      $v1, .LE007009C
/* 374140 E0070090 AE03000C */   sw       $v1, 0xC($s0)
.LE0070094:
/* 374144 E0070094 0801C025 */  j         .LE0070094
/* 374148 E0070098 00000000 */   nop
.LE007009C:
/* 37414C E007009C AC730000 */  sw        $s3, 0x0($v1)
/* 374150 E00700A0 1E400004 */  bgtz      $s2, .LE00700B4
/* 374154 E00700A4 AC60003C */   sw       $zero, 0x3C($v1)
/* 374158 E00700A8 240203E8 */  addiu     $v0, $zero, 0x3E8
/* 37415C E00700AC 0801C02E */  j         .LE00700B8
/* 374160 E00700B0 AC620038 */   sw       $v0, 0x38($v1)
.LE00700B4:
/* 374164 E00700B4 AC720038 */  sw        $s2, 0x38($v1)
.LE00700B8:
/* 374168 E00700B8 240400FF */  addiu     $a0, $zero, 0xFF
/* 37416C E00700BC AC64004C */  sw        $a0, 0x4C($v1)
/* 374170 E00700C0 E4740004 */  swc1      $f20, 0x4($v1)
/* 374174 E00700C4 E4760008 */  swc1      $f22, 0x8($v1)
/* 374178 E00700C8 E478000C */  swc1      $f24, 0xC($v1)
/* 37417C E00700CC C7A00068 */  lwc1      $f0, 0x68($sp)
/* 374180 E00700D0 2402001E */  addiu     $v0, $zero, 0x1E
/* 374184 E00700D4 AC640040 */  sw        $a0, 0x40($v1)
/* 374188 E00700D8 AC640044 */  sw        $a0, 0x44($v1)
/* 37418C E00700DC AC640048 */  sw        $a0, 0x48($v1)
/* 374190 E00700E0 E4600060 */  swc1      $f0, 0x60($v1)
/* 374194 E00700E4 44820000 */  mtc1      $v0, $f0
/* 374198 E00700E8 00000000 */  nop
/* 37419C E00700EC 46800020 */  cvt.s.w   $f0, $f0
/* 3741A0 E00700F0 E4600010 */  swc1      $f0, 0x10($v1)
/* 3741A4 E00700F4 16600007 */  bnez      $s3, .LE0070114
/* 3741A8 E00700F8 E4600014 */   swc1     $f0, 0x14($v1)
/* 3741AC E00700FC 240200D7 */  addiu     $v0, $zero, 0xD7
/* 3741B0 E0070100 AC620050 */  sw        $v0, 0x50($v1)
/* 3741B4 E0070104 240200EB */  addiu     $v0, $zero, 0xEB
/* 3741B8 E0070108 AC640054 */  sw        $a0, 0x54($v1)
/* 3741BC E007010C 0801C049 */  j         .LE0070124
/* 3741C0 E0070110 AC620058 */   sw       $v0, 0x58($v1)
.LE0070114:
/* 3741C4 E0070114 2402007F */  addiu     $v0, $zero, 0x7F
/* 3741C8 E0070118 AC640050 */  sw        $a0, 0x50($v1)
/* 3741CC E007011C AC620054 */  sw        $v0, 0x54($v1)
/* 3741D0 E0070120 AC640058 */  sw        $a0, 0x58($v1)
.LE0070124:
/* 3741D4 E0070124 AC64005C */  sw        $a0, 0x5C($v1)
/* 3741D8 E0070128 2A420014 */  slti      $v0, $s2, 0x14
/* 3741DC E007012C 10400009 */  beqz      $v0, .LE0070154
/* 3741E0 E0070130 2463006C */   addiu    $v1, $v1, 0x6C
/* 3741E4 E0070134 2622FFFF */  addiu     $v0, $s1, -0x1
/* 3741E8 E0070138 3C0141A0 */  lui       $at, (0x41A00000 >> 16)
/* 3741EC E007013C 44811000 */  mtc1      $at, $f2
/* 3741F0 E0070140 44820000 */  mtc1      $v0, $f0
/* 3741F4 E0070144 00000000 */  nop
/* 3741F8 E0070148 46800020 */  cvt.s.w   $f0, $f0
/* 3741FC E007014C 0801C05D */  j         .LE0070174
/* 374200 E0070150 46001083 */   div.s    $f2, $f2, $f0
.LE0070154:
/* 374204 E0070154 44920000 */  mtc1      $s2, $f0
/* 374208 E0070158 00000000 */  nop
/* 37420C E007015C 46800020 */  cvt.s.w   $f0, $f0
/* 374210 E0070160 2622FFFF */  addiu     $v0, $s1, -0x1
/* 374214 E0070164 44821000 */  mtc1      $v0, $f2
/* 374218 E0070168 00000000 */  nop
/* 37421C E007016C 468010A0 */  cvt.s.w   $f2, $f2
/* 374220 E0070170 46020083 */  div.s     $f2, $f0, $f2
.LE0070174:
/* 374224 E0070174 24040001 */  addiu     $a0, $zero, 0x1
/* 374228 E0070178 0091102A */  slt       $v0, $a0, $s1
/* 37422C E007017C 10400011 */  beqz      $v0, .LE00701C4
/* 374230 E0070180 0200102D */   daddu    $v0, $s0, $zero
.LE0070184:
/* 374234 E0070184 44840000 */  mtc1      $a0, $f0
/* 374238 E0070188 00000000 */  nop
/* 37423C E007018C 46800020 */  cvt.s.w   $f0, $f0
/* 374240 E0070190 46000007 */  neg.s     $f0, $f0
/* 374244 E0070194 46020002 */  mul.s     $f0, $f0, $f2
/* 374248 E0070198 00000000 */  nop
/* 37424C E007019C 24840001 */  addiu     $a0, $a0, 0x1
/* 374250 E00701A0 4600010D */  trunc.w.s $f4, $f0
/* 374254 E00701A4 44022000 */  mfc1      $v0, $f4
/* 374258 E00701A8 00000000 */  nop
/* 37425C E00701AC 2442FFFF */  addiu     $v0, $v0, -0x1
/* 374260 E00701B0 AC620030 */  sw        $v0, 0x30($v1)
/* 374264 E00701B4 0091102A */  slt       $v0, $a0, $s1
/* 374268 E00701B8 1440FFF2 */  bnez      $v0, .LE0070184
/* 37426C E00701BC 2463006C */   addiu    $v1, $v1, 0x6C
/* 374270 E00701C0 0200102D */  daddu     $v0, $s0, $zero
.LE00701C4:
/* 374274 E00701C4 8FBF0038 */  lw        $ra, 0x38($sp)
/* 374278 E00701C8 8FB30034 */  lw        $s3, 0x34($sp)
/* 37427C E00701CC 8FB20030 */  lw        $s2, 0x30($sp)
/* 374280 E00701D0 8FB1002C */  lw        $s1, 0x2C($sp)
/* 374284 E00701D4 8FB00028 */  lw        $s0, 0x28($sp)
/* 374288 E00701D8 D7B80050 */  ldc1      $f24, 0x50($sp)
/* 37428C E00701DC D7B60048 */  ldc1      $f22, 0x48($sp)
/* 374290 E00701E0 D7B40040 */  ldc1      $f20, 0x40($sp)
/* 374294 E00701E4 03E00008 */  jr        $ra
/* 374298 E00701E8 27BD0058 */   addiu    $sp, $sp, 0x58

### DECOMPILED C INSTRUCTIONS:

EffectInstance* shimmer_burst_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
    EffectBlueprint bp;
    EffectInstance* effect;
    ShimmerBurstFXData* part;
    s32 numParts = 61;
    s32 temp30 = 30;
    f32 temp;
    s32 i;

    bp.init = shimmer_burst_init;
    bp.update = shimmer_burst_update;
    bp.renderWorld = shimmer_burst_render;
    bp.unk_00 = 0;
    bp.renderUI = NULL;
    bp.effectID = EFFECT_SHIMMER_BURST;

    effect = shim_create_effect_instance(&bp);
    effect->numParts = numParts;
    part = effect->data.shimmerBurst = shim_general_heap_malloc(numParts * sizeof(*part));
    ASSERT(effect->data.shimmerBurst != NULL);

    part->unk_00 = arg0;
    part->unk_3C = 0;
    if (arg5 <= 0) {
        part->unk_38 = 1000;
    } else {
        part->unk_38 = arg5;
    }
    part->unk_4C = 255;
    part->unk_04 = arg1;
    part->unk_08 = arg2;
    part->unk_0C = arg3;
    part->unk_60 = arg4;
    part->unk_10 = temp30;
    part->unk_14 = temp30;
    part->unk_40 = 255;
    part->unk_44 = 255;
    part->unk_48 = 255;

    if (arg0 == 0) {
        part->unk_50 = 215;
        part->unk_54 = 255;
        part->unk_58 = 235;
        part->unk_5C = 255;
    } else {
        part->unk_50 = 255;
        part->unk_54 = 127;
        part->unk_58 = 255;
        part->unk_5C = 255;
    }

    part++;

    if (arg5 < 20) {
        temp = 20.0f / (numParts - 1);
    } else {
        temp = (f32) arg5 / (numParts - 1);
    }

    for (i = 1; i < numParts; i++, part++) {
        part->unk_30 = (s32) (-(f32) i * temp) - 1;
    }

    return effect;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel update_effects
/* 35150 80059D50 3C02800A */  lui       $v0, %hi(gOverrideFlags)
/* 35154 80059D54 8C42A650 */  lw        $v0, %lo(gOverrideFlags)($v0)
/* 35158 80059D58 27BDFFD8 */  addiu     $sp, $sp, -0x28
/* 3515C 80059D5C AFBF0020 */  sw        $ra, 0x20($sp)
/* 35160 80059D60 AFB3001C */  sw        $s3, 0x1C($sp)
/* 35164 80059D64 AFB20018 */  sw        $s2, 0x18($sp)
/* 35168 80059D68 AFB10014 */  sw        $s1, 0x14($sp)
/* 3516C 80059D6C 30420C00 */  andi      $v0, $v0, 0xC00
/* 35170 80059D70 14400059 */  bnez      $v0, .L80059ED8
/* 35174 80059D74 AFB00010 */   sw       $s0, 0x10($sp)
/* 35178 80059D78 0000902D */  daddu     $s2, $zero, $zero
/* 3517C 80059D7C 3C10800A */  lui       $s0, %hi(gEffectGraphicsData)
/* 35180 80059D80 26104000 */  addiu     $s0, $s0, %lo(gEffectGraphicsData)
/* 35184 80059D84 24040003 */  addiu     $a0, $zero, 0x3
.L80059D88:
/* 35188 80059D88 8E030000 */  lw        $v1, 0x0($s0)
/* 3518C 80059D8C 30620001 */  andi      $v0, $v1, 0x1
/* 35190 80059D90 10400007 */  beqz      $v0, .L80059DB0
/* 35194 80059D94 26520001 */   addiu    $s2, $s2, 0x1
/* 35198 80059D98 30620002 */  andi      $v0, $v1, 0x2
/* 3519C 80059D9C 14400004 */  bnez      $v0, .L80059DB0
/* 351A0 80059DA0 00000000 */   nop
/* 351A4 80059DA4 34620002 */  ori       $v0, $v1, 0x2
/* 351A8 80059DA8 AE020000 */  sw        $v0, 0x0($s0)
/* 351AC 80059DAC AE04000C */  sw        $a0, 0xC($s0)
.L80059DB0:
/* 351B0 80059DB0 2A42000F */  slti      $v0, $s2, 0xF
/* 351B4 80059DB4 1440FFF4 */  bnez      $v0, .L80059D88
/* 351B8 80059DB8 26100020 */   addiu    $s0, $s0, 0x20
/* 351BC 80059DBC 0000902D */  daddu     $s2, $zero, $zero
/* 351C0 80059DC0 2413FFFD */  addiu     $s3, $zero, -0x3
/* 351C4 80059DC4 3C11800B */  lui       $s1, %hi(gEffectInstances)
/* 351C8 80059DC8 26314398 */  addiu     $s1, $s1, %lo(gEffectInstances)
.L80059DCC:
/* 351CC 80059DCC 8E300000 */  lw        $s0, 0x0($s1)
/* 351D0 80059DD0 52000020 */  beql      $s0, $zero, .L80059E54
/* 351D4 80059DD4 26520001 */   addiu    $s2, $s2, 0x1
/* 351D8 80059DD8 8E020000 */  lw        $v0, 0x0($s0)
/* 351DC 80059DDC 30420001 */  andi      $v0, $v0, 0x1
/* 351E0 80059DE0 5040001C */  beql      $v0, $zero, .L80059E54
/* 351E4 80059DE4 26520001 */   addiu    $s2, $s2, 0x1
/* 351E8 80059DE8 8E030010 */  lw        $v1, 0x10($s0)
/* 351EC 80059DEC 8C620000 */  lw        $v0, 0x0($v1)
/* 351F0 80059DF0 3C048007 */  lui       $a0, %hi(gGameStatusPtr)
/* 351F4 80059DF4 8C84419C */  lw        $a0, %lo(gGameStatusPtr)($a0)
/* 351F8 80059DF8 00531024 */  and       $v0, $v0, $s3
/* 351FC 80059DFC AC620000 */  sw        $v0, 0x0($v1)
/* 35200 80059E00 80820070 */  lb        $v0, 0x70($a0)
/* 35204 80059E04 10400007 */  beqz      $v0, .L80059E24
/* 35208 80059E08 00000000 */   nop
/* 3520C 80059E0C 8E020000 */  lw        $v0, 0x0($s0)
/* 35210 80059E10 30420004 */  andi      $v0, $v0, 0x4
/* 35214 80059E14 5040000F */  beql      $v0, $zero, .L80059E54
/* 35218 80059E18 26520001 */   addiu    $s2, $s2, 0x1
/* 3521C 80059E1C 0801678D */  j         .L80059E34
/* 35220 80059E20 00000000 */   nop
.L80059E24:
/* 35224 80059E24 8E020000 */  lw        $v0, 0x0($s0)
/* 35228 80059E28 30420004 */  andi      $v0, $v0, 0x4
/* 3522C 80059E2C 54400009 */  bnel      $v0, $zero, .L80059E54
/* 35230 80059E30 26520001 */   addiu    $s2, $s2, 0x1
.L80059E34:
/* 35234 80059E34 8E020010 */  lw        $v0, 0x10($s0)
/* 35238 80059E38 8C420010 */  lw        $v0, 0x10($v0)
/* 3523C 80059E3C 0040F809 */  jalr      $v0
/* 35240 80059E40 0200202D */   daddu    $a0, $s0, $zero
/* 35244 80059E44 8E020000 */  lw        $v0, 0x0($s0)
/* 35248 80059E48 34420008 */  ori       $v0, $v0, 0x8
/* 3524C 80059E4C AE020000 */  sw        $v0, 0x0($s0)
/* 35250 80059E50 26520001 */  addiu     $s2, $s2, 0x1
.L80059E54:
/* 35254 80059E54 2A420060 */  slti      $v0, $s2, 0x60
/* 35258 80059E58 1440FFDC */  bnez      $v0, .L80059DCC
/* 3525C 80059E5C 26310004 */   addiu    $s1, $s1, 0x4
/* 35260 80059E60 0000902D */  daddu     $s2, $zero, $zero
/* 35264 80059E64 3C10800A */  lui       $s0, %hi(gEffectGraphicsData)
/* 35268 80059E68 26104000 */  addiu     $s0, $s0, %lo(gEffectGraphicsData)
/* 3526C 80059E6C 2611001C */  addiu     $s1, $s0, 0x1C
.L80059E70:
/* 35270 80059E70 8E030000 */  lw        $v1, 0x0($s0)
/* 35274 80059E74 30620001 */  andi      $v0, $v1, 0x1
/* 35278 80059E78 50400013 */  beql      $v0, $zero, .L80059EC8
/* 3527C 80059E7C 26520001 */   addiu    $s2, $s2, 0x1
/* 35280 80059E80 30620002 */  andi      $v0, $v1, 0x2
/* 35284 80059E84 50400010 */  beql      $v0, $zero, .L80059EC8
/* 35288 80059E88 26520001 */   addiu    $s2, $s2, 0x1
/* 3528C 80059E8C 8E22FFF0 */  lw        $v0, -0x10($s1)
/* 35290 80059E90 10400003 */  beqz      $v0, .L80059EA0
/* 35294 80059E94 2442FFFF */   addiu    $v0, $v0, -0x1
/* 35298 80059E98 080167B1 */  j         .L80059EC4
/* 3529C 80059E9C AE22FFF0 */   sw       $v0, -0x10($s1)
.L80059EA0:
/* 352A0 80059EA0 8E240000 */  lw        $a0, 0x0($s1)
/* 352A4 80059EA4 50800005 */  beql      $a0, $zero, .L80059EBC
/* 352A8 80059EA8 AE000000 */   sw       $zero, 0x0($s0)
/* 352AC 80059EAC 0C00AB1E */  jal       general_heap_free
/* 352B0 80059EB0 00000000 */   nop
/* 352B4 80059EB4 AE200000 */  sw        $zero, 0x0($s1)
/* 352B8 80059EB8 AE000000 */  sw        $zero, 0x0($s0)
.L80059EBC:
/* 352BC 80059EBC 0C019A48 */  jal       osUnmapTLB
/* 352C0 80059EC0 0240202D */   daddu    $a0, $s2, $zero
.L80059EC4:
/* 352C4 80059EC4 26520001 */  addiu     $s2, $s2, 0x1
.L80059EC8:
/* 352C8 80059EC8 26310020 */  addiu     $s1, $s1, 0x20
/* 352CC 80059ECC 2A42000F */  slti      $v0, $s2, 0xF
/* 352D0 80059ED0 1440FFE7 */  bnez      $v0, .L80059E70
/* 352D4 80059ED4 26100020 */   addiu    $s0, $s0, 0x20
.L80059ED8:
/* 352D8 80059ED8 8FBF0020 */  lw        $ra, 0x20($sp)
/* 352DC 80059EDC 8FB3001C */  lw        $s3, 0x1C($sp)
/* 352E0 80059EE0 8FB20018 */  lw        $s2, 0x18($sp)
/* 352E4 80059EE4 8FB10014 */  lw        $s1, 0x14($sp)
/* 352E8 80059EE8 8FB00010 */  lw        $s0, 0x10($sp)
/* 352EC 80059EEC 03E00008 */  jr        $ra
/* 352F0 80059EF0 27BD0028 */   addiu    $sp, $sp, 0x28

### DECOMPILED C INSTRUCTIONS:

void update_effects(void) {
    if (!(gOverrideFlags & (GLOBAL_OVERRIDES_800 | GLOBAL_OVERRIDES_400))) {
        EffectGraphics* effectGraphics;
        s32 i;

        // reset free delay for each EffectGraphics touched in previous update
        for (i = 0, effectGraphics = gEffectGraphicsData; i < ARRAY_COUNT(gEffectGraphicsData); i++, effectGraphics++) {
            if (effectGraphics->flags & FX_GRAPHICS_LOADED) {
                if (!(effectGraphics->flags & FX_GRAPHICS_CAN_FREE)) {
                    effectGraphics->flags |= FX_GRAPHICS_CAN_FREE;
                    effectGraphics->freeDelay = 3;
                }
            }
        }

        // update each EffectInstances
        for (i = 0; i < ARRAY_COUNT(gEffectInstances); i++) {
            EffectInstance* effectInstance = gEffectInstances[i];

            if (effectInstance != NULL && (effectInstance->flags & FX_INSTANCE_FLAG_ENABLED)) {
                effectInstance->graphics->flags &= ~FX_GRAPHICS_CAN_FREE;

                if (gGameStatusPtr->isBattle) {
                    if (effectInstance->flags & FX_INSTANCE_FLAG_BATTLE) {
                        effectInstance->graphics->update(effectInstance);
                        effectInstance->flags |= FX_INSTANCE_FLAG_HAS_UPDATED;
                    }
                } else {
                    if (!(effectInstance->flags & FX_INSTANCE_FLAG_BATTLE)) {
                        effectInstance->graphics->update(effectInstance);
                        effectInstance->flags |= FX_INSTANCE_FLAG_HAS_UPDATED;
                    }
                }
            }
        }

        // free any EffectGraphics which haven't been used recently
        for (i = 0, effectGraphics = gEffectGraphicsData; i < ARRAY_COUNT(gEffectGraphicsData); i++, effectGraphics++) {
            if (effectGraphics->flags & FX_GRAPHICS_LOADED) {
                if (effectGraphics->flags & FX_GRAPHICS_CAN_FREE) {
                    if (effectGraphics->freeDelay != 0) {
                        effectGraphics->freeDelay--;
                    } else {
                        if (effectGraphics->data != NULL) {
                            general_heap_free(effectGraphics->data);
                            effectGraphics->data = NULL;
                        }
                        effectGraphics->flags = FX_GRAPHICS_DISABLED;
                        osUnmapTLB(i);
                    }
                }
            }
        }
    }
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel player_raycast_up_corner
/* 77EB8 800DEA08 27BDFF58 */  addiu     $sp, $sp, -0xA8
/* 77EBC 800DEA0C AFB30064 */  sw        $s3, 0x64($sp)
/* 77EC0 800DEA10 0080982D */  daddu     $s3, $a0, $zero
/* 77EC4 800DEA14 AFB40068 */  sw        $s4, 0x68($sp)
/* 77EC8 800DEA18 00A0A02D */  daddu     $s4, $a1, $zero
/* 77ECC 800DEA1C AFB5006C */  sw        $s5, 0x6C($sp)
/* 77ED0 800DEA20 00C0A82D */  daddu     $s5, $a2, $zero
/* 77ED4 800DEA24 AFB20060 */  sw        $s2, 0x60($sp)
/* 77ED8 800DEA28 00E0902D */  daddu     $s2, $a3, $zero
/* 77EDC 800DEA2C AFB1005C */  sw        $s1, 0x5C($sp)
/* 77EE0 800DEA30 2411FFFF */  addiu     $s1, $zero, -0x1
/* 77EE4 800DEA34 3C040001 */  lui       $a0, (0x10000 >> 16)
/* 77EE8 800DEA38 AFBF0070 */  sw        $ra, 0x70($sp)
/* 77EEC 800DEA3C AFB00058 */  sw        $s0, 0x58($sp)
/* 77EF0 800DEA40 F7BE00A0 */  sdc1      $f30, 0xA0($sp)
/* 77EF4 800DEA44 F7BC0098 */  sdc1      $f28, 0x98($sp)
/* 77EF8 800DEA48 F7BA0090 */  sdc1      $f26, 0x90($sp)
/* 77EFC 800DEA4C F7B80088 */  sdc1      $f24, 0x88($sp)
/* 77F00 800DEA50 F7B60080 */  sdc1      $f22, 0x80($sp)
/* 77F04 800DEA54 F7B40078 */  sdc1      $f20, 0x78($sp)
/* 77F08 800DEA58 C6780000 */  lwc1      $f24, 0x0($s3)
/* 77F0C 800DEA5C C6960000 */  lwc1      $f22, 0x0($s4)
/* 77F10 800DEA60 C6B40000 */  lwc1      $f20, 0x0($s5)
/* 77F14 800DEA64 C6400000 */  lwc1      $f0, 0x0($s2)
/* 77F18 800DEA68 3C013F80 */  lui       $at, (0x3F800000 >> 16)
/* 77F1C 800DEA6C 44811000 */  mtc1      $at, $f2
/* 77F20 800DEA70 4406B000 */  mfc1      $a2, $f22
/* 77F24 800DEA74 4407A000 */  mfc1      $a3, $f20
/* 77F28 800DEA78 4405C000 */  mfc1      $a1, $f24
/* 77F2C 800DEA7C 27A20038 */  addiu     $v0, $sp, 0x38
/* 77F30 800DEA80 E7A00044 */  swc1      $f0, 0x44($sp)
/* 77F34 800DEA84 AFA2001C */  sw        $v0, 0x1C($sp)
/* 77F38 800DEA88 27A2003C */  addiu     $v0, $sp, 0x3C
/* 77F3C 800DEA8C AFA20020 */  sw        $v0, 0x20($sp)
/* 77F40 800DEA90 27A20040 */  addiu     $v0, $sp, 0x40
/* 77F44 800DEA94 AFA20024 */  sw        $v0, 0x24($sp)
/* 77F48 800DEA98 27A20044 */  addiu     $v0, $sp, 0x44
/* 77F4C 800DEA9C AFA20028 */  sw        $v0, 0x28($sp)
/* 77F50 800DEAA0 27A20048 */  addiu     $v0, $sp, 0x48
/* 77F54 800DEAA4 AFA2002C */  sw        $v0, 0x2C($sp)
/* 77F58 800DEAA8 27A2004C */  addiu     $v0, $sp, 0x4C
/* 77F5C 800DEAAC AFA20030 */  sw        $v0, 0x30($sp)
/* 77F60 800DEAB0 27A20050 */  addiu     $v0, $sp, 0x50
/* 77F64 800DEAB4 AFA00010 */  sw        $zero, 0x10($sp)
/* 77F68 800DEAB8 E7A20014 */  swc1      $f2, 0x14($sp)
/* 77F6C 800DEABC AFA00018 */  sw        $zero, 0x18($sp)
/* 77F70 800DEAC0 0C017334 */  jal       test_ray_colliders
/* 77F74 800DEAC4 AFA20034 */   sw       $v0, 0x34($sp)
/* 77F78 800DEAC8 0040802D */  daddu     $s0, $v0, $zero
/* 77F7C 800DEACC 4600C686 */  mov.s     $f26, $f24
/* 77F80 800DEAD0 4600B706 */  mov.s     $f28, $f22
/* 77F84 800DEAD4 0600000C */  bltz      $s0, .L800DEB08
/* 77F88 800DEAD8 4600A786 */   mov.s    $f30, $f20
/* 77F8C 800DEADC C6400000 */  lwc1      $f0, 0x0($s2)
/* 77F90 800DEAE0 C7A20044 */  lwc1      $f2, 0x44($sp)
/* 77F94 800DEAE4 4600103C */  c.lt.s    $f2, $f0
/* 77F98 800DEAE8 00000000 */  nop
/* 77F9C 800DEAEC 45020007 */  bc1fl     .L800DEB0C
/* 77FA0 800DEAF0 4600D606 */   mov.s    $f24, $f26
/* 77FA4 800DEAF4 0200882D */  daddu     $s1, $s0, $zero
/* 77FA8 800DEAF8 E6420000 */  swc1      $f2, 0x0($s2)
/* 77FAC 800DEAFC E6780000 */  swc1      $f24, 0x0($s3)
/* 77FB0 800DEB00 E6960000 */  swc1      $f22, 0x0($s4)
/* 77FB4 800DEB04 E6B40000 */  swc1      $f20, 0x0($s5)
.L800DEB08:
/* 77FB8 800DEB08 4600D606 */  mov.s     $f24, $f26
.L800DEB0C:
/* 77FBC 800DEB0C 4600E586 */  mov.s     $f22, $f28
/* 77FC0 800DEB10 3C014120 */  lui       $at, (0x41200000 >> 16)
/* 77FC4 800DEB14 44811000 */  mtc1      $at, $f2
/* 77FC8 800DEB18 44802000 */  mtc1      $zero, $f4
/* 77FCC 800DEB1C 3C013F80 */  lui       $at, (0x3F800000 >> 16)
/* 77FD0 800DEB20 44810000 */  mtc1      $at, $f0
/* 77FD4 800DEB24 27A20038 */  addiu     $v0, $sp, 0x38
/* 77FD8 800DEB28 E7A20044 */  swc1      $f2, 0x44($sp)
/* 77FDC 800DEB2C AFA20018 */  sw        $v0, 0x18($sp)
/* 77FE0 800DEB30 27A2003C */  addiu     $v0, $sp, 0x3C
/* 77FE4 800DEB34 AFA2001C */  sw        $v0, 0x1C($sp)
/* 77FE8 800DEB38 27A20040 */  addiu     $v0, $sp, 0x40
/* 77FEC 800DEB3C AFA20020 */  sw        $v0, 0x20($sp)
/* 77FF0 800DEB40 27A20044 */  addiu     $v0, $sp, 0x44
/* 77FF4 800DEB44 AFA20024 */  sw        $v0, 0x24($sp)
/* 77FF8 800DEB48 27A20048 */  addiu     $v0, $sp, 0x48
/* 77FFC 800DEB4C AFA20028 */  sw        $v0, 0x28($sp)
/* 78000 800DEB50 27A2004C */  addiu     $v0, $sp, 0x4C
/* 78004 800DEB54 AFA2002C */  sw        $v0, 0x2C($sp)
/* 78008 800DEB58 27A20050 */  addiu     $v0, $sp, 0x50
/* 7800C 800DEB5C E7A00010 */  swc1      $f0, 0x10($sp)
/* 78010 800DEB60 E7A40014 */  swc1      $f4, 0x14($sp)
/* 78014 800DEB64 AFA20030 */  sw        $v0, 0x30($sp)
/* 78018 800DEB68 8EA60000 */  lw        $a2, 0x0($s5)
/* 7801C 800DEB6C 44072000 */  mfc1      $a3, $f4
/* 78020 800DEB70 C66C0000 */  lwc1      $f12, 0x0($s3)
/* 78024 800DEB74 C68E0000 */  lwc1      $f14, 0x0($s4)
/* 78028 800DEB78 0C017512 */  jal       test_ray_entities
/* 7802C 800DEB7C 4600F506 */   mov.s    $f20, $f30
/* 78030 800DEB80 0040802D */  daddu     $s0, $v0, $zero
/* 78034 800DEB84 06000010 */  bltz      $s0, .L800DEBC8
/* 78038 800DEB88 0220102D */   daddu    $v0, $s1, $zero
/* 7803C 800DEB8C C6420000 */  lwc1      $f2, 0x0($s2)
/* 78040 800DEB90 C7A00044 */  lwc1      $f0, 0x44($sp)
/* 78044 800DEB94 4602003C */  c.lt.s    $f0, $f2
/* 78048 800DEB98 00000000 */  nop
/* 7804C 800DEB9C 4500000A */  bc1f      .L800DEBC8
/* 78050 800DEBA0 00000000 */   nop
/* 78054 800DEBA4 0C04417A */  jal       get_entity_by_index
/* 78058 800DEBA8 0200202D */   daddu    $a0, $s0, $zero
/* 7805C 800DEBAC C7A00044 */  lwc1      $f0, 0x44($sp)
/* 78060 800DEBB0 36114000 */  ori       $s1, $s0, 0x4000
/* 78064 800DEBB4 E6400000 */  swc1      $f0, 0x0($s2)
/* 78068 800DEBB8 E6780000 */  swc1      $f24, 0x0($s3)
/* 7806C 800DEBBC E6960000 */  swc1      $f22, 0x0($s4)
/* 78070 800DEBC0 E6B40000 */  swc1      $f20, 0x0($s5)
/* 78074 800DEBC4 0220102D */  daddu     $v0, $s1, $zero
.L800DEBC8:
/* 78078 800DEBC8 8FBF0070 */  lw        $ra, 0x70($sp)
/* 7807C 800DEBCC 8FB5006C */  lw        $s5, 0x6C($sp)
/* 78080 800DEBD0 8FB40068 */  lw        $s4, 0x68($sp)
/* 78084 800DEBD4 8FB30064 */  lw        $s3, 0x64($sp)
/* 78088 800DEBD8 8FB20060 */  lw        $s2, 0x60($sp)
/* 7808C 800DEBDC 8FB1005C */  lw        $s1, 0x5C($sp)
/* 78090 800DEBE0 8FB00058 */  lw        $s0, 0x58($sp)
/* 78094 800DEBE4 D7BE00A0 */  ldc1      $f30, 0xA0($sp)
/* 78098 800DEBE8 D7BC0098 */  ldc1      $f28, 0x98($sp)
/* 7809C 800DEBEC D7BA0090 */  ldc1      $f26, 0x90($sp)
/* 780A0 800DEBF0 D7B80088 */  ldc1      $f24, 0x88($sp)
/* 780A4 800DEBF4 D7B60080 */  ldc1      $f22, 0x80($sp)
/* 780A8 800DEBF8 D7B40078 */  ldc1      $f20, 0x78($sp)
/* 780AC 800DEBFC 03E00008 */  jr        $ra
/* 780B0 800DEC00 27BD00A8 */   addiu    $sp, $sp, 0xA8

### DECOMPILED C INSTRUCTIONS:

s32 player_raycast_up_corners(PlayerStatus* player, f32* posX, f32* posY, f32* posZ, f32* hitDepth, f32 yaw) {
    f32 startX;
    f32 startY;
    f32 startZ;
    f32 depth;
    f32 theta;
    f32 deltaZ;
    f32 deltaX;
    f32 x,y,z;
    s32 ret;
    s32 hitID;
    f32 radius;

    radius = player->colliderDiameter * 0.3f;
    theta = DEG_TO_RAD(yaw);
    deltaX = radius * sin_rad(theta);
    deltaZ = -radius * cos_rad(theta);

    x = *posX;
    y = *posY;
    z = *posZ;

    depth = *hitDepth;
    startX = x + deltaX;
    startY = y;
    startZ = z + deltaZ;

    ret = NO_COLLIDER;
    hitID = player_raycast_up_corner(&startX, &startY, &startZ, &depth);

    if (hitID < 0) {
        startX = x - deltaX;
        startY = y;
        startZ = z - deltaZ;
        hitID = player_raycast_up_corner(&startX, &startY, &startZ, &depth);
    }

    if (hitID < 0) {
        startX = x + deltaZ;
        startY = y;
        startZ = z + deltaX;
        hitID = player_raycast_up_corner(&startX, &startY, &startZ, &depth);
    }

    if (hitID < 0) {
        startX = x - deltaZ;
        startY = y;
        startZ = z - deltaX;
        hitID = player_raycast_up_corner(&startX, &startY, &startZ, &depth);
    }

    if (hitID >= 0) {
        *posX = startX;
        *posY = startY;
        *posZ = startZ;
        *hitDepth = depth;
        ret = hitID;
    }

    if (ret < 0) {
        *posX = startX;
        *posY = startY;
        *posZ = startZ;
        *hitDepth = 0;
    }

    return ret;
}


### RAW ASSEMBLY INSTRUCTIONS:

dlabel func_80263064
/* 191944 80263064 0000402D */  daddu     $t0, $zero, $zero
/* 191948 80263068 14A00003 */  bnez      $a1, .L80263078
/* 19194C 8026306C 248A022C */   addiu    $t2, $a0, 0x22C
/* 191950 80263070 03E00008 */  jr        $ra
/* 191954 80263074 0100102D */   daddu    $v0, $t0, $zero
.L80263078:
/* 191958 80263078 80AC01F3 */  lb        $t4, 0x1F3($a1)
/* 19195C 8026307C 8CA601F4 */  lw        $a2, 0x1F4($a1)
/* 191960 80263080 010C102A */  slt       $v0, $t0, $t4
/* 191964 80263084 10400067 */  beqz      $v0, .L80263224
/* 191968 80263088 0000482D */   daddu    $t1, $zero, $zero
/* 19196C 8026308C 3C0F0002 */  lui       $t7, (0x20000 >> 16)
/* 191970 80263090 3C0E0080 */  lui       $t6, (0x800000 >> 16)
/* 191974 80263094 3C0D0010 */  lui       $t5, (0x100000 >> 16)
/* 191978 80263098 2487023C */  addiu     $a3, $a0, 0x23C
.L8026309C:
/* 19197C 8026309C 8CC30000 */  lw        $v1, 0x0($a2)
/* 191980 802630A0 006F1024 */  and       $v0, $v1, $t7
/* 191984 802630A4 1440005A */  bnez      $v0, .L80263210
/* 191988 802630A8 006E1024 */   and      $v0, $v1, $t6
/* 19198C 802630AC 5040005A */  beql      $v0, $zero, .L80263218
/* 191990 802630B0 25290001 */   addiu    $t1, $t1, 0x1
/* 191994 802630B4 8CCB0008 */  lw        $t3, 0x8($a2)
/* 191998 802630B8 006D1024 */  and       $v0, $v1, $t5
/* 19199C 802630BC 14400026 */  bnez      $v0, .L80263158
/* 1919A0 802630C0 00000000 */   nop
/* 1919A4 802630C4 C4A40144 */  lwc1      $f4, 0x144($a1)
/* 1919A8 802630C8 C4A20148 */  lwc1      $f2, 0x148($a1)
/* 1919AC 802630CC 84C20014 */  lh        $v0, 0x14($a2)
/* 1919B0 802630D0 C4A6014C */  lwc1      $f6, 0x14C($a1)
/* 1919B4 802630D4 44820000 */  mtc1      $v0, $f0
/* 1919B8 802630D8 00000000 */  nop
/* 1919BC 802630DC 46800020 */  cvt.s.w   $f0, $f0
/* 1919C0 802630E0 8CA20000 */  lw        $v0, 0x0($a1)
/* 1919C4 802630E4 30420800 */  andi      $v0, $v0, 0x800
/* 1919C8 802630E8 14400007 */  bnez      $v0, .L80263108
/* 1919CC 802630EC 46002100 */   add.s    $f4, $f4, $f0
/* 1919D0 802630F0 84C20016 */  lh        $v0, 0x16($a2)
/* 1919D4 802630F4 44820000 */  mtc1      $v0, $f0
/* 1919D8 802630F8 00000000 */  nop
/* 1919DC 802630FC 46800020 */  cvt.s.w   $f0, $f0
/* 1919E0 80263100 08098C47 */  j         .L8026311C
/* 1919E4 80263104 46001080 */   add.s    $f2, $f2, $f0
.L80263108:
/* 1919E8 80263108 84C20016 */  lh        $v0, 0x16($a2)
/* 1919EC 8026310C 44820000 */  mtc1      $v0, $f0
/* 1919F0 80263110 00000000 */  nop
/* 1919F4 80263114 46800020 */  cvt.s.w   $f0, $f0
/* 1919F8 80263118 46001081 */  sub.s     $f2, $f2, $f0
.L8026311C:
/* 1919FC 8026311C 84C20018 */  lh        $v0, 0x18($a2)
/* 191A00 80263120 44820000 */  mtc1      $v0, $f0
/* 191A04 80263124 00000000 */  nop
/* 191A08 80263128 46800020 */  cvt.s.w   $f0, $f0
/* 191A0C 8026312C 84C2006C */  lh        $v0, 0x6C($a2)
/* 191A10 80263130 46003180 */  add.s     $f6, $f6, $f0
/* 191A14 80263134 44820000 */  mtc1      $v0, $f0
/* 191A18 80263138 00000000 */  nop
/* 191A1C 8026313C 46800020 */  cvt.s.w   $f0, $f0
/* 191A20 80263140 8CA20000 */  lw        $v0, 0x0($a1)
/* 191A24 80263144 30420800 */  andi      $v0, $v0, 0x800
/* 191A28 80263148 1040000E */  beqz      $v0, .L80263184
/* 191A2C 8026314C 46002100 */   add.s    $f4, $f4, $f0
/* 191A30 80263150 08098C67 */  j         .L8026319C
/* 191A34 80263154 00000000 */   nop
.L80263158:
/* 191A38 80263158 C4C4002C */  lwc1      $f4, 0x2C($a2)
/* 191A3C 8026315C C4C20030 */  lwc1      $f2, 0x30($a2)
/* 191A40 80263160 84C2006C */  lh        $v0, 0x6C($a2)
/* 191A44 80263164 C4C60034 */  lwc1      $f6, 0x34($a2)
/* 191A48 80263168 44820000 */  mtc1      $v0, $f0
/* 191A4C 8026316C 00000000 */  nop
/* 191A50 80263170 46800020 */  cvt.s.w   $f0, $f0
/* 191A54 80263174 8CA20000 */  lw        $v0, 0x0($a1)
/* 191A58 80263178 30420800 */  andi      $v0, $v0, 0x800
/* 191A5C 8026317C 14400007 */  bnez      $v0, .L8026319C
/* 191A60 80263180 46002100 */   add.s    $f4, $f4, $f0
.L80263184:
/* 191A64 80263184 84C2006E */  lh        $v0, 0x6E($a2)
/* 191A68 80263188 44820000 */  mtc1      $v0, $f0
/* 191A6C 8026318C 00000000 */  nop
/* 191A70 80263190 46800020 */  cvt.s.w   $f0, $f0
/* 191A74 80263194 08098C6C */  j         .L802631B0
/* 191A78 80263198 46001080 */   add.s    $f2, $f2, $f0
.L8026319C:
/* 191A7C 8026319C 84C2006E */  lh        $v0, 0x6E($a2)
/* 191A80 802631A0 44820000 */  mtc1      $v0, $f0
/* 191A84 802631A4 00000000 */  nop
/* 191A88 802631A8 46800020 */  cvt.s.w   $f0, $f0
/* 191A8C 802631AC 46001081 */  sub.s     $f2, $f2, $f0
.L802631B0:
/* 191A90 802631B0 94A20192 */  lhu       $v0, 0x192($a1)
/* 191A94 802631B4 25080001 */  addiu     $t0, $t0, 0x1
/* 191A98 802631B8 A5420000 */  sh        $v0, 0x0($t2)
/* 191A9C 802631BC A4820428 */  sh        $v0, 0x428($a0)
/* 191AA0 802631C0 91620004 */  lbu       $v0, 0x4($t3)
/* 191AA4 802631C4 254A0014 */  addiu     $t2, $t2, 0x14
/* 191AA8 802631C8 00021600 */  sll       $v0, $v0, 24
/* 191AAC 802631CC 00021603 */  sra       $v0, $v0, 24
/* 191AB0 802631D0 A4E2FFF2 */  sh        $v0, -0xE($a3)
/* 191AB4 802631D4 A0820426 */  sb        $v0, 0x426($a0)
/* 191AB8 802631D8 4600220D */  trunc.w.s $f8, $f4
/* 191ABC 802631DC 44024000 */  mfc1      $v0, $f8
/* 191AC0 802631E0 00000000 */  nop
/* 191AC4 802631E4 A4E2FFF4 */  sh        $v0, -0xC($a3)
/* 191AC8 802631E8 4600120D */  trunc.w.s $f8, $f2
/* 191ACC 802631EC 44024000 */  mfc1      $v0, $f8
/* 191AD0 802631F0 00000000 */  nop
/* 191AD4 802631F4 A4E2FFF6 */  sh        $v0, -0xA($a3)
/* 191AD8 802631F8 4600320D */  trunc.w.s $f8, $f6
/* 191ADC 802631FC 44024000 */  mfc1      $v0, $f8
/* 191AE0 80263200 00000000 */  nop
/* 191AE4 80263204 A4E2FFF8 */  sh        $v0, -0x8($a3)
/* 191AE8 80263208 A0E00000 */  sb        $zero, 0x0($a3)
/* 191AEC 8026320C 24E70014 */  addiu     $a3, $a3, 0x14
.L80263210:
/* 191AF0 80263210 8CC6000C */  lw        $a2, 0xC($a2)
/* 191AF4 80263214 25290001 */  addiu     $t1, $t1, 0x1
.L80263218:
/* 191AF8 80263218 012C102A */  slt       $v0, $t1, $t4
/* 191AFC 8026321C 1440FF9F */  bnez      $v0, .L8026309C
/* 191B00 80263220 00000000 */   nop
.L80263224:
/* 191B04 80263224 A088040C */  sb        $t0, 0x40C($a0)
/* 191B08 80263228 03E00008 */  jr        $ra
/* 191B0C 8026322C 0100102D */   daddu    $v0, $t0, $zero

### DECOMPILED C INSTRUCTIONS:

s32 func_80263064(Actor* actor0, Actor* actor1, s32 unused) {
    s32 ret = 0;
    SelectableTarget* target = actor0->targetData;
    s32 numParts;
    ActorPart* part;
    s32 i;

    if (actor1 == NULL) {
        return ret;
    }

    numParts = actor1->numParts;
    part = actor1->partsTable;

    for (i = 0; i < numParts; i++) {
        if (!(part->flags & ACTOR_PART_FLAG_NO_TARGET)) {
            if (!(part->flags & ACTOR_PART_FLAG_MULTI_TARGET)) {
                continue;
            } else {
                ActorPartBlueprint* bp = part->staticData;
                f32 x, y, z;

                if (!(part->flags & ACTOR_PART_FLAG_USE_ABSOLUTE_POSITION)) {
                    x = actor1->currentPos.x;
                    y = actor1->currentPos.y;
                    z = actor1->currentPos.z;

                    x += part->partOffset.x;
                    if (!(actor1->flags & ACTOR_FLAG_UPSIDE_DOWN)) {
                        y += part->partOffset.y;
                    } else {
                        y -= part->partOffset.y;
                    }
                    z += part->partOffset.z;

                    x += part->targetOffset.x;
                    if (!(actor1->flags & ACTOR_FLAG_UPSIDE_DOWN)) {
                        y += part->targetOffset.y;
                    } else {
                        y -= part->targetOffset.y;
                    }
                } else {
                    x = part->absolutePosition.x;
                    y = part->absolutePosition.y;
                    z = part->absolutePosition.z;

                    x += part->targetOffset.x;
                    if (!(actor1->flags & ACTOR_FLAG_UPSIDE_DOWN)) {
                        y += part->targetOffset.y;
                    } else {
                        y -= part->targetOffset.y;
                    }
                }

                actor0->targetActorID = target->actorID = actor1->actorID;
                actor0->targetPartIndex = target->partID = bp->index;
                target->posA.x = x;
                target->posA.y = y;
                target->posA.z = z;
                target->unk_10 = 0;
                target++;
                ret++;
            }
        }
        part = part->nextPart;
    }
    actor0->targetListLength = ret;
    return ret;
}