### RAW ASSEMBLY INSTRUCTIONS:

glabel load_engine_data
/* 21DC 80026DDC 27BDFFE8 */  addiu     $sp, $sp, -0x18
/* 21E0 80026DE0 3C040010 */  lui       $a0, %hi(D_FEE30)
/* 21E4 80026DE4 2484EE30 */  addiu     $a0, $a0, %lo(D_FEE30)
/* 21E8 80026DE8 3C050010 */  lui       $a1, %hi(D_102610)
/* 21EC 80026DEC 24A52610 */  addiu     $a1, $a1, %lo(D_102610)
/* 21F0 80026DF0 3C06802E */  lui       $a2, %hi(spr_init_quad_cache)
/* 21F4 80026DF4 24C6BD40 */  addiu     $a2, $a2, %lo(spr_init_quad_cache)
/* 21F8 80026DF8 AFBF0014 */  sw        $ra, 0x14($sp)
/* 21FC 80026DFC 0C00A5CF */  jal       dma_copy
/* 2200 80026E00 AFB00010 */   sw       $s0, 0x10($sp)
/* 2204 80026E04 3C040007 */  lui       $a0, %hi(D_759B0)
/* 2208 80026E08 248459B0 */  addiu     $a0, $a0, %lo(D_759B0)
/* 220C 80026E0C 3C05000A */  lui       $a1, %hi(D_A5DD0)
/* 2210 80026E10 24A55DD0 */  addiu     $a1, $a1, %lo(D_A5DD0)
/* 2214 80026E14 3C06800E */  lui       $a2, %hi(npc_raycast_down)
/* 2218 80026E18 24C6C500 */  addiu     $a2, $a2, %lo(npc_raycast_down)
/* 221C 80026E1C 0C00A5CF */  jal       dma_copy
/* 2220 80026E20 00000000 */   nop
/* 2224 80026E24 3C04000E */  lui       $a0, %hi(D_E79B0)
/* 2228 80026E28 248479B0 */  addiu     $a0, $a0, %lo(D_E79B0)
/* 222C 80026E2C 3C050010 */  lui       $a1, %hi(D_FEE30)
/* 2230 80026E30 24A5EE30 */  addiu     $a1, $a1, %lo(D_FEE30)
/* 2234 80026E34 3C06802C */  lui       $a2, %hi(sort_scripts)
/* 2238 80026E38 24C63000 */  addiu     $a2, $a2, %lo(sort_scripts)
/* 223C 80026E3C 0C00A5CF */  jal       dma_copy
/* 2240 80026E40 00000000 */   nop
/* 2244 80026E44 3C040010 */  lui       $a0, %hi(D_102610)
/* 2248 80026E48 24842610 */  addiu     $a0, $a0, %lo(D_102610)
/* 224C 80026E4C 3C050011 */  lui       $a1, %hi(D_10CC10)
/* 2250 80026E50 24A5CC10 */  addiu     $a1, $a1, %lo(D_10CC10)
/* 2254 80026E54 3C06802E */  lui       $a2, %hi(entity_Shadow_init)
/* 2258 80026E58 24C60D90 */  addiu     $a2, $a2, %lo(entity_Shadow_init)
/* 225C 80026E5C 0C00A5CF */  jal       dma_copy
/* 2260 80026E60 00000000 */   nop
/* 2264 80026E64 3C04000A */  lui       $a0, %hi(D_A5DD0)
/* 2268 80026E68 24845DD0 */  addiu     $a0, $a0, %lo(D_A5DD0)
/* 226C 80026E6C 3C05000E */  lui       $a1, %hi(D_E79B0)
/* 2270 80026E70 24A579B0 */  addiu     $a1, $a1, %lo(D_E79B0)
/* 2274 80026E74 3C068011 */  lui       $a2, %hi(update_entities)
/* 2278 80026E78 24C6F6D0 */  addiu     $a2, $a2, %lo(update_entities)
/* 227C 80026E7C 0C00A5CF */  jal       dma_copy
/* 2280 80026E80 00000000 */   nop
/* 2284 80026E84 3C040011 */  lui       $a0, %hi(D_10CC10)
/* 2288 80026E88 2484CC10 */  addiu     $a0, $a0, %lo(D_10CC10)
/* 228C 80026E8C 3C050011 */  lui       $a1, %hi(D_10F1B0)
/* 2290 80026E90 24A5F1B0 */  addiu     $a1, $a1, %lo(D_10F1B0)
/* 2294 80026E94 3C06802F */  lui       $a2, %hi(D_802EB3D0)
/* 2298 80026E98 24C6B3D0 */  addiu     $a2, $a2, %lo(D_802EB3D0)
/* 229C 80026E9C 0C00A5CF */  jal       dma_copy
/* 22A0 80026EA0 00000000 */   nop
/* 22A4 80026EA4 3C108007 */  lui       $s0, %hi(gGameStatusPtr)
/* 22A8 80026EA8 2610419C */  addiu     $s0, $s0, %lo(gGameStatusPtr)
/* 22AC 80026EAC 8E020000 */  lw        $v0, 0x0($s0)
/* 22B0 80026EB0 3C01800A */  lui       $at, %hi(gOverrideFlags)
/* 22B4 80026EB4 AC20A650 */  sw        $zero, %lo(gOverrideFlags)($at)
/* 22B8 80026EB8 A0400079 */  sb        $zero, 0x79($v0)
/* 22BC 80026EBC 8E030000 */  lw        $v1, 0x0($s0)
/* 22C0 80026EC0 24040001 */  addiu     $a0, $zero, 0x1
/* 22C4 80026EC4 A064007A */  sb        $a0, 0x7A($v1)
/* 22C8 80026EC8 8E020000 */  lw        $v0, 0x0($s0)
/* 22CC 80026ECC A4600148 */  sh        $zero, 0x148($v1)
/* 22D0 80026ED0 A044007C */  sb        $a0, 0x7C($v0)
/* 22D4 80026ED4 8E030000 */  lw        $v1, 0x0($s0)
/* 22D8 80026ED8 2402FFFF */  addiu     $v0, $zero, -0x1
/* 22DC 80026EDC A06200A8 */  sb        $v0, 0xA8($v1)
/* 22E0 80026EE0 8E020000 */  lw        $v0, 0x0($s0)
/* 22E4 80026EE4 A04000AA */  sb        $zero, 0xAA($v0)
/* 22E8 80026EE8 8E020000 */  lw        $v0, 0x0($s0)
/* 22EC 80026EEC A0400081 */  sb        $zero, 0x81($v0)
/* 22F0 80026EF0 8E030000 */  lw        $v1, 0x0($s0)
/* 22F4 80026EF4 2402FFF8 */  addiu     $v0, $zero, -0x8
/* 22F8 80026EF8 A0620082 */  sb        $v0, 0x82($v1)
/* 22FC 80026EFC 8E030000 */  lw        $v1, 0x0($s0)
/* 2300 80026F00 24020004 */  addiu     $v0, $zero, 0x4
/* 2304 80026F04 A0620083 */  sb        $v0, 0x83($v1)
/* 2308 80026F08 8E020000 */  lw        $v0, 0x0($s0)
/* 230C 80026F0C 3C01800A */  lui       $at, %hi(timeFreezeMode)
/* 2310 80026F10 AC20A5D8 */  sw        $zero, %lo(timeFreezeMode)($at)
/* 2314 80026F14 A440013C */  sh        $zero, 0x13C($v0)
/* 2318 80026F18 A0400075 */  sb        $zero, 0x75($v0)
/* 231C 80026F1C 8E030000 */  lw        $v1, 0x0($s0)
/* 2320 80026F20 24020005 */  addiu     $v0, $zero, 0x5
/* 2324 80026F24 3C018007 */  lui       $at, %hi(gGameStepDelayCount)
/* 2328 80026F28 A0224021 */  sb        $v0, %lo(gGameStepDelayCount)($at)
/* 232C 80026F2C 0C00AE13 */  jal       fio_init_flash
/* 2330 80026F30 AC600168 */   sw       $zero, 0x168($v1)
/* 2334 80026F34 0C00A20E */  jal       func_80028838
/* 2338 80026F38 00000000 */   nop
/* 233C 80026F3C 0C00AB00 */  jal       general_heap_create
/* 2340 80026F40 00000000 */   nop
/* 2344 80026F44 0C047624 */  jal       clear_render_tasks
/* 2348 80026F48 00000000 */   nop
/* 234C 80026F4C 0C048C2E */  jal       clear_worker_list
/* 2350 80026F50 00000000 */   nop
/* 2354 80026F54 0C0B0C77 */  jal       clear_script_list
/* 2358 80026F58 00000000 */   nop
/* 235C 80026F5C 0C00B7BD */  jal       create_cameras_a
/* 2360 80026F60 00000000 */   nop
/* 2364 80026F64 0C037F14 */  jal       clear_player_status
/* 2368 80026F68 00000000 */   nop
/* 236C 80026F6C 0C0B763E */  jal       spr_init_sprites
/* 2370 80026F70 0000202D */   daddu    $a0, $zero, $zero
/* 2374 80026F74 0C0482EC */  jal       clear_entity_models
/* 2378 80026F78 00000000 */   nop
/* 237C 80026F7C 0C047889 */  jal       clear_animator_list
/* 2380 80026F80 00000000 */   nop
/* 2384 80026F84 0C045751 */  jal       clear_model_data
/* 2388 80026F88 00000000 */   nop
/* 238C 80026F8C 0C052010 */  jal       clear_sprite_shading_data
/* 2390 80026F90 00000000 */   nop
/* 2394 80026F94 0C05177E */  jal       reset_background_settings
/* 2398 80026F98 00000000 */   nop
/* 239C 80026F9C 0C048D98 */  jal       clear_character_set
/* 23A0 80026FA0 00000000 */   nop
/* 23A4 80026FA4 0C048D9D */  jal       clear_printers
/* 23A8 80026FA8 00000000 */   nop
/* 23AC 80026FAC 0C044AE6 */  jal       clear_game_modes
/* 23B0 80026FB0 00000000 */   nop
/* 23B4 80026FB4 0C00E12F */  jal       clear_npcs
/* 23B8 80026FB8 00000000 */   nop
/* 23BC 80026FBC 0C050440 */  jal       hud_element_clear_cache
/* 23C0 80026FC0 00000000 */   nop
/* 23C4 80026FC4 0C0515A0 */  jal       clear_trigger_data
/* 23C8 80026FC8 00000000 */   nop
/* 23CC 80026FCC 0C04432E */  jal       clear_entity_data
/* 23D0 80026FD0 0000202D */   daddu    $a0, $zero, $zero
/* 23D4 80026FD4 0C039CE8 */  jal       clear_player_data
/* 23D8 80026FD8 00000000 */   nop
/* 23DC 80026FDC 0C00F8CE */  jal       init_encounter_status
/* 23E0 80026FE0 00000000 */   nop
/* 23E4 80026FE4 0C04E042 */  jal       clear_screen_overlays
/* 23E8 80026FE8 00000000 */   nop
/* 23EC 80026FEC 0C016727 */  jal       clear_effect_data
/* 23F0 80026FF0 00000000 */   nop
/* 23F4 80026FF4 0C0514C8 */  jal       clear_saved_variables
/* 23F8 80026FF8 00000000 */   nop
/* 23FC 80026FFC 0C04C3FC */  jal       clear_item_entity_data
/* 2400 80027000 00000000 */   nop
/* 2404 80027004 0C052926 */  jal       bgm_reset_sequence_players
/* 2408 80027008 00000000 */   nop
/* 240C 8002700C 0C051C8C */  jal       reset_ambient_sounds
/* 2410 80027010 00000000 */   nop
/* 2414 80027014 0C052586 */  jal       sfx_clear_sounds
/* 2418 80027018 00000000 */   nop
/* 241C 8002701C 0C051CFC */  jal       clear_windows
/* 2420 80027020 00000000 */   nop
/* 2424 80027024 0C00AE90 */  jal       initialize_curtains
/* 2428 80027028 00000000 */   nop
/* 242C 8002702C 0C00A3B8 */  jal       poll_rumble
/* 2430 80027030 00000000 */   nop
/* 2434 80027034 0000182D */  daddu     $v1, $zero, $zero
/* 2438 80027038 24050003 */  addiu     $a1, $zero, 0x3
/* 243C 8002703C 2404000C */  addiu     $a0, $zero, 0xC
/* 2440 80027040 8E100000 */  lw        $s0, 0x0($s0)
.L80027044:
/* 2444 80027044 A6050050 */  sh        $a1, 0x50($s0)
/* 2448 80027048 A6040048 */  sh        $a0, 0x48($s0)
/* 244C 8002704C 24630001 */  addiu     $v1, $v1, 0x1
/* 2450 80027050 28620004 */  slti      $v0, $v1, 0x4
/* 2454 80027054 1440FFFB */  bnez      $v0, .L80027044
/* 2458 80027058 26100002 */   addiu    $s0, $s0, 0x2
/* 245C 8002705C 3C03800A */  lui       $v1, %hi(gOverrideFlags)
/* 2460 80027060 2463A650 */  addiu     $v1, $v1, %lo(gOverrideFlags)
/* 2464 80027064 8C620000 */  lw        $v0, 0x0($v1)
/* 2468 80027068 0000202D */  daddu     $a0, $zero, $zero
/* 246C 8002706C 34420008 */  ori       $v0, $v0, 0x8
/* 2470 80027070 0C00CD3C */  jal       set_game_mode
/* 2474 80027074 AC620000 */   sw       $v0, 0x0($v1)
/* 2478 80027078 8FBF0014 */  lw        $ra, 0x14($sp)
/* 247C 8002707C 8FB00010 */  lw        $s0, 0x10($sp)
/* 2480 80027080 03E00008 */  jr        $ra
/* 2484 80027084 27BD0018 */   addiu    $sp, $sp, 0x18

### DECOMPILED C INSTRUCTIONS:

void load_engine_data(void) {
    s32 i;

    dma_copy(engine4_ROM_START, engine4_ROM_END, engine4_VRAM);
    dma_copy(engine1_ROM_START, engine1_ROM_END, engine1_VRAM);
    dma_copy(evt_ROM_START, evt_ROM_END, evt_VRAM);
    dma_copy(entity_ROM_START, entity_ROM_END, entity_VRAM);
    dma_copy(engine2_ROM_START, engine2_ROM_END, engine2_VRAM);
    dma_copy(font_width_ROM_START, font_width_ROM_END, font_width_VRAM);

    gOverrideFlags = 0;
    gGameStatusPtr->unk_79 = 0;
    gGameStatusPtr->backgroundFlags = 0;
    gGameStatusPtr->musicEnabled = 1;
    gGameStatusPtr->unk_7C = 1;
    gGameStatusPtr->creditsViewportMode = -1;
    gGameStatusPtr->demoFlags = 0;
    gGameStatusPtr->multiplayerEnabled = 0;
    gGameStatusPtr->unk_82 = -8;
    gGameStatusPtr->unk_83 = 4;
    timeFreezeMode = 0;
    gGameStatusPtr->debugQuizmo = gGameStatusPtr->unk_13C = 0;
    gGameStepDelayCount = 5;
    gGameStatusPtr->saveCount = 0;
    fio_init_flash();
    func_80028838();
    general_heap_create();
    clear_render_tasks();
    clear_worker_list();
    clear_script_list();
    create_cameras_a();
    clear_player_status();
    spr_init_sprites(PLAYER_SPRITES_MARIO_WORLD);
    clear_entity_models();
    clear_animator_list();
    clear_model_data();
    clear_sprite_shading_data();
    reset_background_settings();
    clear_character_set();
    clear_printers();
    clear_game_modes();
    clear_npcs();
    hud_element_clear_cache();
    clear_trigger_data();
    clear_entity_data(0);
    clear_player_data();
    init_encounter_status();
    clear_screen_overlays();
    clear_effect_data();
    clear_saved_variables();
    clear_item_entity_data();
    bgm_reset_sequence_players();
    reset_ambient_sounds();
    sfx_clear_sounds();
    clear_windows();
    initialize_curtains();
    poll_rumble();

    for (i = 0; i < ARRAY_COUNT(gGameStatusPtr->unk_50); i++) {
        gGameStatusPtr->unk_50[i] = 3;
        gGameStatusPtr->unk_48[i] = 12;
    }

    gOverrideFlags |= GLOBAL_OVERRIDES_8;
    set_game_mode(GAME_MODE_STARTUP);
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel au_bgm_dispatch_player_event
/* 28BE0 8004D7E0 27BDFFD0 */  addiu     $sp, $sp, -0x30
/* 28BE4 8004D7E4 AFB20018 */  sw        $s2, 0x18($sp)
/* 28BE8 8004D7E8 0080902D */  daddu     $s2, $a0, $zero
/* 28BEC 8004D7EC AFB50024 */  sw        $s5, 0x24($sp)
/* 28BF0 8004D7F0 AFBF0028 */  sw        $ra, 0x28($sp)
/* 28BF4 8004D7F4 AFB40020 */  sw        $s4, 0x20($sp)
/* 28BF8 8004D7F8 AFB3001C */  sw        $s3, 0x1C($sp)
/* 28BFC 8004D7FC AFB10014 */  sw        $s1, 0x14($sp)
glabel func_8004D800
/* 28C00 8004D800 AFB00010 */  sw        $s0, 0x10($sp)
/* 28C04 8004D804 8E540000 */  lw        $s4, 0x0($s2)
/* 28C08 8004D808 8E530010 */  lw        $s3, 0x10($s2)
/* 28C0C 8004D80C 12800074 */  beqz      $s4, .L8004D9E0
/* 28C10 8004D810 0000A82D */   daddu    $s5, $zero, $zero
/* 28C14 8004D814 0C0135E5 */  jal       au_bgm_get_player_with_song_name
/* 28C18 8004D818 0280202D */   daddu    $a0, $s4, $zero
/* 28C1C 8004D81C 0040802D */  daddu     $s0, $v0, $zero
/* 28C20 8004D820 52000070 */  beql      $s0, $zero, .L8004D9E4
/* 28C24 8004D824 24150002 */   addiu    $s5, $zero, 0x2
/* 28C28 8004D828 8E020064 */  lw        $v0, 0x64($s0)
/* 28C2C 8004D82C 8E450004 */  lw        $a1, 0x4($s2)
/* 28C30 8004D830 10A00008 */  beqz      $a1, .L8004D854
/* 28C34 8004D834 24510010 */   addiu    $s1, $v0, 0x10
/* 28C38 8004D838 28A22711 */  slti      $v0, $a1, 0x2711
/* 28C3C 8004D83C 14400003 */  bnez      $v0, .L8004D84C
/* 28C40 8004D840 28A200FA */   slti     $v0, $a1, 0xFA
/* 28C44 8004D844 08013615 */  j         .L8004D854
/* 28C48 8004D848 24052710 */   addiu    $a1, $zero, 0x2710
.L8004D84C:
/* 28C4C 8004D84C 54400001 */  bnel      $v0, $zero, .L8004D854
/* 28C50 8004D850 240500FA */   addiu    $a1, $zero, 0xFA
.L8004D854:
/* 28C54 8004D854 8E460008 */  lw        $a2, 0x8($s2)
/* 28C58 8004D858 28C20080 */  slti      $v0, $a2, 0x80
/* 28C5C 8004D85C 50400001 */  beql      $v0, $zero, .L8004D864
/* 28C60 8004D860 2406007F */   addiu    $a2, $zero, 0x7F
.L8004D864:
/* 28C64 8004D864 10C00002 */  beqz      $a2, .L8004D870
/* 28C68 8004D868 00061200 */   sll      $v0, $a2, 8
/* 28C6C 8004D86C 344600FF */  ori       $a2, $v0, 0xFF
.L8004D870:
/* 28C70 8004D870 8E47000C */  lw        $a3, 0xC($s2)
/* 28C74 8004D874 28E20080 */  slti      $v0, $a3, 0x80
/* 28C78 8004D878 50400001 */  beql      $v0, $zero, .L8004D880
/* 28C7C 8004D87C 2407007F */   addiu    $a3, $zero, 0x7F
.L8004D880:
/* 28C80 8004D880 10E00003 */  beqz      $a3, .L8004D890
/* 28C84 8004D884 00071200 */   sll      $v0, $a3, 8
/* 28C88 8004D888 08013625 */  j         .L8004D894
/* 28C8C 8004D88C 344700FF */   ori      $a3, $v0, 0xFF
.L8004D890:
/* 28C90 8004D890 24077FFF */  addiu     $a3, $zero, 0x7FFF
.L8004D894:
/* 28C94 8004D894 0C014E5D */  jal       au_fade_init
/* 28C98 8004D898 2604002C */   addiu    $a0, $s0, 0x2C
/* 28C9C 8004D89C 0200202D */  daddu     $a0, $s0, $zero
/* 28CA0 8004D8A0 24027FFF */  addiu     $v0, $zero, 0x7FFF
/* 28CA4 8004D8A4 A6020044 */  sh        $v0, 0x44($s0)
/* 28CA8 8004D8A8 24020001 */  addiu     $v0, $zero, 0x1
/* 28CAC 8004D8AC A6020046 */  sh        $v0, 0x46($s0)
/* 28CB0 8004D8B0 92220000 */  lbu       $v0, 0x0($s1)
/* 28CB4 8004D8B4 3C050002 */  lui       $a1, (0x2625A >> 16)
/* 28CB8 8004D8B8 30420007 */  andi      $v0, $v0, 0x7
/* 28CBC 8004D8BC 3C068008 */  lui       $a2, %hi(D_80078510)
/* 28CC0 8004D8C0 00C23021 */  addu      $a2, $a2, $v0
/* 28CC4 8004D8C4 90C68510 */  lbu       $a2, %lo(D_80078510)($a2)
/* 28CC8 8004D8C8 0C013A20 */  jal       func_8004E880
/* 28CCC 8004D8CC 34A5625A */   ori      $a1, $a1, (0x2625A & 0xFFFF)
/* 28CD0 8004D8D0 2E620004 */  sltiu     $v0, $s3, 0x4
/* 28CD4 8004D8D4 10400005 */  beqz      $v0, .L8004D8EC
/* 28CD8 8004D8D8 00131040 */   sll      $v0, $s3, 1
/* 28CDC 8004D8DC 02221021 */  addu      $v0, $s1, $v0
glabel func_8004D8E0
/* 28CE0 8004D8E0 94420004 */  lhu       $v0, 0x4($v0)
/* 28CE4 8004D8E4 14400003 */  bnez      $v0, .L8004D8F4
/* 28CE8 8004D8E8 00131040 */   sll      $v0, $s3, 1
.L8004D8EC:
/* 28CEC 8004D8EC 0000982D */  daddu     $s3, $zero, $zero
/* 28CF0 8004D8F0 00131040 */  sll       $v0, $s3, 1
.L8004D8F4:
/* 28CF4 8004D8F4 02221021 */  addu      $v0, $s1, $v0
/* 28CF8 8004D8F8 AE130060 */  sw        $s3, 0x60($s0)
/* 28CFC 8004D8FC 94420004 */  lhu       $v0, 0x4($v0)
/* 28D00 8004D900 8E030064 */  lw        $v1, 0x64($s0)
/* 28D04 8004D904 00021080 */  sll       $v0, $v0, 2
/* 28D08 8004D908 00431021 */  addu      $v0, $v0, $v1
/* 28D0C 8004D90C AE02006C */  sw        $v0, 0x6C($s0)
/* 28D10 8004D910 AE020068 */  sw        $v0, 0x68($s0)
/* 28D14 8004D914 9622000C */  lhu       $v0, 0xC($s1)
/* 28D18 8004D918 1040001F */  beqz      $v0, .L8004D998
/* 28D1C 8004D91C 00021080 */   sll      $v0, $v0, 2
/* 28D20 8004D920 00431021 */  addu      $v0, $v0, $v1
/* 28D24 8004D924 AE020078 */  sw        $v0, 0x78($s0)
/* 28D28 8004D928 9222000F */  lbu       $v0, 0xF($s1)
/* 28D2C 8004D92C A202021C */  sb        $v0, 0x21C($s0)
/* 28D30 8004D930 304200FF */  andi      $v0, $v0, 0xFF
/* 28D34 8004D934 1040000C */  beqz      $v0, .L8004D968
/* 28D38 8004D938 0000182D */   daddu    $v1, $zero, $zero
/* 28D3C 8004D93C 0200282D */  daddu     $a1, $s0, $zero
/* 28D40 8004D940 0060202D */  daddu     $a0, $v1, $zero
.L8004D944:
/* 28D44 8004D944 8E020078 */  lw        $v0, 0x78($s0)
/* 28D48 8004D948 24630001 */  addiu     $v1, $v1, 0x1
/* 28D4C 8004D94C 00441021 */  addu      $v0, $v0, $a0
/* 28D50 8004D950 ACA20080 */  sw        $v0, 0x80($a1)
/* 28D54 8004D954 24A50004 */  addiu     $a1, $a1, 0x4
/* 28D58 8004D958 9202021C */  lbu       $v0, 0x21C($s0)
/* 28D5C 8004D95C 0062102B */  sltu      $v0, $v1, $v0
/* 28D60 8004D960 1440FFF8 */  bnez      $v0, .L8004D944
/* 28D64 8004D964 2484000C */   addiu    $a0, $a0, 0xC
.L8004D968:
/* 28D68 8004D968 2C62000C */  sltiu     $v0, $v1, 0xC
/* 28D6C 8004D96C 1040000C */  beqz      $v0, .L8004D9A0
/* 28D70 8004D970 00031080 */   sll      $v0, $v1, 2
/* 28D74 8004D974 00502021 */  addu      $a0, $v0, $s0
.L8004D978:
/* 28D78 8004D978 8E020080 */  lw        $v0, 0x80($s0)
/* 28D7C 8004D97C 24630001 */  addiu     $v1, $v1, 0x1
/* 28D80 8004D980 AC820080 */  sw        $v0, 0x80($a0)
/* 28D84 8004D984 2C62000C */  sltiu     $v0, $v1, 0xC
/* 28D88 8004D988 1440FFFB */  bnez      $v0, .L8004D978
/* 28D8C 8004D98C 24840004 */   addiu    $a0, $a0, 0x4
/* 28D90 8004D990 08013668 */  j         .L8004D9A0
/* 28D94 8004D994 00000000 */   nop
.L8004D998:
/* 28D98 8004D998 AE000078 */  sw        $zero, 0x78($s0)
/* 28D9C 8004D99C A200021C */  sb        $zero, 0x21C($s0)
.L8004D9A0:
/* 28DA0 8004D9A0 96220010 */  lhu       $v0, 0x10($s1)
/* 28DA4 8004D9A4 10400007 */  beqz      $v0, .L8004D9C4
/* 28DA8 8004D9A8 00021080 */   sll      $v0, $v0, 2
/* 28DAC 8004D9AC 8E030064 */  lw        $v1, 0x64($s0)
/* 28DB0 8004D9B0 00431021 */  addu      $v0, $v0, $v1
/* 28DB4 8004D9B4 AE02007C */  sw        $v0, 0x7C($s0)
/* 28DB8 8004D9B8 92220013 */  lbu       $v0, 0x13($s1)
/* 28DBC 8004D9BC 08013673 */  j         .L8004D9CC
glabel func_8004D9C0
/* 28DC0 8004D9C0 A202021D */   sb       $v0, 0x21D($s0)
.L8004D9C4:
/* 28DC4 8004D9C4 AE00007C */  sw        $zero, 0x7C($s0)
/* 28DC8 8004D9C8 A200021D */  sb        $zero, 0x21D($s0)
.L8004D9CC:
/* 28DCC 8004D9CC AE14001C */  sw        $s4, 0x1C($s0)
/* 28DD0 8004D9D0 0C013976 */  jal       au_bgm_player_initialize
/* 28DD4 8004D9D4 0200202D */   daddu    $a0, $s0, $zero
/* 28DD8 8004D9D8 0801367A */  j         .L8004D9E8
/* 28DDC 8004D9DC 02A0102D */   daddu    $v0, $s5, $zero
.L8004D9E0:
/* 28DE0 8004D9E0 24150003 */  addiu     $s5, $zero, 0x3
.L8004D9E4:
/* 28DE4 8004D9E4 02A0102D */  daddu     $v0, $s5, $zero
.L8004D9E8:
/* 28DE8 8004D9E8 8FBF0028 */  lw        $ra, 0x28($sp)
/* 28DEC 8004D9EC 8FB50024 */  lw        $s5, 0x24($sp)
/* 28DF0 8004D9F0 8FB40020 */  lw        $s4, 0x20($sp)
/* 28DF4 8004D9F4 8FB3001C */  lw        $s3, 0x1C($sp)
/* 28DF8 8004D9F8 8FB20018 */  lw        $s2, 0x18($sp)
/* 28DFC 8004D9FC 8FB10014 */  lw        $s1, 0x14($sp)
/* 28E00 8004DA00 8FB00010 */  lw        $s0, 0x10($sp)
/* 28E04 8004DA04 03E00008 */  jr        $ra
/* 28E08 8004DA08 27BD0030 */   addiu    $sp, $sp, 0x30

### DECOMPILED C INSTRUCTIONS:

AuResult au_bgm_dispatch_player_event(SongUpdateEvent* event) {
    BGMPlayer* player;
    BGMFileInfo* fileInfo;
    s32 songName;
    s32 variation;
    s32 duration;
    s32 volume0;
    s32 volume1;
    AuResult status;
    u32 i;

    status = AU_RESULT_OK;
    songName = event->songName;
    variation = event->variation;
    if (songName != 0) {
        player = au_bgm_get_player_with_song_name(songName);
        if (player != NULL) {
            fileInfo = &player->bgmFile->info;
            duration = event->duration;
            if (duration != 0) {
                if (duration > SND_MAX_DURATION) {
                    duration = SND_MAX_DURATION;
                } else if (duration < SND_MIN_DURATION) {
                    duration = SND_MIN_DURATION;
                }
            }
            volume0 = event->startVolume;
            if (volume0 > 0x7F) {
                volume0 = 0x7F;
            }
            if (volume0 != 0) {
                volume0 = (volume0 << 8) | 0xFF;
            }
            volume1 = event->finalVolume;
            if (volume1 > 0x7F) {
                volume1 = 0x7F;
            }
            if (volume1 != 0) {
                volume1 = (volume1 << 8) | 0xFF;
            } else {
                volume1 = 0x7FFF;
            }

            au_fade_init(&player->fadeInfo, duration, volume0, volume1);
            player->fadeInfo.targetVolScale = 0x7FFF;
            player->fadeInfo.volScaleTime = 1;
            func_8004E880(player, BGM_SAMPLE_RATE, BgmDivisors[fileInfo->numSegments & 7]);

            if (variation < 0 || variation >= 4 || fileInfo->segments[variation] == 0) {
                variation = 0;
            }
            player->curSegmentID = variation;

            player->segmentStartPos = AU_FILE_RELATIVE(player->bgmFile, fileInfo->segments[variation] << 2);
            player->segmentReadPos = player->segmentStartPos;

            if (fileInfo->drums != 0) {
                player->drumsInfo = AU_FILE_RELATIVE(player->bgmFile, fileInfo->drums << 2);
                player->bgmDrumCount = fileInfo->drumCount;

                for (i = 0; i < player->bgmDrumCount; i++) {
                    BGMDrumInfo* drum = &player->drumsInfo[i];
                    player->drums[i] = drum;
                }
                for (; i < ARRAY_COUNT(player->drums); i++) {
                    player->drums[i] = player->drums[0];
                }
            } else {
                player->drumsInfo = NULL;
                player->bgmDrumCount = 0;
            }
            if (fileInfo->instruments != 0) {
                player->instrumentsInfo = AU_FILE_RELATIVE(player->bgmFile, fileInfo->instruments << 2);
                player->bgmInstrumentCount = fileInfo->instrumentCount;
            } else {
                player->instrumentsInfo = NULL;
                player->bgmInstrumentCount = 0;
            }
            player->songName = songName;
            au_bgm_player_initialize(player);
        } else {
            status = AU_ERROR_SONG_NOT_PLAYING;
        }
    } else {
        status = AU_ERROR_NULL_SONG_NAME;
    }
    return status;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel InterpCamTargetPos
/* EF9B8 802CB008 27BDFFD0 */  addiu     $sp, $sp, -0x30
/* EF9BC 802CB00C AFB3001C */  sw        $s3, 0x1C($sp)
/* EF9C0 802CB010 0080982D */  daddu     $s3, $a0, $zero
/* EF9C4 802CB014 AFBF002C */  sw        $ra, 0x2C($sp)
/* EF9C8 802CB018 AFB60028 */  sw        $s6, 0x28($sp)
/* EF9CC 802CB01C AFB50024 */  sw        $s5, 0x24($sp)
/* EF9D0 802CB020 AFB40020 */  sw        $s4, 0x20($sp)
/* EF9D4 802CB024 AFB20018 */  sw        $s2, 0x18($sp)
/* EF9D8 802CB028 AFB10014 */  sw        $s1, 0x14($sp)
/* EF9DC 802CB02C AFB00010 */  sw        $s0, 0x10($sp)
/* EF9E0 802CB030 10A00066 */  beqz      $a1, .L802CB1CC
/* EF9E4 802CB034 8E72000C */   lw       $s2, 0xC($s3)
/* EF9E8 802CB038 8E450000 */  lw        $a1, 0x0($s2)
/* EF9EC 802CB03C 0C0B1EAF */  jal       evt_get_variable
/* EF9F0 802CB040 26520004 */   addiu    $s2, $s2, 0x4
/* EF9F4 802CB044 8E450000 */  lw        $a1, 0x0($s2)
/* EF9F8 802CB048 26520004 */  addiu     $s2, $s2, 0x4
/* EF9FC 802CB04C 0260202D */  daddu     $a0, $s3, $zero
/* EFA00 802CB050 0C0B1EAF */  jal       evt_get_variable
/* EFA04 802CB054 0040802D */   daddu    $s0, $v0, $zero
/* EFA08 802CB058 8E450000 */  lw        $a1, 0x0($s2)
/* EFA0C 802CB05C 26520004 */  addiu     $s2, $s2, 0x4
/* EFA10 802CB060 0260202D */  daddu     $a0, $s3, $zero
/* EFA14 802CB064 0C0B1EAF */  jal       evt_get_variable
/* EFA18 802CB068 0040882D */   daddu    $s1, $v0, $zero
/* EFA1C 802CB06C 8E450000 */  lw        $a1, 0x0($s2)
/* EFA20 802CB070 26520004 */  addiu     $s2, $s2, 0x4
/* EFA24 802CB074 0260202D */  daddu     $a0, $s3, $zero
/* EFA28 802CB078 0C0B1EAF */  jal       evt_get_variable
/* EFA2C 802CB07C 0040A02D */   daddu    $s4, $v0, $zero
/* EFA30 802CB080 8E450000 */  lw        $a1, 0x0($s2)
/* EFA34 802CB084 26520004 */  addiu     $s2, $s2, 0x4
/* EFA38 802CB088 0260202D */  daddu     $a0, $s3, $zero
/* EFA3C 802CB08C 0C0B1EAF */  jal       evt_get_variable
/* EFA40 802CB090 0040A82D */   daddu    $s5, $v0, $zero
/* EFA44 802CB094 0260202D */  daddu     $a0, $s3, $zero
/* EFA48 802CB098 8E450000 */  lw        $a1, 0x0($s2)
/* EFA4C 802CB09C 0C0B1EAF */  jal       evt_get_variable
/* EFA50 802CB0A0 0040B02D */   daddu    $s6, $v0, $zero
/* EFA54 802CB0A4 24040018 */  addiu     $a0, $zero, 0x18
/* EFA58 802CB0A8 0C00AB39 */  jal       heap_malloc
/* EFA5C 802CB0AC 0040902D */   daddu    $s2, $v0, $zero
/* EFA60 802CB0B0 0040282D */  daddu     $a1, $v0, $zero
/* EFA64 802CB0B4 3C04800B */  lui       $a0, %hi(gCameras)
/* EFA68 802CB0B8 24841D80 */  addiu     $a0, $a0, %lo(gCameras)
/* EFA6C 802CB0BC 00101080 */  sll       $v0, $s0, 2
/* EFA70 802CB0C0 00501021 */  addu      $v0, $v0, $s0
/* EFA74 802CB0C4 00021080 */  sll       $v0, $v0, 2
/* EFA78 802CB0C8 00501023 */  subu      $v0, $v0, $s0
/* EFA7C 802CB0CC 000218C0 */  sll       $v1, $v0, 3
/* EFA80 802CB0D0 00431021 */  addu      $v0, $v0, $v1
/* EFA84 802CB0D4 000210C0 */  sll       $v0, $v0, 3
/* EFA88 802CB0D8 AE650060 */  sw        $a1, 0x60($s3)
/* EFA8C 802CB0DC ACB10004 */  sw        $s1, 0x4($a1)
/* EFA90 802CB0E0 0220302D */  daddu     $a2, $s1, $zero
/* EFA94 802CB0E4 00441821 */  addu      $v1, $v0, $a0
/* EFA98 802CB0E8 ACA30000 */  sw        $v1, 0x0($a1)
/* EFA9C 802CB0EC 10C00006 */  beqz      $a2, .L802CB108
/* EFAA0 802CB0F0 ACB20014 */   sw       $s2, 0x14($a1)
/* EFAA4 802CB0F4 24020001 */  addiu     $v0, $zero, 0x1
/* EFAA8 802CB0F8 10C20018 */  beq       $a2, $v0, .L802CB15C
/* EFAAC 802CB0FC 00000000 */   nop
/* EFAB0 802CB100 080B2C73 */  j         .L802CB1CC
/* EFAB4 802CB104 00000000 */   nop
.L802CB108:
/* EFAB8 802CB108 C4620054 */  lwc1      $f2, 0x54($v1)
/* EFABC 802CB10C 44940000 */  mtc1      $s4, $f0
/* EFAC0 802CB110 00000000 */  nop
/* EFAC4 802CB114 46800020 */  cvt.s.w   $f0, $f0
/* EFAC8 802CB118 46020001 */  sub.s     $f0, $f0, $f2
/* EFACC 802CB11C 44921000 */  mtc1      $s2, $f2
/* EFAD0 802CB120 00000000 */  nop
/* EFAD4 802CB124 468010A0 */  cvt.s.w   $f2, $f2
/* EFAD8 802CB128 46020003 */  div.s     $f0, $f0, $f2
/* EFADC 802CB12C E4A00008 */  swc1      $f0, 0x8($a1)
/* EFAE0 802CB130 C4620058 */  lwc1      $f2, 0x58($v1)
/* EFAE4 802CB134 44950000 */  mtc1      $s5, $f0
/* EFAE8 802CB138 00000000 */  nop
/* EFAEC 802CB13C 46800020 */  cvt.s.w   $f0, $f0
/* EFAF0 802CB140 46020001 */  sub.s     $f0, $f0, $f2
/* EFAF4 802CB144 C4A20014 */  lwc1      $f2, 0x14($a1)
/* EFAF8 802CB148 468010A0 */  cvt.s.w   $f2, $f2
/* EFAFC 802CB14C 46020003 */  div.s     $f0, $f0, $f2
/* EFB00 802CB150 E4A0000C */  swc1      $f0, 0xC($a1)
/* EFB04 802CB154 080B2C6B */  j         .L802CB1AC
/* EFB08 802CB158 C462005C */   lwc1     $f2, 0x5C($v1)
.L802CB15C:
/* EFB0C 802CB15C C4620060 */  lwc1      $f2, 0x60($v1)
/* EFB10 802CB160 44940000 */  mtc1      $s4, $f0
/* EFB14 802CB164 00000000 */  nop
/* EFB18 802CB168 46800020 */  cvt.s.w   $f0, $f0
/* EFB1C 802CB16C 46020001 */  sub.s     $f0, $f0, $f2
/* EFB20 802CB170 44921000 */  mtc1      $s2, $f2
/* EFB24 802CB174 00000000 */  nop
/* EFB28 802CB178 468010A0 */  cvt.s.w   $f2, $f2
/* EFB2C 802CB17C 46020003 */  div.s     $f0, $f0, $f2
/* EFB30 802CB180 E4A00008 */  swc1      $f0, 0x8($a1)
/* EFB34 802CB184 C4620064 */  lwc1      $f2, 0x64($v1)
/* EFB38 802CB188 44950000 */  mtc1      $s5, $f0
/* EFB3C 802CB18C 00000000 */  nop
/* EFB40 802CB190 46800020 */  cvt.s.w   $f0, $f0
/* EFB44 802CB194 46020001 */  sub.s     $f0, $f0, $f2
/* EFB48 802CB198 C4A20014 */  lwc1      $f2, 0x14($a1)
/* EFB4C 802CB19C 468010A0 */  cvt.s.w   $f2, $f2
/* EFB50 802CB1A0 46020003 */  div.s     $f0, $f0, $f2
/* EFB54 802CB1A4 E4A0000C */  swc1      $f0, 0xC($a1)
/* EFB58 802CB1A8 C4620068 */  lwc1      $f2, 0x68($v1)
.L802CB1AC:
/* EFB5C 802CB1AC 44960000 */  mtc1      $s6, $f0
/* EFB60 802CB1B0 00000000 */  nop
/* EFB64 802CB1B4 46800020 */  cvt.s.w   $f0, $f0
/* EFB68 802CB1B8 46020001 */  sub.s     $f0, $f0, $f2
/* EFB6C 802CB1BC C4A20014 */  lwc1      $f2, 0x14($a1)
/* EFB70 802CB1C0 468010A0 */  cvt.s.w   $f2, $f2
/* EFB74 802CB1C4 46020003 */  div.s     $f0, $f0, $f2
/* EFB78 802CB1C8 E4A00010 */  swc1      $f0, 0x10($a1)
.L802CB1CC:
/* EFB7C 802CB1CC 8E650060 */  lw        $a1, 0x60($s3)
/* EFB80 802CB1D0 8CA40004 */  lw        $a0, 0x4($a1)
/* EFB84 802CB1D4 8CA30000 */  lw        $v1, 0x0($a1)
/* EFB88 802CB1D8 10800005 */  beqz      $a0, .L802CB1F0
/* EFB8C 802CB1DC 24020001 */   addiu    $v0, $zero, 0x1
/* EFB90 802CB1E0 10820010 */  beq       $a0, $v0, .L802CB224
/* EFB94 802CB1E4 00000000 */   nop
/* EFB98 802CB1E8 080B2C95 */  j         .L802CB254
/* EFB9C 802CB1EC 00000000 */   nop
.L802CB1F0:
/* EFBA0 802CB1F0 C4600054 */  lwc1      $f0, 0x54($v1)
/* EFBA4 802CB1F4 C4A20008 */  lwc1      $f2, 0x8($a1)
/* EFBA8 802CB1F8 46020000 */  add.s     $f0, $f0, $f2
/* EFBAC 802CB1FC E4600054 */  swc1      $f0, 0x54($v1)
/* EFBB0 802CB200 C4600058 */  lwc1      $f0, 0x58($v1)
/* EFBB4 802CB204 C4A2000C */  lwc1      $f2, 0xC($a1)
/* EFBB8 802CB208 46020000 */  add.s     $f0, $f0, $f2
/* EFBBC 802CB20C E4600058 */  swc1      $f0, 0x58($v1)
/* EFBC0 802CB210 C460005C */  lwc1      $f0, 0x5C($v1)
/* EFBC4 802CB214 C4A20010 */  lwc1      $f2, 0x10($a1)
/* EFBC8 802CB218 46020000 */  add.s     $f0, $f0, $f2
/* EFBCC 802CB21C 080B2C95 */  j         .L802CB254
/* EFBD0 802CB220 E460005C */   swc1     $f0, 0x5C($v1)
.L802CB224:
/* EFBD4 802CB224 C4600060 */  lwc1      $f0, 0x60($v1)
/* EFBD8 802CB228 C4A20008 */  lwc1      $f2, 0x8($a1)
/* EFBDC 802CB22C 46020000 */  add.s     $f0, $f0, $f2
/* EFBE0 802CB230 E4600060 */  swc1      $f0, 0x60($v1)
/* EFBE4 802CB234 C4600064 */  lwc1      $f0, 0x64($v1)
/* EFBE8 802CB238 C4A2000C */  lwc1      $f2, 0xC($a1)
/* EFBEC 802CB23C 46020000 */  add.s     $f0, $f0, $f2
/* EFBF0 802CB240 E4600064 */  swc1      $f0, 0x64($v1)
/* EFBF4 802CB244 C4600068 */  lwc1      $f0, 0x68($v1)
/* EFBF8 802CB248 C4A20010 */  lwc1      $f2, 0x10($a1)
/* EFBFC 802CB24C 46020000 */  add.s     $f0, $f0, $f2
/* EFC00 802CB250 E4600068 */  swc1      $f0, 0x68($v1)
.L802CB254:
/* EFC04 802CB254 8CA20014 */  lw        $v0, 0x14($a1)
/* EFC08 802CB258 2442FFFF */  addiu     $v0, $v0, -0x1
/* EFC0C 802CB25C 10400003 */  beqz      $v0, .L802CB26C
/* EFC10 802CB260 ACA20014 */   sw       $v0, 0x14($a1)
/* EFC14 802CB264 080B2CA0 */  j         .L802CB280
/* EFC18 802CB268 0000102D */   daddu    $v0, $zero, $zero
.L802CB26C:
/* EFC1C 802CB26C 8E640060 */  lw        $a0, 0x60($s3)
/* EFC20 802CB270 0C00AB4B */  jal       heap_free
/* EFC24 802CB274 00000000 */   nop
/* EFC28 802CB278 24020002 */  addiu     $v0, $zero, 0x2
/* EFC2C 802CB27C AE600060 */  sw        $zero, 0x60($s3)
.L802CB280:
/* EFC30 802CB280 8FBF002C */  lw        $ra, 0x2C($sp)
/* EFC34 802CB284 8FB60028 */  lw        $s6, 0x28($sp)
/* EFC38 802CB288 8FB50024 */  lw        $s5, 0x24($sp)
/* EFC3C 802CB28C 8FB40020 */  lw        $s4, 0x20($sp)
/* EFC40 802CB290 8FB3001C */  lw        $s3, 0x1C($sp)
/* EFC44 802CB294 8FB20018 */  lw        $s2, 0x18($sp)
/* EFC48 802CB298 8FB10014 */  lw        $s1, 0x14($sp)
/* EFC4C 802CB29C 8FB00010 */  lw        $s0, 0x10($sp)
/* EFC50 802CB2A0 03E00008 */  jr        $ra
/* EFC54 802CB2A4 27BD0030 */   addiu    $sp, $sp, 0x30

### DECOMPILED C INSTRUCTIONS:

ApiStatus InterpCamTargetPos(Evt* script, s32 isInitialCall) {
    typedef struct CamInterpData {
        /* 0x00 */ Camera* cam;
        /* 0x04 */ s32 useTarget;
        /* 0x08 */ Vec3f vel;
        /* 0x14 */ s32 time;
    } CamInterpData; // size = 0x18

    Bytecode* args = script->ptrReadPos;
    CamInterpData* data;
    Camera* cam;

    if (isInitialCall) {
        s32 camID = evt_get_variable(script, *args++);
        s32 useTarget = evt_get_variable(script, *args++);
        s32 posX = evt_get_variable(script, *args++);
        s32 posY = evt_get_variable(script, *args++);
        s32 posZ = evt_get_variable(script, *args++);
        s32 time = evt_get_variable(script, *args++);

        data = heap_malloc(sizeof(*data));
        script->userData = data;
        cam = &gCameras[camID];
        data->cam = cam;
        data->useTarget = useTarget;
        data->time = time;

        switch (data->useTarget) {
            case 0:
                data->vel.x = (posX - cam->lookAt_obj_target.x) / data->time;
                data->vel.y = (posY - cam->lookAt_obj_target.y) / data->time;
                data->vel.z = (posZ - cam->lookAt_obj_target.z) / data->time;
                break;
            case 1:
                data->vel.x = (posX - cam->targetPos.x) / data->time;
                data->vel.y = (posY - cam->targetPos.y) / data->time;
                data->vel.z = (posZ - cam->targetPos.z) / data->time;
                break;
        }
    }

    data = script->userData;
    cam = data->cam;
    switch (data->useTarget) {
        case 0:
            cam->lookAt_obj_target.x += data->vel.x;
            cam->lookAt_obj_target.y += data->vel.y;
            cam->lookAt_obj_target.z += data->vel.z;
            break;
        case 1:
            cam->targetPos.x += data->vel.x;
            cam->targetPos.y += data->vel.y;
            cam->targetPos.z += data->vel.z;
            break;
    }

    data->time--;
    if (data->time == 0) {
        heap_free(script->userData);
        script->userData = NULL;
        return ApiStatus_DONE2;
    }
    return ApiStatus_BLOCK;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel au_load_BK_to_bank
/* 2FBC8 800547C8 27BDFF80 */  addiu     $sp, $sp, -0x80
/* 2FBCC 800547CC AFB5006C */  sw        $s5, 0x6C($sp)
/* 2FBD0 800547D0 0080A82D */  daddu     $s5, $a0, $zero
/* 2FBD4 800547D4 AFB40068 */  sw        $s4, 0x68($sp)
/* 2FBD8 800547D8 00A0A02D */  daddu     $s4, $a1, $zero
/* 2FBDC 800547DC AFB70074 */  sw        $s7, 0x74($sp)
/* 2FBE0 800547E0 00C0B82D */  daddu     $s7, $a2, $zero
/* 2FBE4 800547E4 AFBE0078 */  sw        $fp, 0x78($sp)
/* 2FBE8 800547E8 00E0F02D */  daddu     $fp, $a3, $zero
/* 2FBEC 800547EC AFB1005C */  sw        $s1, 0x5C($sp)
/* 2FBF0 800547F0 27B10018 */  addiu     $s1, $sp, 0x18
/* 2FBF4 800547F4 0220282D */  daddu     $a1, $s1, $zero
/* 2FBF8 800547F8 3C028008 */  lui       $v0, %hi(gSynDriverPtr)
/* 2FBFC 800547FC 8C428E54 */  lw        $v0, %lo(gSynDriverPtr)($v0)
/* 2FC00 80054800 24060040 */  addiu     $a2, $zero, 0x40
/* 2FC04 80054804 AFB30064 */  sw        $s3, 0x64($sp)
/* 2FC08 80054808 2413000B */  addiu     $s3, $zero, 0xB
/* 2FC0C 8005480C AFB20060 */  sw        $s2, 0x60($sp)
/* 2FC10 80054810 AFBF007C */  sw        $ra, 0x7C($sp)
/* 2FC14 80054814 AFB60070 */  sw        $s6, 0x70($sp)
/* 2FC18 80054818 AFB00058 */  sw        $s0, 0x58($sp)
/* 2FC1C 8005481C 8C560018 */  lw        $s6, 0x18($v0)
/* 2FC20 80054820 0C015380 */  jal       au_read_rom
/* 2FC24 80054824 24120001 */   addiu    $s2, $zero, 0x1
/* 2FC28 80054828 3263FFFF */  andi      $v1, $s3, 0xFFFF
.L8005482C:
/* 2FC2C 8005482C 2402006F */  addiu     $v0, $zero, 0x6F
/* 2FC30 80054830 10620057 */  beq       $v1, $v0, .L80054990
/* 2FC34 80054834 28620070 */   slti     $v0, $v1, 0x70
/* 2FC38 80054838 1040005E */  beqz      $v0, .L800549B4
/* 2FC3C 8005483C 2402000B */   addiu    $v0, $zero, 0xB
/* 2FC40 80054840 1062000A */  beq       $v1, $v0, .L8005486C
/* 2FC44 80054844 2862000C */   slti     $v0, $v1, 0xC
/* 2FC48 80054848 5440005B */  bnel      $v0, $zero, .L800549B8
/* 2FC4C 8005484C 0000902D */   daddu    $s2, $zero, $zero
/* 2FC50 80054850 24020015 */  addiu     $v0, $zero, 0x15
/* 2FC54 80054854 1062000E */  beq       $v1, $v0, .L80054890
/* 2FC58 80054858 24020065 */   addiu    $v0, $zero, 0x65
/* 2FC5C 8005485C 1062001A */  beq       $v1, $v0, .L800548C8
/* 2FC60 80054860 00000000 */   nop
/* 2FC64 80054864 0801526E */  j         .L800549B8
/* 2FC68 80054868 0000902D */   daddu    $s2, $zero, $zero
.L8005486C:
/* 2FC6C 8005486C 96230000 */  lhu       $v1, 0x0($s1)
/* 2FC70 80054870 2402424B */  addiu     $v0, $zero, 0x424B
/* 2FC74 80054874 54620050 */  bnel      $v1, $v0, .L800549B8
/* 2FC78 80054878 0000902D */   daddu    $s2, $zero, $zero
/* 2FC7C 8005487C 8E220004 */  lw        $v0, 0x4($s1)
/* 2FC80 80054880 5040004D */  beql      $v0, $zero, .L800549B8
/* 2FC84 80054884 0000902D */   daddu    $s2, $zero, $zero
/* 2FC88 80054888 0801526E */  j         .L800549B8
/* 2FC8C 8005488C 24130015 */   addiu    $s3, $zero, 0x15
.L80054890:
/* 2FC90 80054890 9623000C */  lhu       $v1, 0xC($s1)
/* 2FC94 80054894 24024352 */  addiu     $v0, $zero, 0x4352
/* 2FC98 80054898 14620003 */  bne       $v1, $v0, .L800548A8
/* 2FC9C 8005489C 24024452 */   addiu    $v0, $zero, 0x4452
/* 2FCA0 800548A0 0801526E */  j         .L800549B8
/* 2FCA4 800548A4 24130065 */   addiu    $s3, $zero, 0x65
.L800548A8:
/* 2FCA8 800548A8 14620003 */  bne       $v1, $v0, .L800548B8
/* 2FCAC 800548AC 24025352 */   addiu    $v0, $zero, 0x5352
/* 2FCB0 800548B0 0801526E */  j         .L800549B8
/* 2FCB4 800548B4 241300C9 */   addiu    $s3, $zero, 0xC9
.L800548B8:
/* 2FCB8 800548B8 5462003F */  bnel      $v1, $v0, .L800549B8
/* 2FCBC 800548BC 0000902D */   daddu    $s2, $zero, $zero
/* 2FCC0 800548C0 0801526E */  j         .L800549B8
/* 2FCC4 800548C4 2413012D */   addiu    $s3, $zero, 0x12D
.L800548C8:
/* 2FCC8 800548C8 96240032 */  lhu       $a0, 0x32($s1)
/* 2FCCC 800548CC 96220036 */  lhu       $v0, 0x36($s1)
/* 2FCD0 800548D0 9623003A */  lhu       $v1, 0x3A($s1)
/* 2FCD4 800548D4 2484000F */  addiu     $a0, $a0, 0xF
/* 2FCD8 800548D8 3084FFF0 */  andi      $a0, $a0, 0xFFF0
/* 2FCDC 800548DC 2442000F */  addiu     $v0, $v0, 0xF
/* 2FCE0 800548E0 3042FFF0 */  andi      $v0, $v0, 0xFFF0
/* 2FCE4 800548E4 00822021 */  addu      $a0, $a0, $v0
/* 2FCE8 800548E8 2463000F */  addiu     $v1, $v1, 0xF
/* 2FCEC 800548EC 3063FFF0 */  andi      $v1, $v1, 0xFFF0
/* 2FCF0 800548F0 9622003E */  lhu       $v0, 0x3E($s1)
/* 2FCF4 800548F4 00832021 */  addu      $a0, $a0, $v1
/* 2FCF8 800548F8 2442000F */  addiu     $v0, $v0, 0xF
/* 2FCFC 800548FC 3042FFF0 */  andi      $v0, $v0, 0xFFF0
/* 2FD00 80054900 00822021 */  addu      $a0, $a0, $v0
/* 2FD04 80054904 16800006 */  bnez      $s4, .L80054920
/* 2FD08 80054908 24900040 */   addiu    $s0, $a0, 0x40
/* 2FD0C 8005490C 02C0202D */  daddu     $a0, $s6, $zero
/* 2FD10 80054910 24050001 */  addiu     $a1, $zero, 0x1
/* 2FD14 80054914 0C015FE4 */  jal       alHeapAlloc
/* 2FD18 80054918 0200302D */   daddu    $a2, $s0, $zero
/* 2FD1C 8005491C 0040A02D */  daddu     $s4, $v0, $zero
.L80054920:
/* 2FD20 80054920 02A0202D */  daddu     $a0, $s5, $zero
/* 2FD24 80054924 0280282D */  daddu     $a1, $s4, $zero
/* 2FD28 80054928 0C015380 */  jal       au_read_rom
/* 2FD2C 8005492C 0200302D */   daddu    $a2, $s0, $zero
/* 2FD30 80054930 03C0202D */  daddu     $a0, $fp, $zero
/* 2FD34 80054934 0C0151D1 */  jal       au_get_BK_instruments
/* 2FD38 80054938 02E0282D */   daddu    $a1, $s7, $zero
/* 2FD3C 8005493C 0040802D */  daddu     $s0, $v0, $zero
/* 2FD40 80054940 0200182D */  daddu     $v1, $s0, $zero
/* 2FD44 80054944 0000302D */  daddu     $a2, $zero, $zero
/* 2FD48 80054948 00C0282D */  daddu     $a1, $a2, $zero
/* 2FD4C 8005494C 0220202D */  daddu     $a0, $s1, $zero
.L80054950:
/* 2FD50 80054950 94820012 */  lhu       $v0, 0x12($a0)
/* 2FD54 80054954 10400004 */  beqz      $v0, .L80054968
/* 2FD58 80054958 00541021 */   addu     $v0, $v0, $s4
/* 2FD5C 8005495C 24C60001 */  addiu     $a2, $a2, 0x1
/* 2FD60 80054960 0801525B */  j         .L8005496C
/* 2FD64 80054964 AC620000 */   sw       $v0, 0x0($v1)
.L80054968:
/* 2FD68 80054968 AC600000 */  sw        $zero, 0x0($v1)
.L8005496C:
/* 2FD6C 8005496C 24630004 */  addiu     $v1, $v1, 0x4
/* 2FD70 80054970 24A50001 */  addiu     $a1, $a1, 0x1
/* 2FD74 80054974 2CA20010 */  sltiu     $v0, $a1, 0x10
/* 2FD78 80054978 1440FFF5 */  bnez      $v0, .L80054950
/* 2FD7C 8005497C 24840002 */   addiu    $a0, $a0, 0x2
/* 2FD80 80054980 50C0000D */  beql      $a2, $zero, .L800549B8
/* 2FD84 80054984 0000902D */   daddu    $s2, $zero, $zero
/* 2FD88 80054988 0801526E */  j         .L800549B8
/* 2FD8C 8005498C 2413006F */   addiu    $s3, $zero, 0x6F
.L80054990:
/* 2FD90 80054990 24020001 */  addiu     $v0, $zero, 0x1
/* 2FD94 80054994 AFA20010 */  sw        $v0, 0x10($sp)
/* 2FD98 80054998 02A0202D */  daddu     $a0, $s5, $zero
/* 2FD9C 8005499C 0280282D */  daddu     $a1, $s4, $zero
/* 2FDA0 800549A0 0200302D */  daddu     $a2, $s0, $zero
/* 2FDA4 800549A4 0C01527E */  jal       au_swizzle_BK_instruments
/* 2FDA8 800549A8 24070010 */   addiu    $a3, $zero, 0x10
/* 2FDAC 800549AC 0801526E */  j         .L800549B8
/* 2FDB0 800549B0 0000982D */   daddu    $s3, $zero, $zero
.L800549B4:
/* 2FDB4 800549B4 0000902D */  daddu     $s2, $zero, $zero
.L800549B8:
/* 2FDB8 800549B8 3242FFFF */  andi      $v0, $s2, 0xFFFF
/* 2FDBC 800549BC 1440FF9B */  bnez      $v0, .L8005482C
/* 2FDC0 800549C0 3263FFFF */   andi     $v1, $s3, 0xFFFF
/* 2FDC4 800549C4 0280102D */  daddu     $v0, $s4, $zero
/* 2FDC8 800549C8 8FBF007C */  lw        $ra, 0x7C($sp)
/* 2FDCC 800549CC 8FBE0078 */  lw        $fp, 0x78($sp)
/* 2FDD0 800549D0 8FB70074 */  lw        $s7, 0x74($sp)
/* 2FDD4 800549D4 8FB60070 */  lw        $s6, 0x70($sp)
/* 2FDD8 800549D8 8FB5006C */  lw        $s5, 0x6C($sp)
/* 2FDDC 800549DC 8FB40068 */  lw        $s4, 0x68($sp)
/* 2FDE0 800549E0 8FB30064 */  lw        $s3, 0x64($sp)
/* 2FDE4 800549E4 8FB20060 */  lw        $s2, 0x60($sp)
/* 2FDE8 800549E8 8FB1005C */  lw        $s1, 0x5C($sp)
/* 2FDEC 800549EC 8FB00058 */  lw        $s0, 0x58($sp)
/* 2FDF0 800549F0 03E00008 */  jr        $ra
/* 2FDF4 800549F4 27BD0080 */   addiu    $sp, $sp, 0x80

### DECOMPILED C INSTRUCTIONS:

SoundBank* au_load_BK_to_bank(s32 bkFileOffset, SoundBank* bank, s32 bankIndex, s32 bankGroup) {
    ALHeap* heap = gSynDriverPtr->heap;
    BKHeader bkHeader;
    BKHeader* header = &bkHeader;
    u16 keepReading;
    u16 readState;
    InstrumentGroup* group;
    Instrument** inst;
    s32 instrumentCount;
    s32 size;
    u32 i;

    au_read_rom(bkFileOffset, header, sizeof(*header));
    readState = BK_READ_FETCH_HEADER;
    keepReading = TRUE;

    while (keepReading) {
        switch (readState) {
            case BK_READ_DONE:
                keepReading = FALSE;
                break;
            case BK_READ_FETCH_HEADER:
                if (header->signature != AL_HEADER_SIG_BK) {
                    keepReading = FALSE;
                } else if (header->size == 0) {
                    keepReading = FALSE;
                } else {
                    readState = BK_READ_FETCH_DATA;
                }
                break;
            case BK_READ_FETCH_DATA:
                if (header->format == AL_HEADER_SIG_CR) {
                    readState = BK_READ_PROCESS_CR;
                } else if (header->format == AL_HEADER_SIG_DR) {
                    readState = BK_READ_PROCESS_DR;
                } else if (header->format == AL_HEADER_SIG_SR) {
                    readState = BK_READ_PROCESS_SR;
                } else {
                    keepReading = FALSE;
                }
                break;

            case BK_READ_PROCESS_CR:
                size = ALIGN16_(header->instrumetsSize)
                    + ALIGN16_(header->unkSizeA)
                    + ALIGN16_(header->predictorsSize)
                    + ALIGN16_(header->unkSizeB)
                    + sizeof(*header);
                if (bank == NULL) {
                    bank = alHeapAlloc(heap, 1, size);
                }
                au_read_rom(bkFileOffset, bank, size);

                group = au_get_BK_instruments(bankGroup, bankIndex);
                inst = (*group);
                instrumentCount = 0;

                for (i = 0; i < ARRAY_COUNT(header->instruments); inst++, i++) {
                    u16 instOffset = header->instruments[i];
                    if (instOffset != 0) {
                        instrumentCount++;
                        *inst = AU_FILE_RELATIVE(bank, instOffset);
                    } else {
                        *inst = NULL;
                    }
                }

                if (instrumentCount != 0) {
                    readState = BK_READ_SWIZZLE_CR;
                } else {
                    keepReading = FALSE;
                }
                break;
            case BK_READ_SWIZZLE_CR:
                au_swizzle_BK_instruments(bkFileOffset, bank, *group, 16, 1);
                readState = BK_READ_DONE;
                break;

            // inferred states
            case BK_READ_PROCESS_DR:
            case BK_READ_UNK_DR:
            case BK_READ_PROCESS_SR:
            case BK_READ_UNK_SR:
            default:
                keepReading = FALSE;
                break;
        }
    }

    return bank;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel state_step_battle
/* ECE4 800338E4 27BDFFE8 */  addiu     $sp, $sp, -0x18
/* ECE8 800338E8 AFB00010 */  sw        $s0, 0x10($sp)
/* ECEC 800338EC 3C10800A */  lui       $s0, %hi(D_800A0900)
/* ECF0 800338F0 26100900 */  addiu     $s0, $s0, %lo(D_800A0900)
/* ECF4 800338F4 24030005 */  addiu     $v1, $zero, 0x5
/* ECF8 800338F8 AFBF0014 */  sw        $ra, 0x14($sp)
/* ECFC 800338FC 82020000 */  lb        $v0, 0x0($s0)
/* ED00 80033900 1443000F */  bne       $v0, $v1, .L80033940
/* ED04 80033904 92040000 */   lbu      $a0, 0x0($s0)
/* ED08 80033908 3C02800A */  lui       $v0, %hi(nuGfxCfb)
/* ED0C 8003390C 8C42A658 */  lw        $v0, %lo(nuGfxCfb)($v0)
/* ED10 80033910 8C430004 */  lw        $v1, 0x4($v0)
/* ED14 80033914 3C02800A */  lui       $v0, %hi(nuGfxCfb_ptr)
/* ED18 80033918 8C42A64C */  lw        $v0, %lo(nuGfxCfb_ptr)($v0)
/* ED1C 8003391C 14620089 */  bne       $v1, $v0, .L80033B44
/* ED20 80033920 2484FFFF */   addiu    $a0, $a0, -0x1
/* ED24 80033924 3C02800A */  lui       $v0, %hi(gOverrideFlags)
/* ED28 80033928 2442A650 */  addiu     $v0, $v0, %lo(gOverrideFlags)
/* ED2C 8003392C 8C430000 */  lw        $v1, 0x0($v0)
/* ED30 80033930 A2040000 */  sb        $a0, 0x0($s0)
/* ED34 80033934 34630008 */  ori       $v1, $v1, 0x8
/* ED38 80033938 0C018028 */  jal       nuContRmbForceStop
/* ED3C 8003393C AC430000 */   sw       $v1, 0x0($v0)
.L80033940:
/* ED40 80033940 82030000 */  lb        $v1, 0x0($s0)
/* ED44 80033944 04600071 */  bltz      $v1, .L80033B0C
/* ED48 80033948 92020000 */   lbu      $v0, 0x0($s0)
/* ED4C 8003394C 18600003 */  blez      $v1, .L8003395C
/* ED50 80033950 2442FFFF */   addiu    $v0, $v0, -0x1
/* ED54 80033954 0800CED1 */  j         .L80033B44
/* ED58 80033958 A2020000 */   sb       $v0, 0x0($s0)
.L8003395C:
/* ED5C 8003395C 3C048007 */  lui       $a0, %hi(bFrameBuffers)
/* ED60 80033960 248478A0 */  addiu     $a0, $a0, %lo(bFrameBuffers)
/* ED64 80033964 24050002 */  addiu     $a1, $zero, 0x2
/* ED68 80033968 2402FFFF */  addiu     $v0, $zero, -0x1
/* ED6C 8003396C 0C017CBC */  jal       nuGfxSetCfb
/* ED70 80033970 A2020000 */   sb       $v0, 0x0($s0)
/* ED74 80033974 0C018030 */  jal       nuContRmbForceStopEnd
/* ED78 80033978 00000000 */   nop
/* ED7C 8003397C 0C05260E */  jal       sfx_stop_env_sounds
/* ED80 80033980 00000000 */   nop
/* ED84 80033984 0C00EC6A */  jal       func_8003B1A8
/* ED88 80033988 00000000 */   nop
/* ED8C 8003398C 3C108007 */  lui       $s0, %hi(gGameStatusPtr)
/* ED90 80033990 2610419C */  addiu     $s0, $s0, %lo(gGameStatusPtr)
/* ED94 80033994 8E030000 */  lw        $v1, 0x0($s0)
/* ED98 80033998 24020001 */  addiu     $v0, $zero, 0x1
/* ED9C 8003399C 0C016BA8 */  jal       backup_map_collision_data
/* EDA0 800339A0 A0620070 */   sb       $v0, 0x70($v1)
/* EDA4 800339A4 0C00B458 */  jal       load_obfuscation_shims
/* EDA8 800339A8 00000000 */   nop
/* EDAC 800339AC 0C0AC82D */  jal       shim_battle_heap_create_obfuscated
/* EDB0 800339B0 00000000 */   nop
/* EDB4 800339B4 0C05259C */  jal       sfx_clear_env_sounds
/* EDB8 800339B8 0000202D */   daddu    $a0, $zero, $zero
/* EDBC 800339BC 8E100000 */  lw        $s0, 0x0($s0)
/* EDC0 800339C0 3C03800E */  lui       $v1, %hi(D_800DC4EA)
/* EDC4 800339C4 9063C4EA */  lbu       $v1, %lo(D_800DC4EA)($v1)
/* EDC8 800339C8 9205007E */  lbu       $a1, 0x7E($s0)
/* EDCC 800339CC 3C04800E */  lui       $a0, %hi(D_800DC4EB)
/* EDD0 800339D0 9084C4EB */  lbu       $a0, %lo(D_800DC4EB)($a0)
/* EDD4 800339D4 30A20001 */  andi      $v0, $a1, 0x1
/* EDD8 800339D8 14400007 */  bnez      $v0, .L800339F8
/* EDDC 800339DC 34A20001 */   ori      $v0, $a1, 0x1
/* EDE0 800339E0 24020026 */  addiu     $v0, $zero, 0x26
/* EDE4 800339E4 54620006 */  bnel      $v1, $v0, .L80033A00
/* EDE8 800339E8 24040005 */   addiu    $a0, $zero, 0x5
/* EDEC 800339EC 54800004 */  bnel      $a0, $zero, .L80033A00
/* EDF0 800339F0 24040005 */   addiu    $a0, $zero, 0x5
/* EDF4 800339F4 34A20001 */  ori       $v0, $a1, 0x1
.L800339F8:
/* EDF8 800339F8 A202007E */  sb        $v0, 0x7E($s0)
/* EDFC 800339FC 24040006 */  addiu     $a0, $zero, 0x6
.L80033A00:
/* EE00 80033A00 0C0B763E */  jal       spr_init_sprites
/* EE04 80033A04 00000000 */   nop
/* EE08 80033A08 0C045751 */  jal       clear_model_data
/* EE0C 80033A0C 00000000 */   nop
/* EE10 80033A10 0C052010 */  jal       clear_sprite_shading_data
/* EE14 80033A14 00000000 */   nop
/* EE18 80033A18 0C05177E */  jal       reset_background_settings
/* EE1C 80033A1C 00000000 */   nop
/* EE20 80033A20 0C0482EC */  jal       clear_entity_models
/* EE24 80033A24 00000000 */   nop
/* EE28 80033A28 0C047889 */  jal       clear_animator_list
/* EE2C 80033A2C 00000000 */   nop
/* EE30 80033A30 0C048C2E */  jal       clear_worker_list
/* EE34 80033A34 00000000 */   nop
/* EE38 80033A38 0000202D */  daddu     $a0, $zero, $zero
/* EE3C 80033A3C 0C0514BA */  jal       hud_element_set_aux_cache
/* EE40 80033A40 0080282D */   daddu    $a1, $a0, $zero
/* EE44 80033A44 0C050440 */  jal       hud_element_clear_cache
/* EE48 80033A48 00000000 */   nop
/* EE4C 80033A4C 0C03A6EC */  jal       reset_status_bar
/* EE50 80033A50 00000000 */   nop
/* EE54 80033A54 0C04C3FC */  jal       clear_item_entity_data
/* EE58 80033A58 00000000 */   nop
/* EE5C 80033A5C 0C0B0C77 */  jal       clear_script_list
/* EE60 80033A60 00000000 */   nop
/* EE64 80033A64 0C00E12F */  jal       clear_npcs
/* EE68 80033A68 00000000 */   nop
/* EE6C 80033A6C 0C04432E */  jal       clear_entity_data
/* EE70 80033A70 24040001 */   addiu    $a0, $zero, 0x1
/* EE74 80033A74 0C0515A0 */  jal       clear_trigger_data
/* EE78 80033A78 00000000 */   nop
/* EE7C 80033A7C 3C040017 */  lui       $a0, %hi(D_16C8E0)
/* EE80 80033A80 2484C8E0 */  addiu     $a0, $a0, %lo(D_16C8E0)
/* EE84 80033A84 3C05001D */  lui       $a1, %hi(D_1CC310)
/* EE88 80033A88 24A5C310 */  addiu     $a1, $a1, %lo(D_1CC310)
/* EE8C 80033A8C 3C068024 */  lui       $a2, %hi(get_dpad_input_radial)
/* EE90 80033A90 24C6E000 */  addiu     $a2, $a2, %lo(get_dpad_input_radial)
/* EE94 80033A94 0C00A5CF */  jal       dma_copy
/* EE98 80033A98 00000000 */   nop
/* EE9C 80033A9C 0C08F84C */  jal       initialize_battle
/* EEA0 80033AA0 00000000 */   nop
/* EEA4 80033AA4 0C09027D */  jal       D_802409F4
/* EEA8 80033AA8 00000000 */   nop
/* EEAC 80033AAC 0C01CAF7 */  jal       load_battle_section
/* EEB0 80033AB0 00000000 */   nop
/* EEB4 80033AB4 3C04800F */  lui       $a0, %hi(gPlayerStatusPtr)
/* EEB8 80033AB8 8C847B30 */  lw        $a0, %lo(gPlayerStatusPtr)($a0)
/* EEBC 80033ABC 8C820004 */  lw        $v0, 0x4($a0)
/* EEC0 80033AC0 2403FFBF */  addiu     $v1, $zero, -0x41
/* EEC4 80033AC4 3C01800A */  lui       $at, %hi(D_800A0904)
/* EEC8 80033AC8 AC220904 */  sw        $v0, %lo(D_800A0904)($at)
/* EECC 80033ACC 00431024 */  and       $v0, $v0, $v1
/* EED0 80033AD0 0C009C64 */  jal       get_time_freeze_mode
/* EED4 80033AD4 AC820004 */   sw       $v0, 0x4($a0)
/* EED8 80033AD8 3C01800A */  lui       $at, %hi(D_800A0908)
/* EEDC 80033ADC AC220908 */  sw        $v0, %lo(D_800A0908)($at)
/* EEE0 80033AE0 0C009C22 */  jal       set_time_freeze_mode
/* EEE4 80033AE4 0000202D */   daddu    $a0, $zero, $zero
/* EEE8 80033AE8 3C05800A */  lui       $a1, %hi(gOverrideFlags)
/* EEEC 80033AEC 24A5A650 */  addiu     $a1, $a1, %lo(gOverrideFlags)
/* EEF0 80033AF0 2403FFF7 */  addiu     $v1, $zero, -0x9
/* EEF4 80033AF4 8CA20000 */  lw        $v0, 0x0($a1)
/* EEF8 80033AF8 3C04800A */  lui       $a0, %hi(D_800A0900)
/* EEFC 80033AFC 80840900 */  lb        $a0, %lo(D_800A0900)($a0)
/* EF00 80033B00 00431024 */  and       $v0, $v0, $v1
/* EF04 80033B04 0481000F */  bgez      $a0, .L80033B44
/* EF08 80033B08 ACA20000 */   sw       $v0, 0x0($a1)
.L80033B0C:
/* EF0C 80033B0C 0C00F949 */  jal       update_encounters
/* EF10 80033B10 00000000 */   nop
/* EF14 80033B14 0C08F90E */  jal       btl_update
/* EF18 80033B18 00000000 */   nop
/* EF1C 80033B1C 0C00E64C */  jal       update_npcs
/* EF20 80033B20 00000000 */   nop
/* EF24 80033B24 0C04C7BB */  jal       update_item_entities
/* EF28 80033B28 00000000 */   nop
/* EF2C 80033B2C 0C016754 */  jal       update_effects
/* EF30 80033B30 00000000 */   nop
/* EF34 80033B34 0C04599D */  jal       iterate_models
/* EF38 80033B38 00000000 */   nop
/* EF3C 80033B3C 0C00B500 */  jal       update_cameras
/* EF40 80033B40 00000000 */   nop
.L80033B44:
/* EF44 80033B44 8FBF0014 */  lw        $ra, 0x14($sp)
/* EF48 80033B48 8FB00010 */  lw        $s0, 0x10($sp)
/* EF4C 80033B4C 03E00008 */  jr        $ra
/* EF50 80033B50 27BD0018 */   addiu    $sp, $sp, 0x18

### DECOMPILED C INSTRUCTIONS:

void state_step_battle(void) {
    u32 currentBattleSelection;
    u32 currentBattleIndex;

    if (D_800A0900 == 5) {
        if (nuGfxCfb[1] != nuGfxCfb_ptr) {
            return;
        }
        D_800A0900--;
        gOverrideFlags |= GLOBAL_OVERRIDES_8;
        nuContRmbForceStop();
    }

    if (D_800A0900 >= 0) {
        if (D_800A0900 > 0) {
            D_800A0900--;
            return;
        } else {
            D_800A0900 = -1;
            nuGfxSetCfb(bFrameBuffers, 2);
            nuContRmbForceStopEnd();
            sfx_stop_env_sounds();
            func_8003B1A8();
            gGameStatusPtr->isBattle = TRUE;
            backup_map_collision_data();

#if VERSION_IQUE
            battle_heap_create();
#else
            load_obfuscation_shims();
            shim_battle_heap_create_obfuscated();
#endif

            sfx_clear_env_sounds(0);

            currentBattleSelection = UNPACK_BTL_AREA(gCurrentBattleID);
            currentBattleIndex = UNPACK_BTL_INDEX(gCurrentBattleID);

            if (gGameStatusPtr->peachFlags & PEACH_STATUS_FLAG_IS_PEACH ||
                (currentBattleSelection == BTL_AREA_KKJ && currentBattleIndex == 0)) {
                gGameStatusPtr->peachFlags |= PEACH_STATUS_FLAG_IS_PEACH;
                spr_init_sprites(PLAYER_SPRITES_PEACH_BATTLE);
            } else {
                spr_init_sprites(PLAYER_SPRITES_MARIO_BATTLE);
            }

            clear_model_data();
            clear_sprite_shading_data();
            reset_background_settings();
            clear_entity_models();
            clear_animator_list();
            clear_worker_list();
            hud_element_set_aux_cache(NULL, 0);
            hud_element_clear_cache();
            reset_status_bar();
            clear_item_entity_data();
            clear_script_list();
            clear_npcs();
            clear_entity_data(1);
            clear_trigger_data();
            dma_copy(battle_code_ROM_START, battle_code_ROM_END, battle_code_VRAM);
            initialize_battle();
            btl_save_world_cameras();
            load_battle_section();
            D_800A0904 = gPlayerStatusPtr->animFlags;
            gPlayerStatusPtr->animFlags &= ~PA_FLAG_PULSE_STONE_VISIBLE;
            D_800A0908 = get_time_freeze_mode();
            set_time_freeze_mode(TIME_FREEZE_NORMAL);
            gOverrideFlags &= ~GLOBAL_OVERRIDES_8;

            if (D_800A0900 >= 0) {
                return;
            }
        }
    }

    update_encounters();
    btl_update();
    update_npcs();
    update_item_entities();
    update_effects();
    iterate_models();
    update_cameras();
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel func_80050970
/* 2BD70 80050970 27BDFFC0 */  addiu     $sp, $sp, -0x40
/* 2BD74 80050974 AFBF003C */  sw        $ra, 0x3C($sp)
/* 2BD78 80050978 AFBE0038 */  sw        $fp, 0x38($sp)
/* 2BD7C 8005097C AFB70034 */  sw        $s7, 0x34($sp)
/* 2BD80 80050980 AFB60030 */  sw        $s6, 0x30($sp)
/* 2BD84 80050984 AFB5002C */  sw        $s5, 0x2C($sp)
/* 2BD88 80050988 AFB40028 */  sw        $s4, 0x28($sp)
/* 2BD8C 8005098C AFB30024 */  sw        $s3, 0x24($sp)
/* 2BD90 80050990 AFB20020 */  sw        $s2, 0x20($sp)
/* 2BD94 80050994 AFB1001C */  sw        $s1, 0x1C($sp)
/* 2BD98 80050998 AFB00018 */  sw        $s0, 0x18($sp)
/* 2BD9C 8005099C 8C820000 */  lw        $v0, 0x0($a0)
/* 2BDA0 800509A0 8C840010 */  lw        $a0, 0x10($a0)
/* 2BDA4 800509A4 0000B82D */  daddu     $s7, $zero, $zero
/* 2BDA8 800509A8 1040006A */  beqz      $v0, .L80050B54
/* 2BDAC 800509AC AFA40010 */   sw       $a0, 0x10($sp)
/* 2BDB0 800509B0 0C0135E5 */  jal       au_bgm_get_player_with_song_name
/* 2BDB4 800509B4 0040202D */   daddu    $a0, $v0, $zero
/* 2BDB8 800509B8 0040882D */  daddu     $s1, $v0, $zero
/* 2BDBC 800509BC 12200063 */  beqz      $s1, .L80050B4C
/* 2BDC0 800509C0 02E0A82D */   daddu    $s5, $s7, $zero
/* 2BDC4 800509C4 241E0001 */  addiu     $fp, $zero, 0x1
/* 2BDC8 800509C8 3C168008 */  lui       $s6, %hi(D_80078554)
/* 2BDCC 800509CC 26D68554 */  addiu     $s6, $s6, %lo(D_80078554)
/* 2BDD0 800509D0 2414025C */  addiu     $s4, $zero, 0x25C
.L800509D4:
/* 2BDD4 800509D4 02349021 */  addu      $s2, $s1, $s4
/* 2BDD8 800509D8 8E420000 */  lw        $v0, 0x0($s2)
/* 2BDDC 800509DC 50400056 */  beql      $v0, $zero, .L80050B38
/* 2BDE0 800509E0 26B50001 */   addiu    $s5, $s5, 0x1
/* 2BDE4 800509E4 92420059 */  lbu       $v0, 0x59($s2)
/* 2BDE8 800509E8 10400052 */  beqz      $v0, .L80050B34
/* 2BDEC 800509EC 0040182D */   daddu    $v1, $v0, $zero
/* 2BDF0 800509F0 00031040 */  sll       $v0, $v1, 1
/* 2BDF4 800509F4 00431021 */  addu      $v0, $v0, $v1
/* 2BDF8 800509F8 00021140 */  sll       $v0, $v0, 5
/* 2BDFC 800509FC 244201FC */  addiu     $v0, $v0, 0x1FC
/* 2BE00 80050A00 8FA70010 */  lw        $a3, 0x10($sp)
/* 2BE04 80050A04 10E00024 */  beqz      $a3, .L80050A98
/* 2BE08 80050A08 02229821 */   addu     $s3, $s1, $v0
/* 2BE0C 80050A0C 9242005A */  lbu       $v0, 0x5A($s2)
/* 2BE10 80050A10 50400049 */  beql      $v0, $zero, .L80050B38
/* 2BE14 80050A14 26B50001 */   addiu    $s5, $s5, 0x1
/* 2BE18 80050A18 A240005A */  sb        $zero, 0x5A($s2)
/* 2BE1C 80050A1C 92650052 */  lbu       $a1, 0x52($s3)
/* 2BE20 80050A20 92620053 */  lbu       $v0, 0x53($s3)
/* 2BE24 80050A24 00A2102A */  slt       $v0, $a1, $v0
/* 2BE28 80050A28 10400014 */  beqz      $v0, .L80050A7C
/* 2BE2C 80050A2C A27E005A */   sb       $fp, 0x5A($s3)
/* 2BE30 80050A30 000510C0 */  sll       $v0, $a1, 3
/* 2BE34 80050A34 00451021 */  addu      $v0, $v0, $a1
/* 2BE38 80050A38 000210C0 */  sll       $v0, $v0, 3
/* 2BE3C 80050A3C 24461320 */  addiu     $a2, $v0, 0x1320
.L80050A40:
/* 2BE40 80050A40 8E220000 */  lw        $v0, 0x0($s1)
/* 2BE44 80050A44 00462021 */  addu      $a0, $v0, $a2
/* 2BE48 80050A48 90830045 */  lbu       $v1, 0x45($a0)
/* 2BE4C 80050A4C 92220234 */  lbu       $v0, 0x234($s1)
/* 2BE50 80050A50 14620005 */  bne       $v1, $v0, .L80050A68
/* 2BE54 80050A54 00000000 */   nop
/* 2BE58 80050A58 9082003D */  lbu       $v0, 0x3D($a0)
/* 2BE5C 80050A5C AC960018 */  sw        $s6, 0x18($a0)
/* 2BE60 80050A60 34420010 */  ori       $v0, $v0, 0x10
/* 2BE64 80050A64 A082003D */  sb        $v0, 0x3D($a0)
.L80050A68:
/* 2BE68 80050A68 92620053 */  lbu       $v0, 0x53($s3)
/* 2BE6C 80050A6C 24A50001 */  addiu     $a1, $a1, 0x1
/* 2BE70 80050A70 00A2102A */  slt       $v0, $a1, $v0
/* 2BE74 80050A74 1440FFF2 */  bnez      $v0, .L80050A40
/* 2BE78 80050A78 24C60048 */   addiu    $a2, $a2, 0x48
.L80050A7C:
/* 2BE7C 80050A7C 0220202D */  daddu     $a0, $s1, $zero
/* 2BE80 80050A80 82500018 */  lb        $s0, 0x18($s2)
/* 2BE84 80050A84 0C013FAC */  jal       au_BGMCmd_E9_SubTrackVolume
/* 2BE88 80050A88 0240282D */   daddu    $a1, $s2, $zero
/* 2BE8C 80050A8C 0220202D */  daddu     $a0, $s1, $zero
/* 2BE90 80050A90 080142C8 */  j         .L80050B20
/* 2BE94 80050A94 0240282D */   daddu    $a1, $s2, $zero
.L80050A98:
/* 2BE98 80050A98 9242005A */  lbu       $v0, 0x5A($s2)
/* 2BE9C 80050A9C 54400026 */  bnel      $v0, $zero, .L80050B38
/* 2BEA0 80050AA0 26B50001 */   addiu    $s5, $s5, 0x1
/* 2BEA4 80050AA4 A25E005A */  sb        $fp, 0x5A($s2)
/* 2BEA8 80050AA8 A260005A */  sb        $zero, 0x5A($s3)
/* 2BEAC 80050AAC 92450052 */  lbu       $a1, 0x52($s2)
/* 2BEB0 80050AB0 92420053 */  lbu       $v0, 0x53($s2)
/* 2BEB4 80050AB4 00A2102A */  slt       $v0, $a1, $v0
/* 2BEB8 80050AB8 10400013 */  beqz      $v0, .L80050B08
/* 2BEBC 80050ABC 000510C0 */   sll      $v0, $a1, 3
/* 2BEC0 80050AC0 00451021 */  addu      $v0, $v0, $a1
/* 2BEC4 80050AC4 000210C0 */  sll       $v0, $v0, 3
/* 2BEC8 80050AC8 24461320 */  addiu     $a2, $v0, 0x1320
.L80050ACC:
/* 2BECC 80050ACC 8E220000 */  lw        $v0, 0x0($s1)
/* 2BED0 80050AD0 00462021 */  addu      $a0, $v0, $a2
/* 2BED4 80050AD4 90830045 */  lbu       $v1, 0x45($a0)
/* 2BED8 80050AD8 92220234 */  lbu       $v0, 0x234($s1)
/* 2BEDC 80050ADC 14620005 */  bne       $v1, $v0, .L80050AF4
/* 2BEE0 80050AE0 00000000 */   nop
/* 2BEE4 80050AE4 9082003D */  lbu       $v0, 0x3D($a0)
/* 2BEE8 80050AE8 AC960018 */  sw        $s6, 0x18($a0)
/* 2BEEC 80050AEC 34420010 */  ori       $v0, $v0, 0x10
/* 2BEF0 80050AF0 A082003D */  sb        $v0, 0x3D($a0)
.L80050AF4:
/* 2BEF4 80050AF4 92420053 */  lbu       $v0, 0x53($s2)
/* 2BEF8 80050AF8 24A50001 */  addiu     $a1, $a1, 0x1
/* 2BEFC 80050AFC 00A2102A */  slt       $v0, $a1, $v0
/* 2BF00 80050B00 1440FFF2 */  bnez      $v0, .L80050ACC
/* 2BF04 80050B04 24C60048 */   addiu    $a2, $a2, 0x48
.L80050B08:
/* 2BF08 80050B08 0220202D */  daddu     $a0, $s1, $zero
/* 2BF0C 80050B0C 82700018 */  lb        $s0, 0x18($s3)
/* 2BF10 80050B10 0C013FAC */  jal       au_BGMCmd_E9_SubTrackVolume
/* 2BF14 80050B14 0260282D */   daddu    $a1, $s3, $zero
/* 2BF18 80050B18 0220202D */  daddu     $a0, $s1, $zero
/* 2BF1C 80050B1C 0260282D */  daddu     $a1, $s3, $zero
.L80050B20:
/* 2BF20 80050B20 24020060 */  addiu     $v0, $zero, 0x60
/* 2BF24 80050B24 A22000D4 */  sb        $zero, 0xD4($s1)
/* 2BF28 80050B28 A62200D4 */  sh        $v0, 0xD4($s1)
/* 2BF2C 80050B2C 0C013FB4 */  jal       au_BGMCmd_F6_TrackVolumeFade
/* 2BF30 80050B30 A23000D6 */   sb       $s0, 0xD6($s1)
.L80050B34:
/* 2BF34 80050B34 26B50001 */  addiu     $s5, $s5, 0x1
.L80050B38:
/* 2BF38 80050B38 2AA20010 */  slti      $v0, $s5, 0x10
/* 2BF3C 80050B3C 1440FFA5 */  bnez      $v0, .L800509D4
/* 2BF40 80050B40 26940060 */   addiu    $s4, $s4, 0x60
/* 2BF44 80050B44 080142D7 */  j         .L80050B5C
/* 2BF48 80050B48 02E0102D */   daddu    $v0, $s7, $zero
.L80050B4C:
/* 2BF4C 80050B4C 080142D6 */  j         .L80050B58
/* 2BF50 80050B50 24170002 */   addiu    $s7, $zero, 0x2
.L80050B54:
/* 2BF54 80050B54 24170003 */  addiu     $s7, $zero, 0x3
.L80050B58:
/* 2BF58 80050B58 02E0102D */  daddu     $v0, $s7, $zero
.L80050B5C:
/* 2BF5C 80050B5C 8FBF003C */  lw        $ra, 0x3C($sp)
/* 2BF60 80050B60 8FBE0038 */  lw        $fp, 0x38($sp)
/* 2BF64 80050B64 8FB70034 */  lw        $s7, 0x34($sp)
/* 2BF68 80050B68 8FB60030 */  lw        $s6, 0x30($sp)
/* 2BF6C 80050B6C 8FB5002C */  lw        $s5, 0x2C($sp)
/* 2BF70 80050B70 8FB40028 */  lw        $s4, 0x28($sp)
/* 2BF74 80050B74 8FB30024 */  lw        $s3, 0x24($sp)
/* 2BF78 80050B78 8FB20020 */  lw        $s2, 0x20($sp)
/* 2BF7C 80050B7C 8FB1001C */  lw        $s1, 0x1C($sp)
/* 2BF80 80050B80 8FB00018 */  lw        $s0, 0x18($sp)
/* 2BF84 80050B84 03E00008 */  jr        $ra
/* 2BF88 80050B88 27BD0040 */   addiu    $sp, $sp, 0x40
/* 2BF8C 80050B8C 00000000 */  nop

### DECOMPILED C INSTRUCTIONS:

AuResult func_80050970(SongUpdateEvent* update) {
    BGMPlayer* player;
    BGMPlayerTrack* track;
    BGMPlayerTrack* parentTrack;
    AuVoice* voice;
    s32 i;
    s32 j;
    s8 oldVolume;

    s32 songName = update->songName;
    s32 variation = update->variation;
    AuResult status = AU_RESULT_OK;

    if (songName != 0) {
        player = au_bgm_get_player_with_song_name(songName);
        if (player != NULL) {
            for (i = 0; i < ARRAY_COUNT(player->tracks); i++) {
                track = &player->tracks[i];
                if (track->bgmReadPos != NULL) {
                    if (track->parentTrackIdx != 0) {
                        parentTrack = &player->tracks[track->parentTrackIdx - 1];
                        if (variation != 0) {
                            if (track->unk_5A != 0) {
                                track->unk_5A = 0;
                                parentTrack->unk_5A = 1;
                                for (j = parentTrack->unk_52; j < parentTrack->unk_53; j++) {
                                    voice = &player->globals->voices[j];
                                    if (voice->priority == player->priority) {
                                        voice->envelope.cmdListRelease = EnvelopeReleaseDefaultFast;
                                        voice->envelopeFlags |= AU_VOICE_ENV_FLAG_KEY_RELEASED;
                                    }
                                }
                                oldVolume = track->subTrackVolume >> 24;
                                au_BGMCmd_E9_SubTrackVolume(player, track);
                                player->seqCmdArgs.raw[0] = 0;
                                player->seqCmdArgs.TrackVolumeFade.time = 96;
                                player->seqCmdArgs.TrackVolumeFade.value = oldVolume;
                                au_BGMCmd_F6_TrackVolumeFade(player, track);
                            }
                        } else {
                            if (track->unk_5A == 0) {
                                track->unk_5A = 1;
                                parentTrack->unk_5A = 0;
                                for (j = track->unk_52; j < track->unk_53; j++) {
                                    voice = &player->globals->voices[j];
                                    if (voice->priority == player->priority) {
                                        voice->envelope.cmdListRelease = EnvelopeReleaseDefaultFast;
                                        voice->envelopeFlags |= AU_VOICE_ENV_FLAG_KEY_RELEASED;
                                    }
                                }
                                oldVolume = parentTrack->subTrackVolume >> 24;
                                au_BGMCmd_E9_SubTrackVolume(player, parentTrack);
                                player->seqCmdArgs.raw[0] = 0;
                                player->seqCmdArgs.TrackVolumeFade.time = 96;
                                player->seqCmdArgs.TrackVolumeFade.value = oldVolume;
                                au_BGMCmd_F6_TrackVolumeFade(player, parentTrack);
                            }
                        }
                    }
                }
            }
        } else {
            status = AU_ERROR_SONG_NOT_PLAYING;
        }
    } else {
        status = AU_ERROR_NULL_SONG_NAME;
    }

    return status;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel PartnerTestEnemy
/* 1AEDB0 802804D0 27BDFFD8 */  addiu     $sp, $sp, -0x28
.L802804D4:
/* 1AEDB4 802804D4 AFB20018 */  sw        $s2, 0x18($sp)
/* 1AEDB8 802804D8 0080902D */  daddu     $s2, $a0, $zero
/* 1AEDBC 802804DC AFBF0024 */  sw        $ra, 0x24($sp)
/* 1AEDC0 802804E0 AFB40020 */  sw        $s4, 0x20($sp)
/* 1AEDC4 802804E4 AFB3001C */  sw        $s3, 0x1C($sp)
/* 1AEDC8 802804E8 AFB10014 */  sw        $s1, 0x14($sp)
/* 1AEDCC 802804EC AFB00010 */  sw        $s0, 0x10($sp)
/* 1AEDD0 802804F0 8E440148 */  lw        $a0, 0x148($s2)
/* 1AEDD4 802804F4 0C09A75B */  jal       get_actor
/* 1AEDD8 802804F8 8E50000C */   lw       $s0, 0xC($s2)
/* 1AEDDC 802804FC 8E140000 */  lw        $s4, 0x0($s0)
/* 1AEDE0 80280500 26100004 */  addiu     $s0, $s0, 0x4
.L80280504:
/* 1AEDE4 80280504 8E030000 */  lw        $v1, 0x0($s0)
/* 1AEDE8 80280508 26100004 */  addiu     $s0, $s0, 0x4
/* 1AEDEC 8028050C 0240202D */  daddu     $a0, $s2, $zero
/* 1AEDF0 80280510 3C11800E */  lui       $s1, %hi(gBattleStatus)
/* 1AEDF4 80280514 2631C070 */  addiu     $s1, $s1, %lo(gBattleStatus)
/* 1AEDF8 80280518 0040982D */  daddu     $s3, $v0, $zero
glabel ShowShopPurchaseDialog
/* 1AEDFC 8028051C AE230188 */  sw        $v1, 0x188($s1)
/* 1AEE00 80280520 8E030000 */  lw        $v1, 0x0($s0)
/* 1AEE04 80280524 26100004 */  addiu     $s0, $s0, 0x4
/* 1AEE08 80280528 AE23018C */  sw        $v1, 0x18C($s1)
/* 1AEE0C 8028052C 8E030000 */  lw        $v1, 0x0($s0)
/* 1AEE10 80280530 26100004 */  addiu     $s0, $s0, 0x4
/* 1AEE14 80280534 AE230190 */  sw        $v1, 0x190($s1)
/* 1AEE18 80280538 8E050000 */  lw        $a1, 0x0($s0)
/* 1AEE1C 8028053C 0C0B1EAF */  jal       evt_get_variable
/* 1AEE20 80280540 26100004 */   addiu    $s0, $s0, 0x4
/* 1AEE24 80280544 A622017E */  sh        $v0, 0x17E($s1)
/* 1AEE28 80280548 A2200198 */  sb        $zero, 0x198($s1)
/* 1AEE2C 8028054C 8E100000 */  lw        $s0, 0x0($s0)
/* 1AEE30 80280550 24020030 */  addiu     $v0, $zero, 0x30
/* 1AEE34 80280554 32030030 */  andi      $v1, $s0, 0x30
/* 1AEE38 80280558 54620004 */  bnel      $v1, $v0, .L8028056C
/* 1AEE3C 8028055C 32020010 */   andi     $v0, $s0, 0x10
/* 1AEE40 80280560 8E220000 */  lw        $v0, 0x0($s1)
/* 1AEE44 80280564 080A016B */  j         .L802805AC
/* 1AEE48 80280568 34420030 */   ori      $v0, $v0, 0x30
.L8028056C:
/* 1AEE4C 8028056C 10400004 */  beqz      $v0, .L80280580
/* 1AEE50 80280570 2403FFDF */   addiu    $v1, $zero, -0x21
/* 1AEE54 80280574 8E220000 */  lw        $v0, 0x0($s1)
/* 1AEE58 80280578 080A016A */  j         .L802805A8
/* 1AEE5C 8028057C 34420010 */   ori      $v0, $v0, 0x10
.L80280580:
/* 1AEE60 80280580 32020020 */  andi      $v0, $s0, 0x20
/* 1AEE64 80280584 10400005 */  beqz      $v0, .L8028059C
/* 1AEE68 80280588 2403FFEF */   addiu    $v1, $zero, -0x11
/* 1AEE6C 8028058C 8E220000 */  lw        $v0, 0x0($s1)
/* 1AEE70 80280590 00431024 */  and       $v0, $v0, $v1
/* 1AEE74 80280594 080A016B */  j         .L802805AC
/* 1AEE78 80280598 34420020 */   ori      $v0, $v0, 0x20
.L8028059C:
/* 1AEE7C 8028059C 8E220000 */  lw        $v0, 0x0($s1)
/* 1AEE80 802805A0 00431024 */  and       $v0, $v0, $v1
/* 1AEE84 802805A4 2403FFDF */  addiu     $v1, $zero, -0x21
.L802805A8:
/* 1AEE88 802805A8 00431024 */  and       $v0, $v0, $v1
.L802805AC:
/* 1AEE8C 802805AC AE220000 */  sw        $v0, 0x0($s1)
/* 1AEE90 802805B0 32020040 */  andi      $v0, $s0, 0x40
/* 1AEE94 802805B4 10400007 */  beqz      $v0, .L802805D4
/* 1AEE98 802805B8 2404FFBF */   addiu    $a0, $zero, -0x41
/* 1AEE9C 802805BC 3C03800E */  lui       $v1, %hi(gBattleStatus)
/* 1AEEA0 802805C0 2463C070 */  addiu     $v1, $v1, %lo(gBattleStatus)
/* 1AEEA4 802805C4 8C620000 */  lw        $v0, 0x0($v1)
/* 1AEEA8 802805C8 34420040 */  ori       $v0, $v0, 0x40
/* 1AEEAC 802805CC 080A017A */  j         .L802805E8
/* 1AEEB0 802805D0 AC620000 */   sw       $v0, 0x0($v1)
.L802805D4:
/* 1AEEB4 802805D4 3C02800E */  lui       $v0, %hi(gBattleStatus)
/* 1AEEB8 802805D8 2442C070 */  addiu     $v0, $v0, %lo(gBattleStatus)
.L802805DC:
/* 1AEEBC 802805DC 8C430000 */  lw        $v1, 0x0($v0)
/* 1AEEC0 802805E0 00641824 */  and       $v1, $v1, $a0
/* 1AEEC4 802805E4 AC430000 */  sw        $v1, 0x0($v0)
.L802805E8:
/* 1AEEC8 802805E8 32020200 */  andi      $v0, $s0, 0x200
/* 1AEECC 802805EC 10400007 */  beqz      $v0, .L8028060C
/* 1AEED0 802805F0 2404FDFF */   addiu    $a0, $zero, -0x201
/* 1AEED4 802805F4 3C03800E */  lui       $v1, %hi(gBattleStatus)
/* 1AEED8 802805F8 2463C070 */  addiu     $v1, $v1, %lo(gBattleStatus)
/* 1AEEDC 802805FC 8C620000 */  lw        $v0, 0x0($v1)
/* 1AEEE0 80280600 34420200 */  ori       $v0, $v0, 0x200
/* 1AEEE4 80280604 080A0188 */  j         .L80280620
.L80280608:
/* 1AEEE8 80280608 AC620000 */   sw       $v0, 0x0($v1)
.L8028060C:
/* 1AEEEC 8028060C 3C02800E */  lui       $v0, %hi(gBattleStatus)
/* 1AEEF0 80280610 2442C070 */  addiu     $v0, $v0, %lo(gBattleStatus)
/* 1AEEF4 80280614 8C430000 */  lw        $v1, 0x0($v0)
/* 1AEEF8 80280618 00641824 */  and       $v1, $v1, $a0
/* 1AEEFC 8028061C AC430000 */  sw        $v1, 0x0($v0)
.L80280620:
/* 1AEF00 80280620 32020080 */  andi      $v0, $s0, 0x80
/* 1AEF04 80280624 10400007 */  beqz      $v0, .L80280644
/* 1AEF08 80280628 2404FF7F */   addiu    $a0, $zero, -0x81
/* 1AEF0C 8028062C 3C03800E */  lui       $v1, %hi(gBattleStatus)
/* 1AEF10 80280630 2463C070 */  addiu     $v1, $v1, %lo(gBattleStatus)
/* 1AEF14 80280634 8C620000 */  lw        $v0, 0x0($v1)
/* 1AEF18 80280638 34420080 */  ori       $v0, $v0, 0x80
/* 1AEF1C 8028063C 080A0196 */  j         .L80280658
.L80280640:
/* 1AEF20 80280640 AC620000 */   sw       $v0, 0x0($v1)
.L80280644:
/* 1AEF24 80280644 3C02800E */  lui       $v0, %hi(gBattleStatus)
/* 1AEF28 80280648 2442C070 */  addiu     $v0, $v0, %lo(gBattleStatus)
/* 1AEF2C 8028064C 8C430000 */  lw        $v1, 0x0($v0)
.L80280650:
/* 1AEF30 80280650 00641824 */  and       $v1, $v1, $a0
/* 1AEF34 80280654 AC430000 */  sw        $v1, 0x0($v0)
.L80280658:
/* 1AEF38 80280658 32020800 */  andi      $v0, $s0, 0x800
/* 1AEF3C 8028065C 10400007 */  beqz      $v0, .L8028067C
/* 1AEF40 80280660 2404F7FF */   addiu    $a0, $zero, -0x801
/* 1AEF44 80280664 3C03800E */  lui       $v1, %hi(gBattleStatus)
/* 1AEF48 80280668 2463C070 */  addiu     $v1, $v1, %lo(gBattleStatus)
/* 1AEF4C 8028066C 8C620000 */  lw        $v0, 0x0($v1)
/* 1AEF50 80280670 34420800 */  ori       $v0, $v0, 0x800
.L80280674:
/* 1AEF54 80280674 080A01A4 */  j         .L80280690
/* 1AEF58 80280678 AC620000 */   sw       $v0, 0x0($v1)
.L8028067C:
/* 1AEF5C 8028067C 3C02800E */  lui       $v0, %hi(gBattleStatus)
/* 1AEF60 80280680 2442C070 */  addiu     $v0, $v0, %lo(gBattleStatus)
/* 1AEF64 80280684 8C430000 */  lw        $v1, 0x0($v0)
/* 1AEF68 80280688 00641824 */  and       $v1, $v1, $a0
/* 1AEF6C 8028068C AC430000 */  sw        $v1, 0x0($v0)
.L80280690:
/* 1AEF70 80280690 96620428 */  lhu       $v0, 0x428($s3)
/* 1AEF74 80280694 92230193 */  lbu       $v1, 0x193($s1)
/* 1AEF78 80280698 A62201A0 */  sh        $v0, 0x1A0($s1)
/* 1AEF7C 8028069C 92620426 */  lbu       $v0, 0x426($s3)
/* 1AEF80 802806A0 A2230194 */  sb        $v1, 0x194($s1)
/* 1AEF84 802806A4 306300FF */  andi      $v1, $v1, 0xFF
/* 1AEF88 802806A8 A22201A2 */  sb        $v0, 0x1A2($s1)
/* 1AEF8C 802806AC 240200FF */  addiu     $v0, $zero, 0xFF
/* 1AEF90 802806B0 50620001 */  beql      $v1, $v0, .L802806B8
/* 1AEF94 802806B4 A2200194 */   sb       $zero, 0x194($s1)
.L802806B8:
/* 1AEF98 802806B8 8E220190 */  lw        $v0, 0x190($s1)
/* 1AEF9C 802806BC 30420F00 */  andi      $v0, $v0, 0xF00
/* 1AEFA0 802806C0 00021203 */  sra       $v0, $v0, 8
/* 1AEFA4 802806C4 0C09F7DF */  jal       calc_partner_test_enemy
/* 1AEFA8 802806C8 A2220195 */   sb       $v0, 0x195($s1)
.L802806CC:
/* 1AEFAC 802806CC 04400006 */  bltz      $v0, .L802806E8
/* 1AEFB0 802806D0 0240202D */   daddu    $a0, $s2, $zero
/* 1AEFB4 802806D4 0280282D */  daddu     $a1, $s4, $zero
/* 1AEFB8 802806D8 0C0B2026 */  jal       evt_set_variable
/* 1AEFBC 802806DC 0040302D */   daddu    $a2, $v0, $zero
/* 1AEFC0 802806E0 080A01BB */  j         .L802806EC
/* 1AEFC4 802806E4 24020002 */   addiu    $v0, $zero, 0x2
.L802806E8:
/* 1AEFC8 802806E8 240200FF */  addiu     $v0, $zero, 0xFF
.L802806EC:
/* 1AEFCC 802806EC 8FBF0024 */  lw        $ra, 0x24($sp)
/* 1AEFD0 802806F0 8FB40020 */  lw        $s4, 0x20($sp)
/* 1AEFD4 802806F4 8FB3001C */  lw        $s3, 0x1C($sp)
/* 1AEFD8 802806F8 8FB20018 */  lw        $s2, 0x18($sp)
/* 1AEFDC 802806FC 8FB10014 */  lw        $s1, 0x14($sp)
/* 1AEFE0 80280700 8FB00010 */  lw        $s0, 0x10($sp)
/* 1AEFE4 80280704 03E00008 */  jr        $ra
/* 1AEFE8 80280708 27BD0028 */   addiu    $sp, $sp, 0x28

### DECOMPILED C INSTRUCTIONS:

ApiStatus PartnerTestEnemy(Evt* script, s32 isInitialCall) {
    BattleStatus* battleStatus = &gBattleStatus;
    PlayerStatus* playerStatus = &gPlayerStatus;
    Bytecode* args = script->ptrReadPos;
    Actor* enemy = get_actor(script->owner1.enemyID);
    s32 temp_s4;
    s32 flags;
    s32 damageResult;
    u8 statusChance;

    temp_s4 = *args++;
    gBattleStatus.currentAttackElement = *args++;
    gBattleStatus.currentAttackEventSuppression = *args++;
    gBattleStatus.currentAttackStatus = *args++;
    gBattleStatus.currentAttackDamage = evt_get_variable(script, *args++);
    gBattleStatus.powerBounceCounter = 0;
    flags = *args++;

    if ((flags & (BS_FLAGS1_10 | BS_FLAGS1_SP_EVT_ACTIVE)) == (BS_FLAGS1_10 | BS_FLAGS1_SP_EVT_ACTIVE)) {
        battleStatus->flags1 |= BS_FLAGS1_10;
        battleStatus->flags1 |= BS_FLAGS1_SP_EVT_ACTIVE;
    } else if (flags & BS_FLAGS1_10) {
        battleStatus->flags1 |= BS_FLAGS1_10;
        battleStatus->flags1 &= ~BS_FLAGS1_SP_EVT_ACTIVE;
    } else if (flags & BS_FLAGS1_SP_EVT_ACTIVE) {
        battleStatus->flags1 &= ~BS_FLAGS1_10;
        battleStatus->flags1 |= BS_FLAGS1_SP_EVT_ACTIVE;
    } else {
        battleStatus->flags1 &= ~BS_FLAGS1_10;
        battleStatus->flags1 &= ~BS_FLAGS1_SP_EVT_ACTIVE;
    }

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

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

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

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

    statusChance = battleStatus->currentAttackStatus;
    battleStatus->currentTargetID = enemy->targetActorID;
    battleStatus->currentTargetPart = enemy->targetPartIndex;
    battleStatus->statusChance = statusChance;

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

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

    if (damageResult < 0) {
        return ApiStatus_FINISH;
    }

    evt_set_variable(script, temp_s4, damageResult);

    return ApiStatus_DONE2;
}


### RAW ASSEMBLY INSTRUCTIONS:

glabel func_E0020000
/* 333EC0 E0020000 27BDFF78 */  addiu     $sp, $sp, -0x88
/* 333EC4 E0020004 AFB1005C */  sw        $s1, 0x5C($sp)
/* 333EC8 E0020008 0080882D */  daddu     $s1, $a0, $zero
/* 333ECC E002000C AFB30064 */  sw        $s3, 0x64($sp)
/* 333ED0 E0020010 AFB00058 */  sw        $s0, 0x58($sp)
/* 333ED4 E0020014 3C108007 */  lui       $s0, %hi(gCurrentCameraID)
/* 333ED8 E0020018 26107410 */  addiu     $s0, $s0, %lo(gCurrentCameraID)
/* 333EDC E002001C AFBF0068 */  sw        $ra, 0x68($sp)
/* 333EE0 E0020020 AFB20060 */  sw        $s2, 0x60($sp)
/* 333EE4 E0020024 F7B80080 */  sdc1      $f24, 0x80($sp)
/* 333EE8 E0020028 F7B60078 */  sdc1      $f22, 0x78($sp)
/* 333EEC E002002C F7B40070 */  sdc1      $f20, 0x70($sp)
/* 333EF0 E0020030 8E030000 */  lw        $v1, 0x0($s0)
/* 333EF4 E0020034 C638001C */  lwc1      $f24, 0x1C($s1)
/* 333EF8 E0020038 C6360020 */  lwc1      $f22, 0x20($s1)
/* 333EFC E002003C 00031080 */  sll       $v0, $v1, 2
/* 333F00 E0020040 00431021 */  addu      $v0, $v0, $v1
/* 333F04 E0020044 00021080 */  sll       $v0, $v0, 2
/* 333F08 E0020048 00431023 */  subu      $v0, $v0, $v1
/* 333F0C E002004C 000218C0 */  sll       $v1, $v0, 3
/* 333F10 E0020050 00431021 */  addu      $v0, $v0, $v1
/* 333F14 E0020054 000210C0 */  sll       $v0, $v0, 3
/* 333F18 E0020058 3C01800B */  lui       $at, %hi(gCameras + 0x6C)
/* 333F1C E002005C 00220821 */  addu      $at, $at, $v0
/* 333F20 E0020060 C42C1DEC */  lwc1      $f12, %lo(gCameras + 0x6C)($at)
/* 333F24 E0020064 8E32003C */  lw        $s2, 0x3C($s1)
/* 333F28 E0020068 0C080140 */  jal       shim_sin_deg
/* 333F2C E002006C 00A0982D */   daddu    $s3, $a1, $zero
/* 333F30 E0020070 8E030000 */  lw        $v1, 0x0($s0)
/* 333F34 E0020074 00031080 */  sll       $v0, $v1, 2
/* 333F38 E0020078 00431021 */  addu      $v0, $v0, $v1
/* 333F3C E002007C 00021080 */  sll       $v0, $v0, 2
/* 333F40 E0020080 00431023 */  subu      $v0, $v0, $v1
/* 333F44 E0020084 000218C0 */  sll       $v1, $v0, 3
/* 333F48 E0020088 00431021 */  addu      $v0, $v0, $v1
/* 333F4C E002008C 000210C0 */  sll       $v0, $v0, 3
/* 333F50 E0020090 3C01800B */  lui       $at, %hi(gCameras + 0x6C)
/* 333F54 E0020094 00220821 */  addu      $at, $at, $v0
/* 333F58 E0020098 C42C1DEC */  lwc1      $f12, %lo(gCameras + 0x6C)($at)
/* 333F5C E002009C 0C080144 */  jal       shim_cos_deg
/* 333F60 E00200A0 46000506 */   mov.s    $f20, $f0
/* 333F64 E00200A4 00131080 */  sll       $v0, $s3, 2
/* 333F68 E00200A8 46000007 */  neg.s     $f0, $f0
/* 333F6C E00200AC E7A00010 */  swc1      $f0, 0x10($sp)
/* 333F70 E00200B0 3C0141A0 */  lui       $at, (0x41A00000 >> 16)
/* 333F74 E00200B4 44810000 */  mtc1      $at, $f0
/* 333F78 E00200B8 00531021 */  addu      $v0, $v0, $s3
/* 333F7C E00200BC 4600C001 */  sub.s     $f0, $f24, $f0
/* 333F80 E00200C0 00021080 */  sll       $v0, $v0, 2
/* 333F84 E00200C4 44821000 */  mtc1      $v0, $f2
/* 333F88 E00200C8 00000000 */  nop
/* 333F8C E00200CC 468010A0 */  cvt.s.w   $f2, $f2
/* 333F90 E00200D0 46020000 */  add.s     $f0, $f0, $f2
/* 333F94 E00200D4 27A40018 */  addiu     $a0, $sp, 0x18
/* 333F98 E00200D8 4406A000 */  mfc1      $a2, $f20
/* 333F9C E00200DC 46000007 */  neg.s     $f0, $f0
/* 333FA0 E00200E0 44050000 */  mfc1      $a1, $f0
/* 333FA4 E00200E4 0C080104 */  jal       shim_guRotateF
/* 333FA8 E00200E8 0000382D */   daddu    $a3, $zero, $zero
/* 333FAC E00200EC 2402FFFF */  addiu     $v0, $zero, -0x1
/* 333FB0 E00200F0 1642001F */  bne       $s2, $v0, .LE0020170
/* 333FB4 E00200F4 00000000 */   nop
/* 333FB8 E00200F8 3C014180 */  lui       $at, (0x41800000 >> 16)
/* 333FBC E00200FC 44813000 */  mtc1      $at, $f6
/* 333FC0 E0020100 00000000 */  nop
/* 333FC4 E0020104 4606B180 */  add.s     $f6, $f22, $f6
/* 333FC8 E0020108 C7A40028 */  lwc1      $f4, 0x28($sp)
/* 333FCC E002010C 46062102 */  mul.s     $f4, $f4, $f6
/* 333FD0 E0020110 00000000 */  nop
/* 333FD4 E0020114 3C028011 */  lui       $v0, %hi(gPlayerStatus)
/* 333FD8 E0020118 2442EFC8 */  addiu     $v0, $v0, %lo(gPlayerStatus)
/* 333FDC E002011C C4400028 */  lwc1      $f0, 0x28($v0)
/* 333FE0 E0020120 C6220010 */  lwc1      $f2, 0x10($s1)
/* 333FE4 E0020124 46020000 */  add.s     $f0, $f0, $f2
/* 333FE8 E0020128 46040000 */  add.s     $f0, $f0, $f4
/* 333FEC E002012C E6200004 */  swc1      $f0, 0x4($s1)
/* 333FF0 E0020130 C7A4002C */  lwc1      $f4, 0x2C($sp)
/* 333FF4 E0020134 46062102 */  mul.s     $f4, $f4, $f6
/* 333FF8 E0020138 00000000 */  nop
/* 333FFC E002013C C6220014 */  lwc1      $f2, 0x14($s1)
/* 334000 E0020140 C440002C */  lwc1      $f0, 0x2C($v0)
/* 334004 E0020144 46020000 */  add.s     $f0, $f0, $f2
/* 334008 E0020148 46040000 */  add.s     $f0, $f0, $f4
/* 33400C E002014C E6200008 */  swc1      $f0, 0x8($s1)
/* 334010 E0020150 C7A40030 */  lwc1      $f4, 0x30($sp)
/* 334014 E0020154 46062102 */  mul.s     $f4, $f4, $f6
/* 334018 E0020158 00000000 */  nop
/* 33401C E002015C C6220018 */  lwc1      $f2, 0x18($s1)
/* 334020 E0020160 C4400030 */  lwc1      $f0, 0x30($v0)
/* 334024 E0020164 46020000 */  add.s     $f0, $f0, $f2
/* 334028 E0020168 0800808F */  j         .LE002023C
/* 33402C E002016C 46040000 */   add.s    $f0, $f0, $f4
.LE0020170:
/* 334030 E0020170 1240001D */  beqz      $s2, .LE00201E8
/* 334034 E0020174 00000000 */   nop
/* 334038 E0020178 3C014180 */  lui       $at, (0x41800000 >> 16)
/* 33403C E002017C 44813000 */  mtc1      $at, $f6
/* 334040 E0020180 00000000 */  nop
/* 334044 E0020184 4606B180 */  add.s     $f6, $f22, $f6
/* 334048 E0020188 C7A40028 */  lwc1      $f4, 0x28($sp)
/* 33404C E002018C 46062102 */  mul.s     $f4, $f4, $f6
/* 334050 E0020190 00000000 */  nop
/* 334054 E0020194 C6400038 */  lwc1      $f0, 0x38($s2)
/* 334058 E0020198 C6220010 */  lwc1      $f2, 0x10($s1)
/* 33405C E002019C 46020000 */  add.s     $f0, $f0, $f2
/* 334060 E00201A0 46040000 */  add.s     $f0, $f0, $f4
/* 334064 E00201A4 E6200004 */  swc1      $f0, 0x4($s1)
/* 334068 E00201A8 C7A4002C */  lwc1      $f4, 0x2C($sp)
/* 33406C E00201AC 46062102 */  mul.s     $f4, $f4, $f6
/* 334070 E00201B0 00000000 */  nop
/* 334074 E00201B4 C6220014 */  lwc1      $f2, 0x14($s1)
/* 334078 E00201B8 C640003C */  lwc1      $f0, 0x3C($s2)
/* 33407C E00201BC 46020000 */  add.s     $f0, $f0, $f2
/* 334080 E00201C0 46040000 */  add.s     $f0, $f0, $f4
/* 334084 E00201C4 E6200008 */  swc1      $f0, 0x8($s1)
/* 334088 E00201C8 C7A40030 */  lwc1      $f4, 0x30($sp)
/* 33408C E00201CC 46062102 */  mul.s     $f4, $f4, $f6
/* 334090 E00201D0 00000000 */  nop
/* 334094 E00201D4 C6220018 */  lwc1      $f2, 0x18($s1)
/* 334098 E00201D8 C6400040 */  lwc1      $f0, 0x40($s2)
/* 33409C E00201DC 46020000 */  add.s     $f0, $f0, $f2
/* 3340A0 E00201E0 0800808F */  j         .LE002023C
/* 3340A4 E00201E4 46040000 */   add.s    $f0, $f0, $f4
.LE00201E8:
/* 3340A8 E00201E8 3C014180 */  lui       $at, (0x41800000 >> 16)
/* 3340AC E00201EC 44812000 */  mtc1      $at, $f4
/* 3340B0 E00201F0 00000000 */  nop
/* 3340B4 E00201F4 4604B100 */  add.s     $f4, $f22, $f4
/* 3340B8 E00201F8 C7A20028 */  lwc1      $f2, 0x28($sp)
/* 3340BC E00201FC 46041082 */  mul.s     $f2, $f2, $f4
/* 3340C0 E0020200 00000000 */  nop
/* 3340C4 E0020204 C6200010 */  lwc1      $f0, 0x10($s1)
/* 3340C8 E0020208 46020000 */  add.s     $f0, $f0, $f2
/* 3340CC E002020C E6200004 */  swc1      $f0, 0x4($s1)
/* 3340D0 E0020210 C7A2002C */  lwc1      $f2, 0x2C($sp)
/* 3340D4 E0020214 46041082 */  mul.s     $f2, $f2, $f4
/* 3340D8 E0020218 00000000 */  nop
/* 3340DC E002021C C6200014 */  lwc1      $f0, 0x14($s1)
/* 3340E0 E0020220 46020000 */  add.s     $f0, $f0, $f2
/* 3340E4 E0020224 E6200008 */  swc1      $f0, 0x8($s1)
/* 3340E8 E0020228 C7A20030 */  lwc1      $f2, 0x30($sp)
/* 3340EC E002022C 46041082 */  mul.s     $f2, $f2, $f4
/* 3340F0 E0020230 00000000 */  nop
/* 3340F4 E0020234 C6200018 */  lwc1      $f0, 0x18($s1)
/* 3340F8 E0020238 46020000 */  add.s     $f0, $f0, $f2
.LE002023C:
/* 3340FC E002023C E620000C */  swc1      $f0, 0xC($s1)
/* 334100 E0020240 3C014140 */  lui       $at, (0x41400000 >> 16)
/* 334104 E0020244 44810000 */  mtc1      $at, $f0
/* 334108 E0020248 3C013F00 */  lui       $at, (0x3F000000 >> 16)
/* 33410C E002024C 44811000 */  mtc1      $at, $f2
/* 334110 E0020250 4600B003 */  div.s     $f0, $f22, $f0
/* 334114 E0020254 46020002 */  mul.s     $f0, $f0, $f2
/* 334118 E0020258 00000000 */  nop
/* 33411C E002025C 00131080 */  sll       $v0, $s3, 2
/* 334120 E0020260 3C0141A0 */  lui       $at, (0x41A00000 >> 16)
/* 334124 E0020264 44812000 */  mtc1      $at, $f4
/* 334128 E0020268 00531021 */  addu      $v0, $v0, $s3
/* 33412C E002026C 4604C101 */  sub.s     $f4, $f24, $f4
/* 334130 E0020270 00021080 */  sll       $v0, $v0, 2
/* 334134 E0020274 44821000 */  mtc1      $v0, $f2
/* 334138 E0020278 00000000 */  nop
/* 33413C E002027C 468010A0 */  cvt.s.w   $f2, $f2
/* 334140 E0020280 46022100 */  add.s     $f4, $f4, $f2
/* 334144 E0020284 3C013FE0 */  lui       $at, (0x3FE00000 >> 16)
/* 334148 E0020288 44811800 */  mtc1      $at, $f3
/* 33414C E002028C 44801000 */  mtc1      $zero, $f2
/* 334150 E0020290 46000021 */  cvt.d.s   $f0, $f0
/* 334154 E0020294 46220000 */  add.d     $f0, $f0, $f2
/* 334158 E0020298 E6240024 */  swc1      $f4, 0x24($s1)
/* 33415C E002029C 46200020 */  cvt.s.d   $f0, $f0
/* 334160 E00202A0 E6200028 */  swc1      $f0, 0x28($s1)
/* 334164 E00202A4 8FBF0068 */  lw        $ra, 0x68($sp)
/* 334168 E00202A8 8FB30064 */  lw        $s3, 0x64($sp)
/* 33416C E00202AC 8FB20060 */  lw        $s2, 0x60($sp)
/* 334170 E00202B0 8FB1005C */  lw        $s1, 0x5C($sp)
/* 334174 E00202B4 8FB00058 */  lw        $s0, 0x58($sp)
/* 334178 E00202B8 D7B80080 */  ldc1      $f24, 0x80($sp)
/* 33417C E00202BC D7B60078 */  ldc1      $f22, 0x78($sp)
/* 334180 E00202C0 D7B40070 */  ldc1      $f20, 0x70($sp)
/* 334184 E00202C4 03E00008 */  jr        $ra
/* 334188 E00202C8 27BD0088 */   addiu    $sp, $sp, 0x88

### DECOMPILED C INSTRUCTIONS:

void func_E0020000(EmoteFXData* part, s32 arg1) {
    f32 unk_1C = part->unk_1C;
    f32 unk_20 = part->unk_20;
    Npc* npc = part->unk_3C;
    Matrix4f sp18;
    f32 sin;
    f32 cos;

    sin = shim_sin_deg(gCameras[gCurrentCameraID].currentYaw);
    cos = shim_cos_deg(gCameras[gCurrentCameraID].currentYaw);
    shim_guRotateF(sp18, -(unk_1C - 20.0f + arg1 * 20), sin, 0.0f, -cos);

    if (npc == PTR_LIST_END) {
        part->unk_04 = gPlayerStatus.position.x + part->unk_10 + sp18[1][0] * (unk_20 + 16.0f);
        part->unk_08 = gPlayerStatus.position.y + part->unk_14 + sp18[1][1] * (unk_20 + 16.0f);
        part->unk_0C = gPlayerStatus.position.z + part->unk_18 + sp18[1][2] * (unk_20 + 16.0f);
    } else if (npc != NULL) {
        part->unk_04 = npc->pos.x + part->unk_10 + sp18[1][0] * (unk_20 + 16.0f);
        part->unk_08 = npc->pos.y + part->unk_14 + sp18[1][1] * (unk_20 + 16.0f);
        part->unk_0C = npc->pos.z + part->unk_18 + sp18[1][2] * (unk_20 + 16.0f);
    } else {
        part->unk_04 = part->unk_10 + sp18[1][0] * (unk_20 + 16.0f);
        part->unk_08 = part->unk_14 + sp18[1][1] * (unk_20 + 16.0f);
        part->unk_0C = part->unk_18 + sp18[1][2] * (unk_20 + 16.0f);
    }

    part->unk_24 = unk_1C - 20.0f + arg1 * 20;
    part->unk_28 = (unk_20 / 12.0f) * 0.5f + 0.5;
}