summaryrefslogtreecommitdiff
path: root/src/code_800AF9B0.c
diff options
context:
space:
mode:
authorChiefFruitcake <96551211+ChiefFruitcake@users.noreply.github.com>2022-01-09 21:24:30 -0500
committerGitHub <noreply@github.com>2022-01-09 19:24:30 -0700
commitbc99dedb8bc0d8a1f6fed20e36ed60a3ed70b01b (patch)
tree042743f4f487447c0c289f030064f2fa502cc9f4 /src/code_800AF9B0.c
parent7acd1cbc20ad7d5632d006de6c2fae322ca5c8c0 (diff)
code_800AF9B0 - ghost data (#133)
* Match functions related to struct at D_8018EE10 * Remove asm for matched functions * Match func_800B64EC, func_800B6708, and func_800B6798 * Match func_80091EE4. Fix unused variable warnings in code_80091750.c * Name some of the fields in struct_8018EE10_entry
Diffstat (limited to 'src/code_800AF9B0.c')
-rw-r--r--src/code_800AF9B0.c221
1 files changed, 74 insertions, 147 deletions
diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c
index b44da0f29..c915f263e 100644
--- a/src/code_800AF9B0.c
+++ b/src/code_800AF9B0.c
@@ -3687,14 +3687,12 @@ s32 func_800B6014(void) {
return -1;
}
-void func_800B6088(s32 arg0) {
- s32 temp_t6;
- u8* temp_v1;
-
- temp_t6 = arg0 << 7;
- temp_v1 = (u8*) &D_8018EE10 + temp_t6;
- temp_v1[0x7F] = func_800B6828(); // compute checksum?
- osPfsReadWriteFile(&D_8018E868, D_8018EB84, PFS_WRITE, temp_t6, sizeof(struct_8018EE10_entry), temp_v1);
+s32 func_800B6088(s32 arg0) {
+ struct_8018EE10_entry* temp_v1;
+
+ temp_v1 = &D_8018EE10[arg0];
+ temp_v1->checksum = func_800B6828(arg0);
+ return osPfsReadWriteFile(&D_8018E868, D_8018EB84, PFS_WRITE, arg0 * 0x80 /* 0x80 == sizeof(struct_8018EE10_entry) */, sizeof(struct_8018EE10_entry), (u8*) temp_v1);
}
#ifdef MIPS_TO_C
@@ -3826,141 +3824,97 @@ s32 func_800B6178(s32 arg0) {
GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B6178.s")
#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-extern ? D_8018EE10;
-
-? func_800B6348(s32 arg0) {
- if ((D_8018EE10.unk4 != 0) && (arg0 == D_8018EE10.unk5)) {
+s32 func_800B6348(s32 arg0) {
+ if ((D_8018EE10[0].ghostDataSaved != 0) && (arg0 == D_8018EE10[0].courseIndex)) {
return 0;
}
- if ((D_8018EE10.unk84 != 0) && (arg0 == D_8018EE10.unk85)) {
+ if ((D_8018EE10[1].ghostDataSaved != 0) && (arg0 == D_8018EE10[1].courseIndex)) {
return 1;
}
return 0;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B6348.s")
-#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-extern ? D_8018EE10;
-
-? func_800B639C(s32 arg0) {
- if ((D_8018EE10.unk4 != 0) && (arg0 == D_8018EE10.unk5)) {
+s32 func_800B639C(s32 arg0) {
+ if ((D_8018EE10[0].ghostDataSaved != 0) && (arg0 == D_8018EE10[0].courseIndex)) {
return 0;
}
- if ((D_8018EE10.unk84 != 0) && (arg0 == D_8018EE10.unk85)) {
+ if ((D_8018EE10[1].ghostDataSaved != 0) && (arg0 == D_8018EE10[1].courseIndex)) {
return 1;
}
return -1;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B639C.s")
-#endif
-
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-? func_800051C4(); // extern
-? func_80005AE8(Player *); // extern
-s32 func_800B60E8(s32); // extern
-extern s16 D_80162DD6;
-extern s32 D_80162DFC;
-extern ? D_8018EE10;
-extern s8 gCupSelection;
-? func_800B63F0(s32 arg0) {
+s32 func_800B63F0(s32 arg0) {
s32 temp_s0;
- void *temp_v0;
- s32 phi_s0;
- void *phi_s1;
- ? phi_s3;
+ u8* phi_s1;
+ s32 phi_s3;
func_800051C4();
D_80162DD6 = 1;
func_80005AE8(gPlayerThree);
- temp_v0 = (arg0 << 7) + &D_8018EE10;
+
phi_s3 = 0;
- if (((gCupSelection * 4) + gCupCourseSelection) != temp_v0->unk5) {
+ if (((gCupSelection * 4) + gCupCourseSelection) != D_8018EE10[arg0].courseIndex) {
phi_s3 = 2;
- } else if (D_80162DFC != temp_v0->unk0) {
+ } else if (D_80162DFC != D_8018EE10[arg0].unk_00) {
phi_s3 = 3;
} else {
- phi_s0 = 0;
- phi_s1 = temp_v0;
- if (D_80162DE0 != temp_v0->unk6) {
+ if (D_80162DE0 != (u8) D_8018EE10[arg0].characterId) {
phi_s3 = 4;
} else {
-loop_6:
- temp_s0 = phi_s0 + 1;
- phi_s0 = temp_s0;
- if (phi_s1->unk7 != func_800B60E8(phi_s0)) {
- phi_s3 = 1;
- } else {
- phi_s1 += 1;
- if (temp_s0 != 0x3C) {
- goto loop_6;
+ temp_s0 = 0;
+ phi_s1 = (u8*) &D_8018EE10[arg0];
+
+ while (temp_s0 < 0x3C)
+ {
+ if (phi_s1[7] != func_800B60E8(temp_s0)) {
+ phi_s3 = 1;
+ break;
}
+
+ ++phi_s1;
+ ++temp_s0;
}
}
}
+
return phi_s3;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B63F0.s")
-#endif
-
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-? func_8000522C(); // extern
-s32 func_800B60E8(s32); // extern
-extern u8 *D_800DC714;
-extern s32 D_80162DFC;
-extern OSPfs D_8018E868;
-extern s32 D_8018EB84;
-extern ? D_8018EE10;
s32 func_800B64EC(s32 arg0) {
- s32 sp30;
s32 temp_s0;
s32 temp_v0;
- void *temp_s3;
- s32 phi_s0;
- void *phi_s1;
+ u8 *phi_s1;
- if ((arg0 != 0) && (arg0 != 1)) {
+ if ((arg0 != 0) && (arg0 != 1))
+ {
return -1;
}
- temp_v0 = osPfsReadWriteFile(&D_8018E868, D_8018EB84, 0, (arg0 * 0x3C00) + 0x100, 0x3C00, D_800DC714);
- sp30 = temp_v0;
- if (temp_v0 == 0) {
- temp_s3 = (arg0 << 7) + &D_8018EE10;
- phi_s0 = 0;
- phi_s1 = temp_s3;
-loop_5:
- temp_s0 = phi_s0 + 1;
- phi_s0 = temp_s0;
- if (phi_s1->unk7 != func_800B60E8(phi_s0)) {
- temp_s3->unk4 = 0;
- return -2;
- }
- phi_s1 += 1;
- if (temp_s0 == 0x3C) {
- func_8000522C();
- *D_80162DD4 = 0;
- D_80162DE0 = temp_s3->unk6;
- D_80162DFC = temp_s3->unk0;
- goto block_9;
+
+ temp_v0 = osPfsReadWriteFile(&D_8018E868, D_8018EB84, PFS_READ, (arg0 * 0x3C00) + 0x100, 0x3C00, (u8 *) D_800DC714);
+ if (temp_v0 == 0)
+ {
+ phi_s1 = (u8 *) &D_8018EE10[arg0]; temp_s0 = 0; while (1) {
+
+ if (phi_s1[7] != func_800B60E8(temp_s0)) {
+ D_8018EE10[arg0].ghostDataSaved = 0;
+ return -2;
+ }
+
+ ++phi_s1;
+ if ((++temp_s0) == 0x3C) {
+ func_8000522C();
+ D_80162DD4[0] = 0;
+ D_80162DE0 = (s32) D_8018EE10[arg0].characterId;
+ D_80162DFC = D_8018EE10[arg0].unk_00;
+ break;
+ }
}
- goto loop_5;
+
}
-block_9:
- return sp30;
+
+ return temp_v0;
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B64EC.s")
-#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
@@ -4012,62 +3966,35 @@ block_9:
GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B65F4.s")
#endif
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-s32 func_800B6828(s32); // extern
-extern OSPfs D_8018E868;
-extern s32 D_8018EB84;
-extern u8 D_8018EE10;
-
void func_800B6708(void) {
s32 temp_s0;
- s32 phi_s0;
- u8 *phi_s1;
- osPfsReadWriteFile(&D_8018E868, D_8018EB84, 0, 0, 0x100, &D_8018EE10);
- phi_s0 = 0;
- phi_s1 = &D_8018EE10;
- do {
- temp_s0 = phi_s0 + 1;
- phi_s0 = temp_s0;
- if (phi_s1->unk7F != func_800B6828(phi_s0)) {
- phi_s1->unk4 = 0;
+ osPfsReadWriteFile(&D_8018E868, D_8018EB84, PFS_READ, 0, 0x100 /* 2*sizeof(struct_8018EE10_entry) ? */, (u8*) &D_8018EE10);
+
+ for (temp_s0 = 0; temp_s0 < 2; ++temp_s0) {
+ if (D_8018EE10[temp_s0].checksum != func_800B6828(temp_s0)) {
+ D_8018EE10[temp_s0].ghostDataSaved = 0;
}
- phi_s1 += 0x80;
- } while (temp_s0 != 2);
+ }
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B6708.s")
-#endif
-
-#ifdef MIPS_TO_C
-//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
-s32 func_800B68F4(s32); // extern
-extern u8 *D_8018D9C0;
-extern OSPfs D_8018E8D0;
-extern s32 D_8018EB88;
void func_800B6798(void) {
s32 temp_s0;
- u8 *temp_s2;
- void *temp_v1;
- s32 phi_s0;
+ u8* tmp;
+
+ tmp = (u8*) D_8018D9C0;
- temp_s2 = D_8018D9C0;
- osPfsReadWriteFile(&D_8018E8D0, D_8018EB88, 0, 0, 0x100, temp_s2);
- phi_s0 = 0;
- do {
- temp_v1 = temp_s2 + (phi_s0 << 7);
- temp_s0 = phi_s0 + 1;
- phi_s0 = temp_s0;
- if (temp_v1->unk7F != func_800B68F4(phi_s0)) {
- temp_v1->unk4 = 0;
+ osPfsReadWriteFile(&D_8018E8D0, D_8018EB88, PFS_READ, 0, 0x100 /* 2*sizeof(struct_8018EE10_entry) ? */, tmp);
+
+ for (temp_s0 = 0; temp_s0 < 2; ++temp_s0) {
+ // if (D_8018D9C0[temp_s0]->checksum != func_800B68F4(temp_s0)) {
+ // D_8018D9C0[temp_s0]->ghostDataSaved = 0;
+ // }
+ if ( ((struct_8018EE10_entry*) (tmp + (temp_s0 << 7)))->checksum != func_800B68F4(temp_s0)) {
+ ((struct_8018EE10_entry*) (tmp + (temp_s0 << 7)))->ghostDataSaved = 0;
}
- } while (temp_s0 != 2);
+ }
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B6798.s")
-#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307