summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorDragorn421 <Dragorn421@users.noreply.github.com>2023-11-12 22:59:52 +0100
committerGitHub <noreply@github.com>2023-11-12 16:59:52 -0500
commit4c75260097135edb171501942e451474fce66c50 (patch)
tree5ecafffc7ee1eb140504bdb745329a3c8f9cfa83 /src/code
parentdc323052c36959e7221a927c094053e279334f41 (diff)
Fix misc 21 (#1573)
* Make `sNew` in (unused) `code_800FC620.c` a string It is passed as a filename to `__osMallocDebug` so should be a nul-terminated string, not a char[3] missing an explicit \0 * Fix gcc warning in `JpegDecoder_ParseNextSymbol` about SLL on negative value -1U is an unsigned value, aka 0xFFFFFFFF I keep -1 because it seems that's what a jpeg standard has too References: https://stackoverflow.com/questions/40508958/shifting-a-negative-signed-value-is-undefined https://www.w3.org/Graphics/JPEG/itu-t81.pdf (page 105, figure F.12) * Small cleanup * Fix few mistakes (thanks gcc warnings) * Add `@bug` in file select settings draw code, using the wrong array * format * format main * rename arg for a happy formatter * Move important function call out of a printf
Diffstat (limited to 'src/code')
-rw-r--r--src/code/code_800FC620.c4
-rw-r--r--src/code/jpegdecoder.c2
-rw-r--r--src/code/z_play.c5
-rw-r--r--src/code/z_player_lib.c2
4 files changed, 8 insertions, 5 deletions
diff --git a/src/code/code_800FC620.c b/src/code/code_800FC620.c
index d31d028a9..deca11a4f 100644
--- a/src/code/code_800FC620.c
+++ b/src/code/code_800FC620.c
@@ -13,7 +13,7 @@ typedef struct InitFunc {
// .data
void* sInitFuncs = NULL;
-char sNew[] = { 'n', 'e', 'w' };
+char sNew[] = "new";
char D_80134488[0x18] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00,
@@ -100,7 +100,7 @@ void func_800FCB34(void) {
initFunc = (InitFunc*)((s32)initFunc + nextOffset);
if (initFunc->func != NULL) {
- (*initFunc->func)();
+ initFunc->func();
}
nextOffset = initFunc->nextOffset;
diff --git a/src/code/jpegdecoder.c b/src/code/jpegdecoder.c
index 3301817d0..c0c772abd 100644
--- a/src/code/jpegdecoder.c
+++ b/src/code/jpegdecoder.c
@@ -154,7 +154,7 @@ s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, s8* out
if (sym) {
*outCoeff = JpegDecoder_ReadBits(sym);
if (*outCoeff < (1 << (sym - 1))) {
- *outCoeff += (-1 << sym) + 1;
+ *outCoeff += (-1U << sym) + 1;
}
}
diff --git a/src/code/z_play.c b/src/code/z_play.c
index 58fa9f726..b71a60564 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -1447,6 +1447,7 @@ void Play_InitScene(PlayState* this, s32 spawn) {
void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn) {
SceneTableEntry* scene = &gSceneTable[sceneId];
+ u32 size;
scene->unk_13 = 0;
this->loadedScene = scene;
@@ -1463,7 +1464,9 @@ void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn) {
Play_InitScene(this, spawn);
- osSyncPrintf("ROOM SIZE=%fK\n", func_80096FE8(this, &this->roomCtx) / 1024.0f);
+ size = func_80096FE8(this, &this->roomCtx);
+
+ osSyncPrintf("ROOM SIZE=%fK\n", size / 1024.0f);
}
void Play_GetScreenPos(PlayState* this, Vec3f* src, Vec3f* dest) {
diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c
index 39a56c545..6c12331d5 100644
--- a/src/code/z_player_lib.c
+++ b/src/code/z_player_lib.c
@@ -1061,7 +1061,7 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx**
// Note: The increment would not be done for the root limb, even if it had a non-NULL `dList`.
// So if the root limb had a non-NULL `dList` (which is not the case in vanilla),
// an out-of-bounds write to `bodyPartsPos` would occur.
- sCurBodyPartPos = &this->bodyPartsPos[-1];
+ sCurBodyPartPos = &this->bodyPartsPos[0] - 1;
if (!LINK_IS_ADULT) {
if (!(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_2) || (this->skelAnime.moveFlags & ANIM_FLAG_0)) {