diff --git a/asm/non_matchings/code_80091750/func_8009CA2C.s b/asm/non_matchings/code_80091750/func_8009CA2C.s deleted file mode 100644 index 401fe88e2..000000000 --- a/asm/non_matchings/code_80091750/func_8009CA2C.s +++ /dev/null @@ -1,18 +0,0 @@ -glabel func_8009CA2C -/* 09D62C 8009CA2C 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 09D630 8009CA30 AFB10018 */ sw $s1, 0x18($sp) -/* 09D634 8009CA34 AFB00014 */ sw $s0, 0x14($sp) -/* 09D638 8009CA38 AFBF001C */ sw $ra, 0x1c($sp) -/* 09D63C 8009CA3C 00008025 */ move $s0, $zero -/* 09D640 8009CA40 24110005 */ li $s1, 5 -.L8009CA44: -/* 09D644 8009CA44 0C02729B */ jal func_8009CA6C -/* 09D648 8009CA48 02002025 */ move $a0, $s0 -/* 09D64C 8009CA4C 26100001 */ addiu $s0, $s0, 1 -/* 09D650 8009CA50 1611FFFC */ bne $s0, $s1, .L8009CA44 -/* 09D654 8009CA54 00000000 */ nop -/* 09D658 8009CA58 8FBF001C */ lw $ra, 0x1c($sp) -/* 09D65C 8009CA5C 8FB00014 */ lw $s0, 0x14($sp) -/* 09D660 8009CA60 8FB10018 */ lw $s1, 0x18($sp) -/* 09D664 8009CA64 03E00008 */ jr $ra -/* 09D668 8009CA68 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/src/code_80091750.c b/src/code_80091750.c index ccfad1d77..0542f27a8 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -67,44 +67,34 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_800917B0.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -f64 func_80091A6C(?, s32); // extern -? func_80091AC0(f64, f64, s32 *); // extern -extern f64 D_800F0CC0; -extern f64 D_800F0CC8; - +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de +extern f64 D_800F0CC0;// = 1.414213562373095; +extern f64 D_800F0CC8;// = 0.6931471805599453; f64 func_8009186C(f64 arg0) { s32 sp38; + f64 temp_f0; + f64 temp_f12; f64 temp_f14; - f64 temp_f14_2; - f64 temp_f14_3; - f64 temp_f14_4; - f64 temp_f2; - s32 temp_v0; - f64 phi_f2; - f64 phi_f14; - s32 phi_v0; + f64 var_f14; + f64 var_f2; + s32 var_v0; - temp_f14 = arg0; if (arg0 <= 0.0) { return 0.0; } - arg0 = temp_f14; - func_80091AC0(temp_f14 / D_800F0CC0, temp_f14, &sp38); - temp_f14_2 = arg0 / func_80091A6C(0, sp38); - temp_f14_3 = (temp_f14_2 - 1.0) / (temp_f14_2 + 1.0); - phi_f2 = temp_f14_3; - phi_f14 = temp_f14_3; - phi_v0 = 1; + func_80091AC0(arg0 / 1.414213562373095, &sp38); + temp_f14 = arg0 / func_80091A6C(0.0, sp38); + var_v0 = 1; + var_f14 = (temp_f14 - 1.0) / (temp_f14 + 1.0); + temp_f12 = var_f14 * var_f14; + var_f2 = var_f14; do { - temp_v0 = phi_v0 + 2; - temp_f14_4 = phi_f14 * (temp_f14_3 * temp_f14_3); - temp_f2 = phi_f2 + (temp_f14_4 / temp_v0); - phi_f2 = temp_f2; - phi_f14 = temp_f14_4; - phi_v0 = temp_v0; - } while (phi_f2 != temp_f2); - return (sp38 * D_800F0CC8) + (2.0 * temp_f2); + var_v0 += 2; + var_f14 *= temp_f12; + temp_f0 = var_f2; + var_f2 += var_f14 / (f64) var_v0; + } while (temp_f0 != var_f2); + return ((f64) sp38 * 0.6931471805599453) + (2.0 * var_f2); } #else GLOBAL_ASM("asm/non_matchings/code_80091750/func_8009186C.s") @@ -199,17 +189,15 @@ void swap_values(s32 *arg0, s32 *arg1) { } #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 func_80091D74(); // extern -? func_80094C60(); // extern -? func_800AF9B0(); // extern -? func_800B44BC(); // extern -? load_save_data(); // extern -? func_800C97C4(s32); // extern -? func_800C9D0C(s32); // extern -extern s8 D_800E852C; -extern s32 gMenuSelection; +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de +s32 func_80091D74(); /* extern */ +? func_800C97C4(s32); /* extern */ +? func_800C9D0C(s32); /* extern */ +void *func_802AA88C(? *, ? *); /* extern */ +? load_save_data(); /* extern */ +extern void *D_800DC5EC; extern s32 D_800E86A4; +extern s32 D_8015F734; extern s32 D_8018D9B0; extern s32 D_8018D9B4; extern s32 D_8018D9B8; @@ -223,129 +211,118 @@ extern s8 D_8018EDF5; extern s8 D_8018EDF6; extern s8 D_8018EE0C; extern ? _course_mario_raceway_dl_mio0SegmentRomStart; +extern ? _data_825800SegmentRomStart; extern s32 gPrevLoadedAddress; -extern OSMesgQueue gSIEventMesgQueue; +static s8 D_800E852C = 1; void func_80091B78(void) { - s32 temp_s0; - s32 temp_s0_2; - u32 temp_v0; - u32 temp_v0_2; - ? *phi_v0; - ? *phi_v0_2; - s32 phi_s0; - s32 phi_s0_2; + ? *var_v0; + ? *var_v0_2; + s32 var_s0; + s32 var_s0_2; if (D_800E852C != 0) { D_800E852C = 0; - D_8018EDF4 = 0xA; + D_8018EDF4 = 0x0A; D_8018EDF5 = 5; - D_8018EDF6 = 0xA; + D_8018EDF6 = 0x0A; if (osEepromProbe(&gSIEventMesgQueue) != 0) { load_save_data(); } if (func_80091D74() != 0) { - gMenuSelection = CONTROLLER_PAK_MENU; + gMenuSelection = 9; } } - if (gMenuSelection == LOGO_INTRO_MENU) { + if (gMenuSelection == 8) { gPrevLoadedAddress = D_8015F734; set_segment_base_addr(6, func_802AA88C(&_data_825800SegmentRomStart, &_course_mario_raceway_dl_mio0SegmentRomStart)); } gPrevLoadedAddress = D_8015F734; - D_8018D9B0 = func_802A7B70(0x900B0); - D_8018D9B4 = func_802A7B70(0xCE00); - D_8018D9B8 = func_802A7B70(0x12C00); - D_8018D9C0 = func_802A7B70(0x1000); + D_8018D9B0 = func_802A7B70(0x000900B0); + D_8018D9B4 = func_802A7B70(0x0000CE00); + D_8018D9B8 = func_802A7B70(0x00012C00); + D_8018D9C0 = func_802A7B70(0x00001000); func_800AF9B0(); D_8018EE0C = 0; - phi_v0 = &D_8018E7AC; + var_v0 = &D_8018E7AC; do { - temp_v0 = phi_v0 + 1; - temp_v0->unk-1 = 0; - phi_v0 = temp_v0; - } while (temp_v0 < &D_8018E7B1); - phi_v0_2 = &D_8018E838; + var_v0 += 1; + var_v0->unk-1 = 0; + } while ((u32) var_v0 < (u32) &D_8018E7B1); + var_v0_2 = &D_8018E838; do { - temp_v0_2 = phi_v0_2 + 1; - temp_v0_2->unk-1 = 0; - phi_v0_2 = temp_v0_2; - } while (temp_v0_2 < &D_8018E83C); - D_800DC5EC->unk30 = 0xA0; - D_800DC5EC->unk32 = 0x78; - D_800DC5EC->unk2C = 0x140; - D_800DC5EC->unk2E = 0xF0; + var_v0_2 += 1; + var_v0_2->unk-1 = 0; + } while ((u32) var_v0_2 < (u32) &D_8018E83C); + D_800DC5EC->unk30 = 0x00A0; + D_800DC5EC->unk32 = 0x0078; + D_800DC5EC->unk2C = 0x0140; + D_800DC5EC->unk2E = 0x00F0; D_800E86A4 = 1; func_80094C60(); - phi_s0 = 0; + var_s0 = 0; do { - func_800C97C4(phi_s0 & 0xFF); - temp_s0 = phi_s0 + 1; - phi_s0 = temp_s0; - } while (temp_s0 < 4); - phi_s0_2 = 1; + func_800C97C4(var_s0 & 0xFF); + var_s0 += 1; + } while (var_s0 < 4); + var_s0_2 = 1; do { - func_800C9D0C(phi_s0_2 & 0xFF); - temp_s0_2 = phi_s0_2 + 1; - phi_s0_2 = temp_s0_2; - } while (temp_s0_2 != 8); + func_800C9D0C(var_s0_2 & 0xFF); + var_s0_2 += 1; + } while (var_s0_2 != 8); func_800B44BC(); - osViSetSpecialFeatures(0x40); + osViSetSpecialFeatures(0x00000040U); } #else GLOBAL_ASM("asm/non_matchings/code_80091750/func_80091B78.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 osPfsInit(OSMesgQueue *, OSPfs *, ?); // extern +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de extern OSPfs D_8018E868; extern ? D_8018E938; extern ? D_8018EB38; extern s32 D_8018EB78; extern s32 D_8018EB7C; -extern s32 gControllerPakNumPagesFree; extern u8 gControllerBits; +extern void *gControllerOne; extern ? gControllerStatuses; -extern OSMesgQueue gSIEventMesgQueue; -? func_80091D74(void) { +s32 func_80091D74(void) { u8 sp67; - ? *temp_s1; - s32 temp_s0; - s32 phi_s0; - ? *phi_s1; + ? *var_s1; + s32 temp_v0; + s32 var_s0; if (gControllerBits == 0) { return 0; } - if (((*(&gControllerStatuses + 2) == 0) & 1) != 0) { + if ((*(&gControllerStatuses + 2) == 0) & 1) { return 0; } - if ((gControllerOne->button & 0x1000) == 0) { + if (!(gControllerOne->unk4 & 0x1000)) { return 0; } osPfsIsPlug(&gSIEventMesgQueue, &sp67); - if ((sp67 & 1) != 0) { + if (sp67 & 1) { if (osPfsInit(&gSIEventMesgQueue, &D_8018E868, 0) != 0) { return 0; } - phi_s0 = 0; + var_s0 = 0; if (osPfsNumFiles(&D_8018E868, &D_8018EB78, &D_8018EB7C) != 0) { return 0; } - phi_s1 = &D_8018EB38; + var_s1 = &D_8018EB38; do { - temp_s0 = phi_s0 + 1; - temp_s1 = phi_s1 + 4; - temp_s1->unk-4 = osPfsFileState(&D_8018E868, phi_s0, &D_8018E938 + (phi_s0 << 5)); - phi_s0 = temp_s0; - phi_s1 = temp_s1; - } while (temp_s0 != 0x10); + temp_v0 = osPfsFileState(&D_8018E868, var_s0, &D_8018E938 + (var_s0 << 5)); + var_s0 += 1; + var_s1 += 4; + var_s1->unk-4 = temp_v0; + } while (var_s0 != 0x00000010); if (osPfsFreeBlocks(&D_8018E868, &gControllerPakNumPagesFree) != 0) { return 0; } - gControllerPakNumPagesFree = gControllerPakNumPagesFree >> 8; + gControllerPakNumPagesFree = (s32) gControllerPakNumPagesFree >> 8; return 1; } return 0; @@ -608,8 +585,6 @@ void func_800925A0(void) { add_8018D9E0_entry(0xAF, 0, 0, 0); } -struct_8018D9E0_entry *find_8018D9E0_entry_dupe(s32 arg0); - void func_800925CC(void) { struct_8018D9E0_entry *temp = find_8018D9E0_entry_dupe(0xAF); if (temp->unk4 == 2) { @@ -753,7 +728,7 @@ void func_80092C80(void) { D_8018ED91 = 1; } -#ifdef NON_MATCHING +#ifdef NEEDS_RODATA // Originally func_80092C90 // Some kind of lookup function, seems to return an index to be used // to get a character's width in pixels @@ -1185,30 +1160,26 @@ void func_80093A30(s32 arg0) { } #ifdef MIPS_TO_C -//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 -? func_80093C1C(s8, u32); /* extern */ -? func_800940EC(s8, u32); /* extern */ -? func_8009C918(u32); /* extern */ +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de +extern s32 D_8015F788; static ? D_800F0B1C; /* unable to generate initializer; const */ void func_80093A5C(u32 arg0) { - Gfx *temp_v1; - if (D_8015F788 == 0) { func_8009C918(arg0); } switch (arg0) { case 0: - func_800940EC(*(&D_800F0B1C + arg0), arg0); + func_800940EC((s32) *(&D_800F0B1C + arg0)); break; case 1: case 2: case 3: case 4: if (D_8015F788 == 0) { - func_80093C1C(*(&D_800F0B1C + arg0), arg0); + func_80093C1C((s32) *(&D_800F0B1C + arg0)); } else { - func_800940EC(*(&D_800F0B1C + arg0), arg0); + func_800940EC((s32) *(&D_800F0B1C + arg0)); } break; case 8: @@ -1216,16 +1187,13 @@ void func_80093A5C(u32 arg0) { case 10: case 11: if (D_8015F788 == 3) { - func_800940EC(*(&D_800F0B1C + arg0), arg0); + func_800940EC((s32) *(&D_800F0B1C + arg0)); } else { - func_80093C1C(*(&D_800F0B1C + arg0), arg0); + func_80093C1C((s32) *(&D_800F0B1C + arg0)); } break; } - temp_v1 = gDisplayListHead; - gDisplayListHead = temp_v1 + 8; - temp_v1->words.w0 = 0xB900031D; - temp_v1->words.w1 = 0xF0A4000; + gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); } #else GLOBAL_ASM("asm/non_matchings/code_80091750/func_80093A5C.s") @@ -1353,9 +1321,9 @@ void func_800940EC(s32 arg0) { } #ifdef MIPS_TO_C -//generated by mips_to_c commit 06ada559d7a32fdab49fa2d619cdfa027615bcda -? guRotate(Mtx *, f32, f32, f32, f32); /* extern */ -? guScale(Mtx *, f32, f32, f32); /* extern */ +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de +f32 D_800E8530 = 0.0f; +f32 D_800E8534 = 3.0f; void func_800942D0(void) { Gfx *sp6C; @@ -1380,11 +1348,12 @@ void func_800942D0(void) { Mtx *temp_s1_3; Mtx *temp_s4; Mtx *temp_s4_2; + Mtx *var_s1; + f32 var_f26; s32 temp_s3; - Mtx *phi_s1; - s32 phi_s2; - f32 phi_f26; - s32 phi_s5; + s32 var_s2; + s32 var_s5; + u32 temp_t4; temp_v0 = gDisplayListHead; gDisplayListHead = temp_v0 + 8; @@ -1415,7 +1384,7 @@ void func_800942D0(void) { temp_v0_6 = gDisplayListHead; gDisplayListHead = temp_v0_6 + 8; temp_v0_6->words.w0 = 0xB900031D; - temp_v0_6->words.w1 = 0x552078; + temp_v0_6->words.w1 = 0x00552078; temp_v0_7 = gDisplayListHead; gDisplayListHead = temp_v0_7 + 8; temp_v0_7->words.w1 = 0; @@ -1428,24 +1397,24 @@ void func_800942D0(void) { gDisplayListHead = temp_v0_9 + 8; temp_v0_9->words.w1 = 0; temp_v0_9->words.w0 = 0xBD000000; - phi_s1 = temp_s1_2 + 0x40; - phi_s2 = 0; - phi_s5 = 0xC0; - if (0.0f < 0.0f) { - phi_f26 = 3.0f; - if (10.0f < 3.0f) { - phi_f26 = 10.0f; + var_s1 = temp_s1_2 + 0x40; + var_s2 = 0; + var_s5 = 0xC0; + if (D_800E8530 > 0.0f) { + var_f26 = D_800E8534; + if (var_f26 > 10.0f) { + var_f26 = 10.0f; } sp6C = D_06009410; do { - guRotate(phi_s1, 0.0f, 1.0f, 0.0f, 0.0f); - temp_s3 = phi_s2 + 1; - temp_s4_2 = phi_s1 + 0x40; - guRotate(temp_s4_2, (f32) temp_s3 * 0.0f * phi_f26, 0.0f, 1.0f, 0.0f); - guScale(phi_s1 + 0x80, 1.0f, 1.0f, 2.0f); + guRotate(var_s1, 0.0f, 1.0f, 0.0f, 0.0f); + temp_s3 = var_s2 + 1; + temp_s4_2 = var_s1 + 0x40; + guRotate(temp_s4_2, (f32) temp_s3 * D_800E8530 * var_f26, 0.0f, 1.0f, 0.0f); + guScale(var_s1 + 0x80, 1.0f, 1.0f, 2.0f); temp_v0_10 = gDisplayListHead; gDisplayListHead = temp_v0_10 + 8; - temp_v0_10->words.w1 = (u32) phi_s1; + temp_v0_10->words.w1 = (u32) var_s1; temp_v0_10->words.w0 = 0x01040040; temp_v0_11 = gDisplayListHead; temp_s1_3 = temp_s4_2 + 0x40; @@ -1453,18 +1422,22 @@ void func_800942D0(void) { temp_v0_11->words.w1 = (u32) temp_s4_2; temp_v0_11->words.w0 = 0x01000040; temp_v0_12 = gDisplayListHead; + temp_t4 = var_s5 & 0xFF; gDisplayListHead = temp_v0_12 + 8; temp_v0_12->words.w1 = (u32) temp_s1_3; temp_v0_12->words.w0 = 0x01000040; temp_v0_13 = gDisplayListHead; gDisplayListHead = temp_v0_13 + 8; - temp_v0_13->words.w1 = 0x5049D8; + temp_v0_13->words.w1 = 0x005049D8; temp_v0_13->words.w0 = 0xB900031D; temp_v0_14 = gDisplayListHead; + var_s5 -= 0x10; gDisplayListHead = temp_v0_14 + 8; - temp_v0_14->words.w1 = phi_s5 & 0xFF; + temp_v0_14->words.w1 = temp_t4; temp_v0_14->words.w0 = 0xFB000000; temp_v0_15 = gDisplayListHead; + var_s2 = temp_s3; + var_s1 = temp_s1_3 + 0x40; gDisplayListHead = temp_v0_15 + 8; temp_v0_15->words.w0 = 0x06000000; temp_v0_15->words.w1 = (u32) sp6C; @@ -1472,9 +1445,6 @@ void func_800942D0(void) { gDisplayListHead = temp_v0_16 + 8; temp_v0_16->words.w1 = 0; temp_v0_16->words.w0 = 0xBD000000; - phi_s1 = temp_s1_3 + 0x40; - phi_s2 = temp_s3; - phi_s5 += -0x10; } while (temp_s3 != 0xC); } } @@ -1518,7 +1488,7 @@ void func_800947B4(struct GfxPool *arg0, s32 unused) { gSPDisplayList(gDisplayListHead++, D_02007650); } -#ifdef NON_MATCHING +#ifdef NEEDS_RODATA // Non-matching due to .rodata diffs resulting from the switch/case // jump table void func_80094A64(Mtx *arg0) { @@ -4132,110 +4102,94 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_80099A94.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 5bd751fca3befef73d6a2e20d84a88cc918a77fe -? mio0decode(s32, s32); /* extern */ -? osInvalDCache(s32, s32); /* extern */ -? osPiStartDma(? *, ?, ?, void *, s32, s32, ? *); /* extern */ -? osRecvMesg(? *, ? *, ?); /* extern */ -extern s32 D_800DC50C; +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de extern s32 D_8018D9B0; -extern s32 D_8018D9B4; +extern u8 *D_8018D9B4; extern void *D_8018E060; extern ? _textures_0aSegmentRomStart; -extern ? gDmaMesgQueue; void func_80099AEC(void) { - ? sp6C; - ? sp68; + OSIoMesg sp6C; + void *sp68; s32 sp60; ? *sp58; s32 temp_t7; + s8 var_s5; u16 temp_v1; u16 temp_v1_2; u16 temp_v1_3; - void *temp_s1; + u16 var_s0; + u16 var_s0_2; + u16 var_s0_3; + void **temp_s1; + void **var_s1; void *temp_s2; void *temp_v0; void *temp_v0_2; - s32 phi_s0; - s32 phi_s0_2; - void **phi_s1; - s32 phi_s0_3; - s32 phi_s0_4; - s8 phi_s5; - s32 phi_s0_5; - s32 phi_s0_6; - s8 phi_s5_2; - s8 phi_s5_3; - if (D_800DC50C == RACING) { - sp60 = 0x500; + if (D_800DC50C == 4) { + sp60 = 0x00000500; } else { - sp60 = 0x1000; + sp60 = 0x00001000; } + var_s1 = &D_8018E060; temp_s2 = D_8018E060; - phi_s1 = &D_8018E060; - phi_s5_3 = 0; - if (temp_s2 != 0) { + var_s5 = 0; + if (temp_s2 != NULL) { temp_v1 = temp_s2->unk10; - phi_s0 = 0x1400; - phi_s0_3 = 0x1400; - phi_s0_5 = 0x1400; + var_s0 = 0x1400; if (temp_v1 != 0) { - phi_s0 = (s32) temp_v1; + var_s0 = temp_v1; } - phi_s0_2 = phi_s0; - if ((phi_s0 % 8) != 0) { - phi_s0_2 = ((phi_s0 / 8) * 8) + 8; + if (((s32) var_s0 % 8) != 0) { + var_s0 = (((s32) var_s0 / 8) * 8) + 8; } - osInvalDCache(D_8018D9B4, phi_s0_2); + osInvalDCache(D_8018D9B4, (u32) var_s0); sp58 = &_textures_0aSegmentRomStart; - osPiStartDma(&sp6C, 0, 0, &_textures_0aSegmentRomStart + (temp_s2->unk4 & 0xFFFFFF), D_8018D9B4, phi_s0_2, &gDmaMesgQueue); + osPiStartDma(&sp6C, 0, 0, (u32) (&_textures_0aSegmentRomStart + (temp_s2->unk4 & 0xFFFFFF)), D_8018D9B4, (u32) var_s0, &gDmaMesgQueue); osRecvMesg(&gDmaMesgQueue, &sp68, 1); loop_9: - temp_v0 = phi_s1->unk8; - phi_s5 = phi_s5_3; - if (temp_v0 == 0) { - phi_s5 = (s8) (phi_s5_3 + 1); + temp_v0 = var_s1->unk8; + if (temp_v0 == NULL) { + var_s5 += 1; } else { temp_v1_2 = temp_v0->unk10; temp_t7 = sp60 * 4; if (temp_v1_2 != 0) { - phi_s0_3 = (s32) temp_v1_2; + var_s0_2 = temp_v1_2; + } else { + var_s0_2 = 0x1400; } - phi_s0_4 = phi_s0_3; - if ((phi_s0_3 % 8) != 0) { - phi_s0_4 = ((phi_s0_3 / 8) * 8) + 8; + if (((s32) var_s0_2 % 8) != 0) { + var_s0_2 = (((s32) var_s0_2 / 8) * 8) + 8; } - osInvalDCache(temp_t7 + D_8018D9B4, phi_s0_4); - osPiStartDma(&sp6C, 0, 0, sp58 + (temp_v0->unk4 & 0xFFFFFF), temp_t7 + D_8018D9B4, phi_s0_4, &gDmaMesgQueue); + osInvalDCache(temp_t7 + D_8018D9B4, (u32) var_s0_2); + osPiStartDma(&sp6C, 0, 0, (u32) (sp58 + (temp_v0->unk4 & 0xFFFFFF)), temp_t7 + D_8018D9B4, (u32) var_s0_2, &gDmaMesgQueue); } - mio0decode(D_8018D9B4, (D_8018E118[phi_s1->unk4].offset * 2) + D_8018D9B0); - phi_s1->unk0 = NULL; - temp_s1 = phi_s1 + 8; - phi_s5_2 = phi_s5; - if (phi_s5 == 0) { + mio0decode(D_8018D9B4, (D_8018E118[var_s1->unk4].offset * 2) + D_8018D9B0); + var_s1->unk0 = NULL; + temp_s1 = var_s1 + 8; + if (var_s5 == 0) { osRecvMesg(&gDmaMesgQueue, &sp68, 1); temp_v0_2 = temp_s1->unk8; - if (temp_v0_2 == 0) { - phi_s5_2 = (s8) (phi_s5 + 1); + if (temp_v0_2 == NULL) { + var_s5 += 1; } else { temp_v1_3 = temp_v0_2->unk10; + var_s0_3 = 0x1400; if (temp_v1_3 != 0) { - phi_s0_5 = (s32) temp_v1_3; + var_s0_3 = temp_v1_3; } - phi_s0_6 = phi_s0_5; - if ((phi_s0_5 % 8) != 0) { - phi_s0_6 = ((phi_s0_5 / 8) * 8) + 8; + if (((s32) var_s0_3 % 8) != 0) { + var_s0_3 = (((s32) var_s0_3 / 8) * 8) + 8; } - osInvalDCache(D_8018D9B4, phi_s0_6); - osPiStartDma(&sp6C, 0, 0, sp58 + (temp_v0_2->unk4 & 0xFFFFFF), D_8018D9B4, phi_s0_6, &gDmaMesgQueue); + osInvalDCache(D_8018D9B4, (u32) var_s0_3); + osPiStartDma(&sp6C, 0, 0, (u32) (sp58 + (temp_v0_2->unk4 & 0xFFFFFF)), D_8018D9B4, (u32) var_s0_3, &gDmaMesgQueue); } mio0decode((sp60 * 4) + D_8018D9B4, (D_8018E118[temp_s1->unk4].offset * 2) + D_8018D9B0); - temp_s1->unk0 = 0; - phi_s1 = temp_s1 + 8; - phi_s5_3 = phi_s5_2; - if (phi_s5_2 == 0) { + temp_s1->unk0 = NULL; + var_s1 = temp_s1 + 8; + if (var_s5 == 0) { osRecvMesg(&gDmaMesgQueue, &sp68, 1); goto loop_9; } @@ -5727,24 +5681,13 @@ void func_8009C918(void) { GLOBAL_ASM("asm/non_matchings/code_80091750/func_8009C918.s") #endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_8009CA6C(s32); // extern - void func_8009CA2C(void) { - s32 temp_s0; - s32 phi_s0; + s32 var_s0; - phi_s0 = 0; - do { - func_8009CA6C(phi_s0); - temp_s0 = phi_s0 + 1; - phi_s0 = temp_s0; - } while (temp_s0 != 5); + for(var_s0 = 0; var_s0 < 5; var_s0++) { + func_8009CA6C(var_s0); + } } -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_8009CA2C.s") -#endif #ifdef MIPS_TO_C //generated by mips_to_c commit 06ada559d7a32fdab49fa2d619cdfa027615bcda @@ -5906,81 +5849,83 @@ void func_8009CE1C(void) { } #ifdef MIPS_TO_C -//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de ? func_8000F124(s8, s32); /* extern */ ? func_8009CE1C(s32 *, s32, s32); /* extern */ -void *find_8018D9E0_entry(?, s32, s32); /* extern */ ? func_80290338(); /* extern */ ? func_80290360(); /* extern */ ? func_80290388(); /* extern */ ? func_802903B0(); /* extern */ +extern s32 D_800DC524; +extern s32 D_800E86A4; +extern s16 D_8015F892; extern ? D_8018E7AC; extern ? D_8018E7B0; -static ? gCupSelectionByCourseId; /* unable to generate initializer; const */ -static ? gCharacterSelections; /* unable to generate initializer; const */ -static ? gPerCupIndexByCourseId; /* unable to generate initializer; const */ -s16 gCreditsCourseId; /* unable to generate initializer */ +extern u32 D_8018EDE0; +extern s8 D_8018EDF3; +extern s8 D_8018EDFB; +extern s8 D_8018EE08; +extern s8 D_8018EE0C; +extern s16 gCreditsCourseId; +extern s8 gDebugGotoScene; +extern s32 gMenuSelectionFromEndingSequence; +extern s32 gScreenModeSelection; +u8 gCupSelectionByCourseId[0x15]; /* unable to generate initializer */ s16 gCurrentCourseId; /* unable to generate initializer */ +u8 gPerCupIndexByCourseId[0x15]; /* unable to generate initializer; const */ void func_8009CE64(s32 *arg0, s32 arg2, s32 arg3) { s32 sp28; s8 *sp18; s16 temp_a0; - s16 temp_a0_2; + s32 *var_a0; s32 temp_t6; s32 temp_t6_2; s32 temp_v0; s32 temp_v0_7; - s32 temp_v0_8; s32 temp_v1; s32 temp_v1_2; s32 temp_v1_3; s32 temp_v1_5; s32 temp_v1_6; s32 temp_v1_8; + s32 var_a1; + s32 var_a1_2; + s32 var_a2; + s32 var_t7; + s32 var_v0; s8 *temp_v0_2; s8 temp_v1_4; s8 temp_v1_7; s8 temp_v1_9; + struct_8018D9E0_entry *temp_v0_3; + struct_8018D9E0_entry *temp_v0_4; + struct_8018D9E0_entry *temp_v0_5; + struct_8018D9E0_entry *temp_v0_6; u32 temp_t9; - void *temp_v0_3; - void *temp_v0_4; - void *temp_v0_5; - void *temp_v0_6; - s32 phi_a1; - s32 phi_a1_2; - s32 phi_a1_3; - s32 phi_t7; - s32 *phi_a0; - s32 phi_a2; - s32 phi_v0; + var_a0 = arg0; + var_a2 = arg3; temp_v0 = D_800DC50C; - phi_a1 = 0; - phi_a1_2 = 0; - phi_a1_3 = 0; - phi_a0 = arg0; - phi_a2 = arg3; - phi_a2 = arg3; - phi_a2 = arg3; - if (temp_v0 == ENDING_SEQUENCE) { + var_a1 = 0; + if (temp_v0 == (s32) 5) { temp_v1 = gCCSelection; - if ((temp_v1 != CC_150) && (temp_v1 != CC_EXTRA)) { + if ((temp_v1 != 2) && (temp_v1 != 3)) { - } else if ((D_802874F5 < 3) && (gCupSelection == SPECIAL_CUP)) { - phi_a1 = 1; + } else if ((D_802874F5 < 3) && (gCupSelection == 3)) { + var_a1 = 1; } - if (phi_a1 != 0) { - gMenuSelectionFromEndingSequence = CREDITS_SEQUENCE; - gCreditsCourseId = COURSE_LUIGI_RACEWAY; + if (var_a1 != 0) { + gMenuSelectionFromEndingSequence = 9; + gCreditsCourseId = 8; return; } - gMenuSelectionFromEndingSequence = MAIN_MENU_FROM_QUIT; - gMenuSelection = MAIN_MENU; + gMenuSelectionFromEndingSequence = 1; + gMenuSelection = 0x0000000B; return; } - if (temp_v0 == RACING) { - temp_v0_2 = arg0 + &D_8018E7AC; + if (temp_v0 == 4) { + temp_v0_2 = var_a0 + &D_8018E7AC; if (*temp_v0_2 == 2) { if (temp_v0_2 != &D_8018E7B0) { *temp_v0_2 = 5; @@ -5988,233 +5933,228 @@ void func_8009CE64(s32 *arg0, s32 arg2, s32 arg3) { } sp18 = temp_v0_2; sp28 = 0; - temp_v0_3 = find_8018D9E0_entry(0xB0, 0, 2); - if (temp_v0_3 != 0) { + temp_v0_3 = find_8018D9E0_entry(0x000000B0); + if (temp_v0_3 != NULL) { temp_v1_2 = temp_v0_3->unk4; - if (temp_v1_2 != 0xA) { - if (temp_v1_2 != 0xB) { - if (temp_v1_2 != 0xC) { - if (temp_v1_2 != 0xD) { - - } - func_80290338(); - return; - } - func_80290360(); - return; - } - func_80290388(); - return; - } - func_802903B0(); - return; - } - sp28 = 0; - temp_v0_4 = find_8018D9E0_entry(0xAC, 0); - if (temp_v0_4 != 0) { - temp_v1_3 = temp_v0_4->unk4; - if (temp_v1_3 != 0xB) { - if (temp_v1_3 != 0xC) { - - } - func_80290338(); - return; - } - func_802903B0(); - D_8016556E = 1; - return; - } - sp28 = 0; - temp_v0_5 = find_8018D9E0_entry(0xC7, 0); - if (temp_v0_5 != 0) { - temp_t6 = temp_v0_5->unk4; - switch (temp_t6) { /* switch 1 */ - case 12: /* switch 1 */ - func_802903B0(); - phi_a1_2 = 1; - break; - case 13: /* switch 1 */ - case 22: /* switch 1 */ - case 42: /* switch 1 */ - func_80290388(); - phi_a1_2 = 1; - break; - case 14: /* switch 1 */ - case 23: /* switch 1 */ - case 43: /* switch 1 */ - func_80290360(); - phi_a1_2 = 1; - break; - case 15: /* switch 1 */ - case 24: /* switch 1 */ - case 32: /* switch 1 */ - case 44: /* switch 1 */ - func_80290338(); - phi_a1_2 = 1; - break; - default: /* switch 1 */ - *sp18 = 5; - break; - } - phi_a1_3 = phi_a1_2; - if (phi_a1_2 != 0) { - D_800DC5FC = 0; - } - } - temp_v0_6 = find_8018D9E0_entry(0xBD, phi_a1_3); - if (temp_v0_6 != 0) { - temp_t6_2 = temp_v0_6->unk4; - switch (temp_t6_2) { /* switch 2 */ - case 11: /* switch 2 */ - D_8015F892 = 1; - D_8015F890 = 0; + switch (temp_v1_2) { /* switch 8; irregular */ + case 10: /* switch 8 */ func_802903B0(); return; - case 12: /* switch 2 */ - D_8015F892 = 0; - D_8015F890 = 0; + case 11: /* switch 8 */ func_80290388(); return; - case 13: /* switch 2 */ - D_8015F892 = 0; - D_8015F890 = 0; + case 12: /* switch 8 */ func_80290360(); return; - case 14: /* switch 2 */ - D_8015F892 = 0; - D_8015F890 = 0; + default: /* switch 8 */ + case 13: /* switch 8 */ func_80290338(); return; - case 15: /* switch 2 */ - D_8015F892 = 0; - D_8015F890 = 1; - func_802903B0(); - return; } } else { - *sp18 = 5; + sp28 = 0; + temp_v0_4 = find_8018D9E0_entry(0x000000AC); + if (temp_v0_4 != NULL) { + temp_v1_3 = temp_v0_4->unk4; + switch (temp_v1_3) { /* switch 7; irregular */ + case 11: /* switch 7 */ + func_802903B0(); + D_8016556E = 1; + return; + default: /* switch 7 */ + case 12: /* switch 7 */ + func_80290338(); + return; + } + } else { + sp28 = 0; + temp_v0_5 = find_8018D9E0_entry(0x000000C7); + var_a1_2 = 0; + if (temp_v0_5 != NULL) { + temp_t6 = temp_v0_5->unk4; + switch (temp_t6) { /* switch 1 */ + case 12: /* switch 1 */ + func_802903B0(); + var_a1_2 = 1; + break; + case 13: /* switch 1 */ + case 22: /* switch 1 */ + case 42: /* switch 1 */ + func_80290388(); + var_a1_2 = 1; + break; + case 14: /* switch 1 */ + case 23: /* switch 1 */ + case 43: /* switch 1 */ + func_80290360(); + var_a1_2 = 1; + break; + case 15: /* switch 1 */ + case 24: /* switch 1 */ + case 32: /* switch 1 */ + case 44: /* switch 1 */ + func_80290338(); + var_a1_2 = 1; + break; + default: /* switch 1 */ + *sp18 = 5; + break; + } + if (var_a1_2 != 0) { + D_800DC5FC = 0; + } + } + temp_v0_6 = find_8018D9E0_entry(0x000000BD); + if (temp_v0_6 != NULL) { + temp_t6_2 = temp_v0_6->unk4; + switch (temp_t6_2) { /* switch 2 */ + case 11: /* switch 2 */ + D_8015F892 = 1; + D_8015F890 = 0; + func_802903B0(); + return; + case 12: /* switch 2 */ + D_8015F892 = 0; + D_8015F890 = 0; + func_80290388(); + return; + case 13: /* switch 2 */ + D_8015F892 = 0; + D_8015F890 = 0; + func_80290360(); + return; + case 14: /* switch 2 */ + D_8015F892 = 0; + D_8015F890 = 0; + func_80290338(); + return; + case 15: /* switch 2 */ + D_8015F892 = 0; + D_8015F890 = 1; + func_802903B0(); + return; + } + } else { + *sp18 = 5; + } + } } - } else { - /* Duplicate return node #115. Try simplifying control flow for better match */ } } else { - *(&D_8018E7AC + arg0) = 0; - if (gDebugMenuSelection != DEBUG_MENU_EXITED) { + *(&D_8018E7AC + var_a0) = 0; + if (gDebugMenuSelection != 0x40) { temp_t9 = D_8018EDE0; switch (temp_t9) { /* switch 3 */ case 0: /* switch 3 */ + var_a0 = &gMenuSelection; temp_v0_7 = gMenuSelection; - phi_t7 = temp_v0_7 + 1; - phi_a0 = &gMenuSelection; - phi_a2 = 2; - phi_a2 = 2; - if (temp_v0_7 == LOGO_INTRO_MENU) { - gMenuSelection = START_MENU; + var_a2 = 2; + var_t7 = temp_v0_7 + 1; + if (temp_v0_7 == 8) { + gMenuSelection = 0x0000000A; D_800E86A4 = 2; } else { block_74: - gMenuSelection = phi_t7; - phi_a0 = &gMenuSelection; + *var_a0 = var_t7; } break; case 1: /* switch 3 */ - gMenuSelection += -1; - phi_a0 = &gMenuSelection; + var_a0 = &gMenuSelection; + gMenuSelection -= 1; break; - // Setting up game state for title screen demos case 2: /* switch 3 */ D_800DC51C = 1; D_8018EE08 = 1; - - D_800DC524 = RACING; - gCCSelection = CC_100; - switch (gNextDemoId) { /* switch 4 */ - case DEMO_ONE: /* switch 4 */ - gCurrentCourseId = COURSE_MARIO_RACEWAY; - gScreenModeSelection = SCREEN_MODE_1P; - gPlayerCountSelection1 = 1; - D_8018EDF3 = ONE_PLAYERS_SELECTED; - gCharacterSelections[0] = MARIO; - gModeSelection = GRAND_PRIX; + D_800DC524 = 4; + gCCSelection = (s32) 1; + temp_v1_4 = (s8) gNextDemoId; + switch (temp_v1_4) { /* switch 4 */ + case 0: /* switch 4 */ + gCurrentCourseId = 0; + gScreenModeSelection = 0; + gPlayerCountSelection1 = (s32) 1; + D_8018EDF3 = 1; + gCharacterSelections->unk0 = 0; + gModeSelection = 0; break; - case DEMO_TWO: /* switch 4 */ - gCurrentCourseId = COURSE_CHOCO_MOUNTAIN; - gScreenModeSelection = SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL; + case 1: /* switch 4 */ + gCurrentCourseId = (s16) 1; + var_a2 = 2; + gScreenModeSelection = (s32) 1; gPlayerCountSelection1 = 2; - D_8018EDF3 = TWO_PLAYERS_SELECTED; - gCharacterSelections[0] = YOSHI; - gCharacterSelections[1] = DK; - gModeSelection = VERSUS; - phi_a2 = 2; + D_8018EDF3 = (s8) 2; + gCharacterSelections->unk0 = (s8) 2; + gCharacterSelections->unk1 = (s8) 4; + gModeSelection = 2; break; - case DEMO_THREE: /* switch 4 */ - gCurrentCourseId = COURSE_KALAMARI_DESERT; - gScreenModeSelection = SCREEN_MODE_1P; - gPlayerCountSelection1 = 1; - D_8018EDF3 = ONE_PLAYERS_SELECTED; - gCharacterSelections[0] = LUIGI; - gModeSelection = GRAND_PRIX; + case 2: /* switch 4 */ + gCurrentCourseId = 0x000B; + gScreenModeSelection = 0; + gPlayerCountSelection1 = (s32) 1; + D_8018EDF3 = 1; + gCharacterSelections->unk0 = 1; + gModeSelection = 0; break; - case DEMO_FOUR: /* switch 4 */ - gCurrentCourseId = COURSE_WARIO_STADIUM; - gScreenModeSelection = SCREEN_MODE_3P_4P_SPLITSCREEN; + case 3: /* switch 4 */ + gCurrentCourseId = 0x000E; + var_a2 = 2; + gScreenModeSelection = 3; gPlayerCountSelection1 = 3; - D_8018EDF3 = THREE_PLAYERS_SELECTED; - gCharacterSelections[0] = WARIO; - gCharacterSelections[1] = YOSHI; - gCharacterSelections[2] = BOWSER; - gModeSelection = VERSUS; - phi_a2 = 2; + D_8018EDF3 = (s8) 3; + gCharacterSelections->unk0 = 5; + gCharacterSelections->unk1 = (s8) 2; + gCharacterSelections->unk2 = 7; + gModeSelection = 2; break; - case DEMO_FIVE: /* switch 4 */ - gCurrentCourseId = COURSE_BOWSER_CASTLE; - gScreenModeSelection = SCREEN_MODE_1P; - gPlayerCountSelection1 = 1; - D_8018EDF3 = ONE_PLAYERS_SELECTED; - gCharacterSelections[0] = BOWSER; - gModeSelection = GRAND_PRIX; - phi_a2 = 2; + case 4: /* switch 4 */ + var_a2 = 2; + gCurrentCourseId = (s16) 2; + gScreenModeSelection = 0; + gPlayerCountSelection1 = (s32) 1; + D_8018EDF3 = 1; + gCharacterSelections->unk0 = 7; + gModeSelection = 0; break; - case DEMO_SIX: /* switch 4 */ - gCurrentCourseId = COURSE_SHERBET_LAND; - gScreenModeSelection = SCREEN_MODE_3P_4P_SPLITSCREEN; + case 5: /* switch 4 */ + gCurrentCourseId = 0x000C; + var_a2 = 2; + gScreenModeSelection = 3; gPlayerCountSelection1 = 4; - D_8018EDF3 = FOUR_PLAYERS_SELECTED; - gCharacterSelections[0] = MARIO; - gCharacterSelections[1] = LUIGI; - gCharacterSelections[2] = PEACH; - gCharacterSelections[3] = TOAD; - gModeSelection = VERSUS; - phi_a2 = 2; + D_8018EDF3 = (s8) 4; + gCharacterSelections->unk0 = 0; + gCharacterSelections->unk1 = 1; + gCharacterSelections->unk2 = 6; + gCharacterSelections->unk3 = (s8) 3; + gModeSelection = 2; break; } - gNextDemoId += 1; - if (gNextDemoId >= NUM_DEMOS) { - gNextDemoId = DEMO_ONE; + gNextDemoId = temp_v1_4 + 1; + if ((s8) gNextDemoId >= 6) { + gNextDemoId = 0; } - gCupSelection = gCupSelectionByCourseId[gCurrentCourseId]; - D_800DC540 = gCupSelection; - gCupCourseSelection = gPerCupIndexByCourseId[gCurrentCourseId]; - phi_a0 = gCurrentCourseId; + var_a0 = (s32 *) gCurrentCourseId; + gCupSelection = (s8) gCupSelectionByCourseId[var_a0]; + D_800DC540 = (s32) gCupSelection; + gCupCourseSelection = (s8) gPerCupIndexByCourseId[var_a0]; break; case 3: /* switch 3 */ + var_a0 = &gMenuSelection; temp_v1_5 = gMenuSelection; - phi_a0 = &gMenuSelection; - if (temp_v1_5 != DATA_MENU) { - if (temp_v1_5 == MAIN_MENU) { - gMenuSelection = DATA_MENU; + if (temp_v1_5 != 6) { + if (temp_v1_5 == 0x0000000B) { + gMenuSelection = 6; } } else { - gMenuSelection = MAIN_MENU; + gMenuSelection = 0x0000000B; } break; case 4: /* switch 3 */ + var_a0 = &gMenuSelection; temp_v1_6 = gMenuSelection; - phi_t7 = 0xB; - phi_a0 = &gMenuSelection; - if (temp_v1_6 != OPTIONS_MENU) { - if (temp_v1_6 == MAIN_MENU) { - gMenuSelection = OPTIONS_MENU; + var_t7 = 0x0000000B; + if (temp_v1_6 != (s32) 5) { + if (temp_v1_6 == 0x0000000B) { + gMenuSelection = (s32) 5; } } else { goto block_74; @@ -6224,76 +6164,76 @@ block_74: if (D_800E86A4 == 0) { D_800E86A4 = 1; } - if (gMenuSelection >= RACING_DUPLICATE) { - D_800DC524 = RACING; - if (gModeSelection == TIME_TRIALS) { - D_8018EDFB = 1; + if (gMenuSelection >= 0xE) { + D_800DC524 = 4; + if (gModeSelection == 1) { + D_8018EDFB = (s8) 1; } - func_8009CE1C(phi_a0, 1, phi_a2); + func_8009CE1C(var_a0, 1, var_a2); } D_8018EE0C = 0; return; } temp_v1_7 = gDebugGotoScene; - if (temp_v1_7 != DEBUG_GOTO_ENDING_SEQUENCE) { - if ((temp_v1_7 != DEBUG_GOTO_CREDITS_SEQUENCE_CC_50) && (temp_v1_7 != DEBUG_GOTO_CREDITS_SEQUENCE_CC_EXTRA)) { - D_800DC524 = RACING; - if (gModeSelection == TIME_TRIALS) { - D_8018EDFB = 1; - } - } else { - D_800DC524 = CREDITS_SEQUENCE; - gCreditsCourseId = COURSE_LUIGI_RACEWAY; + switch (temp_v1_7) { /* switch 5; irregular */ + case 1: /* switch 5 */ + D_800DC524 = (s32) 5; + break; + case 2: /* switch 5 */ + case 3: /* switch 5 */ + D_800DC524 = 9; + gCreditsCourseId = 8; + break; + default: /* switch 5 */ + D_800DC524 = 4; + if (gModeSelection == (s32) 1) { + D_8018EDFB = 1; } - } else { - D_800DC524 = ENDING_SEQUENCE; + break; } func_8000F124(1, 2); - if ((gScreenModeSelection == SCREEN_MODE_3P_4P_SPLITSCREEN) && ((temp_v1_8 = gModeSelection, (temp_v1_8 == 0)) || (temp_v1_8 == 1))) { - gModeSelection = VERSUS; + if ((gScreenModeSelection == 3) && ((temp_v1_8 = gModeSelection, (temp_v1_8 == 0)) || (temp_v1_8 == 1))) { + gModeSelection = 2; } - temp_a0_2 = gCurrentCourseId; - if ((temp_a0_2 != 0xF) && (temp_a0_2 != 0x10) && (temp_a0_2 != 0x11) && (temp_a0_2 != 0x13)) { - // Selected course is not one of the battle courses - temp_v0_8 = gModeSelection; - phi_v0 = temp_v0_8; - if (temp_v0_8 == 3) { - gModeSelection = GRAND_PRIX; - phi_v0 = 0; + temp_a0 = gCurrentCourseId; + if ((temp_a0 != 0x000F) && (temp_a0 != 0x0010) && (temp_a0 != 0x0011) && (temp_a0 != 0x0013)) { + var_v0 = gModeSelection; + if (var_v0 == 3) { + gModeSelection = 0; + var_v0 = 0; } - if ((phi_v0 == 2) && (gPlayerCountSelection1 == 1)) { - gModeSelection = GRAND_PRIX; + if ((var_v0 == 2) && (gPlayerCountSelection1 == 1)) { + gModeSelection = 0; } } else { - gModeSelection = BATTLE; + gModeSelection = 3; if (gPlayerCountSelection1 == 1) { - D_8018EDF3 = TWO_PLAYERS_SELECTED; - gScreenModeSelection = SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL; - gPlayerCountSelection1 = D_8018EDF3; + D_8018EDF3 = (s8) 2; + gScreenModeSelection = 1; + gPlayerCountSelection1 = (s32) D_8018EDF3; } } - gCupSelection = gCupSelectionByCourseId[gCurrentCourseId]; + gCupSelection = (s8) gCupSelectionByCourseId[temp_a0]; temp_v1_9 = gDebugGotoScene; - D_800DC540 = gCupSelection; - gCupCourseSelection = gPerCupIndexByCourseId[gCurrentCourseId]; - if (temp_v1_9 != DEBUG_GOTO_ENDING_SEQUENCE) { - if (temp_v1_9 != DEBUG_GOTO_CREDITS_SEQUENCE_CC_50) { - if (temp_v1_9 != DEBUG_GOTO_CREDITS_SEQUENCE_CC_EXTRA) { - if (gCCSelection == CC_EXTRA) { - gIsMirrorMode = 1; - return; - } - gIsMirrorMode = 0; - /* Duplicate return node #115. Try simplifying control flow for better match */ - return; - } - gCCSelection = CC_EXTRA; + D_800DC540 = (s32) gCupSelection; + gCupCourseSelection = (s8) gPerCupIndexByCourseId[temp_a0]; + switch (temp_v1_9) { /* switch 6; irregular */ + case 2: /* switch 6 */ + gCCSelection = 0; + return; + case 3: /* switch 6 */ + gCCSelection = 3; + return; + default: /* switch 6 */ + if (gCCSelection == 3) { + gIsMirrorMode = 1; return; } - gCCSelection = CC_50; + gIsMirrorMode = 0; + case 1: /* switch 6 */ + default: /* switch 2 */ return; } - default: /* switch 2 */ } } #else @@ -8975,7 +8915,8 @@ void func_800A15EC(struct_8018D9E0_entry *arg0) { } #ifdef MIPS_TO_C -//generated by mips_to_c commit 0ca3d5f5fa5e3d957908269ac1535e7d4f12bce9 +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de +RGBA16 D_800E74D0[3]; /* unable to generate initializer */ void func_800A1780(struct_8018D9E0_entry *arg0) { Gfx *temp_t0; @@ -8994,7 +8935,7 @@ void func_800A1780(struct_8018D9E0_entry *arg0) { gDisplayListHead = temp_t0 + 8; temp_t0->words.w0 = 0xFA000000; temp_t0->words.w1 = (((s32) ((temp_v1->red * temp_a2) + (temp_a1->red * temp_v0)) / 256) << 0x18) | ((((s32) ((temp_v1->green * temp_a2) + (temp_a1->green * temp_v0)) / 256) & 0xFF) << 0x10) | ((((s32) ((temp_v1->blue * temp_a2) + (temp_a1->blue * temp_v0)) / 256) & 0xFF) << 8) | (((s32) ((temp_v1->alpha * temp_a2) + (temp_a1->alpha * temp_v0)) / 256) & 0xFF); - gDisplayListHead = func_8009BA74(gDisplayListHead, segmented_to_virtual(&D_02001FA4), arg0->column, arg0->row); + gDisplayListHead = func_8009BA74(gDisplayListHead, segmented_to_virtual(D_02001FA4), arg0->column, arg0->row); } #else GLOBAL_ASM("asm/non_matchings/code_80091750/func_800A1780.s") @@ -11477,11 +11418,8 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_800A638C.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 06ada559d7a32fdab49fa2d619cdfa027615bcda +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de ? guMtxCatL(Mtx *, Mtx *, Mtx *); /* extern */ -? guRotate(Mtx *, f32, f32, f32, f32); /* extern */ -? guScale(f32, f32, Mtx *, f32, f32, f32); /* extern */ -? guTranslate(Mtx *, f32, f32, f32); /* extern */ extern ? D_0D003090; extern f32 D_8018ED98; extern f32 D_8018ED9C; @@ -11520,9 +11458,9 @@ void func_800A66A8(struct_8018D9E0_entry *arg0, f32 *arg1) { D_8018EDA4 = temp_f2; D_8018EDA8 = temp_f12; D_8018EDAC = temp_f14; - D_8018ED98 = D_8018ED98 + temp_f2; - D_8018ED9C = D_8018ED9C + temp_f12; - guScale(temp_f12, temp_f14, temp_s1, 1.2f, 1.2f, 1.2f); + D_8018ED98 += temp_f2; + D_8018ED9C += temp_f12; + guScale(temp_s1, 1.2f, 1.2f, 1.2f); temp_s0 = temp_s1 + 0x40; guRotate(temp_s0, D_8018ED9C, 0.0f, 1.0f, 0.0f); guMtxCatL(temp_s1, temp_s0, temp_s1); @@ -11540,7 +11478,7 @@ void func_800A66A8(struct_8018D9E0_entry *arg0, f32 *arg1) { D_80164AF0 += 1; gDisplayListHead = temp_v0_2 + 8; temp_v0_2->words.w0 = 0xB6000000; - temp_v0_2->words.w1 = 0x20000; + temp_v0_2->words.w1 = 0x00020000; temp_v0_3 = gDisplayListHead; gDisplayListHead = temp_v0_3 + 8; temp_v0_3->words.w1 = 0xFF33FFFF; @@ -11551,7 +11489,7 @@ void func_800A66A8(struct_8018D9E0_entry *arg0, f32 *arg1) { temp_v0_4->words.w0 = 0xC0000000; temp_v0_5 = gDisplayListHead; gDisplayListHead = temp_v0_5 + 8; - temp_v0_5->words.w1 = 0x504340; + temp_v0_5->words.w1 = 0x00504340; temp_v0_5->words.w0 = 0xB900031D; temp_v0_6 = gDisplayListHead; gDisplayListHead = temp_v0_6 + 8; @@ -11816,46 +11754,40 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_800A6E94.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 06ada559d7a32fdab49fa2d619cdfa027615bcda -static s8 *D_800E7A34[2] = { "RACE DATA CANNOT ", "BE SAVED FOR GHOST" }; /* const */ +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de +static s8 *D_800E7A34[2] = { "RACE DATA CANNOT ", "BE SAVED FOR GHOST" }; void func_800A70E8(struct_8018D9E0_entry *arg0) { Gfx *temp_v0; - s32 temp_a1; s32 temp_f6; - s32 temp_s0; - s32 temp_s0_2; - s32 phi_s0; - s32 phi_a1; - s32 phi_s0_2; - s8 **phi_s1; + s32 var_a1; + s32 var_s0; + s32 var_s0_2; + s8 **var_s1; if (arg0->unk4 == 1) { - temp_s0 = (s32) ((f32) get_string_width(D_800E7A34->unk0) * 0.45f); + var_s0 = (s32) ((f32) get_string_width(D_800E7A34->unk0) * 0.45f); temp_f6 = (s32) ((f32) get_string_width(D_800E7A34->unk4) * 0.45f); - phi_s0 = temp_s0; - if (temp_s0 < temp_f6) { - phi_s0 = temp_f6; + if (var_s0 < temp_f6) { + var_s0 = temp_f6; } - gDisplayListHead = draw_box(gDisplayListHead, 0xC0, 0x22, phi_s0 + 0xC6, 0x39, 0, 0, 0, 0x96); - temp_a1 = 0x180 - (((s32) arg0->unk1C % 32) * 8); - phi_a1 = temp_a1; - if (temp_a1 >= 0x100) { - phi_a1 = 0xFF; + gDisplayListHead = draw_box(gDisplayListHead, 0x000000C0, 0x00000022, var_s0 + 0xC6, 0x00000039, 0, 0, 0, 0x00000096); + var_a1 = 0x180 - (((s32) arg0->unk1C % 32) * 8); + if (var_a1 >= 0x100) { + var_a1 = 0xFF; } temp_v0 = gDisplayListHead; gDisplayListHead = temp_v0 + 8; - temp_v0->words.w1 = phi_a1 & 0xFF; + temp_v0->words.w1 = var_a1 & 0xFF; temp_v0->words.w0 = 0xFA000000; set_text_color(2); - phi_s0_2 = 0x2C; - phi_s1 = D_800E7A34; + var_s1 = D_800E7A34; + var_s0_2 = 0x0000002C; do { - func_80093358(0xC0, phi_s0_2, *phi_s1, 0, 0.45f, 0.45f); - temp_s0_2 = phi_s0_2 + 0xA; - phi_s0_2 = temp_s0_2; - phi_s1 += 4; - } while (temp_s0_2 != 0x40); + func_80093358(0x000000C0, var_s0_2, *var_s1, 0, 0.45f, 0.45f); + var_s0_2 += 0xA; + var_s1 += 4; + } while (var_s0_2 != 0x00000040); } } #else @@ -14470,46 +14402,42 @@ void func_800AB020(struct_8018D9E0_entry *arg0) { GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AB020.s") #endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 06ada559d7a32fdab49fa2d619cdfa027615bcda +#ifdef NEEDS_RODATA +// Needs jpt_800F2608 void func_800AB098(struct_8018D9E0_entry *arg0) { - s32 temp_t6; - s32 temp_t8; - s32 temp_v0; - - temp_t6 = arg0->unk4; - switch (temp_t6) { + switch (arg0->unk4) { case 0: - if (arg0->type == (gCupSelection + 0x53)) { + if ((gCupSelection + 0x53) == arg0->type) { arg0->unk4 = 2; - return; + } else { + arg0->unk4 = 1; } - arg0->unk4 = 1; - return; + break; case 4: - if (arg0->type == (gCupSelection + 0x53)) { + if ((gCupSelection + 0x53) == arg0->type) { arg0->unk4 = 2; arg0->unk1C = 0; - return; + break; + } else { + arg0->unk4 = 1; } - arg0->unk4 = 1; + // Purposeful fallthrough case 1: - temp_v0 = arg0->unk1C; - temp_t8 = temp_v0 + 2; - if (temp_v0 < 0x20) { - arg0->unk1C = temp_t8; - if (temp_t8 >= 0x20) { - arg0->unk1C = 0x20; - return; + if (arg0->unk1C < 32) { + arg0->unk1C += 2; + if (arg0->unk1C >= 32) { + arg0->unk1C = 32; } } - default: - return; + break; case 3: - if (arg0->type == (gCupSelection + 0x53)) { + if ((gCupSelection + 0x53) == arg0->type) { arg0->unk4 = 2; } break; + case 2: + default: + break; } } #else @@ -14578,38 +14506,32 @@ void func_800AB290(struct_8018D9E0_entry *arg0) { } #ifdef MIPS_TO_C -//generated by mips_to_c commit 06ada559d7a32fdab49fa2d619cdfa027615bcda +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de void func_800AB314(struct_8018D9E0_entry *arg0) { s32 sp3C; void *sp24; void **sp1C; - s32 temp_a1; - s32 temp_a1_2; s32 temp_t2; s32 temp_t5; s32 temp_t7; - s32 temp_v0; - void **temp_v1; - void **phi_v1; - s32 phi_a1; - s32 phi_v0; - s8 phi_a0; - s32 phi_a1_2; - void **phi_v1_2; + s32 var_a1; + s32 var_v0; + s8 var_a1_2; + struct_8018D9E0_entry *temp_v0; + void **var_v1; + void **var_v1_2; + void *temp_t7_2; - phi_v1 = &sp24; - phi_a1 = 0; - phi_a1_2 = 0; + var_v1 = &sp24; + var_a1 = 0; do { - sp1C = phi_v1; - sp3C = phi_a1; - arg0 = arg0; - temp_a1 = phi_a1 + 1; - temp_v1 = phi_v1 + 4; - temp_v1->unk-4 = find_8018D9E0_entry_dupe(phi_a1 + 0x5F); - phi_v1 = temp_v1; - phi_a1 = temp_a1; - } while (temp_a1 < 4); + sp1C = var_v1; + sp3C = var_a1; + temp_v0 = find_8018D9E0_entry_dupe(var_a1 + 0x5F); + var_a1 += 1; + var_v1 += 4; + var_v1->unk-4 = temp_v0; + } while (var_a1 < 4); if (gModeSelection != 0) { if (D_8018EDEC != 1) { arg0->unk4 = 0; @@ -14658,10 +14580,8 @@ void func_800AB314(struct_8018D9E0_entry *arg0) { sp30->unk14 = 6; } } else { - temp_v0 = arg0->unk4; - phi_v0 = temp_v0; - phi_a0 = 1; - switch (temp_v0) { /* irregular */ + var_v0 = arg0->unk4; + switch (var_v0) { /* irregular */ case 0: if (((s32) arg0->unk1C / 4) == gCupSelection) { temp_t5 = arg0->unk20 + 1; @@ -14675,32 +14595,31 @@ void func_800AB314(struct_8018D9E0_entry *arg0) { arg0->unk20 = 0; arg0->unk1C = gCupSelection * 4; } - phi_a0 = 1; if (D_8018EDEC == 3) { arg0->unk4 = 2; arg0->unk20 = 0; } - phi_v0 = arg0->unk4; + var_v0 = arg0->unk4; break; case 1: + var_v0 = 0; if (((s32) arg0->unk1C / 4) != gCupSelection) { arg0->unk4 = 0; arg0->unk20 = 0; arg0->unk1C = 0; - phi_v0 = 0; } else { temp_t2 = arg0->unk20 + 1; arg0->unk20 = temp_t2; if (temp_t2 >= 0x1F) { arg0->unk20 = 0; + var_v0 = arg0->unk4; arg0->unk1C = (gCupSelection * 4) + ((s32) (((s32) arg0->unk1C % 4) + 1) % 4); - phi_v0 = arg0->unk4; } else { if (D_8018EDEC == 3) { arg0->unk4 = 2; arg0->unk20 = 0; } - phi_v0 = arg0->unk4; + var_v0 = arg0->unk4; } } break; @@ -14716,76 +14635,77 @@ void func_800AB314(struct_8018D9E0_entry *arg0) { arg0->unk20 = 0; arg0->unk1C = 0; } - phi_v0 = arg0->unk4; + var_v0 = arg0->unk4; break; case 3: if (D_8018EDEC != 3) { arg0->unk4 = 0; arg0->unk20 = 0; arg0->unk1C = 0; - phi_v0 = 0; + var_v0 = 0; } break; } - if ((phi_v0 != 0) && (phi_v0 != phi_a0)) { - if (phi_v0 != 2) { - if (phi_v0 != 3) { + if ((var_v0 != 0) && (var_v0 != (s32) 1)) { + var_a1_2 = 0; + if (var_v0 != 2) { + if (var_v0 != (s32) 3) { return; } - sp24->unk15 = phi_a0; + sp24->unk15 = 1; sp24->unk14 = 6; - sp28->unk15 = phi_a0; + sp28->unk15 = 1; sp28->unk14 = 6; - sp2C->unk15 = phi_a0; + sp2C->unk15 = 1; sp2C->unk14 = 6; - sp30->unk15 = phi_a0; + sp30->unk15 = 1; sp30->unk14 = 6; return; } - phi_v1_2 = &sp24; + var_v1_2 = &sp24; do { - if (phi_a1_2 == ((s32) arg0->unk1C % 4)) { - phi_v1_2->unk0->unk14 = 6; - } else if (arg0->unk20 < (phi_a1_2 * 5)) { - phi_v1_2->unk0->unk14 = 4; + if (var_a1_2 == ((s32) arg0->unk1C % 4)) { + var_v1_2->unk0->unk14 = 6; + } else if (arg0->unk20 < (var_a1_2 * 5)) { + var_v1_2->unk0->unk14 = 4; } else { - phi_v1_2->unk0->unk14 = 8; + var_v1_2->unk0->unk14 = 8; } - phi_v1_2->unk0->unk15 = phi_a0; - if ((phi_a1_2 + 1) == ((s32) arg0->unk1C % 4)) { - phi_v1_2->unk4->unk14 = 6; - } else if (arg0->unk20 < ((phi_a1_2 * 5) + 5)) { - phi_v1_2->unk4->unk14 = 4; + var_v1_2->unk0->unk15 = 1; + if ((var_a1_2 + 1) == ((s32) arg0->unk1C % 4)) { + var_v1_2->unk4->unk14 = 6; + } else if (arg0->unk20 < ((var_a1_2 * 5) + 5)) { + var_v1_2->unk4->unk14 = 4; } else { - phi_v1_2->unk4->unk14 = 8; + var_v1_2->unk4->unk14 = 8; } - temp_a1_2 = phi_a1_2 + 2; - phi_v1_2->unk4->unk15 = phi_a0; - phi_a1_2 = temp_a1_2; - phi_v1_2 += 8; - } while (temp_a1_2 != 4); + temp_t7_2 = var_v1_2->unk4; + var_a1_2 += 2; + var_v1_2 += 8; + temp_t7_2->unk15 = 1; + } while (var_a1_2 != 4); return; } - if ((arg0->unk1C & 3) == 0) { - sp24->unk15 = phi_a0; + if (!(arg0->unk1C & 3)) { + sp24->unk15 = 1; } else { sp24->unk15 = 0; } sp24->unk14 = 6; if (((s32) arg0->unk1C % 4) == 1) { - sp28->unk15 = phi_a0; + sp28->unk15 = 1; } else { sp28->unk15 = 0; } sp28->unk14 = 6; if (((s32) arg0->unk1C % 4) == 2) { - sp2C->unk15 = phi_a0; + sp2C->unk15 = 1; } else { sp2C->unk15 = 0; } sp2C->unk14 = 6; if (((s32) arg0->unk1C % 4) == 3) { - sp30->unk15 = phi_a0; + sp30->unk15 = 1; } else { sp30->unk15 = 0; } @@ -17225,72 +17145,60 @@ void func_800AF4DC(struct_8018D9E0_entry *arg0) { GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AF4DC.s") #endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 06ada559d7a32fdab49fa2d619cdfa027615bcda -? func_800A9208(struct_8018D9E0_entry *, s32); /* extern */ -? func_800A94C8(struct_8018D9E0_entry *, s32, ?); /* extern */ -extern ? D_802854B0; - +#ifdef NEEDS_RODATA +// Needs jpt_800F2B00 +extern f64 D_800F2B18;// 0.05; +extern f64 D_800F2B20;// 0.0085; +extern f64 D_800F2B28;// 0.4; void func_800AF740(struct_8018D9E0_entry *arg0) { - struct_802850C0_entry *sp20; - f64 temp_f0; - s32 temp_t6; - s32 temp_t6_2; - s32 temp_t9; + s32 pad; s32 temp_v0; struct_802850C0_entry *temp_v1; - temp_t9 = arg0->unk4; temp_v0 = arg0->type - 0x190; temp_v1 = &D_802850C0[temp_v0]; - arg0->row = (s32) temp_v1->row; - switch (temp_t9) { + arg0->row = temp_v1->row; + switch (arg0->unk4) { case 0: + arg0->column = temp_v1->startingColumn; arg0->unk4 = 1; - arg0->column = (s32) temp_v1->startingColumn; - sp20 = temp_v1; - arg0->unk20 = (s32) ((f32) temp_v1->columnExtra - (((f32) get_string_width(*(&D_802854B0 + (temp_v0 * 4))) * temp_v1->textScaling) / 2.0f)); + arg0->unk20 = temp_v1->columnExtra - (get_string_width(D_802854B0[temp_v0]) * temp_v1->textScaling / 2); /* fallthrough */ case 1: func_800A9208(arg0, arg0->unk20); - temp_t6 = (s32) (arg0->column - arg0->unk20) / 4; - arg0->unk1C = temp_t6; - if (temp_t6 >= 9) { + arg0->unk1C = (s32) (arg0->column - arg0->unk20) / 4; + if (arg0->unk1C >= 9) { arg0->unk1C = 8; } - arg0->unk24 = (f32) (((f64) arg0->unk1C * 0.05) + 1.0); + arg0->unk24 = (arg0->unk1C * 0.05) + 1.0; if ((arg0->unk20 + 0x14) >= arg0->column) { arg0->unk4 = 2; arg0->D_8018DEE0_index = 0; - return; } - default: - return; + break; case 2: func_800A9208(arg0, arg0->unk20); - temp_t6_2 = arg0->D_8018DEE0_index + 1; - temp_f0 = (f64) (temp_t6_2 - 0xA); - arg0->unk1C = (s32) (arg0->column - arg0->unk20) / 4; - arg0->D_8018DEE0_index = temp_t6_2; - arg0->unk24 = (f32) ((temp_f0 * 0.0085 * temp_f0) + 0.4); - if ((temp_t6_2 >= 9) && ((f64) arg0->unk24 > 1.0)) { - arg0->unk4 = 3; + arg0->unk1C = (arg0->column - arg0->unk20) / 4; + arg0->D_8018DEE0_index += 1; + arg0->unk24 = ((arg0->D_8018DEE0_index - 0xA) * 0.0085 * (arg0->D_8018DEE0_index - 0xA)) + 0.4; + if ((arg0->D_8018DEE0_index >= 9) && ((f64) arg0->unk24 > 1)) { arg0->unk24 = 1.0f; - return; + arg0->unk4 = 3; } break; case 3: if ((u8) D_8018ED91 != 0) { arg0->unk4 = 4; - return; } break; case 4: func_800A94C8(arg0, arg0->unk20, -1); - if ((f64) arg0->row > 480.0) { + if (arg0->row > 480.0) { arg0->type = 0; } break; + default: + break; } } #else diff --git a/src/code_80091750.h b/src/code_80091750.h index f784285c0..4b3e5f3ed 100644 --- a/src/code_80091750.h +++ b/src/code_80091750.h @@ -63,6 +63,7 @@ void func_80092290(s32, s32*, s32*); void func_80092500(); void func_80092564(); void func_800925A0(); +void func_800925CC(); void func_80092604(); void func_80092630(); void func_8009265C(); @@ -115,7 +116,7 @@ void func_8009CA2C(); void func_8009CA6C(s32); void func_80099A94(MkTexture *, s32); void func_80099AEC(); -void func_8009E1E4(void); +void func_8009E1E4(); void func_80099E54(); void func_80099E60(MkTexture *, s32, s32); void func_80099EC4(); @@ -137,12 +138,13 @@ Gfx *func_8009BEF0(Gfx*, s32, f32, f32, s32, f32,f32); Gfx *func_8009C434(Gfx*, struct_8018DEE0_entry*, s32, s32, s32); Gfx *func_8009C708(Gfx*, struct_8018DEE0_entry *, s32, s32, s32, s32); void func_8009C918(); +void func_8009CA2C(); void func_8009E0F0(s32); void func_8009E1C0(); void func_8009E1E4(); -void func_8009E208(void); -void func_8009E258(void); -void func_8009E280(void); +void func_8009E208(); +void func_8009E258(); +void func_8009E280(); void func_8009E5BC(); void func_8009E620(); void add_8018D9E0_entry(s32, s32, s32, s8); @@ -192,6 +194,7 @@ struct_8018D9E0_entry *find_8018D9E0_entry_dupe(s32); struct_8018D9E0_entry *find_8018D9E0_entry(s32); s32 func_800AAF70(s32); void func_800AAF94(struct_8018D9E0_entry*, s32); +void func_800AB098(struct_8018D9E0_entry*); void func_800AB260(struct_8018D9E0_entry*); void func_800AB290(struct_8018D9E0_entry*); void func_800AC978(struct_8018D9E0_entry*); diff --git a/src/render_courses.c b/src/render_courses.c index d25729613..a9a64b46f 100644 --- a/src/render_courses.c +++ b/src/render_courses.c @@ -83,142 +83,132 @@ void func_80290CAC(uintptr_t arg0) { } #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s16 func_802ABD40(u16, void *, s16); // extern +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de extern ? D_80152300; -extern void *gDisplayListHead; -extern ? gSegmentTable; +s16 gCurrentCourseId; /* unable to generate initializer */ -void load_surface_map(u32 arg0, void *arg1) { - void *sp34; - void *sp30; - s32 sp24; +void load_surface_map(u32 arg0, struct UnkStruct_800DC5EC *arg1) { + Player *sp34; + Camera *sp30; + void *sp24; s16 sp22; s16 sp1E; + Camera *temp_a2; + Gfx *temp_v1_3; + Player *temp_t1; s16 temp_v0_3; s16 temp_v0_4; s16 temp_v1; s16 temp_v1_2; + s16 var_a0; + s16 var_a3; u16 temp_v0; u16 temp_v0_2; - void *temp_a2; - void *temp_t1; - void *temp_v1_3; - s16 phi_a3; - s16 phi_a0; - void *phi_t0; - s16 phi_a3_2; - temp_t1 = arg1->unk8; - temp_a2 = arg1->unk4; - sp24 = *(&gSegmentTable + ((arg0 >> 0x18) * 4)) + (arg0 & 0xFFFFFF) + 0x80000000; + temp_t1 = arg1->player; + temp_a2 = arg1->camera; + sp24 = gSegmentTable[arg0 >> 0x18] + (arg0 & 0xFFFFFF) + 0x80000000; if (gIsMirrorMode != 0) { - temp_v0 = temp_a2->unk26; - if (temp_v0 < 0x2000) { - phi_a3 = 2; - } else if (temp_v0 < 0x6000) { - phi_a3 = 3; - } else if (temp_v0 < 0xA000) { - phi_a3 = 0; - } else if (temp_v0 < 0xE000) { - phi_a3 = 1; + temp_v0 = (u16) temp_a2->rot[1]; + if ((s32) temp_v0 < 0x2000) { + var_a3 = 2; + } else if ((s32) temp_v0 < 0x6000) { + var_a3 = 3; + } else if ((s32) temp_v0 < 0xA000) { + var_a3 = 0; + } else if ((s32) temp_v0 < 0xE000) { + var_a3 = 1; } else { - phi_a3 = 2; + var_a3 = 2; } } else { - temp_v0_2 = temp_a2->unk26; - if (temp_v0_2 < 0x2000) { - phi_a3 = 2; - } else if (temp_v0_2 < 0x6000) { - phi_a3 = 1; - } else if (temp_v0_2 < 0xA000) { - phi_a3 = 0; + temp_v0_2 = (u16) temp_a2->rot[1]; + if ((s32) temp_v0_2 < 0x2000) { + var_a3 = 2; + } else if ((s32) temp_v0_2 < 0x6000) { + var_a3 = 1; + } else if ((s32) temp_v0_2 < 0xA000) { + var_a3 = 0; } else { - phi_a3 = 2; - if (temp_v0_2 < 0xE000) { - phi_a3 = 3; + var_a3 = 2; + if ((s32) temp_v0_2 < 0xE000) { + var_a3 = 3; } } } - arg1->unk36 = phi_a3; - if (*(&D_80152300 + (((temp_a2 - camera1) / 0xB8) * 2)) == 1) { + arg1->playerDirection = var_a3; + if (*(&D_80152300 + (((s32) (temp_a2 - camera1) / 184) * 2)) == 1) { sp34 = temp_t1; - sp22 = phi_a3; + sp22 = var_a3; sp30 = temp_a2; - sp1E = func_802ABD40(temp_a2->unk5E, temp_a2, phi_a3); - temp_v0_3 = func_802ABD40(temp_t1->unk11A); + sp1E = func_802ABD40(temp_a2->unk_54.unk3A); + temp_v0_3 = func_802ABD40(temp_t1->unk_110.unk3A); temp_v1 = sp1E - temp_v0_3; - phi_t0 = arg1; - phi_a3_2 = phi_a3; if ((temp_v1 < 2) && (temp_v1 >= -1)) { - if (sp1E == 0xFF) { - if (temp_v0_3 == 0xFF) { + if (sp1E == 0x00FF) { + if (temp_v0_3 == 0x00FF) { goto block_60; } - if (temp_t1->unk124 > 30.0f) { + if (temp_t1->unk_110.unk44 > 30.0f) { goto block_60; } - phi_a0 = temp_v0_3; + var_a0 = temp_v0_3; } else { - if (temp_a2->unk68 > 30.0f) { + if (temp_a2->unk_54.unk44 > 30.0f) { goto block_60; } - phi_a0 = sp1E; + var_a0 = sp1E; } } else { temp_v1_2 = gCurrentCourseId; if (temp_v1_2 != 1) { if (temp_v1_2 == 2) { if ((temp_v0_3 >= 0x11) && (temp_v0_3 < 0x18)) { - phi_a0 = temp_v0_3; - } else if ((temp_v0_3 == 0xFF) && (sp1E != 0xFF)) { - phi_a0 = sp1E; - } else if ((temp_v0_3 != 0xFF) && (sp1E == 0xFF)) { - phi_a0 = temp_v0_3; + var_a0 = temp_v0_3; + } else if ((temp_v0_3 == 0x00FF) && (sp1E != 0x00FF)) { + var_a0 = sp1E; + } else if ((temp_v0_3 != 0x00FF) && (sp1E == 0x00FF)) { + var_a0 = temp_v0_3; } else { goto block_60; } } else { - if (temp_v0_3 == 0xFF) { + if (temp_v0_3 == 0x00FF) { goto block_60; } - if (temp_t1->unk124 > 30.0f) { + if (temp_t1->unk_110.unk44 > 30.0f) { goto block_60; } - phi_a0 = temp_v0_3; + var_a0 = temp_v0_3; } } else if ((temp_v0_3 >= 0xE) && (temp_v0_3 < 0x16)) { - phi_a0 = temp_v0_3; - } else if ((temp_v0_3 == 0xFF) && (sp1E != 0xFF)) { - phi_a0 = sp1E; - } else if ((temp_v0_3 != 0xFF) && (sp1E == 0xFF)) { - phi_a0 = temp_v0_3; + var_a0 = temp_v0_3; + } else if ((temp_v0_3 == 0x00FF) && (sp1E != 0x00FF)) { + var_a0 = sp1E; + } else if ((temp_v0_3 != 0x00FF) && (sp1E == 0x00FF)) { + var_a0 = temp_v0_3; } else { goto block_60; } } } else { - sp22 = phi_a3; + sp22 = var_a3; sp30 = temp_a2; - temp_v0_4 = func_802ABD40(temp_a2->unk5E, temp_a2, phi_a3); - phi_a0 = temp_v0_4; - phi_t0 = arg1; - phi_a3_2 = phi_a3; - if (temp_a2->unk68 > 30.0f) { + temp_v0_4 = func_802ABD40(temp_a2->unk_54.unk3A); + var_a0 = temp_v0_4; + if (temp_a2->unk_54.unk44 > 30.0f) { goto block_60; } - if (temp_v0_4 == 0xFF) { + if (temp_v0_4 == 0x00FF) { block_60: - phi_a0 = arg1->unk38; - phi_t0 = arg1; - phi_a3_2 = phi_a3; + var_a0 = arg1->pathCounter; } } - phi_t0->unk38 = phi_a0; + arg1->pathCounter = var_a0; temp_v1_3 = gDisplayListHead; gDisplayListHead = temp_v1_3 + 8; - temp_v1_3->unk0 = 0x6000000; - temp_v1_3->unk4 = *(sp24 + ((((phi_a0 * 4) + phi_a3_2) - 4) * 4)); + temp_v1_3->words.w0 = 0x06000000; + temp_v1_3->words.w1 = *(sp24 + ((s16) (((var_a0 * 4) + var_a3) - 4) * 4)); } #else GLOBAL_ASM("asm/non_matchings/render_courses/load_surface_map.s") diff --git a/src/skybox_and_splitscreen.c b/src/skybox_and_splitscreen.c index 83076fbc0..64864488d 100644 --- a/src/skybox_and_splitscreen.c +++ b/src/skybox_and_splitscreen.c @@ -581,102 +581,6 @@ void func_802A4A0C(Vtx *arg0, struct UnkStruct_800DC5EC *arg1, s32 arg2, s32 arg GLOBAL_ASM("asm/non_matchings/skybox/func_802A4A0C.s") #endif -/* -void func_802A4A0C(Vtx *arg0, void *arg1, ? arg2, ? arg3) { - void *sp13C; - ? sp128; - ? spE8; - ? spA8; - ? sp68; - f32 sp64; - f32 sp60; - f32 sp5C; - f32 sp58; - Gfx *temp_v0; - Gfx *temp_v0_2; - Gfx *temp_v0_3; - Gfx *temp_v0_4; - Gfx *temp_v0_5; - Gfx *temp_v0_6; - Gfx *temp_v0_7; - Gfx *temp_v0_8; - Gfx *temp_v0_9; - f32 temp_f0; - f32 temp_f10; - f32 temp_f16; - f32 temp_f18; - f32 temp_f6; - s16 temp_t5; - - sp13C = arg1->unk4; - func_802A450C(arg0); - sp64 = D_802B9BB0; - sp5C = 0.0f; - sp60 = 0.0f; - func_802B5564(&spE8, &sp128, sp13C->unkB4, D_80150148, D_80150150, D_8015014C, 1.0f); - func_802B5794(&spA8, sp13C, sp13C + 0xC); - func_802B71CC(&sp68, &spE8, &spA8); - sp58 = spA4 + ((sp74 * sp5C) + (sp84 * sp60) + (sp94 * sp64)); - func_802B6434(&sp5C, &sp68); - temp_f0 = (f32) (1.0 / (f64) sp58); - temp_f18 = sp5C * temp_f0; - temp_f6 = sp60 * temp_f0; - temp_f10 = temp_f18 * 160.0f; - sp5C = temp_f18; - temp_f16 = temp_f6 * 120.0f; - sp60 = temp_f6; - sp5C = temp_f10; - sp60 = temp_f16; - temp_t5 = 0x78 - (s32) temp_f16; - arg1->unk28 = temp_t5; - arg0->unk12 = temp_t5; - arg0->unk22 = temp_t5; - arg0->unk42 = temp_t5; - arg0->unk72 = temp_t5; - func_802A3E3C(); - temp_v0 = gDisplayListHead; - gDisplayListHead = temp_v0 + 8; - temp_v0->words.w0 = 0xB900031D; - temp_v0->words.w1 = 0xF0A4000; - temp_v0_2 = gDisplayListHead; - gDisplayListHead = temp_v0_2 + 8; - temp_v0_2->words.w0 = 0xB6000000; - temp_v0_2->words.w1 = 0x20001; - guOrtho((Mtx *) gGfxPool, 0.0f, 320.0f, 0.0f, 240.0f, 0.0f, 5.0f, 1.0f); - temp_v0_3 = gDisplayListHead; - gDisplayListHead = temp_v0_3 + 8; - temp_v0_3->words.w1 = 0xFFFF; - temp_v0_3->words.w0 = 0xB4000000; - temp_v0_4 = gDisplayListHead; - gDisplayListHead = temp_v0_4 + 8; - temp_v0_4->words.w0 = 0x1030040; - temp_v0_4->words.w1 = (s32) gGfxPool & 0x1FFFFFFF; - temp_v0_5 = gDisplayListHead; - gDisplayListHead = temp_v0_5 + 8; - temp_v0_5->words.w1 = (s32) &D_0D008E98 & 0x1FFFFFFF; - temp_v0_5->words.w0 = 0x1020040; - temp_v0_6 = gDisplayListHead; - gDisplayListHead = temp_v0_6 + 8; - temp_v0_6->words.w1 = (u32) arg0; - temp_v0_6->words.w0 = 0x400103F; - temp_v0_7 = gDisplayListHead; - gDisplayListHead = temp_v0_7 + 8; - temp_v0_7->words.w0 = 0xB1000602; - temp_v0_7->words.w1 = 0x20604; - if (gCurrentCourseId == 0xD) { - temp_v0_8 = gDisplayListHead; - gDisplayListHead = temp_v0_8 + 8; - temp_v0_8->words.w1 = (u32) (arg0 + 0x40); - temp_v0_8->words.w0 = 0x400103F; - temp_v0_9 = gDisplayListHead; - gDisplayListHead = temp_v0_9 + 8; - temp_v0_9->words.w1 = 0x20604; - temp_v0_9->words.w0 = 0xB1000602; - } -} - -*/ - #ifdef MIPS_TO_C extern s32 gScreenModeSelection; void func_802A4D18(void) { @@ -1481,95 +1385,63 @@ void func_802A74BC(void) { } #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 +//generated by m2c commit 3b40ab93768f52ac241c5ae84ef58ef6bc4cb1de void func_802A7658(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { - s32 temp_a0; - s32 temp_a1; - s32 temp_a1_2; s32 temp_t5; - s32 temp_v0; - s32 temp_v0_2; - s32 temp_v1; - u16 *temp_t1; - u16 *temp_t1_2; - u16 *temp_t1_3; - void *temp_t3; - u16 *phi_t3; - u16 *phi_t1; - s32 phi_a1; - void *phi_t3_2; - u16 *phi_t1_2; - s32 phi_a1_2; - s32 phi_v1; - s32 phi_a2; - s32 phi_v0; - s32 phi_a0; - s32 phi_a0_2; - s32 phi_v0_2; - s32 phi_v0_3; + s32 var_a0; + s32 var_a1; + s32 var_a2; + s32 var_v0; + s32 var_v1; + u16 *var_t1; + u16 *var_t3; + u16 temp_t8; + u16 temp_t9; + void *var_t3_2; - phi_v1 = 0; - phi_v0 = 0; + var_v0 = 0; + var_v1 = 0; if (arg3 > 0) { - phi_a2 = (arg1 * 0x140) + arg0; + var_a2 = (arg1 * 0x140) + arg0; do { - phi_a1 = 0; - phi_a0 = phi_a2; - phi_a1_2 = 0; - phi_a0_2 = phi_a2; - phi_v0_2 = phi_v0; - phi_v0_3 = phi_v0; + var_a0 = var_a2; + var_a1 = 0; if (arg2 > 0) { temp_t5 = arg2 & 3; - temp_t1 = arg5 + (phi_v0 * 2); - phi_t1 = temp_t1; - phi_t1_2 = temp_t1; + var_t1 = arg5 + (var_v0 * 2); if (temp_t5 != 0) { - phi_t3 = arg4 + (phi_a2 * 2); + var_t3 = arg4 + (var_a0 * 2); do { - temp_a1 = phi_a1 + 1; - temp_v0 = phi_v0_2 + 1; - temp_t1_2 = phi_t1 + 2; - temp_a0 = phi_a0_2 + 1; - temp_t1_2->unk-2 = *phi_t3; - phi_t3 += 2; - phi_t1 = temp_t1_2; - phi_a1 = temp_a1; - phi_a0 = temp_a0; - phi_t1_2 = temp_t1_2; - phi_a1_2 = temp_a1; - phi_v0 = temp_v0; - phi_a0_2 = temp_a0; - phi_v0_2 = temp_v0; - phi_v0_3 = temp_v0; - } while (temp_t5 != temp_a1); - if (temp_a1 != arg2) { + temp_t9 = *var_t3; + var_a1 += 1; + var_v0 += 1; + var_t1 += 2; + var_a0 += 1; + var_t3 += 2; + var_t1->unk-2 = temp_t9; + } while (temp_t5 != var_a1); + if (var_a1 != arg2) { goto block_7; } } else { block_7: - phi_t3_2 = arg4 + (phi_a0 * 2); + var_t3_2 = arg4 + (var_a0 * 2); do { - temp_a1_2 = phi_a1_2 + 4; - temp_v0_2 = phi_v0_3 + 4; - *phi_t1_2 = phi_t3_2->unk0; - temp_t1_3 = phi_t1_2 + 8; - temp_t3 = phi_t3_2 + 8; - temp_t1_3->unk-6 = phi_t3_2->unk2; - temp_t1_3->unk-4 = temp_t3->unk-4; - temp_t1_3->unk-2 = temp_t3->unk-2; - phi_t3_2 = temp_t3; - phi_t1_2 = temp_t1_3; - phi_a1_2 = temp_a1_2; - phi_v0 = temp_v0_2; - phi_v0_3 = temp_v0_2; - } while (temp_a1_2 != arg2); + var_a1 += 4; + var_v0 += 4; + *var_t1 = var_t3_2->unk0; + temp_t8 = var_t3_2->unk2; + var_t1 += 8; + var_t3_2 += 8; + var_t1->unk-6 = temp_t8; + var_t1->unk-4 = (u16) var_t3_2->unk-4; + var_t1->unk-2 = (u16) var_t3_2->unk-2; + } while (var_a1 != arg2); } } - temp_v1 = phi_v1 + 1; - phi_v1 = temp_v1; - phi_a2 += 0x140; - } while (temp_v1 != arg3); + var_v1 += 1; + var_a2 += 0x140; + } while (var_v1 != arg3); } } #else