/**
 * @file code_80057C60.c
 * @warning there are too many variables here
*/

#include <ultra64.h>
#include <macros.h>
#include <PR/gbi.h>

#include "code_80057C60.h"
#include "main.h"
#include "actors.h"
#include "code_800029B0.h"
#include "racing/memory.h"
#include <config.h>
#include <defines.h>
#include "math_util.h"
#include "math_util_2.h"
#include "code_80005FD0.h"
#include "render_player.h"
#include "hud_renderer.h"
#include "code_8006E9C0.h"
#include "code_80071F00.h"
#include "code_80086E70.h"
#include "effects.h"
#include "src/data/data_800E8700.h"
#include "skybox_and_splitscreen.h"
#include "common_textures.h"
#include "audio/external.h"
#include "objects.h"
#include "bomb_kart.h"
#include "menus.h"
#include "data/other_textures.h"
#include "spawn_players.h"
#include "sounds.h"
#include "code_80071F00.h"


//! @warning this macro is undef'd at the end of this file
#define MAKE_RGB(r,g,b) (((r) << 0x10) | ((g) << 0x08) | (b << 0x00))

s32 D_80165590;
s32 D_80165594;
s32 D_80165598;
s32 D_8016559C;
UNUSED s32 D_801655A0;
s32 D_801655A4;
UNUSED s32 D_801655A8;
s32 D_801655AC;
UNUSED s32 D_801655B0;
s32 D_801655B4;
UNUSED s32 D_801655B8;
s32 D_801655BC;
s32 D_801655C0;
s32 D_801655C4;
s32 D_801655C8;
s32 D_801655CC;
UNUSED s32 D_801655D0[2];
s32 D_801655D8;
UNUSED s32 D_801655DC[2];
s32 D_801655E8;
UNUSED s32 D_801655EC;
s32 D_801655F0;
UNUSED s32 D_801655F4;
s32 D_801655F8;
UNUSED s32 D_80165600[2];
s32 D_80165608;
UNUSED s32 D_80165610[2];
s32 D_80165618;
UNUSED s32 D_80165620[2];
s32 D_80165628;
UNUSED s32 D_80165630[2];
u32 D_80165638;
UNUSED s32 D_80165640[2];
u32 D_80165648;
UNUSED u32 D_80165650[2];
u32 D_80165658[8];
s32 D_80165678;
UNUSED s32 D_80165680[12];
u16 D_801656B0;
UNUSED s32 D_801656B8[2];
u16 D_801656C0;
UNUSED s32 D_801656C8[2];
u16 D_801656D0;
UNUSED s32 D_801656D8[2];
u16 D_801656E0;
UNUSED s32 D_801656E8[2];
s16 D_801656F0;
UNUSED s32 D_801656F8[4];
s16 D_80165708;
UNUSED s32 D_8016570C;
s16 D_80165710;
UNUSED s32 D_80165714;
s16 D_80165718;
UNUSED s32 D_8016571C;
s16 D_80165720;
UNUSED s32 D_80165724;
s16 D_80165728;
UNUSED s32 D_8016572C;
s16 D_80165730;
UNUSED s32 D_80165734;
//! Tracking a count of some object type, don't know what object type yet
s16 D_80165738;
UNUSED s32 D_8016573C;
s16 D_80165740;
UNUSED s32 D_80165744;
s16 D_80165748;
UNUSED s32 D_8016574C;

s16 gNumActiveThwomps;
s32 D_80165754;
ThwompSpawn *gThowmpSpawnList;

Vec4s D_80165760;
UNUSED s16 D_80165768; 
s8 D_8016576A;
Vec4s D_80165770;
UNUSED s32 D_80165778;
Vec4s D_80165780;
UNUSED s32 D_80165788;
s16 D_8016578C;
UNUSED s16 D_8016578E;
s16 D_80165790;
UNUSED s16 D_80165792;
s16 D_80165794;
UNUSED s32 D_80165798;
s8 D_8016579C;
u16 D_8016579E;
UNUSED s16 D_801657A0;
//! Something related to the rotation(?) of ice in Sherbet Land
u16 D_801657A2;
UNUSED s32 D_801657A4;
UNUSED s16 D_801657A8[3];
s8 D_801657AE;
UNUSED s8 D_801657AF;
//! HUD related
s8 D_801657B0;
UNUSED s8 D_801657B1;
s8 D_801657B2;
UNUSED s8 D_801657B3;
s8 D_801657B4;
s8 D_801657B8[16];
s8 D_801657C8;
s8 D_801657D0[8];
s8 D_801657D8;
UNUSED s16 D_801657DA[2];
UNUSED s8 D_801657E0;
s8 D_801657E1;
s8 D_801657E2;
s8 D_801657E3;
s8 D_801657E4;
s8 D_801657E5;
bool8 D_801657E6;
u8 D_801657E7;
bool8 D_801657E8;
UNUSED s32 D_801657EC;
bool8 D_801657F0;
UNUSED s32 D_801657F4;
bool8 D_801657F8;
s32 D_801657FC;
s8 D_80165800[2];
s32 D_80165804;
s8 D_80165808;
s32 D_8016580C;
bool8 D_80165810;
s32 D_80165814;
bool8 D_80165818;
s32 D_8016581C;
s8 D_80165820;
UNUSED s32 D_80165824;
s8 D_80165828;
Vec3su D_8016582C;
s8 D_80165832[2];
Vec3su D_80165834;
UNUSED s32 D_8016583A;
s8 D_80165840[3];
UNUSED s32 D_80165848[6];
s32 D_80165860;
UNUSED s32 D_80165864;
UNUSED s32 D_80165868;
s32 D_8016586C;
UNUSED s32 D_80165870[2];
s32 D_80165878;
s32 D_8016587C;
u8 *D_80165880;
UNUSED s32 D_80165884;
s8 D_80165888;
UNUSED s32 D_8016588C;
s8 D_80165890;
UNUSED s32 D_80165894;
s8 D_80165898;
s32 D_8016589C;
UNUSED s32 D_801658A0[2];
s8 D_801658A8;
UNUSED s32 D_801658B0[3];
s8 D_801658BC;
UNUSED s32 D_801658C0;
UNUSED s16 D_801658C4;
s8 D_801658C6;
UNUSED s32 D_801658C8;
UNUSED s16 D_801658CC;
s8 D_801658CE;
UNUSED s32 D_801658D0;
UNUSED s16 D_801658D4;
s8 D_801658D6;
UNUSED s32 D_801658D8;
s8 D_801658DC;
UNUSED s32 D_801658E0;
s8 D_801658E4;
UNUSED s32 D_801658E8;
s8 D_801658EC;
UNUSED s32 D_801658F0;
s8 D_801658F4;
UNUSED s32 D_801658F8;
UNUSED s8 D_801658FC;
u8 sRandomItemIndex;
s8 D_801658FE;
u8 gControllerRandom;
s16 D_80165900;
UNUSED s32 D_80165904;
s8 D_80165908;
UNUSED s32 D_80165910[96];
s8 D_80165A90;
UNUSED s32 D_80165AA0[95];
UNUSED s32 D_80165C14;
Objects gObjectList[OBJECT_LIST_SIZE];
UNUSED s32 D_80183D58;
s32 objectListSize;
Mtx D_80183D60;
/**
 * Use unknown. An object is reserved and its index is saved to
 * this variable, but it appears to go unreferenced
 **/
s32 D_80183DA0;
f32 D_80183DA8[4];
//! Lakitu?
s32 gIndexLakituList[4];
f32 D_80183DC8[4];
//! Indexes for the objects associated with the Bomb Karts
s32 D_80183DD8[NUM_BOMB_KARTS_MAX];
UNUSED s32 D_80183DF8[16];
//! Next free spot in gObjectParticle1? Wraps back around to 0 if it gets bigger than gObjectParticle1_SIZE
s32 gNextFreeObjectParticle1;
Vec3f D_80183E40;
//! Next free spot in gObjectParticle2? Wraps back around to 0 if it gets bigger than gObjectParticle2_SIZE
s32 gNextFreeObjectParticle2;
Vec3f D_80183E50;
//! Next free spot in gObjectParticle3?
s32 gNextFreeObjectParticle3;
UNUSED s32 D_80183E60[3];
//! Next free spot in gObjectParticle4? Wraps back around to 0 if it gets bigger than gObjectParticle4_SIZE
s32 gNextFreeObjectParticle4;
Vec3f D_80183E70;
//! Next free spot in gLeafParticle? Wraps back around to 0 if it gets bigger than gLeafParticle_SIZE
s32 gNextFreeLeafParticle;
Vec3su D_80183E80;
//! Appears to be a list of object list indices for the Item Window part of the HUD
s32 gItemWindowObjectByPlayerId[4];
Vec3su D_80183E98;
/**
 * Snowmen bodies in FrappeSnowland
 * Crabs in Koopa Troopa Beach
 * Hot air balloon in Luigi Raceway?
 * Neon signs in Rainbow Road?
 * Thwomps in Bower's Castle?
 * Penguins in Sherbet Land?
 * Flag Poles in Yoshi Valley?
 */
s32 indexObjectList1[32];
UNUSED s32 D_80183F20[2];
/**
 * Snowmen heads in Frappe Snowland
 * Chain Chomps in RaindbowRoad?
 * Trophy in award ceremony?
 * Seagulls in Koopa Troopa Beach?
 * Hedgehogs in Yoshi Valley?
 * Spawn for big fire breath in Bowser's Castle
 */
s32 indexObjectList2[32];
/**
 * Seemingly a list of textures for Lakitu
 * Never explicitly given data, data appears to be placed here
 * via some type of DMA.
 * I'm also not certain about its dimensions
 * I think the entires in this array are way over-sized
 */
u8 D_80183FA8[4][0x2000];
/**
 * Boos in Banshee Boardwalk
 * Spawners for the 4 small fire breaths inside Bowser's Castle
 */
s32 indexObjectList3[32];
//! Seemingly a pointer to Lakitu texture(s)
u8 *D_8018C028;
/**
 * Unused list of object indices
 */
s32 indexObjectList4[32];
//! Array of (4) Collisions?
Collision D_8018C0B0[4];
/**
 * List of object list indices used for:
 *   Moles in Moo Moo Farm
 *   Snow flakes in Frappe Snowland
 *   Segments of the fire breath from the statues in Bowser's Castle
 *   Potentially other things
 */
s32 gObjectParticle1[gObjectParticle2_SIZE];
Collision D_8018C3B0;
/**
 * List of object list indices used for:
 *   Bats in Banshee's Boardwalk (but only 1 player mode?)
 */
s32 gObjectParticle2[gObjectParticle2_SIZE];
// Maybe some unused Collision?
UNUSED Collision D_8018C5F0;
s32 gObjectParticle3[gObjectParticle3_SIZE];
Collision D_8018C830;
/**
 * List of object list indices. Used both for the fires in the DK Jungle cave
 * and, seemingly for the trail that shells leave behind them.
 * I think they're using the same texture, which would explain the dual use
 */
s32 gObjectParticle4[gObjectParticle4_SIZE];
/**
 * Seemingly a list of object list indices used for the leaves that sometimes fall
 * trees when you bonk into them
 */
s32 gLeafParticle[gLeafParticle_SIZE];
hud_player playerHUD[4];
/**
 * List of object list indices used by the clouds and stars in some stages
 * Also used for snowflakes like gObjectParticle1? Not sure what's up with that
 */
s32 D_8018CC80[D_8018CC80_SIZE];
struct_D_8018CE10 D_8018CE10[8];
//! Unknown object index, only set for Kalimari Desert, never read
s32 D_8018CF10;
Camera *D_8018CF14;
s16 D_8018CF18;
Player *D_8018CF1C;
s16 D_8018CF20;
UNUSED s32 D_8018CF24;
Player *D_8018CF28[4];
UNUSED s32 D_8018CF38[4];
s16 D_8018CF48;
s16 D_8018CF50[8];
s16 D_8018CF60;
//! This may be a list of tilemap flags on a per-camera basis
s16 D_8018CF68[8];
s16 D_8018CF78;
/**
 * List of half-word character IDs indicating each character's
 * place in the current Grand Prix race's standings
 */
s16 gGPCurrentRaceCharacterIdByRank[8];
s16 D_8018CF90;
s16 D_8018CF98[8];
s16 D_8018CFA8;
s8  D_8018CFAC[4];
s16 D_8018CFB0;
s8  D_8018CFB4[4];
s16 D_8018CFB8;
s8  D_8018CFBC[4];
s16 D_8018CFC0;
s8  D_8018CFC4[4];
s16 D_8018CFC8;
f32 D_8018CFCC;
s16 D_8018CFD0;
f32 D_8018CFD4;
s16 D_8018CFD8;

s16 D_800E4730[] = {
    0x00ff, 0x0000, 0x0000,
    0x00ff, 0x00ff, 0x0000,
	0x0000, 0x00ff, 0x0000,
	0x0032, 0x00ff, 0x00ff,
	0x0000, 0x0000, 0x00ff,
	0x00ff, 0x0032, 0x00ff,
	0x00ff, 0x0028, 0x0028,
	0x0032, 0x00ff, 0x0064,
	0x0082, 0x000f, 0x00ff,
	0x0000, 0x0000, 0x0000,
    // I'm not convinced these aren't just padding, but stuff doesn't match
    // without them :/
    0x0000
};

u8 **D_800E4770[] = {
	&D_8018D420, &D_8018D424, &D_8018D428, &D_8018D428,
	&D_8018D42C, &D_8018D42C, &D_8018D430, &D_8018D430,
	&D_8018D434, &D_8018D434, &D_8018D434, &D_8018D434,
};

u8 **D_800E47A0[] = {
	&D_8018D438, &D_8018D43C, &D_8018D440, &D_8018D444,
	&D_8018D448, &D_8018D44C, &D_8018D450, &D_8018D454,
	&D_8018D458, &D_8018D45C, &D_8018D460, &D_8018D464,
	&D_8018D468, &D_8018D46C, &D_8018D470,
};

s32 D_800E47DC[] = {
    MAKE_RGB(0xFB, 0xFF, 0xFB),
    MAKE_RGB(0xA0, 0x60, 0x11),
    MAKE_RGB(0xE0, 0xC0, 0x90),
    MAKE_RGB(0xD0, 0xB0, 0x80),
    MAKE_RGB(0x90, 0x70, 0x40),
    MAKE_RGB(0xC0, 0x70, 0x10),
    MAKE_RGB(0xD0, 0xF0, 0xFF),
    MAKE_RGB(0xE0, 0x90, 0x30),
    MAKE_RGB(0xC0, 0x90, 0x30),
    MAKE_RGB(0x60, 0x40, 0x20),
    MAKE_RGB(0xF0, 0xD0, 0xB0),
    MAKE_RGB(0xA0, 0x80, 0x30),
};

s32 D_800E480C[] = {
    MAKE_RGB(0xB0, 0xB0, 0xB0),
    MAKE_RGB(0x80, 0x40, 0x11),
    MAKE_RGB(0xB0, 0x80, 0x50),
    MAKE_RGB(0xA0, 0x70, 0x40),
    MAKE_RGB(0x60, 0x30, 0x11),
    MAKE_RGB(0x80, 0x40, 0x10),
    MAKE_RGB(0x70, 0x90, 0xA0),
    MAKE_RGB(0xA0, 0x60, 0x30),
    MAKE_RGB(0xA0, 0x70, 0x10),
    MAKE_RGB(0x30, 0x10, 0x11),
    MAKE_RGB(0xB0, 0xA0, 0x80),
    MAKE_RGB(0x80, 0x60, 0x10),
};

// UI Code?
void func_80057C60(void) {
    gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(D_802B8880));
    gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_80183D60), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
}

void func_80057CE4(void) {
    switch (D_8018D21C) {
    case 0:
        func_802A3730(D_800DC5EC);
        break;
    case 1:
        func_802A3730(D_800DC5EC);
        break;
    case 2:
        func_802A3730(D_800DC5F0);
        break;
    case 3:
        func_802A3730(D_800DC5EC);
        break;
    case 4:
        func_802A3730(D_800DC5F0);
        break;
    case 8:
        func_802A3730(D_800DC5EC);
        break;
    case 9:
        func_802A3730(D_800DC5F0);
        break;
    case 10:
        func_802A3730(D_800DC5F4);
        break;
    case 11:
        func_802A3730(D_800DC5F8);
        break;
    }
}

void func_80057DD0(void) {
    if (D_801657B2 != 0) {
        func_8004C024(0xF, 0xB, 0x122, 0, 0xFF, 0, 0xFF);
        func_8004C148(0x131, 0xB, 0xDA, 0, 0xFF, 0, 0xFF);
        func_8004C024(0xF, 0xE5, 0x122, 0, 0xFF, 0, 0xFF);
        func_8004C148(0xF, 0xB, 0xDA, 0, 0xFF, 0, 0xFF);
        func_8004C024(0x16, 0x10, 0x114, 0xFF, 0, 0, 0xFF);
        func_8004C148(0x12A, 0x10, 0xD0, 0xFF, 0, 0, 0xFF);
        func_8004C024(0x16, 0xE0, 0x114, 0xFF, 0, 0, 0xFF);
        func_8004C148(0x16, 0x10, 0xD0, 0xFF, 0, 0, 0xFF);
        func_8004C024(0x18, 0x15, 0x110, 0, 0, 0xFF, 0xFF);
        func_8004C148(0x128, 0x15, 0xC4, 0, 0, 0xFF, 0xFF);
        func_8004C024(0x18, 0xDB, 0x110, 0, 0, 0xFF, 0xFF);
        func_8004C148(0x18, 0x15, 0xC4, 0, 0, 0xFF, 0xFF);
    }
}

void func_80057FC4(u32 arg0) {
    UNUSED Gfx *temp_v1;


    if ((D_801657B0 != 0)) {
        return;
    }
    gSPDisplayList(gDisplayListHead++, &D_0D0076F8);
    func_80041EF4();

    if ((D_801657C8 != 0)){
        return;
    }

    switch (arg0) {
        case 0:
            func_80051EBC();
            break;
        case 1:
            func_80051EF8();
            break;
        case 2:
            func_80051F9C();
            break;
        case 3:
            func_80052044();
            break;
        case 4:
            func_80052080();
            break;
    }

}

void func_80058090(u32 arg0) {
    UNUSED Gfx *temp_v1;

    if (D_801657B0 != 0) {
        return;
    }

    gSPDisplayList(gDisplayListHead++, &D_0D0076F8);

    if (D_8018D22C != 0) {
        return;
    }


    switch (arg0) {
        case 0:
            func_800581C8();
            break;
        case 1:
            func_800581C8();
            break;
        case 2:
            func_800582CC();
            break;
        case 3:
            func_800581C8();
            break;
        case 4:
            func_800582CC();
            break;
        case 5:
            func_800581C8();
            break;
        case 6:
            func_800582CC();
            break;
        case 7:
            func_80058394();
            break;
        case 8:
            func_800581C8();
            break;
        case 9:
            func_800582CC();
            break;
        case 10:
            func_80058394();
            break;
        case 11:
            func_8005845C();
            break;
    }
}

void func_800581C8(void) {

    gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[0]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[0]), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);

    func_8001C3C4(0);
    if (gGamestate == ENDING) {
        func_80055F48(0);
        func_80056160(0);
        func_8005217C(0);
        func_80054BE8(0);
        return;
    }
    if (!gDemoMode) {
        func_800532A4(0);
    }
    func_800588F4(0);
}

void func_800582CC(void) {

    gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[1]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[1]), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
    func_8001C3C4(1);
    if (!gDemoMode) {
        func_800532A4(1);
    }
    func_800588F4(1);
}

void func_80058394(void) {
    gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[2]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[2]), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
    func_8001C3C4(2);
    if (!gDemoMode) {
        func_800532A4(2);
    }
    func_800588F4(2);
}

void func_8005845C(void) {

    gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[3]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[3]), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
    func_8001C3C4(3);
    if ((!gDemoMode) && (gPlayerCountSelection1 == 4)) {
        func_800532A4(3);
    }
    func_800588F4(3);
}

void func_80058538(u32 arg0) {
    UNUSED Gfx *temp_v1;

    if (D_801657B0 != 0) {
        return;
    }

    gSPDisplayList(gDisplayListHead++, &D_0D0076F8);

    if (D_8018D22C != 0) {
        return;
    }
    switch (arg0) {
        case 0:
            func_80058640();
            break;
        case 1:
            func_80058640();
            break;
        case 2:
            func_800586FC();
            break;
        case 3:
            func_80058640();
            break;
        case 4:
            func_800586FC();
            break;
        case 8:
            func_80058640();
            break;
        case 9:
            func_800586FC();
            break;
        case 10:
            func_800587A4();
            break;
        case 11:
            func_8005884C();
            break;
    }
}

void func_80058640(void) {
    gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[0]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[0]), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
    if (gGamestate != ENDING) {
        func_80058B58(0);
    }
}

void func_800586FC(void) {
    gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[1]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[1]), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
    func_80058B58(1);
}

void func_800587A4(void) {
    gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[2]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[2]), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
    func_80058B58(2);
}

void func_8005884C(void) {
    gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[3]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxLookAt[3]), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION);
    func_80058B58(3);
}

void func_800588F4(s32 cameraId) {

    switch (gCurrentCourseId) {
        case COURSE_MARIO_RACEWAY:
            break;
        case COURSE_CHOCO_MOUNTAIN:
            break;
        case COURSE_BOWSER_CASTLE:
            func_80053870(cameraId);
            func_80054664(cameraId);
            break;
        case COURSE_BANSHEE_BOARDWALK:
            if (gGamestate != CREDITS_SEQUENCE) {
                func_800527D8(cameraId);
                func_80052590(cameraId);
                func_8005217C(cameraId);
                func_800524B4(cameraId);
            }
            break;
        case COURSE_YOSHI_VALLEY:
            func_80055228(cameraId);
            if (gGamestate != CREDITS_SEQUENCE) {
                func_8005568C(cameraId);
            }
            break;
        case COURSE_FRAPPE_SNOWLAND:
            if (gGamestate != CREDITS_SEQUENCE) {
                func_8005327C(cameraId);
            }
            break;
        case COURSE_KOOPA_BEACH:
            if (gGamestate != CREDITS_SEQUENCE) {
                func_80055528(cameraId);
            }
            if (gGamestate != CREDITS_SEQUENCE) {

                if ((gPlayerCount == 1) || (gPlayerCount == 2)) {
                    func_80055380(cameraId);
                }
            } else {
                func_80055380(cameraId);
            }
            break;
        case COURSE_ROYAL_RACEWAY:
            break;
        case COURSE_LUIGI_RACEWAY:
            if (D_80165898 != 0) {
                func_80055E68(cameraId);
            }
            break;
        case COURSE_MOO_MOO_FARM:
            if (gGamestate != CREDITS_SEQUENCE) {
                func_800550A4(cameraId);
            }
            break;
        case COURSE_TOADS_TURNPIKE:
            break;
        case COURSE_KALAMARI_DESERT:
            func_800541BC(cameraId);
            break;
        case COURSE_SHERBET_LAND:
            if (gGamestate != CREDITS_SEQUENCE) {
                func_80052E30(cameraId);
            }
            func_8005592C(cameraId);
            break;
        case COURSE_RAINBOW_ROAD:
            if (gGamestate != CREDITS_SEQUENCE) {
                func_80056188(cameraId);
                func_80055C38(cameraId);
            }
            break;
        case COURSE_WARIO_STADIUM:
            break;
        case COURSE_BLOCK_FORT:
            break;
        case COURSE_SKYSCRAPER:
            break;
        case COURSE_DOUBLE_DECK:
            break;
        case COURSE_DK_JUNGLE:
            if (gGamestate != CREDITS_SEQUENCE) {
                func_80054414(cameraId);
            }
            break;
    }

    func_80054938(cameraId);
    func_80051638(cameraId);

    if (D_80165730 != 0) {
        func_80053E6C(cameraId);
    }
    if (gModeSelection == BATTLE) {
        func_80056AC0(cameraId);
    }
}

void func_80058B58(s32 arg0) {
    switch(gCurrentCourseId) {
        case COURSE_FRAPPE_SNOWLAND:
            if (gGamestate != 9) {
                if ((D_8015F894 == 0) && (gPlayerCountSelection1 == 1)) {
                    func_800517C8();
                }
            } else {
                func_800517C8();
            }
            break;
        case COURSE_SHERBET_LAND:
            func_80052C60(arg0);
            break;
    }
}

void func_80058BF4(void) {
    gSPDisplayList(gDisplayListHead++, &D_0D0076F8);
}

void func_80058C20(u32 arg0) {

    D_8018D21C = arg0;
    gSPDisplayList(gDisplayListHead++, &D_0D0076F8);

    if (D_8018D22C == 0) {
        switch (arg0) {
            case 0:
                func_80058F48();
                break;
            case 1:
                if (!gDemoMode) {
                    func_80059358();
                    break;
                }

                break;
            case 2:
                if (!gDemoMode) {
                    func_800593F0();
                    break;
                }

                break;
            case 3:
                if (!gDemoMode) {
                    func_800594F0();
                    break;
                }

                break;
            case 4:
                if (!gDemoMode) {
                    func_80059528();
                    break;
                }

                break;
            case 8:
                if (!gDemoMode) {
                    func_800596A8();
                    break;
                }

                break;
            case 9:
                if (!gDemoMode) {
                    func_80059710();
                    break;
                }

                break;
            case 10:
                if (!gDemoMode) {
                    func_80059750();
                    break;
                }

                break;
            case 11:
                if ((!gDemoMode) && (gPlayerCountSelection1 == 4)) {
                    func_800597B8();
                }
                break;
        }
    }
}

void func_80058DB4(u32 arg0) {

    D_8018D21C = arg0;
    gSPDisplayList(gDisplayListHead++, &D_0D0076F8);
    if (D_8018D22C == 0) {
        switch (arg0) {
        case 0:
            func_80058F78();
            break;
        case 1:
            if (!gDemoMode) {
                func_80059360();
                break;
            }

            break;
        case 2:
            if (!gDemoMode) {
                func_800593F8();
                break;
            }

            break;
        case 3:
            if (!gDemoMode) {
                func_800594F8();
                break;
            }

            break;
        case 4:
            if (!gDemoMode) {
                func_80059530();
                break;
            }

            break;
        case 8:
            if (!gDemoMode) {
                func_800596D8();
                break;
            }

            break;
        case 9:
            if (!gDemoMode) {
                func_80059718();
                break;
            }

            break;
        case 10:
            if (!gDemoMode) {
                func_80059780();
                break;
            }

            break;
        case 11:
            if ((!gDemoMode) && (gPlayerCountSelection1 == 4)) {
                func_800597E8();
            }
            break;
        }
    }
}

void func_80058F48(void) {
    if (D_801657B0 == 0) {
        func_80041EF4();
    }
}

void func_80058F78(void) {
    if (D_801657B0 == 0) {
        func_80041EF4();
        if ((!gDemoMode) && (gIsHUDVisible != 0) && (D_801657D8 == 0)) {
            func_8004E638(0);
            if (D_801657E4 != 2) {
                func_8004FA78(0);
                func_8004E78C(0);
                func_8004EB38(0);
                if (D_801657E6 != FALSE) {
                    func_8004ED40(0);
                }
            }
        }
    }
}

void func_80059024(void) {

}

void func_8005902C(void) {

    if (D_8018D2AC != 0) {
        switch(gPlayerCountSelection1) {
            case 2:
                func_8004EB30(PLAYER_ONE);
                func_8004EB30(PLAYER_TWO);
                break;
            case 3:
                func_8004EB30(PLAYER_ONE);
                func_8004EB30(PLAYER_TWO);
                func_8004EB30(PLAYER_THREE);
                break;
            case 4:
                func_8004EB30(PLAYER_ONE);
                func_8004EB30(PLAYER_TWO);
                func_8004EB30(PLAYER_THREE);
                func_8004EB30(PLAYER_FOUR);
                break;
        }
    }
}

void func_800590D4(void) {
    if (D_8018D2A4 != 0) {
        if (gModeSelection != BATTLE) {
            switch (gPlayerCountSelection1) {
                case 1:
                    if (gModeSelection != TIME_TRIALS) {
                        func_8004E800(PLAYER_ONE);
                        break;
                    }
                    break;
                case 2:
                    func_8004E800(PLAYER_ONE);
                    func_8004E800(PLAYER_TWO);
                    break;
                case 3:
                    func_8004E998(PLAYER_ONE);
                    func_8004E998(PLAYER_TWO);
                    func_8004E998(PLAYER_THREE);
                    break;
                case 4:
                    func_8004E998(PLAYER_ONE);
                    func_8004E998(PLAYER_TWO);
                    func_8004E998(PLAYER_THREE);
                    func_8004E998(PLAYER_FOUR);
                    break;
            }
        }
    }
}

void func_800591B4(void) {

    if ((D_801657B0 == 0) && (D_800DC5B8 != 0)) {
        func_80057C60();
        gSPDisplayList(gDisplayListHead++, &D_0D0076F8);

        if (gIsHUDVisible != 0) {
            if (D_801657D8 == 0) {
                if (D_801657F0 != FALSE) {
                    func_800514BC();
                }
                if ((!gDemoMode) && (D_801657E8 != FALSE)) {
                    if (D_80165800[0] != 0) {
                        func_8004EE54(0);
                        if (gModeSelection != BATTLE) {
                            func_8004F020(0);
                        }
                        func_8004F3E4(0);
                    }
                    if ((gScreenModeSelection == SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL) && (D_80165800[1] != 0)) {
                        func_8004EE54(1);
                        if (gModeSelection != BATTLE) {
                            func_8004F020(1);
                        }
                        func_8004F3E4(1);
                    }
                }
            }
            if ((D_801657E4 != 2) && (gModeSelection == GRAND_PRIX) && (D_8018D2BC != 0)) {
                func_80050320();
            }
            func_800590D4();
        }
        func_8005902C();
        func_80057DD0();
        func_80057CE4();
    }
}

void func_80059358(void) {

}

void func_80059360(void) {
    if (D_801657B0 == 0) {
        func_8004FA78(0);
        if (playerHUD[PLAYER_ONE].lapCount != 3) {
            func_8004CB60(playerHUD[PLAYER_ONE].lapX, playerHUD[PLAYER_ONE].lapY, (u8*) common_texture_hud_lap);
            func_8004FC78(playerHUD[PLAYER_ONE].lapX + 0xC, playerHUD[PLAYER_ONE].lapY - 4, playerHUD[PLAYER_ONE].alsoLapCount);
            func_8004E638(0);
        }
    }
}

void func_800593F0(void) {

}

void func_800593F8(void) {
    if (D_801657B0 == 0) {
        func_8004FA78(1);
        if (playerHUD[PLAYER_TWO].lapCount != 3) {
            func_8004CB60(playerHUD[PLAYER_TWO].lapX, playerHUD[PLAYER_TWO].lapY, (u8*) common_texture_hud_lap);
            func_8004FC78(playerHUD[PLAYER_TWO].lapX + 0xC, playerHUD[PLAYER_TWO].lapY - 4, playerHUD[PLAYER_TWO].alsoLapCount);
            func_8004E638(1);
        }
    }
}

void func_80059488(s32 arg0) {
    if ((gModeSelection != BATTLE) && (D_80165800[arg0] == 0) && (gIsHUDVisible != 0)) {
        func_8004FA78(arg0);
        func_8004E78C(arg0);
    }
    func_8004E638(arg0);
}

void func_800594F0(void) {

}

void func_800594F8(void) {
    if (D_801657B0 == 0) {
        func_80059488(0);
    }
}

void func_80059528(void) {

}

void func_80059530(void) {
    if (D_801657B0 == 0) {
        func_80059488(1);
    }
}

void func_80059560(s32 playerId) {
    if (gModeSelection != BATTLE) {
        if (D_801657F8 && gIsHUDVisible) {
            func_8004CB60(playerHUD[playerId].lapX, playerHUD[playerId].lapY, (u8*) common_texture_hud_lap);
            func_8004FC78(playerHUD[playerId].lapX - 12, playerHUD[playerId].lapY + 4, playerHUD[playerId].alsoLapCount);
        }
        if (D_801657E4 == 2) {
            if (playerHUD[playerId].unk_74 && D_80165608) {
                func_80047910(playerHUD[playerId].unk_6C, playerHUD[playerId].unk_6E, 0, 1.0f, (u8*) common_tlut_portrait_bomb_kart_and_question_mark, common_texture_portrait_bomb_kart, D_0D005AE0, 0x20, 0x20, 0x20, 0x20);
            }
        }
    }
    func_8004E6C4(playerId);
}

void func_800596A8(void) {
    if (D_801657B0 == 0) {
        func_80041EF4();
    }
}

void func_800596D8(void) {
    if (D_801657B0 == 0) {
        func_80041EF4();
        func_80059560(0);
    }
}

void func_80059710(void) {

}

void func_80059718(void) {
    if (D_801657B0 == 0) {
        func_80041EF4();
        func_80059560(1);
    }
}

void func_80059750(void) {
    if (D_801657B0 == 0) {
        func_80041EF4();
    }
}

void func_80059780(void) {
    if (D_801657B0 == 0) {
        func_80041EF4();
        func_80059560(2);
    }
}

void func_800597B8(void) {
    if (D_801657B0 == 0) {
        func_80041EF4();
    }
}

void func_800597E8(void) {
    if (D_801657B0 == 0) {
        func_80041EF4();
        func_80059560(3);
    }
}

void func_80059820(s32 playerId) {
    hud_player *temp_v0;

    D_8018CF1C = &gPlayerOne[playerId];
    D_8018CF14 = &camera1[playerId];
    temp_v0 = &playerHUD[playerId];
    temp_v0->posXInt = (s32) D_8018CF1C->pos[0];
    temp_v0->posYInt = (s32) D_8018CF1C->pos[1];
    temp_v0->posZInt = (s32) D_8018CF1C->pos[2];
}

void randomize_seed_from_controller(s32 arg0) {
    struct Controller *controller = &gControllerOne[arg0];

    if ((controller->button & A_BUTTON) != 0) {
        gControllerRandom++;
    }
    if ((controller->button & B_BUTTON) != 0) {
        gControllerRandom++;
    }
    if ((controller->button & R_TRIG) != 0) {
        gControllerRandom++;
    }
}

void func_8005994C(void) {
    D_8018D214 = TRUE;
}

void func_8005995C(void) {
    s32 i;
    Player *player = gPlayerOne;
    for (i = 0; i < 4; i++) {
        if ((D_80165890 != 0) && (player->type & PLAYER_INVISIBLE_OR_BOMB)) {
            player->currentItemCopy = ITEM_MUSHROOM;
            
            playerHUD[i].unk_75 = 2;
        }
        if ((player->type & PLAYER_INVISIBLE_OR_BOMB) && (player->currentItemCopy == ITEM_NONE)) {
            if (playerHUD[i].unk_75) {
                player->currentItemCopy = ITEM_MUSHROOM;
                --playerHUD[i].unk_75;
            }
        }
        ++player;
    }
    D_80165890 = 0;
}

void func_80059A88(s32 playerId) {
    func_80059820(playerId);
    if (!gDemoMode) {
        update_obj_laikitu(playerId);
        func_8007BB9C(playerId);
    }
}

void func_80059AC8(void) {
    s32 i;

    if (gIsGamePaused == FALSE) {
        func_8008C1D8(&D_80165678);
        gRaceFrameCounter++;
        for (i = 0; i < NUM_PLAYERS; i++) {
            D_8018CF68[i] = func_8008A890(&camera1[i]);
            func_800892E0(i);
        }
        switch (gScreenModeSelection) {
        case SCREEN_MODE_1P:
            if (gGamestate != 9) {
                func_80059A88(PLAYER_ONE);
                if (gModeSelection == TIME_TRIALS) {
                    func_8005995C();
                }
            } else {
                func_80059820(PLAYER_ONE);
            }
            break;
        case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL:
            func_80059A88(PLAYER_ONE);
            func_80059A88(PLAYER_TWO);
            break;
        case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL:
            func_80059A88(PLAYER_ONE);
            func_80059A88(PLAYER_TWO);
            break;
        case SCREEN_MODE_3P_4P_SPLITSCREEN:
            func_80059A88(PLAYER_ONE);
            func_80059A88(PLAYER_TWO);
            func_80059A88(PLAYER_THREE);
            func_80059A88(PLAYER_FOUR);
            break;
        }
        func_8005A71C();
    }
}

void func_80059C50(void) {
    s32 someIndex;
    s32 playerId;

    func_8005A3C0();
    for (someIndex = 0; someIndex < NUM_PLAYERS; someIndex++) {
        playerId = gGPCurrentRacePlayerIdByRank[someIndex];
        // I hate this dumb pointer access here
        gGPCurrentRaceCharacterIdByRank[someIndex] = (gPlayerOne + playerId)->characterId;
    }
    for (someIndex = 0; someIndex < NUM_PLAYERS; someIndex++) {
        D_8018CF98[someIndex] = gGPCurrentRaceRankByPlayerId[someIndex];
    }
}

void func_80059D00(void) {
    
    func_8005A99C();
    func_8005A3C0();
    func_8005A380();

    if (D_801657AE == 0) {
        switch (gScreenModeSelection) {  
        case SCREEN_MODE_1P:
            randomize_seed_from_controller(PLAYER_ONE);
            if (D_8018D214 == FALSE) {
                func_80059820(PLAYER_ONE);
                func_8005B914();
                if (!gDemoMode) {
                    func_8007AA44(0);
                }
                func_80078C70(0);
                if (playerHUD[PLAYER_ONE].raceCompleteBool == 0) {
                    func_8005C360((gPlayerOneCopy->unk_094 / 18.0f) * 216.0f);
                }
                func_8005D0FC(PLAYER_ONE);
            } else {
                func_80059820(PLAYER_ONE);
                func_80078C70(1);
                func_80059820(PLAYER_TWO);
                func_80078C70(2);
            }
            update_obj();
            break;
        case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL:
            randomize_seed_from_controller(PLAYER_ONE);
            randomize_seed_from_controller(PLAYER_TWO);
            func_80059820(PLAYER_ONE);
            func_8005D0FC(PLAYER_ONE);
            if (!gDemoMode) {
                func_8007AA44(0);
            }
            func_80078C70(1);
            func_8005D1F4(0);
            func_80059820(PLAYER_TWO);
            func_8005D0FC(PLAYER_TWO);
            if (!gDemoMode) {
                func_8007AA44(1);
            }
            func_80078C70(2);
            func_8005D1F4(1);
            update_obj();
            break;
        case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL:
            randomize_seed_from_controller(PLAYER_ONE);
            randomize_seed_from_controller(PLAYER_TWO);
            func_80059820(PLAYER_ONE);
            func_8005D0FC(PLAYER_ONE);
            if (!gDemoMode) {
                func_8007AA44(0);
            }
            func_80078C70(3);
            func_8005D1F4(0);
            func_80059820(PLAYER_TWO);
            func_8005D0FC(PLAYER_TWO);
            if (!gDemoMode) {
                func_8007AA44(1);
            }
            func_80078C70(4);
            func_8005D1F4(1);
            update_obj();
            break;
        case SCREEN_MODE_3P_4P_SPLITSCREEN:
            randomize_seed_from_controller(PLAYER_ONE);
            randomize_seed_from_controller(PLAYER_TWO);
            randomize_seed_from_controller(PLAYER_THREE);
            randomize_seed_from_controller(PLAYER_FOUR);
            func_80059820(PLAYER_ONE);
            func_8005D0FC(PLAYER_ONE);
            if (!gDemoMode) {
                func_8007AA44(0);
            }
            func_8005D1F4(0);
            func_80059820(PLAYER_TWO);
            func_8005D0FC(PLAYER_TWO);
            if (!gDemoMode) {
                func_8007AA44(1);
            }
            func_8005D1F4(1);
            func_80059820(PLAYER_THREE);
            func_8005D0FC(PLAYER_THREE);
            if (!gDemoMode) {
                func_8007AA44(2);
            }
            func_8005D1F4(2);
            if (gPlayerCountSelection1 == 4) {
                func_80059820(PLAYER_FOUR);
                func_8005D0FC(PLAYER_FOUR);
                if ((!gDemoMode) && (gPlayerCountSelection1 == 4)) {
                    func_8007AA44(3);
                }
                func_8005D1F4(3);
            }
            update_obj();
            break;
        }
        func_800744CC();
    }
}

void func_8005A070(void) {
    func_8008C1D8(&D_80165678);
    gMatrixHudCount = 0;
    D_801655C0 = 0;
    func_80041D34();
    if (gIsGamePaused == FALSE) {
        func_8005C728();
        if (gGamestate == ENDING) {
            func_80086604();
            func_80086D80();
            func_8007C2F8(1);
            func_80077640();
        } else if (gGamestate == CREDITS_SEQUENCE) {
            func_80059820(PLAYER_ONE);
            func_80078C70(0);
            update_obj();
        } else {
            func_80059D00();
        }
    }
    func_8008C204();
    func_8008C1E0(&D_80165678, (s32)&D_801655F0);
}

void func_8005A14C(s32 playerId) {
    s32 objectIndex;
    s32 lapCount;
    Player *player;
    UNUSED s32 stackPadding;

    player = &gPlayerOne[playerId];
    objectIndex = D_8018CE10[playerId].objectIndex;
    lapCount = gLapCountByPlayerId[playerId];
    if (player->type & PLAYER_EXISTS) {
        if (player->effects & 0x204C0) {
            gObjectList[objectIndex].direction_angle[2] += 0x1000;
        } else {
            if (gObjectList[objectIndex].direction_angle[2] != 0) {
                gObjectList[objectIndex].direction_angle[2] += 0x1000;
            }
        }
        if (player->effects & LIGHTNING_EFFECT) {
            f32_step_towards(&gObjectList[objectIndex].sizeScaling, 0.3f, 0.02f);
        } else {
            f32_step_towards(&gObjectList[objectIndex].sizeScaling, 0.6f, 0.02f);
        }
        if (player->effects & 0x04000000) {
            u16_step_up_towards(&gObjectList[objectIndex].direction_angle[0], 0x0C00U, 0x0100U);
        } else {
            u16_step_down_towards(&gObjectList[objectIndex].direction_angle[0], 0, 0x00000100);
        }
        if (player->effects & 0x03000000) {
            func_80087D24(objectIndex, 6.0f, 1.5f, 0.0f);
        } else {
            f32_step_towards(&gObjectList[objectIndex].unk_028[1], 0.0f, 1.0f);
        }
        if ((player->type & PLAYER_INVISIBLE_OR_BOMB) || (player->effects & BOO_EFFECT)) {
            gObjectList[objectIndex].unk_0A0 = 0x0050;
        } else {
            gObjectList[objectIndex].unk_0A0 = 0x00FF;
        }
        if (lapCount >= 3) {
            gObjectList[objectIndex].direction_angle[2] = 0;
            gObjectList[objectIndex].direction_angle[1] = 0;
            gObjectList[objectIndex].direction_angle[0] = 0;
            gObjectList[objectIndex].unk_028[2] = 0.0f;
            gObjectList[objectIndex].unk_028[1] = 0.0f;
            gObjectList[objectIndex].unk_028[0] = 0.0f;
            gObjectList[objectIndex].sizeScaling = 0.6f;
            gObjectList[objectIndex].unk_0A0 = 0x00FF;
        }
    }
}

void func_8005A380(void) {
    s32 temp_s0;
    for (temp_s0 = 0; temp_s0 < NUM_PLAYERS; ++temp_s0) {
        func_8005A14C(temp_s0);
    }
}

void func_8005A3C0(void) {
    bool b = FALSE;
    if ((gGamestate != ENDING) && (gGamestate != CREDITS_SEQUENCE) && !D_8018D204) {
        switch (gPlayerCountSelection1) {
        case 1:
            if (gControllerOne->buttonPressed & R_CBUTTONS) {
                if (++D_801657E4 >= 3) {
                    D_801657E4 = 0;
                }
                if (D_801657E4 == 2) {
                    D_801657E8 = FALSE;
                    D_801657E6 = FALSE;
                    D_801657F0 = TRUE;
                } else if (D_801657E4 == 1) {
                    D_801657E8 = FALSE;
                    D_801657E6 = TRUE;
                    D_801657F0 = FALSE;
                } else {
                    D_801657E8 = TRUE;
                    D_801657E6 = FALSE;
                    D_801657F0 = FALSE;
                }
                b = TRUE;
            }
            break;
        case 2:
            if (gModeSelection != BATTLE) {
                if (gControllerOne->buttonPressed & R_CBUTTONS) {
                    D_80165800[0] = (D_80165800[0] + 1) & 1;
                    b = TRUE;
                }
                if (gControllerTwo->buttonPressed & R_CBUTTONS) {
                    D_80165800[1] = (D_80165800[1] + 1) & 1;
                    b = TRUE;
                }
                if (D_80165800[0] && D_80165800[1]) {
                    D_801657F0 = FALSE;
                } else {
                    D_801657F0 = TRUE;
                }
                if (gDemoMode) {
                    D_801657F0 = FALSE;
                }
            }
            break;
        case 3:
            if ((gControllerOne->buttonPressed & R_CBUTTONS)
                || (gControllerTwo->buttonPressed & R_CBUTTONS)
                || (gControllerThree->buttonPressed & R_CBUTTONS)) {
                if (gModeSelection != BATTLE) {
                    D_801657F0 = (D_801657F0 + 1) & 1;
                }
                D_801657E4 = (D_801657E4 + 1) & 1;
                b = TRUE;
            }
            break;
        case 4:
            if ((gControllerOne->buttonPressed & R_CBUTTONS)
                || (gControllerTwo->buttonPressed & R_CBUTTONS)
                || (gControllerThree->buttonPressed & R_CBUTTONS)
                || (gControllerFour->buttonPressed & R_CBUTTONS)) {
                D_801657E4 = (D_801657E4 + 1) & 1;
                D_801657F8 = (D_801657F8 + 1) & 1;
                D_80165800[0] = (D_80165800[0] + 1) & 1;
                if (gModeSelection != BATTLE) {
                    D_801657F0 = (D_801657F0 + 1) & 1;
                }
                b = TRUE;
            }
            break;
        }
        if (b) {
            func_8006F824(1);
        }
    }
}

void func_8005A71C(void) {
    if (gCurrentCourseId == COURSE_BOWSER_CASTLE) {
        func_80081210();
    }
}

void update_obj(void) {
    switch (gCurrentCourseId) {
    case COURSE_MARIO_RACEWAY:
    case COURSE_CHOCO_MOUNTAIN:
        break;
    case COURSE_BOWSER_CASTLE:
        func_80081208();
        update_particle_bowser_castle();
        break;
    case COURSE_BANSHEE_BOARDWALK:
        if (gGamestate != CREDITS_SEQUENCE) {
            func_8007E1AC();
            func_8007E4C4();
            if (gModeSelection != TIME_TRIALS) {
                func_8007DB44();
            }
            func_8007C340();
            func_8007C2F8(0);
        }
        break;
    case COURSE_YOSHI_VALLEY:
        func_80083080();
        if (gGamestate != CREDITS_SEQUENCE) {
            func_800834B8();
        }
        break;
    case COURSE_FRAPPE_SNOWLAND:
        if (gGamestate != CREDITS_SEQUENCE) {
            func_80083D60();
        }
        func_80078838();
        break;
    case COURSE_KOOPA_BEACH:
        if (gGamestate != CREDITS_SEQUENCE) {
            func_80082E5C();
        }
        if ((gPlayerCount == 1) || (gPlayerCount == 2) || (gGamestate == CREDITS_SEQUENCE)) {
            func_80082870();
        }
        break;
    case COURSE_LUIGI_RACEWAY:
        if (D_80165898 != 0) {
            func_800857C0();
        }
        break;
    case COURSE_MOO_MOO_FARM:
        if (gGamestate != CREDITS_SEQUENCE) {
            func_800821FC();
        }
        break;
    case COURSE_KALAMARI_DESERT:
        func_80075838();
        break;
    case COURSE_SHERBET_LAND:
        if (gGamestate != CREDITS_SEQUENCE) {
            func_800842C8();
        }
        func_80085214();
        break;
    case COURSE_RAINBOW_ROAD:
        if (gGamestate != CREDITS_SEQUENCE) {
            update_neon();
            func_80085AA8();
        }
        break;
    case COURSE_DK_JUNGLE:
        func_80075CA8();
        break;
    }
    if (D_80165730 != 0) {
        func_80074EE8();
    }
    func_80076F2C();
    if ((s16) gCurrentCourseId != COURSE_FRAPPE_SNOWLAND) {
        func_80077C9C();
    }
}

void func_8005A99C(void) {
    if (D_8018D170 == 0) {
        if (D_8018D178 == 0) {
            if (gPlayerCountSelection1 == 1) {
                func_8005AA34();
            }
            if (gPlayerCountSelection1 == 3) {
                D_801657E8 = TRUE;
            }
            gIsHUDVisible = (s32) 1;
            D_8018D170 = (s32) 1;
            D_8018D190 = (s32) 1;
            D_8018D204 = 0;
            return;
        }
        --D_8018D178;
    }
}

void func_8005AA34(void) {
    D_8018D1CC = 1;
    D_8018D1A0 = 0;
}

void func_8005AA4C(void) {
    ++D_8018D1CC;
    D_8018D1A0 = 0;
}

void func_8005AA6C(s32 arg0) {
    D_8018D1CC = arg0;
    D_8018D1A0 = 0;
}

void func_8005AA80(void) {
    D_8018D1CC = 0;
    D_8018D1A0 = 0;
}

void func_8005AA94(s32 arg0) {
    if (D_8018D1A0 == 0) {
        D_8018D1D4 = arg0;
        D_8018D1A0 = 1;
    }

    --D_8018D1D4;
    if (D_8018D1D4 < 0) {
        D_8018D1A0 = 0;
        func_8005AA4C();
    }
}

void func_8005AAF0(void) {
    D_8018D1B4 = 1;
    D_8018D1A0 = 0;
    func_8005AA4C();
}

void func_8005AB20(void) {
    if ((gModeSelection == GRAND_PRIX) && (gPlayerCountSelection1 == 1)) {
        func_8005AA6C(0x14);
    }
}

void func_8005AB60(void) {
    switch (playerHUD[PLAYER_ONE].unk_78) {
        case 0:
            break;
        case 1:
            s16_step_towards(&playerHUD[PLAYER_ONE].speedometerX, 0x106, 0x10);
            if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 0xB6, 0x10) != 0) {
                playerHUD[PLAYER_ONE].unk_78++;
                playerHUD[PLAYER_ONE].unk_79 = 1;
            }
            break;
        case 2:
            s16_step_towards(&playerHUD[PLAYER_ONE].speedometerX, 0x116, 4);
            if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 0xC6, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_78++;
            }
            break;
        case 3:
            s16_step_towards(&playerHUD[PLAYER_ONE].speedometerX, 0x106, 4);
            if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 0xB6, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_78++;
            }
            break;
        case 4:
            s16_step_towards(&playerHUD[PLAYER_ONE].speedometerX, 0x10E, 4);
            if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 0xBE, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_78++;
            }
            break;
        case 5:
            s16_step_towards(&playerHUD[PLAYER_ONE].speedometerX, 0x106, 4);
            if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 0xB6, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_78++;
            }
            break;
        case 6:
            s16_step_towards(&playerHUD[PLAYER_ONE].speedometerX, 0x10A, 2);
            if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 0xBA, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_78++;
            }
            break;
        case 7:
            s16_step_towards(&playerHUD[PLAYER_ONE].speedometerX, 0x106, 2);
            if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 0xB6, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_78++;
            }
            break;
        case 8:
            playerHUD[PLAYER_ONE].unk_78 = 0;
            break;
    }
    if ((playerHUD[PLAYER_ONE].unk_79 != 0) && (playerHUD[PLAYER_ONE].unk_79 == 1)) {
        if (++D_801657E7 >= 0x10) {
            D_801657E7 = 0;
            D_8016579E = 0xDD00;
            playerHUD[PLAYER_ONE].unk_79 = 0U;
        } else {
            D_8016579E = D_800E55B0[D_801657E7] + 0xDD00;
        }
    }
    switch (playerHUD[PLAYER_ONE].unk_80) {
        case 0:
            break;
        case 1:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].slideItemBoxY, 0x40, 8) != 0) {
                playerHUD[PLAYER_ONE].unk_80++;
            }
            break;
        case 2:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].slideItemBoxY, 0x38, 8) != 0) {
                playerHUD[PLAYER_ONE].unk_80++;
            }
            break;
        case 3:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].slideItemBoxY, 0x40, 8) != 0) {
                playerHUD[PLAYER_ONE].unk_80++;
            }
            break;
        case 4:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].slideItemBoxY, 0x38, 8) != 0) {
                playerHUD[PLAYER_ONE].unk_80++;
            }
            break;
        case 5:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].slideItemBoxY, 0x40, 8) != 0) {
                playerHUD[PLAYER_ONE].unk_80++;
            }
            break;
        case 6:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].slideItemBoxY, 0x38, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_80++;
            }
            break;
        case 7:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].slideItemBoxY, 0x40, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_80++;
            }
            break;
        case 8:
            playerHUD[PLAYER_ONE].unk_80 = 0;
            break;
    }
    switch (playerHUD[PLAYER_ONE].unk_7A) {
        case 0:
            break;
        case 1:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].timerX, 0xE4, 0x10) != 0) {
                playerHUD[PLAYER_ONE].unk_7A++;
            }
            break;
        case 2:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].timerX, 0xF4, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7A++;
            }
            break;
        case 3:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].timerX, 0xE4, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7A++;
            }
            break;
        case 4:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].timerX, 0xEC, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7A++;
            }
            break;
        case 5:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].timerX, 0xE4, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7A++;
            }
            break;
        case 6:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].timerX, 0xE8, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7A++;
            }
            break;
        case 7:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].timerX, 0xE4, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7A++;
            }
            break;
        case 8:
            playerHUD[PLAYER_ONE].unk_7A = 0;
            break;
    }
    switch (playerHUD[PLAYER_ONE].unk_7D) {
        case 0:
            break;
        case 1:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapX, 0x53, 0x10) != 0) {
                playerHUD[PLAYER_ONE].unk_7D++;
            }
            break;
        case 2:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapX, 0x43, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7D++;
            }
            break;
        case 3:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapX, 0x53, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7D++;
            }
            break;
        case 4:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapX, 0x4B, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7D++;
            }
            break;
        case 5:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapX, 0x53, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7D++;
            }
            break;
        case 6:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapX, 0x4F, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7D++;
            }
            break;
        case 7:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapX, 0x53, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7D++;
            }
            break;
        case 8:
            playerHUD[PLAYER_ONE].unk_7D = 0;
            break;
    }
    D_8018CFEC = (f32) (playerHUD[PLAYER_ONE].speedometerX + 0x18);
    D_8018CFF4 = (f32) (playerHUD[PLAYER_ONE].speedometerY + 6);
    switch (playerHUD[PLAYER_ONE].unk_7B) {
        case 0:
            break;
        case 1:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap1CompletionTimeX, 0xE4, 0x10) != 0) {
                playerHUD[PLAYER_ONE].unk_7B++;
            }
            break;
        case 2:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap1CompletionTimeX, 0xF4, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7B++;
            }
            break;
        case 3:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap1CompletionTimeX, 0xE4, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7B++;
            }
            break;
        case 4:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap1CompletionTimeX, 0xEC, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7B++;
            }
            break;
        case 5:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap1CompletionTimeX, 0xE4, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7B++;
            }
            break;
        case 6:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap1CompletionTimeX, 0xE8, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7B++;
            }
            break;
        case 7:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap1CompletionTimeX, 0xE4, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7B++;
            }
            break;
        case 8:
            playerHUD[PLAYER_ONE].unk_7B = 0;
            break;
    }
    switch (playerHUD[PLAYER_ONE].unk_7E) {
        case 0:
            break;
        case 1:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage1X, 0x53, 0x10) != 0) {
                playerHUD[PLAYER_ONE].unk_7E++;
            }
            break;
        case 2:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage1X, 0x43, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7E++;
            }
            break;
        case 3:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage1X, 0x53, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7E++;
            }
            break;
        case 4:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage1X, 0x4B, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7E++;
            }
            break;
        case 5:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage1X, 0x53, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7E++;
            }
            break;
        case 6:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage1X, 0x4F, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7E++;
            }
            break;
        case 7:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage1X, 0x53, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7E++;
            }
            break;
        case 8:
            playerHUD[PLAYER_ONE].unk_7E = 0;
            break;
    }
    switch (playerHUD[PLAYER_ONE].unk_7C) {
        case 0:
            break;
        case 1:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap2CompletionTimeX, 0xE4, 0x10) != 0) {
                playerHUD[PLAYER_ONE].unk_7C++;
            }
            break;
        case 2:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap2CompletionTimeX, 0xF4, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7C++;
            }
            break;
        case 3:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap2CompletionTimeX, 0xE4, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7C++;
            }
            break;
        case 4:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap2CompletionTimeX, 0xEC, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7C++;
            }
            break;
        case 5:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap2CompletionTimeX, 0xE4, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7C++;
            }
            break;
        case 6:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap2CompletionTimeX, 0xE8, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7C++;
            }
            break;
        case 7:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lap2CompletionTimeX, 0xE4, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7C++;
            }
            break;
        case 8:
            playerHUD[PLAYER_ONE].unk_7C = 0;
            break;
    }
    switch (playerHUD[PLAYER_ONE].unk_7F) {
        case 0:
            break;
        case 1:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage2X, 0x53, 0x10) != 0) {
                playerHUD[PLAYER_ONE].unk_7F++;
            }
            break;
        case 2:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage2X, 0x43, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7F++;
            }
            break;
        case 3:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage2X, 0x53, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7F++;
            }
            break;
        case 4:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage2X, 0x4B, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7F++;
            }
            break;
        case 5:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage2X, 0x53, 4) != 0) {
                playerHUD[PLAYER_ONE].unk_7F++;
            }
            break;
        case 6:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage2X, 0x4F, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7F++;
            }
            break;
        case 7:
            if (s16_step_towards(&playerHUD[PLAYER_ONE].lapAfterImage2X, 0x53, 2) != 0) {
                playerHUD[PLAYER_ONE].unk_7F++;
            }
            break;
        case 8:
            playerHUD[PLAYER_ONE].unk_7F = 0;
            break;
    }
}

void func_8005B7A0(void) {
    f32 temp_f0;
    f32* temp_s2;
    f32* temp_s3;
    f32* temp_s4;
    UNUSED f32* var_s1;
    s32 var_s0;

    s16_step_towards(&playerHUD[PLAYER_ONE].lap1CompletionTimeX, 0xE4, 0x10);
    s16_step_towards(&playerHUD[PLAYER_ONE].lap2CompletionTimeX, 0xE4, 0x10);
    s16_step_towards(&playerHUD[PLAYER_ONE].lap3CompletionTimeX, 0xE4, 0x10);
    s16_step_towards(&playerHUD[PLAYER_ONE].totalTimeX, 0xE4, 0x10);
    for (var_s0 = 0; var_s0 < NUM_PLAYERS; var_s0++) {
        temp_s2 = &D_8018D028[var_s0];
        temp_s3 = &D_8018D0C8[var_s0];
        temp_s4 = &D_8018D078[var_s0];
        if (D_8018D050[var_s0] >= 0.0f) {
            f32_step_towards(temp_s2, *temp_s3, *temp_s4);
            temp_f0 = *temp_s2;
            if (temp_f0 == *temp_s3) {
                *temp_s4 = 0.0f;
            }
            if ((f64) temp_f0 <= -32.0) {
                D_8018D050[var_s0] = -32.0f;
            }
        }
    }
}

void func_8005B914(void) {
    s32 i;
    UNUSED s32 unk;

    switch (D_8018D1CC) {
    case 0:
        break;
    case 0x1:
        func_8005AAF0();
        break;
    case 0x2:
        if (gModeSelection == TIME_TRIALS) {
            playerHUD[PLAYER_ONE].unk_80 = 1;
        }
        playerHUD[PLAYER_ONE].unk_78 = 1;
        playerHUD[PLAYER_ONE].unk_7A = 1;
        playerHUD[PLAYER_ONE].unk_7D = 1;
        func_8005AA4C();
        break;
    case 0x3:
        func_8005AA94(0);
        break;
    case 0x4:
        playerHUD[PLAYER_ONE].unk_7B = 1;
        playerHUD[PLAYER_ONE].unk_7E = 1;
        func_8005AA4C();
        break;
    case 0x5:
        func_8005AA94(0);
        break;
    case 0x6:
        playerHUD[PLAYER_ONE].unk_7C = 1;
        playerHUD[PLAYER_ONE].unk_7F = 1;
        func_8005AA4C();
        func_8005AA80();
        break;
    case 0x14:
        D_8018D078[0] = 16.0f;
        func_8005AA4C();
        break;
    case 0x15:
        func_8005AA94(4);
        break;
    case 0x16:
        D_8018D078[1] = 16.0f;
        func_8005AA4C();
        break;
    case 0x17:
        func_8005AA94(4);
        break;
    case 0x18:
        D_8018D078[2] = 16.0f;
        func_8005AA4C();
        break;
    case 0x19:
        func_8005AA94(4);
        break;
    case 0x1A:
        D_8018D078[3] = 16.0f;
        func_8005AA4C();
        break;
    case 0x1B:
        func_8005AA94(0xA);
        break;
    case 0x1C:
        func_8005AA80();
        break;
    case 0x64:
        func_8005AA4C();
        break;
    case 0x65:
        func_8005AA94(0x3A);
        break;
    case 0x66:
        D_8018D078[0] = -8.0f;
        D_8018D0C8[0] = -32.0f;
        func_8005AA4C();
        break;
    case 0x67:
        func_8005AA94(4);
        break;
    case 0x68:
        D_8018D078[1] = -8.0f;
        D_8018D0C8[1] = -32.0f;
        func_8005AA4C();
        break;
    case 0x69:
        func_8005AA94(4);
        break;
    case 0x6A:
        D_8018D078[2] = -8.0f;
        D_8018D0C8[2] = -32.0f;
        func_8005AA4C();
        break;
    case 0x6B:
        func_8005AA94(4);
        break;
    case 0x6C:
        D_8018D078[3] = -8.0f;
        D_8018D0C8[3] = -32.0f;
        func_8005AA4C();
        break;
    case 0x6D:
        func_8005AA94(0xA);
        break;
    case 0x6E:
        for (i = 0; i < NUM_PLAYERS; i += 4) {
            D_8018D050[i] = -32.0f;
            D_8018D050[i + 1] = -32.0f;
            D_8018D050[i + 2] = -32.0f;
            D_8018D050[i + 3] = -32.0f;
        }
        D_8018D028[0] = 360.0f;
        D_8018D050[0] = 110.0f;
        D_8018D0C8[0] = 44.0f;
        D_8018D078[0] = -16.0f;
        D_801657E2 = 1;
        func_8005AA4C();
        break;
    case 0x6F:
        func_8005AA94(4);
        break;
    case 0x70:
        D_8018D028[1] = 360.0f;
        D_8018D050[1] = 110.0f;
        D_8018D0C8[1] = 76.0f;
        D_8018D078[1] = -16.0f;
        func_8005AA4C();
        break;
    case 0x71:
        func_8005AA94(4);
        break;
    case 0x72:
        D_8018D028[2] = 360.0f;
        D_8018D050[2] = 110.0f;
        D_8018D0C8[2] = 108.0f;
        D_8018D078[2] = -16.0f;
        func_8005AA4C();
        break;
    case 0x73:
        func_8005AA94(4);
        break;
    case 0x74:
        D_8018D028[3] = 360.0f;
        D_8018D050[3] = 110.0f;
        D_8018D0C8[3] = 140.0f;
        D_8018D078[3] = -16.0f;
        func_8005AA4C();
        break;
    case 0x75:
        func_8005AA94(4);
        break;
    case 0x76:
        D_8018D028[4] = 360.0f;
        D_8018D050[4] = 110.0f;
        D_8018D0C8[4] = 180.0f;
        D_8018D078[4] = -16.0f;
        func_8005AA4C();
        break;
    case 0x77:
        func_8005AA94(4);
        break;
    case 0x78:
        D_8018D028[5] = 360.0f;
        D_8018D050[5] = 110.0f;
        D_8018D0C8[5] = 212.0f;
        D_8018D078[5] = -16.0f;
        func_8005AA4C();
        break;
    case 0x79:
        func_8005AA94(4);
        break;
    case 0x7A:
        D_8018D028[6] = 360.0f;
        D_8018D050[6] = 110.0f;
        D_8018D0C8[6] = 244.0f;
        D_8018D078[6] = -16.0f;
        func_8005AA4C();
        break;
    case 0x7B:
        func_8005AA94(4);
        break;
    case 0x7C:
        D_8018D028[7] = 360.0f;
        D_8018D050[7] = 110.0f;
        D_8018D0C8[7] = 276.0f;
        D_8018D078[7] = -16.0f;
        func_8005AA4C();
        break;
    case 0x7D:
        func_8005AA94(0xA);
        break;
    case 0x7E:
        for (i = 0; i < NUM_PLAYERS; i++) {
            D_8018D078[i] = 0.0f;
        }
        func_8005AA4C();
        break;
    case 0x7F:
        func_8005AA94(0x82);
        break;
    case 0x80:
        if (gGPCurrentRaceRankByPlayerId[0] < 4) {
            func_8005AA6C(0x8C);
        } else {
            func_8005AA6C(0x82);
        }
        break;
    case 0x82:
        func_8005AA80();
        break;
    case 0x8C:
        D_8018D078[0] = -16.0f;
        D_8018D0C8[0] = -32.0f;
        func_8005AA4C();
        break;
    case 0x8D:
        func_8005AA94(4);
        break;
    case 0x8E:
        D_8018D078[1] = -16.0f;
        D_8018D0C8[1] = -32.0f;
        func_8005AA4C();
        break;
    case 0x8F:
        func_8005AA94(4);
        break;
    case 0x90:
        D_8018D078[2] = -16.0f;
        D_8018D0C8[2] = -32.0f;
        func_8005AA4C();
        break;
    case 0x91:
        func_8005AA94(4);
        break;
    case 0x92:
        D_8018D078[3] = -16.0f;
        D_8018D0C8[3] = -32.0f;
        func_8005AA4C();
        break;
    case 0x93:
        func_8005AA94(4);
        break;
    case 0x94:
        D_8018D078[4] = -16.0f;
        D_8018D0C8[4] = -32.0f;
        func_8005AA4C();
        break;
    case 0x95:
        func_8005AA94(4);
        break;
    case 0x96:
        D_8018D078[5] = -16.0f;
        D_8018D0C8[5] = -32.0f;
        func_8005AA4C();
        break;
    case 0x97:
        func_8005AA94(4);
        break;
    case 0x98:
        D_8018D078[6] = -16.0f;
        D_8018D0C8[6] = -32.0f;
        func_8005AA4C();
        break;
    case 0x99:
        func_8005AA94(4);
        break;
    case 0x9A:
        D_8018D078[7] = -16.0f;
        D_8018D0C8[7] = -32.0f;
        func_8005AA4C();
        break;
    case 0x9B:
        func_8005AA94(0x14);
        break;
    case 0x9C:
        func_8005AA80();
        break;
    }
    if (D_8018D1CC < 0x64) {
        func_8005AB60();
    } else if (D_8018D1CC < 0xC8) {
        func_8005B7A0();
    }
    if ((D_8018D1CC != 0) && (D_8018D1CC >= 0x14) && (D_8018D1CC < 0x1E)) {
        for (i = 0; i < 4; i++) {
            f32_step_towards(&D_8018D028[i], D_8018D0C8[i], D_8018D078[i]);
            if (D_8018D028[i] == D_8018D0C8[i]) {
                D_8018D078[i] = 0.0f;
            }
        }
    }
}

void func_8005C360(f32 arg0) {
    if (!playerHUD[PLAYER_ONE].unk_79) {
        u16 v;
        if (arg0 < 10.0) {
            v = (u16) (128.0f * arg0) + 0xDD00;
        } else if (arg0 < 20.0) {
            v = (u16) ((arg0 - 10.0) * 256.0) + 0xE200;
        } else {
            v = (u16) ((arg0 - 20.0) * 268.8) + 0xEC00;
        }
        if (arg0 == D_8018CFE4) {
            if (arg0 > 5.0f) {
                if (++D_801657E7 == 8) {
                    D_801657E7 = 0;
                }
            } else {
                D_801657E7 = 0;
            }
        }
        D_8016579E = v + D_800E55A0[D_801657E7];
        D_8018CFE4 = arg0;
    }
}

void func_8005C64C(UNUSED s32 *arg0) {

}

void func_8005C654(s32 *arg0) {
    *arg0 = 0;
}

void func_8005C65C(s32 arg0) {
    D_8018D2C8[arg0] = 1;
}

void func_8005C674(s8 index, s16 *x, s16 *y, s16 *z) {
    s16 *src = &D_800E4730[index * 3];
    *x = *src++;
    *y = *src++;
    *z = *src++;
}

void func_8005C6B4(s8 arg0, s16* arg1, s16* arg2, s16* arg3) {
    switch (arg0) {
    case 0:
        *arg1 = 0xFF;
        *arg2 = 0x40;
        *arg3 = 0x40;
        break;
    case 1:
        *arg1 = 0xFF;
        *arg2 = 0xFF;
        *arg3 = 0x40;
        break;
    case 2:
        *arg1 = 0x40;
        *arg2 = 0x40;
        *arg3 = 0xFF;
        break;
    }
}

void func_8005C728(void) {
    s16 x;
    s16 y;
    s16 z;
    s32 temp_t7;

    temp_t7 = ++D_8018D400;
    D_8018D40C = temp_t7 & 0x3F; // temp_t7 % 64
    D_8018D410 = temp_t7 & 0x1F; // temp_t7 % 32
    D_80165590 = temp_t7 & 0xF;  // temp_t7 % 16
    D_80165594 = temp_t7 & 7;    // temp_t7 % 8
    D_80165598 = temp_t7 & 3;    // temp_t7 % 4
    D_8016559C = temp_t7 & 1;    // temp_t7 % 2
    if (D_8018D40C == 0) {
        D_801655A4 += 1;
        D_801655D8 ^= 1;
    }
    if (D_8018D410 == 0) {
        D_801655AC += 1;
        D_801655E8 ^= 1;
    }
    if (D_80165590 == 0) {
        D_801655B4 += 1;
        D_801655F8 ^= 1;
    }
    if (D_80165594 == 0) {
        D_801655BC += 1;
        D_80165608 ^= 1;
    }
    if (D_80165598 == 0) {
        D_801655C4 += 1;
        D_80165618 ^= 1;
    }
    if (D_8016559C == 0) {
        D_801655CC += 1;
        D_80165628 ^= 1;
    }
    if (--D_8018D2AC < 0) {
        D_8018D2AC = 0;
    }
    D_801658A8 += 1;
    if (D_801658A8 >= 7) {
        D_801658A8 = 0;
    }
    func_8005C674(D_801658A8, &x, &y, &z);
    D_801656C0 = x / 2;
    D_801656D0 = y / 2;
    D_801656E0 = z / 2;
    func_8005C980();
}

void func_8005C980(void) {
    s32 var_v0;
    s32 sp0;
    s32 temp_v1;
    for (var_v0 = 0; var_v0 < NUM_PLAYERS; var_v0++) {
        temp_v1 = gGPCurrentRaceRankByPlayerId[var_v0];
        if (D_80165590 == 0) {
            D_8018CF98[var_v0] = temp_v1;
        }
        D_8018CF28[temp_v1] = &gPlayerOne[sp0];
        if (sp0 == 0) {
            D_80165794 = temp_v1;
        }
    }

    for (var_v0 = 0; var_v0 < NUM_PLAYERS; var_v0++) {
        sp0 = gGPCurrentRacePlayerIdByRank[var_v0];
        D_8018CF50[var_v0] = sp0;
        if (D_80165590 == 0) {
            gGPCurrentRaceCharacterIdByRank[var_v0] = (gPlayerOne + sp0)->characterId;
        }
    }

    if (--D_8018D314 <= 0) {
        D_8018D314 = D_8018D3F4;
        D_8018D3E4 = D_800E55D0[D_8018D3F8][0];
        D_8018D3E8 = D_800E55D0[D_8018D3F8][1];
        D_8018D3EC = D_800E55D0[D_8018D3F8][2];
        if (++D_8018D3F8 == 6) {
            D_8018D3F8 = 0;
        }
    }
}

void func_8005CB60(s32 playerId, s32 lapCount) {
    s32 temp_a0_2;
    UNUSED s32 stackPadding;
    s8 *huh;
    s8 *huhthedeuce;
    Player *player;

    player = &gPlayerOne[playerId];
    huh = &playerHUD[playerId].alsoLapCount;
    huhthedeuce = &playerHUD[playerId].lapCount;
    if (playerHUD[playerId].lapCount < D_8018D320) {
        playerHUD[playerId].someTimer = (u32) (s32) (gCourseTimer * 100.0f);
        if (*huh < lapCount) {
            temp_a0_2 = gTimePlayerLastTouchedFinishLine[playerId] * 100.0f;
            playerHUD[playerId].timeLastTouchedFinishLine = temp_a0_2;
            playerHUD[playerId].lapCompletionTimes[*huh] = temp_a0_2;
            if (*huh == 0) {
                playerHUD[playerId].lapDurations[*huh] = playerHUD[playerId].timeLastTouchedFinishLine;
            } else {
                playerHUD[playerId].lapDurations[*huh] = playerHUD[playerId].lapCompletionTimes[*huh] - playerHUD[playerId].lapCompletionTimes[*huh - 1];
            }
            playerHUD[playerId].someTimer1 = playerHUD[playerId].lapDurations[*huh];
            playerHUD[playerId].blinkTimer = 0x003C;
            if (lapCount == 3) {
                playerHUD[playerId].someTimer = playerHUD[playerId].lapCompletionTimes[*huh];
            }
            if (gModeSelection == (s32) 1) {
                if (D_80165638 >= playerHUD[playerId].someTimer1) {
                    if (D_80165638 != playerHUD[playerId].someTimer1) {
                        D_80165658[0] = D_80165658[1] = 0;
                    }
                    func_800C90F4(0U, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x0D));
                    D_80165638 = playerHUD[playerId].someTimer1;
                    D_80165658[lapCount-1] = 1;
                    D_801657E3 = 1;
                }
                if ((lapCount == 3) && ((u32) playerHUD[playerId].someTimer < (u32) D_80165648)) {
                    D_801657E5 = 1;
                }
            }
            *huh += 1;
            if (D_8018D320 == *huh) {
                *huh = D_8018D320 - 1;
            }
            *huhthedeuce += 1;
            if (1) {}
            switch (*huhthedeuce) {                      /* switch 1; irregular */
            case 0:                                 /* switch 1 */
                break;
            case 1:                                 /* switch 1 */
                func_80079084(playerId);
                func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0xF0, 0x15));
                if ((gCurrentCourseId == 8) && (D_80165898 == 0) && (gModeSelection != (s32) 1)) {
                    D_80165898 = 1;
                }
                break;
            case 2:                                 /* switch 1 */
                func_800790B4(playerId);
                break;
            case 3:                                 /* switch 1 */
                if ((D_8018D114 == 0) || (D_8018D114 == 1)) {
                    D_801657E4 = 0;
                    D_801657E6 = 0;
                    D_801657F0 = 0;
                    D_801657E8 = 1;
                    D_80165800[0] = 1;
                    D_80165800[1] = 1;
                    D_8018D204 = (s32) 1;
                }
                playerHUD[playerId].raceCompleteBool = 1;
                if (D_8018D114 == 2) {
                    D_80165800[playerId] = 0;
                }
                if (gCurrentCourseId == 4) {
                    playerHUD[playerId].unk_81 = 1;
                }
                playerHUD[playerId].lap1CompletionTimeX = 0x0140;
                playerHUD[playerId].lap2CompletionTimeX = 0x01E0;
                playerHUD[playerId].lap3CompletionTimeX = 0x0280;
                playerHUD[playerId].totalTimeX = 0x0320;
                D_8016587C = (s32) 1;
                if (D_8018D20C == 0) {
                    func_80079054(playerId);
                    D_8018D20C = 1;
                    if (gPlayerCount == (s8) 1) {
                        D_8018D1CC = 0x00000064;
                    }
                }
                break;
            }
        }
    } else {
        f32_step_towards(&playerHUD[playerId].rankScaling, 1.0f, 0.125f);
        switch (gScreenModeSelection) {             /* irregular */
        case 0:
            s16_step_towards(&playerHUD[playerId].slideRankX, 0x001C, 7);
            if (D_8018D1FC != 0) {
                s16_step_towards(&playerHUD[playerId].slideRankY, -0x0028, 1);
            } else {
                s16_step_towards(&playerHUD[playerId].slideRankY, -0x0010, 4);
            }
            break;
        case 2:
            s16_step_towards(&playerHUD[playerId].slideRankX, 0x001C, 7);
            s16_step_towards(&playerHUD[playerId].slideRankY, -0x0010, 4);
            break;
        case 1:
            s16_step_towards(&playerHUD[playerId].slideRankX, 0x001C, 7);
            s16_step_towards(&playerHUD[playerId].slideRankY, -0x0010, 4);
            s16_step_towards(&playerHUD[playerId].lap1CompletionTimeX, 0x00E4, 0x0010);
            s16_step_towards(&playerHUD[playerId].lap2CompletionTimeX, 0x00E4, 0x0010);
            s16_step_towards(&playerHUD[playerId].lap3CompletionTimeX, 0x00E4, 0x0010);
            s16_step_towards(&playerHUD[playerId].totalTimeX, 0x00E4, 0x0010);
            break;
        case 3:
            if ((playerId & 1) == 1) {
                s16_step_towards(&playerHUD[playerId].slideRankX, -8, 2);
            } else {
                s16_step_towards(&playerHUD[playerId].slideRankX, 8, 2);
            }
            s16_step_towards(&playerHUD[playerId].slideRankY, -0x0010, 4);
            break;
        }
    }
    if (playerHUD[playerId].blinkTimer == 0) {
        playerHUD[playerId].someTimer1 = playerHUD[playerId].someTimer;
        D_801657E3 = 0;
        return;
    }
    if (D_80165594 == 0) {
        playerHUD[playerId].blinkState += 1;
        playerHUD[playerId].blinkState &= 1;
    }
    playerHUD[playerId].blinkTimer -= 1;
    if (playerHUD[playerId].blinkTimer == 0) {
        playerHUD[playerId].blinkState = 0;
    }
}

void func_8005D0FC(s32 playerId) {
    if (gModeSelection != BATTLE) {
        switch (playerId) {                             /* irregular */
            case PLAYER_ONE:
                func_8005CB60(playerId, gLapCountByPlayerId[PLAYER_ONE]);
                break;
            case PLAYER_TWO:
                func_8005CB60(playerId, gLapCountByPlayerId[PLAYER_TWO]);
                break;
            case PLAYER_THREE:
                func_8005CB60(playerId, gLapCountByPlayerId[PLAYER_THREE]);
                break;
            case PLAYER_FOUR:
                func_8005CB60(playerId, gLapCountByPlayerId[PLAYER_FOUR]);
                break;
        }
    }
}

void func_8005D18C(void) {
    if ((gModeSelection == GRAND_PRIX) && (gPlayerCountSelection1 == TIME_TRIALS)) {
        D_801657D8 = 1;
        D_8018D2BC = 0;
        D_8018D2A4 = 0;
        if (gGPCurrentRaceRankByPlayerId[0] >= 4) {
            D_8018D1FC = 1;
            D_8018D2A4 = 1;
            D_8018D2BC = 1;
        }
    }
}

void func_8005D1F4(s32 arg0) {
    s32 playerWaypoint;
    s32 bombWaypoint;
    s32 var_a2;
    s32 waypointDiff;

    if (gModeSelection == 2) {
        playerWaypoint = gNearestWaypointByPlayerId[arg0];
        playerHUD[arg0].unk_74 = 0;
        for (var_a2 = 0; var_a2 < NUM_BOMB_KARTS_VERSUS; var_a2++) {
            if ((gBombKarts[var_a2].state == BOMB_STATE_EXPLODED) || (gBombKarts[var_a2].state == BOMB_STATE_INACTIVE)) continue;
            bombWaypoint = gBombKarts[var_a2].waypointIndex;
            waypointDiff = bombWaypoint - playerWaypoint;
            if ((waypointDiff < -5) || (waypointDiff > 0x1E)) continue;
            playerHUD[arg0].unk_74 = 1;
            break;
        }
    }
}

// Appears to load GP Mode race staging balloons and kart shadows.
void func_8005D290(void) {
    D_8018D488 = dma_textures(gTexture69C80C, 0x400, 0x400);
    D_8018D474 = dma_textures(gTextureKartShadow, 0x1000, 0x1000);
    D_8018D420 = dma_textures(gTexture69B03C, 0x100, 0x100);
    D_8018D424 = dma_textures(gTexture69B140, 0x400, 0x400);
    D_8018D478 = dma_textures(gTexture69C1E8, 0x200, 0x200);
    D_8018D480 = dma_textures(gTexture69BA28, 0x400, 0x400);
    D_8018D484 = dma_textures(gTexture69B960, 0x400, 0x400);
    D_8018D48C = dma_textures(gTexture69C354, 0x400, 0x400);
    D_8018D494 = dma_textures(gTexture69C4E4, 0x400, 0x400);
    D_8018D490 = D_8018D48C;
    D_8018D498 = dma_textures(gTexture69B378, 0x1000, 0x1000);
    D_8018D4BC = dma_textures(gTextureBalloon1, 0x800, 0x800);
    D_8018D4C0 = dma_textures(gTextureBalloon2, 0x800, 0x800);
    D_8018D49C = dma_textures(gTexture69C9C4, 0x200, 0x200);
    D_8018D4A0 = dma_textures(gTextureBoingExclamation, 0x800, 0x800);
    D_8018D4A4 = dma_textures(gTextureOnomatopoeiaPoomp1, 0x800, 0x800);
    D_8018D4A8 = dma_textures(gTextureOnomatopoeiaPoomp2, 0x800, 0x800);
    D_8018D4AC = dma_textures(gTextureOnomatopoeiaWhrrrr1, 0x800, 0x800);
    D_8018D4B0 = dma_textures(gTextureOnomatopoeiaWhrrrr2, 0x800, 0x800);
    D_8018D4B4 = dma_textures(gTextureOnomatopoeiaCrash1, 0x800, 0x800);
    D_8018D4B8 = dma_textures(gTextureOnomatopoeiaCrash2, 0x800, 0x800);
    D_8018D438 = dma_textures(gTexture69CB84, 0x800, 0x800);
    D_8018D43C = dma_textures(gTexture69CCEC, 0x800, 0x800);
    D_8018D440 = dma_textures(gTexture69CEB8, 0x800, 0x800);
    D_8018D444 = dma_textures(gTexture69D148, 0x800, 0x800);
    D_8018D448 = dma_textures(gTexture69D4E0, 0x800, 0x800);
    D_8018D44C = dma_textures(gTexture69D8FC, 0x800, 0x800);
    D_8018D450 = dma_textures(gTexture69DCB4, 0x800, 0x800);
    D_8018D454 = dma_textures(gTexture69DFA0, 0x800, 0x800);
    D_8018D458 = dma_textures(gTexture69E25C, 0x800, 0x800);
    D_8018D45C = dma_textures(gTexture69E518, 0x800, 0x800);
    D_8018D460 = dma_textures(gTexture69E7A8, 0x800, 0x800);
    D_8018D464 = dma_textures(gTexture69EA18, 0x800, 0x800);
    D_8018D468 = dma_textures(gTexture69EC54, 0x800, 0x800);
    D_8018D46C = dma_textures(gTexture69EE38, 0x800, 0x800);
    D_8018D470 = dma_textures(gTexture69EFE0, 0x800, 0x800);
    D_8018D4C4 = dma_textures(gTextureLightningBolt0, 0x800, 0x800);
    D_8018D4C8 = dma_textures(gTextureLightningBolt1, 0x800, 0x800);
}

void func_8005D6C0(Player* player) {
    s32 temp_v0;

    for (temp_v0 = 0; temp_v0 < 10; ++temp_v0) {
        player->unk_258[temp_v0].unk_01C = 0;
        player->unk_258[temp_v0].unk_01E = 0;
        player->unk_258[temp_v0].unk_012 = 0;
    }

    for (temp_v0 = 0; temp_v0 < 10; ++temp_v0) {
        player->unk_258[30 + temp_v0].unk_01C = 0;
        player->unk_258[30 + temp_v0].unk_01E = 0;
        player->unk_258[30 + temp_v0].unk_012 = 0;
    }

    for (temp_v0 = 0; temp_v0 < 10; ++temp_v0) {
        player->unk_258[10 + temp_v0].unk_01C = 0;
        player->unk_258[10 + temp_v0].unk_01E = 0;
        player->unk_258[10 + temp_v0].unk_012 = 0;
    }

    for (temp_v0 = 0; temp_v0 < 10; ++temp_v0) {
        player->unk_258[20 + temp_v0].unk_01C = 0;
        player->unk_258[20 + temp_v0].unk_01E = 0;
        player->unk_258[20 + temp_v0].unk_012 = 0;
    }
}

void func_8005D794(Player* player, UnkPlayerStruct258* arg1, f32 arg2, f32 arg3, f32 arg4, s8 surfaceType, s8 arg6) {
    arg1->unk_000[2] = arg4;
    arg1->unk_000[0] = arg2;
    arg1->unk_000[1] = arg3;
    arg1->unk_020 = -player->rotation[1];
    arg1->unk_014 = surfaceType;
    arg1->unk_010 = arg6;
}

s32 func_8005D7D8(UnkPlayerStruct258* arg0, s8 arg1, f32 arg2) {
    arg0->unk_01C = 1;
    arg0->unk_012 = arg1;
    arg0->unk_01E = 0;
    arg0->unk_00C = arg2;
}

s32 func_8005D800(UnkPlayerStruct258* arg0, s32 arg1, s16 arg2) {
    arg0->unk_038 = (u8) (arg1 >> 16);
    arg0->unk_03A = (u8) (arg1 >> 8);
    arg0->unk_03C = (u8)  arg1;
    arg0->unk_03E = arg2;
}

s32 func_8005D82C(UnkPlayerStruct258* arg0, s32 arg1, s16 arg2) {
    s32 temp_v0;
    temp_v0 = random_int(0x30);

    arg0->unk_038 = (u8) ((u8) (arg1 >> 0x10) - temp_v0) ;
    arg0->unk_03A = (u8) ((u8) (arg1 >> 8) - temp_v0) ;
    arg0->unk_03C = (u8) ((u8)  arg1 - temp_v0) ;
    arg0->unk_03E = arg2;
}

void func_8005D898(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    s32 temp_lo;

    if (player->unk_0C0 >= 0) {
        func_8005D794(player, &player->unk_258[10 + arg1], player->boundingBoxCorners[2].cornerPos[0], player->boundingBoxCorners[2].cornerGroundY + 2.0f, player->boundingBoxCorners[2].cornerPos[2], player->boundingBoxCorners[2].surfaceType, 1);
    } else {
        func_8005D794(player, &player->unk_258[10 + arg1], player->boundingBoxCorners[3].cornerPos[0], player->boundingBoxCorners[3].cornerGroundY + 2.0f, player->boundingBoxCorners[3].cornerPos[2],  player->boundingBoxCorners[3].surfaceType, 0);
    }

    temp_lo = player->unk_0C0 / 182;
    if ((temp_lo >= 7) || (temp_lo < -6)) {
        func_8005D7D8(&player->unk_258[10 + arg1], 1, 0.35f);
        if (player->unk_22A == 0) {
            func_8005D800(&player->unk_258[10 + arg1], 0xFFFFFF, 0x70);
        }

        if (player->unk_22A == 1) {
            func_8005D800(&player->unk_258[10 + arg1], 0xFFFF00, 0x70);
  
        }

        if (player->unk_22A >= 2) {
            func_8005D800(&player->unk_258[10 + arg1], 0xFF9600, 0x70);
        }

        if (player->unk_22A >= 2) {
            // Why not put this in previous if statement?
            player->unk_258[10 + arg1].unk_040 = 2;
            return;
        }

        player->unk_258[10 + arg1].unk_040 = player->unk_22A;
    }
}

void func_8005DA30(Player *player, s16 arg1, s32 arg2, s8 arg3, s8 arg4) {
    if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E >= 3) || (player->unk_258[10 + arg2].unk_01C == 0))) {
        func_8005D898(player, arg1, arg2, arg3, arg4);
    } else if (player->unk_258[10 + arg2].unk_01E >= 3) {
        func_8005D898(player, arg1, arg2, arg3, arg4);
    }
}

UNUSED void func_8005DAD0(void) {

}

void func_8005DAD8(UnkPlayerStruct258* arg0, s16 arg1, s16 arg2, s16 arg3) {
    arg0->unk_038 = arg1;
    arg0->unk_03E = arg3;
    arg0->unk_040 = arg2;
}

void func_8005DAF4(Player *player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    UNUSED s32 stackPadding;
    s32 surfaceType;
    s32 var_t3;
    f32 var_f2;
    f32 var_f12;
    f32 var_f14;
    s32 temp_v0;
    static s32 test = 8;

    surfaceType = 0x000000FF;
    temp_v0 = random_int(test);
    if ((temp_v0 == 0) || (temp_v0 == 4)) {
        var_f2  = player->boundingBoxCorners[2].cornerPos[0];
        var_f12 = player->boundingBoxCorners[2].cornerGroundY + 2.0f;
        var_f14 = player->boundingBoxCorners[2].cornerPos[2];
        var_t3 = 1;
        surfaceType = player->boundingBoxCorners[2].surfaceType;
    }
    if ((temp_v0 == 2) || (temp_v0 == 6)) {
        var_f2  = player->boundingBoxCorners[3].cornerPos[0];
        var_f12 = player->boundingBoxCorners[3].cornerGroundY + 2.0f;
        var_f14 = player->boundingBoxCorners[3].cornerPos[2];
        var_t3 = 0;
        surfaceType = player->boundingBoxCorners[3].surfaceType;
    }
    switch (surfaceType) {
        case DIRT:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) {
                    func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                    func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                    if ((gCurrentCourseId == COURSE_CHOCO_MOUNTAIN) || (gCurrentCourseId == COURSE_ROYAL_RACEWAY)) {
                        func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080);
                    }
                    if (gCurrentCourseId == COURSE_KALAMARI_DESERT) {
                        func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080);
                    }
                    if (gCurrentCourseId == COURSE_MOO_MOO_FARM) {
                        func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080);
                    }
                    if (gCurrentCourseId == COURSE_WARIO_STADIUM) {
                        func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080);
                    }
                    if (gCurrentCourseId == COURSE_YOSHI_VALLEY) {
                        func_8005DAD8(&player->unk_258[10 + arg1], 10, 0, 0x0080);
                    }
                    if (gCurrentCourseId == COURSE_DK_JUNGLE) {
                        func_8005DAD8(&player->unk_258[10 + arg1], 11, 0, 0x0080);
                    }
                    player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
                }
            } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                if ((gCurrentCourseId == COURSE_CHOCO_MOUNTAIN) || (gCurrentCourseId == COURSE_ROYAL_RACEWAY)) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_KALAMARI_DESERT) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_MOO_MOO_FARM) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_WARIO_STADIUM) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_YOSHI_VALLEY) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 10, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_DK_JUNGLE) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 11, 0, 0x0080);
                }
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case GRASS:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) {
                    func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                    func_8005D7D8(&player->unk_258[10 + arg1], 3, 1.0f);
                    func_8005D800(&player->unk_258[10 + arg1], 0x00FFFFFF, 0x00FF);
                    player->unk_258[10 + arg1].unk_038 -= arg1 * 8;
                    player->unk_258[10 + arg1].unk_03A -= arg1 * 8;
                    player->unk_258[10 + arg1].unk_03C -= arg1 * 8;
                }
            } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 3, 1.0f);
                func_8005D800(&player->unk_258[10 + arg1], 0x00FFFFFF, 0x00FF);
                player->unk_258[10 + arg1].unk_038 -= arg1 * 8;
                player->unk_258[10 + arg1].unk_03A -= arg1 * 8;
                player->unk_258[10 + arg1].unk_03C -= arg1 * 8;
            }
            player->unk_258[10 + arg1].unk_000[1] -= 1.5;
            break;
        case SAND_OFFROAD:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) {
                    func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                    func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                    func_8005DAD8(&player->unk_258[10 + arg1], 2, 1, 0x00A8);
                    player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
                }
            } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 2, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case SAND:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) {
                    func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                    func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                    func_8005DAD8(&player->unk_258[10 + arg1], 3, 1, 0x00A8);
                    player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
                }
            } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 3, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case WET_SAND:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) {
                    func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                    func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                    func_8005DAD8(&player->unk_258[10 + arg1], 4, 1, 0x00A8);
                    player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
                }
            } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 4, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case DIRT_OFFROAD:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) {
                    func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                    func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                    func_8005DAD8(&player->unk_258[10 + arg1], 5, 1, 0x00A8);
                    player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
                }
            } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                func_8005D82C(&player->unk_258[10 + arg1], 0x00FFA54F, 0x00AF);
                func_8005DAD8(&player->unk_258[10 + arg1], 5, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case SNOW:
        case SNOW_OFFROAD:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) {
                    func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                    func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                    func_8005DAD8(&player->unk_258[10 + arg1], 6, 1, 0x00A8);
                    player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
                }
            } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 6, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case ASPHALT:
        case STONE:
        case BRIDGE:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                if (((((player->unk_094 / 18.0f) * 216.0f) >= 30.0f) && ((((player->unk_0C0 / 182) > 0x14) || ((player->unk_0C0 / 182) < (-0x14))))) || ((player->unk_22C - player->unk_094) >= 0.04)) {
                    func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                    func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                    func_8005DAD8(&player->unk_258[10 + arg1], 0, 0, 0x0080);
                    player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
                }
            } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((((player->unk_094 / 18.0f) * 216.0f) >= 30.0f) && (((player->unk_0C0 / 182) >= 0x15) || ((player->unk_0C0 / 182) < -0x14))) || ((player->unk_22C - player->unk_094) >= 0.04))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 0, 0, 0x0080);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        default:
            break;
    }
}

void func_8005EA94(Player *player, s16 arg1, s32 arg2, s8 arg3, UNUSED s8 arg4) {
    s32 temp_v0;
    s32 var_t0;
    s32 var_t1;
    f32 var_f2;
    f32 var_f12;
    f32 var_f14;
    static s32 test = 10;

    var_t0 = 0x000000FF;
    temp_v0 = random_int(test);
    if ((temp_v0 == 0) || (temp_v0 == 8)) {
        if ((D_801652A0[arg3] - player->boundingBoxCorners[2].cornerGroundY) >= 3.5) {
            var_f2 = player->boundingBoxCorners[2].cornerPos[0];
            var_f12 = player->boundingBoxCorners[2].cornerGroundY + 2.0f;
            var_f14 = player->boundingBoxCorners[2].cornerPos[2];
            var_t1 = 1;
            var_t0 = 0;
        }
    }
    if ((temp_v0 == 2) || (temp_v0 == 6)) {
        if ((D_801652A0[arg3] - player->boundingBoxCorners[3].cornerGroundY) >= 3.5) {
            var_f2 = player->boundingBoxCorners[3].cornerPos[0];
            var_f12 = player->boundingBoxCorners[3].cornerGroundY + 2.0f;
            var_f14 = player->boundingBoxCorners[3].cornerPos[2];
            var_t1 = 0;
            var_t0 = 0;
        }
    }
    if (1) {}
    if (var_t0 == 0) {
        if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
            if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, var_t0, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 9, 0.8f);
                func_8005D800(&player->unk_258[10 + arg1], 0x00FFFFFF, 0x00AF);
            }
        } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) {
            func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, var_t0, var_t1);
            func_8005D7D8(&player->unk_258[10 + arg1], 9, 0.8f);
            func_8005D800(&player->unk_258[10 + arg1], 0x00FFFFFF, 0x00AF);
        }
    }
}

void func_8005ED48(Player *player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    s32 temp_v0;
    s32 surfaceType;
    s32 var_t3;
    f32 var_f0;
    f32 var_f2;
    f32 var_f12;
    static s32 test = 8;

    surfaceType = 0x000000FF;
    temp_v0 = random_int(test);
    if ((temp_v0 == 2) || (temp_v0 == 4)) {
        var_f0 = player->boundingBoxCorners[2].cornerPos[0];
        var_f2 = player->boundingBoxCorners[2].cornerGroundY + 2.0f;
        var_f12 = player->boundingBoxCorners[2].cornerPos[2];
        var_t3 = 1;
        surfaceType = player->boundingBoxCorners[2].surfaceType;
    }
    if ((temp_v0 == 0) || (temp_v0 == 6)) {
        var_f0 = player->boundingBoxCorners[3].cornerPos[0];
        var_f2 = player->boundingBoxCorners[3].cornerGroundY + 2.0f;
        var_f12 = player->boundingBoxCorners[3].cornerPos[2];
        var_t3 = 0;
        surfaceType = player->boundingBoxCorners[3].surfaceType;
    }
    switch (surfaceType) {
        case DIRT:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                if ((gCurrentCourseId == COURSE_CHOCO_MOUNTAIN) || (gCurrentCourseId == COURSE_ROYAL_RACEWAY)) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_KALAMARI_DESERT) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_MOO_MOO_FARM) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_WARIO_STADIUM) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_YOSHI_VALLEY) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 10, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_DK_JUNGLE) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 11, 0, 0x0080);
                }
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                if ((gCurrentCourseId == COURSE_CHOCO_MOUNTAIN) || (gCurrentCourseId == COURSE_ROYAL_RACEWAY)) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_KALAMARI_DESERT) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_MOO_MOO_FARM) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_WARIO_STADIUM) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_YOSHI_VALLEY) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 0x000A, 0, 0x0080);
                }
                if (gCurrentCourseId == COURSE_DK_JUNGLE) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 0x000B, 0, 0x0080);
                }
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case GRASS:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.1f);
                func_8005D800(&player->unk_258[10 + arg1], 0x00FFFFFF, 0x00FF);
                player->unk_258[10 + arg1].unk_038 -= arg1 * 8;
                player->unk_258[10 + arg1].unk_03A -= arg1 * 8;
                player->unk_258[10 + arg1].unk_03C -= arg1 * 8;
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.1f);
                func_8005D800(&player->unk_258[10 + arg1], 0x00FFFFFF, 0x00FF);
                player->unk_258[10 + arg1].unk_038 -= arg1 * 8;
                player->unk_258[10 + arg1].unk_03A -= arg1 * 8;
                player->unk_258[10 + arg1].unk_03C -= arg1 * 8;
            }
            player->unk_258[10 + arg1].unk_000[1] -= 1.5;
            break;
        case SAND_OFFROAD:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 2, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 2, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case SAND:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 3, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 3, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case WET_SAND:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 4, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 4, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case DIRT_OFFROAD:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 5, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 5, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case SNOW:
        case SNOW_OFFROAD:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 6, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 6, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case ASPHALT:
        case STONE:
        case BRIDGE:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 0, 0, 0x0080);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, (s8) surfaceType, (s8) var_t3);
                func_8005D7D8(&player->unk_258[10 + arg1], 5, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 0, 0, 0x0080);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        default:
            break;
    }
}

#ifdef NON_MATCHING
// Its close, there's some register allocation issue though
// Permuter hasn't found anything
// https://decomp.me/scratch/WjMqd

void func_8005F90C(Player *player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    s32 var_t1;
    u8 surfaceType;
    f32 var_f0;
    f32 var_f2;
    f32 var_f12;

    var_t1 = 0;
    if ((player->effects & 0x80) == 0x80) {
        var_f0 = player->pos[0];
        var_f2 = player->pos[1] - player->boundingBoxSize;
        var_f12 = player->pos[2];
        var_t1 = 1;
        surfaceType = player->boundingBoxCorners[2].surfaceType;
    } else {
        var_f0 = player->pos[0];
        var_f2 = player->pos[1] - player->boundingBoxSize;
        var_f12 = player->pos[2];
        surfaceType = player->boundingBoxCorners[3].surfaceType;
    }
    switch (surfaceType) {
        case DIRT:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                if ((gCurrentCourseId == 1) || (gCurrentCourseId == 7)) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080);
                }
                if (gCurrentCourseId == 0x000B) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080);
                }
                if (gCurrentCourseId == 9) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080);
                }
                if (gCurrentCourseId == 0x000E) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080);
                }
                if (gCurrentCourseId == 4) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 0x000A, 0, 0x0080);
                }
                if (gCurrentCourseId == 0x0012) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 0x000B, 0, 0x0080);
                }
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                if ((gCurrentCourseId == 1) || (gCurrentCourseId == 7)) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 1, 0, 0x0080);
                }
                if (gCurrentCourseId == 0x000B) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 7, 0, 0x0080);
                }
                if (gCurrentCourseId == 9) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 8, 0, 0x0080);
                }
                if (gCurrentCourseId == 0x000E) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 9, 0, 0x0080);
                }
                if (gCurrentCourseId == 4) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 0x000A, 0, 0x0080);
                }
                if (gCurrentCourseId == 0x0012) {
                    func_8005DAD8(&player->unk_258[10 + arg1], 0x000B, 0, 0x0080);
                }
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case GRASS:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.1f);
                func_8005D800(&player->unk_258[10 + arg1], 0x00FFFFFF, 0x00FF);
                player->unk_258[10 + arg1].unk_038 -= arg1 * 8;
                player->unk_258[10 + arg1].unk_03A -= arg1 * 8;
                player->unk_258[10 + arg1].unk_03C -= arg1 * 8;
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.1f);
                func_8005D800(&player->unk_258[10 + arg1], 0x00FFFFFF, 0x00FF);
                player->unk_258[10 + arg1].unk_038 -= arg1 * 8;
                player->unk_258[10 + arg1].unk_03A -= arg1 * 8;
                player->unk_258[10 + arg1].unk_03C -= arg1 * 8;
            }
            player->unk_258[10 + arg1].unk_000[1] -= 1.5;
            break;
        case SAND_OFFROAD:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 2, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 2, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case SAND:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 3, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 3, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case WET_SAND:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 4, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 4, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case DIRT_OFFROAD:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 5, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 5, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case SNOW:
        case SNOW_OFFROAD:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 6, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 6, 1, 0x00A8);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        case ASPHALT:
        case STONE:
        case BRIDGE:
            if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 0, 0, 0x0080);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            } else if (player->unk_258[10 + arg2].unk_01E > 0) {
                func_8005D794(player, &player->unk_258[10 + arg1], var_f0, var_f2, var_f12, surfaceType, var_t1);
                func_8005D7D8(&player->unk_258[10 + arg1], 4, 0.46f);
                func_8005DAD8(&player->unk_258[10 + arg1], 0, 0, 0x0080);
                player->unk_258[10 + arg1].unk_03A = random_int(0x0010U);
            }
            break;
        default:
            break;
    }
}
#else
GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8005F90C.s")
#endif

void func_80060504(Player *player, s16 arg1, s32 arg2, s8 arg3, s8 arg4) {
    UNUSED s32 thing1;
    s16 thing2;
    UNUSED s32 thing3;
    f32 sp50;
    f32 sp4C;
    f32 sp48;
    f32 var_f0;
    s32 var_v0;
    s32 temp_v0;
    UNUSED s32 test;

    if ((player->unk_044 & 0x20) == 0x20) {
        var_v0 = 5;
    } else {
        var_v0 = 0xE;
    }
    temp_v0 = random_int(var_v0);
    if ((temp_v0 == 1) || (temp_v0 == 2) || (temp_v0 == 3)) {
        if ((arg1 == 0) && ((player->unk_258[arg2].unk_01E > 0) || (player->unk_258[arg2].unk_01C == 0))) {
            sp4C = player->pos[1] - 2.5;
            sp48 = player->pos[2];
            sp50 = player->pos[0];
            func_8005D794(player, &player->unk_258[arg1], sp50, sp4C, sp48, 0, 0);
            func_8005D7D8(&player->unk_258[arg1], 1, 0.5f);
        } else if (player->unk_258[arg2].unk_01E > 0) {
            sp4C = player->pos[1] - 2.5;
            sp48 = player->pos[2];
            sp50 = player->pos[0];
            func_8005D794(player, &player->unk_258[arg1], sp50, sp4C, sp48, 0, 0);
            func_8005D7D8(&player->unk_258[arg1], 1, 0.5f);
        }
    }
    player->unk_258[arg1].unk_024 = 0.0f;
    if ((player->unk_044 & 0x20) == 0x20) {
        player->unk_258[arg1].unk_040 = 0;
        if ((player->effects & BOOST_EFFECT) == BOOST_EFFECT) {
            func_8005D800(&player->unk_258[arg1], 0x00FFFF00, 0x0080);
            player->unk_258[arg1].unk_038 = 1;
        } else {
            func_8005D800(&player->unk_258[arg1], 0x00FFFFFF, 0x0070);
            player->unk_258[arg1].unk_038 = 0;
        }
    } else {
        player->unk_258[arg1].unk_040 = 1;
        if ((player->effects & BOOST_EFFECT) == BOOST_EFFECT) {
            func_8005D800(&player->unk_258[arg1], 0x00FFFF00, 0x0080);
            player->unk_258[arg1].unk_038 = 1;
        } else {
            func_8005D800(&player->unk_258[arg1], 0x00FFFFFF, 0x0070);
            player->unk_258[arg1].unk_038 = 0;
        }
    }
    thing2 = (player->unk_258[arg1].unk_020 - (player->unk_0C0 / 2));
    if (player->unk_258[arg1].unk_040 == 0) {
        var_f0 = -((player->unk_098 / 3000.0f) + 0.1);
    } else {
        var_f0 = -((player->unk_098 / 5000.0f) + 0.1);
    }
    func_80062B18(&sp50, &sp4C, &sp48, 0.0f, 4.5f, (player->unk_258[arg1].unk_01E * var_f0) + -5.5, -thing2, -player->unk_206 * 2);
    player->unk_258[arg1].unk_000[0] = player->pos[0] + sp50;
    sp4C = sp4C + (player->pos[1] - player->boundingBoxSize);
    player->unk_258[arg1].unk_000[2] = player->pos[2] + sp48;
    player->unk_258[arg1].unk_000[1] = player->unk_258[arg1].unk_024 + sp4C;
    player->unk_258[arg1].unk_010 = 0;
}

void func_800608E0(Player *player, s16 arg1, UNUSED s32 arg2, s8 arg3, UNUSED s8 arg4) {
    f32 var_f0;
    f32 sp50;
    f32 sp4C;
    f32 sp48;

    var_f0 = 8.0f - (D_801652A0[arg3] - player->pos[1]);
    if ((f64) var_f0 <= 0.0) {
        var_f0 = 0.0f;
    }
    sp4C = (D_801652A0[arg3] - player->pos[1]) - 3.0f;
    if ((player->unk_0DE & 1) && (gCurrentCourseId != COURSE_KOOPA_BEACH)) {
        var_f0 = 2.5f;
        sp4C = (f32) ((f64) (D_801652A0[arg3] - player->pos[1]) + 0.1);
    }
    func_8005D794(player, &player->unk_258[arg1], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0);
    func_8005D7D8(&player->unk_258[arg1], 3, var_f0);
    if ((gCurrentCourseId == COURSE_BOWSER_CASTLE) || (gCurrentCourseId == COURSE_BIG_DONUT)) {
        func_8005D800(&player->unk_258[arg1], 0, 0x00AF);
    } else {
        func_8005D800(&player->unk_258[arg1], 0x00FFFFFF, 0x00CF);
    }
    func_80062B18(&sp50, &sp4C, &sp48, 0.0f, sp4C, ((-player->unk_258[arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 10.0f) + -4.0f, -player->unk_258[arg1].unk_020, -player->unk_206 * 2);
    player->unk_258[arg1].unk_000[0] = player->pos[0] + sp50;
    player->unk_258[arg1].unk_000[2] = player->pos[2] + sp48;
    player->unk_258[arg1].unk_000[1] = player->pos[1] + sp4C;
}

void func_80060B14(Player *player, s16 arg1, s32 arg2, s8 arg3, s8 arg4) {
    if ((gCurrentCourseId != COURSE_SKYSCRAPER) && (gCurrentCourseId != COURSE_RAINBOW_ROAD)) {
        if ((arg1 == 0) && ((player->unk_258[arg2].unk_01E > 0) || (player->unk_258[arg2].unk_01C == 0))) {
            func_800608E0(player, arg1, arg2, arg3, arg4);
        } else if (player->unk_258[arg2].unk_01E > 0) {
            func_800608E0(player, arg1, arg2, arg3, arg4);
        }
    }
}

void func_80060BCC(Player *player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    s32 sp54;
    UNUSED s32 pad;
    s32 sp4C;
    f32 sp48;
    f32 sp44;

    if (gCurrentCourseId == COURSE_SKYSCRAPER) return;
    if (gCurrentCourseId == COURSE_RAINBOW_ROAD) return;
    sp54 = random_int(0x0168U) - 0xB4;
    sp4C = random_int(6U);
    sp44 = random_int(6U);
    sp48 = random_int(3U);
    if (player != gPlayerOne) return;
    if ((arg1 == 0) && ((player->unk_258[arg2 + 10].unk_01E > 0) || (player->unk_258[arg2 + 10].unk_01C == 0))) {
        func_8005D794(player, &player->unk_258[arg1 + 10], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0);
        func_8005D7D8(&player->unk_258[arg1 + 10], 0x0B, 0.4f);
        func_8005D800(&player->unk_258[arg1 + 10], 0x00FFFFFF, 0x00FF);
        player->unk_258[arg1 + 10].unk_000[2] = player->pos[2] + (coss(sp54 * 0xB6) * -1.8);
        player->unk_258[arg1 + 10].unk_000[0] = player->pos[0] + (sins(sp54 * 0xB6) * -1.8);
        player->unk_258[arg1 + 10].unk_000[1] = (player->pos[1] - player->boundingBoxSize) + sp4C + 2.0f;
        player->unk_258[arg1 + 10].unk_018 = sp44 + 1.0f;
        player->unk_258[arg1 + 10].unk_00C = (sp48 + 2.0f) / 10.0f;
    }
    else if (player->unk_258[arg2 + 10].unk_01E > 0) {
        func_8005D794(player, &player->unk_258[arg1 + 10], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0);
        func_8005D7D8(&player->unk_258[arg1 + 10], 0x0B, 0.4f);
        func_8005D800(&player->unk_258[arg1 + 10], 0x00FFFFFF, 0x00FF);
        player->unk_258[arg1 + 10].unk_000[2] = player->pos[2] + (coss(sp54 * 0xB6) * -1.8);
        player->unk_258[arg1 + 10].unk_000[0] = player->pos[0] + (sins(sp54 * 0xB6) * -1.8);
        player->unk_258[arg1 + 10].unk_000[1] = (player->pos[1] - player->boundingBoxSize) + sp4C + 2.0f;
        player->unk_258[arg1 + 10].unk_018 = sp44 + 1.0f;
        player->unk_258[arg1 + 10].unk_00C = (sp48 + 2.0f) / 10.0f;
    }
}

void func_80060F50(Player* player, s16 arg1, UNUSED s32 arg2, s8 arg3, UNUSED s8 arg4) {
    func_8005D794(player, &player->unk_258[arg1], 0.0f, 0.0f, 0.0f, 0, 0);
    func_8005D7D8(&player->unk_258[arg1], 5, 4.0f);

    if ((gCurrentCourseId == COURSE_BOWSER_CASTLE) || (gCurrentCourseId == COURSE_BIG_DONUT)) {
        func_8005D800(&player->unk_258[arg1], 0xFF0000, 0xFF);
    } else {
        func_8005D800(&player->unk_258[arg1], 0xFFFFFF, 0xFF);
    }

    player->unk_258[arg1].unk_000[2] = player->pos[2] + (coss(player->unk_258[arg1].unk_020) * -5.8);
    player->unk_258[arg1].unk_000[0] = player->pos[0] + (sins(player->unk_258[arg1].unk_020) * -5.8);
    player->unk_258[arg1].unk_000[1] = D_801652A0[arg3];
    player->unk_0DE &= ~0x0008;
}

void func_80061094(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    if (arg1 == 0) {
        func_8005D794(player, &player->unk_258[arg1], 0.0f, 0.0f, 0.0f, 0, 0);
        func_8005D7D8(&player->unk_258[arg1], 6, 3.8f);
        func_8005D800(&player->unk_258[arg1], 0xFFFFFF, 0xFF);
        player->unk_258[arg1].unk_038 = 0;
        player->unk_258[arg1].unk_03A = 0;
        player->unk_258[arg1].unk_03C = 0;
    }
}

void func_80061130(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    func_8005D794(player, &player->unk_258[arg1], 0.0f, 0.0f, 0.0f, 0, 0);
    func_8005D7D8(&player->unk_258[arg1], 7, 0.6f);
    func_8005D800(&player->unk_258[arg1], 0xFFFFFF, 0xD0);

    player->unk_258[arg1].unk_000[2] = player->pos[2] +(coss(player->unk_258[arg1].unk_020) * 6.0f);
    player->unk_258[arg1].unk_000[0] = player->pos[0] + (sins(player->unk_258[arg1].unk_020) * 6.0f);
    player->unk_258[arg1].unk_000[1] = player->pos[1] - 5.0f;
    player->unk_258[arg1].unk_040 = 0;
    player->unk_258[arg1].unk_024 = 0.0f;
}

void func_80061224(Player *player, s16 arg1, s32 arg2, s8 arg3, s8 arg4) {
    if ((arg1 == 0) && ((player->unk_258[arg2].unk_01E > 0) || (player->unk_258[arg1].unk_01C == 0))) {
        func_80061130(player, arg1, arg2, arg3, arg4);
    }
    else if (player->unk_258[arg2].unk_01E >= 2) {
        func_80061130(player, arg1, arg2, arg3, arg4);
        if (arg1 == 9) {
            player->unk_044 &= ~0x0200;
        }
    }
}

void func_800612F8(Player *player, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    s32 var_s2;

    for (var_s2 = 0; var_s2 < 10; var_s2++){
        player->unk_258[0x1E + var_s2].unk_01C = 1;
        player->unk_258[0x1E + var_s2].unk_028 = player->pos[1] + 5.0f;
        player->unk_258[0x1E + var_s2].unk_020 = (0x1C70 * var_s2) - player->rotation[1];
        player->unk_258[0x1E + var_s2].unk_024 = (random_int(0x0064U) / 100.0f) + 1.5;
        player->unk_258[0x1E + var_s2].unk_03A = 0;
        player->unk_258[0x1E + var_s2].unk_012 = 1;
        player->unk_258[0x1E + var_s2].unk_01E = 0;
        player->unk_258[0x1E + var_s2].unk_03E = 0x00FF;
        player->unk_258[0x1E + var_s2].unk_000[2] = player->pos[2];
        player->unk_258[0x1E + var_s2].unk_000[0] = player->pos[0];
    }
    player->unk_046 &= ~0x0008;
}

void func_80061430(Player *player, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    s32 var_s2;

    for (var_s2 = 0; var_s2 < 7; var_s2++){
        player->unk_258[0x1E + var_s2].unk_01C = 1;
        player->unk_258[0x1E + var_s2].unk_028 = player->pos[1] - 4.0f;
        player->unk_258[0x1E + var_s2].unk_020 = (0x1C70 * var_s2) - player->rotation[1];
        // ???
        player->unk_258[0x1E + var_s2].unk_024 = (random_int(0x0064U) / 100.0f) + 1.9;
        player->unk_258[0x1E + var_s2].unk_024 = (random_int(0x0064U) / 100.0f) + 1.5;
        player->unk_258[0x1E + var_s2].unk_03A = 0;
        player->unk_258[0x1E + var_s2].unk_012 = 9;
        player->unk_258[0x1E + var_s2].unk_01E = 0;
        player->unk_258[0x1E + var_s2].unk_03E = 0x00FF;
        player->unk_258[0x1E + var_s2].unk_000[2] = player->pos[2];
        player->unk_258[0x1E + var_s2].unk_000[0] = player->pos[0];
    }
    player->unk_044 &= ~0x1000;
}

void func_800615AC(Player *player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    s32 test = 2;
    UNUSED s32 stackPadding0;
    UNUSED s32 stackPadding1;
    f32 temp_f0;
    f32 sp28[10] = { -182.0f, 182.0f, 364.0f, -364.0f, 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f };

    if (random_int(3U) == 2.0f) {
        player->unk_258[0x1E + arg1].unk_01C = 1;
        player->unk_258[0x1E + arg1].unk_000[0] = player->pos[0];
        player->unk_258[0x1E + arg1].unk_000[2] = player->pos[2];
        player->unk_258[0x1E + arg1].unk_020 = -player->rotation[1] + sp28[arg1];
        player->unk_258[0x1E + arg1].unk_018 = random_int(1U) + 2.0f;
        temp_f0 = random_int(4U);
        temp_f0 -= test;
        player->unk_258[0x1E + arg1].unk_014 = temp_f0;
        player->unk_258[0x1E + arg1].unk_000[1] = player->pos[1] + temp_f0;
        player->unk_258[0x1E + arg1].unk_00C = 0.15f;
        player->unk_258[0x1E + arg1].unk_012 = 5;
        player->unk_258[0x1E + arg1].unk_01E = 0;
        player->unk_258[0x1E + arg1].unk_03E = 0x00FF;
        player->unk_258[0x1E + arg1].unk_038 = 0;
    }
}

void func_80061754(Player *player, s16 arg1, UNUSED s32 arg2, UNUSED s32 arg3, UNUSED s32 arg4) {
    s32 sp54;
    s16 temp_s1;
    s32 sp4C;
    f32 sp48;
    f32 sp44;

    sp54 = random_int(0x0168U) - 0xB4;
    sp4C = random_int(6U);
    temp_s1 = random_int(0x0060U);
    sp44 = random_int(6U);
    sp48 = random_int(2U);
    func_8005D794(player, &player->unk_258[0x1E + arg1], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0);
    func_8005D7D8(&player->unk_258[0x1E + arg1], 6, 1.0f);
    if ((player->effects & HIT_BY_ITEM_EFFECT) || ((player->effects) & 0x01000000) || ((player->effects) & 0x400) || ((player->effects) & BOO_EFFECT)) {
        func_8005D800(&player->unk_258[0x1E + arg1], 0x00FFFFFF, 0x00A0);
        player->unk_258[0x1E + arg1].unk_038 -= temp_s1;
        player->unk_258[0x1E + arg1].unk_03A -= temp_s1;
        player->unk_258[0x1E + arg1].unk_03C -= temp_s1;
    } else {
        func_8005D800(&player->unk_258[0x1E + arg1], 0, 0x00A0);
        player->unk_258[0x1E + arg1].unk_038 += temp_s1;
        player->unk_258[0x1E + arg1].unk_03A += temp_s1;
        player->unk_258[0x1E + arg1].unk_03C += temp_s1;
    }
    player->unk_258[0x1E + arg1].unk_000[2] = player->pos[2] + (coss(sp54 * 0xB6) * -5.0f);
    player->unk_258[0x1E + arg1].unk_000[0] = player->pos[0] + (sins(sp54 * 0xB6) * -5.0f);
    player->unk_258[0x1E + arg1].unk_000[1] = (player->pos[1] - player->boundingBoxSize) + sp4C + 2.0f;
    player->unk_258[0x1E + arg1].unk_018 = sp44 + 1.0f;
    player->unk_258[0x1E + arg1].unk_00C = sp48 + 1.0f;
}

void func_8006199C(Player *player, s16 arg1, s32 arg2, s8 arg3, s8 arg4) {
    if ((arg1 == 0) && ((player->unk_258[0x1E + arg2].unk_01E > 0) || (player->unk_258[0x1E + arg2].unk_01C == 0))) {
        func_80061754(player, arg1, arg2, (s32) arg3, arg4);
    } else if (player->unk_258[0x1E + arg2].unk_01E > 0) {
        func_80061754(player, arg1, arg2, (s32) arg3, arg4);
    }
}

void func_80061A34(Player *player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    s32 sp54;
    UNUSED s32 stackPadding0;
    s32 sp4C;
    f32 sp48;
    UNUSED s32 stackPadding1;

    sp54 = random_int(0x0168U) - 0xB4;
    sp4C = random_int(6U);
    random_int(6U);
    sp48 = (f32) random_int(3U);
    if ((arg1 == 0) && ((player->unk_258[0x1E + arg2].unk_01E > 0) || (player->unk_258[0x1E + arg2].unk_01C == 0))) {
        func_8005D794(player, &player->unk_258[0x1E + arg1], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0);
        func_8005D7D8(&player->unk_258[0x1E + arg1], 7, 1.0f);
        func_8005D800(&player->unk_258[0x1E + arg1], 0x00FFFFFF, 0x00FF);
        player->unk_258[0x1E + arg1].unk_000[2] = player->pos[2] + (coss(sp54 * 0xB6) * -2.0);
        player->unk_258[0x1E + arg1].unk_000[0] = player->pos[0] + (sins(sp54 * 0xB6) * -2.0);
        player->unk_258[0x1E + arg1].unk_000[1] = (player->pos[1] - player->boundingBoxSize) + sp4C + 2.0f;
        player->unk_258[0x1E + arg1].unk_00C = (sp48 + 2.0f) / 10.0f;
    } else if (player->unk_258[0x1E + arg2].unk_01E > 0) {
        func_8005D794(player, &player->unk_258[0x1E + arg1], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0);
        func_8005D7D8(&player->unk_258[0x1E + arg1], 7, 1.0f);
        func_8005D800(&player->unk_258[0x1E + arg1], 0x00FFFFFF, 0x00FF);
        player->unk_258[0x1E + arg1].unk_000[2] = player->pos[2] + (coss(sp54 * 0xB6) * -2.0);
        player->unk_258[0x1E + arg1].unk_000[0] = player->pos[0] + (sins(sp54 * 0xB6) * -2.0);
        player->unk_258[0x1E + arg1].unk_000[1] = (player->pos[1] - player->boundingBoxSize) + (f32) sp4C + 2.0f;
        player->unk_258[0x1E + arg1].unk_00C = (sp48 + 2.0f) / 10.0f;
    }
}

void func_80061D4C(Player *player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    s32 test = 2;
    UNUSED s32 stackPadding0;
    UNUSED s32 stackPadding1;
    UNUSED s32 stackPadding2;
    f32 sp20[10] = { -182.0f, 182.0f, 364.0f, -364.0f, 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f };

    if (random_int(3U) == 2.0f) {
        player->unk_258[0x1E + arg1].unk_01C = 1;
        player->unk_258[0x1E + arg1].unk_000[0] = player->pos[0];
        player->unk_258[0x1E + arg1].unk_000[1] = player->pos[1] + 2.0f;
        player->unk_258[0x1E + arg1].unk_000[2] = player->pos[2];
        player->unk_258[0x1E + arg1].unk_020 = -player->rotation[1] + sp20[arg1];
        player->unk_258[0x1E + arg1].unk_018 = random_int(3U) + 2.0f;
        player->unk_258[0x1E + arg1].unk_014 = random_int(4U);
        player->unk_258[0x1E + arg1].unk_014 -= test;
        player->unk_258[0x1E + arg1].unk_00C = 0.4f;
        player->unk_258[0x1E + arg1].unk_012 = 2;
        player->unk_258[0x1E + arg1].unk_01E = 0;
        player->unk_258[0x1E + arg1].unk_03E = 0x00FF;
    }
}

void func_80061EF4(Player *player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    UNUSED s32 stackPadding0;
    s32 var_t0 = 0x000000FF;
    s32 var_t1;
    s32 temp_v1;
    f32 var_f2;
    UNUSED s32 stackPadding1;

    if(1) {};
    temp_v1 = random_int(8U) & 1;
    if (temp_v1 == 1) {
        var_t1 = 1;
        var_t0 = 0;
        var_f2 = player->pos[1];
    }
    if (temp_v1 == 0) {
        var_t1 = 0;
        var_t0 = 0;
        var_f2 = player->pos[1];
    }
    if (var_t0 == 0) {
        if ((arg1 == 0) && ((player->unk_258[0x1E + arg2].unk_01E > 0) || (player->unk_258[0x1E + arg2].unk_01C == 0))) {
            func_8005D794(player, &player->unk_258[0x1E + arg1], 0.0f, var_f2, 0.0f, (s8) var_t0, (s8) var_t1);
            func_8005D7D8(&player->unk_258[0x1E + arg1], 3, 0.5f);
            func_8005D800(&player->unk_258[0x1E + arg1], 0x00FFFFFF, 0x0060);
            player->unk_258[0x1E + arg1].unk_020 = 0;
            if (player->unk_258[0x1E + arg1].unk_010 == 1) {
                player->unk_258[0x1E + arg1].unk_020 += 0x888;
            } else {
                player->unk_258[0x1E + arg1].unk_020 -= 0x888;
            }
            player->unk_258[0x1E + arg1].unk_000[2] = player->pos[2] + (coss(player->unk_258[0x1E + arg1].unk_020 - player->rotation[1] - player->unk_0C0) * 5.0f);
            player->unk_258[0x1E + arg1].unk_000[0] = player->pos[0] + (sins(player->unk_258[0x1E + arg1].unk_020 - player->rotation[1] - player->unk_0C0) * 5.0f);
        } else if (player->unk_258[0x1E + arg2].unk_01E > 0) {
            func_8005D794(player, &player->unk_258[0x1E + arg1], 0.0f, var_f2, 0.0f, (s8) var_t0, (s8) var_t1);
            func_8005D7D8(&player->unk_258[0x1E + arg1], 3, 0.5f);
            func_8005D800(&player->unk_258[0x1E + arg1], 0x00FFFFFF, 0x0060);
            player->unk_258[0x1E + arg1].unk_020 = 0;
            if (player->unk_258[0x1E + arg1].unk_010 == 1) {
                player->unk_258[0x1E + arg1].unk_020 += 0x888;
            } else {
                player->unk_258[0x1E + arg1].unk_020 -= 0x888;
            }
            player->unk_258[0x1E + arg1].unk_000[2] = player->pos[2] + (coss(player->unk_258[0x1E + arg1].unk_020 - player->rotation[1] - player->unk_0C0) * 5.0f);
            player->unk_258[0x1E + arg1].unk_000[0] = player->pos[0] + (sins(player->unk_258[0x1E + arg1].unk_020 - player->rotation[1] - player->unk_0C0) * 5.0f);
        }
    }
}

void func_800621BC(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    s32 temp_v1;
    s32 phi_t0;
    s32 phi_t1;
    Player *new_var;
    f32 phi_f2;
    Player *new_var2;

    phi_t0 = 0xFF;
    temp_v1 = random_int(8) & 1;
    if (temp_v1 == 1) {
        phi_t1 = 1;
        phi_t0 = 0;
        phi_f2 = player->pos[1];
    }

    if (temp_v1 == 0) {
        phi_t1 = 0;
        if (1) {
            phi_t0 = 0;
        }
        phi_f2 = player->pos[1];
    }

    if (phi_t0 == 0) {
        if ((arg1 == 0) && ((player->unk_258[30 + arg2].unk_01E > 0) || (player->unk_258[30 + arg2].unk_01C == 0))) {
            func_8005D794(player, &player->unk_258[30 + arg1], 0.0f, phi_f2, 0.0f, phi_t0, phi_t1);
            func_8005D7D8(&player->unk_258[30 + arg1], 8, 1.0f);
            func_8005D800(&player->unk_258[30 + arg1], 0xFFFF20, 0xFF);

            player->unk_258[30 + arg1].unk_020 = 0;
            if (player->unk_258[30 + arg1].unk_010 == 1) {
                player->unk_258[30 + arg1].unk_020 += 2184;
            } else {
                player->unk_258[30 + arg1].unk_020 -= 2184;
            }

            player->unk_258[30 + arg1].unk_000[2] = player->pos[2] + (coss((player->unk_258[30 + arg1].unk_020 - player->rotation[1]) - player->unk_0C0) * 5.0f);
            player->unk_258[30 + arg1].unk_000[0] = player->pos[0] + (sins((player->unk_258[30 + arg1].unk_020 - player->rotation[1]) - player->unk_0C0) * 5.0f);
            return;
        }

        new_var2 = player;
        if (new_var2->unk_258[30 + arg2].unk_01E > 0) {
            func_8005D794(new_var2, &new_var2->unk_258[30 + arg1], 0.0f, phi_f2, 0.0f, phi_t0, phi_t1);
            func_8005D7D8(&new_var2->unk_258[30 + arg1], 8, 1.0f);
            func_8005D800(&new_var2->unk_258[30 + arg1], 0xFFFF20, 0xFF);
            new_var2->unk_258[30 + arg1].unk_020 = 0;
            if (new_var2->unk_258[30 + arg1].unk_010 == 1) {
                new_var2->unk_258[30 + arg1].unk_020 += 2184;
            } else {
                new_var2->unk_258[30 + arg1].unk_020 -= 2184;
            }

            new_var = new_var2;
            new_var->unk_258[30 + arg1].unk_000[2] = new_var->pos[2] + (coss((new_var->unk_258[30 + arg1].unk_020 - new_var->rotation[1]) - new_var->unk_0C0) * 5.0f);
            new_var->unk_258[30 + arg1].unk_000[0] = new_var->pos[0] + (sins((new_var->unk_258[30 + arg1].unk_020 - new_var->rotation[1]) - new_var->unk_0C0) * 5.0f);
        }
    }
}

void func_80062484(Player* player, UnkPlayerStruct258* arg1, s32 arg2) {
    arg1->unk_01C = 1;
    arg1->unk_000[1] = player->unk_074 + 1.0f;
    arg1->unk_000[2] = player->pos[2];
    arg1->unk_000[0] = player->pos[0];
    arg1->unk_020 = (arg2 * 0x1998) - player->rotation[1];
    arg1->unk_012 = 4;
    arg1->unk_01E = 0;
}

void func_800624D8(Player *player, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UNUSED s8 arg4) {
    s32 var_s1;

    switch (player->surfaceType) {
        case DIRT:
            for (var_s1 = 0; var_s1 < 10; var_s1++) {
                if ((gCurrentCourseId == COURSE_CHOCO_MOUNTAIN) || (gCurrentCourseId == COURSE_ROYAL_RACEWAY)) {
                    func_8005DAD8(&player->unk_258[0x1E + var_s1], 1, 0, 0x00A8);
                }
                if (gCurrentCourseId == COURSE_KALAMARI_DESERT) {
                    func_8005DAD8(&player->unk_258[0x1E + var_s1], 7, 0, 0x00A8);
                }
                if (gCurrentCourseId == COURSE_MOO_MOO_FARM) {
                    func_8005DAD8(&player->unk_258[0x1E + var_s1], 8, 0, 0x00A8);
                }
                if (gCurrentCourseId == COURSE_WARIO_STADIUM) {
                    func_8005DAD8(&player->unk_258[0x1E + var_s1], 9, 0, 0x00A8);
                }
                if (gCurrentCourseId == COURSE_YOSHI_VALLEY) {
                    func_8005DAD8(&player->unk_258[0x1E + var_s1], 0x000A, 0, 0x00A8);
                }
                if (gCurrentCourseId == COURSE_DK_JUNGLE) {
                    func_8005DAD8(&player->unk_258[0x1E + var_s1], 0x000B, 0, 0x00A8);
                }
                func_80062484(player, &player->unk_258[0x1E + var_s1], var_s1);
            }
            player->unk_044 &= ~0x0100;
            break;
        case GRASS:
            for (var_s1 = 0; var_s1 < 10; var_s1++) {
                func_8005DAD8(&player->unk_258[0x1E + var_s1], 2, 1, 0x00A8);
                func_80062484(player, &player->unk_258[0x1E + var_s1], var_s1);
            }
            player->unk_044 &= ~0x0100;
            break;
        case SAND_OFFROAD:
            for (var_s1 = 0; var_s1 < 10; var_s1++) {
                func_8005DAD8(&player->unk_258[0x1E + var_s1], 2, 1, 0x00A8);
                func_80062484(player, &player->unk_258[0x1E + var_s1], var_s1);
            }
            player->unk_044 &= ~0x0100;
            break;
        case SAND:
            for (var_s1 = 0; var_s1 < 10; var_s1++) {
                func_8005DAD8(&player->unk_258[0x1E + var_s1], 3, 1, 0x00A8);
                func_80062484(player, &player->unk_258[0x1E + var_s1], var_s1);
            }
            player->unk_044 &= ~0x0100;
            break;
        case WET_SAND:
            for (var_s1 = 0; var_s1 < 10; var_s1++) {
                func_8005DAD8(&player->unk_258[0x1E + var_s1], 4, 1, 0x00A8);
                func_80062484(player, &player->unk_258[0x1E + var_s1], var_s1);
            }
            player->unk_044 &= ~0x0100;
            break;
        case DIRT_OFFROAD:
            for (var_s1 = 0; var_s1 < 10; var_s1++) {
                func_8005DAD8(&player->unk_258[0x1E + var_s1], 5, 1, 0x00A8);
                func_80062484(player, &player->unk_258[0x1E + var_s1], var_s1);
            }
            player->unk_044 &= ~0x0100;
            break;
        case SNOW:
        case SNOW_OFFROAD:
            for (var_s1 = 0; var_s1 < 10; var_s1++) {
                func_8005DAD8(&player->unk_258[0x1E + var_s1], 6, 1, 0x00A8);
                func_80062484(player, &player->unk_258[0x1E + var_s1], var_s1);
            }
            player->unk_044 &= ~0x0100;
            break;
        case ASPHALT:
        case STONE:
        case BRIDGE:
            for (var_s1 = 0; var_s1 < 10; var_s1++) {
                func_8005DAD8(&player->unk_258[0x1E + var_s1], 0, 0, 0x00A8);
                func_80062484(player, &player->unk_258[0x1E + var_s1], var_s1);
            }
            player->unk_044 &= ~0x0100;
            break;
        default:
            for (var_s1 = 0; var_s1 < 10; var_s1++) {
                func_8005DAD8(&player->unk_258[0x1E + var_s1], 0, 0, 0x00A8);
                func_80062484(player, &player->unk_258[0x1E + var_s1], var_s1);
            }
            player->unk_044 &= ~0x0100;
            break;
    }
}

void func_800628C0(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) {
    player->unk_258[20 + arg3].unk_01C = 1;
    player->unk_258[20 + arg3].unk_020 = -player->rotation[1];
    player->unk_258[20 + arg3].unk_012 = 2;
    player->unk_258[20 + arg3].unk_01E = 0;
    player->unk_258[20 + arg3].unk_00C =  0.2f;
}

void func_80062914(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) {
    player->unk_258[20 + arg3].unk_01C = 1;
    player->unk_258[20 + arg3].unk_020 = -player->rotation[1];
    player->unk_258[20 + arg3].unk_012 = 4;
    player->unk_258[20 + arg3].unk_01E = 0;
    player->unk_258[20 + arg3].unk_00C = 1.0f;
}

void func_80062968(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) {
    player->unk_258[20 + arg3].unk_01C = 1;
    player->unk_258[20 + arg3].unk_020 = -player->rotation[1];
    player->unk_258[20 + arg3].unk_012 = 5;
    player->unk_258[20 + arg3].unk_01E = 0;
    player->unk_258[20 + arg3].unk_00C = 0.2f;
}

void func_800629BC(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) {
    player->unk_258[20 + arg3].unk_01C = 1;
    player->unk_258[20 + arg3].unk_020 = -player->rotation[1];
    player->unk_258[20 + arg3].unk_012 = 6;
    player->unk_258[20 + arg3].unk_01E = 0;
    player->unk_258[20 + arg3].unk_00C = 0.2f;
    player->unk_258[20 + arg3].unk_000[1] = 0.0f;
}

void func_80062A18(Player* player, s8 arg1, UNUSED s8 arg2, s8 arg3) {
    player->unk_258[20 + arg3].unk_01C = 1;
    player->unk_258[20 + arg3].unk_012 = 3;
    player->unk_258[20 + arg1 /* arg1 instead of arg3 */].unk_00C = 0.2f;
    player->unk_258[20 + arg3].unk_01E = 1;
    player->unk_258[20 + arg3].unk_020 = 0;
    player->unk_0B6 &= ~0x0080;
    player->unk_258[20 + arg3].unk_000[2] = player->pos[2];
    player->unk_258[20 + arg3].unk_000[0] = player->pos[0];
    player->unk_258[20 + arg3].unk_000[1] = (player->pos[1] + 4.0f);
}

void func_80062AA8(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) {
    player->unk_258[20 + arg3].unk_01C = 1;
    player->unk_258[20 + arg3].unk_012 = 5;
    player->unk_258[20 + arg3].unk_00C = 0.1f;
    player->unk_258[20 + arg3].unk_01E = 0;
    player->unk_258[20 + arg3].unk_000[1] = (player->pos[1] + player->boundingBoxSize) - 2.5;
}

void func_80062B18(f32 *arg0, f32 *arg1, f32 *arg2, f32 arg3, f32 arg4, f32 arg5, u16 arg6, u16 arg7) {
    UNUSED f32 pad;
    f32 sp30;
    f32 sp2C;
    f32 sp28;
    f32 temp_f20;

    //  Apply the matrix multiplication:
    //  Matrix is the Jacobian for cartesian to spherical coordinates?
    //  Get the change in r, theta, and phi for a change in x, y, z?
    //
    // | arg0 |     | cos(arg6)*cos(arg7)  cos(arg6)*sin(arg7)   -sin(arg6) |     | arg3 |
    // |      |     |                                                       |     |      |
    // | arg1 |  =  | -sin(arg7)           cos(arg7)                 0      |  X  | arg4 |
    // |      |     |                                                       |     |      |
    // | arg2 |     | sin(arg6)*cos(arg7)  sin(arg6)*sin(arg7)    cos(arg6) |     | arg5 |
    //
    sp28 = sins(arg7);
    sp2C = coss(arg6);
    sp30 = coss(arg7);
    temp_f20 = coss(arg6);
    //    = arg3 * cos(arg6) * cos(arg7) + arg4 * cos(arg6) * sin(arg7) - arg5 * sin(arg6)
    *arg0 = (((arg3 * temp_f20) * sp30) + (arg4 * sp2C) * sp28) - (sins(arg6) * arg5);

    temp_f20 = sins(arg7);
    //    = -arg3 * sin(arg7) + arg4 * cos(arg7)
    *arg1 = (coss(arg7) * arg4) - (arg3 * temp_f20);

    sp28 = sins(arg7);
    sp2C = sins(arg6);
    sp30 = coss(arg7);
    temp_f20 = sins(arg6);
    //    = arg3 * sin(arg6) * cos(arg7) + arg4 * sin(arg6) * sin(arg7) + arg5 * cos(arg6)
    *arg2 = (coss(arg6) * arg5) + (((arg3 * temp_f20) * sp30) + ((arg4 * sp2C) * sp28));
}

void func_80062C74(Player *player, s16 arg1, UNUSED s32 arg2, UNUSED s32 arg3) {
    f32 sp48[8] = { 4.5f, 4.5f, 4.5f, 4.5f, 4.5f, 5.5f, 4.5f, 6.5f };
    f32 var_f6;
    f32 sp40;
    f32 sp3C;
    f32 sp38;
    s16 thing;

    player->unk_258[arg1].unk_01E += 1;
    if (player->unk_258[arg1].unk_01E == 0x000C) {
        player->unk_258[arg1].unk_01C = 0;
        player->unk_258[arg1].unk_01E = 0;
        player->unk_258[arg1].unk_012 = 0;
    }
    player->unk_258[arg1].unk_018 = 2.0f;
    if (player->unk_258[arg1].unk_040 == 0) {
        player->unk_258[arg1].unk_00C = player->unk_258[arg1].unk_00C + 0.07;
        player->unk_258[arg1].unk_024 = player->unk_258[arg1].unk_024 + 0.3;
        if (player->unk_258[arg1].unk_01E >= 3) {
            player->unk_258[arg1].unk_03E -= 3;
        }
        if (player->unk_258[arg1].unk_03E <= 0) {
            player->unk_258[arg1].unk_03E = 0;
        }
    } else {
        player->unk_258[arg1].unk_00C = player->unk_258[arg1].unk_00C + 0.1;
        player->unk_258[arg1].unk_024 = player->unk_258[arg1].unk_024 + 0.3;
        if (player->unk_258[arg1].unk_01E >= 3) {
            player->unk_258[arg1].unk_03E -= 2;
        }
        if (player->unk_258[arg1].unk_03E <= 0) {
            player->unk_258[arg1].unk_03E = 0;
        }
    }
    thing = player->unk_258[arg1].unk_020 - (player->unk_0C0 / 2);
    if (player->unk_258[arg1].unk_040 == 0) {
        var_f6 = -((player->unk_098 / 5000.0f) + 0.1);
    } else {
        var_f6 = -((player->unk_098 / 6000.0f) + 0.1);
    }
    if (((player->effects & BOOST_EFFECT) == BOOST_EFFECT) && (player->unk_258[arg1].unk_01E >= 6)) {
        player->unk_258[arg1].unk_00C = player->unk_258[arg1].unk_00C + 0.06;
    }
    player->unk_258[arg1].unk_010++;
    if (player->unk_258[arg1].unk_010 >= 3) {
        player->unk_258[arg1].unk_010 = 0;
    }
    func_80062B18(&sp40, &sp38, &sp3C, 0.0f, sp48[player->characterId], (player->unk_258[arg1].unk_01E * var_f6) + -5.5, -thing, -player->unk_206 * 2);
    player->unk_258[arg1].unk_000[0] = player->pos[0] + sp40;
    sp38 = (player->pos[1] - player->boundingBoxSize) + sp38;
    player->unk_258[arg1].unk_000[2] = player->pos[2] + sp3C;
    player->unk_258[arg1].unk_000[1] = player->unk_258[arg1].unk_024 + sp38;
}

void func_80062F98(Player* player, s16 arg1, s8 arg2, UNUSED s8 arg3) {
    f32 temp_f0;
    
    temp_f0 = player->unk_258[10 + arg1].unk_018 / 10.0f;
    ++player->unk_258[10 + arg1].unk_01E;
    player->unk_258[10 + arg1].unk_000[1] += temp_f0;
    if ((player->unk_0CA & 1) == 1) {
        player->unk_258[10 + arg1].unk_000[1] += (temp_f0 + 0.3);
        if ((player->unk_258[10 + arg1].unk_01E == 0x10) || ((D_801652A0[arg2] - player->unk_258[10 + arg1].unk_000[1]) < 3.0f)) {
            player->unk_258[10 + arg1].unk_01C = 0;
            player->unk_258[10 + arg1].unk_01E = 0;
            player->unk_258[10 + arg1].unk_012 = 0;
        }
    } else if ((player->unk_258[10 + arg1].unk_01E == 0xA) || ((D_801652A0[arg2] - player->unk_258[10 + arg1].unk_000[1]) < 3.0f)) {
        player->unk_258[10 + arg1].unk_01C = 0;
        player->unk_258[10 + arg1].unk_01E = 0;
        player->unk_258[10 + arg1].unk_012 = 0;
    }
}

void func_800630C0(Player* player, s16 arg1, s8 arg2, UNUSED s8 arg3) {
    ++player->unk_258[arg1].unk_01E;
    player->unk_258[arg1].unk_000[2] = player->pos[2] + coss(player->unk_258[arg1].unk_020) * -5.8;
    player->unk_258[arg1].unk_000[0] = player->pos[0] + sins(player->unk_258[arg1].unk_020) * -5.8;
    player->unk_258[arg1].unk_000[1] = D_801652A0[arg2];
    if (player->unk_258[arg1].unk_01E == 15) {
        player->unk_258[arg1].unk_01C = 0;
        player->unk_258[arg1].unk_01E = 0;
        player->unk_258[arg1].unk_012 = 0;
    }
}

void func_800631A8(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    ++player->unk_258[arg1].unk_01E;
    if ((s32) player->unk_258[arg1].unk_01E < 9) {
        if ((player->unk_258[arg1].unk_01E & 1) != 0) {
            player->unk_258[arg1].unk_038 = 8;
        } else {
            player->unk_258[arg1].unk_038 = 0;
        }
    } else if (((player->unk_258[arg1].unk_01E & 1) != 0) || ((player->unk_258[arg1].unk_01E >= 9) && (player->unk_258[arg1].unk_01E < 12))) {
        player->unk_258[arg1].unk_038 = 0xFF;
    } else if ((player->unk_258[arg1].unk_01E & 2) != 0) {
        player->unk_258[arg1].unk_038 = 8;
    } else {
        player->unk_258[arg1].unk_038 = 0;
    }
    player->unk_258[arg1].unk_03A = 0;
    player->unk_258[arg1].unk_03C = 0;
    if ((s32) player->unk_258[arg1].unk_01E >= 0x19) {
        player->unk_258[arg1].unk_01C = 0;
        player->unk_258[arg1].unk_01E = 0;
        player->unk_258[arg1].unk_012 = 0;
    }
}

void func_80063268(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    if (player->unk_258[arg1].unk_01E >= 0x1E) {
        player->unk_258[arg1].unk_040 += 0x1FFE;
    } else {
        player->unk_258[arg1].unk_040 += 0x1554;
    }

    player->unk_258[arg1].unk_024 += 0.25;
    player->unk_258[arg1].unk_000[2] = player->pos[2] + (coss((player->unk_258[arg1].unk_020 + player->unk_258[arg1].unk_040)) * 5.5);
    player->unk_258[arg1].unk_000[0] = player->pos[0] + (sins((player->unk_258[arg1].unk_020 + player->unk_258[arg1].unk_040)) * 5.5);
    player->unk_258[arg1].unk_000[1] = ((player->pos[1] - 5.0f) + player->unk_258[arg1].unk_024);
    ++player->unk_258[arg1].unk_01E;
    player->unk_258[arg1].unk_00C += 0.05;
    player->unk_258[arg1].unk_03E -= 5;

    if ((s32) player->unk_258[arg1].unk_03E <= 0) {
        player->unk_258[arg1].unk_03E = 0;
    }

    if ((s32) player->unk_258[arg1].unk_01E >= 0x28) {
        player->unk_258[arg1].unk_01C = 0;
        player->unk_258[arg1].unk_01E = 0;
        player->unk_258[arg1].unk_012 = 0;
    }
}

void func_80063408(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    if (player->unk_258[10 + arg1].unk_010 == 1) {
        player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + (player->unk_258[10 + arg1].unk_01E * -7) * coss(player->unk_258[10 + arg1].unk_020);
        player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + (player->unk_258[10 + arg1].unk_01E * -7) * sins(player->unk_258[10 + arg1].unk_020);
    } else {
        player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + (player->unk_258[10 + arg1].unk_01E * -7) * coss(player->unk_258[10 + arg1].unk_020);
        player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + (player->unk_258[10 + arg1].unk_01E * -7) * sins(player->unk_258[10 + arg1].unk_020);
    }

    ++player->unk_258[10 + arg1].unk_01E;
    player->unk_258[10 + arg1].unk_000[1] += 1.0f;

    if (((player->effects & 0x80) != 0) || ((player->effects & 0x40) != 0)) {
        player->unk_258[10 + arg1].unk_01C = 0;
        player->unk_258[10 + arg1].unk_01E = 0;
    }

    if (player->unk_258[10 + arg1].unk_01E == 8) {
        player->unk_258[10 + arg1].unk_01E = 0;
        player->unk_258[10 + arg1].unk_01C = 0;
        player->unk_258[10 + arg1].unk_012 = 0;
    }

    player->unk_258[10 + arg1].unk_00C += 0.08;
    if (player->unk_258[10 + arg1].unk_01E >= 4) {
        player->unk_258[10 + arg1].unk_03E -= 16;
    }

    if (player->unk_258[10 + arg1].unk_03E <= 0) {
        player->unk_258[10 + arg1].unk_03E = 0;
    }
}

void func_800635D4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    f32 sp44;
    f32 sp40;
    f32 sp3C;

    if (player->unk_258[10 + arg1].unk_010 == 1) {
        if ((player->effects & LIGHTNING_EFFECT)) {
            func_80062B18(&sp44, &sp40, &sp3C, -2.0f, 0.0f, (-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16, -player->unk_258[10 + arg1].unk_020, 2 * -player->unk_206);
            player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + sp44;
            player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + sp3C;
        } else {
            player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * coss(player->unk_258[10 + arg1].unk_020);
            player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * sins(player->unk_258[10 + arg1].unk_020);
        }
    } else if ((player->effects & LIGHTNING_EFFECT)) {
        func_80062B18(&sp44, &sp40, &sp3C, 2.0f, 0.0f,  (-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16, - player->unk_258[10 + arg1].unk_020,  2 * -player->unk_206);
        player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + sp44;
        player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + sp3C;
    } else {
        player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * coss(player->unk_258[10 + arg1].unk_020);
        player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * sins(player->unk_258[10 + arg1].unk_020);
    }

    ++player->unk_258[10 + arg1].unk_01E;
    player->unk_258[10 + arg1].unk_000[1] += 0.2;
    if (((player->effects & 0x80) != 0) || ((player->effects & 0x40) != 0)) {
        player->unk_258[10 + arg1].unk_01C = 0;
        player->unk_258[10 + arg1].unk_01E = 0;
    }

    if (player->unk_258[10 + arg1].unk_01E == 8) {
        player->unk_258[10 + arg1].unk_01C = 0;
        player->unk_258[10 + arg1].unk_01E = 0;
        player->unk_258[10 + arg1].unk_012 = 0;
    }

    player->unk_258[10 + arg1].unk_00C += 0.1;
    if (player->unk_258[10 + arg1].unk_040 == 0) {
        if (player->unk_258[10 + arg1].unk_01E >= 4) {
            player->unk_258[10 + arg1].unk_03E -= 12;
        }
        if (player->unk_258[10 + arg1].unk_03E <= 0) {
            player->unk_258[10 + arg1].unk_03E = 0;
        }
    } else {
        if (player->unk_258[10 + arg1].unk_01E >= 4) {
            player->unk_258[10 + arg1].unk_03E -= 16;
        }
        if (player->unk_258[10 + arg1].unk_03E <= 0) {
            player->unk_258[10 + arg1].unk_03E = 0;
        }
    }
}

void func_800639DC(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    if (player->unk_258[10 + arg1].unk_010 == 1) {
        player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * coss(player->unk_258[10 + arg1].unk_020);
        player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * sins(player->unk_258[10 + arg1].unk_020);
    } else {
        player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * coss(player->unk_258[10 + arg1].unk_020);
        player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + (-1.8f * player->unk_258[10 + arg1].unk_01E) * sins(player->unk_258[10 + arg1].unk_020);
    }
    ++player->unk_258[10 + arg1].unk_01E;
    player->unk_258[10 + arg1].unk_000[1] += 0.3;
    if (player->unk_258[10 + arg1].unk_01E == 8) {
        player->unk_258[10 + arg1].unk_01C = 0;
        player->unk_258[10 + arg1].unk_01E = 0;
        player->unk_258[10 + arg1].unk_012 = 0;
    }

    player->unk_258[10 + arg1].unk_00C += 0.15;
    if (player->unk_258[10 + arg1].unk_040 == 0) {
        if ((s32) player->unk_258[10 + arg1].unk_01E >= 4) {
            --player->unk_258[10 + arg1].unk_03E;
        }
        if ((s32) player->unk_258[10 + arg1].unk_03E <= 0) {
            player->unk_258[10 + arg1].unk_03E = 0;
        }
    } else {
        if ((s32) player->unk_258[10 + arg1].unk_01E >= 4) {
            player->unk_258[10 + arg1].unk_03E -= 16;
        }
        if ((s32) player->unk_258[10 + arg1].unk_03E <= 0) {

            player->unk_258[10 + arg1].unk_03E = 0;
        }
    }
}

void func_80063BD4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    if (player->unk_258[10 + arg1].unk_010 == 1) {
        player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + (-2 * player->unk_258[10 + arg1].unk_01E * coss(player->unk_258[10 + arg1].unk_020));
        player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + (-2 * player->unk_258[10 + arg1].unk_01E * sins(player->unk_258[10 + arg1].unk_020));
    } else {
        player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + (-2 * player->unk_258[10 + arg1].unk_01E * coss(player->unk_258[10 + arg1].unk_020));
        player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + (-2 * player->unk_258[10 + arg1].unk_01E * sins(player->unk_258[10 + arg1].unk_020));
    }

    ++player->unk_258[10 + arg1].unk_01E;
    player->unk_258[10 + arg1].unk_000[1] += 0.2;
    if (player->unk_258[10 + arg1].unk_01E == 8) {
        player->unk_258[10 + arg1].unk_01C = 0;
        player->unk_258[10 + arg1].unk_01E = 0;
        player->unk_258[10 + arg1].unk_012 = 0;
    }

    player->unk_258[10 + arg1].unk_018 = 2.0f;
    player->unk_258[10 + arg1].unk_00C -= 0.06;
}

void func_80063D58(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    if (player->unk_258[10 + arg1].unk_010 == 1) {
        player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[2].cornerPos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * coss(player->unk_258[10 + arg1].unk_020);
        player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[2].cornerPos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * sins(player->unk_258[10 + arg1].unk_020);
    } else {
        player->unk_258[10 + arg1].unk_000[2] = player->boundingBoxCorners[3].cornerPos[2] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * coss(player->unk_258[10 + arg1].unk_020);
        player->unk_258[10 + arg1].unk_000[0] = player->boundingBoxCorners[3].cornerPos[0] + ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * sins(player->unk_258[10 + arg1].unk_020);
    }

    ++player->unk_258[10 + arg1].unk_01E;
    if (player->unk_258[10 + arg1].unk_01E == 8) {
        player->unk_258[10 + arg1].unk_01E = 0;
        player->unk_258[10 + arg1].unk_01C = 0;
        player->unk_258[10 + arg1].unk_012 = 0;
    }

    player->unk_258[10 + arg1].unk_00C += 0.2;
    if (player->unk_258[10 + arg1].unk_01E >= 4) {
        player->unk_258[10 + arg1].unk_03E -= 18;
        player->unk_258[10 + arg1].unk_000[1] -= 0.1;
    } else {
        player->unk_258[10 + arg1].unk_000[1] += 0.4;
    }
    
    if (player->unk_258[10 + arg1].unk_03E <= 0) {
        player->unk_258[10 + arg1].unk_03E = 0;
    }
}

void func_80063FBC(Player *player, s16 arg1, UNUSED s32 arg2, UNUSED s32 arg3) {
    f32 sp3C;
    f32 sp38;
    f32 sp34;

    if (player->unk_258[10 + arg1].unk_010 == 1) {
        func_80062B18(&sp3C, &sp34, &sp38, 3.0f, 0.0f, -5.5 - (player->unk_258[10 + arg1].unk_01E * (((player->unk_094 / 18.0f) * 216.0f) / 15.0f)), -player->unk_258[10 + arg1].unk_020, 0);
    } else {
        func_80062B18(&sp3C, &sp34, &sp38, -3.0f, 0.0f, -5.5 - (player->unk_258[10 + arg1].unk_01E * (((player->unk_094 / 18.0f) * 216.0f) / 15.0f)), -player->unk_258[10 + arg1].unk_020, 0);
    }
    player->unk_258[10 + arg1].unk_000[0] = player->pos[0] + sp3C;
    player->unk_258[10 + arg1].unk_000[2] = player->pos[2] + sp38;
    player->unk_258[10 + arg1].unk_000[1] = (player->pos[1] - player->boundingBoxSize) + sp34;
    player->unk_258[10 + arg1].unk_01E++;
    if (player->unk_258[10 + arg1].unk_01E == 6) {
        player->unk_258[10 + arg1].unk_01C = 0;
        player->unk_258[10 + arg1].unk_01E = 0;
        player->unk_258[10 + arg1].unk_012 = 0;
    }
}

void func_80064184(Player* player, s16 arg1, s8 arg2, UNUSED s8 arg3) {
    f32 sp44;
    f32 sp40;
    f32 sp3C;

    sp40 = D_801652A0[arg2] - player->pos[1] - 3.0f;
    if (((player->unk_0DE & 1) != 0) && (gCurrentCourseId != COURSE_KOOPA_BEACH)) {
        sp40 = D_801652A0[arg2] - player->pos[1] + 0.1;
    }

    func_80062B18(&sp44, &sp40, &sp3C, 0.0f, sp40, -4.0f + ((-player->unk_258[arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 10.0f), -player->unk_258[arg1].unk_020, 2 * -player->unk_206);
    player->unk_258[arg1].unk_000[0] = player->pos[0] + sp44;
    player->unk_258[arg1].unk_000[2] = player->pos[2] + sp3C;
    player->unk_258[arg1].unk_000[1] = player->pos[1] + sp40;
    ++player->unk_258[arg1].unk_01E;
    if ((player->unk_258[arg1].unk_01E == 12) || (D_801652A0[arg2] <= (player->pos[1] - player->boundingBoxSize))) {
        player->unk_258[arg1].unk_01C = 0;
        player->unk_258[arg1].unk_01E = 0;
        player->unk_258[arg1].unk_012 = 0;
    }
    player->unk_258[arg1].unk_018 = 2.0f;
    player->unk_258[arg1].unk_00C -= 0.35;
    if (player->unk_258[arg1].unk_00C < 0.0f) {
        player->unk_258[arg1].unk_00C = 0.0f;
    }

    player->unk_258[arg1].unk_03E -= 22;
    if (player->unk_258[arg1].unk_03E <= 0) {
        player->unk_258[arg1].unk_03E = 0;
    }
}

void func_800643A8(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    player->unk_258[10 + arg1].unk_000[2] = player->pos[2] + (-1.2 * player->unk_258[10 + arg1].unk_01E * coss(player->unk_258[10 + arg1].unk_020));
    player->unk_258[10 + arg1].unk_000[0] = player->pos[0] + (-1.2 * player->unk_258[10 + arg1].unk_01E * sins(player->unk_258[10 + arg1].unk_020));
    player->unk_258[10 + arg1].unk_000[1] = player->unk_258[10 + arg1].unk_000[1] + 0.5;

    ++player->unk_258[10 + arg1].unk_01E;
    if (player->unk_258[10 + arg1].unk_01E == 10) {
        player->unk_258[10 + arg1].unk_01C = 0;
        player->unk_258[10 + arg1].unk_01E = 0;
        player->unk_258[10 + arg1].unk_012 = 0;
    }
    
    player->unk_258[10 + arg1].unk_00C += 0.2;
    player->unk_258[10 + arg1].unk_03E -= 8;
    if (player->unk_258[10 + arg1].unk_03E <= 0) {
        player->unk_258[10 + arg1].unk_03E = 0;
    }
}

void func_800644E8(Player *player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    f32 thing2;
    UNUSED s32 stackPadding0;
    s32 thing;
    UNUSED s32 stackPadding1;

    if (player->unk_258[30 + arg1].unk_01E >= 9) {
        player->unk_258[30 + arg1].unk_01E = 9;
    }
    thing2 = player->unk_258[30 + arg1].unk_024;
    thing = player->unk_258[30 + arg1].unk_01E;
    player->unk_258[30 + arg1].unk_000[2] = player->pos[2] + (coss(player->unk_258[30 + arg1].unk_020) * (-0.7 * thing));
    player->unk_258[30 + arg1].unk_000[0] = player->pos[0] + (sins(player->unk_258[30 + arg1].unk_020) * (-0.7 * thing));
    player->unk_258[30 + arg1].unk_01E++;
    player->unk_258[30 + arg1].unk_000[1] = player->unk_258[30 + arg1].unk_028 + (f32) ((thing * thing2) - (0.2 * (thing * thing)));
    if (player->unk_258[30 + arg1].unk_01E == 0x000A) {
        player->unk_258[30 + arg1].unk_01E = 0;
        player->unk_258[30 + arg1].unk_01C = 0;
        player->unk_258[30 + arg1].unk_012 = 0;
    }
    if (player->unk_258[30 + arg1].unk_01E >= 7) {
        player->unk_258[30 + arg1].unk_03E -= 0x60;
        if (player->unk_258[30 + arg1].unk_03E <= 0) {
            player->unk_258[30 + arg1].unk_03E = 0;
        }
    }
}

void func_80064664(Player *player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    f32 temp_f4;
    UNUSED s32 stackPadding0;
    s32 temp_v1;
    UNUSED s32 stackPadding1;

    temp_v1 = player->unk_258[30 + arg1].unk_01E;
    temp_f4 = player->unk_258[30 + arg1].unk_024;
    player->unk_258[30 + arg1].unk_000[2] = player->pos[2] + (coss(player->unk_258[30 + arg1].unk_020) * (-0.6 * temp_v1));
    player->unk_258[30 + arg1].unk_000[0] = player->pos[0] + (sins(player->unk_258[30 + arg1].unk_020) * (-0.6 * temp_v1));
    player->unk_258[30 + arg1].unk_01E++;
    player->unk_258[30 + arg1].unk_000[1] = player->unk_258[30 + arg1].unk_028 + (f32) ((temp_v1 * temp_f4) - (0.1 * (temp_v1 * temp_v1)));
    if (player->unk_258[30 + arg1].unk_01E == 0x0019) {
        player->unk_258[30 + arg1].unk_01E = 0;
        player->unk_258[30 + arg1].unk_01C = 0;
        player->unk_258[30 + arg1].unk_012 = 0;
    }
    if (player->unk_258[30 + arg1].unk_01E >= 7) {
        player->unk_258[30 + arg1].unk_03E -= 0x6;
        if (player->unk_258[30 + arg1].unk_03E <= 0) {
            player->unk_258[30 + arg1].unk_03E = 0;
        }
    }
}

void func_800647C8(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {

    ++player->unk_258[30 + arg1].unk_01E;
    player->unk_258[30 + arg1].unk_000[2] = player->pos[2] + ((-0.8 * (player->unk_258[30 + arg1].unk_01E)) * coss(player->unk_258[30 + arg1].unk_020));
    player->unk_258[30 + arg1].unk_000[0] = player->pos[0] + ((-0.8 * (player->unk_258[30 + arg1].unk_01E)) * sins(player->unk_258[30 + arg1].unk_020));
    player->unk_258[30 + arg1].unk_000[1] =  (player->unk_074 + 2.0f);

    if (player->unk_258[30 + arg1].unk_01E == 14) {
        player->unk_258[30 + arg1].unk_01C = 0;
        player->unk_258[30 + arg1].unk_01E = 0;
        player->unk_258[30 + arg1].unk_012 = 0;
    }

    player->unk_258[30 + arg1].unk_03E -= 12;
    if (player->unk_258[30 + arg1].unk_03E <= 0) {
       player->unk_258[30 + arg1].unk_03E = 0;
    }
}

void func_800648E4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    ++player->unk_258[30 + arg1].unk_01E;
    player->unk_258[30 + arg1].unk_00C -=  0.06;
    player->unk_258[30 + arg1].unk_000[1] += 0.1;
    player->unk_258[30 + arg1].unk_03E -= 12;
    
    if (player->unk_258[30 + arg1].unk_03E <= 0) {
        player->unk_258[30 + arg1].unk_03E = 0;
    }
    
    if (player->unk_258[30 + arg1].unk_01E == 10) {
        player->unk_258[30 + arg1].unk_01C = 0;
        player->unk_258[30 + arg1].unk_01E = 0;
        player->unk_258[30 + arg1].unk_012 = 0;
    }
}

void func_80064988(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    ++player->unk_258[30 + arg1].unk_01E;
    player->unk_258[30 + arg1].unk_000[1] -= 0.3;

    if (player->unk_258[30 + arg1].unk_01E == 10) {
        player->unk_258[30 + arg1].unk_01C = 0;
        player->unk_258[30 + arg1].unk_01E = 0;
        player->unk_258[30 + arg1].unk_012 = 0;
    }
}

void func_800649F4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    f32 temp;
    temp = player->unk_258[30 + arg1].unk_018;
   
    player->unk_258[30 + arg1].unk_000[2] = player->unk_21C + (((-temp) * player->unk_258[30 + arg1].unk_01E) * coss(player->unk_258[30 + arg1].unk_020));
    player->unk_258[30 + arg1].unk_000[0] = player->unk_218 + (((-temp) * player->unk_258[30 + arg1].unk_01E) * sins(player->unk_258[30 + arg1].unk_020));
    player->unk_258[30 + arg1].unk_000[1] = player->pos[1] + player->unk_258[30 + arg1].unk_014;
    player->unk_258[30 + arg1].unk_00C += 0.04;

    ++player->unk_258[30 + arg1].unk_01E;
    if (player->unk_258[30 + arg1].unk_01E == 12) {
        player->unk_258[30 + arg1].unk_01E = 0;
        player->unk_258[30 + arg1].unk_01C = 0;
        player->unk_258[30 + arg1].unk_012 = 0;
    }
    
    if (player->unk_258[30 + arg1].unk_01E >= 9) {
        player->unk_258[30 + arg1].unk_03E -= 0x10;
        if (player->unk_258[30 + arg1].unk_03E <= 0) {
            player->unk_258[30 + arg1].unk_03E = 0;
        }
    }
}

void func_80064B30(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {
    f32 temp;
    temp = player->unk_258[30 + arg1].unk_018 * 1.2;

    player->unk_258[30 + arg1].unk_000[2] = (player->pos[2] + (-temp * player->unk_258[30 + arg1].unk_01E) * (coss(player->unk_258[30 + arg1].unk_020)));
    player->unk_258[30 + arg1].unk_000[0] = (player->pos[0] + (-temp * player->unk_258[30 + arg1].unk_01E) * (sins(player->unk_258[30 + arg1].unk_020)));
    player->unk_258[30 + arg1].unk_000[1] += 0.1;

    ++player->unk_258[30 + arg1].unk_01E;
    if (player->unk_258[30 + arg1].unk_01E == 10) {
        player->unk_258[30 + arg1].unk_01E = 0;
        player->unk_258[30 + arg1].unk_01C = 0;
        player->unk_258[30 + arg1].unk_012 = 0;
    }
    
    player->unk_258[30 + arg1].unk_038 += 1820;
    if (player->unk_258[30 + arg1].unk_01E >= 6) {
        player->unk_258[30 + arg1].unk_03E -= 16;
        if (player->unk_258[30 + arg1].unk_03E <= 0) {
            player->unk_258[30 + arg1].unk_03E = 0;
        }
    }
}

void func_80064C74(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) {

    if (player->unk_258[30 + arg1].unk_010 == 1) {
        player->unk_258[30 + arg1].unk_020 += 2184;
    } else {
        player->unk_258[30 + arg1].unk_020 -= 2184;
    }
    
    player->unk_258[30 + arg1].unk_000[2] = player->pos[2] + (coss(player->unk_258[30 + arg1].unk_020 - player->rotation[1] - player->unk_0C0) * 5.0f);
    player->unk_258[30 + arg1].unk_000[0] = player->pos[0] + (sins(player->unk_258[30 + arg1].unk_020 - player->rotation[1] - player->unk_0C0) * 5.0f);
    player->unk_258[30 + arg1].unk_000[1] = player->pos[1] - 1.0f;
    player->unk_258[30 + arg1].unk_00C += 0.4;
    ++player->unk_258[30 + arg1].unk_01E;

    if (player->unk_258[30 + arg1].unk_01E == 10) {
        player->unk_258[30 + arg1].unk_01E = 0;
        player->unk_258[30 + arg1].unk_01C = 0;
        player->unk_258[30 + arg1].unk_012 = 0;
    }
    if (player->unk_258[30 + arg1].unk_01E >= 5) {
        player->unk_258[30 + arg1].unk_03E -= 20;
        if (player->unk_258[30 + arg1].unk_03E <= 0) {
            player->unk_258[30 + arg1].unk_03E = 0;
        }
    }
}

void func_80064DEC(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) {

    player->unk_258[20 + arg3].unk_000[1] = player->pos[1];
    ++player->unk_258[20 + arg3].unk_01E;
    
    if (player->unk_258[20 + arg3].unk_01E == 9) {
        player->unk_0B6 &= ~0x0040;
        player->unk_258[20 + arg3].unk_01C = 0;
        player->unk_258[20 + arg3].unk_01E = 0;
        player->unk_258[20 + arg3].unk_012 = 0;
    }
    
    player->unk_258[20 + arg3].unk_00C += 0.8;
    if (player->unk_258[20 + arg3].unk_00C >= (f64) 2.5) {
        player->unk_258[20 + arg3].unk_00C = 2.5f;
    }
}

void func_80064EA4(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) {
    ++player->unk_258[20 + arg3].unk_01E;
    if (player->unk_258[20 + arg3].unk_01E < 4) {
        player->unk_258[20 + arg3].unk_00C += 1.2;
        if (player->unk_258[20 + arg3].unk_00C >= 3.5) {
            player->unk_258[20 + arg3].unk_00C = 3.5f;
        }
    } else {
        player->unk_258[20 + arg3].unk_00C -= 1.8;
        if (player->unk_258[20 + arg3].unk_00C <= 0.0f) {
            player->unk_0B6 &= ~0x1000;
            player->unk_258[20 + arg3].unk_01C = 0;
            player->unk_258[20 + arg3].unk_01E = 0;
            player->unk_258[20 + arg3].unk_012 = 0;
        }
    }
}

void func_80064F88(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) {
    ++player->unk_258[20 + arg3].unk_01E;
    player->unk_258[20 + arg3].unk_00C += 0.15;
    
    if (1.2 <= player->unk_258[20 + arg3].unk_00C) {
        player->unk_258[20 + arg3].unk_00C = 1.2f;
    }
    if (player->unk_258[20 + arg3].unk_01E >= 12) {
        player->unk_0B6 &= ~0x0800;
        player->unk_258[20 + arg3].unk_01C = 0;
        player->unk_258[20 + arg3].unk_01E = 0;
        player->unk_258[20 + arg3].unk_012 = 0;
    }
}

void func_80065030(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) {
    ++player->unk_258[20 + arg3].unk_01E;

    player->unk_258[20 + arg3].unk_000[1] += 0.8;
    player->unk_258[20 + arg3].unk_00C += 0.4;
    if (player->unk_258[20 + arg3].unk_00C >= (f64) 1.5) {
        player->unk_258[20 + arg3].unk_00C = 1.5f;
    }
    
    if (player->unk_258[20 + arg3].unk_01E >= 12) {
        player->unk_0B6 &= ~0x0100;
        player->unk_258[20 + arg3].unk_01C = 0;
        player->unk_258[20 + arg3].unk_01E = 0;
        player->unk_258[20 + arg3].unk_012 = 0;
    }
}

void func_800650FC(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) {
    player->unk_258[20 + arg3].unk_000[2] = (f32) player->pos[2];
    player->unk_258[20 + arg3].unk_000[0] = (f32) player->pos[0];
    player->unk_258[20 + arg3].unk_000[1] = (f32) (player->pos[1] + 4.0f);
    if ((player->effects & 0x80) == 0x80) {
        player->unk_258[20 + arg3].unk_020 += 4732;
    } else {
         player->unk_258[20 + arg3].unk_020 -= 4732;
    }

    if (((player->effects & 0x80) != 0x80) && ((player->effects & 0x40) != 0x40)) {
        player->unk_258[20 + arg3].unk_01C = 0;
        player->unk_258[20 + arg3].unk_01E = 0;
        player->unk_258[20 + arg3].unk_012 = 0;
    }

    player->unk_258[20 + arg3].unk_00C += 0.08;
    if (player->unk_258[20 + arg3].unk_00C >= 1.5) {
        player->unk_258[20 + arg3].unk_00C = 1.5f;
    }
}

void func_800651F4(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) {
    ++player->unk_258[20 + arg3].unk_01E;
    if (player->unk_258[20 + arg3].unk_01E < 8) {
        player->unk_258[20 + arg3].unk_00C += 0.2;
        if (1.2 <= player->unk_258[20 + arg3].unk_00C) {
            player->unk_258[20 + arg3].unk_00C = 1.2f;
        }
    } else {
        player->unk_258[20 + arg3].unk_00C -= 0.4;
        if (player->unk_258[20 + arg3].unk_00C <= 0.0f) {
            player->unk_0B6 &= ~0x0020;
            player->unk_258[20 + arg3].unk_01C = 0;
            player->unk_258[20 + arg3].unk_01E = 0;
            player->unk_258[20 + arg3].unk_012 = 0;
        }
    }
}

void func_800652D4(Vec3f arg0, Vec3s arg1, f32 arg2) {
    Mat4 sp20;

    mtxf_translate_rotate(sp20, arg0, arg1);
    mtxf_scale2(sp20, arg2);
    convert_to_fixed_point_matrix(&gGfxPool->mtxEffect[gMatrixEffectCount], sp20);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxEffect[gMatrixEffectCount]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
}

void func_8006538C(Player *player, s8 arg1, s16 arg2, s8 arg3) {
    Vec3f spB4;
    Vec3s spAC;
    s32 primColors[] = { MAKE_RGB(0xFB, 0xFF, 0xFB), MAKE_RGB(0xFF, 0xFB, 0x86) };
    s32 envColors[]  = { MAKE_RGB(0x89, 0x62, 0x8F), MAKE_RGB(0xFE, 0x01, 0x09) };
    s16 primRed;
    s16 primGreen;
    s16 primBlue;
    s16 primAlpha;
    s16 envRed;
    s16 envGreen;
    s16 envBlue;

    if (player->unk_258[arg2].unk_01C == 1) {
        spB4[0] = player->unk_258[arg2].unk_000[0];
        spB4[1] = player->unk_258[arg2].unk_000[1];
        spB4[2] = player->unk_258[arg2].unk_000[2];
        spAC[0] = 0;
        spAC[1] = player->unk_048[arg3];
        spAC[2] = 0;
        if ((player->effects & STAR_EFFECT) && (((s32) gCourseTimer - D_8018D930[arg1]) < 9)) {
            primRed   = (primColors[1] >> 0x10) & 0xFF;
            primGreen = (primColors[1] >> 0x08) & 0xFF;
            primBlue  = (primColors[1] >> 0x00) & 0xFF;
            envRed    = ( envColors[1] >> 0x10) & 0xFF;
            envGreen  = ( envColors[1] >> 0x08) & 0xFF;
            envBlue   = ( envColors[1] >> 0x00) & 0xFF;
            primAlpha = player->unk_258[arg2].unk_03E;
            func_800652D4(spB4, spAC, ((player->unk_258[arg2].unk_00C * player->size) * 1.4));
            gSPDisplayList(gDisplayListHead++, D_0D008DB8);
            gDPLoadTextureBlock(gDisplayListHead++, common_texture_particle_smoke[player->unk_258[arg2].unk_010], G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            func_8004B72C(primRed, primGreen, primBlue, envRed, envGreen, envBlue, primAlpha);
            gDPSetAlphaCompare(gDisplayListHead++, G_AC_DITHER);
            gSPDisplayList(gDisplayListHead++, D_0D008E48);
        } else {
            primRed   = (primColors[player->unk_258[arg2].unk_038] >> 0x10) & 0xFF;
            primGreen = (primColors[player->unk_258[arg2].unk_038] >> 0x08) & 0xFF;
            primBlue  = (primColors[player->unk_258[arg2].unk_038] >> 0x00) & 0xFF;
            envRed    = ( envColors[player->unk_258[arg2].unk_038] >> 0x10) & 0xFF;
            envGreen  = ( envColors[player->unk_258[arg2].unk_038] >> 0x08) & 0xFF;
            envBlue   = ( envColors[player->unk_258[arg2].unk_038] >> 0x00) & 0xFF;
            primAlpha = player->unk_258[arg2].unk_03E;
            func_800652D4(spB4, spAC, player->unk_258[arg2].unk_00C * player->size);
            gSPDisplayList(gDisplayListHead++, D_0D008DB8);
            gDPLoadTextureBlock(gDisplayListHead++, common_texture_particle_smoke[player->unk_258[arg2].unk_010], G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            func_8004B72C(primRed, primGreen, primBlue, envRed, envGreen, envBlue, primAlpha);
            gSPDisplayList(gDisplayListHead++, D_0D008E48);
        }
        gMatrixEffectCount += 1;
    }
}

void func_800658A0(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp54;
    Vec3s sp4C;
    s16 red;
    s16 green;
    s16 blue;
    s16 alpha;

    if (player->unk_258[arg2].unk_01C == 1) {
        red = player->unk_258[arg2].unk_038;
        green = player->unk_258[arg2].unk_03A;
        blue = player->unk_258[arg2].unk_03C;
        alpha = player->unk_258[arg2].unk_03E;
        sp54[0] = player->unk_258[arg2].unk_000[0];
        sp54[1] = player->unk_258[arg2].unk_000[1];
        sp54[2] = player->unk_258[arg2].unk_000[2];
        sp4C[0] = 0;
        sp4C[1] = player->unk_048[arg3];
        sp4C[2] = 0;
        func_800652D4(sp54, sp4C, player->unk_258[arg2].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008DB8);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D48C, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B35C(red, green, blue, alpha);
        gSPDisplayList(gDisplayListHead++, D_0D008E48);
        gMatrixEffectCount += 1;
    }
}

#ifdef NON_MATCHING
// Something about the handling of the prim/env colors is off,
// its causing a huge diff. Can't figure out what's up.
void func_80065AB0(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f spB4;
    Vec3s spAC;
    s32 var_s0;
    s16 primRed;
    s16 primGreen;
    s16 primBlue;
    s16 primAlpha;
    s16 envRed;
    s16 envGreen;
    s16 envBlue;
    s32 envColors[] = { MAKE_RGB(0xFF, 0xFF, 0xFF), MAKE_RGB(0xFF, 0xFF, 0x00), MAKE_RGB(0xFF, 0x96, 0x00) };

    if (player->unk_258[10 + arg2].unk_01C == 1) {
        if (player->unk_204 >= 0x32) {
            var_s0 = 1;
        } else {
            var_s0 = 0;
        }
        primRed   = player->unk_258[10 + arg2].unk_038;
        primGreen = player->unk_258[10 + arg2].unk_03A;
        primBlue  = player->unk_258[10 + arg2].unk_03C;
        primAlpha = player->unk_258[10 + arg2].unk_03E;
        envRed    = (envColors[player->unk_258[10 + arg2].unk_040] >> 0x10) & 0xFF;
        envGreen  = (envColors[player->unk_258[10 + arg2].unk_040] >> 0x08) & 0xFF;
        envBlue   = (envColors[player->unk_258[10 + arg2].unk_040] >> 0x00) & 0xFF;
        spB4[0] = player->unk_258[10 + arg2].unk_000[0];
        spB4[1] = player->unk_258[10 + arg2].unk_000[1];
        spB4[2] = player->unk_258[10 + arg2].unk_000[2];
        spAC[0] = 0;
        spAC[1] = player->unk_048[arg3];
        spAC[2] = 0;
        func_800652D4(spB4, spAC, player->unk_258[10 + arg2].unk_00C * player->size);
        if (var_s0 == 0) {
            gSPDisplayList(gDisplayListHead++, D_0D008DB8);
            gDPLoadTextureBlock(gDisplayListHead++, D_800E4770[var_s0], G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            func_8004B72C(primRed, primGreen, primBlue, envRed, envGreen, envBlue, primAlpha);
            gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2);
            gSPDisplayList(gDisplayListHead++, D_0D008DF8);
        } else {
            gSPDisplayList(gDisplayListHead++, D_0D008DB8);
            gDPLoadTextureBlock(gDisplayListHead++, D_800E4770[var_s0], G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            func_8004B72C(primRed, primGreen, primBlue, envRed, envGreen, envBlue, primAlpha);
            gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2);
            gSPDisplayList(gDisplayListHead++, D_0D008E48);
        }
        gMatrixEffectCount += 1;
    }
}
#else
GLOBAL_ASM("asm/non_matchings/code_80057C60/func_80065AB0.s")
#endif

#ifdef NON_MATCHING
//https://decomp.me/scratch/KEz08
// Something is very wrong with the handling of prim/evn colors, but I can't figuer out what.
void func_80065F0C(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f spDC;
    Vec3s spD4;
    s16 primRed;
    s16 primGreen;
    s16 primBlue;
    s16 primAlpha;
    u8 envRed;
    s16 envGreen;
    s16 envBlue;

    if ((player->unk_258[10 + arg2].unk_01C == 1) && (player->unk_258[10 + arg2].unk_01E != 0)) {
        spDC[0] = player->unk_258[10 + arg2].unk_000[0];
        spDC[1] = player->unk_258[10 + arg2].unk_000[1];
        spDC[2] = player->unk_258[10 + arg2].unk_000[2];
        spD4[0] = 0;
        spD4[1] = player->unk_048[arg3];
        spD4[2] = 0;
        func_800652D4(spDC, spD4, player->unk_258[10 + arg2].unk_00C * player->size);
        if ((s32)player->unk_258[10 + arg2].unk_014 != 8) {
            primRed   = ((D_800E47DC[player->unk_258[10 + arg2].unk_038] >> 0x10) & 0xFF) - player->unk_258[10 + arg2].unk_03A;
            primGreen = ((D_800E47DC[player->unk_258[10 + arg2].unk_038] >> 0x08) & 0xFF) - player->unk_258[10 + arg2].unk_03A;
            primBlue  = ((D_800E47DC[player->unk_258[10 + arg2].unk_038] >> 0x00) & 0xFF) - player->unk_258[10 + arg2].unk_03A;
            envRed    = ((D_800E480C[player->unk_258[10 + arg2].unk_038] >> 0x10) & 0xFF) - player->unk_258[10 + arg2].unk_03A;
            envGreen  = ((D_800E480C[player->unk_258[10 + arg2].unk_038] >> 0x08) & 0xFF) - player->unk_258[10 + arg2].unk_03A;
            envBlue   = ((D_800E480C[player->unk_258[10 + arg2].unk_038] >> 0x00) & 0xFF) - player->unk_258[10 + arg2].unk_03A;
            primAlpha = player->unk_258[10 + arg2].unk_03E;
            if (player->unk_258[10 + arg2].unk_040 == 0) {
                gSPDisplayList(gDisplayListHead++, D_0D008DB8);
                gDPLoadTextureBlock(gDisplayListHead++, D_8018D494, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
                func_8004B72C(primRed, primGreen, primBlue, envRed, envGreen, envBlue, primAlpha);
                gSPDisplayList(gDisplayListHead++, D_0D008E48);
            } else {
                gSPDisplayList(gDisplayListHead++, D_0D008DB8);
                gDPLoadTextureBlock(gDisplayListHead++, D_8018D494, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
                func_8004B72C(primRed, primGreen, primBlue, envRed, envGreen, envBlue, primAlpha);
                gDPSetAlphaCompare(gDisplayListHead++, G_AC_DITHER);
                gSPDisplayList(gDisplayListHead++, D_0D008E48);
            }
        } else {
            primRed   = player->unk_258[10 + arg2].unk_038;
            primGreen = player->unk_258[10 + arg2].unk_03A;
            primBlue  = player->unk_258[10 + arg2].unk_03C;
            gSPDisplayList(gDisplayListHead++, D_0D008C90);
            gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE);
            gDPLoadTextureBlock(gDisplayListHead++, D_8018D498, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            func_8004B35C(primRed, primGreen, primBlue, 0x000000FF);
            gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2);
            gSPVertex(gDisplayListHead++, D_800E8C00, 4, 0);
            gSPDisplayList(gDisplayListHead++, D_0D008DA0);

        }
        gMatrixEffectCount += 1;
    }
}
#else
GLOBAL_ASM("asm/non_matchings/code_80057C60/func_80065F0C.s")
#endif

void func_800664E0(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp54;
    Vec3s sp4C;
    s16 red;
    s16 green;
    s16 blue;
    s16 alpha;

    if (player->unk_258[10 + arg2].unk_01C == 1) {
        red   = player->unk_258[10 + arg2].unk_038;
        green = player->unk_258[10 + arg2].unk_03A;
        blue  = player->unk_258[10 + arg2].unk_03C;
        alpha = player->unk_258[10 + arg2].unk_03E;
        sp54[0] = player->unk_258[10 + arg2].unk_000[0];
        sp54[1] = player->unk_258[10 + arg2].unk_000[1];
        sp54[2] = player->unk_258[10 + arg2].unk_000[2];
        sp4C[0] = 0;
        sp4C[1] = player->unk_048[arg3];
        sp4C[2] = 0;
        func_800652D4(sp54, sp4C, player->unk_258[10 + arg2].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008DB8);
        gDPSetAlphaCompare(gDisplayListHead++, G_AC_DITHER);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D48C, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B35C(red, green, blue, alpha);
        gSPDisplayList(gDisplayListHead++, D_0D008E48);
        gMatrixEffectCount += 1;
    }
}

void func_80066714(Player *player, UNUSED s32 arg1, s16 arg2, s8 arg3) {
    Vec3f sp5C;
    Vec3s sp54;
    s16 red;
    s16 green;
    s16 blue;
    s16 alpha;

    if (player->unk_258[10 + arg2].unk_01C == 1) {
        red   = player->unk_258[10 + arg2].unk_038;
        green = player->unk_258[10 + arg2].unk_03A;
        blue  = player->unk_258[10 + arg2].unk_03C;
        alpha = player->unk_258[10 + arg2].unk_03E;
        sp5C[0] = player->unk_258[10 + arg2].unk_000[0];
        sp5C[1] = player->unk_258[10 + arg2].unk_000[1];
        sp5C[2] = player->unk_258[10 + arg2].unk_000[2];
        sp54[0] = 0;
        sp54[1] = player->unk_048[arg3];
        sp54[2] = 0;
        func_800652D4(sp5C, sp54, player->unk_258[10 + arg2].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008C90);
        gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE);
        gDPLoadTextureBlock(gDisplayListHead++, common_texture_particle_fire, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B35C(red, green, blue, alpha);
        gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2);
        gSPVertex(gDisplayListHead++, D_800E8B00, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount += 1;
    }
}

void func_80066998(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp54;
    Vec3s sp4C;
    s16 red;
    s16 green;
    s16 blue;
    s16 alpha;

    if (player->unk_258[arg2].unk_01C == 1) {
        red   = player->unk_258[arg2].unk_038;
        green = player->unk_258[arg2].unk_03A;
        blue  = player->unk_258[arg2].unk_03C;
        alpha = player->unk_258[arg2].unk_03E;
        sp54[0] = player->unk_258[arg2].unk_000[0];
        sp54[1] = player->unk_258[arg2].unk_000[1];
        sp54[2] = player->unk_258[arg2].unk_000[2];
        sp4C[0] = 0x4000;
        sp4C[1] = player->unk_048[arg3];
        sp4C[2] = 0;
        func_800652D4(sp54, sp4C, player->unk_258[arg2].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008DB8);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D48C, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B35C(red, green, blue, alpha);
        gSPDisplayList(gDisplayListHead++, D_0D008E48);
        gMatrixEffectCount += 1;
    }
}

void func_80066BAC(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f spDC;
    Vec3s spD4;
    UNUSED s32 stackPadding;

    if ((player->unk_258[arg2].unk_01C == 1) && (player->unk_258[arg2].unk_038 != 0x00FF)) {
        if (player->unk_110.unk3C[2] >= 300.0f) {
            spDC[1] = player->pos[1] + 5.0f;
        } else {
            spDC[1] = player->pos[1] - 3.0f;
        }
        spDC[2] = player->pos[2] + (coss(player->unk_048[arg3]) * -10.0f);
        spDC[0] = player->pos[0] + (sins(player->unk_048[arg3]) * -10.0f);
        if (player->unk_110.unk3C[2] >= 300.0f) {
            spD4[0] = cameras[arg3].rot[0] - 0x4000;
        } else {
            spD4[0] = 0;
        }
        spD4[1] = player->unk_048[arg3];
        spD4[2] = 0;
        func_800652D4(spDC, spD4, player->unk_258[arg2].unk_00C * player->size);
        if (player->unk_258[arg2].unk_038 == 0) {
            gSPDisplayList(gDisplayListHead++, D_0D008DB8);
            gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
            gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
            gDPLoadTextureBlock(gDisplayListHead++, D_8018D4C4, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            gSPVertex(gDisplayListHead++, &D_800E8900[0][player->unk_258[arg2].unk_038], 4, 0);
            gSPDisplayList(gDisplayListHead++, common_square_plain_render);
            gDPLoadTextureBlock(gDisplayListHead++, D_8018D4C8, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            gSPVertex(gDisplayListHead++, &D_800E8900[1][player->unk_258[arg2].unk_038], 4, 0);
            gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        } else {
            gSPDisplayList(gDisplayListHead++, D_0D008DB8);
            gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
            gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
            gDPLoadTextureBlock(gDisplayListHead++, D_8018D4C8, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            gSPVertex(gDisplayListHead++, &D_800E8900[0][player->unk_258[arg2].unk_038], 4, 0);
            gSPDisplayList(gDisplayListHead++, common_square_plain_render);
            gDPLoadTextureBlock(gDisplayListHead++, D_8018D4C4, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            gSPVertex(gDisplayListHead++, &D_800E8900[1][player->unk_258[arg2].unk_038], 4, 0);
            gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        }
        gMatrixEffectCount += 1;
    }
}

void func_80067280(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp7C;
    Vec3s sp74;
    s16 red;
    s16 green;
    s16 blue;
    s16 alpha;

    if (player->unk_258[30 + arg2].unk_01C == 1) {
        red   = player->unk_258[30 + arg2].unk_038;
        green = player->unk_258[30 + arg2].unk_03A;
        blue  = player->unk_258[30 + arg2].unk_03C;
        alpha = player->unk_258[30 + arg2].unk_03E;
        sp7C[0] = player->unk_258[30 + arg2].unk_000[0];
        sp7C[1] = player->unk_258[30 + arg2].unk_000[1];
        sp7C[2] = player->unk_258[30 + arg2].unk_000[2];
        sp74[0] = -0x071C;
        sp74[2] = 0;
        if (player->unk_258[30 + arg2].unk_010 == 1) {
            sp74[1] = player->unk_048[arg3] - 0x2000;
            func_800652D4(sp7C, sp74, player->unk_258[30 + arg2].unk_00C * player->size);
            gSPDisplayList(gDisplayListHead++, D_0D008DB8);
            gDPLoadTextureBlock(gDisplayListHead++, D_8018D48C, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            func_8004B35C(red, green, blue, alpha);
            gSPDisplayList(gDisplayListHead++, D_0D008E70);
        } else {
            sp74[1] = player->unk_048[arg3] + 0x2000;
            func_800652D4(sp7C, sp74, player->unk_258[30 + arg2].unk_00C * player->size);
            gSPDisplayList(gDisplayListHead++, D_0D008DB8);
            gDPLoadTextureBlock(gDisplayListHead++, D_8018D48C, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            func_8004B35C(red, green, blue, alpha & 0xFFFFFFFF); // huh?
            gSPDisplayList(gDisplayListHead++, D_0D008E48);
        }
        gMatrixEffectCount += 1;
    }
}

void func_80067604(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp8C;
    Vec3s sp84;
    UNUSED s32 stackPadding[4];

    if (player->unk_258[30 + arg2].unk_01C == 1) {
        sp8C[0] = player->unk_258[30 + arg2].unk_000[0];
        sp8C[1] = player->unk_258[30 + arg2].unk_000[1];
        sp8C[2] = player->unk_258[30 + arg2].unk_000[2];
        sp84[0] = 0;
        sp84[1] = player->unk_048[arg3];
        sp84[2] = 0;
        func_800652D4(sp8C, sp84, player->unk_258[30 + arg2].unk_00C * player->size);
        if (player->unk_258[30 + arg2].unk_010 == 1) {
            gSPDisplayList(gDisplayListHead++, D_0D008DB8);
            gDPLoadTextureBlock(gDisplayListHead++, common_texture_particle_spark, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            func_8004B72C(0x000000FF, 0x000000FF, 0x000000DF, 0x000000FF, 0x0000005F, 0, 0x00000060);
            gSPDisplayList(gDisplayListHead++, D_0D008E70);
        } else {
            gSPDisplayList(gDisplayListHead++, D_0D008DB8);
            gDPLoadTextureBlock(gDisplayListHead++, common_texture_particle_spark, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
            func_8004B72C(0x000000FF, 0x000000FF, 0x000000DF, 0x000000FF, 0x0000005F, 0, 0x00000060);
            gSPDisplayList(gDisplayListHead++, D_0D008E48);
        }
        gMatrixEffectCount += 1;
    }
}

void func_80067964(Player *player, UNUSED s8 arg1, f32 arg2, UNUSED s8 arg3, s8 arg4) {
    Vec3f sp9C;
    Vec3s sp94;
    UNUSED s32 stackPadding[2];

    if (player->unk_258[20 + arg4].unk_01C == 1) {
        sp9C[0] = player->unk_258[20 + arg4].unk_000[0];
        sp9C[1] = player->unk_258[20 + arg4].unk_000[1];
        sp9C[2] = player->unk_258[20 + arg4].unk_000[2];
        sp94[0] = 0;
        sp94[1] = player->unk_258[20 + arg4].unk_020;
        sp94[2] = 0;
        func_800652D4(sp9C, sp94, player->size * arg2);
        gSPDisplayList(gDisplayListHead++, D_0D008C90);
        gSPClearGeometryMode(gDisplayListHead++, G_CULL_BOTH);
        gDPLoadTLUT_pal256(gDisplayListHead++, D_800E52D0);
        gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D4AC, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        gSPVertex(gDisplayListHead++, D_800E8840, 4, 0);
        gSPDisplayList(gDisplayListHead++, common_square_plain_render);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D4B0, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        gSPVertex(gDisplayListHead++, D_800E8800, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount += 1;
    }
}

void func_80067D3C(Player *player, s8 arg1, u8 *texture, s8 arg3, f32 arg4, s32 arg5) {
    Vec3f sp7C;
    Vec3s sp74;
    f32 sp54[8] = { 0.0f, -1.2f, 0.1f, 1.2f, -1.7f, -0.8f, -0.2f, -1.9f };
    // ????????????????????????????????????????
    s16 red   = ((arg5 >> 0x10) & 0xFF) & 0xFF;
    s16 green = ((arg5 >> 0x08) & 0xFF) & 0xFF;
    s16 blue  = ((arg5 >> 0x00) & 0xFF) & 0xFF;
    // ????????????????????????????????????????

    if (player->unk_258[20 + arg3].unk_01C == 1) {
        sp74[0] = 0;
        sp74[1] = player->unk_048[arg1];
        sp74[2] = 0;
        sp7C[0] = player->pos[0] + (sins((0x4000 & 0xFFFFFFFF) - (player->rotation[1] + player->unk_0C0)) * arg4);
        sp7C[1] = player->pos[1] + player->boundingBoxSize - sp54[player->characterId] - 2.0f;
        sp7C[2] = player->pos[2] + (coss((0x4000 & 0xFFFFFFFF) - (player->rotation[1] + player->unk_0C0)) * arg4);
        func_800652D4(sp7C, sp74, player->unk_258[20 + arg3].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008DB8);
        gDPLoadTextureBlock(gDisplayListHead++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);

        func_8004B414(red, green, blue, 0x000000FF);
        gSPDisplayList(gDisplayListHead++, D_0D008E20);
        gMatrixEffectCount += 1;
    }
}

void func_8006801C(Player *player, s8 arg1, u8 *texture, s8 arg3, f32 arg4, s32 arg5) {
    Vec3f sp7C;
    Vec3s sp74;
    f32 sp54[8] = { -0.7f, -1.9f, -0.6f, 0.4f, -2.5f, -1.6f, -0.95f, -2.7f };
    // ????????????????????????????????????????
    s16 red   = ((arg5 >> 0x10) & 0xFF) & 0xFF;
    s16 green = ((arg5 >> 0x08) & 0xFF) & 0xFF;
    s16 blue  = ((arg5 >> 0x00) & 0xFF) & 0xFF;
    // ????????????????????????????????????????

    if (player->unk_258[20 + arg3].unk_01C == 1) {
        sp74[0] = 0;
        sp74[1] = player->unk_048[arg1];
        sp74[2] = 0;
        sp7C[0] = player->pos[0] + (sins((0x4000 & 0xFFFFFFFF) - (player->rotation[1] + player->unk_0C0)) * arg4);
        sp7C[1] = player->pos[1] + player->boundingBoxSize - sp54[player->characterId] - 2.0f;
        sp7C[2] = player->pos[2] + (coss((0x4000 & 0xFFFFFFFF) - (player->rotation[1] + player->unk_0C0)) * arg4);
        func_800652D4(sp7C, sp74, player->unk_258[20 + arg3].unk_00C * player->size * 0.8);
        gSPDisplayList(gDisplayListHead++, D_0D008DB8);
        gDPLoadTextureBlock(gDisplayListHead++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);

        func_8004B414(red, green, blue, 0x000000FF);
        gSPDisplayList(gDisplayListHead++, D_0D008E20);
        gMatrixEffectCount += 1;
    }
}

void func_80068310(Player *player, UNUSED s8 arg1, UNUSED f32 arg2, s8 arg3, s8 arg4) {
    UNUSED s32 stackPadding[16]; // huh?
    Vec3f sp9C;
    Vec3s sp94;

    if (player->unk_258[20 + arg4].unk_01C == 1) {
        sp9C[1] = player->unk_258[20 + arg4].unk_000[1];
        sp9C[2] = player->pos[2] + (coss(player->unk_048[arg3]) * -10.0f);
        sp9C[0] = player->pos[0] + (sins(player->unk_048[arg3]) * -10.0f);
        sp94[0] = 0;
        sp94[1] = player->unk_048[arg3];
        sp94[2] = 0;
        func_800652D4(sp9C, sp94, player->unk_258[20 + arg4].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008C90);
        gDPLoadTLUT_pal256(gDisplayListHead++, D_800E52D0);
        gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D4B4, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        gSPVertex(gDisplayListHead++, D_800E8880, 4, 0);
        gSPDisplayList(gDisplayListHead++, common_square_plain_render);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D4B8, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        gSPVertex(gDisplayListHead++, D_800E88C0, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount += 1;
    }
}

void func_80068724(Player *player, UNUSED s8 arg1, UNUSED f32 arg2, s8 arg3, s8 arg4) {
    UNUSED s32 stackPadding[16]; // huh?
    Vec3f sp84;
    Vec3s sp7C;

    if (player->unk_258[20 + arg4].unk_01C == 1) {
        sp84[1] = player->pos[1] - 3.0f;
        sp84[2] = player->pos[2] + (coss(player->unk_048[arg3]) * -10.0f);
        sp84[0] = player->pos[0] + (sins(player->unk_048[arg3]) * -10.0f);
        sp7C[0] = 0;
        sp7C[1] = player->unk_048[arg3];
        sp7C[2] = 0;
        func_800652D4(sp84, sp7C, player->unk_258[20 + arg4].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008DB8);
        gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
        gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D4C4, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        gSPVertex(gDisplayListHead++, D_800E8A00, 4, 0);
        gSPDisplayList(gDisplayListHead++, common_square_plain_render);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D4C8, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        gSPVertex(gDisplayListHead++, D_800E8A40, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount += 1;
    }
}

void func_80068AA4(Player *player, UNUSED s8 arg1, UNUSED f32 arg2, s8 arg3, s8 arg4) {
    Vec3f sp64;
    Vec3s sp5C;

    if ((player->unk_258[20 + arg4].unk_01C == 1) && (player->animFrameSelector[arg3] < 0xD)) {
        sp64[1] = player->pos[1] - 3.0f;
        sp64[2] = player->pos[2] + ((-2.5 * player->unk_258[20 + arg4].unk_01E) * coss(player->unk_048[arg3]));
        sp64[0] = player->pos[0] + ((-2.5 * player->unk_258[20 + arg4].unk_01E) * sins(player->unk_048[arg3]));
        sp5C[0] = 0;
        sp5C[1] = player->unk_048[arg3];
        sp5C[2] = 0;
        func_800652D4(sp64, sp5C, player->unk_258[20 + arg4].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008D58);
        gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D4A0, G_IM_FMT_IA, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B35C(0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF);
        gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
        gSPVertex(gDisplayListHead++, D_800E8B40, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount += 1;
    }
}

void func_80068DA0(Player *player, UNUSED s8 arg1, UNUSED f32 arg2, s8 arg3, s8 arg4) {
    Vec3f sp9C;
    Vec3s sp94;

    if ((player->unk_258[20 + arg4].unk_01C == 1) && ((s32) player->animFrameSelector[arg3] < 0xD)) {
        sp9C[1] = (player->pos[1] - 3.0f) + player->unk_258[20 + arg4].unk_000[1];
        sp9C[2] = player->pos[2] + (coss(player->unk_048[arg3]) * -10.0f);
        sp9C[0] = player->pos[0] + (sins(player->unk_048[arg3]) * -10.0f);
        sp94[0] = 0;
        sp94[1] = player->unk_048[arg3];
        sp94[2] = 0;
        func_800652D4(sp9C, sp94, player->unk_258[20 + arg4].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008C90);
        gDPLoadTLUT_pal256(gDisplayListHead++, D_800E52D0);
        gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D4A4, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        gSPVertex(gDisplayListHead++, D_800E8B80, 4, 0);
        gSPDisplayList(gDisplayListHead++, common_square_plain_render);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D4A8, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        gSPVertex(gDisplayListHead++, D_800E8BC0, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount += 1;
    }
}

void func_800691B8(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp5C;
    Vec3s sp54;
    s16 alpha;

    if (player->unk_258[30 + arg2].unk_01C == 1) {
        alpha = player->unk_258[30 + arg2].unk_03E;
        sp5C[0] = player->unk_258[30 + arg2].unk_000[0];
        sp5C[1] = player->unk_258[30 + arg2].unk_000[1];
        sp5C[2] = player->unk_258[30 + arg2].unk_000[2];
        sp54[0] = 0;
        sp54[1] = player->unk_048[arg3];
        player->unk_258[30 + arg2].unk_03A += 0x1C71;
        sp54[2] = player->unk_258[30 + arg2].unk_03A;
        func_800652D4(sp5C, sp54, player->size * 0.5);
        gSPDisplayList(gDisplayListHead++, D_0D008D58);
        gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D488, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B35C(0xFF, 0xFF, 0, alpha);
        gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
        gSPVertex(gDisplayListHead++, D_800E87C0, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount++;
    }
}

void func_80069444(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp74;
    Vec3s sp6C;
    s16 primRed;
    s16 primGreen;
    s16 primBlue;
    s16 primAlpha;
    s16 envRed;
    s16 envGreen;
    s16 envBlue;
    u16 test;
    if (player->unk_258[30 + arg2].unk_01C == 1) {
        primRed = (D_800E47DC[player->unk_258[30 + arg2].unk_038] >> 0x10) & 0xFF;
        primGreen = (D_800E47DC[player->unk_258[30 + arg2].unk_038] >> 8) & 0xFF;
        primBlue = D_800E47DC[player->unk_258[30 + arg2].unk_038] & 0xFF;

        envRed = (D_800E480C[player->unk_258[30 + arg2].unk_038] >> 0x10) & 0xFF;
        envGreen = (D_800E480C[player->unk_258[30 + arg2].unk_038] >> 8) & 0xFF;
        envBlue = D_800E480C[player->unk_258[30 + arg2].unk_038] & 0xFF;
        primAlpha = player->unk_258[30 + arg2].unk_03E;

        sp74[0] = player->unk_258[30 + arg2].unk_000[0];
        sp74[1] = player->unk_258[30 + arg2].unk_000[1];
        sp74[2] = player->unk_258[30 + arg2].unk_000[2];
        sp6C[0] = 0;
        sp6C[1] = player->unk_048[arg3];
        sp6C[2] = 0;
        func_800652D4(sp74, sp6C, player->size * 1.5);
        gSPDisplayList(gDisplayListHead++, D_0D008DB8);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D494, G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        // `test` MUST be a u16
        // `test` MUST be set to `envRed`s value
        // `test` MUST be typecast to s16 when passed as a function parameter
        // What. the. fuck.
        test = envRed;
        func_8004B72C(primRed, primGreen, primBlue, (s16)test, envGreen, envBlue, primAlpha);
        gSPDisplayList(gDisplayListHead++, D_0D008E48);
        gMatrixEffectCount += 1;
    }
}

void func_800696CC(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3, f32 arg4) {
    Vec3f sp5C;
    Vec3s sp54;
    s16 alpha;

    if (player->unk_258[30 + arg2].unk_01C == 1) {
        alpha = player->unk_258[30 + arg2].unk_03E;
        sp5C[0] = player->unk_258[30 + arg2].unk_000[0];
        sp5C[1] = player->unk_258[30 + arg2].unk_000[1];
        sp5C[2] = player->unk_258[30 + arg2].unk_000[2];
        sp54[0] = 0;
        sp54[1] = player->unk_048[arg3];
        sp54[2] = 0;
        func_800652D4(sp5C, sp54, player->size * arg4);
        gSPDisplayList(gDisplayListHead++, D_0D008D58);
        gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D488, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B35C(0x000000FF, 0x000000FF, 0, alpha);
        gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
        gSPVertex(gDisplayListHead++, D_800E87C0, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount += 1;
    }
}

void func_80069938(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp5C;
    Vec3s sp54;
    s16 alpha;

    if (player->unk_258[30 + arg2].unk_01C == 1) {
        alpha = player->unk_258[30 + arg2].unk_03E;
        sp5C[0] = player->unk_258[30 + arg2].unk_000[0];
        sp5C[1] = player->unk_258[30 + arg2].unk_000[1];
        sp5C[2] = player->unk_258[30 + arg2].unk_000[2];
        sp54[0] = 0;
        sp54[1] = player->unk_048[arg3];
        sp54[2] = player->unk_258[30 + arg2].unk_038;
        func_800652D4(sp5C, sp54, player->unk_258[30 + arg2].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008D58);
        gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D488, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B35C(0x000000FF, 0x000000FF, 0, alpha);
        gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
        gSPVertex(gDisplayListHead++, D_800E87C0, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount += 1;
    }
}

void func_80069BA8(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp54;
    Vec3s sp4C;
    s16 red;
    s16 green;
    s16 blue;
    s16 alpha;

    if (player->unk_258[30 + arg2].unk_01C == 1) {
        red   = player->unk_258[30 + arg2].unk_038;
        green = player->unk_258[30 + arg2].unk_03A;
        blue  = player->unk_258[30 + arg2].unk_03C;
        alpha = player->unk_258[30 + arg2].unk_03E;
        sp54[0] = player->unk_258[30 + arg2].unk_000[0];
        sp54[1] = player->unk_258[30 + arg2].unk_000[1];
        sp54[2] = player->unk_258[30 + arg2].unk_000[2];
        sp4C[0] = 0;
        sp4C[1] = player->unk_048[arg3];
        sp4C[2] = 0;
        func_800652D4(sp54, sp4C, player->unk_258[30 + arg2].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008DB8);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D48C, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B35C(red, green, blue, alpha);
        gSPDisplayList(gDisplayListHead++, D_0D008E48);
        gMatrixEffectCount += 1;
    }
}

void func_80069DB8(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp5C;
    Vec3s sp54;
    UNUSED s32 stackPadding[2];

    if (player->unk_258[30 + arg2].unk_01C == 1) {
        sp5C[0] = player->unk_258[30 + arg2].unk_000[0];
        sp5C[1] = player->unk_258[30 + arg2].unk_000[1];
        sp5C[2] = player->unk_258[30 + arg2].unk_000[2];
        sp54[0] = 0;
        sp54[1] = player->unk_048[arg3];
        sp54[2] = 0;
        func_800652D4(sp5C, sp54, player->unk_258[30 + arg2].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008D58);
        gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D49C, G_IM_FMT_IA, G_IM_SIZ_16b, 16, 16, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B35C(0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF);
        gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
        gSPVertex(gDisplayListHead++, D_800E8740, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount += 1;
    }
}

void func_8006A01C(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp54;
    Vec3s sp4C;

    if (player->unk_258[arg2].unk_01C == 1) {
        sp54[0] = player->unk_258[10 + arg2].unk_000[0];
        sp54[1] = player->unk_258[10 + arg2].unk_000[1];
        sp54[2] = player->unk_258[10 + arg2].unk_000[2];
        sp4C[0] = 0;
        sp4C[1] = player->unk_048[arg3];
        sp4C[2] = 0;
        func_800652D4(sp54, sp4C, player->unk_258[10 + arg2].unk_00C * player->size);

        gSPDisplayList(gDisplayListHead++, D_0D008D58);
        gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE);
        gDPLoadTextureBlock(gDisplayListHead++, D_8018D49C, G_IM_FMT_IA, G_IM_SIZ_16b, 16, 16, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B35C(0xFF, 0xFF, 0xFF, 0xFF);
        gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
        gSPVertex(gDisplayListHead++, D_0D008B78, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount++;
    }
}

void func_8006A280(Player *player, UNUSED s8 arg1, s16 arg2, s8 arg3) {
    Vec3f sp5C;
    Vec3s sp54;
    s16 red;
    s16 green;
    s16 blue;

    if (player->unk_258[arg2].unk_01C == 1) {
        red   = player->unk_258[arg2].unk_038;
        green = player->unk_258[arg2].unk_03A;
        blue  = player->unk_258[arg2].unk_03C;
        sp5C[0] = player->unk_258[arg2].unk_000[0];
        sp5C[1] = player->unk_258[arg2].unk_000[1];
        sp5C[2] = player->unk_258[arg2].unk_000[2];
        sp54[0] = 0;
        sp54[1] = player->unk_048[arg3];
        sp54[2] = 0;
        func_800652D4(sp5C, sp54, player->unk_258[arg2].unk_00C * player->size);
        gSPDisplayList(gDisplayListHead++, D_0D008D58);
        gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE);
        gDPLoadTextureBlock_4b(gDisplayListHead++, *D_800E47A0[player->unk_258[arg2].unk_01E], G_IM_FMT_I, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
        func_8004B414(red, green, blue, 0x000000FF);
        gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
        gSPVertex(gDisplayListHead++, D_800E8780, 4, 0);
        gSPDisplayList(gDisplayListHead++, D_0D008DA0);
        gMatrixEffectCount += 1;
    }
}

void func_8006A50C(Player *player, f32 arg1, f32 arg2, s8 arg3, s8 arg4, s16 arg5) {
    f32 someX;
    f32 someY;
    f32 someZ;

    gPlayerBalloonStatus[arg3][arg4] = 0;
    D_8018D650[arg3][arg4] = 0.1f;
    D_8018D6B0[arg3][arg4] = 0.0f;
    D_8018D710[arg3][arg4] = 0.0f;
    D_8018D770[arg3][arg4] = 0;
    D_8018D7A0[arg3][arg4] = 0;
    D_8018D7D0[arg3][arg4] = 0;
    D_8018D800[arg3][arg4] = 5;
    D_8018D830[arg3][arg4] = 1;
    D_8018D620[arg3][arg4] = -player->rotation[1] - player->unk_0C0;
    func_80062B18(&someX, &someY, &someZ, arg1, 4.0f, arg2 + -3.8, -player->rotation[1], 0);
    D_8018D4D0[arg3][arg4] = player->pos[0] + someX;
    D_8018D590[arg3][arg4] = player->pos[2] + someZ;
    D_8018D530[arg3][arg4] = (player->pos[1] - player->boundingBoxSize) + someY;
    gPlayerBalloonStatus[arg3][arg4] |= 1;
    D_8018D860[arg3][arg4] = arg5;
    D_8018D890[arg3][arg4] = 0;
}

void func_8006A7C0(Player *player, f32 arg1, f32 arg2, s8 arg3, s8 arg4) {
    f32 sp80[] = {
         9.0f, 10.0f, 9.0f,  8.0f,
        10.0f,  9.5f, 9.5f, 11.0f,
    };
    UNUSED s32 stackPadding0;
    f32 someX;
    f32 someY;
    f32 someZ;
    f32 sp6C;
    UNUSED s32 stackPadding1;
    UNUSED s32 stackPadding2;

    sp6C = (-(player->unk_094 / 18.0f) * 216.0f) / 10.0f;
    if ((gPlayerBalloonStatus[arg3][arg4] & 2) != 2) {
        D_8018D650[arg3][arg4] += -0.003 + (-player->unk_094 * 0.0006);
        if (D_8018D650[arg3][arg4] >= 0.05) {
            D_8018D650[arg3][arg4] = 0.05f;
        }
        if (D_8018D650[arg3][arg4] <= -0.05) {
            D_8018D650[arg3][arg4] = -0.05f;
        }
        D_8018D6B0[arg3][arg4] += D_8018D650[arg3][arg4];
        if (D_8018D6B0[arg3][arg4] >= 0.06) {
            D_8018D6B0[arg3][arg4] = 0.06f;
        }
        if (D_8018D6B0[arg3][arg4] <= -0.06) {
            D_8018D6B0[arg3][arg4] = -0.06f;
        }
        D_8018D710[arg3][arg4] += D_8018D6B0[arg3][arg4];
        if (D_8018D710[arg3][arg4] < 0.0f) {
            D_8018D650[arg3][arg4] = random_int(0x000BU) / 10;
            D_8018D6B0[arg3][arg4] = 0.0f;
            D_8018D710[arg3][arg4] = 0.0f;
        }
        D_8018D620[arg3][arg4] = -player->rotation[1] - player->unk_0C0;
        move_s16_towards(&D_8018D890[arg3][arg4], player->unk_094 * 182.0f, 0.1f);
    }
    if (D_8018D830[arg3][arg4] == 1) {
        D_8018D770[arg3][arg4] += D_8018D800[arg3][arg4] - player->unk_094;
    } else {
        D_8018D770[arg3][arg4] += D_8018D800[arg3][arg4] + player->unk_094;
    }
    if (D_8018D770[arg3][arg4] >= 0xB) {
        D_8018D770[arg3][arg4] = 0x000B;
    }
    if (D_8018D770[arg3][arg4] < -0xA) {
        D_8018D770[arg3][arg4] = -0x000B;
    }
    D_8018D7A0[arg3][arg4] += D_8018D770[arg3][arg4];
    if (D_8018D7A0[arg3][arg4] >= 0x29) {
        D_8018D7A0[arg3][arg4] = 0x0029;
    }
    if (D_8018D7A0[arg3][arg4] < -0x28) {
        D_8018D7A0[arg3][arg4] = -0x0029;
    }
    D_8018D7D0[arg3][arg4] += D_8018D7A0[arg3][arg4];
    if (D_8018D7D0[arg3][arg4] >= 0x38E) {
        D_8018D800[arg3][arg4] = -random_int(8U);
        if (D_8018D830[arg3][arg4] != 1) {
            D_8018D830[arg3][arg4] = 1;
        }
    }
    if (D_8018D7D0[arg3][arg4] < -0x38D) {
        D_8018D800[arg3][arg4] = random_int(8U);
        if (D_8018D830[arg3][arg4] != -1) {
            D_8018D830[arg3][arg4] = -1;
        }
    }
    func_80062B18(&someX, &someY, &someZ, arg1, sp80[player->characterId] - D_8018D710[arg3][arg4], arg2 + -3.2 + (sp6C * 1), -D_8018D620[arg3][arg4], -player->unk_206 * 2);
    if ((gPlayerBalloonStatus[arg3][arg4] & 2) != 2) {
        D_8018D530[arg3][arg4] = (player->pos[1] - player->boundingBoxSize) + someY;
        D_8018D4D0[arg3][arg4] = player->pos[0] + someX;
        D_8018D590[arg3][arg4] = player->pos[2] + someZ;
        D_8018D8D0[arg3][arg4] = 0;
    } else {
        D_8018D530[arg3][arg4] += 0.2;
        D_8018D8D0[arg3][arg4] += 1;
        move_s16_towards(&D_8018D890[arg3][arg4], 0, 0.1f);
        move_s16_towards(&D_8018D860[arg3][arg4], 0, 0.1f);
        if (D_8018D8D0[arg3][arg4] >= 0x78) {
            func_8006B974((s32) player, arg3, arg4);
        }
    }
}

void func_8006AFD0(Player *player, s8 arg1, s16 arg2, s8 arg3) {
    Mat4 sp140;
    Vec3f sp134;
    Vec3s sp12C;
    UNUSED s16 stackPadding;
    s16 primRed;
    s16 primGreen;
    s16 primBlue;
    s16 envRed;
    s16 envGreen;
    s16 envBlue;
    s16 temp_t1;
    f32 xdiff;
    f32 zdiff;
    f32 var_f20;
    s32 primColors[] = {
        MAKE_RGB(0xC8, 0x01, 0x00), MAKE_RGB(0x00, 0x70, 0x01), MAKE_RGB(0x10, 0x79, 0x51), MAKE_RGB(0x00, 0x59, 0x70),
        MAKE_RGB(0x70, 0x55, 0x00), MAKE_RGB(0x7A, 0x7E, 0x00), MAKE_RGB(0x77, 0x2C, 0x24), MAKE_RGB(0x30, 0x14, 0x58),
    };
    s32 envColors[] = {
        MAKE_RGB(0xDC, 0x00, 0x00), MAKE_RGB(0x00, 0x8C, 0x06), MAKE_RGB(0x00, 0x00, 0x51), MAKE_RGB(0x00, 0x00, 0x00),
        MAKE_RGB(0x00, 0x00, 0x00), MAKE_RGB(0x00, 0x00, 0x00), MAKE_RGB(0x00, 0x00, 0x00), MAKE_RGB(0x00, 0x00, 0x00),
    };

    primRed   = (primColors[player->characterId] >> 0x10) & 0xFF;
    primGreen = (primColors[player->characterId] >> 0x08) & 0xFF;
    primBlue  = (primColors[player->characterId] >> 0x00) & 0xFF;
    envRed    = (envColors[player->characterId]  >> 0x10) & 0xFF;
    envGreen  = (envColors[player->characterId]  >> 0x08) & 0xFF;
    envBlue   = (envColors[player->characterId]  >> 0x00) & 0xFF;
    temp_t1 = (((player->unk_048[arg3] + player->rotation[1] + player->unk_0C0) & 0xFFFF) / 128);
    temp_t1 <<= 7;
    if (arg3 == arg1) {
        var_f20 = 0.3f;
    } else {
        // wut?
        xdiff = (var_f20 = player->pos[0] - cameras[arg3].pos[0]);
        zdiff = player->pos[2] - cameras[arg3].pos[2];
        if (gActiveScreenMode != 3) {
            var_f20 = sqrtf((xdiff * xdiff) + (zdiff * zdiff)) / 300.0f;
        } else {
            var_f20 = sqrtf((xdiff * xdiff) + (zdiff * zdiff)) / 200.0f;
        }
        if (var_f20 >= 1.8) {
            var_f20 = 1.8f;
        }
        if (var_f20 <= 0.3) {
            var_f20 = 0.3f;
        }
    }
    sp134[0] = D_8018D4D0[arg1][arg2];
    sp134[1] = D_8018D530[arg1][arg2];
    sp134[2] = D_8018D590[arg1][arg2];
    sp12C[0] = -((D_8018D890[arg1][arg2] * 4) * coss(temp_t1));
    sp12C[1] = player->unk_048[arg3];
    sp12C[2] = D_8018D7D0[arg1][arg2] - (D_8018D860[arg1][arg2] * coss(temp_t1)) - ((D_8018D890[arg1][arg2] * 8) * sins(temp_t1));
    mtxf_translate_rotate(sp140, sp134, sp12C);
    mtxf_scale2(sp140, var_f20);
    convert_to_fixed_point_matrix(&gGfxPool->mtxEffect[gMatrixEffectCount], sp140);

    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxEffect[gMatrixEffectCount]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
    gSPDisplayList(gDisplayListHead++, D_0D008DB8);
    gDPLoadTLUT_pal256(gDisplayListHead++, D_800E52D0);
    gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16);

    func_8004B614(primRed, primGreen, primBlue, envRed, envGreen, envBlue, 0x000000D8);
    
    gDPSetRenderMode(gDisplayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA));
    gDPLoadTextureBlock(gDisplayListHead++, D_8018D4BC, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
    gSPVertex(gDisplayListHead++, gBalloonVertexPlane1, 4, 0);
    gSPDisplayList(gDisplayListHead++, common_square_plain_render);
    gDPLoadTextureBlock(gDisplayListHead++, D_8018D4C0 - 0x40, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
    gSPVertex(gDisplayListHead++, gBalloonVertexPlane2, 4, 0);
    gSPDisplayList(gDisplayListHead++, common_square_plain_render);
    gSPTexture(gDisplayListHead++, 0x0001, 0x0001, 0, G_TX_RENDERTILE, G_OFF);
    gMatrixEffectCount++;
}

void func_8006B7E4(Player* player, s8 arg1) {
    func_8006A50C(player, 0.0f, 0.0f, arg1, (s8) 0, (s16) 0);
    func_8006A50C(player, 1.5f, 2.0f, arg1, (s8) 1, (s16) 0x1C70);
    func_8006A50C(player, -1.5f, 2.0f, arg1, (s8) 2, (s16) -0x1C70);
    gPlayerBalloonCount[arg1] = 2;
}

void func_8006B87C(UNUSED Player *player, s8 playerIndex) {
    gPlayerBalloonStatus[playerIndex][0] = BALLOON_STATUS_GONE;
    gPlayerBalloonStatus[playerIndex][1] = BALLOON_STATUS_GONE;
    gPlayerBalloonStatus[playerIndex][2] = BALLOON_STATUS_GONE;
}

void func_8006B8B4(Player *player, s8 playerIndex) {
    if (gPlayerBalloonCount[playerIndex] >= 0) {
        gPlayerBalloonStatus[playerIndex][gPlayerBalloonCount[playerIndex]] &= ~1;
        gPlayerBalloonStatus[playerIndex][gPlayerBalloonCount[playerIndex]] |= 2;
        gPlayerBalloonCount[playerIndex]--;
        func_800C9060(playerIndex, SOUND_ARG_LOAD(0x19, 0x00, 0x90, 0x51));
        if (gPlayerBalloonCount[playerIndex] < 0) {
            func_8008FD4C(player, playerIndex);
        }
    }
}

void func_8006B974(UNUSED s32 arg0, s8 playerIndex, s8 balloonIndex) {
    if (gPlayerBalloonCount[playerIndex] >= 0) {
        gPlayerBalloonStatus[playerIndex][balloonIndex] = BALLOON_STATUS_GONE;
    }
}

void func_8006B9CC(Player* player, s8 arg1) {
    if (gPlayerBalloonStatus[arg1][0] != 0) {
        func_8006A7C0(player, 0.0f, 0.0f, arg1, 0);
    }

    if (gPlayerBalloonStatus[arg1][1] != 0) {

        func_8006A7C0(player, 1.8f, 2.6f, arg1, 1);
    }

    if (gPlayerBalloonStatus[arg1][2] != 0) {
        func_8006A7C0(player, -1.8f, 2.6f, arg1, 2);
    }
}

void func_8006BA94(Player* player, s8 playerIndex, s8 arg2) {
    if (gPlayerBalloonStatus[playerIndex][0] != BALLOON_STATUS_GONE) {
        func_8006AFD0(player, playerIndex, 0, arg2);
    }
    if (gPlayerBalloonStatus[playerIndex][1] != BALLOON_STATUS_GONE) {
        func_8006AFD0(player, playerIndex, 1, arg2);
    }
    if (gPlayerBalloonStatus[playerIndex][2] != BALLOON_STATUS_GONE) {
        func_8006AFD0(player, playerIndex, 2, arg2);
    }
}

void render_balloon(Vec3f arg0, f32 arg1, s16 arg2, s16 arg3) {
    Mat4 sp108;
    Vec3f spFC;
    Vec3s spF4;
    UNUSED s16 stackPadding;
    s16 primRed;
    s16 primGreen;
    s16 primBlue;
    s16 envRed;
    s16 envGreen;
    s16 envBlue;
    s32 primColors[] = {
        MAKE_RGB(0xC8, 0x01, 0x00), MAKE_RGB(0x00, 0x70, 0x01), MAKE_RGB(0x10, 0x79, 0x51), MAKE_RGB(0x00, 0x59, 0x70),
        MAKE_RGB(0x70, 0x55, 0x00), MAKE_RGB(0x7A, 0x7E, 0x00), MAKE_RGB(0x77, 0x2C, 0x24), MAKE_RGB(0x30, 0x14, 0x58),
    };
    s32 envColors[] = {
        MAKE_RGB(0xDC, 0x00, 0x00), MAKE_RGB(0x00, 0x8C, 0x06), MAKE_RGB(0x00, 0x00, 0x51), MAKE_RGB(0x00, 0x00, 0x00),
        MAKE_RGB(0x00, 0x00, 0x00), MAKE_RGB(0x00, 0x00, 0x00), MAKE_RGB(0x00, 0x00, 0x00), MAKE_RGB(0x00, 0x00, 0x00),
    };

    primRed   = (primColors[arg3] >> 0x10) & 0xFF;
    primGreen = (primColors[arg3] >> 0x08) & 0xFF;
    primBlue  = (primColors[arg3] >> 0x00) & 0xFF;
    envRed    = ( envColors[arg3] >> 0x10) & 0xFF;
    envGreen  = ( envColors[arg3] >> 0x08) & 0xFF;
    envBlue   = ( envColors[arg3] >> 0x00) & 0xFF;
    spFC[0] = arg0[0];
    spFC[1] = arg0[1];
    spFC[2] = arg0[2];
    spF4[0] = 0;
    spF4[1] = camera1->rot[1];
    spF4[2] = arg2;
    mtxf_translate_rotate(sp108, spFC, spF4);
    mtxf_scale2(sp108, arg1);
    convert_to_fixed_point_matrix(&gGfxPool->mtxEffect[gMatrixEffectCount], sp108);
    gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxEffect[gMatrixEffectCount]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
    gSPDisplayList(gDisplayListHead++, D_0D008DB8);
    gDPLoadTLUT_pal256(gDisplayListHead++, D_800E52D0);
    gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16);
    func_8004B614(primRed, primGreen, primBlue, envRed, envGreen, envBlue, 0x000000D8);
    gDPSetRenderMode(gDisplayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA));
    gDPLoadTextureBlock(gDisplayListHead++, D_8018D4BC, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
    gSPVertex(gDisplayListHead++, gBalloonVertexPlane1, 4, 0);
    gSPDisplayList(gDisplayListHead++, common_square_plain_render);
    // D_8018D4C0 is correct. But interestingly, IDO seems to set "-0x40" to a different register so the texture still looks fine.
    gDPLoadTextureBlock(gDisplayListHead++, D_8018D4C0 - 0x40, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
    gSPVertex(gDisplayListHead++, gBalloonVertexPlane2, 4, 0);
    gSPDisplayList(gDisplayListHead++, common_square_plain_render);
    gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF);
    gMatrixEffectCount += 1;
}

void func_8006C0C8(Vec3f arg0, f32 arg1, s32 rgb, s16 alpha) {
    Vec3f sp4C;
    Vec3s sp44;
    s16 red;
    s16 green;
    s16 blue;

    sp4C[0] = arg0[0];
    sp4C[1] = arg0[1];
    sp4C[2] = arg0[2];
    sp44[0] = 0;
    sp44[1] = camera1->rot[1];
    sp44[2] = 0;
    func_800652D4(sp4C, sp44, arg1);
    gSPDisplayList(gDisplayListHead++, D_0D008DB8);
    gDPLoadTextureBlock(gDisplayListHead++, D_8018D48C, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0,
        G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
    // ???????????????????????????????????
    red   = ((rgb >> 0x10) & 0xFF) & 0xFF;
    green = ((rgb >> 0x08) & 0xFF) & 0xFF;
    blue  = ((rgb >> 0x00) & 0xFF) & 0xFF;
    // ???????????????????????????????????
    func_8004B35C(red, green, blue, alpha);
    gSPDisplayList(gDisplayListHead++, D_0D008E48);
    gMatrixEffectCount += 1;
}

void func_8006C294(Vec3f arg0, f32 arg1, s32 rgb, s16 alpha) {
    Vec3f sp5C;
    Vec3s sp54;
    // ???????????????????????????????????????
    s16 red   = ((rgb >> 0x10) & 0xFF) & 0xFF;
    s16 green = ((rgb >> 0x08) & 0xFF) & 0xFF;
    s16 blue  = ((rgb >> 0x00) & 0xFF) & 0xFF;
    // ???????????????????????????????????????

    sp5C[0] = arg0[0];
    sp5C[1] = arg0[1];
    sp5C[2] = arg0[2];
    sp54[0] = 0;
    sp54[1] = camera1->rot[1];
    sp54[2] = 0;
    func_800652D4(sp5C, sp54, arg1);
    gSPDisplayList(gDisplayListHead++, D_0D008D58);
    gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE);
    gDPLoadTextureBlock(gDisplayListHead++, D_8018D488, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
    func_8004B35C(red, green, blue, alpha);
    gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
    gSPVertex(gDisplayListHead++, D_800E87C0, 4, 0);
    gSPDisplayList(gDisplayListHead++, D_0D008DA0);
    gMatrixEffectCount += 1;
}

void func_8006C4D4(Vec3f arg0, f32 arg1, s32 rgb, s16 alpha, s16 arg4) {
    Vec3f sp4C;
    Vec3s sp44;
    // ???????????????????????????????????????
    s16 red   = ((rgb >> 0x10) & 0xFF) & 0xFF;
    s16 green = ((rgb >> 0x08) & 0xFF) & 0xFF;
    s16 blue  = ((rgb >> 0x00) & 0xFF) & 0xFF;
    // ???????????????????????????????????????

    sp4C[0] = arg0[0];
    sp4C[1] = arg0[1];
    sp4C[2] = arg0[2];
    sp44[0] = 0;
    sp44[1] = camera1->rot[1];
    sp44[2] = 0;
    func_800652D4(sp4C, sp44, arg1);
    gSPDisplayList(gDisplayListHead++, D_0D008DB8);
    gDPLoadTextureBlock(gDisplayListHead++, common_texture_particle_spark[arg4], G_IM_FMT_I, G_IM_SIZ_8b, 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
    func_8004B414(red, green, blue, alpha);
    gSPDisplayList(gDisplayListHead++, D_0D008E48);
    gMatrixEffectCount += 1;
}

void func_8006C6AC(Player *player, s16 arg1, s8 arg2, s8 arg3) {
    s8 arg2_copy = arg2;
    s32 sp28;

    sp28 = arg1 - 1;
    if (sp28 < 0) {
        sp28 = 9;
    }
    if (player->unk_258[10 + arg1].unk_01C == 1) {
        switch (player->unk_258[10 + arg1].unk_012) {
        case 1:
            func_80063408(player, arg1, arg2_copy, arg3);
            break;
        case 2:
            func_800635D4(player, arg1, arg2_copy, arg3);
            break;
        case 3:
            func_80063BD4(player, arg1, arg2_copy, arg3);
            break;
        case 4:
            func_800643A8(player, arg1, arg2_copy, arg3);
            break;
        case 5:
            func_800639DC(player, arg1, arg2_copy, arg3);
            break;
        case 9:
            func_80063D58(player, arg1, arg2_copy, arg3);
            break;
        case 11:
            func_80062F98(player, arg1, arg2_copy, arg3);
            break;
        default:
            break;
        }
    } else {
        if (player->unk_0DE & 1) {
            func_80060BCC(player, arg1, sp28, arg2_copy, arg3);
        } else if (!(player->effects & 8) && !(player->effects & 2)) {
            if (((player->effects & 0x10) == 0x10) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) {
                func_8005DA30(player, arg1, sp28, arg2_copy, arg3);
            } else if (((f64) (D_801652A0[arg2_copy] - player->boundingBoxCorners[3].cornerGroundY) >= 3.5) || ((f64) (D_801652A0[arg2_copy] - player->boundingBoxCorners[2].cornerGroundY) >= 3.5)) {
                func_8005EA94(player, arg1, sp28, arg2_copy, arg3);
            } else if (((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40)) {
                func_8005F90C(player, arg1, sp28, arg2_copy, arg3);
            } else if (((player->effects & 0x4000) && !(player->type & PLAYER_START_SEQUENCE)) || (player->effects & 0x800) || (player->effects & 0x20) || (player->unk_044 & 0x4000)) {
                func_8005ED48(player, arg1, sp28, arg2_copy, arg3);
            } else {
                func_8005DAF4(player, arg1, sp28, arg2_copy, arg3);
            }
        }
    }
}

void func_8006C9B8(Player *player, s16 arg1, s8 arg2, s8 arg3) {
    UNUSED s32 stackPadding;
    s32 sp28;
    sp28 = arg1 - 1;
    if (sp28 < 0) {
        sp28 = 9;
    }
    if (player->unk_258[30 + arg1].unk_01C == 1) {
        switch (player->unk_258[30 + arg1].unk_012) {
            case 1:
            func_800644E8(player, arg1, arg2, arg3);
            break;
            
            case 2:
            func_800649F4(player, arg1, arg2, arg3);
            break;
            
            case 3:
            func_80064C74(player, arg1, arg2, arg3);
            break;
            
            case 4:
            func_800647C8(player, arg1, arg2, arg3);
            break;
            
            case 5:
            func_80064B30(player, arg1, arg2, arg3);
            break;
            
            case 6:
            func_800648E4(player, arg1, arg2, arg3);
            break;
            
            case 7:
            func_80064988(player, arg1, arg2, arg3);
            break;
            
            case 8:
            func_80064C74(player, arg1, arg2, arg3);
            break;
            
            case 9:
            func_80064664(player, arg1, arg2, arg3);
            break;
            
            default:
            break;
        }
    } else {
        if (player->unk_044 & 0x1000) {
            func_80061430(player, arg1, sp28, arg2, arg3);
            player->unk_044 &= ~0x0100;
            return;
        }
        if (((((player->unk_0CA & 0x1000) == 0x1000) || ((player->unk_0E0 < 2) && (player->effects & 0x01000000))) || ((player->unk_0E0 < 2) && (player->effects & HIT_BY_ITEM_EFFECT))) || (player->effects & 0x400)) {
            func_8006199C(player, arg1, sp28, arg2, arg3);
            player->unk_046 &= ~0x0008;
            player->unk_044 &= ~0x0100;
            return;
        }
        if ((player->unk_0CA & 0x2000) == 0x2000) {
            func_80061A34(player, arg1, sp28, arg2, arg3);
            player->unk_046 &= ~0x0008;
            player->unk_044 &= ~0x0100;
            return;
        }
        if ((player->effects & STAR_EFFECT) && ((((s32) gCourseTimer) - D_8018D930[arg2]) < 9)) {
            func_800615AC(player, arg1, sp28, arg2, arg3);
            player->unk_046 &= ~0x0008;
            player->unk_044 &= ~0x0100;
            return;
        }
        if ((player->unk_046 & 8) == 8) {
            func_800612F8(player, arg1, sp28, arg2, arg3);
            player->unk_044 &= ~0x0100;
            return;
        }
        if (((player->unk_046 & 0x20) == 0x20) && (((player->unk_094 / 18.0f) * 216.0f) >= 20.0f)) {
            func_80061D4C(player, arg1, sp28, arg2, arg3);
            player->unk_046 &= ~0x0008;
            player->unk_044 &= ~0x0100;
            return;
        }
        if ((player->effects & BOOST_EFFECT) && (player->type & PLAYER_HUMAN)) {
            func_800621BC(player, arg1, sp28, arg2, arg3);
            return;
        }
        if (((player->effects & 0x200000) || (player->effects & BOOST_RAMP_ASPHALT_EFFECT)) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) {
            func_80061EF4(player, arg1, sp28, arg2, arg3);
            player->unk_046 &= ~0x0008;
            player->unk_044 &= ~0x0100;
            return;
        }
        if ((player->unk_044 & 0x100) == 0x100) {
            func_800624D8(player, arg1, sp28, arg2, arg3);
            player->unk_046 &= ~0x0008;
        }
    }
}

void func_8006CEC0(Player *arg0, s16 arg1, s8 arg2, s8 arg3) {
    UNUSED u16 temp_v0_3;
    s32 sp20 = arg1;
    if (--sp20 < 0) {
        sp20 = 9;
    }
    if (arg0->unk_258[arg1].unk_01C == 1) {
        switch (arg0->unk_258[arg1].unk_012) {
        case 1:
            func_80062C74(arg0, arg1, arg2, arg3);
            break;
        case 3:
            func_80064184(arg0, arg1, arg2, arg3);
            break;
        case 5:
            func_800630C0(arg0, arg1, arg2, arg3);
            break;
        case 6:
            func_800631A8(arg0, arg1, arg2, arg3);
            break;
        case 7:
            func_80063268(arg0, arg1, arg2, arg3);
            break;
        }
    } else {
        if ((arg0->unk_044 & 0x200) && (arg0->type & 0x4000))  {
            func_80061224(arg0, arg1, sp20, arg2, arg3);
            return;
        } else if (((arg0->effects & 0x40000000) == 0x40000000) && (arg0->unk_0B0 < 0x32))  {
            func_80061094(arg0, arg1, sp20, arg2, arg3);
            return;
        } else if ((arg0->type & 0x4000) == 0x4000)  { 
            if ((arg0->unk_0DE & 8) == 8)  {
                func_80060F50(arg0, arg1, sp20, arg2, arg3);
                return;
            } else if ((arg0->unk_0DE & 2) || (arg0->unk_0DE & 1))  {
                func_80060B14(arg0, arg1, sp20, arg2, arg3);
                return;
            }
        }
        switch (gActiveScreenMode) {
        case SCREEN_MODE_1P:
            if (((arg0->effects & 0x04000000) != 0x04000000)
                && ((arg0->effects & 0x400) != 0x400)
                && ((arg0->effects & 0x01000000) != 0x01000000))  {
                if (((arg0->unk_0CA & 2) != 2) && ((arg0->unk_0CA & 0x10) != 0x10) && !(arg0->unk_0CA & 0x100))  {
                    func_80060504(arg0, arg1, sp20, arg2, arg3);
                }
            }
            break;
        default:
            break;
        case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL:
        case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL:
        case SCREEN_MODE_3P_4P_SPLITSCREEN:
            if (((arg0->type & 0x4000) != 0)
                && ((arg0->effects & 0x04000000) != 0x04000000)
                && ((arg0->effects & 0x400) != 0x400)
                && ((arg0->effects & 0x01000000) != 0x01000000)) {
                if (((arg0->unk_0CA & 2) != 2) && ((arg0->unk_0CA & 0x10) != 0x10) && !(arg0->unk_0CA & 0x100))  {
                    func_80060504(arg0, arg1, sp20, arg2, arg3);
                }
            }
            break;
        }
    }
}

void func_8006D194(Player *player, s8 arg1, s8 arg2) {
    if (player->unk_258[0x14].unk_01C == 1) {
        switch (player->unk_258[0x14].unk_012) {
        case 2:
            func_80064DEC(player, arg1, arg2, 0);
            break;
        case 3:
            func_800650FC(player, arg1, arg2, 0);
            break;
        case 4:
            func_80064EA4(player, arg1, arg2, 0);
            break;
        case 5:
            func_80064F88(player, arg1, arg2, 0);
            break;
        case 6:
            func_80065030(player, arg1, arg2, 0);
            break;
        }
    } else {
        if ((player->unk_0B6 & 0x40) == 0x40) {
            func_800628C0(player, arg1, arg2, 0);
        }
        if ((player->unk_0B6 & 0x800) == 0x800) {
            func_80062968(player, arg1, arg2, 0);
        }
        if ((player->unk_0B6 & 0x1000) == 0x1000) {
            func_80062914(player, arg1, arg2, 0);
        }
        if ((player->unk_0B6 & 0x80) == 0x80) {
            func_80062A18(player, arg1, arg2, 0);
        }
        if ((player->unk_0B6 & 0x100) == 0x100) {
            func_800629BC(player, arg1, arg2, 0);
        }
    }
    if (player->unk_258[0x15].unk_01C == 1) {
        if (player->unk_258[0x15].unk_012 == 5) {
            func_800651F4(player, arg1, arg2, 1);
        }
    } else if ((player->unk_0B6 & 0x20) == 0x20) {
        func_80062AA8(player, arg1, arg2, 1);
    }
}

void func_8006D474(Player *player, s8 arg1, s8 arg2) {
    s16 var_s2;
    if ((player->unk_002 & (8 << (arg2 * 4))) == (8 << (arg2 * 4))) {
        for (var_s2 = 0; var_s2 < 10; var_s2++) {
            switch (player->unk_258[var_s2].unk_012) {
            case 1:
                if (gActiveScreenMode == SCREEN_MODE_3P_4P_SPLITSCREEN) {
                    if (arg2 == arg1) {
                        func_8006538C(player, arg1, var_s2, arg2);
                    }
                } else {
                    func_8006538C(player, arg1, var_s2, arg2);
                }
                break;
            case 6:
                if (gActiveScreenMode == SCREEN_MODE_3P_4P_SPLITSCREEN) {
                    if (arg2 == arg1) {
                        func_80066BAC(player, arg1, var_s2, arg2);
                    }
                } else if (arg2 == arg1) {
                    func_80066BAC(player, arg1, var_s2, arg2);
                }
                break;
            }
            switch (player->unk_258[var_s2 + 30].unk_012) {
            case 1:
            case 9:
                if (gActiveScreenMode == SCREEN_MODE_1P) {
                    func_800691B8(player, arg1, var_s2, arg2);
                } else if (arg2 == arg1) {
                    func_800691B8(player, arg1, var_s2, arg2);
                }
                break;
            case 2:
                if (gActiveScreenMode == SCREEN_MODE_1P) {
                    func_800696CC(player, arg1, var_s2, arg2, player->unk_258[var_s2 + 30].unk_00C);
                } else if (arg2 == arg1) {
                    func_800696CC(player, arg1, var_s2, arg2, player->unk_258[var_s2 + 30].unk_00C);
                }
                break;
            case 3:
                if (gActiveScreenMode == SCREEN_MODE_1P) {
                    func_80067280(player, arg1, var_s2, arg2);
                } else if (arg2 == arg1) {
                    func_80067280(player, (s32) arg1, var_s2, arg2);
                }
                break;
            case 4:
                if (gActiveScreenMode == SCREEN_MODE_1P) {
                    func_80069444(player, arg1, var_s2, arg2);
                } else if (arg2 == arg1) {
                    func_80069444(player, arg1, var_s2, arg2);
                }
                break;
            case 5:
                if (gActiveScreenMode == SCREEN_MODE_1P) {
                    func_80069938(player, arg1, var_s2, arg2);
                } else if (arg2 == arg1) {
                    func_80069938(player, arg1, var_s2, arg2);
                }
                break;
            case 6:
                if (gActiveScreenMode == SCREEN_MODE_1P) {
                    func_80069BA8(player, arg1, var_s2, arg2);
                } else if (arg2 == arg1) {
                    func_80069BA8(player, arg1, var_s2, arg2);
                }
                break;
            case 7:
                if (gActiveScreenMode == SCREEN_MODE_1P) {
                    func_80069DB8(player, arg1, var_s2, arg2);
                } else if (arg2 == arg1) {
                    func_80069DB8(player, arg1, var_s2, arg2);
                }
                break;
            case 8:
                if (gActiveScreenMode == SCREEN_MODE_1P) {
                    func_80067604(player, arg1, var_s2, arg2);
                } else if (arg2 == arg1) {
                    func_80067604(player, arg1, var_s2, arg2);
                }
                break;
            }
            switch (player->unk_258[var_s2 + 10].unk_012) {
            case 1:
                if (gActiveScreenMode == SCREEN_MODE_3P_4P_SPLITSCREEN) {
                    if (arg2 == arg1) {
                        func_80065AB0(player, arg1, var_s2, arg2);
                    }
                } else {
                    func_80065AB0(player, arg1, var_s2, arg2);
                }
                break;
            case 2:
            case 3:
            case 4:
            case 5:
                if (gActiveScreenMode == SCREEN_MODE_3P_4P_SPLITSCREEN) {
                    if (arg2 == arg1) {
                        func_80065F0C(player, arg1, var_s2, arg2);
                    }
                } else {
                    func_80065F0C(player, arg1, var_s2, arg2);
                }
                break;
            case 9:
                if (gActiveScreenMode == SCREEN_MODE_3P_4P_SPLITSCREEN) {
                    if (arg2 == arg1) {
                        func_800664E0(player, (s32) arg1, var_s2, arg2);
                    }
                } else {
                    func_800664E0(player, (s32) arg1, var_s2, arg2);
                }
                break;
            case 11:
                if (gActiveScreenMode == SCREEN_MODE_3P_4P_SPLITSCREEN) {
                    if (arg2 == arg1) {
                        func_8006A01C(player, arg1, var_s2, arg2);
                    }
                } else if (arg2 == arg1) {
                    func_8006A01C(player, arg1, var_s2, arg2);
                }
                break;
            }
        }
    }
    if ((gModeSelection == BATTLE) && (player->unk_002 & (2 << (arg2 * 4)))) {
        func_8006BA94(player, arg1, arg2);
    }
}

void func_8006DC54(Player* player, s8 arg1, s8 arg2) {
    s16 i;
    s32 bitwiseMask;

    bitwiseMask = 8 << (arg2 * 4);
    if (bitwiseMask == (player->unk_002 & bitwiseMask)) {
        for (i = 0; i < 10; i++) {
            if (player->unk_258[i].unk_012 == 7) {
                func_800658A0(player, arg1, i, arg2);
            }
        }
    }
}

void func_8006DD3C(Player* arg0, s8 arg1, s8 arg2) {
    s16 temp_s0;
    s32 temp_v0;

    temp_v0 = 8 << (arg2 * 4);
    if (temp_v0 == (arg0->unk_002 & temp_v0)) {
        for (temp_s0 = 0; temp_s0 < 10; ++temp_s0) {
            temp_v0 = arg0->unk_258[temp_s0].unk_012;
            if (temp_v0 != 3) {
                if (temp_v0 == 5) {
                    func_8006A280(arg0, arg1, temp_s0, arg2);
                }
            } else if (gActiveScreenMode == SCREEN_MODE_3P_4P_SPLITSCREEN) {
                if (arg2 == arg1) {
                    func_80066998(arg0, arg1, temp_s0, arg2);
                }
            } else {
                func_80066998(arg0, arg1, temp_s0, arg2);
            }
        }

        if (((arg0->type & 0x4000) == 0x4000) && (arg2 == arg1)) {
            switch (arg0->unk_258[20].unk_012) {
            case 2:
                func_80068310(arg0, arg1, arg0->unk_258[20].unk_00C, arg2, 0);
                break;
            case 3:
                func_80067964(arg0, arg1, arg0->unk_258[20].unk_00C, arg2, 0);
                break;
            case 4:
                func_80068724(arg0, arg1, arg0->unk_258[20].unk_00C, arg2, 0);
                break;
            case 5:
                func_80068AA4(arg0, arg1, arg0->unk_258[20].unk_00C, arg2, 0);
                break;
            case 6:
                func_80068DA0(arg0, arg1, arg0->unk_258[20].unk_00C, arg2, 0);
                break;
            }
            if (arg0->unk_258[21].unk_012 == 5) {
                func_80067D3C(arg0, arg2, D_8018D480, 1, 1.6f, 0xFFFFFF);
                func_8006801C(arg0, arg2, D_8018D484, 1, 1.6f, 0xFF);
            }
        }
    }
}

void func_8006E058(void) {
    switch (gActiveScreenMode) { 
    case SCREEN_MODE_1P:
        switch (gModeSelection) {
        case GRAND_PRIX:
            func_8006E420(gPlayerOne, 0, 0);
            func_8006E420(gPlayerTwo, 1, 0);
            func_8006E420(gPlayerThree, 2, 0);
            func_8006E420(gPlayerFour, 3, 0);
            func_8006E420(gPlayerFive, 4, 0);
            func_8006E420(gPlayerSix, 5, 0);
            func_8006E420(gPlayerSeven, 6, 0);
            func_8006E420(gPlayerEight, 7, 0);

            break;
        case TIME_TRIALS:
            func_8006E420(gPlayerOne, 0, 0);

            if ((gPlayerTwo->type & 0x100) == 0x100) {
                func_8006E420(gPlayerTwo, 1, 0);
            }
           
            if ((gPlayerThree->type & 0x100) == 0x100) {
                func_8006E420(gPlayerThree, 2, 0);
                break;
            }

            break;
        case VERSUS:
        case BATTLE:
            func_8006E420(gPlayerOne, 0, 0);
            func_8006E420(gPlayerTwo, 1, 0);
       
            if (gPlayerCountSelection1 >= 3) {
                func_8006E420(gPlayerThree, 2, 0);
            }

            if (gPlayerCountSelection1 == 4) {
                func_8006E420(gPlayerFour, 3, 0);
                break;
            }

            break;
        }

        break;
    case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL:
    case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL:
        switch (gModeSelection) {     
        case GRAND_PRIX:
            func_8006E420(gPlayerOne, 0, 0);
            func_8006E420(gPlayerTwo, 1, 0);
            func_8006E420(gPlayerThree, 2, 0);
            func_8006E420(gPlayerFour, 3, 0);
            func_8006E420(gPlayerFive, 4, 0);
            func_8006E420(gPlayerSix, 5, 0);
            func_8006E420(gPlayerSeven, 6, 0);
            func_8006E420(gPlayerEight, 7, 0);

            break;
        case VERSUS:           
        case BATTLE:
            func_8006E420(gPlayerOne, 0, 0);
            func_8006E420(gPlayerTwo, 1, 0);

            break;
        case TIME_TRIALS:
            func_8006E420(gPlayerOne, 0, 0);
            
            if ((gPlayerTwo->type & 0x8000) == 0x8000) {
                func_8006E420(gPlayerTwo, 1, 0);
                break;
            }

            break;
        }

        break;
    case SCREEN_MODE_3P_4P_SPLITSCREEN:
        if ((VERSUS == gModeSelection) || (BATTLE == gModeSelection)) {
            func_8006E420(gPlayerOne, 0, 0);
            func_8006E420(gPlayerTwo, 1, 0);
            func_8006E420(gPlayerThree, 2, 0);

            if (gPlayerCountSelection1 == 4) {
                func_8006E420(gPlayerFour, 3, 0);
            }
        }

        break;
    }
}

void func_8006E420(Player* player, s8 arg1, s8 arg2) {
    s16 temp_s0;

    if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) {
        if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) {
            func_8006D194(player, arg1, arg2);
        }
   
        for (temp_s0 = 0; temp_s0 < 10; ++temp_s0) {
            func_8006CEC0(player, temp_s0, arg1, arg2);
            if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) || (gGamestate == ENDING)) {
                func_8006C9B8(player, temp_s0, arg1, arg2);
            }
            func_8006C6AC(player, temp_s0, arg1, arg2);
        }

        if (gModeSelection == BATTLE) {
            func_8006B9CC(player, arg1);
        }
    }
}

void func_8006E5AC(Player* player, s8 arg1, s8 arg2) {
    if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) {
        if ((player->effects & BOO_EFFECT) == BOO_EFFECT) {
            if (arg1 == arg2) {
                func_8006D474(player, arg1, arg2);
            }
        } else {
            func_8006D474(player, arg1, arg2);
        }
        func_8006DC54(player, arg1, arg2);
    }
}

void func_8006E634(Player* player, s8 arg1, s8 arg2) {
    if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) {
        if ((player->effects & BOO_EFFECT) == BOO_EFFECT) {
            if (arg1 == arg2) {
                func_8006D474(player, arg1, arg2);
            }
        } else {
            func_8006D474(player, arg1, arg2);
        }
        func_8006DC54(player, arg1, arg2);
    }
}

void func_8006E6BC(Player* player, s8 arg1, s8 arg2) {
    if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) {
        if ((player->effects & BOO_EFFECT) == BOO_EFFECT) {
            if (arg1 == arg2) {
                func_8006D474(player, arg1, arg2);
            }
        } else {
            func_8006D474(player, arg1, arg2);
        }
        func_8006DC54(player, arg1, arg2);
    }
}

void func_8006E744(Player* player, s8 arg1, s8 arg2) {
    if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) {
        if ((player->effects & BOO_EFFECT) == BOO_EFFECT) {
            if (arg1 == arg2) {
                func_8006D474(player, arg1, arg2);
            }
        } else {
            func_8006D474(player, arg1, arg2);
        }
        func_8006DC54(player, arg1, arg2);
    }
}

void func_8006E7CC(Player* player, s8 arg1, s8 arg2) {
    if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) {
        if ((player->effects & BOO_EFFECT) == BOO_EFFECT) {
            if (arg1 == arg2) {
                func_8006DD3C(player, arg1, arg2);
            }
        } else {
            func_8006DD3C(player, arg1, arg2);
        }
    }
}

void func_8006E848(Player* player, s8 arg1, s8 arg2) {
    if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) {
        if ((player->effects & BOO_EFFECT) == BOO_EFFECT) {
            if (arg1 == arg2) {
                func_8006DD3C(player, arg1, arg2);
            }
        } else {
            func_8006DD3C(player, arg1, arg2);
        }
    }
}

void func_8006E8C4(Player* player, s8 arg1, s8 arg2) {
    if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) {
        if ((player->effects & BOO_EFFECT) == BOO_EFFECT) {
            if (arg1 == arg2) {
                func_8006DD3C(player, arg1, arg2);
            }
        } else {
            func_8006DD3C(player, arg1, arg2);
        }
    }
}

void func_8006E940(Player* player, s8 arg1, s8 arg2) {
    if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) {
        if ((player->effects & BOO_EFFECT) == BOO_EFFECT) {
            if (arg1 == arg2) {
                func_8006DD3C(player, arg1, arg2);
            }
        } else {
            func_8006DD3C(player, arg1, arg2);
        }
    }
}

/***************************************************************/
/* Just a random 10 laying around in data, nothing to see here */
/***************************************************************/
s32 some_unused_data = 10;

#undef MAKE_RGB
