summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorRevo <projectrevotpp@hotmail.com>2022-02-19 16:50:56 -0500
committerGitHub <noreply@github.com>2022-02-19 16:50:56 -0500
commitc3533052ca4b907d4614e8a4341221862ed8e158 (patch)
tree974e7b2bceb2e8cfdabb664aeecde27026a4da0e /src/code
parent67f294774bf3cfbd8d6698c0e7790900bc988e16 (diff)
Add GCC compiler option. (#1056)
* GCC support. * Add note about gcc-mips-linux-gnu requirement to README.md. * changes * changes based on Tharo's suggestion * Cant reproduce file_choose.h error. Removing unnecessary -I * changes * wording based on Fig's suggestion * add AVOID_UB for eyes/mouth reordering issue. * remove unneeded flags and deprecate ZAPDFLAGS. * some changes, waiting on prs for the rest * fixes * discard header sections * change section handling in mkldscript * avoid_ub in DmaMgr_GetFileNameImpl * move asm to inline asm (consolidate gcc functions) * change prefix back * remove space * fix warnings * Revert "remove space" This reverts commit 94af6977b3eb4856b0d8e9eeac602c61f8010576. * Revert "fix warnings" This reverts commit d729ddf45743d6f039526469a15a15874926e9d0. * finish up missing_gcc_functions * revert unwanted mkldscript change * temporary workaround. TODO: Stop the asm processor from choking * fix ido build * Revert "temporary workaround. TODO: Stop the asm processor from choking" This reverts commit 9df892b7acb85b058ae33a1bb5970e9b52c36145. * review * remove unused line in mkldscript * remove tabs * clarify zf comment * review2 * review * remove duplicate cc_check * vanilla code always come first * std_dma avoid ub * add compiler_gcc to cflags * only use two blocks when necessary * clarify zf comment Co-authored-by: fig02 <fig02srl@gmail.com>
Diffstat (limited to 'src/code')
-rw-r--r--src/code/audio_heap.c5
-rw-r--r--src/code/z_player_lib.c23
2 files changed, 27 insertions, 1 deletions
diff --git a/src/code/audio_heap.c b/src/code/audio_heap.c
index b81a5fc76..4ba1cff41 100644
--- a/src/code/audio_heap.c
+++ b/src/code/audio_heap.c
@@ -1019,9 +1019,12 @@ void* AudioHeap_AllocPermanent(s32 tableType, s32 id, u32 size) {
gAudioContext.permanentCache[index].tableType = tableType;
gAudioContext.permanentCache[index].id = id;
gAudioContext.permanentCache[index].size = size;
+
//! @bug UB: missing return. "ret" is in v0 at this point, but doing an
// explicit return uses an additional register.
- // return ret;
+#ifdef AVOID_UB
+ return ret;
+#endif
}
void* AudioHeap_AllocSampleCache(u32 size, s32 fontId, void* sampleAddr, s8 medium, s32 cache) {
diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c
index 3571f0182..cdf4c0abe 100644
--- a/src/code/z_player_lib.c
+++ b/src/code/z_player_lib.c
@@ -655,6 +655,7 @@ u8 sEyeMouthIndexes[][2] = {
* shiftability, and changes will need to be made in the code to account for this in a modding scenario. The symbols
* from adult Link's object are used here.
*/
+#ifndef AVOID_UB
void* sEyeTextures[] = {
gLinkAdultEyesOpenTex, gLinkAdultEyesHalfTex, gLinkAdultEyesClosedfTex, gLinkAdultEyesRollLeftTex,
gLinkAdultEyesRollRightTex, gLinkAdultEyesShockTex, gLinkAdultEyesUnk1Tex, gLinkAdultEyesUnk2Tex,
@@ -666,6 +667,20 @@ void* sMouthTextures[] = {
gLinkAdultMouth3Tex,
gLinkAdultMouth4Tex,
};
+#else
+// Defining `AVOID_UB` will use a 2D array instead and properly use the child link pointers to allow for shifting.
+void* sEyeTextures[][8] = {
+ { gLinkAdultEyesOpenTex, gLinkAdultEyesHalfTex, gLinkAdultEyesClosedfTex, gLinkAdultEyesRollLeftTex,
+ gLinkAdultEyesRollRightTex, gLinkAdultEyesShockTex, gLinkAdultEyesUnk1Tex, gLinkAdultEyesUnk2Tex },
+ { gLinkChildEyesOpenTex, gLinkChildEyesHalfTex, gLinkChildEyesClosedfTex, gLinkChildEyesRollLeftTex,
+ gLinkChildEyesRollRightTex, gLinkChildEyesShockTex, gLinkChildEyesUnk1Tex, gLinkChildEyesUnk2Tex },
+};
+
+void* sMouthTextures[][4] = {
+ { gLinkAdultMouth1Tex, gLinkAdultMouth2Tex, gLinkAdultMouth3Tex, gLinkAdultMouth4Tex },
+ { gLinkChildMouth1Tex, gLinkChildMouth2Tex, gLinkChildMouth3Tex, gLinkChildMouth4Tex },
+};
+#endif
Color_RGB8 sTunicColors[] = {
{ 30, 105, 27 },
@@ -696,13 +711,21 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable,
eyeIndex = sEyeMouthIndexes[face][0];
}
+#ifndef AVOID_UB
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[eyeIndex]));
+#else
+ gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[gSaveContext.linkAge][eyeIndex]));
+#endif
if (mouthIndex < 0) {
mouthIndex = sEyeMouthIndexes[face][1];
}
+#ifndef AVOID_UB
gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[mouthIndex]));
+#else
+ gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[gSaveContext.linkAge][mouthIndex]));
+#endif
color = &sTunicColors[tunic];
gDPSetEnvColor(POLY_OPA_DISP++, color->r, color->g, color->b, 0);