Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable -Wint-conversion warning #1266

Merged
merged 62 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
4969e83
fixing some warnings
AngheloAlf Nov 17, 2022
f103844
more pointer fixing
AngheloAlf Nov 17, 2022
be427de
Use `-Wno-int-conversion` on audio files
AngheloAlf Nov 17, 2022
c6f2a0e
more progress
AngheloAlf Nov 18, 2022
4d96323
fix
AngheloAlf Nov 18, 2022
d6ce52b
more pointer fixes
AngheloAlf Nov 18, 2022
8c8cad7
kinda progress
AngheloAlf Nov 18, 2022
3b5f503
Fix remaining casts
AngheloAlf Nov 18, 2022
8e77c4a
Format
AngheloAlf Nov 18, 2022
7c566eb
fix merge
AngheloAlf Nov 21, 2022
ab64e54
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf May 26, 2023
f2e4c5c
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jun 1, 2023
f991415
fix warnings
AngheloAlf Jun 1, 2023
a258564
fix parameter
AngheloAlf Jun 1, 2023
d6c2dce
use SEGMENT_ROM_START_OFFSET a bit more
AngheloAlf Jun 1, 2023
b086cc7
format
AngheloAlf Jun 1, 2023
19d6dfa
fix audio warnings
AngheloAlf Jun 1, 2023
0657e70
some more fixes
AngheloAlf Jun 1, 2023
443b3c4
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jun 2, 2023
26237ce
fix en_go
AngheloAlf Jun 2, 2023
b25b01c
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jun 5, 2023
3ece9f5
review
AngheloAlf Jun 6, 2023
ca2f535
review
AngheloAlf Jun 6, 2023
f86069f
whoops, missing cast
AngheloAlf Jun 6, 2023
c49ad33
review
AngheloAlf Jun 6, 2023
bf613bc
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jun 10, 2023
dc1c186
review
AngheloAlf Jun 15, 2023
af9e263
->data
AngheloAlf Jun 15, 2023
7818d33
format
AngheloAlf Jun 15, 2023
d33eb83
review
AngheloAlf Jun 16, 2023
874e2e5
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jun 18, 2023
4004a04
fix
AngheloAlf Jun 18, 2023
e975181
asPtr
AngheloAlf Jun 18, 2023
c9dd22a
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jun 18, 2023
0c1fc99
fix
AngheloAlf Jun 18, 2023
f9e3f61
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jun 19, 2023
147acd2
Update src/code/sched.c
AngheloAlf Jun 19, 2023
76d7256
review
AngheloAlf Jun 20, 2023
3180426
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jun 23, 2023
2faa3ca
fix in EnDnh
AngheloAlf Jun 23, 2023
d76ea74
improve format
AngheloAlf Jun 24, 2023
c1ae29e
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jun 24, 2023
dd897f4
engo
AngheloAlf Jun 24, 2023
ad5ae53
format
AngheloAlf Jun 24, 2023
82a2f59
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jun 25, 2023
674b6a7
fix
AngheloAlf Jun 25, 2023
b9f983b
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jun 26, 2023
e88f040
format
AngheloAlf Jun 26, 2023
d51729a
Update include/z64.h
AngheloAlf Jul 4, 2023
51dede1
TexturePtr
AngheloAlf Jul 4, 2023
87a29db
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jul 8, 2023
7812d7e
fix warnings
AngheloAlf Jul 8, 2023
a0047e4
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Jul 27, 2023
d0808f1
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Aug 6, 2023
bb59adc
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Sep 14, 2023
86f5b68
Merge remote-tracking branch 'upstream/master' into int-conversion
AngheloAlf Sep 15, 2023
7daadeb
Merge remote-tracking branch 'upstream/main' into int-conversion
AngheloAlf Oct 9, 2023
e718227
fix warnings
AngheloAlf Oct 9, 2023
6d51251
format
AngheloAlf Oct 9, 2023
7d6c361
Merge remote-tracking branch 'upstream/main' into int-conversion
AngheloAlf Oct 26, 2023
6013f79
fix
AngheloAlf Oct 26, 2023
c5d27ee
review
AngheloAlf Oct 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ endif

# Check code syntax with host compiler
ifneq ($(RUN_CC_CHECK),0)
CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label -Wno-sign-compare -Wno-tautological-compare
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you also removed -Wno-format-security, what does that imply?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does nothing currently. https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wformat-security

It warns you for cases when you misuse printf/scanf functions, like passing a float when you have a %u

We could annotate some variadic functions that work similar to printf (with __attribute__ ((format (printf, 2, 3)))) but that's a out of scope for this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a confusing attribute. Yeah, don't think we need to worry about that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to link the docs about it
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Common-Function-Attributes.html#Common-Function-Attributes
I think it could actually be useful in the future

CHECK_WARNINGS := -Wall -Wextra -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-unused-but-set-variable -Wno-unused-label -Wno-sign-compare -Wno-tautological-compare
CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu89 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -nostdinc $(CHECK_WARNINGS)
AngheloAlf marked this conversation as resolved.
Show resolved Hide resolved
ifneq ($(WERROR), 0)
CC_CHECK += -Werror
Expand Down
6 changes: 3 additions & 3 deletions include/audiothread_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ typedef enum {
* @param sfxState
*/
#define AUDIOCMD_CHANNEL_SET_SFX_STATE(seqPlayerIndex, channelIndex, sfxState) \
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_SFX_STATE, seqPlayerIndex, channelIndex, 0), sfxState)
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_SFX_STATE, seqPlayerIndex, channelIndex, 0), (s32)sfxState)

/**
* Set the reverb index.
Expand Down Expand Up @@ -493,7 +493,7 @@ typedef enum {
* @param functionPtr
*/
#define AUDIOCMD_GLOBAL_SET_CUSTOM_FUNCTION(functionType, functionPtr) \
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_CUSTOM_FUNCTION, 0, 0, functionType), functionPtr)
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_CUSTOM_FUNCTION, 0, 0, functionType), (s32)functionPtr)

/**
* Do something related to the unloaded-type audio data in the heap.
Expand All @@ -514,7 +514,7 @@ typedef enum {
* @param data
*/
#define AUDIOCMD_GLOBAL_SET_REVERB_DATA(reverbIndex, dataType, data) \
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_REVERB_DATA, dataType, reverbIndex, 0), data)
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_REVERB_DATA, dataType, reverbIndex, 0), (s32)data)

/**
* Change the sound mode of audio
Expand Down
4 changes: 2 additions & 2 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ void Color_RGB8_Lerp(Color_RGB8* a, Color_RGB8* b, f32 t, Color_RGB8* dst);
void Lib_Nop801004FC(void);
void* Lib_SegmentedToVirtual(void* ptr);
void* Lib_SegmentedToVirtualNull(void* ptr);
void* Lib_VirtualToPhysical(void* ptr);
void* Lib_PhysicalToVirtual(void* ptr);
uintptr_t Lib_VirtualToPhysical(void* ptr);
void* Lib_PhysicalToVirtual(uintptr_t ptr);
void LifeMeter_Init(PlayState* play);
void LifeMeter_UpdateColors(PlayState* play);
s32 LifeMeter_SaveInterfaceHealth(PlayState* play);
Expand Down
4 changes: 2 additions & 2 deletions include/loadfragment.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef struct OverlayRelocationSection {
} OverlayRelocationSection; // size >= 0x18

// Fragment overlay load functions
size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart, uintptr_t vramEnd, void* allocatedRamAddr);
void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart, uintptr_t vramEnd);
size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* ramStart, void* ramEnd, void* allocatedRamAddr);
void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd);

#endif
2 changes: 1 addition & 1 deletion include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern s32 gScreenWidth;
extern s32 gScreenHeight;
extern size_t gSystemHeapSize;

extern u32 gSegments[NUM_SEGMENTS];
extern uintptr_t gSegments[NUM_SEGMENTS];
extern SchedContext gSchedContext;
extern OSThread gGraphThread;
extern PadMgr gPadMgr;
Expand Down
8 changes: 5 additions & 3 deletions include/segment_symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
#define SEGMENT_END(segment) (_ ## segment ## SegmentEnd)
#define SEGMENT_SIZE(segment) ((uintptr_t)SEGMENT_END(segment) - (uintptr_t)SEGMENT_START(segment))

#define SEGMENT_ROM_START(segment) (_ ## segment ## SegmentRomStart)
#define SEGMENT_ROM_END(segment) (_ ## segment ## SegmentRomEnd)
#define SEGMENT_ROM_SIZE(segment) ((uintptr_t)SEGMENT_ROM_END(segment) - (uintptr_t)SEGMENT_ROM_START(segment))
#define SEGMENT_ROM_START(segment) ((uintptr_t) _ ## segment ## SegmentRomStart)
#define SEGMENT_ROM_START_OFFSET(segment, offset) ((uintptr_t) (( _ ## segment ## SegmentRomStart ) + (offset)))
#define SEGMENT_ROM_END(segment) ((uintptr_t) _ ## segment ## SegmentRomEnd)
#define SEGMENT_ROM_SIZE(segment) (SEGMENT_ROM_END(segment) - SEGMENT_ROM_START(segment))
#define SEGMENT_ROM_SIZE_ALT(segment) ((size_t)( _ ## segment ## SegmentRomEnd - _ ## segment ## SegmentRomStart ))

#define SEGMENT_BSS_START(segment) (_ ## segment ## SegmentBssStart)
#define SEGMENT_BSS_END(segment) (_ ## segment ## SegmentBssEnd)
Expand Down
2 changes: 1 addition & 1 deletion include/sys_flashrom.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

typedef struct {
/* 0x00 */ s32 requestType;
/* 0x04 */ OSMesg response;
/* 0x04 */ s32 response;
/* 0x08 */ void* addr;
/* 0x0C */ s32 pageNum;
/* 0x10 */ s32 pageCount;
Expand Down
3 changes: 2 additions & 1 deletion include/tha.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "ultra64.h"
#include "libc/stdint.h"
#include "libc/stddef.h"

typedef struct TwoHeadArena {
/* 0x0 */ size_t size;
Expand All @@ -19,7 +20,7 @@ void* THA_AllocHeadByte(TwoHeadArena* tha);
void* THA_AllocTail(TwoHeadArena* tha, size_t size);
void* THA_AllocTailAlign16(TwoHeadArena* tha, size_t size);
void* THA_AllocTailAlign(TwoHeadArena* tha, size_t size, uintptr_t mask);
s32 THA_GetRemaining(TwoHeadArena* tha);
ptrdiff_t THA_GetRemaining(TwoHeadArena* tha);
u32 THA_IsCrash(TwoHeadArena* tha);
void THA_Reset(TwoHeadArena* tha);
void THA_Init(TwoHeadArena* tha, void* start, size_t size);
Expand Down
3 changes: 2 additions & 1 deletion include/z64audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ typedef struct {
/* 0x4 */ s8 asSbyte;
/* 0x4 */ u8 asUbyte;
/* 0x4 */ u32 asUInt;
/* 0x4 */ void* asPtr;
};
} AudioCmd; // size = 0x8

Expand Down Expand Up @@ -931,7 +932,7 @@ typedef struct {

typedef void (*AudioCustomUpdateFunction)(void);
typedef u32 (*AudioCustomSeqFunction)(s8 value, SequenceChannel* channel);
typedef s32 (*AudioCustomReverbFunction)(Sample*, s32, s8, s32);
typedef void* (*AudioCustomReverbFunction)(Sample*, s32, s8, s32);
typedef Acmd* (*AudioCustomSynthFunction)(Acmd*, s32, s32);

extern OSVoiceHandle gVoiceHandle;
Expand Down
4 changes: 2 additions & 2 deletions include/z64message.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ typedef struct {
u16 wchar[640]; // msgBufWide
u64 force_structure_alignment_msg;
} msgBuf;
/* 0x11D80 */ u32 messageStart;
/* 0x11D84 */ u32 messageEnd;
/* 0x11D80 */ uintptr_t messageStart;
/* 0x11D84 */ uintptr_t messageEnd;
/* 0x11D88 */ u8 unk_11D88; // current Char Buffer ?
} Font; // size = 0x11D90

Expand Down
2 changes: 1 addition & 1 deletion src/audio/lib/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) {

sampleBankTable = gAudioCtx.sampleBankTable;
numFonts = gAudioCtx.soundFontTable->numEntries;
change.oldAddr = AudioHeap_SearchCaches(SAMPLE_TABLE, CACHE_EITHER, sampleBankId);
change.oldAddr = (uintptr_t)AudioHeap_SearchCaches(SAMPLE_TABLE, CACHE_EITHER, sampleBankId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I defer to @engineer124 on all the audio stuff in here, most of these structs are quite deep.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admittedly, low level audio does a lot of weird pointer manipulation with offsets and indexing when both transferring audio assets from rom to ram (sequences/soundfonts/samples), and even more weird pointer/offset math when extracting meaningful information from it (especially soundfonts, that's really messy when it comes to pointers).

Given that, I think I'd need to sit down and summarize all the pointer math involved in audio and share that to figure out what kind of types we need. That would take time though, so for now I think I'm fine with just making sure it's consistent i.e. warning free?

if (change.oldAddr == 0) {
return;
}
Expand Down
44 changes: 22 additions & 22 deletions src/audio/lib/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef struct {
void AudioLoad_DiscardFont(s32 fontId);
s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIndex, s32 seqId, s32 arg2);
u8* AudioLoad_SyncLoadSeq(s32 seqId);
u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad);
uintptr_t AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad);
SoundFontData* AudioLoad_SyncLoadFont(u32 fontId);
void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate);
u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id);
Expand Down Expand Up @@ -414,7 +414,7 @@ void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3
AudioLoad_SyncLoadSeq(seqId);
}
if (arg2 != 0) {
osSendMesg(arg3, arg2 << 0x18, OS_MESG_NOBLOCK);
osSendMesg(arg3, (OSMesg)(arg2 << 0x18), OS_MESG_NOBLOCK);
}
}
}
Expand All @@ -431,10 +431,10 @@ s32 AudioLoad_SyncLoadSample(Sample* sample, s32 fontId) {
}

if (sample->medium == MEDIUM_UNK) {
AudioLoad_SyncDmaUnkMedium(sample->sampleAddr, sampleAddr, sample->size,
AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, sampleAddr, sample->size,
gAudioCtx.sampleBankTable->unkMediumParam);
} else {
AudioLoad_SyncDma(sample->sampleAddr, sampleAddr, sample->size, sample->medium);
AudioLoad_SyncDma((uintptr_t)sample->sampleAddr, sampleAddr, sample->size, sample->medium);
}
sample->medium = MEDIUM_RAM;
sample->sampleAddr = sampleAddr;
Expand Down Expand Up @@ -471,7 +471,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) {

void AudioLoad_AsyncLoad(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) {
if (AudioLoad_AsyncLoadInner(tableType, id, nChunks, retData, retQueue) == NULL) {
osSendMesg(retQueue, 0xFFFFFFFF, OS_MESG_NOBLOCK);
osSendMesg(retQueue, (OSMesg)0xFFFFFFFF, OS_MESG_NOBLOCK);
}
}

Expand Down Expand Up @@ -632,11 +632,11 @@ u8* AudioLoad_SyncLoadSeq(s32 seqId) {
return AudioLoad_SyncLoad(SEQUENCE_TABLE, seqId, &didAllocate);
}

u32 AudioLoad_GetSampleBank(u32 sampleBankId, u32* outMedium) {
uintptr_t AudioLoad_GetSampleBank(u32 sampleBankId, u32* outMedium) {
return AudioLoad_TrySyncLoadSampleBank(sampleBankId, outMedium, true);
}

u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad) {
uintptr_t AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad) {
void* addr;
AudioTable* sampleBankTable;
u32 realTableId = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId);
Expand All @@ -651,7 +651,7 @@ u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad
}

*outMedium = MEDIUM_RAM;
return addr;
return (uintptr_t)addr;
}

cachePolicy = sampleBankTable->entries[sampleBankId].cachePolicy;
Expand All @@ -664,7 +664,7 @@ u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad
addr = AudioLoad_SyncLoad(SAMPLE_TABLE, sampleBankId, &noLoad);
if (addr != NULL) {
*outMedium = MEDIUM_RAM;
return addr;
return (uintptr_t)addr;
}

*outMedium = sampleBankTable->entries[sampleBankId].medium;
Expand Down Expand Up @@ -785,7 +785,7 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) {
size -= 0x10;
}

bcopy(romAddr, ramAddr, size);
bcopy((void*)romAddr, ramAddr, size);
} else if (medium2 == mediumUnk) {
AudioLoad_SyncDmaUnkMedium(romAddr, ramAddr, size, (s16)table->unkMediumParam);
} else {
Expand Down Expand Up @@ -867,7 +867,7 @@ AudioTable* AudioLoad_GetLoadTable(s32 tableType) {
* @param sampleBankReloc information on the sampleBank containing raw audio samples
*/
void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, SampleBankRelocInfo* sampleBankReloc) {
uintptr_t soundOffset;
void* soundOffset;
uintptr_t soundListOffset;
Instrument* inst;
Drum* drum;
Expand All @@ -876,7 +876,7 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample
s32 numDrums = gAudioCtx.soundFontList[fontId].numDrums;
s32 numInstruments = gAudioCtx.soundFontList[fontId].numInstruments;
s32 numSfx = gAudioCtx.soundFontList[fontId].numSfx;
u32* fontData = (u32*)fontDataStartAddr;
uintptr_t* fontData = (uintptr_t*)fontDataStartAddr;

// Relocate an offset (relative to the start of the font data) to a pointer (a ram address)
#define RELOC_TO_RAM(x) (void*)((uintptr_t)(x) + (uintptr_t)(fontDataStartAddr))
Expand All @@ -889,15 +889,15 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample
// If the soundFont has drums
if ((soundListOffset != 0) && (numDrums != 0)) {

fontData[0] = RELOC_TO_RAM(soundListOffset);
fontData[0] = (uintptr_t)RELOC_TO_RAM(soundListOffset);

// Loop through the drum offsets
for (i = 0; i < numDrums; i++) {
// Get the i'th drum offset
soundOffset = ((Drum**)fontData[0])[i];

// Some drum data entries are empty, represented by an offset of 0 in the list of drum offsets
if (soundOffset == 0) {
if (soundOffset == NULL) {
continue;
}
soundOffset = RELOC_TO_RAM(soundOffset);
Expand Down Expand Up @@ -925,7 +925,7 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample
// If the soundFont has sound effects
if ((soundListOffset != 0) && (numSfx != 0)) {

fontData[1] = RELOC_TO_RAM(soundListOffset);
fontData[1] = (uintptr_t)RELOC_TO_RAM(soundListOffset);

// Loop through the sound effects
for (i = 0; i < numSfx; i++) {
Expand Down Expand Up @@ -955,7 +955,7 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample
for (i = 2; i <= 2 + numInstruments - 1; i++) {
// Some instrument data entries are empty, represented by an offset of 0 in the list of instrument offsets
if (fontData[i] != 0) {
fontData[i] = RELOC_TO_RAM(fontData[i]);
fontData[i] = (uintptr_t)RELOC_TO_RAM(fontData[i]);
inst = (Instrument*)fontData[i];

// The instrument may be in the list multiple times and already relocated
Expand Down Expand Up @@ -1097,7 +1097,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
ramAddr = AudioLoad_SearchCaches(tableType, realId);
if (ramAddr != NULL) {
loadStatus = LOAD_STATUS_COMPLETE;
osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_NOT_LOADED), OS_MESG_NOBLOCK);
osSendMesg(retQueue, (OSMesg)MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_NOT_LOADED), OS_MESG_NOBLOCK);
} else {
table = AudioLoad_GetLoadTable(tableType);
size = table->entries[realId].size;
Expand Down Expand Up @@ -1376,7 +1376,7 @@ s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) {
slowLoad->status = LOAD_STATUS_START;
slowLoad->bytesRemaining = ALIGN16(sample->size);
slowLoad->ramAddr = slowLoad->curRamAddr;
slowLoad->curDevAddr = sample->sampleAddr;
slowLoad->curDevAddr = (uintptr_t)sample->sampleAddr;
slowLoad->medium = sample->medium;
slowLoad->seqOrFontId = fontId;
slowLoad->instId = instId;
Expand Down Expand Up @@ -1464,15 +1464,15 @@ void AudioLoad_ProcessSlowLoads(s32 resetStatus) {
if (slowLoad->medium == MEDIUM_UNK) {
size_t size = slowLoad->bytesRemaining;

AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, slowLoad->curRamAddr, size,
AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, (uintptr_t)slowLoad->curRamAddr, size,
slowLoad->unkMediumParam);
} else {
AudioLoad_DmaSlowCopy(slowLoad, slowLoad->bytesRemaining);
}
slowLoad->bytesRemaining = 0;
} else {
if (slowLoad->medium == MEDIUM_UNK) {
AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, slowLoad->curRamAddr, 0x400,
AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, (uintptr_t)slowLoad->curRamAddr, 0x400,
slowLoad->unkMediumParam);
} else {
AudioLoad_DmaSlowCopy(slowLoad, 0x400);
Expand Down Expand Up @@ -1671,7 +1671,7 @@ void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) {
break;
}

doneMsg = asyncLoad->retMsg;
doneMsg = (OSMesg)asyncLoad->retMsg;
if (1) {}
asyncLoad->status = LOAD_STATUS_WAITING;
osSendMesg(asyncLoad->retQueue, doneMsg, OS_MESG_NOBLOCK);
Expand Down Expand Up @@ -1743,7 +1743,7 @@ void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size) {
size = ALIGN16(size);
Audio_InvalDCache(asyncLoad->curRamAddr, size);
osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1);
bcopy(asyncLoad->curDevAddr, asyncLoad->curRamAddr, size);
bcopy((void*)asyncLoad->curDevAddr, asyncLoad->curRamAddr, size);
osSendMesg(&asyncLoad->msgQueue, NULL, OS_MESG_NOBLOCK);
}

Expand Down
18 changes: 9 additions & 9 deletions src/audio/lib/synthesis.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,12 @@ Acmd* AudioSynth_SaveResampledReverbSamples(Acmd* cmd, SynthesisReverb* reverb,
aResample(cmd++, reverb->resampleFlags, entry->saveResamplePitch, reverb->leftSaveResampleBuf);

cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_SCRATCH, entry->size,
&reverb->leftReverbBuf[entry->startPos]);
(uintptr_t)&reverb->leftReverbBuf[entry->startPos]);

if (entry->wrappedSize != 0) {
// Ring buffer wrapped
cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_SCRATCH, entry->wrappedSize,
reverb->leftReverbBuf);
(uintptr_t)reverb->leftReverbBuf);
}

// Right Resample
Expand All @@ -514,12 +514,12 @@ Acmd* AudioSynth_SaveResampledReverbSamples(Acmd* cmd, SynthesisReverb* reverb,
aResample(cmd++, reverb->resampleFlags, entry->saveResamplePitch, reverb->rightSaveResampleBuf);

cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_SCRATCH, entry->size,
&reverb->rightReverbBuf[entry->startPos]);
(uintptr_t)&reverb->rightReverbBuf[entry->startPos]);

if (entry->wrappedSize != 0) {
// Ring buffer wrapped
cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_SCRATCH, entry->wrappedSize,
reverb->rightReverbBuf);
(uintptr_t)reverb->rightReverbBuf);
}

return cmd;
Expand Down Expand Up @@ -716,16 +716,16 @@ Acmd* AudioSynth_SaveReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updat

if (entry->size != 0) {
cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, entry->size,
&reverb->leftReverbBuf[entry->startPos]);
(uintptr_t)&reverb->leftReverbBuf[entry->startPos]);
cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_RIGHT_CH, entry->size,
&reverb->rightReverbBuf[entry->startPos]);
(uintptr_t)&reverb->rightReverbBuf[entry->startPos]);
}

if (entry->wrappedSize != 0) {
cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_LEFT_CH, entry->wrappedSize,
reverb->leftReverbBuf);
(uintptr_t)reverb->leftReverbBuf);
cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_RIGHT_CH, entry->wrappedSize,
reverb->rightReverbBuf);
(uintptr_t)reverb->rightReverbBuf);
}
}

Expand Down Expand Up @@ -1170,7 +1170,7 @@ Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, Note
} else {
// This medium is not in ram, so dma the requested sample into ram
samplesToLoadAddr =
AudioLoad_DmaSampleData(sampleAddr + (zeroOffset + sampleAddrOffset),
AudioLoad_DmaSampleData((uintptr_t)(sampleAddr + (zeroOffset + sampleAddrOffset)),
ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME), flags,
&synthState->sampleDmaIndex, sample->medium);
}
Expand Down
Loading