From a33965c1d036ef67d7d26a6d6dca456c4042392d Mon Sep 17 00:00:00 2001 From: Roman971 <32455037+Roman971@users.noreply.github.com> Date: Sat, 11 Jun 2022 09:42:05 +0200 Subject: [PATCH] Minor cleanups in z_std_dma.c and yaz0.c (#1269) * Cleanup dma and yaz0 functions using pointers for ram Also includes a minor cleanup of yaz0 names to better fit their purpose * Run formatter * Additional cleanups on dma and yaz0 functions --- include/functions.h | 14 ++-- include/z64.h | 4 +- src/boot/yaz0.c | 35 +++++---- src/boot/z_std_dma.c | 76 +++++++++---------- src/code/z_kanfont.c | 4 +- src/code/z_kankyo.c | 12 +-- src/code/z_message_PAL.c | 38 +++++----- src/code/z_play.c | 2 +- src/code/z_skelanime.c | 4 +- src/code/z_vr_box.c | 8 +- .../actors/ovl_player_actor/z_player.c | 4 +- 11 files changed, 100 insertions(+), 101 deletions(-) diff --git a/include/functions.h b/include/functions.h index c918cd9308..649525f68f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -22,23 +22,23 @@ void Idle_ThreadEntry(void* arg); void ViConfig_UpdateVi(u32 black); void ViConfig_UpdateBlack(void); s32 DmaMgr_CompareName(const char* name1, const char* name2); -s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size); +s32 DmaMgr_DmaRomToRam(u32 rom, void* ram, u32 size); s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc); const char* DmaMgr_GetFileNameImpl(u32 vrom); const char* DmaMgr_GetFileName(u32 vrom); void DmaMgr_ProcessMsg(DmaRequest* req); void DmaMgr_ThreadEntry(void* arg); -s32 DmaMgr_SendRequestImpl(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg); -s32 DmaMgr_SendRequest0(u32 ram, u32 vrom, u32 size); +s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, u32 vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg); +s32 DmaMgr_SendRequest0(void* ram, u32 vrom, u32 size); void DmaMgr_Init(void); -s32 DmaMgr_SendRequest2(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg, +s32 DmaMgr_SendRequest2(DmaRequest* req, void* ram, u32 vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg, const char* file, s32 line); -s32 DmaMgr_SendRequest1(void* ram0, u32 vrom, u32 size, const char* file, s32 line); +s32 DmaMgr_SendRequest1(void* ram, u32 vrom, u32 size, const char* file, s32 line); void* Yaz0_FirstDMA(void); -void* Yaz0_NextDMA(void* curSrcPos); +void* Yaz0_NextDMA(u8* curSrcPos); void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst); -void Yaz0_Decompress(u32 romStart, void* dst, u32 size); +void Yaz0_Decompress(u32 romStart, u8* dst, u32 size); void Locale_Init(void); void Locale_ResetRegion(void); u32 func_80001F48(void); diff --git a/include/z64.h b/include/z64.h index 1d139f6ca2..b7aa80a95b 100644 --- a/include/z64.h +++ b/include/z64.h @@ -539,7 +539,7 @@ typedef struct { typedef struct { /* 0x0000 */ View view; /* 0x0128 */ Font font; - /* 0xE2B0 */ void* textboxSegment; // original name: "fukidashiSegment" + /* 0xE2B0 */ u8* textboxSegment; // original name: "fukidashiSegment" /* 0xE2B4 */ char unk_E2B4[0x4]; /* 0xE2B8 */ OcarinaStaff* ocarinaStaff; // original name : "info" /* 0xE2BC */ char unk_E2BC[0x3C]; @@ -1531,7 +1531,7 @@ typedef struct { /* 0x04 */ u32 decSize; /* 0x08 */ u32 compInfoOffset; // only used in mio0 /* 0x0C */ u32 uncompDataOffset; // only used in mio0 - /* 0x10 */ u32 data[1]; + /* 0x10 */ u8 data[1]; } Yaz0Header; // size = 0x10 ("data" is not part of the header) typedef struct { diff --git a/src/boot/yaz0.c b/src/boot/yaz0.c index 0da6aa362b..63ead5b47e 100644 --- a/src/boot/yaz0.c +++ b/src/boot/yaz0.c @@ -1,21 +1,20 @@ #include "global.h" u8 sYaz0DataBuffer[0x400]; -u32 sYaz0CurDataEnd; +u8* sYaz0DataBufferEnd; u32 sYaz0CurRomStart; u32 sYaz0CurSize; -u32 sYaz0MaxPtr; +u8* sYaz0MaxPtr; void* Yaz0_FirstDMA(void) { - u32 pad0; - u32 pad1; + s32 pad[2]; u32 dmaSize; - u32 curSize; + u32 bufferSize; - sYaz0MaxPtr = sYaz0CurDataEnd - 0x19; + sYaz0MaxPtr = sYaz0DataBufferEnd - 0x19; - curSize = sYaz0CurDataEnd - (u32)sYaz0DataBuffer; - dmaSize = (curSize > sYaz0CurSize) ? sYaz0CurSize : curSize; + bufferSize = sYaz0DataBufferEnd - sYaz0DataBuffer; + dmaSize = (bufferSize > sYaz0CurSize) ? sYaz0CurSize : bufferSize; DmaMgr_DmaRomToRam(sYaz0CurRomStart, sYaz0DataBuffer, dmaSize); sYaz0CurRomStart += dmaSize; @@ -23,26 +22,26 @@ void* Yaz0_FirstDMA(void) { return sYaz0DataBuffer; } -void* Yaz0_NextDMA(void* curSrcPos) { +void* Yaz0_NextDMA(u8* curSrcPos) { u8* dst; u32 restSize; u32 dmaSize; - restSize = sYaz0CurDataEnd - (u32)curSrcPos; + restSize = sYaz0DataBufferEnd - curSrcPos; dst = (restSize & 7) ? (sYaz0DataBuffer - (restSize & 7)) + 8 : sYaz0DataBuffer; bcopy(curSrcPos, dst, restSize); - dmaSize = (sYaz0CurDataEnd - (u32)dst) - restSize; + dmaSize = (sYaz0DataBufferEnd - dst) - restSize; if (sYaz0CurSize < dmaSize) { dmaSize = sYaz0CurSize; } if (dmaSize != 0) { - DmaMgr_DmaRomToRam(sYaz0CurRomStart, (u32)dst + restSize, dmaSize); + DmaMgr_DmaRomToRam(sYaz0CurRomStart, dst + restSize, dmaSize); sYaz0CurRomStart += dmaSize; sYaz0CurSize -= dmaSize; - if (!sYaz0CurSize) { - sYaz0MaxPtr = (u32)dst + restSize + dmaSize; + if (sYaz0CurSize == 0) { + sYaz0MaxPtr = dst + restSize + dmaSize; } } @@ -51,7 +50,7 @@ void* Yaz0_NextDMA(void* curSrcPos) { void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst) { u32 bitIdx = 0; - u8* src = (u8*)hdr->data; + u8* src = hdr->data; u8* dstEnd = dst + hdr->decSize; u32 chunkHeader; u32 nibble; @@ -61,7 +60,7 @@ void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst) { do { if (bitIdx == 0) { - if ((sYaz0MaxPtr < (u32)src) && (sYaz0CurSize != 0)) { + if ((sYaz0MaxPtr < src) && (sYaz0CurSize != 0)) { src = Yaz0_NextDMA(src); } @@ -93,9 +92,9 @@ void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst) { } while (dst != dstEnd); } -void Yaz0_Decompress(u32 romStart, void* dst, u32 size) { +void Yaz0_Decompress(u32 romStart, u8* dst, u32 size) { sYaz0CurRomStart = romStart; sYaz0CurSize = size; - sYaz0CurDataEnd = sYaz0DataBuffer + sizeof(sYaz0DataBuffer); + sYaz0DataBufferEnd = sYaz0DataBuffer + sizeof(sYaz0DataBuffer); Yaz0_DecompressImpl(Yaz0_FirstDMA(), dst); } diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index e34f7c5c1b..7fcc811f62 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -23,7 +23,7 @@ const char* sDmaMgrFileNames[] = { #undef DEFINE_DMA_ENTRY s32 DmaMgr_CompareName(const char* name1, const char* name2) { - while (*name1 != 0u) { + while (*name1 != '\0') { if (*name1 > *name2) { return 1; } @@ -36,14 +36,14 @@ s32 DmaMgr_CompareName(const char* name1, const char* name2) { name2++; } - if (*name2 > 0) { + if (*name2 > '\0') { return -1; } return 0; } -s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { +s32 DmaMgr_DmaRomToRam(u32 rom, void* ram, u32 size) { OSIoMesg ioMsg; OSMesgQueue queue; OSMesg msg; @@ -55,8 +55,8 @@ s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { buffSize = 0x2000; } - osInvalICache((void*)ram, size); - osInvalDCache((void*)ram, size); + osInvalICache(ram, size); + osInvalDCache(ram, size); osCreateMesgQueue(&queue, &msg, 1); while (size > buffSize) { @@ -65,7 +65,7 @@ s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { ioMsg.hdr.pri = OS_MESG_PRI_NORMAL; ioMsg.hdr.retQueue = &queue; ioMsg.devAddr = rom; - ioMsg.dramAddr = (void*)ram; + ioMsg.dramAddr = ram; ioMsg.size = buffSize; if (gDmaMgrVerbose == 10) { @@ -74,7 +74,7 @@ s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { } ret = osEPiStartDma(gCartHandle, &ioMsg, OS_READ); - if (ret) { + if (ret != 0) { goto end; } @@ -90,8 +90,8 @@ s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { } size -= buffSize; - rom += buffSize; - ram += buffSize; + rom = rom + buffSize; + ram = (u8*)ram + buffSize; } if (1) {} // Also necessary to match @@ -99,7 +99,7 @@ s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { ioMsg.hdr.pri = OS_MESG_PRI_NORMAL; ioMsg.hdr.retQueue = &queue; ioMsg.devAddr = rom; - ioMsg.dramAddr = (void*)ram; + ioMsg.dramAddr = ram; ioMsg.size = size; if (gDmaMgrVerbose == 10) { @@ -108,7 +108,7 @@ s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { } ret = osEPiStartDma(gCartHandle, &ioMsg, OS_READ); - if (ret) { + if (ret != 0) { goto end; } @@ -118,8 +118,8 @@ s32 DmaMgr_DmaRomToRam(u32 rom, u32 ram, u32 size) { } end: - osInvalICache((void*)ram, size); - osInvalDCache((void*)ram, size); + osInvalICache(ram, size); + osInvalDCache(ram, size); return ret; } @@ -137,26 +137,26 @@ s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { } ret = osEPiStartDma(pihandle, mb, direction); - if (ret) { + if (ret != 0) { osSyncPrintf("OOPS!!\n"); } return ret; } -void DmaMgr_DmaFromDriveRom(u32 ram, u32 rom, u32 size) { +void DmaMgr_DmaFromDriveRom(void* ram, u32 rom, u32 size) { OSPiHandle* handle = osDriveRomInit(); OSMesgQueue queue; OSMesg msg; OSIoMesg ioMsg; - osInvalICache((void*)ram, size); - osInvalDCache((void*)ram, size); + osInvalICache(ram, size); + osInvalDCache(ram, size); osCreateMesgQueue(&queue, &msg, 1); ioMsg.hdr.retQueue = &queue; ioMsg.hdr.pri = OS_MESG_PRI_NORMAL; ioMsg.devAddr = rom; - ioMsg.dramAddr = (void*)ram; + ioMsg.dramAddr = ram; ioMsg.size = size; handle->transferInfo.cmdType = 2; @@ -166,7 +166,7 @@ void DmaMgr_DmaFromDriveRom(u32 ram, u32 rom, u32 size) { void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc) { u32 vrom = req->vromAddr; - u32 ram = (u32)req->dramAddr; + void* ram = req->dramAddr; u32 size = req->size; char buff1[80]; char buff2[80]; @@ -177,17 +177,17 @@ void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, cons errorDesc != NULL ? errorDesc : (errorName != NULL ? errorName : "???"), vrom, ram, size, file != NULL ? file : "???"); - if (req->filename) { + if (req->filename != NULL) { osSyncPrintf("DMA ERROR: %s %d", req->filename, req->line); - } else if (sDmaMgrCurFileName) { + } else if (sDmaMgrCurFileName != NULL) { osSyncPrintf("DMA ERROR: %s %d", sDmaMgrCurFileName, sDmaMgrCurFileLine); } osSyncPrintf(VT_RST); - if (req->filename) { + if (req->filename != NULL) { sprintf(buff1, "DMA ERROR: %s %d", req->filename, req->line); - } else if (sDmaMgrCurFileName) { + } else if (sDmaMgrCurFileName != NULL) { sprintf(buff1, "DMA ERROR: %s %d", sDmaMgrCurFileName, sDmaMgrCurFileLine); } else { sprintf(buff1, "DMA ERROR: %s", errorName != NULL ? errorName : "???"); @@ -201,7 +201,7 @@ const char* DmaMgr_GetFileNameImpl(u32 vrom) { DmaEntry* iter = gDmaDataTable; const char** name = sDmaMgrFileNames; - while (iter->vromEnd) { + while (iter->vromEnd != 0) { if (vrom >= iter->vromStart && vrom < iter->vromEnd) { return *name; } @@ -251,7 +251,7 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { filename = DmaMgr_GetFileName(vrom); iter = gDmaDataTable; - while (iter->vromEnd) { + while (iter->vromEnd != 0) { if (vrom >= iter->vromStart && vrom < iter->vromEnd) { if (1) {} // Necessary to match @@ -261,7 +261,7 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { "セグメント境界をまたがってDMA転送することはできません"); } - DmaMgr_DmaRomToRam(iter->romStart + (vrom - iter->vromStart), (u32)ram, size); + DmaMgr_DmaRomToRam(iter->romStart + (vrom - iter->vromStart), ram, size); found = true; if (0) { @@ -301,7 +301,7 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { return; } - DmaMgr_DmaRomToRam(vrom, (u32)ram, size); + DmaMgr_DmaRomToRam(vrom, ram, size); if (0) { osSyncPrintf("No Press ROM:%08X RAM:%08X SIZE:%08X (非公式)\n", vrom, ram, size); @@ -326,7 +326,7 @@ void DmaMgr_ThreadEntry(void* arg) { } DmaMgr_ProcessMsg(req); - if (req->notifyQueue) { + if (req->notifyQueue != NULL) { osSendMesg(req->notifyQueue, req->notifyMsg, OS_MESG_NOBLOCK); if (0) { osSyncPrintf("osSendMesg: dmap=%08x, mq=%08x, m=%08x \n", req, req->notifyQueue, req->notifyMsg); @@ -336,17 +336,17 @@ void DmaMgr_ThreadEntry(void* arg) { osSyncPrintf("DMAマネージャスレッド実行終了\n"); } -s32 DmaMgr_SendRequestImpl(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg) { +s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, u32 vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg) { static s32 sDmaMgrQueueFullLogged = 0; - if ((1 && (ram == 0)) || (osMemSize < ram + size + 0x80000000) || (vrom & 1) || (vrom > 0x4000000) || (size == 0) || - (size & 1)) { + if ((1 && (ram == NULL)) || (osMemSize < OS_K0_TO_PHYSICAL(ram) + size) || (vrom & 1) || (vrom > 0x4000000) || + (size == 0) || (size & 1)) { //! @bug `req` is passed to `DmaMgr_Error` without rom, ram and size being set DmaMgr_Error(req, NULL, "ILLIGAL DMA-FUNCTION CALL", "パラメータ異常です"); } req->vromAddr = vrom; - req->dramAddr = (void*)ram; + req->dramAddr = ram; req->size = size; req->unk_14 = 0; req->notifyQueue = queue; @@ -366,7 +366,7 @@ s32 DmaMgr_SendRequestImpl(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk return 0; } -s32 DmaMgr_SendRequest0(u32 ram, u32 vrom, u32 size) { +s32 DmaMgr_SendRequest0(void* ram, u32 vrom, u32 size) { DmaRequest req; OSMesgQueue queue; OSMesg msg; @@ -387,7 +387,7 @@ void DmaMgr_Init(void) { s32 idx; DmaEntry* iter; - DmaMgr_DmaRomToRam((u32)_dmadataSegmentRomStart, (u32)_dmadataSegmentStart, + DmaMgr_DmaRomToRam((u32)_dmadataSegmentRomStart, _dmadataSegmentStart, (u32)(_dmadataSegmentRomEnd - _dmadataSegmentRomStart)); osSyncPrintf("dma_rom_ad[]\n"); @@ -409,7 +409,7 @@ void DmaMgr_Init(void) { idx++; iter++; - if (name) { + if (name != NULL) { name++; } } @@ -427,19 +427,19 @@ void DmaMgr_Init(void) { osStartThread(&sDmaMgrThread); } -s32 DmaMgr_SendRequest2(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg, +s32 DmaMgr_SendRequest2(DmaRequest* req, void* ram, u32 vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg, const char* file, s32 line) { req->filename = file; req->line = line; return DmaMgr_SendRequestImpl(req, ram, vrom, size, unk5, queue, msg); } -s32 DmaMgr_SendRequest1(void* ram0, u32 vrom, u32 size, const char* file, s32 line) { +s32 DmaMgr_SendRequest1(void* ram, u32 vrom, u32 size, const char* file, s32 line) { DmaRequest req; s32 ret; OSMesgQueue queue; OSMesg msg; - u32 ram = (u32)ram0; + s32 pad; req.filename = file; req.line = line; diff --git a/src/code/z_kanfont.c b/src/code/z_kanfont.c index c9a150a5b9..f63be14c89 100644 --- a/src/code/z_kanfont.c +++ b/src/code/z_kanfont.c @@ -30,10 +30,10 @@ void Font_LoadMessageBoxIcon(Font* font, u16 icon) { * the font buffer. */ void Font_LoadOrderedFont(Font* font) { + u8* fontBuf; + s32 fontStatic; s32 len; s32 jj; - s32 fontStatic; - u32 fontBuf; s32 codePointIndex; s32 fontBufIndex; s32 offset; diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 45b7b58543..6ea7970b97 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -708,7 +708,7 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon size = gNormalSkyFiles[newSkybox1Index].file.vromEnd - gNormalSkyFiles[newSkybox1Index].file.vromStart; osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); - DmaMgr_SendRequest2(&envCtx->dmaRequest, (u32)skyboxCtx->staticSegments[0], + DmaMgr_SendRequest2(&envCtx->dmaRequest, skyboxCtx->staticSegments[0], gNormalSkyFiles[newSkybox1Index].file.vromStart, size, 0, &envCtx->loadQueue, NULL, "../z_kankyo.c", 1264); envCtx->skybox1Index = newSkybox1Index; @@ -719,7 +719,7 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon size = gNormalSkyFiles[newSkybox2Index].file.vromEnd - gNormalSkyFiles[newSkybox2Index].file.vromStart; osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); - DmaMgr_SendRequest2(&envCtx->dmaRequest, (u32)skyboxCtx->staticSegments[1], + DmaMgr_SendRequest2(&envCtx->dmaRequest, skyboxCtx->staticSegments[1], gNormalSkyFiles[newSkybox2Index].file.vromStart, size, 0, &envCtx->loadQueue, NULL, "../z_kankyo.c", 1281); envCtx->skybox2Index = newSkybox2Index; @@ -733,14 +733,14 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon gNormalSkyFiles[newSkybox1Index].palette.vromStart; osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); - DmaMgr_SendRequest2(&envCtx->dmaRequest, (u32)skyboxCtx->palettes, + DmaMgr_SendRequest2(&envCtx->dmaRequest, skyboxCtx->palettes, gNormalSkyFiles[newSkybox1Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL, "../z_kankyo.c", 1307); } else { size = gNormalSkyFiles[newSkybox1Index].palette.vromEnd - gNormalSkyFiles[newSkybox1Index].palette.vromStart; osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); - DmaMgr_SendRequest2(&envCtx->dmaRequest, (u32)skyboxCtx->palettes + size, + DmaMgr_SendRequest2(&envCtx->dmaRequest, (u8*)skyboxCtx->palettes + size, gNormalSkyFiles[newSkybox1Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL, "../z_kankyo.c", 1320); } @@ -754,14 +754,14 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon gNormalSkyFiles[newSkybox2Index].palette.vromStart; osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); - DmaMgr_SendRequest2(&envCtx->dmaRequest, (u32)skyboxCtx->palettes, + DmaMgr_SendRequest2(&envCtx->dmaRequest, skyboxCtx->palettes, gNormalSkyFiles[newSkybox2Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL, "../z_kankyo.c", 1342); } else { size = gNormalSkyFiles[newSkybox2Index].palette.vromEnd - gNormalSkyFiles[newSkybox2Index].palette.vromStart; osCreateMesgQueue(&envCtx->loadQueue, &envCtx->loadMsg, 1); - DmaMgr_SendRequest2(&envCtx->dmaRequest, (u32)skyboxCtx->palettes + size, + DmaMgr_SendRequest2(&envCtx->dmaRequest, (u8*)skyboxCtx->palettes + size, gNormalSkyFiles[newSkybox2Index].palette.vromStart, size, 0, &envCtx->loadQueue, NULL, "../z_kankyo.c", 1355); } diff --git a/src/code/z_message_PAL.c b/src/code/z_message_PAL.c index 23bef7df94..14c7cedb24 100644 --- a/src/code/z_message_PAL.c +++ b/src/code/z_message_PAL.c @@ -755,12 +755,12 @@ u16 Message_DrawItemIcon(PlayState* play, u16 itemId, Gfx** p, u16 i) { gDPSetPrimColor(gfx++, 0, 0, 255, 255, 255, msgCtx->textColorAlpha); if (itemId >= ITEM_MEDALLION_FOREST) { - gDPLoadTextureBlock(gfx++, (u32)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, G_IM_FMT_RGBA, G_IM_SIZ_32b, - 24, 24, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + gDPLoadTextureBlock(gfx++, msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, G_IM_FMT_RGBA, G_IM_SIZ_32b, 24, + 24, 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); } else { - gDPLoadTextureBlock(gfx++, (u32)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, G_IM_FMT_RGBA, G_IM_SIZ_32b, - 32, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + gDPLoadTextureBlock(gfx++, msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, G_IM_FMT_RGBA, G_IM_SIZ_32b, 32, + 32, 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); } gSPTextureRectangle(gfx++, (msgCtx->textPosX + R_TEXTBOX_ICON_XPOS) << 2, R_TEXTBOX_ICON_YPOS << 2, @@ -1010,9 +1010,9 @@ void Message_DrawText(PlayState* play, Gfx** gfxP) { sTextboxBackgroundBackPrimColors[msgCtx->textboxBackgroundBackColorIdx][2], msgCtx->textColorAlpha); - gDPLoadTextureBlock_4b(gfx++, (u32)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, G_IM_FMT_I, 96, 48, - 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); + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, G_IM_FMT_I, 96, 48, 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); gSPTextureRectangle( gfx++, (msgCtx->textPosX + 1) << 2, (R_TEXTBOX_BG_YPOS + sTextboxBackgroundYOffsets[msgCtx->textboxBackgroundYOffsetIdx]) << 2, @@ -1020,8 +1020,8 @@ void Message_DrawText(PlayState* play, Gfx** gfxP) { (R_TEXTBOX_BG_YPOS + sTextboxBackgroundYOffsets[msgCtx->textboxBackgroundYOffsetIdx] + 48) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); - gDPLoadTextureBlock_4b(gfx++, (u32)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE + 0x900, G_IM_FMT_I, - 96, 48, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE + 0x900, G_IM_FMT_I, 96, + 48, 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); gSPTextureRectangle( gfx++, (msgCtx->textPosX + 96 + 1) << 2, @@ -1036,15 +1036,15 @@ void Message_DrawText(PlayState* play, Gfx** gfxP) { sTextboxBackgroundForePrimColors[msgCtx->textboxBackgroundForeColorIdx][2], msgCtx->textColorAlpha); - gDPLoadTextureBlock_4b(gfx++, ((u32)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE), G_IM_FMT_I, 96, - 48, 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); + gDPLoadTextureBlock_4b(gfx++, (msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE), G_IM_FMT_I, 96, 48, 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); gSPTextureRectangle(gfx++, msgCtx->textPosX << 2, R_TEXTBOX_BG_YPOS << 2, (msgCtx->textPosX + 96) << 2, (R_TEXTBOX_BG_YPOS + 48) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); - gDPLoadTextureBlock_4b(gfx++, ((u32)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE + 0x900), - G_IM_FMT_I, 96, 48, 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); + gDPLoadTextureBlock_4b(gfx++, (msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE + 0x900), G_IM_FMT_I, + 96, 48, 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); gSPTextureRectangle(gfx++, (msgCtx->textPosX + 96) << 2, R_TEXTBOX_BG_YPOS << 2, (msgCtx->textPosX + 192) << 2, (R_TEXTBOX_BG_YPOS + 48) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); @@ -1167,7 +1167,7 @@ void Message_LoadItemIcon(PlayState* play, 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; - DmaMgr_SendRequest1((u32)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, + DmaMgr_SendRequest1(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, (u32)_icon_item_staticSegmentRomStart + (itemId * 0x1000), 0x1000, "../z_message_PAL.c", 1473); // "Item 32-0" @@ -1176,7 +1176,7 @@ void Message_LoadItemIcon(PlayState* play, u16 itemId, s16 y) { R_TEXTBOX_ICON_XPOS = R_TEXT_INIT_XPOS - sIconItem24XOffsets[gSaveContext.language]; R_TEXTBOX_ICON_YPOS = y + 10; R_TEXTBOX_ICON_SIZE = 24; - DmaMgr_SendRequest1((u32)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, + DmaMgr_SendRequest1(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, (u32)_icon_item_24_staticSegmentRomStart + (itemId - ITEM_MEDALLION_FOREST) * 0x900, 0x900, "../z_message_PAL.c", 1482); // "Item 24" @@ -1535,10 +1535,10 @@ void Message_Decode(PlayState* play) { msgCtx->textboxBackgroundBackColorIdx = font->msgBuf[msgCtx->msgBufPos + 2] & 0xF; msgCtx->textboxBackgroundYOffsetIdx = (font->msgBuf[msgCtx->msgBufPos + 3] & 0xF0) >> 4; msgCtx->textboxBackgroundUnkArg = font->msgBuf[msgCtx->msgBufPos + 3] & 0xF; - DmaMgr_SendRequest1((u32)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, + DmaMgr_SendRequest1(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, (u32)_message_texture_staticSegmentRomStart + msgCtx->textboxBackgroundIdx * 0x900, 0x900, "../z_message_PAL.c", 1830); - DmaMgr_SendRequest1((u32)msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE + 0x900, + DmaMgr_SendRequest1(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE + 0x900, (u32)_message_texture_staticSegmentRomStart + (msgCtx->textboxBackgroundIdx + 1) * 0x900, 0x900, "../z_message_PAL.c", 1834); diff --git a/src/code/z_play.c b/src/code/z_play.c index adc59ebc4a..196839f702 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -414,7 +414,7 @@ void Play_Init(GameState* thisx) { if (dREG(95) != 0) { D_8012D1F0 = D_801614D0; osSyncPrintf("\nkawauso_data=[%x]", D_8012D1F0); - DmaMgr_DmaRomToRam(0x03FEB000, (u32)D_8012D1F0, sizeof(D_801614D0)); + DmaMgr_DmaRomToRam(0x03FEB000, D_8012D1F0, sizeof(D_801614D0)); } } diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index ffc294d0d5..fe19883b29 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -838,10 +838,10 @@ void AnimationContext_SetLoadFrame(PlayState* play, LinkAnimationHeader* animati if (entry != NULL) { LinkAnimationHeader* linkAnimHeader = SEGMENTED_TO_VIRTUAL(animation); - u32 ram = frameTable; + s32 pad; osCreateMesgQueue(&entry->data.load.msgQueue, &entry->data.load.msg, 1); - DmaMgr_SendRequest2(&entry->data.load.req, ram, + DmaMgr_SendRequest2(&entry->data.load.req, frameTable, LINK_ANIMATION_OFFSET(linkAnimHeader->segment, ((sizeof(Vec3s) * limbCount + 2) * frame)), sizeof(Vec3s) * limbCount + 2, 0, &entry->data.load.msgQueue, NULL, "../z_skelanime.c", 2004); diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index 9c9da69fbc..f8e6d98b82 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -430,7 +430,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_SendRequest1(skyboxCtx->palettes, gNormalSkyFiles[skybox1Index].palette.vromStart, size, "../z_vr_box.c", 1075); - DmaMgr_SendRequest1((u32)skyboxCtx->palettes + size, gNormalSkyFiles[skybox2Index].palette.vromStart, + DmaMgr_SendRequest1((u8*)skyboxCtx->palettes + size, gNormalSkyFiles[skybox2Index].palette.vromStart, size, "../z_vr_box.c", 1077); } else { size = gNormalSkyFiles[skybox1Index].palette.vromEnd - gNormalSkyFiles[skybox1Index].palette.vromStart; @@ -441,7 +441,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_SendRequest1(skyboxCtx->palettes, gNormalSkyFiles[skybox2Index].palette.vromStart, size, "../z_vr_box.c", 1088); - DmaMgr_SendRequest1((u32)skyboxCtx->palettes + size, gNormalSkyFiles[skybox1Index].palette.vromStart, + DmaMgr_SendRequest1((u8*)skyboxCtx->palettes + size, gNormalSkyFiles[skybox1Index].palette.vromStart, size, "../z_vr_box.c", 1090); } break; @@ -486,7 +486,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1171); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1173); - DmaMgr_SendRequest1((u32)skyboxCtx->palettes + size, start, size, "../z_vr_box.c", 1175); + DmaMgr_SendRequest1((u8*)skyboxCtx->palettes + size, start, size, "../z_vr_box.c", 1175); break; case SKYBOX_MARKET_ADULT: skyboxCtx->unk_140 = 1; @@ -531,7 +531,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1212); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1214); - DmaMgr_SendRequest1((u32)skyboxCtx->palettes + size, _vr_holy1_pal_staticSegmentRomStart, size, + DmaMgr_SendRequest1((u8*)skyboxCtx->palettes + size, _vr_holy1_pal_staticSegmentRomStart, size, "../z_vr_box.c", 1216); break; case SKYBOX_HOUSE_LINK: diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index dd58a8c955..5818e350dd 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -4860,8 +4860,8 @@ void func_8083AE40(Player* this, s16 objectId) { LOG_HEX("size", size, "../z_player.c", 9090); ASSERT(size <= 1024 * 8, "size <= 1024 * 8", "../z_player.c", 9091); - DmaMgr_SendRequest2(&this->giObjectDmaRequest, (u32)this->giObjectSegment, gObjectTable[objectId].vromStart, - size, 0, &this->giObjectLoadQueue, NULL, "../z_player.c", 9099); + DmaMgr_SendRequest2(&this->giObjectDmaRequest, this->giObjectSegment, gObjectTable[objectId].vromStart, size, 0, + &this->giObjectLoadQueue, NULL, "../z_player.c", 9099); } }