From 8bb988675de8606bf5bbf64ae543796f54c57c55 Mon Sep 17 00:00:00 2001
From: KiritoDev <36680385+KiritoDv@users.noreply.github.com>
Date: Sun, 15 May 2022 19:39:46 -0500
Subject: [PATCH 1/4] Fixed soh filters
---
soh/soh.vcxproj.filters | 800 +++++-----------------------------------
1 file changed, 94 insertions(+), 706 deletions(-)
diff --git a/soh/soh.vcxproj.filters b/soh/soh.vcxproj.filters
index b6af70eb9..10ac7845c 100644
--- a/soh/soh.vcxproj.filters
+++ b/soh/soh.vcxproj.filters
@@ -1,710 +1,87 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+ {8d479b58-9306-40c3-9728-2cf5b185f5c4}
+
+
+ {8ebc52ba-5b1d-4bb3-9848-ba9ea57fc49f}
+
+
+ {54c2fe99-a68e-4ce2-813d-bce0ab1ac24f}
+
+
+ {0b91ecc8-6f20-4da1-87ca-6c7263aab3db}
+
+
+ {2104d3ab-707c-4ab2-bb1a-5cdce5c3d07d}
+
+
+ {022552c8-3bb8-4ba5-904c-e2c3eb28ce10}
+
+
+ {3ab8c311-cbfb-4eca-88af-2446ce3c89b0}
+
+
+ {8f2da1b8-973e-4be0-a036-c79a63bc3067}
+
+
+ {1a584bc2-7081-4251-a953-cdc7b611d62b}
+
+
+ {49bb84e4-a0b9-4733-9720-1ea120795083}
+
+
+ {d4794b4c-ae5d-4bf0-96f4-077f03807f5e}
+
+
+ {981df102-b362-4e2b-8efc-62756c28aa60}
+
+
+ {f8b2165f-9b32-4be1-a285-49349e09bef5}
+
+
+ {fcaae731-4e17-448b-b6c7-36e4c8413838}
+
+
+ {264ed8f8-f42b-475f-82ca-c264225ef56c}
+
+
+ {5fde6633-a728-4eea-a616-59d413bec476}
+
+
+ {3aeae6ac-1340-4a7b-bf34-cd196667fe37}
+
+
+ {fe745190-d4ec-4dc3-a9fd-ea553a971b14}
+
+
+ {06ba0ec4-2ee7-4454-93b5-5fd804723b6d}
+
+
+ {ffe200b9-a955-4843-a1ce-3603c132e591}
+
+
+ {18b9727f-30de-4ab8-a317-916090d4a110}
+
+
+ {9a4378ec-e30f-47b6-9ad6-5ce738b4cf99}
+
+
+ {04fc1c52-49ff-48e2-ae23-2c00867374f8}
+
@@ -2809,6 +2186,7 @@
Source Files\soh\Enhancements\debugger
+
Source Files\soh
@@ -4373,6 +3751,7 @@
Header Files\soh\Enhancements\debugger
+
Header Files\soh
@@ -4384,9 +3763,18 @@
-
+
+ Header Files\include
+
-
+
+ Resource Files
+
+
+
+
+ Resource Files
+
\ No newline at end of file
From 7a4da43d7bafc80eb51634705cc87063a663350d Mon Sep 17 00:00:00 2001
From: Kenix
Date: Mon, 16 May 2022 20:16:56 -0400
Subject: [PATCH 2/4] Audio code converted to uintptr_t
---
soh/include/functions.h | 6 +-
soh/include/z64audio.h | 20 +++---
soh/src/code/audio_heap.c | 12 ++--
soh/src/code/audio_load.c | 114 +++++++++++++++++----------------
soh/src/code/audio_synthesis.c | 10 +--
soh/src/code/code_800E4FE0.c | 1 -
soh/src/code/main.c | 4 +-
7 files changed, 86 insertions(+), 81 deletions(-)
diff --git a/soh/include/functions.h b/soh/include/functions.h
index 0b32e4cdd..92831b138 100644
--- a/soh/include/functions.h
+++ b/soh/include/functions.h
@@ -1909,7 +1909,7 @@ void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* mem, size_t size);
void AudioHeap_PersistentCacheClear(AudioPersistentCache* persistent);
void AudioHeap_TemporaryCacheClear(AudioTemporaryCache* temporary);
void AudioHeap_PopCache(s32 tableType);
-void AudioHeap_InitMainPools(ptrdiff_t sizeForAudioInitPool);
+void AudioHeap_InitMainPools(size_t sizeForAudioInitPool);
void* AudioHeap_AllocCached(s32 tableType, ptrdiff_t size, s32 cache, s32 id);
void* AudioHeap_SearchCaches(s32 tableType, s32 arg1, s32 id);
void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id);
@@ -1921,7 +1921,7 @@ void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size);
void* AudioHeap_AllocSampleCache(size_t size, s32 fontId, void* sampleAddr, s8 medium, s32 cache);
void AudioHeap_ApplySampleBankCache(s32 sampleBankId);
void AudioLoad_DecreaseSampleDmaTtls(void);
-void* AudioLoad_DmaSampleData(u32 devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium);
+uintptr_t AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium);
void AudioLoad_InitSampleDmaBuffers(s32 arg0);
s32 AudioLoad_IsFontLoadComplete(s32 fontId);
s32 AudioLoad_IsSeqLoadComplete(s32 seqId);
@@ -1938,7 +1938,7 @@ s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2);
s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 arg2);
void AudioLoad_ProcessLoads(s32 resetStatus);
void AudioLoad_SetDmaHandler(DmaHandler callback);
-void AudioLoad_Init(void* heap, u32 heapSize);
+void AudioLoad_Init(void* heap, size_t heapSize);
void AudioLoad_InitSlowLoads(void);
s32 AudioLoad_SlowLoadSample(s32 arg0, s32 arg1, s8* arg2);
s32 AudioLoad_SlowLoadSeq(s32 playerIdx, u8* ramAddr, s8* arg2);
diff --git a/soh/include/z64audio.h b/soh/include/z64audio.h
index 78f262dbf..d5ed00678 100644
--- a/soh/include/z64audio.h
+++ b/soh/include/z64audio.h
@@ -107,8 +107,8 @@ typedef struct {
} AdsrEnvelope; // size = 0x4
typedef struct {
- /* 0x00 */ u32 start;
- /* 0x04 */ u32 end;
+ /* 0x00 */ uintptr_t start;
+ /* 0x04 */ uintptr_t end;
/* 0x08 */ u32 count;
/* 0x0C */ char unk_0C[0x4];
/* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned
@@ -712,10 +712,10 @@ typedef struct {
/* 0x01 */ s8 delay;
/* 0x02 */ s8 medium;
/* 0x04 */ u8* ramAddr;
- /* 0x08 */ u32 curDevAddr;
+ /* 0x08 */ u8* curDevAddr;
/* 0x0C */ u8* curRamAddr;
- /* 0x10 */ u32 bytesRemaining;
- /* 0x14 */ u32 chunkSize;
+ /* 0x10 */ size_t bytesRemaining;
+ /* 0x14 */ size_t chunkSize;
/* 0x18 */ s32 unkMediumParam;
/* 0x1C */ u32 retMsg;
/* 0x20 */ OSMesgQueue* retQueue;
@@ -729,7 +729,7 @@ typedef struct {
/* 0x01 */ u8 seqOrFontId;
/* 0x02 */ u16 instId;
/* 0x04 */ s32 unkMediumParam;
- /* 0x08 */ s32 curDevAddr;
+ /* 0x08 */ u8* curDevAddr;
/* 0x0C */ u8* curRamAddr;
/* 0x10 */ u8* ramAddr;
/* 0x14 */ s32 status;
@@ -878,7 +878,7 @@ typedef struct {
/* 0x351C */ s32 audioResetFadeOutFramesLeft;
/* 0x3520 */ f32* unk_3520;
/* 0x3524 */ u8* audioHeap;
- /* 0x3528 */ u32 audioHeapSize;
+ /* 0x3528 */ size_t audioHeapSize;
/* 0x352C */ Note* notes;
/* 0x3530 */ SequencePlayer seqPlayers[4];
/* 0x3AB0 */ SequenceLayer sequenceLayers[64];
@@ -916,9 +916,9 @@ typedef struct {
} NoteSubAttributes; // size = 0x18
typedef struct {
- /* 0x00 */ u32 heapSize;
- /* 0x04 */ u32 initPoolSize;
- /* 0x08 */ u32 permanentPoolSize;
+ /* 0x00 */ size_t heapSize;
+ /* 0x04 */ size_t initPoolSize;
+ /* 0x08 */ size_t permanentPoolSize;
} AudioContextInitSizes; // size = 0xC
typedef struct {
diff --git a/soh/src/code/audio_heap.c b/soh/src/code/audio_heap.c
index 765fd8b09..9e73ac570 100644
--- a/soh/src/code/audio_heap.c
+++ b/soh/src/code/audio_heap.c
@@ -249,7 +249,7 @@ void AudioHeap_PopCache(s32 tableType) {
persistent->numEntries--;
}
-void AudioHeap_InitMainPools(ptrdiff_t initPoolSize) {
+void AudioHeap_InitMainPools(size_t initPoolSize) {
AudioHeap_AllocPoolInit(&gAudioContext.audioInitPool, gAudioContext.audioHeap, initPoolSize);
AudioHeap_AllocPoolInit(&gAudioContext.audioSessionPool, gAudioContext.audioHeap + initPoolSize,
gAudioContext.audioHeapSize - initPoolSize);
@@ -1266,18 +1266,18 @@ void AudioHeap_DiscardSampleCaches(void) {
}
typedef struct {
- u32 oldAddr;
- u32 newAddr;
+ uintptr_t oldAddr;
+ uintptr_t newAddr;
size_t size;
u8 newMedium;
} StorageChange;
void AudioHeap_ChangeStorage(StorageChange* change, SoundFontSample* sample) {
if (sample != NULL) {
- u32 start = change->oldAddr;
- u32 end = change->oldAddr + change->size;
+ uintptr_t start = change->oldAddr;
+ uintptr_t end = change->oldAddr + change->size;
- if (start <= (u32)sample->sampleAddr && (u32)sample->sampleAddr < end) {
+ if (start <= sample->sampleAddr && sample->sampleAddr < end) {
sample->sampleAddr = sample->sampleAddr - start + change->newAddr;
sample->medium = change->newMedium;
}
diff --git a/soh/src/code/audio_load.c b/soh/src/code/audio_load.c
index 7af9037a6..fee03e9ae 100644
--- a/soh/src/code/audio_load.c
+++ b/soh/src/code/audio_load.c
@@ -20,8 +20,8 @@ typedef enum {
typedef struct {
/* 0x00 */ s32 sampleBankId1;
/* 0x04 */ s32 sampleBankId2;
- /* 0x08 */ s32 baseAddr1;
- /* 0x0C */ s32 baseAddr2;
+ /* 0x08 */ intptr_t baseAddr1;
+ /* 0x0C */ intptr_t baseAddr2;
/* 0x10 */ u32 medium1;
/* 0x14 */ u32 medium2;
} RelocInfo; // size = 0x18
@@ -39,27 +39,28 @@ void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus);
void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo, s32 temporary);
void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocInfo* relocInfo);
void AudioLoad_DiscardFont(s32 fontId);
-u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad);
-void* AudioLoad_SyncLoad(u32 tableType, u32 tableId, s32* didAllocate);
-u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 tableId);
+uintptr_t AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad);
+uintptr_t AudioLoad_SyncLoad(u32 tableType, u32 tableId, s32* didAllocate);
+uintptr_t AudioLoad_GetRealTableIndex(s32 tableType, u32 tableId);
void* AudioLoad_SearchCaches(s32 tableType, s32 id);
AudioTable* AudioLoad_GetLoadTable(s32 tableType);
-void AudioLoad_SyncDma(u32 devAddr, u8* addr, size_t size, s32 medium);
-void AudioLoad_SyncDmaUnkMedium(u32 devAddr, u8* addr, size_t size, s32 unkMediumParam);
-s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, u32 devAddr, void* ramAddr, size_t size,
+void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium);
+void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* addr, size_t size, s32 unkMediumParam);
+s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, uintptr_t ramAddr, size_t size,
OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType);
void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue);
-AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, u32 devAddr, void* ramAddr, ptrdiff_t size, s32 medium,
+AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, uintptr_t devAddr, uintptr_t ramAddr,
+ ptrdiff_t size, s32 medium,
s32 nChunks, OSMesgQueue* retQueue, s32 retMsg);
-AudioAsyncLoad* AudioLoad_StartAsyncLoad(u32 devAddr, void* ramAddr, size_t size, s32 medium, s32 nChunks,
+AudioAsyncLoad* AudioLoad_StartAsyncLoad(u32 devAddr, uintptr_t ramAddr, size_t size, s32 medium, s32 nChunks,
OSMesgQueue* retQueue, s32 retMsg);
void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, size_t size);
-void AudioLoad_AsyncDmaUnkMedium(u32 devAddr, void* ramAddr, size_t size, s16 arg3);
+void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, uintptr_t ramAddr, size_t size, s16 arg3);
u8* AudioLoad_SyncLoadSeq(s32 seqId);
s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus);
-void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, ptrdiff_t size);
+void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, size_t size);
void AudioLoad_ProcessSlowLoads(s32 resetStatus);
-void AudioLoad_DmaSlowCopyUnkMedium(s32 devAddr, u8* ramAddr, ptrdiff_t size, s32 arg3);
+void AudioLoad_DmaSlowCopyUnkMedium(uintptr_t devAddr, uintptr_t ramAddr, size_t size, s32 arg3);
OSMesgQueue sScriptLoadQueue;
OSMesg sScriptLoadMesgBuf[0x10];
@@ -106,11 +107,11 @@ void AudioLoad_DecreaseSampleDmaTtls(void) {
gAudioContext.unused2628 = 0;
}
-void* AudioLoad_DmaSampleData(u32 devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium) {
+uintptr_t AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium) {
s32 pad1;
SampleDma* dma;
s32 hasDma = false;
- u32 dmaDevAddr;
+ uintptr_t dmaDevAddr;
u32 pad2;
u32 dmaIndex;
u32 transfer;
@@ -525,6 +526,8 @@ s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2) {
// call matches but is UB because it too is missing a return, and using the
// result of a non-void function that has failed to return a value is UB.
// The callers of this function do not use the return value, so it's fine.
+
+ return 1;
}
s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks) {
@@ -535,6 +538,8 @@ s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks
gAudioContext.seqPlayers[playerIdx].skipTicks = skipTicks;
AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, 0);
// Missing return, see above.
+
+ return 1;
}
s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) {
@@ -590,12 +595,12 @@ 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) {
- void* ret;
+uintptr_t AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad) {
+ uintptr_t ret;
AudioTable* sampleBankTable;
u32 realTableId = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId);
s8 cachePolicy;
@@ -665,7 +670,7 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) {
return ret;
}
-void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
+uintptr_t AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
size_t size;
AudioTable* table;
s32 pad;
@@ -673,7 +678,7 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
s32 status;
uintptr_t romAddr;
s32 cachePolicy;
- void* ret;
+ uintptr_t ret;
u32 realId;
realId = AudioLoad_GetRealTableIndex(tableType, id);
@@ -743,7 +748,7 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
return ret;
}
-u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id) {
+uintptr_t AudioLoad_GetRealTableIndex(s32 tableType, u32 id) {
AudioTable* table = AudioLoad_GetLoadTable(tableType);
if (table->entries[id].size == 0) {
@@ -790,8 +795,8 @@ AudioTable* AudioLoad_GetLoadTable(s32 tableType) {
}
void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo) {
- u32 reloc;
- u32 reloc2;
+ uintptr_t reloc;
+ uintptr_t reloc2;
Instrument* inst;
Drum* drum;
SoundFontSound* sfx;
@@ -801,7 +806,7 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
s32 numSfx = gAudioContext.soundFonts[fontId].numSfx;
void** ptrs = (void**)mem;
-#define BASE_OFFSET(x) (void*)((u32)(x) + (u32)(mem))
+#define BASE_OFFSET(x) (uintptr_t)((uintptr_t)(x) + (uintptr_t)(mem))
reloc2 = ptrs[0];
if (1) {}
@@ -871,7 +876,7 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo
gAudioContext.soundFonts[fontId].instruments = (Instrument**)(ptrs + 2);
}
-void AudioLoad_SyncDma(u32 devAddr, u8* addr, size_t size, s32 medium) {
+void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium) {
OSMesgQueue* msgQueue = &gAudioContext.syncDmaQueue;
OSIoMesg* ioMesg = &gAudioContext.syncDmaIoMesg;
size = ALIGN16(size);
@@ -895,10 +900,10 @@ void AudioLoad_SyncDma(u32 devAddr, u8* addr, size_t size, s32 medium) {
}
}
-void AudioLoad_SyncDmaUnkMedium(u32 devAddr, u8* addr, size_t size, s32 unkMediumParam) {
+void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* addr, size_t size, s32 unkMediumParam) {
}
-s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, u32 devAddr, void* ramAddr, size_t size,
+s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, uintptr_t ramAddr, size_t size,
OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType) {
if (gAudioContext.resetTimer > 0x10) {
return -1;
@@ -924,7 +929,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
void* ret;
s32 medium;
s8 cachePolicy;
- u32 devAddr;
+ uintptr_t devAddr;
s32 status;
u32 temp_v0;
u32 realId;
@@ -1051,7 +1056,7 @@ s32 AudioLoad_AssertValidAddr(uintptr_t ramAddr, uintptr_t startAddr, size_t siz
}
}
-#define BASE_ROM_OFFSET(x) (void*)((u32)(x) + (u32)(romAddr))
+#define BASE_ROM_OFFSET(x) (uintptr_t)((uintptr_t)(x) + (uintptr_t)(romAddr))
void AudioLoad_InitSwapFontSampleHeaders(SoundFontSample* sample, uintptr_t romAddr) {
// OTRTODO: This will be removed when we actually extract the data.
@@ -1128,7 +1133,7 @@ void AudioLoad_InitSwapFont(void) {
}
// sfxs
- ptrs[1] = (void*)BOMSWAP32((u32)ptrs[1]);
+ ptrs[1] = (void*)BOMSWAP32((uintptr_t)ptrs[1]);
if ((ptrs[1] != NULL) && (numSfxs != 0)) {
sfxList = (SoundFontSound*)BASE_ROM_OFFSET(ptrs[1]);
@@ -1178,7 +1183,7 @@ void AudioLoad_InitSwapFont(void) {
#undef BASE_ROM_OFFSET
-void AudioLoad_Init(void* heap, u32 heapSize) {
+void AudioLoad_Init(void* heap, size_t heapSize) {
char pad[0x48];
s32 numFonts;
void* temp_v0_3;
@@ -1245,7 +1250,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) {
gAudioContext.audioHeapSize = heapSize;
}
- for (i = 0; i < (s32)gAudioContext.audioHeapSize / 8; i++) {
+ for (i = 0; i < gAudioContext.audioHeapSize / 8; i++) {
((u64*)gAudioContext.audioHeap)[i] = 0;
}
@@ -1284,7 +1289,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) {
if (temp_v0_3 = AudioHeap_Alloc(&gAudioContext.audioInitPool, D_8014A6C4.permanentPoolSize), temp_v0_3 == NULL) {
// cast away const from D_8014A6C4
- *((u32*)&D_8014A6C4.permanentPoolSize) = 0;
+ *((size_t*)&D_8014A6C4.permanentPoolSize) = 0;
}
AudioHeap_AllocPoolInit(&gAudioContext.permanentPool, temp_v0_3, D_8014A6C4.permanentPoolSize);
@@ -1439,14 +1444,14 @@ void AudioLoad_ProcessSlowLoads(s32 resetStatus) {
}
}
-void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, ptrdiff_t size) {
+void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, size_t size) {
Audio_InvalDCache(slowLoad->curRamAddr, size);
osCreateMesgQueue(&slowLoad->msgqueue, &slowLoad->msg, 1);
AudioLoad_Dma(&slowLoad->ioMesg, OS_MESG_PRI_NORMAL, 0, slowLoad->curDevAddr, slowLoad->curRamAddr, size,
&slowLoad->msgqueue, slowLoad->medium, "SLOWCOPY");
}
-void AudioLoad_DmaSlowCopyUnkMedium(s32 devAddr, u8* ramAddr, ptrdiff_t size, s32 arg3) {
+void AudioLoad_DmaSlowCopyUnkMedium(uintptr_t devAddr, uintptr_t ramAddr, size_t size, s32 arg3) {
}
s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) {
@@ -1494,7 +1499,8 @@ void AudioLoad_InitAsyncLoads(void) {
}
}
-AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, u32 devAddr, void* ramAddr, ptrdiff_t size, s32 medium,
+AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, u32 devAddr, uintptr_t ramAddr, size_t size,
+ s32 medium,
s32 nChunks, OSMesgQueue* retQueue, s32 retMsg) {
AudioAsyncLoad* asyncLoad;
@@ -1509,7 +1515,7 @@ AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, u32 devAdd
return asyncLoad;
}
-AudioAsyncLoad* AudioLoad_StartAsyncLoad(u32 devAddr, void* ramAddr, size_t size, s32 medium, s32 nChunks,
+AudioAsyncLoad* AudioLoad_StartAsyncLoad(uintptr_t devAddr, uintptr_t ramAddr, size_t size, s32 medium, s32 nChunks,
OSMesgQueue* retQueue, s32 retMsg) {
AudioAsyncLoad* asyncLoad;
s32 i;
@@ -1537,7 +1543,7 @@ AudioAsyncLoad* AudioLoad_StartAsyncLoad(u32 devAddr, void* ramAddr, size_t size
} else if (nChunks == 1) {
asyncLoad->chunkSize = size;
} else {
- asyncLoad->chunkSize = ALIGN256((s32)size / nChunks);
+ asyncLoad->chunkSize = ALIGN256(size / nChunks);
if (asyncLoad->chunkSize < 0x100) {
asyncLoad->chunkSize = 0x100;
}
@@ -1682,10 +1688,10 @@ void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, size_t size) {
asyncLoad->medium, "BGCOPY");
}
-void AudioLoad_AsyncDmaUnkMedium(u32 devAddr, void* ramAddr, size_t size, s16 arg3) {
+void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, uintptr_t ramAddr, size_t size, s16 arg3) {
}
-#define RELOC(v, base) (reloc = (void*)((u32)(v) + (u32)(base)))
+#define RELOC(v, base) (reloc = (uintptr_t)((uintptr_t)(v) + (uintptr_t)(base)))
void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocInfo* relocInfo) {
// OTRTODO: This is hack to detect whether or not the sample has been relocated.
@@ -1736,7 +1742,7 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Rel
AudioPreloadReq* preload;
AudioPreloadReq* topPreload;
SoundFontSample* sample;
- ptrdiff_t size;
+ size_t size;
s32 nChunks;
u8* addr;
s32 preloadInProgress;
@@ -1799,12 +1805,12 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Rel
switch (async) {
case false:
if (sample->medium == MEDIUM_UNK) {
- AudioLoad_SyncDmaUnkMedium((u32)sample->sampleAddr, addr, sample->size,
+ AudioLoad_SyncDmaUnkMedium(sample->sampleAddr, addr, sample->size,
gAudioContext.sampleBankTable->unkMediumParam);
sample->sampleAddr = addr;
sample->medium = MEDIUM_RAM;
} else {
- AudioLoad_SyncDma((u32)sample->sampleAddr, addr, sample->size, sample->medium);
+ AudioLoad_SyncDma(sample->sampleAddr, addr, sample->size, sample->medium);
sample->sampleAddr = addr;
sample->medium = MEDIUM_RAM;
}
@@ -1817,7 +1823,7 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Rel
preload->ramAddr = addr;
preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF;
preload->isFree = false;
- preload->endAndMediumKey = (u32)sample->sampleAddr + sample->size + sample->medium;
+ preload->endAndMediumKey = sample->sampleAddr + sample->size + sample->medium;
gAudioContext.preloadSampleStackTop++;
break;
}
@@ -1828,7 +1834,7 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Rel
topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1];
sample = topPreload->sample;
nChunks = (sample->size >> 12) + 1;
- AudioLoad_StartAsyncLoad((u32)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, nChunks,
+ AudioLoad_StartAsyncLoad(sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, nChunks,
&gAudioContext.preloadSampleQueue, topPreload->encodedInfo);
}
}
@@ -1837,7 +1843,7 @@ s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) {
SoundFontSample* sample;
AudioPreloadReq* preload;
u32 preloadIndex;
- u32 key;
+ uintptr_t key;
u32 nChunks;
s32 pad;
@@ -1858,7 +1864,7 @@ s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) {
if (preload->isFree == false) {
sample = preload->sample;
- key = (u32)sample->sampleAddr + sample->size + sample->medium;
+ key = sample->sampleAddr + sample->size + sample->medium;
if (key == preload->endAndMediumKey) {
// Change storage for sample to the preloaded version.
sample->sampleAddr = preload->ramAddr;
@@ -1881,12 +1887,12 @@ s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) {
sample = preload->sample;
nChunks = (sample->size >> 12) + 1;
- key = (u32)sample->sampleAddr + sample->size + sample->medium;
+ key = sample->sampleAddr + sample->size + sample->medium;
if (key != preload->endAndMediumKey) {
preload->isFree = true;
gAudioContext.preloadSampleStackTop--;
} else {
- AudioLoad_StartAsyncLoad((u32)sample->sampleAddr, preload->ramAddr, sample->size, sample->medium,
+ AudioLoad_StartAsyncLoad(sample->sampleAddr, preload->ramAddr, sample->size, sample->medium,
nChunks, &gAudioContext.preloadSampleQueue, preload->encodedInfo);
break;
}
@@ -1964,7 +1970,7 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo
AudioPreloadReq* preload;
AudioPreloadReq* topPreload;
u8* addr = NULL;
- ptrdiff_t size;
+ size_t size;
s32 i;
SoundFontSample* sample;
s32 preloadInProgress;
@@ -2056,12 +2062,12 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo
switch (async) {
case false:
if (sample->medium == MEDIUM_UNK) {
- AudioLoad_SyncDmaUnkMedium((u32)sample->sampleAddr, addr, sample->size,
+ AudioLoad_SyncDmaUnkMedium(sample->sampleAddr, addr, sample->size,
gAudioContext.sampleBankTable->unkMediumParam);
sample->sampleAddr = addr;
sample->medium = MEDIUM_RAM;
} else {
- AudioLoad_SyncDma((u32)sample->sampleAddr, addr, sample->size, sample->medium);
+ AudioLoad_SyncDma(sample->sampleAddr, addr, sample->size, sample->medium);
sample->sampleAddr = addr;
sample->medium = MEDIUM_RAM;
}
@@ -2073,7 +2079,7 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo
preload->ramAddr = addr;
preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF;
preload->isFree = false;
- preload->endAndMediumKey = (u32)sample->sampleAddr + sample->size + sample->medium;
+ preload->endAndMediumKey = sample->sampleAddr + sample->size + sample->medium;
gAudioContext.preloadSampleStackTop++;
break;
}
@@ -2084,7 +2090,7 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo
topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1];
sample = topPreload->sample;
nChunks = (sample->size >> 12) + 1;
- AudioLoad_StartAsyncLoad((u32)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, nChunks,
+ AudioLoad_StartAsyncLoad(sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, nChunks,
&gAudioContext.preloadSampleQueue, topPreload->encodedInfo);
}
}
diff --git a/soh/src/code/audio_synthesis.c b/soh/src/code/audio_synthesis.c
index 037bd2ec3..3416631bf 100644
--- a/soh/src/code/audio_synthesis.c
+++ b/soh/src/code/audio_synthesis.c
@@ -675,11 +675,11 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
s32 temp_v1_6;
void* buf;
s32 nSamplesToDecode;
- u32 sampleAddr;
+ uintptr_t sampleAddr;
u32 samplesLenFixedPoint;
s32 samplesLenAdjusted;
s32 nSamplesProcessed;
- s32 loopEndPos;
+ uintptr_t loopEndPos;
s32 nSamplesToProcess;
s32 phi_s4;
s32 nFirstFrameSamplesToIgnore;
@@ -687,15 +687,15 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
s32 frameSize;
s32 nFramesToDecode;
s32 skipInitialSamples;
- s32 sampleDataStart;
+ intptr_t sampleDataStart;
u8* sampleData;
s32 nParts;
s32 curPart;
- s32 sampleDataStartPad;
+ intptr_t sampleDataStartPad;
s32 side;
s32 resampledTempLen;
u16 noteSamplesDmemAddrBeforeResampling;
- s32 sampleDataOffset;
+ intptr_t sampleDataOffset;
s32 thing;
s32 s5;
Note* note;
diff --git a/soh/src/code/code_800E4FE0.c b/soh/src/code/code_800E4FE0.c
index c46ae7a07..5d2d11188 100644
--- a/soh/src/code/code_800E4FE0.c
+++ b/soh/src/code/code_800E4FE0.c
@@ -39,7 +39,6 @@ extern u64 rspAspMainDataStart[];
extern u64 rspAspMainDataEnd[];
void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples) {
- // OTRTODO: uintptr_t?
u32 sp4C;
gAudioContext.totalTaskCnt++;
diff --git a/soh/src/code/main.c b/soh/src/code/main.c
index 0680aad3e..b9e74298d 100644
--- a/soh/src/code/main.c
+++ b/soh/src/code/main.c
@@ -6,7 +6,7 @@
s32 gScreenWidth = SCREEN_WIDTH;
s32 gScreenHeight = SCREEN_HEIGHT;
-u32 gSystemHeapSize = 0;
+size_t gSystemHeapSize = 0;
PreNmiBuff* gAppNmiBufferPtr;
SchedContext gSchedContext;
@@ -53,7 +53,7 @@ void Main(void* arg) {
uintptr_t sysHeap;
uintptr_t fb;
void* debugHeap;
- s32 debugHeapSize;
+ size_t debugHeapSize;
s16* msg;
osSyncPrintf("mainproc 実行開始\n"); // "Start running"
From 6ccd3ede1a3320813fd3c37d68bfe33a9272fc02 Mon Sep 17 00:00:00 2001
From: sholdee <102821812+sholdee@users.noreply.github.com>
Date: Sat, 21 May 2022 13:16:12 -0400
Subject: [PATCH 3/4] Update soh path for z64 branch (#344)
This check will fail on Windows before it gets merged btw
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 14b2a40ca..2eb840966 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -52,7 +52,7 @@ pipeline {
cd "..\\..\\"
- move "soh\\Release\\soh.exe" ".\\"
+ move "soh\\x64\\Release\\soh.exe" ".\\"
move "OTRGui\\build\\assets" ".\\"
move ".\\OTRExporter\\x64\\Release\\ZAPD.exe" ".\\assets\\extractor\\"
move ".\\OTRGui\\build\\Release\\OTRGui.exe" ".\\"
From fca79ae92ae0346bfedd1f2a976ac512209e8d75 Mon Sep 17 00:00:00 2001
From: Kevin Alexis Contreras <36680385+KiritoDv@users.noreply.github.com>
Date: Mon, 30 May 2022 11:19:08 -0500
Subject: [PATCH 4/4] Fixed camera and disabled sound
---
soh/include/z64camera.h | 12 ++++++------
soh/src/code/code_800EC960.c | 1 +
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/soh/include/z64camera.h b/soh/include/z64camera.h
index f4f064045..51f8a45b1 100644
--- a/soh/include/z64camera.h
+++ b/soh/include/z64camera.h
@@ -55,7 +55,7 @@ typedef enum {
/* 0x1E */ CAM_SET_CRAWLSPACE, // Used in all crawlspaces "RAIL3"
/* 0x1F */ CAM_SET_START0, // Data is given in Temple of Time, but no surface uses it
/* 0x20 */ CAM_SET_START1, // Scene/room door transitions that snap the camera to a fixed location (example: ganon's towers doors climbing up)
- /* 0x21 */ CAM_SET_FREE0, // Full manual control is given over the camera
+ /* 0x21 */ CAM_SET_FREE0, // Full manual control is given over the camera
/* 0x22 */ CAM_SET_FREE2, // Various OnePoint Cutscenes, 10 total (example: falling chest)
/* 0x23 */ CAM_SET_PIVOT_CORNER, // Inside the carpenter jail cells from theives hideout "CIRCLE4"
/* 0x24 */ CAM_SET_PIVOT_WATER_SURFACE, // Player diving from the surface of the water to underwater "CIRCLE5"
@@ -391,7 +391,7 @@ typedef struct {
{ groundAtLerpStepScale, CAM_DATA_GROUND_AT_LERP_STEP_SCALE }
typedef struct {
-
+
/* 0x00 */ SwingAnimation swing;
/* 0x1C */ f32 unk_1C;
/* 0x20 */ VecSph unk_20;
@@ -403,7 +403,7 @@ typedef struct {
/* 0x08 */ f32 distMax;
/* 0x0C */ f32 yawUpateRateTarget;
/* 0x10 */ f32 maxYawUpdate;
- /* 0x14 */ f32 unk_14; // never used.
+ /* 0x14 */ f32 unk_14; // never used.
/* 0x18 */ f32 atLERPScaleMax;
/* 0x1C */ s16 interfaceFlags;
/* 0x20 */ Jump1Anim anim;
@@ -954,7 +954,7 @@ typedef struct {
* 0x2: Add atTargetInit to view's lookAt
* if initFlags & 0x6060: use world for focus point
* 0x3: Add atTargetInit to camera's at
- * 0x4: Don't update targets?
+ * 0x4: Don't update targets?
* 0x8: flag to use atTagetInit as f32 pitch, yaw, r
* 0x10: ? unused
* 0x20: focus on player
@@ -1033,7 +1033,7 @@ typedef struct {
typedef struct {
/* 0x0 */ s16 interfaceFlags;
/* 0x2 */ s16 unk_02;
- /* 0x4 */ Demo6Anim anim;
+ /* 0x4 */ Demo6Anim anim;
} Demo6; // size = 0x14
typedef struct {
@@ -1157,7 +1157,7 @@ typedef struct {
} CamColChk; // size = 0x28
typedef struct {
- /* 0x000 */ char paramData[0x50];
+ /* 0x000 */ char paramData[0xFF];
/* 0x050 */ Vec3f at;
/* 0x05C */ Vec3f eye;
/* 0x068 */ Vec3f up;
diff --git a/soh/src/code/code_800EC960.c b/soh/src/code/code_800EC960.c
index 5d61d170e..13a50c554 100644
--- a/soh/src/code/code_800EC960.c
+++ b/soh/src/code/code_800EC960.c
@@ -4256,6 +4256,7 @@ void Audio_ClearSariaBgmAtPos(Vec3f* pos) {
* equally between the two bgm channels. Split based on note priority
*/
void Audio_SplitBgmChannels(s8 volSplit) {
+ return;
u8 volume;
u8 notePriority;
u16 channelBits;