From e371625acbcd8ca2ce9c1c73e253f15864608b05 Mon Sep 17 00:00:00 2001 From: Tyler McGavran Date: Mon, 24 Jan 2022 23:22:05 -0500 Subject: [PATCH] Add in a struct for surface map entires (#150) Sourced from https://github.com/micro500/mariokart64/wiki/Surface-Map, only minor adjustments were made. Updated the bounding box corner struct a little based on information from the surface map struct. Refreshed several mips_to_c outputs Signed-off-by: Taggerung --- include/common_structs.h | 57 +++++- include/types.h | 16 -- include/variables.h | 3 + src/code_8001F980.c | 70 +++---- src/code_800393C0.c | 16 +- src/code_80071F00.c | 45 ++-- src/code_80280000.c | 2 + src/code_80281780.h | 3 - src/code_80290C20.c | 16 +- src/code_80296A50.c | 65 +++--- src/memory.c | 432 ++++++++++++++++++++------------------- 11 files changed, 389 insertions(+), 336 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index b09b50094..16aa22edf 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -190,19 +190,72 @@ typedef struct { /* 0x46 */ s16 unk_046; } UnkPlayerStruct258; // size = 0x48 +typedef struct { + s16 ob[3]; /* x, y, z */ + s16 tc[2]; /* texture coord */ + u8 ca[4]; /* color & alpha */ + +} mk64_Vtx; + +typedef struct { + s16 ob[3]; /* x, y, z */ + s16 tc[2]; /* texture coord */ + s8 flag[2]; /* unk flag */ + u8 ca[4]; /* color & alpha */ + +} mk_Vtx_Flag; + +/* +This struct has been copied (with only minor modifications) from +https://github.com/micro500/mariokart64/wiki/Surface-Map +on January 23rd, 2022 +The original author is assumed to be RenaKunisaki +*/ +typedef struct { + /* 0x00 */ u16 flags; + // Top bytes is a collections of flags, bottom byte is of unknown purpose + //bit 7: 1 = only tangible if landed on, not if driven onto? + // very weird. game crashes sometimes when playing with this. + //bit 6: 1 = Lakitu can drop you here (XXX verify) + //bit 4: 1 = out of bounds + //bit 3: 1 = player tumbles upon contact (may fall right through) + /* 0x02 */ u16 surfaceType; + /* 0x04 */ s16 vtx3[3]; //X, Y, Z of poly's third vertex + /* 0x0A */ s16 vtx2[3]; //X, Y, Z of poly's second vertex + /* 0x10 */ mk_Vtx_Flag *vtxs[3]; //pointer to the 3 vertices of this poly + //unsure why this exists along with a copy of two of the vertices. + //both are involved in hit detection. + /* 0x1C */ f32 height; + //normally 0; read at 0x802AB1A4. this value is added to the height Lakitu + //drops you at. changing it seems to make the surface intangible. + /* 0x20 */ f32 gravity; + //normally 1. The height Lakitu drops you off at is divided by this value + //(before adding the value at 0x1C), although if set to zero, he just tries + //to drop you at about the height of the finish line banner. Changing it + //has various unusual effects, making the polygon intangible or + //significantly reducing the gravity above it, probably depending on its Y + //position. + /* 0x24 */ f32 rotation; //normally about -0.001. no idea what this actually is. + /* 0x28 */ f32 height2; //changes Y position of all vertices (but not graphics or + //Lakitu drop position). Normally set to (track_height * -1) + about 6. +} mk64_surface_map_ram; // size = 0x2C + typedef struct { /* 0x00 */ f32 cornerX; /* 0x04 */ f32 cornerY; /* 0x08 */ f32 cornerZ; // Type of surface the corner is above /* 0x0C */ u8 surfaceType; - /* 0x0D */ u8 unk_0D; + // Close to being a copy of the top byte of the surface_map "flag" member + /* 0x0D */ u8 surfaceFlags; // Don't know if "tile" is right the right term // D_8015F580 is a pointer to an array of "tile" structs. This is an index to that array - /* 0x0E */ u16 tileIndex; + /* 0x0E */ u16 surfaceMapIndex; // cornerX/Y/Z place the corner "in the air" as it were, this member indicates the Y position of the corner's "on the ground" sibling // On flat ground this value should be cornerY - gKartBoundingBoxTable[characterId] /* 0x10 */ f32 cornerGroundY; + // Something lighting related. 1 when in a shaded region, 2 when in a tree's shadow + // 3 when getting crushed by a whomp, but curiously only the front left tyre will ever have this value /* 0x14 */ s32 unk_14; } KartBoundingBoxCorner; // size = 0x18 diff --git a/include/types.h b/include/types.h index a483f9226..6298dbf11 100644 --- a/include/types.h +++ b/include/types.h @@ -249,22 +249,6 @@ struct UnkStruct_800DDB68 { s32 *D_800ED620; s32 *D_800ED628; s32 *D_800ED630; s32 *D_800ED638; }; - -typedef struct { - s16 ob[3]; /* x, y, z */ - s16 tc[2]; /* texture coord */ - u8 ca[4]; /* color & alpha */ - -} mk64_Vtx; - -typedef struct { - s16 ob[3]; /* x, y, z */ - s16 tc[2]; /* texture coord */ - s8 flag[2]; /* unk flag */ - u8 ca[4]; /* color & alpha */ - -} mk_Vtx_Flag; - typedef struct { s8 ob[3]; s8 unk; diff --git a/include/variables.h b/include/variables.h index 84c2e88bc..b375dd5b1 100644 --- a/include/variables.h +++ b/include/variables.h @@ -101,6 +101,9 @@ extern struct_D_802BFB80 D_802BFB80[][8]; extern struct GfxPool *gGfxPool; // D_8014EF40 +extern mk64_surface_map_ram (*D_8015F580)[]; // Pointer to a list of surface_map entries +extern u16 D_8015F588; // Number of entires in D_8015F580 + extern Vec3f D_80165070[]; extern Vp D_802B8880[]; diff --git a/src/code_8001F980.c b/src/code_8001F980.c index 3c14e051a..93216fadf 100644 --- a/src/code_8001F980.c +++ b/src/code_8001F980.c @@ -1544,16 +1544,15 @@ GLOBAL_ASM("asm/non_matchings/code_8001F980/func_800231D8.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_80022F14(s8, s8, ?, ?); // extern -? func_80023038(void *, s8, ?, ?); // extern -s32 func_800230E4(void *, s8); // extern -? func_800231D8(void *, s8); // extern +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +? func_80022F14(s8, s8, ?, ?); /* extern */ +? func_80023038(Player *, s8, ?, ?); /* extern */ +s32 func_800230E4(Player *, s8); /* extern */ +? func_800231D8(Player *, s8); /* extern */ extern ? D_80164B80; extern ? D_8018D930; -extern f32 gCourseTimer; -void func_800235AC(void *arg0, s8 arg1) { +void func_800235AC(Player *arg0, s8 arg1) { s32 *sp24; s16 temp_v0; s32 *temp_v1_2; @@ -1576,36 +1575,36 @@ void func_800235AC(void *arg0, s8 arg1) { s32 phi_v0_6; s32 phi_v0_7; - if (((arg0->unk0 & 0x100) == 0x100) && (arg0 == gPlayerThree)) { + if (((arg0->unk_000 & 0x100) == 0x100) && (arg0 == gPlayerThree)) { func_80022F14(arg1, 0x1C0000, 0x3E99999A); func_80023038(arg0, arg1, 0xE0, 0x3E99999A); *(&D_80164B80 + (arg1 * 4)) = 0; return; } - temp_v0 = arg0->unkCA; + temp_v0 = arg0->unk_0CA; temp_v1 = temp_v0 & 0x10; if ((temp_v1 == 0x10) && ((temp_v0 & 4) == 4)) { - func_80022F14(arg0, arg1, 0x646464, 0x3F000000); + func_80022F14((s8) arg0, arg1, 0x646464, 0x3F000000); func_80023038(arg0, arg1, 0xFF0000, 0x3DCCCCCD); return; } if ((temp_v0 & 4) == 4) { - func_80022F14(arg0, arg1, 0, 0x3F800000); + func_80022F14((s8) arg0, arg1, 0, 0x3F800000); func_80023038(arg0, arg1, 0, 0x3F800000); return; } if (temp_v1 == 0x10) { - func_80022F14(arg0, arg1, 0x646464, 0x3F000000); + func_80022F14((s8) arg0, arg1, 0x646464, 0x3F000000); func_80023038(arg0, arg1, 0xFF0000, 0x3DCCCCCD); return; } if ((temp_v0 & 0x20) == 0x20) { - func_80022F14(arg0, arg1, 0, 0x3DCCCCCD); + func_80022F14((s8) arg0, arg1, 0, 0x3DCCCCCD); func_80023038(arg0, arg1, 0, 0x3DCCCCCD); return; } - temp_v0_2 = arg0->unkBC; - if (((temp_v0_2 & 0x40000000) == 0x40000000) && (arg0->unkB0 < 0x78)) { + temp_v0_2 = arg0->unk_0BC; + if (((temp_v0_2 & 0x40000000) == 0x40000000) && ((s32) arg0->unk_0B0 < 0x78)) { temp_t6 = arg1 * 4; temp_v1_2 = temp_t6 + &D_80164B80; temp_v0_3 = *temp_v1_2 + 5; @@ -1618,33 +1617,29 @@ void func_800235AC(void *arg0, s8 arg1) { phi_v0_2 = phi_v0; if ((phi_v0 >= 0) && (phi_v0 < 0xB)) { sp24 = temp_v1_2; - func_80022F14(arg0, arg1, 0x808080, 0x3F4CCCCD); + func_80022F14((s8) arg0, arg1, 0x808080, 0x3F4CCCCD); func_80023038(arg0, arg1, 0, 0x3F4CCCCD); phi_v0_2 = *temp_v1_2; } phi_v0_3 = phi_v0_2; if ((phi_v0_2 >= 0xB) && (phi_v0_2 < 0x15)) { sp24 = temp_t6 + &D_80164B80; - func_80022F14(arg0, arg1, 0x70, 0x3F4CCCCD); + func_80022F14((s8) arg0, arg1, 0x70, 0x3F4CCCCD); func_80023038(arg0, arg1, 0, 0x3F4CCCCD); phi_v0_3 = *(temp_t6 + &D_80164B80); } if ((phi_v0_3 >= 0x15) && (phi_v0_3 < 0x1F)) { - func_80022F14(arg0, arg1, 0x8F8F00, 0x3F4CCCCD); + func_80022F14((s8) arg0, arg1, 0x8F8F00, 0x3F4CCCCD); func_80023038(arg0, arg1, 0, 0x3F4CCCCD); - return; } - // Duplicate return node #50. Try simplifying control flow for better match - return; - } - if (((temp_v0_2 & 0x200) != 0) && (temp_v0_4 = arg1 * 4, temp_v1_3 = gCourseTimer - *(&D_8018D930 + temp_v0_4), ((temp_v1_3 < 9) != 0))) { + } else if (((temp_v0_2 & 0x200) != 0) && (temp_v0_4 = arg1 * 4, temp_v1_3 = (s32) gCourseTimer - *(&D_8018D930 + temp_v0_4), ((temp_v1_3 < 9) != 0))) { if (temp_v1_3 >= 7) { temp_v1_4 = temp_v0_4 + &D_80164B80; - *temp_v1_4 = *temp_v1_4 + 0xA; + *temp_v1_4 += 0xA; phi_v1 = temp_v1_4; } else { temp_v1_5 = temp_v0_4 + &D_80164B80; - *temp_v1_5 = *temp_v1_5 + 5; + *temp_v1_5 += 5; phi_v1 = temp_v1_5; } temp_v0_5 = *phi_v1; @@ -1656,45 +1651,40 @@ void func_800235AC(void *arg0, s8 arg1) { phi_v0_5 = phi_v0_4; if ((phi_v0_4 >= 0) && (phi_v0_4 < 0xB)) { sp24 = phi_v1; - func_80022F14(arg0, arg1, 0x70, 0x3F4CCCCD); + func_80022F14((s8) arg0, arg1, 0x70, 0x3F4CCCCD); func_80023038(arg0, arg1, 0, 0x3F4CCCCD); phi_v0_5 = *phi_v1; } phi_v0_6 = phi_v0_5; if ((phi_v0_5 >= 0xB) && (phi_v0_5 < 0x15)) { sp24 = phi_v1; - func_80022F14(arg0, arg1, 0x707000, 0x3F4CCCCD); + func_80022F14((s8) arg0, arg1, 0x707000, 0x3F4CCCCD); func_80023038(arg0, arg1, 0, 0x3F4CCCCD); phi_v0_6 = *phi_v1; } phi_v0_7 = phi_v0_6; if ((phi_v0_6 >= 0x15) && (phi_v0_6 < 0x1F)) { sp24 = phi_v1; - func_80022F14(arg0, arg1, 0x700000, 0x3F4CCCCD); + func_80022F14((s8) arg0, arg1, 0x700000, 0x3F4CCCCD); func_80023038(arg0, arg1, 0, 0x3F4CCCCD); phi_v0_7 = *phi_v1; } if (phi_v0_7 >= 0x1F) { - func_80022F14(arg0, arg1, 0x7000, 0x3F4CCCCD); + func_80022F14((s8) arg0, arg1, 0x7000, 0x3F4CCCCD); func_80023038(arg0, arg1, 0, 0x3F4CCCCD); - return; } - // Duplicate return node #50. Try simplifying control flow for better match - return; - } - if (func_800230E4(arg0, arg1) != 1) { - temp_v0_6 = arg0->unk1F4; - if (((temp_v0_6 & 1) == 1) || ((temp_v0_6 & 2) == 2) || ((arg0->unk1AC & 3) == 3)) { - func_80022F14(arg0, arg1, 0, 0x3E99999A); + } else if (func_800230E4(arg0, arg1) != 1) { + temp_v0_6 = arg0->boundingBoxCorners[3].unk_14; + if (((temp_v0_6 & 1) == 1) || ((temp_v0_6 & 2) == 2) || ((arg0->boundingBoxCorners[0].unk_14 & 3) == 3)) { + func_80022F14((s8) arg0, arg1, 0, 0x3E99999A); func_80023038(arg0, arg1, 0x6F6F6F, 0x3E99999A); return; } func_800231D8(arg0, arg1); - if ((arg0->unkCA & 0x1000) == 0x1000) { - func_80022F14(arg0, arg1, 0, 0x3E99999A); + if ((arg0->unk_0CA & 0x1000) == 0x1000) { + func_80022F14((s8) arg0, arg1, 0, 0x3E99999A); func_80023038(arg0, arg1, 0xF0F0F0, 0x3E99999A); } - // Duplicate return node #50. Try simplifying control flow for better match } } #else diff --git a/src/code_800393C0.c b/src/code_800393C0.c index 2ec0714bc..4cb55837d 100644 --- a/src/code_800393C0.c +++ b/src/code_800393C0.c @@ -238,15 +238,15 @@ void spawn_player(Player *player, s8 playerIndex, f32 arg2, f32 arg3, f32 arg4, player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceType = 0; player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceType = 0; - player->boundingBoxCorners[FRONT_LEFT_TYRE].unk_0D = 0; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].unk_0D = 0; - player->boundingBoxCorners[BACK_LEFT_TYRE].unk_0D = 0; - player->boundingBoxCorners[BACK_RIGHT_TYRE].unk_0D = 0; + player->boundingBoxCorners[FRONT_LEFT_TYRE].surfaceFlags = 0; + player->boundingBoxCorners[FRONT_RIGHT_TYRE].surfaceFlags = 0; + player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceFlags = 0; + player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceFlags = 0; - player->boundingBoxCorners[FRONT_LEFT_TYRE].tileIndex = 0; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].tileIndex = 0; - player->boundingBoxCorners[BACK_LEFT_TYRE].tileIndex = 0; - player->boundingBoxCorners[BACK_RIGHT_TYRE].tileIndex = 0; + player->boundingBoxCorners[FRONT_LEFT_TYRE].surfaceMapIndex = 0; + player->boundingBoxCorners[FRONT_RIGHT_TYRE].surfaceMapIndex = 0; + player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceMapIndex = 0; + player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceMapIndex = 0; player->boundingBoxCorners[FRONT_RIGHT_TYRE].unk_14 = 0; player->boundingBoxCorners[FRONT_LEFT_TYRE].unk_14 = 0; diff --git a/src/code_80071F00.c b/src/code_80071F00.c index 0b49cfdc4..5fc4b5c9e 100644 --- a/src/code_80071F00.c +++ b/src/code_80071F00.c @@ -9995,12 +9995,12 @@ GLOBAL_ASM("asm/non_matchings/code_80071F00/func_800808CC.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_80088A58(?); // extern +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +s32 func_80088A58(?); /* extern */ -void func_80080A14(void *arg1) { +void func_80080A14(s32 arg0, Player *player) { if (func_80088A58(0x41400000) != 0) { - arg1->unk1AC = arg1->unk1AC | 3; + player->boundingBoxCorners[0].unk_14 |= 3; } } #else @@ -10325,7 +10325,7 @@ GLOBAL_ASM("asm/non_matchings/code_80071F00/func_80081208.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 ? func_80072100(s32 *); /* extern */ s32 func_8007223C(s32, ?); /* extern */ ? func_800722CC(s32, ?); /* extern */ @@ -10338,14 +10338,17 @@ s32 func_80072320(s32, ?); /* extern */ ? func_800801FC(s32); /* extern */ ? func_80080408(s32); /* extern */ ? func_800808CC(s32); /* extern */ -? func_80080A14(s32, void *); /* extern */ +? func_80080A14(s32, Player *); /* extern */ ? func_80080A4C(s32, s32); /* extern */ ? func_80080B28(s32, s32); /* extern */ ? func_80080FEC(s32); /* extern */ ? func_800810F4(s32); /* extern */ ? func_8008A4CC(s32); /* extern */ +extern s16 D_80165750; extern ? D_80165834; extern ? D_80165C18; +extern s32 D_80183EA0; +extern s32 D_8018C3F0; extern ? D_8018C5F0; void func_80081210(void) { @@ -10369,7 +10372,7 @@ void func_80081210(void) { s32 *phi_s2_2; s32 phi_s4_2; s32 phi_v0; - void *phi_s3; + Player *phi_s3; s32 *phi_s1; s32 phi_s4_3; s32 phi_s2_3; @@ -10377,12 +10380,12 @@ void func_80081210(void) { s32 phi_s4_4; s32 *phi_s2_5; - D_80165834.unk0 = D_80165834.unk0 + 0x100; - D_80165834.unk2 = D_80165834.unk2 + 0x200; + D_80165834.unk0 = (u16) (D_80165834.unk0 + 0x100); + D_80165834.unk2 = (u16) (D_80165834.unk2 + 0x200); phi_s4 = 0; phi_s4_4 = 0; phi_s4_3 = 0; - if (D_80165750 > 0) { + if ((s32) D_80165750 > 0) { phi_s2 = &D_80183EA0; do { temp_s0 = *phi_s2; @@ -10391,15 +10394,15 @@ void func_80081210(void) { temp_s4 = phi_s4 + 1; phi_s2 += 4; phi_s4 = temp_s4; - } while (temp_s4 < D_80165750); + } while (temp_s4 < (s32) D_80165750); } func_8007F8D8(); temp_v0 = D_80165750; phi_s2_2 = &D_80183EA0; phi_s4_2 = 0; - phi_v0 = temp_v0; + phi_v0 = (s32) temp_v0; phi_s4_3 = 0; - if (temp_v0 > 0) { + if ((s32) temp_v0 > 0) { do { temp_s0_2 = *phi_s2_2; temp_s1 = (temp_s0_2 * 0xE0) + &D_80165C18; @@ -10409,7 +10412,7 @@ void func_80081210(void) { case 1: func_8007ED6C(temp_s0_2); block_14: - phi_v0 = D_80165750; + phi_v0 = (s32) D_80165750; break; case 2: func_8007F5A8(temp_s0_2); @@ -10435,14 +10438,14 @@ block_14: } phi_s3 = gPlayerOne; do { - phi_s3->unk1AC = phi_s3->unk1AC & ~3; - phi_s3->unk46 = phi_s3->unk46 & 0xFFF9; + phi_s3->boundingBoxCorners[0].unk_14 &= -4; + phi_s3->unk_046 &= 0xFFF9; phi_s1 = &D_80183EA0; phi_s2_3 = 0; - if (D_80165750 > 0) { + if ((s32) D_80165750 > 0) { do { temp_s0_3 = *phi_s1; - if ((phi_s3->unkBC & 0x80000000) == 0) { + if ((phi_s3->unk_0BC & 0x80000000) == 0) { func_80080B28(temp_s0_3, phi_s4_3); } if (func_8007223C(temp_s0_3, 0x20000) != 0) { @@ -10454,14 +10457,14 @@ block_14: temp_s2 = phi_s2_3 + 1; phi_s1 += 4; phi_s2_3 = temp_s2; - } while (temp_s2 < D_80165750); + } while (temp_s2 < (s32) D_80165750); } temp_s4_3 = phi_s4_3 + 1; phi_s3 += 0xDD8; phi_s4_3 = temp_s4_3; } while (temp_s4_3 < 8); func_8007542C(3); - if (D_80165750 > 0) { + if ((s32) D_80165750 > 0) { phi_s2_4 = &D_80183EA0; do { temp_s0_4 = *phi_s2_4; @@ -10472,7 +10475,7 @@ block_14: temp_s4_4 = phi_s4_4 + 1; phi_s2_4 += 4; phi_s4_4 = temp_s4_4; - } while (temp_s4_4 < D_80165750); + } while (temp_s4_4 < (s32) D_80165750); } phi_s2_5 = &D_8018C3F0; do { diff --git a/src/code_80280000.c b/src/code_80280000.c index fbf592c05..dcbe591bb 100644 --- a/src/code_80280000.c +++ b/src/code_80280000.c @@ -18,6 +18,8 @@ extern u16 D_80150112; extern u16 D_80164AF0; extern u32 D_8018D120; extern s32 gPrevLoadedAddress; +extern mk64_surface_map_ram (*D_8015F580)[]; +extern u16 D_8015F588; // Number of entires in D_8015F580 extern u16 gIsInQuitToMenuTransition, gQuitToMenuTransitionCounter; extern s32 D_802874A0; diff --git a/src/code_80281780.h b/src/code_80281780.h index 7ba625082..6e1946b76 100644 --- a/src/code_80281780.h +++ b/src/code_80281780.h @@ -50,9 +50,6 @@ extern u16 D_8015F6F0; extern s32 D_8015F59C; extern s32 D_8015F5A0; extern s32 D_8015F58C; -extern u16 D_8015F588; - -extern s32 D_8015F580; extern s32 D_00821D10; extern s32 D_00825800; diff --git a/src/code_80290C20.c b/src/code_80290C20.c index 5203a890c..0619f470b 100644 --- a/src/code_80290C20.c +++ b/src/code_80290C20.c @@ -2184,15 +2184,15 @@ GLOBAL_ASM("asm/non_matchings/code_80290C20/func_80295A38.s") void func_80295BF8(s32 playerIndex) { Player* player = &gPlayers[playerIndex]; func_802AAAAC(&player->unk_110); - player->boundingBoxCorners[FRONT_RIGHT_TYRE].unk_0D = 0.0f; - player->boundingBoxCorners[FRONT_LEFT_TYRE].unk_0D = 0.0f; - player->boundingBoxCorners[BACK_RIGHT_TYRE].unk_0D = 0.0f; - player->boundingBoxCorners[BACK_LEFT_TYRE].unk_0D = 0.0f; + player->boundingBoxCorners[FRONT_RIGHT_TYRE].surfaceFlags = 0; + player->boundingBoxCorners[FRONT_LEFT_TYRE].surfaceFlags = 0; + player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceFlags = 0; + player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceFlags = 0; - player->boundingBoxCorners[FRONT_RIGHT_TYRE].tileIndex = 0x1388; - player->boundingBoxCorners[FRONT_LEFT_TYRE].tileIndex = 0x1388; - player->boundingBoxCorners[BACK_RIGHT_TYRE].tileIndex = 0x1388; - player->boundingBoxCorners[BACK_LEFT_TYRE].tileIndex = 0x1388; + player->boundingBoxCorners[FRONT_RIGHT_TYRE].surfaceMapIndex = 0x1388; + player->boundingBoxCorners[FRONT_LEFT_TYRE].surfaceMapIndex = 0x1388; + player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceMapIndex = 0x1388; + player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceMapIndex = 0x1388; } diff --git a/src/code_80296A50.c b/src/code_80296A50.c index a1f9d7e6c..6e1261ead 100644 --- a/src/code_80296A50.c +++ b/src/code_80296A50.c @@ -511,18 +511,18 @@ void func_80297760(struct bigboi *arg0, struct bigboi *arg1) { arg1->unk_004 = func_802ABE30(arg1->unk_000, arg1->unk_004, arg1->unk_008, arg0->unk_03A); } -void func_802977B0(struct bigboi *arg0) { - arg0->unk_1C4 = arg0->unk_1C4 | 2; - arg0->unk_1AC = arg0->unk_1AC | 2; - arg0->unk_1F4 = arg0->unk_1F4 | 2; - arg0->unk_1DC = arg0->unk_1DC | 2; +void func_802977B0(Player *arg0) { + arg0->boundingBoxCorners[1].unk_14 |= 2; + arg0->boundingBoxCorners[0].unk_14 |= 2; + arg0->boundingBoxCorners[3].unk_14 |= 2; + arg0->boundingBoxCorners[2].unk_14 |= 2; } -void func_802977E4(struct bigboi *arg0) { - arg0->unk_1C4 = arg0->unk_1C4 & 0xFFFD; - arg0->unk_1AC = arg0->unk_1AC & 0xFFFD; - arg0->unk_1F4 = arg0->unk_1F4 & 0xFFFD; - arg0->unk_1DC = arg0->unk_1DC & 0xFFFD; +void func_802977E4(Player *arg0) { + arg0->boundingBoxCorners[1].unk_14 &= 0xFFFD; + arg0->boundingBoxCorners[0].unk_14 &= 0xFFFD; + arg0->boundingBoxCorners[3].unk_14 &= 0xFFFD; + arg0->boundingBoxCorners[2].unk_14 &= 0xFFFD; } #ifdef MIPS_TO_C @@ -5330,30 +5330,31 @@ GLOBAL_ASM("asm/non_matchings/code_actors/func_8029F2FC.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_8008DABC(void *, s8); // extern -? func_800C90F4(s32, s32); // extern -? func_800C98B8(void *, void *, ?, void *); // extern -? func_802977B0(void *); // extern +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +? func_8008DABC(Player *, s8); /* extern */ +? func_800C90F4(s32, s32); /* extern */ +? func_800C98B8(f32 *, f32 *, ?, Player *); /* extern */ +? func_802977B0(Player *); /* extern */ +f32 sqrtf(f32, f32); /* extern */ extern s32 D_80162DF8; -? func_8029F408(void *arg0, void *arg1) { +s32 func_8029F408(Player *arg0, Player *arg1) { f32 sp1C; + Player *temp_a0; + Player *temp_a3; f32 temp_f0; f32 temp_f0_2; f32 temp_f2; f32 temp_f2_2; - void *temp_a0; - void *temp_a3; - temp_f2 = arg1->unk18 - arg0->unk14; + temp_f2 = arg1->posY - arg0->posX; if ((temp_f2 < 0.0f) && (temp_f2 < -60.0f)) { return 0; } if (temp_f2 > 60.0f) { return 0; } - temp_f0 = arg1->unk20 - arg0->unk1C; + temp_f0 = arg1->rotX - arg0->posZ; if ((temp_f0 < 0.0f) && (temp_f0 < -60.0f)) { return 0; } @@ -5361,7 +5362,7 @@ extern s32 D_80162DF8; return 0; } arg0 = arg0; - temp_f0_2 = sqrtf((temp_f2 * temp_f2) + (temp_f0 * temp_f0)); + temp_f0_2 = sqrtf((temp_f2 * temp_f2) + (temp_f0 * temp_f0), 60.0f); temp_f2_2 = temp_f0_2; temp_a0 = arg0; if (temp_f0_2 > 60.0f) { @@ -5371,28 +5372,28 @@ extern s32 D_80162DF8; sp1C = temp_f2_2; func_802977B0(temp_a0); temp_a3 = arg0; - if ((temp_a3->unk18 - arg1->unk1C) < 0.0f) { + if ((temp_a3->posY - arg1->posZ) < 0.0f) { return 0; } - if ((temp_a3->unk70 + arg1->unkC) < temp_f2_2) { + if ((temp_a3->unk_070 + (bitwise f32) arg1->unk_00C) < temp_f2_2) { return 0; } - if ((temp_a3->unk0 & 0x4000) != 0) { - if ((temp_a3->unkBC & 0x200) != 0) { - arg1->unk2 = arg1->unk2 | 0x400; - arg1->unk28 = 8.0f; + if ((temp_a3->unk_000 & 0x4000) != 0) { + if ((temp_a3->unk_0BC & 0x200) != 0) { + arg1->unk_002 = (s16) arg1->unk_002 | 0x400; + arg1->rotZ = 8.0f; arg0 = temp_a3; - func_800C98B8(temp_a3 + 0x14, temp_a3 + 0x34, 0x19018010, temp_a3); - func_800C90F4(((arg0 - gPlayerOne) / 0xDD8) & 0xFF, (arg0->unk254 * 0x10) + 0x2900800D); + func_800C98B8(&temp_a3->posX, &temp_a3->unk_034, 0x19018010, temp_a3); + func_800C90F4(((s32) (arg0 - gPlayerOne) / 3544) & 0xFF, (arg0->characterId * 0x10) + 0x2900800D); } else { arg0 = temp_a3; - func_8008DABC(temp_a3, (temp_a3 - gPlayerOne) / 0xDD8); - if ((gModeSelection == TIME_TRIALS) && ((arg0->unk0 & 0x1000) == 0)) { + func_8008DABC(temp_a3, (s8) ((s32) (temp_a3 - gPlayerOne) / 3544)); + if ((gModeSelection == 1) && ((arg0->unk_000 & 0x1000) == 0)) { D_80162DF8 = 1; } } } else { - func_8008DABC(temp_a3, (temp_a3 - gPlayerOne) / 0xDD8); + func_8008DABC(temp_a3, (s8) ((s32) (temp_a3 - gPlayerOne) / 3544)); } return 1; } diff --git a/src/memory.c b/src/memory.c index bb9aefec2..b4550b2e9 100644 --- a/src/memory.c +++ b/src/memory.c @@ -2508,17 +2508,17 @@ GLOBAL_ASM("asm/non_matchings/memory/func_802ABDF4.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 f32 func_802ABE30(f32 arg0, f32 arg1, f32 arg2, s32 arg3) { f32 temp_f2; - void *temp_v0; + mk64_surface_map_ram *temp_v0; - temp_v0 = ((arg3 & 0xFFFF) * 0x2C) + D_8015F580; - temp_f2 = temp_v0->unk20; + temp_v0 = &(*D_8015F580)[arg3 & 0xFFFF]; + temp_f2 = temp_v0->gravity; if (temp_f2 == 0.0f) { return arg1; } - return ((temp_v0->unk1C * arg0) + (temp_v0->unk24 * arg2) + temp_v0->unk28) / -temp_f2; + return ((temp_v0->height * arg0) + (temp_v0->rotation * arg2) + temp_v0->height2) / -temp_f2; } #else GLOBAL_ASM("asm/non_matchings/memory/func_802ABE30.s") @@ -3264,14 +3264,18 @@ GLOBAL_ASM("asm/non_matchings/memory/func_802AD278.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_802AC760(void *, f32, f32, f32, f32, ?32, ?32, ?32, ?32); // extern -s32 func_802ACBA4(void *, void *, f32, f32, f32, s32, ?32, ?32, ?32); // extern -s32 func_802AD278(void *, void *, f32, f32, f32, s32, ?32, ?32, ?32); // extern +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +s32 func_802AC760(void *, f32, f32, f32, f32, f32, f32, f32, f32); /* extern */ +s32 func_802ACBA4(void *, void *, f32, f32, f32, s32, f32, f32, f32); /* extern */ +s32 func_802AD278(void *, void *, f32, f32, f32, s32, f32, f32, f32); /* extern */ extern ? D_8014F110; extern s32 D_8015F584; +extern s16 D_8015F6E8; +extern s16 D_8015F6EA; +extern s16 D_8015F6F0; +extern s16 D_8015F6F2; -s32 func_802AD950(void *arg0, void *arg1, f32 arg2, f32 arg3, f32 arg4, ?32 arg5, ?32 arg6, ?32 arg7) { +s32 func_802AD950(void *arg0, void *arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7) { s16 temp_v0_4; s16 temp_v1; s32 temp_f10; @@ -3301,17 +3305,17 @@ s32 func_802AD950(void *arg0, void *arg1, f32 arg2, f32 arg3, f32 arg4, ?32 arg5 arg0->unk14 = 1000.0f; temp_v0 = arg0->unkA; phi_s4_6 = 0; - if ((temp_v0 < D_8015F588) && (func_802AC760(arg1, arg2, arg3, arg4, (bitwise f32) temp_v0, arg5, arg6, arg7) == 1)) { + if (((s32) temp_v0 < (s32) D_8015F588) && (func_802AC760(arg1, arg2, arg3, arg4, (bitwise f32) temp_v0, arg5, arg6, arg7) == 1)) { phi_s4_6 = 0x4000; } temp_v0_2 = arg0->unk6; phi_s4_4 = phi_s4_6; - if ((temp_v0_2 < D_8015F588) && (func_802ACBA4(arg0, arg1, arg2, arg3, arg4, temp_v0_2, arg5, arg6, arg7) == 1)) { + if (((s32) temp_v0_2 < (s32) D_8015F588) && (func_802ACBA4(arg0, arg1, arg2, arg3, arg4, (s32) temp_v0_2, arg5, arg6, arg7) == 1)) { phi_s4_4 = (phi_s4_6 | 0x2000) & 0xFFFF; } temp_v0_3 = arg0->unk8; phi_s4 = phi_s4_4; - if ((temp_v0_3 < D_8015F588) && (func_802AD278(arg0, arg1, arg2, arg3, arg4, temp_v0_3, arg5, arg6, arg7) == 1)) { + if (((s32) temp_v0_3 < (s32) D_8015F588) && (func_802AD278(arg0, arg1, arg2, arg3, arg4, (s32) temp_v0_3, arg5, arg6, arg7) == 1)) { phi_s4 = (phi_s4_4 | 0x8000) & 0xFFFF; } phi_s4_2 = phi_s4; @@ -3321,28 +3325,28 @@ s32 func_802AD950(void *arg0, void *arg1, f32 arg2, f32 arg3, f32 arg4, ?32 arg5 } temp_v0_4 = D_8015F6EA; temp_v1 = D_8015F6F2; - temp_f10 = (arg2 - temp_v0_4) / ((D_8015F6E8 - temp_v0_4) / 0x20); - temp_f16 = (arg4 - temp_v1) / ((D_8015F6F0 - temp_v1) / 0x20); - if (temp_f10 < 0) { + temp_f10 = (s32) ((arg2 - (f32) temp_v0_4) / (f32) ((s32) (D_8015F6E8 - temp_v0_4) / 32)); + temp_f16 = (s32) ((arg4 - (f32) temp_v1) / (f32) ((s32) (D_8015F6F0 - temp_v1) / 32)); + if ((s32) (s16) temp_f10 < 0) { return 0; } - if (temp_f16 < 0) { + if ((s32) (s16) temp_f16 < 0) { return 0; } - if (temp_f10 >= 0x20) { + if ((s32) (s16) temp_f10 >= 0x20) { return 0; } - if (temp_f16 >= 0x20) { + if ((s32) (s16) temp_f16 >= 0x20) { return 0; } - temp_v1_2 = ((temp_f10 + (temp_f16 << 5)) * 4) + &D_8014F110; + temp_v1_2 = ((s16) ((s16) temp_f10 + ((s16) temp_f16 << 5)) * 4) + &D_8014F110; temp_s6 = temp_v1_2->unk2; phi_s3 = 0; if (temp_s6 == 0) { } else { phi_s2 = temp_v1_2->unk0; - if (temp_s6 > 0) { + if ((s32) temp_s6 > 0) { loop_22: phi_s4_3 = phi_s4_2; phi_s4_5 = phi_s4_2; @@ -3350,16 +3354,16 @@ loop_22: } else { temp_v0_5 = *(D_8015F584 + (phi_s2 * 2)); - temp_v1_3 = *(D_8015F580 + (temp_v0_5 * 0x2C)); + temp_v1_3 = (*D_8015F580)[temp_v0_5].flags; if ((temp_v1_3 & 0x4000) != 0) { - if (((phi_s4_2 & 0x4000) == 0) && (arg0->unkA != temp_v0_5) && (func_802AC760(arg0, (bitwise f32) arg1, arg2, arg3, arg4, temp_v0_5, arg5, arg6, arg7) == 1)) { + if (((phi_s4_2 & 0x4000) == 0) && (arg0->unkA != temp_v0_5) && (func_802AC760(arg0, (bitwise f32) arg1, arg2, arg3, arg4, (bitwise f32) temp_v0_5, arg5, arg6, arg7) == 1)) { phi_s4_5 = (phi_s4_2 | 0x4000) & 0xFFFF; } } else if ((temp_v1_3 & 0x8000) != 0) { - if (((phi_s4_2 & 0x8000) == 0) && (arg0->unk8 != temp_v0_5) && (func_802AD278(arg0, arg1, arg2, arg3, arg4, temp_v0_5, arg5, arg6, arg7) == 1)) { + if (((phi_s4_2 & 0x8000) == 0) && (arg0->unk8 != temp_v0_5) && (func_802AD278(arg0, arg1, arg2, arg3, arg4, (s32) temp_v0_5, arg5, arg6, arg7) == 1)) { phi_s4_5 = (phi_s4_2 | 0x8000) & 0xFFFF; } - } else if (((phi_s4_2 & 0x2000) == 0) && (arg0->unk6 != temp_v0_5) && (func_802ACBA4(arg0, arg1, arg2, arg3, arg4, temp_v0_5, arg5, arg6, arg7) == 1)) { + } else if (((phi_s4_2 & 0x2000) == 0) && (arg0->unk6 != temp_v0_5) && (func_802ACBA4(arg0, arg1, arg2, arg3, arg4, (s32) temp_v0_5, arg5, arg6, arg7) == 1)) { phi_s4_5 = (phi_s4_2 | 0x2000) & 0xFFFF; } temp_t7 = (phi_s3 + 1) & 0xFFFF; @@ -3367,7 +3371,7 @@ loop_22: phi_s2 = (phi_s2 + 1) & 0xFFFF; phi_s3 = temp_t7; phi_s4_3 = phi_s4_5; - if (temp_t7 < temp_s6) { + if (temp_t7 < (s32) temp_s6) { goto loop_22; } } @@ -3498,17 +3502,21 @@ GLOBAL_ASM("asm/non_matchings/memory/func_802ADDC8.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_802ABB04(f32, f32, s32); // extern -f32 func_802ABE30(f32, f32, f32, s32); // extern +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +s32 func_802ABB04(f32, f32, s32); /* extern */ +f32 func_802ABE30(f32, f32, f32, s32); /* extern */ extern ? D_8014F110; extern s32 D_8015F584; -extern f32 D_802B9E4C; -extern f32 D_802B9E50; -extern f32 D_802B9E54; -extern f32 D_802B9E58; -extern f32 D_802B9E5C; -extern f32 D_802B9E60; +extern s16 D_8015F6E8; +extern s16 D_8015F6EA; +extern s16 D_8015F6F0; +extern s16 D_8015F6F2; +static f32 D_802B9E4C = -3000.0f; +static f32 D_802B9E50 = 3000.0f; +static f32 D_802B9E54 = 3000.0f; +static f32 D_802B9E58 = 3000.0f; +static f32 D_802B9E5C = 3000.0f; +static f32 D_802B9E60 = 3000.0f; f32 func_802AE1C0(f32 arg0, f32 arg1, f32 arg2) { f32 temp_f0; @@ -3531,20 +3539,20 @@ f32 func_802AE1C0(f32 arg0, f32 arg1, f32 arg2) { temp_v0 = D_8015F6EA; temp_f20 = D_802B9E4C; temp_v1 = D_8015F6F2; - temp_f4 = (arg0 - temp_v0) / ((D_8015F6E8 - temp_v0) / 0x20); - temp_f6 = (arg2 - temp_v1) / ((D_8015F6F0 - temp_v1) / 0x20); - temp_t0 = temp_f6 << 5; - temp_t2 = ((temp_f4 + temp_t0) * 4) + &D_8014F110; + temp_f4 = (s32) ((arg0 - (f32) temp_v0) / (f32) ((s32) (D_8015F6E8 - temp_v0) / 32)); + temp_f6 = (s32) ((arg2 - (f32) temp_v1) / (f32) ((s32) (D_8015F6F0 - temp_v1) / 32)); + temp_t0 = (s16) temp_f6 << 5; + temp_t2 = ((s16) ((s16) temp_f4 + temp_t0) * 4) + &D_8014F110; temp_t1 = temp_t2->unk2; phi_f20 = temp_f20; phi_f20_2 = temp_f20; - if (temp_f4 < 0) { + if ((s32) (s16) temp_f4 < 0) { return D_802B9E50; } - if (temp_f6 & 0x4000000) { + if ((s16) temp_f6 & 0x04000000) { return D_802B9E54; } - if (temp_f4 >= 0x20) { + if ((s32) (s16) temp_f4 >= 0x20) { return D_802B9E58; } if (temp_t0 >= 0x400) { @@ -3555,11 +3563,11 @@ f32 func_802AE1C0(f32 arg0, f32 arg1, f32 arg2) { } phi_s1 = temp_t2->unk0; phi_s2 = 0; - if (temp_t1 > 0) { + if ((s32) temp_t1 > 0) { do { temp_s0 = *(D_8015F584 + (phi_s1 * 2)); phi_f20_3 = phi_f20; - if (((*(D_8015F580 + (temp_s0 * 0x2C)) & 0x4000) != 0) && (func_802ABB04(arg0, arg2, temp_s0 & 0xFFFF) == 1)) { + if ((((*D_8015F580)[temp_s0].flags & 0x4000) != 0) && (func_802ABB04(arg0, arg2, temp_s0 & 0xFFFF) == 1)) { temp_f0 = func_802ABE30(arg0, arg1, arg2, temp_s0 & 0xFFFF); if ((temp_f0 <= arg1) && (phi_f20 < temp_f0)) { phi_f20_3 = temp_f0; @@ -3570,7 +3578,7 @@ f32 func_802AE1C0(f32 arg0, f32 arg1, f32 arg2) { phi_f20 = phi_f20_3; phi_s2 = temp_t9; phi_f20_2 = phi_f20_3; - } while (temp_t9 < temp_t1); + } while (temp_t9 < (s32) temp_t1); } return phi_f20_2; } @@ -3579,16 +3587,24 @@ GLOBAL_ASM("asm/non_matchings/memory/func_802AE1C0.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +extern s32 D_8015F59C; +extern s32 D_8015F5A0; extern s32 D_8015F5A4; +extern s16 D_8015F6E8; +extern s16 D_8015F6EA; +extern s16 D_8015F6EC; +extern s16 D_8015F6EE; +extern s16 D_8015F6F0; +extern s16 D_8015F6F2; extern s16 D_8015F6FA; extern s16 D_8015F6FC; -extern f32 D_802B9E64; -extern f32 D_802B9E68; -extern f32 D_802B9E6C; -extern f32 D_802B9E70; +static f32 D_802B9E64 = -0.9f; +static f32 D_802B9E68 = 0.9f; +static f32 D_802B9E6C = 0.1f; +static f32 D_802B9E70 = -0.1f; -void func_802AE434(void *arg0, void *arg1, void *arg2, s8 arg3, u16 arg4) { +void func_802AE434(mk_Vtx_Flag *arg0, mk_Vtx_Flag *arg1, mk_Vtx_Flag *arg2, s8 arg3, u16 arg4) { s16 spBA; s16 spB8; s16 spB6; @@ -3603,7 +3619,7 @@ void func_802AE434(void *arg0, void *arg1, void *arg2, s8 arg3, u16 arg4) { s16 sp48; s16 sp44; s16 sp42; - void *sp1C; + mk_Vtx_Flag *sp1C; /* compiler-managed */ f64 sp10; f64 sp8; f64 sp0; @@ -3617,6 +3633,10 @@ void func_802AE434(void *arg0, void *arg1, void *arg2, s8 arg3, u16 arg4) { f64 temp_f2; f64 temp_f4; f64 temp_f8; + mk64_surface_map_ram *temp_t0; + mk_Vtx_Flag *temp_t1; + mk_Vtx_Flag *temp_t2; + mk_Vtx_Flag *temp_t6; s16 temp_a0; s16 temp_a1; s16 temp_t3; @@ -3630,10 +3650,6 @@ void func_802AE434(void *arg0, void *arg1, void *arg2, s8 arg3, u16 arg4) { u16 temp_a0_3; u16 temp_a3_2; u16 temp_v1_2; - void *temp_t0; - void *temp_t1; - void *temp_t2; - void *temp_t6; s32 phi_a0; s32 phi_t3; s32 phi_t5; @@ -3649,168 +3665,168 @@ void func_802AE434(void *arg0, void *arg1, void *arg2, s8 arg3, u16 arg4) { u16 phi_t9; u16 phi_t8; - temp_t0 = (D_8015F588 * 0x2C) + D_8015F580; - temp_t0->unk10 = arg0; - temp_t0->unk14 = arg1; - temp_t0->unk18 = arg2; - if ((arg0->unk6 != 4) || (arg1->unk6 != 4) || (temp_t0->unk18->unk6 != 4)) { - temp_t6 = temp_t0->unk10; + temp_t0 = &(*D_8015F580)[D_8015F588]; + temp_t0->vtxs[0] = arg0; + temp_t0->vtxs[1] = arg1; + temp_t0->vtxs[2] = arg2; + if (((u16) arg0->tc[0] != 4) || ((u16) arg1->tc[0] != 4) || ((u16) temp_t0->vtxs[2]->tc[0] != 4)) { + temp_t6 = temp_t0->vtxs[0]; sp1C = temp_t6; - temp_t1 = temp_t0->unk14; - temp_t2 = temp_t0->unk18; - temp_a0 = temp_t6->unk0; - temp_t3 = temp_t1->unk0; - temp_a1 = temp_t6->unk4; - temp_t4 = temp_t1->unk4; - phi_a0 = temp_a0; - phi_t3 = temp_t3; - phi_t5 = temp_t2->unk0; - phi_a1 = temp_a1; - phi_t4 = temp_t4; - phi_v1 = temp_t2->unk4; - phi_a2 = temp_t6->unk2; - phi_a3 = temp_t1->unk2; - phi_v0 = temp_t2->unk2; + temp_t1 = temp_t0->vtxs[1]; + temp_t2 = temp_t0->vtxs[2]; + temp_a0 = temp_t6->ob[0]; + temp_t3 = temp_t1->ob[0]; + temp_a1 = temp_t6->ob[2]; + temp_t4 = temp_t1->ob[2]; + phi_a0 = (s32) temp_a0; + phi_t3 = (s32) temp_t3; + phi_t5 = (s32) temp_t2->ob[0]; + phi_a1 = (s32) temp_a1; + phi_t4 = (s32) temp_t4; + phi_v1 = (s32) temp_t2->ob[2]; + phi_a2 = (s32) temp_t6->ob[1]; + phi_a3 = (s32) temp_t1->ob[1]; + phi_v0 = (s32) temp_t2->ob[1]; if ((temp_a0 == temp_t3) && (temp_a1 == temp_t4)) { - temp_t0->unk18 = arg1; - temp_t0->unk14 = arg2; - phi_a0 = arg0->unk0; - phi_t3 = arg1->unk0; - phi_t5 = arg2->unk0; - phi_a1 = arg0->unk4; - phi_t4 = arg1->unk4; - phi_v1 = arg2->unk4; - phi_a2 = arg0->unk2; - phi_a3 = arg1->unk2; - phi_v0 = arg2->unk2; + temp_t0->vtxs[2] = arg1; + temp_t0->vtxs[1] = arg2; + phi_a0 = (s32) arg0->ob[0]; + phi_t3 = (s32) arg1->ob[0]; + phi_t5 = (s32) arg2->ob[0]; + phi_a1 = (s32) arg0->ob[2]; + phi_t4 = (s32) arg1->ob[2]; + phi_v1 = (s32) arg2->ob[2]; + phi_a2 = (s32) arg0->ob[1]; + phi_a3 = (s32) arg1->ob[1]; + phi_v0 = (s32) arg2->ob[1]; } if (phi_a0 >= phi_t3) { if (phi_a0 >= phi_t5) { - sp4A = phi_a0; + sp4A = (s16) phi_a0; } else { goto block_12; } } else if (phi_t3 >= phi_t5) { - sp4A = phi_t3; + sp4A = (s16) phi_t3; } else { block_12: - sp4A = phi_t5; + sp4A = (s16) phi_t5; } if (phi_a1 >= phi_t4) { if (phi_a1 >= phi_v1) { - sp48 = phi_a1; + sp48 = (s16) phi_a1; } else { goto block_19; } } else if (phi_t4 >= phi_v1) { - sp48 = phi_t4; + sp48 = (s16) phi_t4; } else { block_19: - sp48 = phi_v1; + sp48 = (s16) phi_v1; } if (phi_a2 >= phi_a3) { if (phi_a2 >= phi_v0) { - sp42 = phi_a2; + sp42 = (s16) phi_a2; } else { goto block_26; } } else if (phi_a3 >= phi_v0) { - sp42 = phi_a3; + sp42 = (s16) phi_a3; } else { block_26: - sp42 = phi_v0; + sp42 = (s16) phi_v0; } if (phi_t3 >= phi_a0) { if (phi_t5 >= phi_a0) { - sp44 = phi_a0; + sp44 = (s16) phi_a0; } else { goto block_33; } } else if (phi_t5 >= phi_t3) { - sp44 = phi_t3; + sp44 = (s16) phi_t3; } else { block_33: - sp44 = phi_t5; + sp44 = (s16) phi_t5; } if (phi_a3 >= phi_a2) { if (phi_v0 >= phi_a2) { - phi_t2 = phi_a2; + phi_t2 = (s16) phi_a2; } else { - phi_t2 = phi_v0; + phi_t2 = (s16) phi_v0; } } else if (phi_v0 >= phi_a3) { - phi_t2 = phi_a3; + phi_t2 = (s16) phi_a3; } else { - phi_t2 = phi_v0; + phi_t2 = (s16) phi_v0; } if (phi_t4 >= phi_a1) { if (phi_v1 >= phi_a1) { - phi_t1 = phi_a1; + phi_t1 = (s16) phi_a1; } else { - phi_t1 = phi_v1; + phi_t1 = (s16) phi_v1; } } else if (phi_v1 >= phi_t4) { - phi_t1 = phi_t4; + phi_t1 = (s16) phi_t4; } else { - phi_t1 = phi_v1; + phi_t1 = (s16) phi_v1; } - spAA = phi_v1; - spB8 = phi_a2; - spB2 = phi_a3; - spAC = phi_v0; + spAA = (s16) phi_v1; + spB8 = (s16) phi_a2; + spB2 = (s16) phi_a3; + spAC = (s16) phi_v0; temp_v0 = spB2 - spB8; temp_v1 = spAA - phi_t4; - spB6 = phi_a1; - spBA = phi_a0; + spB6 = (s16) phi_a1; + spBA = (s16) phi_a0; temp_a0_2 = phi_t4 - spB6; temp_a1_2 = spAC - spB2; temp_a2 = phi_t5 - phi_t3; temp_a3 = phi_t3 - spBA; - temp_f12 = (temp_v0 * temp_v1) - (temp_a0_2 * temp_a1_2); + temp_f12 = (f64) ((temp_v0 * temp_v1) - (temp_a0_2 * temp_a1_2)); temp_f18 = temp_f12 * temp_f12; sp10 = temp_f18; - temp_f14 = (temp_a0_2 * temp_a2) - (temp_a3 * temp_v1); + temp_f14 = (f64) ((temp_a0_2 * temp_a2) - (temp_a3 * temp_v1)); temp_f8 = temp_f14 * temp_f14; sp8 = temp_f8; - temp_f16 = (temp_a3 * temp_a1_2) - (temp_v0 * temp_a2); + temp_f16 = (f64) ((temp_a3 * temp_a1_2) - (temp_v0 * temp_a2)); temp_f4 = temp_f16 * temp_f16; sp0 = temp_f4; - temp_f2 = sqrtf(temp_f18 + temp_f8 + temp_f4); - if ((temp_f2 != 0.0) && ((temp_f0 = temp_f12 / temp_f2, sp58 = temp_f0, temp_f4_2 = temp_f14 / temp_f2, sp1C = (bitwise void *) temp_f4_2, sp54 = temp_f4_2, temp_f18_2 = temp_f16 / temp_f2, sp50 = temp_f18_2, sp4C = -((spBA * temp_f0) + (temp_f4_2 * spB8) + (temp_f18_2 * spB6)), (D_8015F59C == 0)) || (!(temp_f4_2 < D_802B9E64) && !(D_802B9E68 < temp_f4_2))) && ((D_8015F5A0 == 0) || !((bitwise f32) sp1C < D_802B9E6C) || !(D_802B9E70 < (bitwise f32) sp1C))) { - temp_t0->unkA = sp4A; - temp_t0->unk8 = phi_t1; - temp_t0->unk6 = phi_t2; - temp_t0->unk4 = sp44; - temp_t0->unkC = sp42; - temp_t0->unkE = sp48; - if (sp44 < D_8015F6EA) { + temp_f2 = (f64) sqrtf((f32) (temp_f18 + temp_f8 + temp_f4)); + if ((temp_f2 != 0.0) && ((temp_f0 = (f32) ((f64) (f32) temp_f12 / temp_f2), sp58 = temp_f0, temp_f4_2 = (f32) ((f64) (f32) temp_f14 / temp_f2), sp1C = temp_f4_2, sp54 = temp_f4_2, temp_f18_2 = (f32) ((f64) (f32) temp_f16 / temp_f2), sp50 = temp_f18_2, sp4C = -(((f32) spBA * temp_f0) + (temp_f4_2 * (f32) spB8) + (temp_f18_2 * (f32) spB6)), (D_8015F59C == 0)) || (!(temp_f4_2 < D_802B9E64) && !(D_802B9E68 < temp_f4_2))) && ((D_8015F5A0 == 0) || !(sp1C < D_802B9E6C) || !(D_802B9E70 < sp1C))) { + temp_t0->vtx2[0] = sp4A; + temp_t0->vtx3[2] = phi_t1; + temp_t0->vtx3[1] = phi_t2; + temp_t0->vtx3[0] = sp44; + temp_t0->vtx2[1] = sp42; + temp_t0->vtx2[2] = sp48; + if ((s32) sp44 < (s32) D_8015F6EA) { D_8015F6EA = sp44; } - if (phi_t2 < D_8015F6EE) { + if ((s32) phi_t2 < (s32) D_8015F6EE) { D_8015F6EE = phi_t2; } - if (phi_t1 < D_8015F6F2) { + if ((s32) phi_t1 < (s32) D_8015F6F2) { D_8015F6F2 = phi_t1; } - if (D_8015F6E8 < sp4A) { + if ((s32) D_8015F6E8 < (s32) sp4A) { D_8015F6E8 = sp4A; } - if (D_8015F6EC < sp42) { + if ((s32) D_8015F6EC < (s32) sp42) { D_8015F6EC = sp42; } - if (D_8015F6F0 < sp48) { + if ((s32) D_8015F6F0 < (s32) sp48) { D_8015F6F0 = sp48; } - temp_t0->unk1C = sp58; - temp_t0->unk20 = sp54; - temp_t0->unk24 = sp50; - temp_t0->unk28 = sp4C; - temp_t0->unk2 = arg3; + temp_t0->height = sp58; + temp_t0->gravity = sp54; + temp_t0->rotation = sp50; + temp_t0->height2 = sp4C; + temp_t0->unk2 = (s16) arg3; D_8015F6FA = 0; D_8015F6FC = 0; - temp_a3_2 = temp_t0->unk10->unk6; - temp_v1_2 = temp_t0->unk14->unk6; - temp_a0_3 = temp_t0->unk18->unk6; + temp_a3_2 = (u16) temp_t0->vtxs[0]->tc[0]; + temp_v1_2 = (u16) temp_t0->vtxs[1]->tc[0]; + temp_a0_3 = (u16) temp_t0->vtxs[2]->tc[0]; phi_a1_2 = arg4; if ((temp_a3_2 == 1) && (temp_v1_2 == 1) && (temp_a0_3 == 1)) { phi_t8 = (arg4 | 0x400) & 0xFFFF; @@ -3825,16 +3841,19 @@ block_33: block_81: phi_a1_2 = phi_t8; } - temp_t0->unk0 = phi_a1_2; - if ((sp10 <= sp8) && (phi_t9 = phi_a1_2 | 0x4000, (sp0 <= sp8))) { - goto block_89; + temp_t0->flags = phi_a1_2; + if (sp10 <= sp8) { + phi_t9 = phi_a1_2 | 0x4000; + if (sp0 <= sp8) { + goto block_89; + } } if ((sp8 < sp10) && (sp0 <= sp10)) { - temp_t0->unk0 = temp_t0->unk0 | 0x8000; + temp_t0->flags |= 0x8000; } else { - phi_t9 = temp_t0->unk0 | 0x2000; + phi_t9 = temp_t0->flags | 0x2000; block_89: - temp_t0->unk0 = phi_t9; + temp_t0->flags = phi_t9; } D_8015F588 = D_8015F588 + 1; } @@ -4061,16 +4080,20 @@ GLOBAL_ASM("asm/non_matchings/memory/func_802AEE1C.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_802AEE1C(s16, s16, s16, s16, s32, s32, s32, s32); // extern +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +s32 func_802AEE1C(s16, s16, s16, s16, s32, s32, s32, s32); /* extern */ -? func_802AF0FC(s16 arg0, s16 arg1, s16 arg2, s16 arg3, u16 arg4) { +s32 func_802AF0FC(s16 arg0, s16 arg1, s16 arg2, s16 arg3, u16 arg4) { s16 sp32; s16 sp30; s16 sp2E; s16 sp2C; s16 sp2A; s16 sp28; + mk64_surface_map_ram *temp_v0; + mk_Vtx_Flag *temp_t0; + mk_Vtx_Flag *temp_t1; + mk_Vtx_Flag *temp_v1; s16 temp_a0; s16 temp_a0_2; s16 temp_a1; @@ -4084,32 +4107,28 @@ s32 func_802AEE1C(s16, s16, s16, s16, s32, s32, s32, s32); // extern s16 temp_t3; s16 temp_t4; s16 temp_t5; - void *temp_t0; - void *temp_t1; - void *temp_v0; - void *temp_v1; temp_a0 = arg0; temp_a2 = arg2; temp_a1 = arg1; temp_a3 = arg3; - temp_v0 = (arg4 * 0x2C) + D_8015F580; - temp_v1 = temp_v0->unk10; - temp_t0 = temp_v0->unk14; - temp_t1 = temp_v0->unk18; - temp_t2 = temp_v1->unk0; - temp_t3 = temp_v1->unk4; - temp_t4 = temp_t0->unk0; - temp_t5 = temp_t0->unk4; - temp_ra = temp_t1->unk0; - sp28 = temp_t1->unk4; - if ((temp_t2 >= temp_a0) && (temp_a1 >= temp_t2) && (temp_t3 >= temp_a2) && (temp_a3 >= temp_t3)) { + temp_v0 = &(*D_8015F580)[arg4]; + temp_v1 = temp_v0->vtxs[0]; + temp_t0 = temp_v0->vtxs[1]; + temp_t1 = temp_v0->vtxs[2]; + temp_t2 = temp_v1->ob[0]; + temp_t3 = temp_v1->ob[2]; + temp_t4 = temp_t0->ob[0]; + temp_t5 = temp_t0->ob[2]; + temp_ra = temp_t1->ob[0]; + sp28 = temp_t1->ob[2]; + if (((s32) temp_t2 >= (s32) temp_a0) && ((s32) temp_a1 >= (s32) temp_t2) && ((s32) temp_t3 >= (s32) temp_a2) && ((s32) temp_a3 >= (s32) temp_t3)) { return 1; } - if ((temp_t4 >= temp_a0) && (temp_a1 >= temp_t4) && (temp_t5 >= temp_a2) && (temp_a3 >= temp_t5)) { + if (((s32) temp_t4 >= (s32) temp_a0) && ((s32) temp_a1 >= (s32) temp_t4) && ((s32) temp_t5 >= (s32) temp_a2) && ((s32) temp_a3 >= (s32) temp_t5)) { return 1; } - if ((temp_ra >= temp_a0) && (temp_a1 >= temp_ra) && (sp28 >= temp_a2) && (temp_a3 >= sp28)) { + if (((s32) temp_ra >= (s32) temp_a0) && ((s32) temp_a1 >= (s32) temp_ra) && ((s32) sp28 >= (s32) temp_a2) && ((s32) temp_a3 >= (s32) sp28)) { return 1; } sp2A = temp_ra; @@ -4125,7 +4144,7 @@ s32 func_802AEE1C(s16, s16, s16, s16, s32, s32, s32, s32); // extern temp_a1_2 = arg1; temp_a2_2 = arg2; temp_a3_2 = arg3; - if (func_802AEE1C(temp_a0, temp_a1, temp_a2, temp_a3, temp_t2, temp_t3, temp_t4, temp_t5) == 1) { + if (func_802AEE1C(temp_a0, temp_a1, temp_a2, temp_a3, (s32) temp_t2, (s32) temp_t3, (s32) temp_t4, (s32) temp_t5) == 1) { return 1; } sp2A = temp_ra; @@ -4135,10 +4154,10 @@ s32 func_802AEE1C(s16, s16, s16, s16, s32, s32, s32, s32); // extern arg3 = temp_a3_2; sp32 = temp_t2; sp30 = temp_t3; - if (func_802AEE1C(temp_a0_2, temp_a1_2, temp_a2_2, temp_a3_2, temp_t4, temp_t5, temp_ra, sp28) == 1) { + if (func_802AEE1C(temp_a0_2, temp_a1_2, temp_a2_2, temp_a3_2, (s32) temp_t4, (s32) temp_t5, (s32) temp_ra, (s32) sp28) == 1) { return 1; } - if (func_802AEE1C(arg0, arg1, arg2, arg3, temp_ra, sp28, temp_t2, temp_t3) == 1) { + if (func_802AEE1C(arg0, arg1, arg2, arg3, (s32) temp_ra, (s32) sp28, (s32) temp_t2, (s32) temp_t3) == 1) { return 1; } return 0; @@ -4148,12 +4167,16 @@ GLOBAL_ASM("asm/non_matchings/memory/func_802AF0FC.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_802AF0FC(s16, s16, s16, s16, s32); // extern +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +s32 func_802AF0FC(s16, s16, s16, s16, s32); /* extern */ extern ? D_8014F110; extern ? D_80150110; extern s32 D_8015F584; extern u16 D_8015F58A; +extern s16 D_8015F6E8; +extern s16 D_8015F6EA; +extern s16 D_8015F6F0; +extern s16 D_8015F6F2; extern s32 gPrevLoadedAddress; void func_802AF314(void) { @@ -4190,10 +4213,10 @@ void func_802AF314(void) { } while (temp_v0 != &D_80150110); D_8015F58A = 0; D_8015F584 = gPrevLoadedAddress; - temp_s6 = (D_8015F6E8 - D_8015F6EA) / 0x20; - temp_fp = (D_8015F6F0 - D_8015F6F2) / 0x20; + temp_s6 = (s32) (D_8015F6E8 - D_8015F6EA) / 32; + temp_fp = (s32) (D_8015F6F0 - D_8015F6F2) / 32; phi_s7 = 0; - phi_v1 = D_8015F588; + phi_v1 = (s32) D_8015F588; do { sp4C = temp_fp * phi_s7; phi_s5 = 0; @@ -4208,19 +4231,19 @@ loop_4: do { temp_a3 = temp_s2 + temp_fp + 0x28; temp_v0_2 = phi_s3 + D_8015F580; - if ((temp_v0_2->unkE >= temp_s2) && (temp_a3 >= temp_v0_2->unk8)) { + if (((s32) temp_v0_2->unkE >= (s32) temp_s2) && ((s32) temp_a3 >= (s32) temp_v0_2->unk8)) { temp_a1 = temp_s1 + temp_s6 + 0x28; - if ((temp_v0_2->unkA >= temp_s1) && (temp_a1 >= temp_v0_2->unk4)) { + if (((s32) temp_v0_2->unkA >= (s32) temp_s1) && ((s32) temp_a1 >= (s32) temp_v0_2->unk4)) { if (func_802AF0FC(temp_s1, temp_a1, temp_s2, temp_a3, phi_s0) == 1) { temp_v0_3 = (((phi_s7 << 5) + phi_s5) * 4) + &D_8014F110; if (temp_v0_3->unk2 == 0) { - temp_v0_3->unk0 = D_8015F58A; + temp_v0_3->unk0 = (u16) D_8015F58A; } - temp_v0_3->unk2 = temp_v0_3->unk2 + 1; - *(D_8015F584 + (D_8015F58A * 2)) = phi_s0; - D_8015F58A = D_8015F58A + 1; + temp_v0_3->unk2 = (u16) (temp_v0_3->unk2 + 1); + *(D_8015F584 + (D_8015F58A * 2)) = (s16) phi_s0; + D_8015F58A += 1; } - phi_v1_2 = D_8015F588; + phi_v1_2 = (s32) D_8015F588; } } temp_s0 = phi_s0 + 1; @@ -4445,7 +4468,6 @@ s32 func_802ACBA4(s16 *, f32, f32, f32, f32, s32, f32, f32, f32); /* extern */ s32 func_802AD278(s16 *, f32, f32, f32, f32, s32, f32, f32, f32); /* extern */ ? func_802AF9F0(f32, ? *, ?32, kartBoundingBoxCorner *); /* extern */ extern ? D_8014F110; -extern s32 D_8015F580; extern s32 D_8015F584; extern s16 D_8015F6E8; extern s16 D_8015F6EA; @@ -4483,17 +4505,16 @@ s32 func_802AFA34(Player *player, kartBoundingBoxCorner *corner, f32 cornerX, f3 f32 temp_f2_4; f32 temp_f2_5; f32 temp_f2_6; + mk64_surface_map_ram *temp_v0_4; s16 temp_v0_2; s16 temp_v1; s32 temp_f10; s32 temp_f16; - s32 temp_s4; s32 temp_t6; u16 temp_s0; u16 temp_v0_3; u16 temp_v1_3; u8 temp_v0; - void *temp_v0_4; void *temp_v1_2; u16 phi_s1; s16 *phi_s7; @@ -4510,7 +4531,7 @@ s32 func_802AFA34(Player *player, kartBoundingBoxCorner *corner, f32 cornerX, f3 spF8 = 0; spFA = 0; spFC = 0; - temp_v0 = corner->unk_0D; + temp_v0 = corner->surfaceFlags; temp_f22 = corner->cornerX; temp_f24 = corner->cornerY; temp_f26 = corner->cornerZ; @@ -4523,8 +4544,8 @@ s32 func_802AFA34(Player *player, kartBoundingBoxCorner *corner, f32 cornerX, f3 if (temp_v0 != 0x80) { goto block_21; } - if (func_802AD278(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, (s32) corner->tileIndex, cornerX, cornerY, cornerZ) == 1) { - temp_f0 = func_802ABE30(temp_f22, temp_f24, temp_f26, corner->tileIndex); + if (func_802AD278(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, (s32) corner->surfaceMapIndex, cornerX, cornerY, cornerZ) == 1) { + temp_f0 = func_802ABE30(temp_f22, temp_f24, temp_f26, corner->surfaceMapIndex); temp_f2 = player->posY; if (!(temp_f2 < temp_f0) && !((2.0f * temp_f20) < (temp_f2 - temp_f0))) { corner->cornerGroundY = temp_f0; @@ -4535,8 +4556,8 @@ s32 func_802AFA34(Player *player, kartBoundingBoxCorner *corner, f32 cornerX, f3 phi_f30 = 2.0f; goto block_22; } - if (func_802AC760(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, (s32) corner->tileIndex, cornerX, cornerY, cornerZ) == 1) { - temp_f0_2 = func_802ABE30(temp_f22, temp_f24, temp_f26, corner->tileIndex); + if (func_802AC760(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, (s32) corner->surfaceMapIndex, cornerX, cornerY, cornerZ) == 1) { + temp_f0_2 = func_802ABE30(temp_f22, temp_f24, temp_f26, corner->surfaceMapIndex); temp_f2_2 = player->posY; if (!(temp_f2_2 < temp_f0_2) && !((2.0f * temp_f20) < (temp_f2_2 - temp_f0_2))) { corner->cornerGroundY = temp_f0_2; @@ -4547,8 +4568,8 @@ s32 func_802AFA34(Player *player, kartBoundingBoxCorner *corner, f32 cornerX, f3 phi_f30 = 2.0f; goto block_22; } - if (func_802ACBA4(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, (s32) corner->tileIndex, cornerX, cornerY, cornerZ) == 1) { - temp_f0_3 = func_802ABE30(temp_f22, temp_f24, temp_f26, corner->tileIndex); + if (func_802ACBA4(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, (s32) corner->surfaceMapIndex, cornerX, cornerY, cornerZ) == 1) { + temp_f0_3 = func_802ABE30(temp_f22, temp_f24, temp_f26, corner->surfaceMapIndex); temp_f2_3 = player->posY; if (!(temp_f2_3 < temp_f0_3) && !((2.0f * temp_f20) < (temp_f2_3 - temp_f0_3))) { corner->cornerGroundY = temp_f0_3; @@ -4590,21 +4611,20 @@ block_22: if (sp8C > 0) { loop_34: temp_s0 = *(D_8015F584 + (phi_s1 * 2)); - temp_s4 = temp_s0 * 0x2C; - temp_v0_4 = D_8015F580 + temp_s4; - temp_v1_3 = temp_v0_4->unk0; + temp_v0_4 = &(*D_8015F580)[temp_s0]; + temp_v1_3 = temp_v0_4->flags; if ((temp_v1_3 & 0x4000) != 0) { - if ((corner->tileIndex != temp_s0) && (func_802AC760(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, (s32) temp_s0, cornerX, cornerY, cornerZ) == 1)) { + if ((corner->surfaceMapIndex != temp_s0) && (func_802AC760(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, (s32) temp_s0, cornerX, cornerY, cornerZ) == 1)) { temp_f0_4 = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF); temp_f2_4 = player->posY; if (!(temp_f2_4 < temp_f0_4) && !((phi_f30 * temp_f20) < (temp_f2_4 - temp_f0_4))) { spD4 = temp_f0_4; func_802AF9F0(temp_f0_4, &sp128, sp10C, corner); corner->cornerGroundY = spD4; - corner->unk_0D = 0x40; - corner->tileIndex = temp_s0; - corner->surfaceType = (u8) (D_8015F580 + temp_s4)->unk2; - if ((*(D_8015F580 + temp_s4) & 0x1000) != 0) { + corner->surfaceFlags = 0x40; + corner->surfaceMapIndex = temp_s0; + corner->surfaceType = (u8) (*D_8015F580)[temp_s0].surfaceType; + if (((*D_8015F580)[temp_s0].flags & 0x1000) != 0) { corner->unk_14 = 1; return 1; } @@ -4615,30 +4635,30 @@ loop_34: goto block_55; } if ((temp_v1_3 & 0x8000) != 0) { - if ((temp_v0_4->unk20 != 0.0f) && (corner->tileIndex != temp_s0) && (func_802AD278(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, (s32) temp_s0, cornerX, cornerY, cornerZ) == 1)) { + if ((temp_v0_4->gravity != 0.0f) && (corner->surfaceMapIndex != temp_s0) && (func_802AD278(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, (s32) temp_s0, cornerX, cornerY, cornerZ) == 1)) { temp_f0_5 = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF); temp_f2_5 = player->posY; if (!(temp_f2_5 < temp_f0_5) && !((phi_f30 * temp_f20) < (temp_f2_5 - temp_f0_5))) { corner->cornerGroundY = temp_f0_5; func_802AF9F0(temp_f0_5, &sp11C, sp108, corner); corner->cornerGroundY = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF); - corner->unk_0D = 0x80; - corner->tileIndex = temp_s0; - corner->surfaceType = (u8) (D_8015F580 + temp_s4)->unk2; + corner->surfaceFlags = 0x80; + corner->surfaceMapIndex = temp_s0; + corner->surfaceType = (u8) (*D_8015F580)[temp_s0].surfaceType; return 1; } } goto block_55; } - if ((temp_v0_4->unk20 != 0.0f) && (corner->tileIndex != temp_s0) && (func_802ACBA4(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, (s32) temp_s0, cornerX, cornerY, cornerZ) == 1)) { + if ((temp_v0_4->gravity != 0.0f) && (corner->surfaceMapIndex != temp_s0) && (func_802ACBA4(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, (s32) temp_s0, cornerX, cornerY, cornerZ) == 1)) { temp_f0_6 = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF); temp_f2_6 = player->posY; if (!(temp_f2_6 < temp_f0_6) && !((phi_f30 * temp_f20) < (temp_f2_6 - temp_f0_6))) { corner->cornerGroundY = temp_f0_6; func_802AF9F0(temp_f0_6, &sp110, sp104, corner); - corner->unk_0D = 0x20; - corner->tileIndex = temp_s0; - corner->surfaceType = (u8) (D_8015F580 + temp_s4)->unk2; + corner->surfaceFlags = 0x20; + corner->surfaceMapIndex = temp_s0; + corner->surfaceType = (u8) (*D_8015F580)[temp_s0].surfaceType; return 1; } }