diff options
| author | Kenix3 <kenixwhisperwind@gmail.com> | 2022-06-21 22:17:47 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-21 22:17:47 -0400 |
| commit | d5db4a86bd1267ac0189e23c0320cca90587ece4 (patch) | |
| tree | 3ba04dd59f89c6148f6bd353c2de3c3e20af460b /soh/src/code | |
| parent | abcf713cc1e38b1091cb9fa0a1dfb0bff64c4efd (diff) | |
| parent | f8e3dcd7c02bd12f745fce8443683c6ec7438cdf (diff) | |
Merge pull request #431 from HarbourMasters/zelda64
Ship of Harkinian 64 bit compilation
Diffstat (limited to 'soh/src/code')
29 files changed, 290 insertions, 288 deletions
diff --git a/soh/src/code/__osMalloc.c b/soh/src/code/__osMalloc.c index bba1e6735..1604332b7 100644 --- a/soh/src/code/__osMalloc.c +++ b/soh/src/code/__osMalloc.c @@ -63,7 +63,7 @@ void ArenaImpl_LockInit(Arena* arena) { } void ArenaImpl_Lock(Arena* arena) { - osSendMesg(&arena->lock, NULL, OS_MESG_BLOCK); + osSendMesgPtr(&arena->lock, NULL, OS_MESG_BLOCK); } void ArenaImpl_Unlock(Arena* arena) { diff --git a/soh/src/code/audioMgr.c b/soh/src/code/audioMgr.c index e8c7be032..ab34a4617 100644 --- a/soh/src/code/audioMgr.c +++ b/soh/src/code/audioMgr.c @@ -7,7 +7,7 @@ void func_800C3C80(AudioMgr* audioMgr) { task = audioMgr->rspTask; if (audioMgr->rspTask->taskQueue != NULL) { - osSendMesg(task->taskQueue, NULL, OS_MESG_BLOCK); + osSendMesgPtr(task->taskQueue, NULL, OS_MESG_BLOCK); } } @@ -25,8 +25,8 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) { audioMgr->audioTask.list = audioMgr->rspTask->task; audioMgr->audioTask.msgQ = &audioMgr->unk_AC; - audioMgr->audioTask.msg = NULL; - osSendMesg(&audioMgr->sched->cmdQ, &audioMgr->audioTask, OS_MESG_BLOCK); + audioMgr->audioTask.msg.ptr = NULL; + osSendMesgPtr(&audioMgr->sched->cmdQ, &audioMgr->audioTask, OS_MESG_BLOCK); Sched_SendEntryMsg(audioMgr->sched); } @@ -96,7 +96,7 @@ void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedCon osCreateMesgQueue(&audioMgr->unk_74, &audioMgr->unk_8C, 8); osCreateMesgQueue(&audioMgr->unk_C8, &audioMgr->unk_E0, 1); - osSendMesg(&audioMgr->unk_AC, NULL, OS_MESG_BLOCK); + osSendMesgPtr(&audioMgr->unk_AC, NULL, OS_MESG_BLOCK); static bool hasInitialized = false; @@ -107,7 +107,7 @@ void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedCon Audio_Init(); AudioLoad_SetDmaHandler(DmaMgr_DmaHandler); Audio_InitSound(); - osSendMesg(&audioMgr->unk_C8, NULL, OS_MESG_BLOCK); + osSendMesgPtr(&audioMgr->unk_C8, NULL, OS_MESG_BLOCK); ModInternal_ExecuteAudioInitHooks(); // Removed due to crash //IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->unk_74); diff --git a/soh/src/code/audio_heap.c b/soh/src/code/audio_heap.c index 84e91d439..25f66e4a7 100644 --- a/soh/src/code/audio_heap.c +++ b/soh/src/code/audio_heap.c @@ -251,7 +251,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); @@ -1150,9 +1150,9 @@ void AudioHeap_UnapplySampleCacheForFont(SampleCacheEntry* entry, s32 fontId) { Drum* drum; Instrument* inst; SoundFontSound* sfx; - s32 instId; - s32 drumId; - s32 sfxId; + size_t instId; + size_t drumId; + size_t sfxId; for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { inst = Audio_GetInstrumentInner(fontId, instId); @@ -1203,7 +1203,7 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) { } } -void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) { if (!gUseLegacySD) return; @@ -1272,18 +1272,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; } @@ -1306,7 +1306,7 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { s32 numFonts; s32 instId; s32 drumId; - s32 sfxId; + size_t sfxId; StorageChange change; s32 sampleBankId1; s32 sampleBankId2; diff --git a/soh/src/code/audio_init_params.c b/soh/src/code/audio_init_params.c index 95af11421..f5bae8fd8 100644 --- a/soh/src/code/audio_init_params.c +++ b/soh/src/code/audio_init_params.c @@ -10,8 +10,8 @@ const s16 D_8014A6C0[] = { 0x0030, // gTatumsPerBeat }; -//const AudioContextInitSizes D_8014A6C4 = { 0x37F00, 0xE0E0, 0xBCE0 }; -const AudioContextInitSizes D_8014A6C4 = { 0x37F000, 0xE0E00, 0xBCE00 }; // OTRTODO: This might be overkill... +// OTRTODO: This might be overkill... +const AudioContextInitSizes D_8014A6C4 = { 0x37F000, 0xE0E00, 0xBCE00 }; ReverbSettings D_80133420[][3] = { { diff --git a/soh/src/code/audio_load.c b/soh/src/code/audio_load.c index 5a579e2a0..107e8f015 100644 --- a/soh/src/code/audio_load.c +++ b/soh/src/code/audio_load.c @@ -21,8 +21,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 @@ -40,27 +40,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, int fontId); void AudioLoad_DiscardFont(s32 fontId); -u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad); -void* AudioLoad_SyncLoad(u32 tableType, u32 tableId, s32* didAllocate); +uintptr_t AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad); +uintptr_t AudioLoad_SyncLoad(u32 tableType, u32 tableId, s32* didAllocate); u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 tableId); void* AudioLoad_SearchCaches(s32 tableType, s32 id); AudioTable* AudioLoad_GetLoadTable(s32 tableType); void AudioLoad_SyncDma(uintptr_t 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_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, + size_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(uintptr_t 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]; @@ -115,11 +116,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; @@ -288,7 +289,6 @@ void AudioLoad_InitSampleDmaBuffers(s32 arg0) { s32 AudioLoad_IsFontLoadComplete(s32 fontId) { return true; - if (fontId == 0xFF) { return true; @@ -390,7 +390,7 @@ SoundFontData* AudioLoad_SyncLoadSeqFonts(s32 seqId, u32* outDefaultFontId) { while (numFonts > 0) { fontId = gAudioContext.sequenceFontTable[index++]; - + font = AudioLoad_SyncLoadFont(fontId); numFonts--; } @@ -416,7 +416,7 @@ void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1) { s32 AudioLoad_SyncLoadSample(SoundFontSample* sample, s32 fontId) { void* sampleAddr; - if (sample->unk_bit25 == 1) + if (sample->unk_bit25 == 1) { if (sample->medium != MEDIUM_RAM) { sampleAddr = AudioHeap_AllocSampleCache(sample->size, fontId, (void*)sample->sampleAddr, sample->medium, @@ -464,7 +464,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); + osSendMesg32(retQueue, 0xFFFFFFFF, OS_MESG_NOBLOCK); } } @@ -483,7 +483,7 @@ void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* ret u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) { s32 index; - if (!gUseLegacySD) + if (!gUseLegacySD) { if (seqId == 255) return NULL; @@ -555,6 +555,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) { @@ -565,6 +567,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) { @@ -581,6 +585,8 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { AudioSeq_SequencePlayerDisable(seqPlayer); fontId = 0xFF; + index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + numFonts = gAudioContext.sequenceFontTable[index++]; if (gUseLegacySD) { index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; @@ -594,11 +600,11 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { numFonts--; } } - else + else { SequenceData seqData2 = ResourceMgr_LoadSeqByName(sequenceMap[seqId]); - for (int i = 0; i < seqData2.numFonts; i++) + for (int i = 0; i < seqData2.numFonts; i++) { fontId = seqData2.fonts[i]; AudioLoad_SyncLoadFont(fontId); // NOTE: If this is commented out, then enemies will play child link sounds... @@ -607,14 +613,13 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { } seqData = AudioLoad_SyncLoadSeq(seqId); - + if (seqData == NULL) { return 0; } AudioSeq_ResetSequencePlayer(seqPlayer); seqPlayer->seqId = seqId; - if (gUseLegacySD) seqPlayer->defaultFont = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); else @@ -642,12 +647,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; @@ -727,7 +732,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; @@ -735,7 +740,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,8 +748,7 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) { if (ret != NULL) { *didAllocate = false; status = 2; - } else - { + } else { char* seqData = 0; SoundFont* fnt; @@ -756,8 +760,8 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) { medium = sData.medium; cachePolicy = sData.cachePolicy; romAddr = 0; - } - else if (!gUseLegacySD && tableType == FONT_TABLE) + } + else if (!gUseLegacySD && tableType == FONT_TABLE) { fnt = ResourceMgr_LoadAudioSoundFont(fontMap[id]); size = sizeof(SoundFont); @@ -765,7 +769,7 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) { cachePolicy = 0; romAddr = 0; } - else + else { table = AudioLoad_GetLoadTable(tableType); size = table->entries[realId].size; @@ -837,7 +841,7 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) { return ret; } -u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id) +u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id) { if ((tableType == SEQUENCE_TABLE || tableType == FONT_TABLE) && !gUseLegacySD) { return id; @@ -845,7 +849,7 @@ u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id) AudioTable* table = AudioLoad_GetLoadTable(tableType); - // If the size is 0, then this entry actually redirects to another entry. + // If the size is 0, then this entry actually redirects to another entry. // The rom address is actually an index into the same table where the "real" data is. if (table->entries[id].size == 0) { id = table->entries[id].romAddr; @@ -891,14 +895,13 @@ 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; s32 i; SoundFont* sf = NULL; - s32 numDrums = 0; s32 numInstruments = 0; s32 numSfx = 0; @@ -912,26 +915,25 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo numDrums = sf->numDrums; numInstruments = sf->numInstruments; numSfx = sf->numSfx; - } + } void** ptrs = (void**)mem; - #define BASE_OFFSET(x) (void*)((u32)(x) + (u32)(mem)) reloc2 = ptrs[0]; if (1) {} - if ((reloc2 != 0 || !gUseLegacySD) && (numDrums != 0)) + if ((reloc2 != 0 || !gUseLegacySD) && (numDrums != 0)) { ptrs[0] = BASE_OFFSET(reloc2); - for (i = 0; i < numDrums; i++) + for (i = 0; i < numDrums; i++) { if (gUseLegacySD) reloc = ((Drum**)ptrs[0])[i]; - if (reloc != 0 || !gUseLegacySD) + if (reloc != 0 || !gUseLegacySD) { - if (gUseLegacySD) + if (gUseLegacySD) { reloc = BASE_OFFSET(reloc); ((Drum**)ptrs[0])[i] = drum = reloc; @@ -940,15 +942,15 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo if (!gUseLegacySD) drum = sf->drums[i]; - if (!drum->loaded) + if (!drum->loaded) { - if (!gUseLegacySD) + if (!gUseLegacySD) { AudioLoad_RelocateSample(&sf->drums[i]->sound, mem, relocInfo, fontOffsets[fontId]); //reloc = drum->envelope; drum->loaded = 1; - } - else + } + else { AudioLoad_RelocateSample(&drum->sound, mem, relocInfo, fontOffsets[fontId]); reloc = drum->envelope; @@ -966,7 +968,7 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo ptrs[1] = BASE_OFFSET(reloc2); for (i = 0; i < numSfx; i++) { reloc = (SoundFontSound*)ptrs[1] + i; - if (reloc != 0 || !gUseLegacySD) + if (reloc != 0 || !gUseLegacySD) { if (!gUseLegacySD) { AudioLoad_RelocateSample(&sf->soundEffects[i].sample, mem, relocInfo, fontOffsets[fontId]); @@ -979,7 +981,7 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo } } } - + if (numInstruments > 0x7E) { numInstruments = 0x7E; } @@ -988,7 +990,7 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo int startEC = gUseLegacySD ? 2 + numInstruments - 1 : numInstruments - 1; //for (i = 2; i <= 2 + numInstruments - 1; i++) { for (i = startI; i <= startEC; i++) { - if (!gUseLegacySD || ptrs[i] != NULL) + if (!gUseLegacySD || ptrs[i] != NULL) { ptrs[i] = BASE_OFFSET(ptrs[i]); @@ -996,9 +998,9 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo inst = ptrs[i]; else inst = sf->instruments[i]; - + if (inst != NULL && !inst->loaded) { - if (inst->normalRangeLo != 0) + if (inst->normalRangeLo != 0) { AudioLoad_RelocateSample(&inst->lowNotesSound, mem, relocInfo, fontOffsets[fontId]); } @@ -1008,10 +1010,10 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo } reloc = inst->envelope; - + if (gUseLegacySD) inst->envelope = BASE_OFFSET(reloc); - + inst->loaded = 1; } } @@ -1050,10 +1052,10 @@ void AudioLoad_SyncDma(uintptr_t 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; @@ -1079,7 +1081,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; @@ -1106,7 +1108,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, ret = AudioLoad_SearchCaches(tableType, realId); if (ret != NULL) { status = 2; - osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, 0), OS_MESG_NOBLOCK); + osSendMesg32(retQueue, MK_ASYNC_MSG(retData, 0, 0, 0), OS_MESG_NOBLOCK); } else { sp50 = AudioLoad_GetLoadTable(tableType); size = sp50->entries[realId].size; @@ -1206,7 +1208,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) { size_t maxSoundFontSize = 0x3AA0; // soundFont 0 is the largest size at 0x3AA0 @@ -1282,7 +1284,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]); @@ -1332,25 +1334,18 @@ 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; s32 i; u64* heapP; - u8* ctxP; s16* u2974p; D_801755D0 = NULL; gAudioContext.resetTimer = 0; - { - s32 i; - u8* ctxP = (u8*)&gAudioContext; - for (i = sizeof(gAudioContext); i >= 0; i--) { - *ctxP++ = 0; - } - } + memset(&gAudioContext, 0, sizeof(gAudioContext)); switch (osTvType) { case OS_TV_PAL: @@ -1399,7 +1394,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; } @@ -1437,7 +1432,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) { if (gUseLegacySD) numFonts = gAudioContext.soundFontTable->numEntries; - if (gUseLegacySD) + if (gUseLegacySD) { gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont)); @@ -1450,7 +1445,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) { int seqListSize = 0; char** seqList = ResourceMgr_ListFiles("audio/sequences*", &seqListSize); - for (int i = 0; i < seqListSize; i++) + for (size_t i = 0; i < seqListSize; i++) { SequenceData sDat = ResourceMgr_LoadSeqByName(seqList[i]); @@ -1465,7 +1460,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) { int fntListSize = 0; char** fntList = ResourceMgr_ListFiles("audio/fonts*", &fntListSize); - for (int i = 0; i < fntListSize; i++) + for (int i = 0; i < fntListSize; i++) { SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fntList[i]); @@ -1485,12 +1480,12 @@ 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; + // *((u32*)&D_8014A6C4.permanentPoolSize) = 0; } AudioHeap_AllocPoolInit(&gAudioContext.permanentPool, temp_v0_3, D_8014A6C4.permanentPoolSize); gAudioContextInitalized = true; - osSendMesg(gAudioContext.taskStartQueueP, (void*)gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK); + osSendMesg32(gAudioContext.taskStartQueueP, gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK); } void AudioLoad_InitSlowLoads(void) { @@ -1501,6 +1496,7 @@ void AudioLoad_InitSlowLoads(void) { s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) { SoundFontSample* sample; AudioSlowLoad* slowLoad; + sample = AudioLoad_GetFontSample(fontId, instId); if (sample == NULL) { *isDone = 0; @@ -1639,14 +1635,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) { @@ -1660,19 +1656,16 @@ s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) { } seqId = AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId); - seqTable = AudioLoad_GetLoadTable(SEQUENCE_TABLE); - slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos]; if (slowLoad->status == LOAD_STATUS_DONE) { slowLoad->status = LOAD_STATUS_WAITING; } - slowLoad->sample.sampleAddr = NULL; slowLoad->isDone = isDone; - if (!gUseLegacySD) + if (!gUseLegacySD) { SequenceData sData = ResourceMgr_LoadSeqByName(sequenceMap[seqId]); char* seqData = sData.seqData; @@ -1708,7 +1701,8 @@ void AudioLoad_InitAsyncLoads(void) { } } -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, size_t size, + s32 medium, s32 nChunks, OSMesgQueue* retQueue, s32 retMsg) { AudioAsyncLoad* asyncLoad; @@ -1718,12 +1712,12 @@ AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, u32 devAdd return NULL; } - osSendMesg(&gAudioContext.asyncLoadUnkMediumQueue, asyncLoad, OS_MESG_NOBLOCK); + osSendMesgPtr(&gAudioContext.asyncLoadUnkMediumQueue, asyncLoad, OS_MESG_NOBLOCK); asyncLoad->unkMediumParam = unkMediumParam; 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; @@ -1751,7 +1745,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; } @@ -1834,7 +1828,7 @@ void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { break; } - doneMsg = asyncLoad->retMsg; + doneMsg.data32 = asyncLoad->retMsg; if (1) {} asyncLoad->status = LOAD_STATUS_WAITING; osSendMesg(asyncLoad->retQueue, doneMsg, OS_MESG_NOBLOCK); @@ -1896,14 +1890,14 @@ 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, int fontId) { size_t maxSoundBankSize = 0x3EB2A0; // sample bank 0 is largest size at 0x3EB2A0 - if (gUseLegacySD) + if (gUseLegacySD) { // NOTE: This is hack to detect whether or not the sample has been relocated. if ((uintptr_t)mem <= maxSoundBankSize) { @@ -1915,7 +1909,7 @@ void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, RelocIn void* reloc; // NOTE: Seems precarious to assume the RAM is never <= 0x3EB2A0, but it largely works. - if ((uintptr_t)sound->sample < maxSoundBankSize || !gUseLegacySD) + if ((uintptr_t)sound->sample < maxSoundBankSize || !gUseLegacySD) { if (!gUseLegacySD) { SoundFontSample* sample2 = sound; @@ -1958,7 +1952,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; @@ -2021,12 +2015,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; } @@ -2039,7 +2033,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; } @@ -2050,7 +2044,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); } } @@ -2059,7 +2053,7 @@ s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { SoundFontSample* sample; AudioPreloadReq* preload; u32 preloadIndex; - u32 key; + uintptr_t key; u32 nChunks; s32 pad; @@ -2188,7 +2182,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; @@ -2256,7 +2250,6 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo } sample = gAudioContext.usedSamples[i]; - if (sample->medium == MEDIUM_RAM) { continue; } @@ -2289,12 +2282,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; } @@ -2306,7 +2299,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; } @@ -2317,7 +2310,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); } } @@ -2333,11 +2326,11 @@ void AudioLoad_LoadPermanentSamples(void) { for (i = 0; i < gAudioContext.permanentPool.count; i++) { RelocInfo relocInfo; - if (gAudioContext.permanentCache[i].tableType == FONT_TABLE) + if (gAudioContext.permanentCache[i].tableType == FONT_TABLE) { fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.permanentCache[i].id); //fontId = gAudioContext.permanentCache[i].id; - + if (!gUseLegacySD) { SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]); relocInfo.sampleBankId1 = sf->sampleBankId1; diff --git a/soh/src/code/audio_playback.c b/soh/src/code/audio_playback.c index df64e2c7b..b9f868bd3 100644 --- a/soh/src/code/audio_playback.c +++ b/soh/src/code/audio_playback.c @@ -286,11 +286,11 @@ void Audio_ProcessNotes(void) { } subAttrs.frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale; - + f32 resampRate = gAudioContext.audioBufferParameters.resampleRate; if (!gUseLegacySD && !noteSubEu2->bitField1.isSyntheticWave && noteSubEu2->sound.soundFontSound != NULL && - noteSubEu2->sound.soundFontSound->sample != NULL && + noteSubEu2->sound.soundFontSound->sample != NULL && noteSubEu2->sound.soundFontSound->sample->sampleRateMagicValue == 'RIFF') { resampRate = CALC_RESAMPLE_FREQ(noteSubEu2->sound.soundFontSound->sample->sampleRate); } @@ -320,7 +320,7 @@ SoundFontSound* Audio_InstrumentGetSound(Instrument* instrument, s32 semitone) { Instrument* Audio_GetInstrumentInner(s32 fontId, s32 instId) { Instrument* inst; - + if (fontId == 0xFF) { return NULL; } @@ -354,7 +354,6 @@ Instrument* Audio_GetInstrumentInner(s32 fontId, s32 instId) { gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x1000000; return inst; } - return inst; } diff --git a/soh/src/code/audio_seqplayer.c b/soh/src/code/audio_seqplayer.c index beac78269..6e33e94e1 100644 --- a/soh/src/code/audio_seqplayer.c +++ b/soh/src/code/audio_seqplayer.c @@ -942,7 +942,7 @@ u8 AudioSeq_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** inst return 0; } - if (inst->envelope != NULL) + if (inst->envelope != NULL) { adsr->envelope = inst->envelope; adsr->releaseRate = (inst->releaseRate); @@ -1067,8 +1067,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { offset = ((u16*)gAudioContext.sequenceFontTable)[seqPlayer->seqId]; lowBits = gAudioContext.sequenceFontTable[offset]; command = gAudioContext.sequenceFontTable[offset + lowBits - result]; - } - else { + } else { SequenceData sDat = ResourceMgr_LoadSeqByName(sequenceMap[seqPlayer->seqId]); command = sDat.fonts[sDat.numFonts - result - 1]; } @@ -1179,14 +1178,12 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) { result = (u8)parameters[0]; command = (u8)parameters[0]; - if (seqPlayer->defaultFont != 0xFF) - { + if (seqPlayer->defaultFont != 0xFF) { if (gUseLegacySD) { offset = ((u16*)gAudioContext.sequenceFontTable)[seqPlayer->seqId]; lowBits = gAudioContext.sequenceFontTable[offset]; command = gAudioContext.sequenceFontTable[offset + lowBits - result]; - } - else { + } else { SequenceData sDat = ResourceMgr_LoadSeqByName(sequenceMap[seqPlayer->seqId]); command = sDat.fonts[sDat.numFonts - result - 1]; } diff --git a/soh/src/code/audio_synthesis.c b/soh/src/code/audio_synthesis.c index 2c5d03102..a50927b21 100644 --- a/soh/src/code/audio_synthesis.c +++ b/soh/src/code/audio_synthesis.c @@ -382,11 +382,11 @@ void AudioSynth_EnvSetup1(Acmd* cmd, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { void func_800DBD08(void) { } -void AudioSynth_LoadBuffer(Acmd* cmd, s32 arg1, s32 arg2, s32 arg3) { +void AudioSynth_LoadBuffer(Acmd* cmd, s32 arg1, s32 arg2, uintptr_t arg3) { aLoadBuffer(cmd, arg3, arg1, arg2); } -void AudioSynth_SaveBuffer(Acmd* cmd, s32 arg1, s32 arg2, s32 arg3) { +void AudioSynth_SaveBuffer(Acmd* cmd, s32 arg1, s32 arg2, uintptr_t arg3) { aSaveBuffer(cmd, arg1, arg3, arg2); } @@ -678,11 +678,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; @@ -690,15 +690,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 d88e731f4..865e8ee29 100644 --- a/soh/src/code/code_800E4FE0.c +++ b/soh/src/code/code_800E4FE0.c @@ -39,8 +39,7 @@ extern u64 rspAspMainDataStart[]; extern u64 rspAspMainDataEnd[]; void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples) { - // OTRTODO: uintptr_t? - u32 sp4C; + OSMesg sp4C; gAudioContext.totalTaskCnt++; @@ -51,7 +50,7 @@ void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples) { if (gAudioContext.resetStatus != 0) { if (AudioHeap_ResetStep() == 0) { if (gAudioContext.resetStatus == 0) { - osSendMesg(gAudioContext.audioResetQueueP, gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK); + osSendMesg8(gAudioContext.audioResetQueueP, gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK); } } } @@ -59,8 +58,8 @@ void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples) { int j = 0; if (gAudioContext.resetStatus == 0) { // msg = 0000RREE R = read pos, E = End Pos - while (osRecvMesg(gAudioContext.cmdProcQueueP, (OSMesg*)&sp4C, OS_MESG_NOBLOCK) != -1) { - Audio_ProcessCmds(sp4C); + while (osRecvMesg(gAudioContext.cmdProcQueueP, &sp4C, OS_MESG_NOBLOCK) != -1) { + Audio_ProcessCmds(sp4C.data32); j++; } if ((j == 0) && (gAudioContext.cmdQueueFinished)) { @@ -85,7 +84,7 @@ AudioTask* func_800E5000(void) { s16* currAiBuffer; OSTask_t* task; s32 index; - u32 sp4C; + OSMesg sp4C; s32 sp48; s32 i; @@ -103,7 +102,7 @@ AudioTask* func_800E5000(void) { } } - osSendMesg(gAudioContext.taskStartQueueP, gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK); + osSendMesg32(gAudioContext.taskStartQueueP, gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK); gAudioContext.rspTaskIdx ^= 1; gAudioContext.curAIBufIdx++; gAudioContext.curAIBufIdx %= 3; @@ -150,7 +149,7 @@ AudioTask* func_800E5000(void) { if (gAudioContext.resetStatus != 0) { if (AudioHeap_ResetStep() == 0) { if (gAudioContext.resetStatus == 0) { - osSendMesg(gAudioContext.audioResetQueueP, gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK); + osSendMesg8(gAudioContext.audioResetQueueP, gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK); } sWaitingAudioTask = NULL; @@ -187,11 +186,11 @@ AudioTask* func_800E5000(void) { j = 0; if (gAudioContext.resetStatus == 0) { // msg = 0000RREE R = read pos, E = End Pos - while (osRecvMesg(gAudioContext.cmdProcQueueP, (OSMesg*)&sp4C, OS_MESG_NOBLOCK) != -1) { + while (osRecvMesg(gAudioContext.cmdProcQueueP, &sp4C, OS_MESG_NOBLOCK) != -1) { if (1) {} if (1) {} if (1) {} - Audio_ProcessCmds(sp4C); + Audio_ProcessCmds(sp4C.data32); j++; } if ((j == 0) && (gAudioContext.cmdQueueFinished)) { @@ -387,11 +386,11 @@ void Audio_InitMesgQueuesInternal(void) { ARRAY_COUNT(gAudioContext.audioResetMesgs)); } -void Audio_QueueCmd(u32 opArgs, void** data) { +void Audio_QueueCmd(u32 opArgs, u32 data) { AudioCmd* cmd = &gAudioContext.cmdBuf[gAudioContext.cmdWrPos & 0xFF]; cmd->opArgs = opArgs; - cmd->data = *data; + cmd->data = data; gAudioContext.cmdWrPos++; @@ -401,23 +400,28 @@ void Audio_QueueCmd(u32 opArgs, void** data) { } void Audio_QueueCmdF32(u32 opArgs, f32 data) { - Audio_QueueCmd(opArgs, (void**)&data); + union + { + f32 f; + u32 u; + } uData = { .f = data }; + Audio_QueueCmd(opArgs, uData.u); } void Audio_QueueCmdS32(u32 opArgs, s32 data) { - Audio_QueueCmd(opArgs, (void**)&data); + Audio_QueueCmd(opArgs, data); } void Audio_QueueCmdS8(u32 opArgs, s8 data) { u32 uData = data << 0x18; - Audio_QueueCmd(opArgs, (void**)&uData); + Audio_QueueCmd(opArgs, uData); } void Audio_QueueCmdU16(u32 opArgs, u16 data) { u32 uData = data << 0x10; - Audio_QueueCmd(opArgs, (void**)&uData); + Audio_QueueCmd(opArgs, uData); } s32 Audio_ScheduleProcessCmds(void) { @@ -429,8 +433,8 @@ s32 Audio_ScheduleProcessCmds(void) { } ret = - osSendMesg(gAudioContext.cmdProcQueueP, - (void*)(((gAudioContext.cmdRdPos & 0xFF) << 8) | (gAudioContext.cmdWrPos & 0xFF)), OS_MESG_NOBLOCK); + osSendMesg32(gAudioContext.cmdProcQueueP, + (((gAudioContext.cmdRdPos & 0xFF) << 8) | (gAudioContext.cmdWrPos & 0xFF)), OS_MESG_NOBLOCK); if (ret != -1) { gAudioContext.cmdRdPos = gAudioContext.cmdWrPos; ret = 0; @@ -532,11 +536,11 @@ void func_800E5EA4(s32 arg0, u32* arg1, u32* arg2) { s32 func_800E5EDC(void) { s32 pad; - s32 sp18; + OSMesg sp18; - if (osRecvMesg(gAudioContext.audioResetQueueP, (OSMesg*)&sp18, OS_MESG_NOBLOCK) == -1) { + if (osRecvMesg(gAudioContext.audioResetQueueP, &sp18, OS_MESG_NOBLOCK) == -1) { return 0; - } else if (gAudioContext.audioResetSpecIdToLoad != sp18) { + } else if (gAudioContext.audioResetSpecIdToLoad != sp18.data8) { return -1; } else { return 1; @@ -546,7 +550,7 @@ s32 func_800E5EDC(void) { void func_800E5F34(void) { // macro? // clang-format off - s32 chk = -1; s32 sp28; do {} while (osRecvMesg(gAudioContext.audioResetQueueP, (OSMesg*)&sp28, OS_MESG_NOBLOCK) != chk); + s32 chk = -1; OSMesg sp28; do {} while (osRecvMesg(gAudioContext.audioResetQueueP, &sp28, OS_MESG_NOBLOCK) != chk); // clang-format on } diff --git a/soh/src/code/code_800EC960.c b/soh/src/code/code_800EC960.c index 23d1ba375..9a67981ea 100644 --- a/soh/src/code/code_800EC960.c +++ b/soh/src/code/code_800EC960.c @@ -1250,7 +1250,7 @@ s32 Audio_SetGanonDistVol(u8 targetVol); // Function originally not called, so repurposing for DPad input void func_800EC960(u8 dpad) { if (dpad) { - sOcarinaAllowedBtnMask = + sOcarinaAllowedBtnMask = (BTN_A | BTN_CUP | BTN_CDOWN | BTN_CLEFT | BTN_CRIGHT | BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT); sOcarinaABtnMap = BTN_A; sOcarinaCUPBtnMap = BTN_CUP | BTN_DUP; @@ -4095,7 +4095,7 @@ void func_800F4870(u8 arg0) { } // (name derived from debug strings, should probably update. used in ganon/ganon_boss scenes) -s32 Audio_SetGanonDistVol(u8 targetVol) +s32 Audio_SetGanonDistVol(u8 targetVol) { u8 phi_v0; u16 phi_v0_2; @@ -4517,7 +4517,7 @@ void func_800F5C2C(void) { sPrevMainBgmSeqId = NA_BGM_DISABLED; } -void Audio_PlayFanfare(u16 seqId) +void Audio_PlayFanfare(u16 seqId) { u16 sp26; u32 sp20; diff --git a/soh/src/code/code_800F7260.c b/soh/src/code/code_800F7260.c index bd8e4091f..4a6189947 100644 --- a/soh/src/code/code_800F7260.c +++ b/soh/src/code/code_800F7260.c @@ -122,9 +122,9 @@ void Audio_ClearBGMMute(u8 channelIdx) { } } -void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* vol, s8* reverbAdd) +void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* vol, s8* reverbAdd) { - u8 i; + size_t i; SoundRequest* req; if (!gSoundBankMuted[SFX_BANK_SHIFT(sfxId)]) { @@ -204,7 +204,7 @@ void Audio_RemoveMatchingSoundRequests(u8 aspect, SoundBankEntry* cmp) { } } -void Audio_ProcessSoundRequest(void) +void Audio_ProcessSoundRequest(void) { u16 sfxId; u8 count; @@ -307,7 +307,7 @@ void Audio_ProcessSoundRequest(void) } } -void Audio_RemoveSoundBankEntry(u8 bankId, u8 entryIndex) +void Audio_RemoveSoundBankEntry(u8 bankId, u8 entryIndex) { SoundBankEntry* entry = &gSoundBanks[bankId][entryIndex]; u8 i; @@ -335,7 +335,7 @@ void Audio_RemoveSoundBankEntry(u8 bankId, u8 entryIndex) } } -void Audio_ChooseActiveSounds(u8 bankId) +void Audio_ChooseActiveSounds(u8 bankId) { u8 numChosenSounds; u8 numChannels; @@ -492,7 +492,7 @@ void Audio_ChooseActiveSounds(u8 bankId) } } -void Audio_PlayActiveSounds(u8 bankId) +void Audio_PlayActiveSounds(u8 bankId) { u8 entryIndex; SequenceChannel* channel; @@ -553,7 +553,7 @@ void Audio_PlayActiveSounds(u8 bankId) } } -void Audio_StopSfxByBank(u8 bankId) +void Audio_StopSfxByBank(u8 bankId) { SoundBankEntry* entry; s32 pad; @@ -615,7 +615,7 @@ void Audio_StopSfxByPos(Vec3f* pos) { Audio_RemoveMatchingSoundRequests(2, &cmp); } -void Audio_StopSfxByPosAndId(Vec3f* pos, u16 sfxId) +void Audio_StopSfxByPosAndId(Vec3f* pos, u16 sfxId) { SoundBankEntry* entry; u8 entryIndex = gSoundBanks[SFX_BANK(sfxId)][0].next; @@ -735,7 +735,7 @@ void func_800F8F88(void) { } } -u8 Audio_IsSfxPlaying(u32 sfxId) +u8 Audio_IsSfxPlaying(u32 sfxId) { SoundBankEntry* entry; u8 entryIndex = gSoundBanks[SFX_BANK(sfxId)][0].next; diff --git a/soh/src/code/game.c b/soh/src/code/game.c index a411523ec..69b7c0ef7 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -240,7 +240,7 @@ int fbTest = -1; void GameState_Update(GameState* gameState) { GraphicsContext* gfxCtx = gameState->gfxCtx; - if (fbTest == -1) + if (fbTest == -1) { fbTest = gfx_create_framebuffer(64, 112); //fbTest = gfx_create_framebuffer(256, 512); @@ -323,18 +323,18 @@ void GameState_Update(GameState* gameState) { GameState_Draw(gameState, gfxCtx); func_800C49F4(gfxCtx); } - + // ----------------------- // Cheats hooks // ----------------------- - + // Inf Money if (CVar_GetS32("gInfiniteMoney", 0) != 0) { if (gSaveContext.rupees < CUR_CAPACITY(UPG_WALLET)) { gSaveContext.rupees = CUR_CAPACITY(UPG_WALLET); } } - + // Inf Health if (CVar_GetS32("gInfiniteHealth", 0) != 0) { if (gSaveContext.health < gSaveContext.healthCapacity) { @@ -348,33 +348,33 @@ void GameState_Update(GameState* gameState) { if (AMMO(ITEM_STICK) < CUR_CAPACITY(UPG_STICKS)) { AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS); } - + // Deku Nuts if (AMMO(ITEM_NUT) < CUR_CAPACITY(UPG_NUTS)) { AMMO(ITEM_NUT) = CUR_CAPACITY(UPG_NUTS); } - + // Bombs if (AMMO(ITEM_BOMB) < CUR_CAPACITY(UPG_BOMB_BAG)) { AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); } - + // Fairy Bow (Ammo) if (AMMO(ITEM_BOW) < CUR_CAPACITY(UPG_QUIVER)) { AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); } - + // Fairy Slingshot (Ammo) if (AMMO(ITEM_SLINGSHOT) < CUR_CAPACITY(UPG_BULLET_BAG)) { AMMO(ITEM_SLINGSHOT) = CUR_CAPACITY(UPG_BULLET_BAG); } - + // Bombchus (max: 50, no upgrades) if (AMMO(ITEM_BOMBCHU) < 50) { AMMO(ITEM_BOMBCHU) = 50; } } - + // Inf Magic if (CVar_GetS32("gInfiniteMagic", 0) != 0) { if (gSaveContext.magicAcquired && gSaveContext.magic != (gSaveContext.doubleMagic + 1) * 0x30) { @@ -386,7 +386,7 @@ void GameState_Update(GameState* gameState) { if (CVar_GetS32("gInfiniteNayru", 0) != 0) { gSaveContext.nayrusLoveTimer = 0x44B; } - + // Moon Jump On L if (CVar_GetS32("gMoonJumpOnL", 0) != 0) { if (gGlobalCtx) { @@ -424,7 +424,7 @@ void GameState_Update(GameState* gameState) { } else { CVar_SetS32("gPrevTime", -1); } - + //since our CVar is same value and properly default to 0 there is not problems doing this in single line. gSaveContext.language = CVar_GetS32("gLanguages", 0); @@ -525,7 +525,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g } SpeedMeter_Init(&D_801664D0); func_800AA0B4(); - osSendMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK); + osSendMesgPtr(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK); endTime = osGetTime(); // "Other initialization processing time %d us" diff --git a/soh/src/code/graph.c b/soh/src/code/graph.c index 651d405d5..ca0c9511a 100644 --- a/soh/src/code/graph.c +++ b/soh/src/code/graph.c @@ -170,12 +170,12 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) { D_8016A528 = osGetTime() - sGraphSetTaskTime - D_8016A558; - osSetTimer(&timer, OS_USEC_TO_CYCLES(3000000), 0, &gfxCtx->queue, (OSMesg)666); + osSetTimer(&timer, OS_USEC_TO_CYCLES(3000000), 0, &gfxCtx->queue, OS_MESG_32(666)); osRecvMesg(&gfxCtx->queue, &msg, OS_MESG_BLOCK); osStopTimer(&timer); //OTRTODO - Proper GFX crash handler - #if 0 + #if 0 if (msg == (OSMesg)666) { osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("RCPが帰ってきませんでした。"); // "RCP did not return." @@ -194,7 +194,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) { } Fault_AddHungupAndCrashImpl("RCP is HUNG UP!!", "Oh! MY GOD!!"); } - #endif + #endif osRecvMesg(&gfxCtx->queue, &msg, OS_MESG_NOBLOCK); D_8012D260 = gfxCtx->workBuffer; @@ -243,7 +243,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) { } scTask->msgQ = &gfxCtx->queue; - scTask->msg = NULL; + scTask->msg.ptr = NULL; cfb = &sGraphCfbInfos[sGraphCfbInfoIdx++]; cfb->fb1 = gfxCtx->curFrameBuffer; @@ -262,7 +262,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) { gfxCtx->schedMsgQ = &gSchedContext.cmdQ; - osSendMesg(&gSchedContext.cmdQ, scTask, OS_MESG_BLOCK); + osSendMesgPtr(&gSchedContext.cmdQ, scTask, OS_MESG_BLOCK); Sched_SendEntryMsg(&gSchedContext); } @@ -399,7 +399,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) { sGraphUpdateTime = time; } - if (CVar_GetS32("gDebugEnabled", 0)) + if (CVar_GetS32("gDebugEnabled", 0)) { if (CHECK_BTN_ALL(gameState->input[0].press.button, BTN_Z) && CHECK_BTN_ALL(gameState->input[0].cur.button, BTN_L | BTN_R)) { @@ -475,14 +475,14 @@ static void RunFrame() { uint64_t ticksA, ticksB; ticksA = GetPerfCounter(); - + Graph_StartFrame(); // TODO: Workaround for rumble being too long. Implement os thread functions. for (int i = 0; i < 3; i++) { PadMgr_ThreadEntry(&gPadMgr); } - + Graph_Update(&runFrameContext.gfxCtx, runFrameContext.gameState); ticksB = GetPerfCounter(); diff --git a/soh/src/code/irqmgr.c b/soh/src/code/irqmgr.c index 6e7118bff..43d61ad71 100644 --- a/soh/src/code/irqmgr.c +++ b/soh/src/code/irqmgr.c @@ -32,11 +32,11 @@ void IrqMgr_AddClient(IrqMgr* this, IrqMgrClient* c, OSMesgQueue* msgQ) { osSetIntMask(prevInt); if (this->resetStatus > STATUS_IDLE) { - osSendMesg(c->queue, (OSMesg) & this->prenmiMsg, OS_MESG_NOBLOCK); + osSendMesgPtr(c->queue, &this->prenmiMsg, OS_MESG_NOBLOCK); } if (this->resetStatus >= STATUS_NMI) { - osSendMesg(c->queue, (OSMesg) & this->nmiMsg, OS_MESG_NOBLOCK); + osSendMesgPtr(c->queue, &this->nmiMsg, OS_MESG_NOBLOCK); } } @@ -107,8 +107,8 @@ void IrqMgr_HandlePreNMI(IrqMgr* this) { this->resetStatus = STATUS_PRENMI; sIrqMgrResetTime = this->resetTime = osGetTime(); - osSetTimer(&this->timer, OS_USEC_TO_CYCLES(450000), 0ull, &this->queue, (OSMesg)PRENMI450_MSG); - IrqMgr_JamMesgForClient(this, (OSMesg) & this->prenmiMsg); + osSetTimer(&this->timer, OS_USEC_TO_CYCLES(450000), 0ull, &this->queue, OS_MESG_32(PRENMI450_MSG)); + IrqMgr_JamMesgForClient(this, OS_MESG_PTR(&this->prenmiMsg)); } void IrqMgr_CheckStack() { @@ -131,19 +131,19 @@ void IrqMgr_HandlePRENMI450(IrqMgr* this) { gIrqMgrResetStatus = temp; this->resetStatus = STATUS_NMI; - osSetTimer(&this->timer, OS_USEC_TO_CYCLES(30000), 0ull, &this->queue, (OSMesg)PRENMI480_MSG); - IrqMgr_SendMesgForClient(this, (OSMesg) & this->nmiMsg); + osSetTimer(&this->timer, OS_USEC_TO_CYCLES(30000), 0ull, &this->queue, OS_MESG_32(PRENMI480_MSG)); + IrqMgr_SendMesgForClient(this, OS_MESG_PTR(&this->nmiMsg)); } void IrqMgr_HandlePRENMI480(IrqMgr* this) { u32 ret; - osSetTimer(&this->timer, OS_USEC_TO_CYCLES(20000), 0ull, &this->queue, (OSMesg)PRENMI500_MSG); + osSetTimer(&this->timer, OS_USEC_TO_CYCLES(20000), 0ull, &this->queue, OS_MESG_32(PRENMI500_MSG)); ret = osAfterPreNMI(); if (ret) { // "osAfterPreNMI returned %d !?" osSyncPrintf("osAfterPreNMIが %d を返しました!?\n", ret); - osSetTimer(&this->timer, OS_USEC_TO_CYCLES(1000), 0ull, &this->queue, (OSMesg)PRENMI480_MSG); + osSetTimer(&this->timer, OS_USEC_TO_CYCLES(1000), 0ull, &this->queue, OS_MESG_32(PRENMI480_MSG)); } } @@ -160,7 +160,7 @@ void IrqMgr_HandleRetrace(IrqMgr* this) { } } sIrqMgrRetraceCount++; - IrqMgr_SendMesgForClient(this, (OSMesg) & this->retraceMsg); + IrqMgr_SendMesgForClient(this, OS_MESG_PTR(&this->retraceMsg)); } void IrqMgr_ThreadEntry(void* arg0) { @@ -168,13 +168,13 @@ void IrqMgr_ThreadEntry(void* arg0) { IrqMgr* this = (IrqMgr*)arg0; u8 exit; - msg = 0; + msg.data32 = 0; osSyncPrintf("IRQマネージャスレッド実行開始\n"); // "Start IRQ manager thread execution" exit = false; while (!exit) { osRecvMesg(&this->queue, &msg, OS_MESG_BLOCK); - switch ((u32)msg) { + switch (msg.data32) { case RETRACE_MSG: IrqMgr_HandleRetrace(this); break; @@ -225,8 +225,8 @@ void IrqMgr_Init(IrqMgr* this, void* stack, OSPri pri, u8 retraceCount) { this->resetTime = 0; osCreateMesgQueue(&this->queue, this->msgBuf, ARRAY_COUNT(this->msgBuf)); - osSetEventMesg(OS_EVENT_PRENMI, &this->queue, (OSMesg)PRE_NMI_MSG); - osViSetEvent(&this->queue, (OSMesg)RETRACE_MSG, retraceCount); + osSetEventMesg(OS_EVENT_PRENMI, &this->queue, OS_MESG_32(PRE_NMI_MSG)); + osViSetEvent(&this->queue, OS_MESG_32(RETRACE_MSG), retraceCount); osCreateThread(&this->thread, 0x13, IrqMgr_ThreadEntry, this, stack, pri); osStartThread(&this->thread); } diff --git a/soh/src/code/main.c b/soh/src/code/main.c index 0680aad3e..35435815c 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" @@ -87,7 +87,7 @@ void Main(void* arg) { R_ENABLE_ARENA_DBG = 0; osCreateMesgQueue(&sSiIntMsgQ, sSiIntMsgBuf, 1); - osSetEventMesg(5, &sSiIntMsgQ, 0); + osSetEventMesg(5, &sSiIntMsgQ, OS_MESG_PTR(NULL)); Main_LogSystemHeap(); @@ -118,7 +118,7 @@ void Main(void* arg) { while (true) { msg = NULL; - osRecvMesg(&irqMgrMsgQ, (OSMesg)&msg, OS_MESG_BLOCK); + osRecvMesg(&irqMgrMsgQ, (OSMesg*)&msg, OS_MESG_BLOCK); if (msg == NULL) { break; } diff --git a/soh/src/code/padmgr.c b/soh/src/code/padmgr.c index b467f5ee6..c650639df 100644 --- a/soh/src/code/padmgr.c +++ b/soh/src/code/padmgr.c @@ -20,7 +20,7 @@ OSMesgQueue* PadMgr_LockSerialMesgQueue(PadMgr* padMgr) { padMgr->serialMsgQ.validCount, padMgr, &padMgr->serialMsgQ, &ctrlrQ); } - osRecvMesg(&padMgr->serialMsgQ, (OSMesg)&ctrlrQ, OS_MESG_BLOCK); + osRecvMesg(&padMgr->serialMsgQ, (OSMesg*)&ctrlrQ, OS_MESG_BLOCK); if (D_8012D280 > 2) { // "serialMsgQ Locked" @@ -38,7 +38,7 @@ void PadMgr_UnlockSerialMesgQueue(PadMgr* padMgr, OSMesgQueue* ctrlrQ) { padMgr->serialMsgQ.validCount, padMgr, &padMgr->serialMsgQ, ctrlrQ); } - osSendMesg(&padMgr->serialMsgQ, ctrlrQ, OS_MESG_BLOCK); + osSendMesgPtr(&padMgr->serialMsgQ, ctrlrQ, OS_MESG_BLOCK); if (D_8012D280 > 2) { // "serialMsgQ Unlocked" @@ -52,7 +52,7 @@ void PadMgr_LockPadData(PadMgr* padMgr) { } void PadMgr_UnlockPadData(PadMgr* padMgr) { - osSendMesg(&padMgr->lockMsgQ, NULL, OS_MESG_BLOCK); + osSendMesgPtr(&padMgr->lockMsgQ, NULL, OS_MESG_BLOCK); } void PadMgr_RumbleControl(PadMgr* padMgr) { @@ -174,7 +174,7 @@ void PadMgr_RumbleStop(PadMgr* padMgr) { for (i = 0; i < 4; i++) { if (osMotorInit(ctrlrQ, &padMgr->pfs[i], i) == 0) { #if 0 - if ((gFaultStruct.msgId == 0) && (padMgr->rumbleOnFrames != 0)) + if ((gFaultStruct.msgId == 0) && (padMgr->rumbleOnFrames != 0)) { osSyncPrintf(VT_FGCOL(YELLOW)); // "Stop vibration pack" @@ -399,7 +399,7 @@ void PadMgr_ThreadEntry(PadMgr* padMgr) { osSyncPrintf("コントローラスレッドイベント待ち %lld\n", OS_CYCLES_TO_USEC(osGetTime())); } - osRecvMesg(&padMgr->interruptMsgQ, (OSMesg)&mesg, OS_MESG_BLOCK); + osRecvMesg(&padMgr->interruptMsgQ, (OSMesg*)&mesg, OS_MESG_BLOCK); //LogUtils_CheckNullPointer("msg", mesg, "../padmgr.c", 563); PadMgr_HandleRetraceMsg(padMgr); diff --git a/soh/src/code/sched.c b/soh/src/code/sched.c index 38b51bcde..4bc314491 100644 --- a/soh/src/code/sched.c +++ b/soh/src/code/sched.c @@ -84,12 +84,12 @@ void Sched_HandleReset(SchedContext* sc) { if (sc->curRSPTask != NULL) { LOG_TIME("(((u64)(now - graph_rsp_start_time)*(1000000LL/15625LL))/((62500000LL*3/4)/15625LL))", OS_CYCLES_TO_USEC(now - sRSPGFXStartTime), "../sched.c", 427); - osSendMesg(&sc->interruptQ, RSP_DONE_MSG, OS_MESG_NOBLOCK); + osSendMesg32(&sc->interruptQ, RSP_DONE_MSG, OS_MESG_NOBLOCK); } if (sc->curRDPTask != NULL) { LOG_TIME("(((u64)(now - rdp_start_time)*(1000000LL/15625LL))/((62500000LL*3/4)/15625LL))", OS_CYCLES_TO_USEC(now - sRDPStartTime), "../sched.c", 431); - osSendMesg(&sc->interruptQ, RDP_DONE_MSG, OS_MESG_NOBLOCK); + osSendMesg32(&sc->interruptQ, RDP_DONE_MSG, OS_MESG_NOBLOCK); } } } @@ -294,10 +294,10 @@ void Sched_HandleEntry(SchedContext* sc) { OSScTask* nextRSP = NULL; OSScTask* nextRDP = NULL; s32 state; - OSMesg msg = NULL; + OSMesg msg = OS_MESG_PTR(NULL); while (osRecvMesg(&sc->cmdQ, &msg, OS_MESG_NOBLOCK) != -1) { - Sched_QueueTask(sc, msg); + Sched_QueueTask(sc, msg.ptr); } if (sc->doAudio != 0 && sc->curRSPTask != NULL) { @@ -427,14 +427,14 @@ void Sched_SendEntryMsg(SchedContext* sc) { osSyncPrintf("osScKickEntryMsg\n"); } - osSendMesg(&sc->interruptQ, ENTRY_MSG, OS_MESG_BLOCK); + osSendMesg32(&sc->interruptQ, ENTRY_MSG, OS_MESG_BLOCK); } void Sched_ThreadEntry(void* arg) { - void* msg; + OSMesg msg; SchedContext* sc = (SchedContext*)arg; - msg = NULL; + msg.ptr = NULL; while (true) { if (sLogScheduler) { @@ -444,7 +444,7 @@ void Sched_ThreadEntry(void* arg) { osRecvMesg(&sc->interruptQ, &msg, OS_MESG_BLOCK); - switch ((s32)msg) { + switch (msg.data32) { case ENTRY_MSG: if (sLogScheduler) { osSyncPrintf("%08d:ENTRY_MSG\n", (u32)OS_CYCLES_TO_USEC(osGetTime())); @@ -466,7 +466,7 @@ void Sched_ThreadEntry(void* arg) { default: break; } - switch (((OSScMsg*)msg)->type) { + switch (((OSScMsg*)msg.ptr)->type) { case 1: Sched_HandleRetrace(sc); continue; @@ -485,8 +485,8 @@ void Sched_Init(SchedContext* sc, void* stack, OSPri priority, UNK_TYPE arg3, UN sc->unk_24C = 1; osCreateMesgQueue(&sc->interruptQ, sc->intBuf, 8); osCreateMesgQueue(&sc->cmdQ, sc->cmdMsgBuf, 8); - osSetEventMesg(OS_EVENT_SP, &sc->interruptQ, RSP_DONE_MSG); - osSetEventMesg(OS_EVENT_DP, &sc->interruptQ, RDP_DONE_MSG); + osSetEventMesg(OS_EVENT_SP, &sc->interruptQ, OS_MESG_32(RSP_DONE_MSG)); + osSetEventMesg(OS_EVENT_DP, &sc->interruptQ, OS_MESG_32(RDP_DONE_MSG)); IrqMgr_AddClient(irqMgr, &sc->irqClient, &sc->interruptQ); osCreateThread(&sc->thread, 5, Sched_ThreadEntry, sc, stack, priority); osStartThread(&sc->thread); diff --git a/soh/src/code/sleep.c b/soh/src/code/sleep.c index f08129701..c637520e7 100644 --- a/soh/src/code/sleep.c +++ b/soh/src/code/sleep.c @@ -6,7 +6,7 @@ void Sleep_Cycles(OSTime cycles) { OSTimer timer; osCreateMesgQueue(&mq, &msg, OS_MESG_BLOCK); - osSetTimer(&timer, cycles, 0, &mq, NULL); + osSetTimer(&timer, cycles, 0, &mq, OS_MESG_PTR(NULL)); osRecvMesg(&mq, NULL, OS_MESG_BLOCK); } diff --git a/soh/src/code/z_bgcheck.c b/soh/src/code/z_bgcheck.c index 811b0bea1..130351f42 100644 --- a/soh/src/code/z_bgcheck.c +++ b/soh/src/code/z_bgcheck.c @@ -1584,6 +1584,11 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis &colCtx->subdivLength.y, &colCtx->subdivLengthInv.y); BgCheck_SetSubdivisionDimension(colCtx->minBounds.z, colCtx->subdivAmount.z, &colCtx->maxBounds.z, &colCtx->subdivLength.z, &colCtx->subdivLengthInv.z); + +#ifdef _SOH64 // BGCheck needs more memory on 64 bits because it crashes on some areas + colCtx->memSize *= 2; +#endif + memSize = colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y * colCtx->subdivAmount.z + colCtx->colHeader->numPolygons * sizeof(u8) + colCtx->dyna.polyNodesMax * sizeof(SSNode) + colCtx->dyna.polyListMax * sizeof(CollisionPoly) + colCtx->dyna.vtxListMax * sizeof(Vec3s) + @@ -3787,7 +3792,7 @@ void CollisionHeader_SegmentedToVirtual(CollisionHeader* colHeader) { /** * Convert CollisionHeader Segmented to Virtual addressing */ -void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest) +void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest) { if (ResourceMgr_OTRSigCheck(colHeader)) colHeader = ResourceMgr_LoadColByName(colHeader); diff --git a/soh/src/code/z_kanfont.c b/soh/src/code/z_kanfont.c index c7f3234bb..c774ac07f 100644 --- a/soh/src/code/z_kanfont.c +++ b/soh/src/code/z_kanfont.c @@ -183,7 +183,7 @@ void Font_LoadChar(Font* font, u8 character, u16 codePointIndex) { * The different icons are given in the MessageBoxIcon enum. */ void Font_LoadMessageBoxIcon(Font* font, u16 icon) { - memcpy(font->iconBuf, msgStaticTbl[4 + icon], FONT_CHAR_TEX_SIZE); + memcpy(font->iconBuf, ResourceMgr_LoadTexByName(msgStaticTbl[4 + icon]), FONT_CHAR_TEX_SIZE); } /** @@ -194,7 +194,7 @@ void Font_LoadOrderedFont(Font* font) { size_t len; size_t jj; s32 fontStatic; - u32 fontBuf; + u8* fontBuf; s32 codePointIndex; s32 fontBufIndex; s32 offset; diff --git a/soh/src/code/z_lifemeter.c b/soh/src/code/z_lifemeter.c index e45850a73..79a1f89eb 100644 --- a/soh/src/code/z_lifemeter.c +++ b/soh/src/code/z_lifemeter.c @@ -136,7 +136,7 @@ void HealthMeter_Init(GlobalContext* globalCtx) { HeartDDOutline[1] = HEARTS_DD_PRIM_G; HeartDDOutline[2] = HEARTS_DD_PRIM_B; } - + interfaceCtx->unk_228 = 0x140; interfaceCtx->unk_226 = gSaveContext.health; interfaceCtx->unk_22A = interfaceCtx->unk_1FE = 0; @@ -162,9 +162,9 @@ void HealthMeter_Init(GlobalContext* globalCtx) { sHeartsDDPrim[0][1] = sHeartsDDPrim[1][1] = HeartDDOutline[1]; sHeartsDDPrim[0][2] = sHeartsDDPrim[1][2] = HeartDDOutline[2]; - sHeartsDDPrim[2][0] = HeartInner[0]; - sHeartsDDPrim[2][1] = HeartInner[1]; - sHeartsDDPrim[2][2] = HeartInner[2]; + // sHeartsDDPrim[2][0] = HeartInner[0]; + // sHeartsDDPrim[2][1] = HeartInner[1]; + // sHeartsDDPrim[2][2] = HeartInner[2]; sHeartsDDEnv[0][0] = sHeartsDDEnv[1][0] = HeartDDInner[0]; sHeartsDDEnv[0][1] = sHeartsDDEnv[1][1] = HeartDDInner[1]; @@ -274,11 +274,11 @@ void HealthMeter_Update(GlobalContext* globalCtx) { sHeartsDDEnv[0][2] = HeartDDInner[2]; if (CVar_GetS32("gHudColors", 1) == 2) { - sHeartsDDPrim[2][0] = HeartInner[0]; + sHeartsDDPrim[2][0] = HeartInner[0]; sHeartsDDPrim[2][1] = HeartInner[1]; sHeartsDDPrim[2][2] = HeartInner[2]; - sHeartsDDPrim[1][0] = HeartDDOutline[0]; + sHeartsDDPrim[1][0] = HeartDDOutline[0]; sHeartsDDPrim[1][1] = HeartDDOutline[1]; sHeartsDDPrim[1][2] = HeartDDOutline[2]; @@ -286,7 +286,7 @@ void HealthMeter_Update(GlobalContext* globalCtx) { sHeartsDDEnv[1][1] = HeartDDInner[1]; sHeartsDDEnv[1][2] = HeartDDInner[2]; - HeartDDInner[0] = HeartInner[0]; + HeartDDInner[0] = HeartInner[0]; HeartDDInner[1] = HeartInner[1]; HeartDDInner[2] = HeartInner[2]; @@ -306,9 +306,9 @@ void HealthMeter_Update(GlobalContext* globalCtx) { sBeatingHeartsDDEnv[1] = (u8)(gFactor + HeartDDInner[1]) & 0xFF; sBeatingHeartsDDEnv[2] = (u8)(bFactor + HeartDDInner[2]) & 0xFF; } else { - sHeartsDDPrim[2][0] = HEARTS_PRIM_R; - sHeartsDDPrim[2][1] = HEARTS_PRIM_G; - sHeartsDDPrim[2][2] = HEARTS_PRIM_B; + // sHeartsDDPrim[2][0] = HEARTS_PRIM_R; + // sHeartsDDPrim[2][1] = HEARTS_PRIM_G; + // sHeartsDDPrim[2][2] = HEARTS_PRIM_B; sHeartsDDPrim[1][0] = HEARTS_DD_PRIM_R; sHeartsDDPrim[1][1] = HEARTS_DD_PRIM_G; diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 84cf20e71..b17a2af56 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -1153,14 +1153,16 @@ void Message_LoadItemIcon(GlobalContext* globalCtx, u16 itemId, s16 y) { R_TEXTBOX_ICON_XPOS = R_TEXT_INIT_XPOS - sIconItem32XOffsets[gSaveContext.language]; R_TEXTBOX_ICON_YPOS = y + 6; R_TEXTBOX_ICON_SIZE = 32; - memcpy((uintptr_t)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, gItemIcons[itemId], 0x1000); + memcpy((uintptr_t)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, + ResourceMgr_LoadTexByName(gItemIcons[itemId]), 0x1000); // "Item 32-0" osSyncPrintf("アイテム32-0\n"); } else { R_TEXTBOX_ICON_XPOS = R_TEXT_INIT_XPOS - sIconItem24XOffsets[gSaveContext.language]; R_TEXTBOX_ICON_YPOS = y + 10; R_TEXTBOX_ICON_SIZE = 24; - memcpy((uintptr_t)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, gItemIcons[itemId], 0x900); + memcpy((uintptr_t)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, + ResourceMgr_LoadTexByName(gItemIcons[itemId]), 0x900); // "Item 24" osSyncPrintf("アイテム24=%d (%d) {%d}\n", itemId, itemId - ITEM_KOKIRI_EMERALD, 84); } @@ -3302,7 +3304,7 @@ void Message_Update(GlobalContext* globalCtx) { void Message_SetTables(void) { OTRMessage_Init(); - + // OTRTODO //sNesMessageEntryTablePtr = sNesMessageEntryTable; //sGerMessageEntryTablePtr = sGerMessageEntryTable; diff --git a/soh/src/code/z_msgevent.c b/soh/src/code/z_msgevent.c index 267180e1f..7ea6521ed 100644 --- a/soh/src/code/z_msgevent.c +++ b/soh/src/code/z_msgevent.c @@ -10,11 +10,11 @@ void MsgEvent_SendNullTask(void) { task.next = NULL; task.flags = OS_SC_RCP_MASK; task.msgQ = &queue; - task.msg = NULL; + task.msg.ptr = NULL; task.framebuffer = NULL; task.list.t.type = M_NULTASK; osCreateMesgQueue(task.msgQ, &msg, 1); - osSendMesg(&gSchedContext.cmdQ, &task, OS_MESG_BLOCK); + osSendMesgPtr(&gSchedContext.cmdQ, &task, OS_MESG_BLOCK); Sched_SendEntryMsg(&gSchedContext); osRecvMesg(&queue, NULL, OS_MESG_BLOCK); } diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 14d677219..f53e35b7c 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1317,7 +1317,7 @@ void Interface_LoadItemIcon1(GlobalContext* globalCtx, u16 button) { osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, interfaceCtx->iconItemSegment + button * 0x1000, (uintptr_t)_icon_item_staticSegmentRomStart + (gSaveContext.equips.buttonItems[button] * 0x1000), - 0x1000, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1171); + 0x1000, 0, &interfaceCtx->loadQueue, OS_MESG_PTR(NULL), "../z_parameter.c", 1171); osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); } @@ -1327,7 +1327,7 @@ void Interface_LoadItemIcon2(GlobalContext* globalCtx, u16 button) { osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_180, interfaceCtx->iconItemSegment + button * 0x1000, (uintptr_t)_icon_item_staticSegmentRomStart + (gSaveContext.equips.buttonItems[button] * 0x1000), - 0x1000, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1193); + 0x1000, 0, &interfaceCtx->loadQueue, OS_MESG_PTR(NULL), "../z_parameter.c", 1193); osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); } @@ -2164,7 +2164,7 @@ void Interface_SetNaviCall(GlobalContext* globalCtx, u16 naviCallState) { if (((naviCallState == 0x1D) || (naviCallState == 0x1E)) && !interfaceCtx->naviCalling && (globalCtx->csCtx.state == CS_STATE_IDLE)) { - if (!CVar_GetS32("gDisableNaviCallAudio", 0)) { + if (!CVar_GetS32("gDisableNaviCallAudio", 0)) { // clang-format off if (naviCallState == 0x1E) { Audio_PlaySoundGeneral(NA_SE_VO_NAVY_CALL, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } @@ -2884,7 +2884,7 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 0); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - + //There is probably a more elegant way to do it. char* doAction = actionsTbl[3]; char newName[512]; @@ -2903,7 +2903,7 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { doAction = newName; } memcpy(interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE * 2, ResourceMgr_LoadTexByName(doAction), DO_ACTION_TEX_SIZE); - + gDPLoadTextureBlock_4b(OVERLAY_DISP++, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE * 2, G_IM_FMT_IA, DO_ACTION_TEX_WIDTH, DO_ACTION_TEX_HEIGHT, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -2987,8 +2987,8 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { //This later will feature color per C button right now that it. gDPSetPrimColor(OVERLAY_DISP++, 0, 0, CVar_GetS32("gCCCBtnPrimR", R_C_BTN_COLOR(0)), CVar_GetS32("gCCCBtnPrimG", R_C_BTN_COLOR(1)), CVar_GetS32("gCCCBtnPrimB", R_C_BTN_COLOR(2)), interfaceCtx->cRightAlpha); } - - OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, ((u8*)gButtonBackgroundTex), 32, 32, + + OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, ((u8*)gButtonBackgroundTex), 32, 32, OTRGetRectDimensionFromRightEdge(R_ITEM_BTN_X(temp)+Right_HUD_Margin), R_ITEM_BTN_Y(temp)+(Top_HUD_Margin*-1), R_ITEM_BTN_WIDTH(temp), R_ITEM_BTN_WIDTH(temp), R_ITEM_BTN_DD(temp) << 1, R_ITEM_BTN_DD(temp) << 1); @@ -3073,7 +3073,7 @@ void Interface_DrawAmmoCount(GlobalContext* globalCtx, s16 button, s16 alpha) { } if (i != 0) { - OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, (u8*)_gAmmoDigit0Tex[i], 8, 8, + OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, (u8*)_gAmmoDigit0Tex[i], 8, 8, OTRGetRectDimensionFromRightEdge(R_ITEM_AMMO_X(button)+Right_HUD_Margin), R_ITEM_AMMO_Y(button)+(Top_HUD_Margin*-1), 8, 8, 1 << 10, 1 << 10); } @@ -3444,11 +3444,11 @@ void Interface_Draw(GlobalContext* globalCtx) { if ((player->stateFlags1 & 0x00800000) || (globalCtx->shootingGalleryStatus > 1) || ((globalCtx->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(globalCtx, 0x38))) { - + if (!fullUi) { Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[0]], 0); } - + gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); @@ -4070,7 +4070,7 @@ void Interface_Draw(GlobalContext* globalCtx) { for (svar1 = 0; svar1 < 5; svar1++) { // clang-format off - svar5 = OTRGetRectDimensionFromLeftEdge(gSaveContext.timerX[svar6]); + svar5 = OTRGetRectDimensionFromLeftEdge(gSaveContext.timerX[svar6]); OVERLAY_DISP = Gfx_TextureI8(OVERLAY_DISP, digitTextures[timerDigits[svar1]], 8, 16, svar5 + timerDigitLeftPos[svar1], svar2 = gSaveContext.timerY[svar6], digitWidth[svar1], VREG(42), VREG(43) << 1, diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 4e48fc512..0850ba5db 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -198,8 +198,8 @@ void Gameplay_Init(GameState* thisx) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; gGlobalCtx = globalCtx; //globalCtx->state.gfxCtx = NULL; - u32 zAlloc; - u32 zAllocAligned; + uintptr_t zAlloc; + uintptr_t zAllocAligned; size_t zAllocSize; Player* player; s32 playerStartCamId; diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 77c569951..d40aeab99 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -363,13 +363,13 @@ void Player_SetModelsForHoldingShield(Player* this) { if ((CVar_GetS32("gShieldTwoHanded", 0) && (this->heldItemActionParam != PLAYER_AP_STICK) || !Player_HoldsTwoHandedWeapon(this)) && !Player_IsChildWithHylianShield(this)) { this->rightHandType = 10; - this->rightHandDLists = &sPlayerDListGroups[10][(void)0, gSaveContext.linkAge]; + this->rightHandDLists = &sPlayerDListGroups[10][gSaveContext.linkAge]; if (this->sheathType == 18) { this->sheathType = 16; } else if (this->sheathType == 19) { this->sheathType = 17; } - this->sheathDLists = &sPlayerDListGroups[this->sheathType][(void)0, gSaveContext.linkAge]; + this->sheathDLists = &sPlayerDListGroups[this->sheathType][gSaveContext.linkAge]; this->modelAnimType = 2; this->itemActionParam = -1; } @@ -381,10 +381,10 @@ void Player_SetModels(Player* this, s32 modelGroup) { this->rightHandType = gPlayerModelTypes[modelGroup][2]; this->sheathType = gPlayerModelTypes[modelGroup][3]; - this->leftHandDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][1]][(void)0, gSaveContext.linkAge]; - this->rightHandDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][2]][(void)0, gSaveContext.linkAge]; - this->sheathDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][3]][(void)0, gSaveContext.linkAge]; - this->waistDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][4]][(void)0, gSaveContext.linkAge]; + this->leftHandDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][1]][gSaveContext.linkAge]; + this->rightHandDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][2]][gSaveContext.linkAge]; + this->sheathDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][3]][gSaveContext.linkAge]; + this->waistDLists = &sPlayerDListGroups[gPlayerModelTypes[modelGroup][4]][gSaveContext.linkAge]; Player_SetModelsForHoldingShield(this); } @@ -859,15 +859,15 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime, (Player_ActionToMagicSpell(this, this->itemActionParam) < 0)) { s32 pad; - sp7C = D_80126058[(void)0, gSaveContext.linkAge]; - sp78 = D_80126060[(void)0, gSaveContext.linkAge]; - sp74 = D_80126068[(void)0, gSaveContext.linkAge] - this->unk_6C4; + sp7C = D_80126058[gSaveContext.linkAge]; + sp78 = D_80126060[gSaveContext.linkAge]; + sp74 = D_80126068[gSaveContext.linkAge] - this->unk_6C4; Matrix_Push(); Matrix_TranslateRotateZYX(pos, rot); Matrix_MultVec3f(&D_8012602C, &spA4); - Matrix_TranslateRotateZYX(&D_80126038[(void)0, gSaveContext.linkAge], &skelAnime->jointTable[shinLimbIndex]); - Matrix_Translate(D_80126050[(void)0, gSaveContext.linkAge], 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_TranslateRotateZYX(&D_80126038[gSaveContext.linkAge], &skelAnime->jointTable[shinLimbIndex]); + Matrix_Translate(D_80126050[gSaveContext.linkAge], 0.0f, 0.0f, MTXMODE_APPLY); Matrix_MultVec3f(&D_8012602C, &sp98); Matrix_MultVec3f(&D_80126070, &footprintPos); Matrix_Pop(); @@ -1055,16 +1055,16 @@ s32 func_800902F0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p if (this->unk_6AD != 2) { *dList = NULL; } else if (limbIndex == PLAYER_LIMB_L_FOREARM) { - *dList = sArmOutDLs[(void)0, gSaveContext.linkAge]; + *dList = sArmOutDLs[gSaveContext.linkAge]; } else if (limbIndex == PLAYER_LIMB_L_HAND) { - *dList = sHandOutDLs[(void)0, gSaveContext.linkAge]; + *dList = sHandOutDLs[gSaveContext.linkAge]; } else if (limbIndex == PLAYER_LIMB_R_SHOULDER) { - *dList = sRightShoulderNearDLs[(void)0, gSaveContext.linkAge]; + *dList = sRightShoulderNearDLs[gSaveContext.linkAge]; } else if (limbIndex == PLAYER_LIMB_R_FOREARM) { - *dList = D_80125F30[(void)0, gSaveContext.linkAge]; + *dList = D_80125F30[gSaveContext.linkAge]; } else if (limbIndex == PLAYER_LIMB_R_HAND) { *dList = Player_HoldsHookshot(this) ? gLinkAdultRightHandHoldingHookshotFarDL - : sHoldingFirstPersonWeaponDLs[(void)0, gSaveContext.linkAge]; + : sHoldingFirstPersonWeaponDLs[gSaveContext.linkAge]; } else { *dList = NULL; } @@ -1348,7 +1348,7 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player_lib.c", 2712), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetEnvColor(POLY_XLU_DISP++, bottleColor->r, bottleColor->g, bottleColor->b, 0); - gSPDisplayList(POLY_XLU_DISP++, sBottleDLists[((void)0, gSaveContext.linkAge)]); + gSPDisplayList(POLY_XLU_DISP++, sBottleDLists[(gSaveContext.linkAge)]); CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2717); } @@ -1479,7 +1479,7 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } else if (limbIndex == PLAYER_LIMB_HEAD) { Matrix_MultVec3f(&D_801260D4, &this->actor.focus.pos); } else { - Vec3f* vec = &D_801261E0[((void)0, gSaveContext.linkAge)]; + Vec3f* vec = &D_801261E0[(gSaveContext.linkAge)]; Actor_SetFeetPos(&this->actor, limbIndex, PLAYER_LIMB_L_FOOT, vec, PLAYER_LIMB_R_FOOT, vec); } @@ -1487,7 +1487,7 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime) { - s16 linkObjectId = gLinkObjectIds[(void)0, gSaveContext.linkAge]; + s16 linkObjectId = gLinkObjectIds[gSaveContext.linkAge]; size_t size; void* ptr; @@ -1504,7 +1504,7 @@ u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime) { gSegments[4] = VIRTUAL_TO_PHYSICAL(segment + 0x3800); gSegments[6] = VIRTUAL_TO_PHYSICAL(segment + 0x8800); - SkelAnime_InitLink(globalCtx, skelAnime, gPlayerSkelHeaders[(void)0, gSaveContext.linkAge], &gPlayerAnim_003238, 9, + SkelAnime_InitLink(globalCtx, skelAnime, gPlayerSkelHeaders[gSaveContext.linkAge], &gPlayerAnim_003238, 9, ptr, ptr, PLAYER_LIMB_MAX); return size + 0x8800 + 0x90; @@ -1518,6 +1518,7 @@ s32 func_80091880(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p s32 type; s32 dListOffset = 0; Gfx** dLists; + size_t ptrSize = sizeof(uint32_t); if ((modelGroup == 2) && !LINK_IS_ADULT && (ptr[1] == 2)) { modelGroup = 1; @@ -1537,12 +1538,12 @@ s32 func_80091880(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p type = gPlayerModelTypes[modelGroup][2]; D_80160018 = type; if (type == 10) { - dListOffset = ptr[1] * sizeof(uintptr_t); + dListOffset = ptr[1] * ptrSize; } } else if (limbIndex == PLAYER_LIMB_SHEATH) { type = gPlayerModelTypes[modelGroup][3]; if ((type == 18) || (type == 19)) { - dListOffset = ptr[1] * sizeof(uintptr_t); + dListOffset = ptr[1] * ptrSize; } else if (type == 16 && CVar_GetS32("gPauseLiveLink", 0)) { //if (ptr[0] == 1) //dListOffset = 4; @@ -1553,7 +1554,7 @@ s32 func_80091880(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return 0; } - dLists = &sPlayerDListGroups[type][(void)0, gSaveContext.linkAge]; + dLists = &sPlayerDListGroups[type][gSaveContext.linkAge]; *dList = dLists[dListOffset]; return 0; @@ -1609,7 +1610,7 @@ void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime viewport.vp.vscale[0] = viewport.vp.vtrans[0] = width * 2; viewport.vp.vscale[1] = viewport.vp.vtrans[1] = height * 2; gSPViewport(POLY_OPA_DISP++, &viewport); - + guPerspective(perspMtx, &perspNorm, fovy, (f32)width / (f32)height, 10.0f, 4000.0f, 1.0f); gSPPerspNormalize(POLY_OPA_DISP++, perspNorm); diff --git a/soh/src/code/z_room.c b/soh/src/code/z_room.c index 5212799a6..f1fa7c7e1 100644 --- a/soh/src/code/z_room.c +++ b/soh/src/code/z_room.c @@ -554,7 +554,7 @@ u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx) { roomCtx->bufPtrs[0] = GameState_Alloc(&globalCtx->state, maxRoomSize, "../z_room.c", 946); // "Room buffer initial pointer=%08x" osSyncPrintf("部屋バッファ開始ポインタ=%08x\n", roomCtx->bufPtrs[0]); - roomCtx->bufPtrs[1] = (void*)((s32)roomCtx->bufPtrs[0] + maxRoomSize); + roomCtx->bufPtrs[1] = (void*)((intptr_t)roomCtx->bufPtrs[0] + maxRoomSize); // "Room buffer end pointer=%08x" osSyncPrintf("部屋バッファ終了ポインタ=%08x\n", roomCtx->bufPtrs[1]); osSyncPrintf(VT_RST); @@ -586,7 +586,7 @@ s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum) { osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1); DmaMgr_SendRequest2(&roomCtx->dmaRequest, roomCtx->unk_34, globalCtx->roomList[roomNum].vromStart, size, 0, - &roomCtx->loadQueue, NULL, "../z_room.c", 1036); + &roomCtx->loadQueue, OS_MESG_PTR(NULL), "../z_room.c", 1036); roomCtx->unk_30 ^= 1; return 1; diff --git a/soh/src/code/z_scene.c b/soh/src/code/z_scene.c index fe311aa63..e6dbf64d3 100644 --- a/soh/src/code/z_scene.c +++ b/soh/src/code/z_scene.c @@ -61,6 +61,7 @@ void Object_InitBank(GlobalContext* globalCtx, ObjectContext* objectCtx) { for (i = 0; i < OBJECT_EXCHANGE_BANK_MAX; i++) { objectCtx->status[i].id = OBJECT_INVALID; + objectCtx->status[i].segment = NULL; } osSyncPrintf(VT_FGCOL(GREEN)); diff --git a/soh/src/code/z_skelanime.c b/soh/src/code/z_skelanime.c index 6dbfac7ef..cb066c5e3 100644 --- a/soh/src/code/z_skelanime.c +++ b/soh/src/code/z_skelanime.c @@ -857,7 +857,7 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader animation = ResourceMgr_LoadAnimByName(animation); LinkAnimationHeader* linkAnimHeader = SEGMENTED_TO_VIRTUAL(animation); - u32 ram = frameTable; + Vec3s* ram = frameTable; osCreateMesgQueue(&entry->data.load.msgQueue, &entry->data.load.msg, 1); |
