From 7ecafcfe7d357ff1cbcf49ce4d87a9efedae552e Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Thu, 17 Nov 2022 02:57:02 +0000 Subject: [PATCH] More documentation for `z_std_dma.c` (#1415) * More documentation for z_std_dma * uintptr casts for rom symbols in z64animation.h and z_kanfont.c * Format * Suggested changes, more defines for static texture sizes * PI Interface -> PI * Further suggested changes * Format * Comments about item_name and map_name texture assumptions --- include/functions.h | 16 +- include/variables.h | 3 - include/z64.h | 29 +- include/z64animation.h | 2 +- include/z64dma.h | 27 +- include/z64item.h | 14 + src/boot/idle.c | 4 +- src/boot/yaz0.c | 12 +- src/boot/z_std_dma.c | 249 ++++++++++++++---- src/code/audioMgr.c | 2 +- src/code/game.c | 2 +- src/code/load.c | 2 +- src/code/z_actor.c | 2 +- src/code/z_construct.c | 74 +++--- src/code/z_kanfont.c | 27 +- src/code/z_kankyo.c | 12 +- src/code/z_map_exp.c | 28 +- src/code/z_message_PAL.c | 53 ++-- src/code/z_parameter.c | 21 +- src/code/z_play.c | 2 +- src/code/z_player_lib.c | 4 +- src/code/z_room.c | 2 +- src/code/z_sample.c | 2 +- src/code/z_scene.c | 8 +- src/code/z_skelanime.c | 2 +- src/code/z_vr_box.c | 130 ++++----- .../actors/ovl_player_actor/z_player.c | 2 +- .../ovl_file_choose/z_file_choose.c | 7 +- src/overlays/gamestates/ovl_select/z_select.c | 3 +- src/overlays/gamestates/ovl_title/z_title.c | 4 +- .../ovl_kaleido_scope/z_kaleido_map_PAL.c | 4 +- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 120 +++++---- 32 files changed, 549 insertions(+), 320 deletions(-) diff --git a/include/functions.h b/include/functions.h index 46dc6299bb..8c60f88b49 100644 --- a/include/functions.h +++ b/include/functions.h @@ -21,24 +21,10 @@ void Main_ThreadEntry(void* arg); 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(uintptr_t 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(uintptr_t vrom); -const char* DmaMgr_GetFileName(uintptr_t vrom); -void DmaMgr_ProcessMsg(DmaRequest* req); -void DmaMgr_ThreadEntry(void* arg); -s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, u32 unk, OSMesgQueue* queue, OSMesg msg); -s32 DmaMgr_SendRequest0(void* ram, uintptr_t vrom, u32 size); -void DmaMgr_Init(void); -s32 DmaMgr_SendRequest2(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg, - const char* file, s32 line); -s32 DmaMgr_SendRequest1(void* ram, uintptr_t vrom, u32 size, const char* file, s32 line); void* Yaz0_FirstDMA(void); void* Yaz0_NextDMA(u8* curSrcPos); void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst); -void Yaz0_Decompress(uintptr_t romStart, u8* dst, u32 size); +void Yaz0_Decompress(uintptr_t romStart, u8* dst, size_t size); void Locale_Init(void); void Locale_ResetRegion(void); u32 func_80001F48(void); diff --git a/include/variables.h b/include/variables.h index 44f7a27250..7c83866725 100644 --- a/include/variables.h +++ b/include/variables.h @@ -13,8 +13,6 @@ extern u32 osMemSize; extern u8 osAppNMIBuffer[0x40]; extern s8 D_80009430; -extern u32 gDmaMgrVerbose; -extern u32 gDmaMgrDmaBuffSize; extern vu8 gViConfigBlack; extern u8 gViConfigAdditionalScanLines; extern u32 gViConfigFeatures; @@ -53,7 +51,6 @@ extern OSTime __osCurrentTime; extern u32 __osBaseCounter; extern u32 __osViIntrCount; extern u32 __osTimerCounter; -extern DmaEntry gDmaDataTable[0x60C]; extern EffectSsOverlay gEffectSsOverlayTable[EFFECT_SS_TYPE_MAX]; extern Gfx D_80116280[]; extern ActorOverlay gActorOverlayTable[ACTOR_ID_MAX]; // original name: "actor_dlftbls" 801162A0 diff --git a/include/z64.h b/include/z64.h index 40dabeb5e3..3fb20884fa 100644 --- a/include/z64.h +++ b/include/z64.h @@ -420,11 +420,14 @@ typedef enum { // TODO get these properties from the textures themselves #define FONT_CHAR_TEX_WIDTH 16 #define FONT_CHAR_TEX_HEIGHT 16 -#define FONT_CHAR_TEX_SIZE ((16 * 16) / 2) // 16x16 I4 texture +#define FONT_CHAR_TEX_SIZE ((FONT_CHAR_TEX_WIDTH * FONT_CHAR_TEX_HEIGHT) / 2) // 16x16 I4 texture // TODO get these properties from the textures themselves #define MESSAGE_STATIC_TEX_SIZE 0x1000 +// TODO get these properties from the textures themselves +#define MESSAGE_TEXTURE_STATIC_TEX_SIZE 0x900 + typedef enum { /* 0x00 */ MSGMODE_NONE, /* 0x01 */ MSGMODE_TEXT_START, @@ -616,6 +619,11 @@ typedef enum { /* 0x1D */ DO_ACTION_MAX } DoAction; +// TODO extract this information from the texture definitions themselves +#define DO_ACTION_TEX_WIDTH 48 +#define DO_ACTION_TEX_HEIGHT 16 +#define DO_ACTION_TEX_SIZE ((DO_ACTION_TEX_WIDTH * DO_ACTION_TEX_HEIGHT) / 2) // (sizeof(gCheckDoActionENGTex)) + typedef struct { /* 0x0000 */ View view; /* 0x0128 */ Vtx* actionVtx; @@ -1427,6 +1435,25 @@ typedef struct { /* 0x6C */ s16* skullFloorIconY; // dungeon big skull icon Y pos } MapData; // size = 0x70 +// TODO get these properties from the textures themselves +#define MAP_I_TEX_WIDTH 96 +#define MAP_I_TEX_HEIGHT 85 +#define MAP_I_TEX_SIZE ((MAP_I_TEX_WIDTH * MAP_I_TEX_HEIGHT) / 2) // 96x85 I4 texture + +#define MAP_48x85_TEX_WIDTH 48 +#define MAP_48x85_TEX_HEIGHT 85 +#define MAP_48x85_TEX_SIZE ((MAP_48x85_TEX_WIDTH * MAP_48x85_TEX_HEIGHT) / 2) // 48x85 CI4 texture + +// Note that z_kaleido_scope_PAL.c assumes that the dimensions and texture format here also matches the dimensions and +// texture format for ITEM_NAME_TEX_* +#define MAP_NAME_TEX1_WIDTH 128 +#define MAP_NAME_TEX1_HEIGHT 16 +#define MAP_NAME_TEX1_SIZE ((MAP_NAME_TEX1_WIDTH * MAP_NAME_TEX1_HEIGHT) / 2) // 128x16 IA4 texture + +#define MAP_NAME_TEX2_WIDTH 80 +#define MAP_NAME_TEX2_HEIGHT 32 +#define MAP_NAME_TEX2_SIZE (MAP_NAME_TEX2_WIDTH * MAP_NAME_TEX2_HEIGHT) // 80x32 IA8 texture + #define PAUSE_MAP_MARK_NONE -1 #define PAUSE_MAP_MARK_CHEST 0 #define PAUSE_MAP_MARK_BOSS 1 diff --git a/include/z64animation.h b/include/z64animation.h index 31d4d84fe2..830befae79 100755 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -10,7 +10,7 @@ struct Actor; struct SkelAnime; #define LINK_ANIMATION_OFFSET(addr, offset) \ - (((u32)_link_animetionSegmentRomStart) + ((u32)addr) - ((u32)_link_animetionSegmentStart) + ((u32)offset)) + (((uintptr_t)_link_animetionSegmentRomStart) + ((uintptr_t)(addr)) - ((uintptr_t)_link_animetionSegmentStart) + (offset)) #define LIMB_DONE 0xFF #define ANIMATION_ENTRY_MAX 50 #define ANIM_FLAG_UPDATEY (1 << 1) diff --git a/include/z64dma.h b/include/z64dma.h index f19c3e767b..c27aa02739 100755 --- a/include/z64dma.h +++ b/include/z64dma.h @@ -2,11 +2,12 @@ #define Z64_DMA_H #include "ultra64.h" +#include "alignment.h" typedef struct { /* 0x00 */ uintptr_t vromAddr; // VROM address (source) /* 0x04 */ void* dramAddr; // DRAM address (destination) - /* 0x08 */ u32 size; // File Transfer size + /* 0x08 */ size_t size; // File Transfer size /* 0x0C */ const char* filename; // Filename for debugging /* 0x10 */ s32 line; // Line for debugging /* 0x14 */ s32 unk_14; @@ -21,4 +22,28 @@ typedef struct { /* 0x0C */ uintptr_t romEnd; } DmaEntry; +extern DmaEntry gDmaDataTable[]; + +extern u32 gDmaMgrVerbose; +extern size_t gDmaMgrDmaBuffSize; + +#define DMAMGR_DEFAULT_BUFSIZE ALIGN16(0x2000) + +// Standard DMA Requests + +s32 DmaMgr_RequestSync(void* ram, uintptr_t vrom, size_t size); +s32 DmaMgr_RequestSyncDebug(void* ram, uintptr_t vrom, size_t size, const char* file, s32 line); +s32 DmaMgr_RequestAsync(DmaRequest* req, void* ram, uintptr_t vrom, size_t size, u32 unk5, OSMesgQueue* queue, + OSMesg msg, const char* file, s32 line); + +// Special-purpose DMA Requests + +s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size); +void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, size_t size); +s32 DmaMgr_AudioDmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); + +// Initialization + +void DmaMgr_Init(void); + #endif diff --git a/include/z64item.h b/include/z64item.h index 264a63d6ec..a642841b96 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -1,6 +1,20 @@ #ifndef Z64ITEM_H #define Z64ITEM_H +#define ICON_ITEM_TEX_WIDTH 32 +#define ICON_ITEM_TEX_HEIGHT 32 +#define ICON_ITEM_TEX_SIZE ((ICON_ITEM_TEX_WIDTH * ICON_ITEM_TEX_HEIGHT) * 4) // 32x32 RGBA32 texture + +#define ICON_ITEM_24_TEX_WIDTH 24 +#define ICON_ITEM_24_TEX_HEIGHT 24 +#define ICON_ITEM_24_TEX_SIZE ((ICON_ITEM_24_TEX_WIDTH * ICON_ITEM_24_TEX_HEIGHT) * 4) // 24x24 RGBA32 texture + +// Note that z_kaleido_scope_PAL.c assumes that the dimensions and texture format here also matches the dimensions and +// texture format for MAP_NAME_TEX1_* +#define ITEM_NAME_TEX_WIDTH 128 +#define ITEM_NAME_TEX_HEIGHT 16 +#define ITEM_NAME_TEX_SIZE ((ITEM_NAME_TEX_WIDTH * ITEM_NAME_TEX_HEIGHT) / 2) // 128x16 IA4 texture + typedef enum { /* 0 */ EQUIP_TYPE_SWORD, /* 1 */ EQUIP_TYPE_SHIELD, diff --git a/src/boot/idle.c b/src/boot/idle.c index 99a0276b44..30c244876c 100644 --- a/src/boot/idle.c +++ b/src/boot/idle.c @@ -23,8 +23,8 @@ void Main_ThreadEntry(void* arg) { DmaMgr_Init(); osSyncPrintf("codeセグメントロード中..."); time = osGetTime(); - DmaMgr_SendRequest1(_codeSegmentStart, (uintptr_t)_codeSegmentRomStart, _codeSegmentRomEnd - _codeSegmentRomStart, - "../idle.c", 238); + DmaMgr_RequestSyncDebug(_codeSegmentStart, (uintptr_t)_codeSegmentRomStart, + _codeSegmentRomEnd - _codeSegmentRomStart, "../idle.c", 238); time -= osGetTime(); osSyncPrintf("\rcodeセグメントロード中...完了\n"); osSyncPrintf("転送時間 %6.3f\n"); diff --git a/src/boot/yaz0.c b/src/boot/yaz0.c index 914560bc41..80d8509280 100644 --- a/src/boot/yaz0.c +++ b/src/boot/yaz0.c @@ -3,13 +3,13 @@ u8 sYaz0DataBuffer[0x400]; u8* sYaz0DataBufferEnd; uintptr_t sYaz0CurRomStart; -u32 sYaz0CurSize; +size_t sYaz0CurSize; u8* sYaz0MaxPtr; void* Yaz0_FirstDMA(void) { s32 pad[2]; - u32 dmaSize; - u32 bufferSize; + size_t dmaSize; + size_t bufferSize; sYaz0MaxPtr = sYaz0DataBufferEnd - 0x19; @@ -24,8 +24,8 @@ void* Yaz0_FirstDMA(void) { void* Yaz0_NextDMA(u8* curSrcPos) { u8* dst; - u32 restSize; - u32 dmaSize; + size_t restSize; + size_t dmaSize; restSize = sYaz0DataBufferEnd - curSrcPos; dst = (restSize & 7) ? (sYaz0DataBuffer - (restSize & 7)) + 8 : sYaz0DataBuffer; @@ -92,7 +92,7 @@ void Yaz0_DecompressImpl(Yaz0Header* hdr, u8* dst) { } while (dst != dstEnd); } -void Yaz0_Decompress(uintptr_t romStart, u8* dst, u32 size) { +void Yaz0_Decompress(uintptr_t romStart, u8* dst, size_t size) { sYaz0CurRomStart = romStart; sYaz0CurSize = size; sYaz0DataBufferEnd = sYaz0DataBuffer + sizeof(sYaz0DataBuffer); diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index 140b966f9f..3b6320b85a 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -1,3 +1,23 @@ +/** + * @file z_std_dma.c + * + * This file implements a system for structuring the ROM image and retrieving data. It is designed to have the same + * external interface regardless of whether the ROM segments are compressed or not. + * + * The ROM image is partitioned into regions that are entered into the DMA data table `gDmaDataTable`. External code + * does not directly address locations on the ROM image directly, instead a "Virtual ROM" addressing is used. Virtual + * ROM is defined to be the ROM address of a segment in a totally uncompressed ROM. For uncompressed ROMs, "physical" + * ROM and VROM addresses coincide. The DMA data table converts VROM to ROM addresses so that code may exclusively use + * VROM addresses even if the ROM is compressed. + * + * External code typically submits requests to the DMA Manager asking for a transfer in terms of Virtual ROM; the DMA + * Manager translates this to the physical ROM address, performs the transfer to RAM and decompresses the data if + * required. + * Requests are processed in the order they are received and may be submitted both synchronously and asynchronously. + * + * There are some additional provisions to ensure that audio DMA is particularly high-speed, the audio data is assumed + * to be uncompressed and the request queue and address translation is skipped. + */ #include "global.h" #include "terminal.h" @@ -10,7 +30,7 @@ const char* sDmaMgrCurFileName; s32 sDmaMgrCurFileLine; u32 gDmaMgrVerbose = 0; -u32 gDmaMgrDmaBuffSize = 0x2000; +size_t gDmaMgrDmaBuffSize = DMAMGR_DEFAULT_BUFSIZE; u32 sDmaMgrIsRomCompressed = false; // dmadata filenames @@ -22,37 +42,54 @@ const char* sDmaMgrFileNames[] = { #undef DEFINE_DMA_ENTRY -s32 DmaMgr_CompareName(const char* name1, const char* name2) { - while (*name1 != '\0') { - if (*name1 > *name2) { +/** + * Compares `str1` and `str2`. + * + * @return + * 0 if str1 and str2 are the same, + * -1 if the first character that does not match has a smaller value in str1 than str2, + * +1 if the first character that does not match has a greater value in str1 than str2 + */ +s32 DmaMgr_StrCmp(const char* str1, const char* str2) { + while (*str1 != '\0') { + if (*str1 > *str2) { return 1; } - - if (*name1 < *name2) { + if (*str1 < *str2) { return -1; } - - name1++; - name2++; + str1++; + str2++; } - if (*name2 > '\0') { + if (*str2 > '\0') { return -1; } - return 0; } -s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, u32 size) { +/** + * Transfer `size` bytes from physical ROM address `rom` to `ram`. + * + * This function is intended for internal use only, however it is possible to use this function externally in which + * case it behaves as a synchronous transfer, data is available as soon as this function returns. + * + * Transfers are divided into chunks based on the current value of `gDmaMgrDmaBuffSize` to avoid congestion of the PI + * so that higher priority transfers can still be carried out in a timely manner. The transfers are sent in a queue to + * the OS PI Manager which performs the transfer. + * + * @return 0 if successful, -1 if the DMA could not be queued with the PI Manager. + */ +s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) { OSIoMesg ioMsg; OSMesgQueue queue; OSMesg msg; s32 ret; - u32 buffSize = gDmaMgrDmaBuffSize; + size_t buffSize = gDmaMgrDmaBuffSize; s32 pad[2]; if (buffSize == 0) { - buffSize = 0x2000; + buffSize = DMAMGR_DEFAULT_BUFSIZE; } osInvalICache(ram, size); @@ -60,6 +97,9 @@ s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, u32 size) { osCreateMesgQueue(&queue, &msg, 1); while (size > buffSize) { + // The system avoids large DMAs as these would stall the PI for too long, potentially causing issues with + // audio. To allow audio to continue to DMA whenever it needs to, other DMAs are split into manageable chunks. + if (1) {} // Necessary to match ioMsg.hdr.pri = OS_MESG_PRI_NORMAL; @@ -124,7 +164,17 @@ end: return ret; } -s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { +/** + * Callback function to facilitate audio DMA. Audio DMA does not use the request queue as audio data is often needed + * very soon after the request is sent, requiring a higher priority method for enqueueing a DMA on the OS PI command + * queue. + * + * @param pihandle Cartridge ROM PI Handle. + * @param mb IO Message describing the transfer. + * @param direction Read or write. (Only read is allowed) + * @return 0 if the IO Message was successfully put on the OS PI command queue, < 0 otherwise + */ +s32 DmaMgr_AudioDmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { s32 ret; ASSERT(pihandle == gCartHandle, "pihandle == carthandle", "../z_std_dma.c", 530); @@ -143,7 +193,14 @@ s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { return ret; } -void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, u32 size) { +/** + * DMA read from disk drive. Blocks the current thread until DMA completes. + * + * @param ram RAM address to write data to. + * @param rom ROM address to read from. + * @param size Size of transfer. + */ +void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, size_t size) { OSPiHandle* handle = osDriveRomInit(); OSMesgQueue queue; OSMesg msg; @@ -164,20 +221,31 @@ void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, u32 size) { osRecvMesg(&queue, NULL, OS_MESG_BLOCK); } +/** + * DMA error encountered, print error messages and bring up the crash screen. + * + * @param req DMA Request causing the error. + * @param file DMA data filename associated with the operation that errored. + * @param errorName Error name string. + * @param errorDesc Error description string. + * + * This function does not return. + */ void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, const char* errorDesc) { uintptr_t vrom = req->vromAddr; void* ram = req->dramAddr; - u32 size = req->size; + size_t size = req->size; char buff1[80]; char buff2[80]; osSyncPrintf("%c", BEL); osSyncPrintf(VT_FGCOL(RED)); + // "DMA Fatal Error" osSyncPrintf("DMA致命的エラー(%s)\nROM:%X RAM:%X SIZE:%X %s\n", errorDesc != NULL ? errorDesc : (errorName != NULL ? errorName : "???"), vrom, ram, size, file != NULL ? file : "???"); - if (req->filename != NULL) { + if (req->filename != NULL) { // Source file name that issued the DMA request osSyncPrintf("DMA ERROR: %s %d", req->filename, req->line); } else if (sDmaMgrCurFileName != NULL) { osSyncPrintf("DMA ERROR: %s %d", sDmaMgrCurFileName, sDmaMgrCurFileLine); @@ -197,7 +265,14 @@ void DmaMgr_Error(DmaRequest* req, const char* file, const char* errorName, cons Fault_AddHungupAndCrashImpl(buff1, buff2); } -const char* DmaMgr_GetFileNameImpl(uintptr_t vrom) { +/** + * Searches the filesystem for the entry containing the address `vrom`. Retrieves the name of this entry from + * the array of file names. + * + * @param vrom Virtual ROM location + * @return Pointer to associated filename + */ +const char* DmaMgr_FindFileName(uintptr_t vrom) { DmaEntry* iter = gDmaDataTable; const char** name = sDmaMgrFileNames; @@ -217,46 +292,56 @@ const char* DmaMgr_GetFileNameImpl(uintptr_t vrom) { } const char* DmaMgr_GetFileName(uintptr_t vrom) { - const char* ret = DmaMgr_GetFileNameImpl(vrom); + const char* ret = DmaMgr_FindFileName(vrom); if (ret == NULL) { return "(unknown)"; } - if (DmaMgr_CompareName(ret, "kanji") == 0 || DmaMgr_CompareName(ret, "link_animetion") == 0) { + if (DmaMgr_StrCmp(ret, "kanji") == 0 || DmaMgr_StrCmp(ret, "link_animetion") == 0) { + // This check may be related to these files being too large to be loaded all at once, however a NULL filename + // does not prevent them from being loaded. return NULL; } - return ret; } -void DmaMgr_ProcessMsg(DmaRequest* req) { +void DmaMgr_ProcessRequest(DmaRequest* req) { uintptr_t vrom = req->vromAddr; void* ram = req->dramAddr; - u32 size = req->size; + size_t size = req->size; uintptr_t romStart; - u32 romSize; + size_t romSize; u8 found = false; DmaEntry* iter; const char* filename; if (0) { - // the string is defined in .rodata but not used, suggesting - // a debug print is here but optimized out in some way + // The string is defined in .rodata but not used, suggesting a debug print is here but was optimized out in + // some way. The last arg of this print looks like it may be filename, but filename above this block does not + // match. osSyncPrintf("DMA ROM:%08X RAM:%08X SIZE:%08X %s\n"); - // the last arg of this print looks like it may be filename, but - // filename above this block does not match } + // Get the filename (for debugging) filename = DmaMgr_GetFileName(vrom); - iter = gDmaDataTable; + // Iterate through the DMA data table until the region containing the vrom address for this request is found + iter = gDmaDataTable; while (iter->vromEnd != 0) { if (vrom >= iter->vromStart && vrom < iter->vromEnd) { + // Found the region this request falls into + if (1) {} // Necessary to match if (iter->romEnd == 0) { + // romEnd of 0 indicates that the file is uncompressed. Files that are stored uncompressed can have + // only part of their content loaded into RAM, so DMA only the requested region. + if (iter->vromEnd < vrom + size) { + // Error, vrom + size ends up in a different file than it started in + + // "DMA transfers cannot cross segment boundaries" DmaMgr_Error(req, filename, "Segment Alignment Error", "セグメント境界をまたがってDMA転送することはできません"); } @@ -268,19 +353,29 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { osSyncPrintf("No Press ROM:%08X RAM:%08X SIZE:%08X\n", vrom, ram, size); } } else { + // File is compressed. Files that are stored compressed must be loaded into RAM all at once. + romStart = iter->romStart; romSize = iter->romEnd - iter->romStart; if (vrom != iter->vromStart) { + // Error, requested vrom is not the start of a file + + // "DMA transfer cannot be performed from the middle of a compressed segment" DmaMgr_Error(req, filename, "Can't Transfer Segment", "圧縮されたセグメントの途中からはDMA転送することはできません"); } if (size != iter->vromEnd - iter->vromStart) { + // Error, only part of the file was requested + + // "It is not possible to DMA only part of a compressed segment" DmaMgr_Error(req, filename, "Can't Transfer Segment", "圧縮されたセグメントの一部だけをDMA転送することはできません"); } + // Reduce the thread priority and decompress the file, the decompression routine handles the DMA + // in chunks. Restores the thread priority when done. osSetThreadPri(NULL, THREAD_PRI_DMAMGR_LOW); Yaz0_Decompress(romStart, ram, romSize); osSetThreadPri(NULL, THREAD_PRI_DMAMGR); @@ -296,15 +391,21 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { } if (!found) { + // Requested region was not found in the filesystem + if (sDmaMgrIsRomCompressed) { + // Error, rom is compressed so DMA may only be requested within the filesystem bounds + + // "Corresponding data does not exist" DmaMgr_Error(req, NULL, "DATA DON'T EXIST", "該当するデータが存在しません"); return; - } + } else { + // ROM is uncompressed, allow arbitrary DMA even if the region is not marked in the filesystem + DmaMgr_DmaRomToRam(vrom, ram, size); - DmaMgr_DmaRomToRam(vrom, ram, size); - - if (0) { - osSyncPrintf("No Press ROM:%08X RAM:%08X SIZE:%08X (非公式)\n", vrom, ram, size); + if (0) { + osSyncPrintf("No Press ROM:%08X RAM:%08X SIZE:%08X (非公式)\n", vrom, ram, size); + } } } } @@ -313,8 +414,11 @@ void DmaMgr_ThreadEntry(void* arg) { OSMesg msg; DmaRequest* req; + // "DMA manager thread execution start" osSyncPrintf("DMAマネージャスレッド実行開始\n"); + while (true) { + // Wait for DMA Requests to arrive from other threads osRecvMesg(&sDmaMgrMsgQueue, &msg, OS_MESG_BLOCK); req = (DmaRequest*)msg; if (req == NULL) { @@ -325,7 +429,10 @@ void DmaMgr_ThreadEntry(void* arg) { osSyncPrintf("DMA登録受付 dmap=%08x\n", req); } - DmaMgr_ProcessMsg(req); + // Process the DMA request + DmaMgr_ProcessRequest(req); + + // Notify the sender that the request has been processed if (req->notifyQueue != NULL) { osSendMesg(req->notifyQueue, req->notifyMsg, OS_MESG_NOBLOCK); if (0) { @@ -333,11 +440,24 @@ void DmaMgr_ThreadEntry(void* arg) { } } } + + // "DMA manager thread execution end" osSyncPrintf("DMAマネージャスレッド実行終了\n"); } -s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, u32 unk, OSMesgQueue* queue, - OSMesg msg) { +/** + * Submits a DMA request to the DMA manager. For internal use only. + * + * @param req DMA request, filled out internally. + * @param ram Location in DRAM for data to be written. + * @param vrom Virtual ROM location for data to be read. + * @param size Transfer size. + * @param queue Message queue to notify with `msg` once the transfer is complete. + * @param msg Message to send to `queue` once the transfer is complete. + * @return 0 + */ +s32 DmaMgr_SendRequest(DmaRequest* req, void* ram, uintptr_t vrom, size_t size, u32 unk, OSMesgQueue* queue, + OSMesg msg) { static s32 sDmaMgrQueueFullLogged = 0; if ((1 && (ram == NULL)) || (osMemSize < OS_K0_TO_PHYSICAL(ram) + size) || (vrom & 1) || (vrom > 0x4000000) || @@ -357,6 +477,7 @@ s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, sDmaMgrQueueFullLogged++; osSyncPrintf("%c", BEL); osSyncPrintf(VT_FGCOL(RED)); + // "dmaEntryMsgQ is full. Reconsider your queue size." osSyncPrintf("dmaEntryMsgQが一杯です。キューサイズの再検討をおすすめします。"); LOG_NUM("(sizeof(dmaEntryMsgBufs) / sizeof(dmaEntryMsgBufs[0]))", ARRAY_COUNT(sDmaMgrMsgBuf), "../z_std_dma.c", 952); @@ -367,15 +488,24 @@ s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, return 0; } -s32 DmaMgr_SendRequest0(void* ram, uintptr_t vrom, u32 size) { +/** + * Submit a synchronous DMA request. This will block the current thread until the requested transfer is complete. Data + * is immediately available as soon as this function returns. + * + * @param ram Location in DRAM for data to be written. + * @param vrom Virtual ROM location for data to be read. + * @param size Transfer size. + * @return 0 + */ +s32 DmaMgr_RequestSync(void* ram, uintptr_t vrom, size_t size) { DmaRequest req; OSMesgQueue queue; OSMesg msg; s32 ret; osCreateMesgQueue(&queue, &msg, 1); - ret = DmaMgr_SendRequestImpl(&req, ram, vrom, size, 0, &queue, NULL); - if (ret == -1) { + ret = DmaMgr_SendRequest(&req, ram, vrom, size, 0, &queue, NULL); + if (ret == -1) { // DmaMgr_SendRequest only returns 0 return ret; } @@ -388,6 +518,7 @@ void DmaMgr_Init(void) { s32 idx; DmaEntry* iter; + // DMA the dma data table to RAM DmaMgr_DmaRomToRam((uintptr_t)_dmadataSegmentRomStart, _dmadataSegmentStart, (u32)(_dmadataSegmentRomEnd - _dmadataSegmentRomStart)); osSyncPrintf("dma_rom_ad[]\n"); @@ -397,6 +528,7 @@ void DmaMgr_Init(void) { iter = gDmaDataTable; idx = 0; + // Check if the ROM is compressed (romEnd not 0) while (iter->vromEnd != 0) { if (iter->romEnd != 0) { sDmaMgrIsRomCompressed = true; @@ -415,12 +547,15 @@ void DmaMgr_Init(void) { } } + // Ensure that the boot segment always follows after the makerom segment. if ((uintptr_t)_bootSegmentRomStart != gDmaDataTable[0].vromEnd) { osSyncPrintf("_bootSegmentRomStart(%08x) != dma_rom_ad[0].rom_b(%08x)\n", _bootSegmentRomStart, gDmaDataTable[0].vromEnd); + //! @bug The main code file where fault.c resides is not yet loaded Fault_AddHungupAndCrash("../z_std_dma.c", 1055); } + // Start the DMA manager osCreateMesgQueue(&sDmaMgrMsgQueue, sDmaMgrMsgBuf, ARRAY_COUNT(sDmaMgrMsgBuf)); StackCheck_Init(&sDmaMgrStackInfo, sDmaMgrStack, STACK_TOP(sDmaMgrStack), 0, 0x100, "dmamgr"); osCreateThread(&sDmaMgrThread, THREAD_ID_DMAMGR, DmaMgr_ThreadEntry, NULL, STACK_TOP(sDmaMgrStack), @@ -428,14 +563,34 @@ void DmaMgr_Init(void) { osStartThread(&sDmaMgrThread); } -s32 DmaMgr_SendRequest2(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, u32 unk5, OSMesgQueue* queue, OSMesg msg, - const char* file, s32 line) { +/** + * Submit an asynchronous DMA request. Unlike other DMA requests, this will not block the current thread. Data arrival + * is not immediate however, ensure that the request has completed by awaiting a message sent to `queue` when the DMA + * operation has completed. + * + * @param req DMA request structure, filled out internally. + * @param ram Location in DRAM for data to be written. + * @param vrom Virtual ROM location for data to be read. + * @param size Transfer size. + * @param queue Message queue to notify with `msg` once the transfer is complete. + * @param msg Message to send to `queue` once the transfer is complete. + * @param file Debug filename of caller. + * @param line Debug line number of caller. + * @return 0 + */ +s32 DmaMgr_RequestAsync(DmaRequest* req, void* ram, uintptr_t vrom, size_t 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); + return DmaMgr_SendRequest(req, ram, vrom, size, unk5, queue, msg); } -s32 DmaMgr_SendRequest1(void* ram, uintptr_t vrom, u32 size, const char* file, s32 line) { +/** + * Synchronous DMA Request with source file and line info for debugging. + * + * @see DmaMgr_RequestSync + */ +s32 DmaMgr_RequestSyncDebug(void* ram, uintptr_t vrom, size_t size, const char* file, s32 line) { DmaRequest req; s32 ret; OSMesgQueue queue; @@ -445,8 +600,8 @@ s32 DmaMgr_SendRequest1(void* ram, uintptr_t vrom, u32 size, const char* file, s req.filename = file; req.line = line; osCreateMesgQueue(&queue, &msg, 1); - ret = DmaMgr_SendRequestImpl(&req, ram, vrom, size, 0, &queue, NULL); - if (ret == -1) { + ret = DmaMgr_SendRequest(&req, ram, vrom, size, 0, &queue, NULL); + if (ret == -1) { // DmaMgr_SendRequest only returns 0 return ret; } diff --git a/src/code/audioMgr.c b/src/code/audioMgr.c index f3701acc26..01bf54397d 100644 --- a/src/code/audioMgr.c +++ b/src/code/audioMgr.c @@ -56,7 +56,7 @@ void AudioMgr_ThreadEntry(void* arg0) { osSyncPrintf("オーディオマネージャスレッド実行開始\n"); // "Start running audio manager thread" Audio_Init(); - AudioLoad_SetDmaHandler(DmaMgr_DmaHandler); + AudioLoad_SetDmaHandler(DmaMgr_AudioDmaHandler); Audio_InitSound(); osSendMesg(&audioMgr->lockQueue, NULL, OS_MESG_BLOCK); IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptQueue); diff --git a/src/code/game.c b/src/code/game.c index 88d2f5527e..7b3a28ed49 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -88,7 +88,7 @@ void func_800C4344(GameState* gameState) { } gDmaMgrVerbose = HREG(60); - gDmaMgrDmaBuffSize = SREG(21) != 0 ? ALIGN16(SREG(21)) : 0x2000; + gDmaMgrDmaBuffSize = SREG(21) != 0 ? ALIGN16(SREG(21)) : DMAMGR_DEFAULT_BUFSIZE; gSystemArenaLogSeverity = HREG(61); gZeldaArenaLogSeverity = HREG(62); if (HREG(80) == 8) { diff --git a/src/code/load.c b/src/code/load.c index a629a16f58..888f2bdc98 100644 --- a/src/code/load.c +++ b/src/code/load.c @@ -20,7 +20,7 @@ s32 Overlay_Load(uintptr_t vRomStart, uintptr_t vRomEnd, void* vRamStart, void* osSyncPrintf("TEXT,DATA,RODATA+relをDMA転送します(%08x-%08x)\n", allocatedVRamAddr, end); } - DmaMgr_SendRequest0(allocatedVRamAddr, vRomStart, size); + DmaMgr_RequestSync(allocatedVRamAddr, vRomStart, size); ovlOffset = ((s32*)end)[-1]; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index a588f4f2ee..0a2317d5b8 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -679,7 +679,7 @@ void TitleCard_InitPlaceName(PlayState* play, TitleCardContext* titleCtx, void* u32 size = loadedScene->titleFile.vromEnd - loadedScene->titleFile.vromStart; if ((size != 0) && (size <= 0x3000)) { - DmaMgr_SendRequest1(texture, loadedScene->titleFile.vromStart, size, "../z_actor.c", 2765); + DmaMgr_RequestSyncDebug(texture, loadedScene->titleFile.vromStart, size, "../z_actor.c", 2765); } titleCtx->texture = texture; diff --git a/src/code/z_construct.c b/src/code/z_construct.c index 7748c0fba6..414d38aeeb 100644 --- a/src/code/z_construct.c +++ b/src/code/z_construct.c @@ -37,42 +37,43 @@ void Interface_Init(PlayState* play) { osSyncPrintf("parameter->parameterSegment=%x\n", interfaceCtx->parameterSegment); ASSERT(interfaceCtx->parameterSegment != NULL, "parameter->parameterSegment != NULL", "../z_construct.c", 161); - DmaMgr_SendRequest1(interfaceCtx->parameterSegment, (uintptr_t)_parameter_staticSegmentRomStart, parameterSize, - "../z_construct.c", 162); + DmaMgr_RequestSyncDebug(interfaceCtx->parameterSegment, (uintptr_t)_parameter_staticSegmentRomStart, parameterSize, + "../z_construct.c", 162); - interfaceCtx->doActionSegment = GameState_Alloc(&play->state, 0x480, "../z_construct.c", 166); + interfaceCtx->doActionSegment = GameState_Alloc(&play->state, 3 * DO_ACTION_TEX_SIZE, "../z_construct.c", 166); - osSyncPrintf("DOアクション テクスチャ初期=%x\n", 0x480); // "DO Action Texture Initialization" + osSyncPrintf("DOアクション テクスチャ初期=%x\n", 3 * DO_ACTION_TEX_SIZE); // "DO Action Texture Initialization" osSyncPrintf("parameter->do_actionSegment=%x\n", interfaceCtx->doActionSegment); ASSERT(interfaceCtx->doActionSegment != NULL, "parameter->do_actionSegment != NULL", "../z_construct.c", 169); if (gSaveContext.language == LANGUAGE_ENG) { - doActionOffset = 0; + doActionOffset = LANGUAGE_ENG * DO_ACTION_MAX * DO_ACTION_TEX_SIZE; } else if (gSaveContext.language == LANGUAGE_GER) { - doActionOffset = 0x2B80; + doActionOffset = LANGUAGE_GER * DO_ACTION_MAX * DO_ACTION_TEX_SIZE; } else { - doActionOffset = 0x5700; + doActionOffset = LANGUAGE_FRA * DO_ACTION_MAX * DO_ACTION_TEX_SIZE; } - DmaMgr_SendRequest1(interfaceCtx->doActionSegment, (uintptr_t)_do_action_staticSegmentRomStart + doActionOffset, - 0x300, "../z_construct.c", 174); + DmaMgr_RequestSyncDebug(interfaceCtx->doActionSegment, (uintptr_t)_do_action_staticSegmentRomStart + doActionOffset, + 2 * DO_ACTION_TEX_SIZE, "../z_construct.c", 174); if (gSaveContext.language == LANGUAGE_ENG) { - doActionOffset = 0x480; + doActionOffset = 3 * DO_ACTION_TEX_SIZE + LANGUAGE_ENG * DO_ACTION_MAX * DO_ACTION_TEX_SIZE; } else if (gSaveContext.language == LANGUAGE_GER) { - doActionOffset = 0x3000; + doActionOffset = 3 * DO_ACTION_TEX_SIZE + LANGUAGE_GER * DO_ACTION_MAX * DO_ACTION_TEX_SIZE; } else { - doActionOffset = 0x5B80; + doActionOffset = 3 * DO_ACTION_TEX_SIZE + LANGUAGE_FRA * DO_ACTION_MAX * DO_ACTION_TEX_SIZE; } - DmaMgr_SendRequest1(interfaceCtx->doActionSegment + 0x300, - (uintptr_t)_do_action_staticSegmentRomStart + doActionOffset, 0x180, "../z_construct.c", 178); + DmaMgr_RequestSyncDebug(interfaceCtx->doActionSegment + 2 * DO_ACTION_TEX_SIZE, + (uintptr_t)_do_action_staticSegmentRomStart + doActionOffset, DO_ACTION_TEX_SIZE, + "../z_construct.c", 178); - interfaceCtx->iconItemSegment = GameState_Alloc(&play->state, 0x4000, "../z_construct.c", 190); + interfaceCtx->iconItemSegment = GameState_Alloc(&play->state, 4 * ICON_ITEM_TEX_SIZE, "../z_construct.c", 190); // "Icon Item Texture Initialization = %x" - osSyncPrintf("アイコンアイテム テクスチャ初期=%x\n", 0x4000); + osSyncPrintf("アイコンアイテム テクスチャ初期=%x\n", 4 * ICON_ITEM_TEX_SIZE); osSyncPrintf("parameter->icon_itemSegment=%x\n", interfaceCtx->iconItemSegment); ASSERT(interfaceCtx->iconItemSegment != NULL, "parameter->icon_itemSegment != NULL", "../z_construct.c", 193); @@ -82,31 +83,36 @@ void Interface_Init(PlayState* play) { gSaveContext.equips.buttonItems[3]); if (gSaveContext.equips.buttonItems[0] < 0xF0) { - DmaMgr_SendRequest1(interfaceCtx->iconItemSegment, - (uintptr_t)_icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[0] * 0x1000, - 0x1000, "../z_construct.c", 198); + DmaMgr_RequestSyncDebug(interfaceCtx->iconItemSegment, + (uintptr_t)_icon_item_staticSegmentRomStart + + gSaveContext.equips.buttonItems[0] * ICON_ITEM_TEX_SIZE, + ICON_ITEM_TEX_SIZE, "../z_construct.c", 198); } else if (gSaveContext.equips.buttonItems[0] != 0xFF) { - DmaMgr_SendRequest1(interfaceCtx->iconItemSegment, - (uintptr_t)_icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[0] * 0x1000, - 0x1000, "../z_construct.c", 203); + DmaMgr_RequestSyncDebug(interfaceCtx->iconItemSegment, + (uintptr_t)_icon_item_staticSegmentRomStart + + gSaveContext.equips.buttonItems[0] * ICON_ITEM_TEX_SIZE, + ICON_ITEM_TEX_SIZE, "../z_construct.c", 203); } if (gSaveContext.equips.buttonItems[1] < 0xF0) { - DmaMgr_SendRequest1(interfaceCtx->iconItemSegment + 0x1000, - (uintptr_t)_icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[1] * 0x1000, - 0x1000, "../z_construct.c", 209); + DmaMgr_RequestSyncDebug(interfaceCtx->iconItemSegment + ICON_ITEM_TEX_SIZE, + (uintptr_t)_icon_item_staticSegmentRomStart + + gSaveContext.equips.buttonItems[1] * ICON_ITEM_TEX_SIZE, + ICON_ITEM_TEX_SIZE, "../z_construct.c", 209); } if (gSaveContext.equips.buttonItems[2] < 0xF0) { - DmaMgr_SendRequest1(interfaceCtx->iconItemSegment + 0x2000, - (uintptr_t)_icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[2] * 0x1000, - 0x1000, "../z_construct.c", 214); + DmaMgr_RequestSyncDebug(interfaceCtx->iconItemSegment + 2 * ICON_ITEM_TEX_SIZE, + (uintptr_t)_icon_item_staticSegmentRomStart + + gSaveContext.equips.buttonItems[2] * ICON_ITEM_TEX_SIZE, + ICON_ITEM_TEX_SIZE, "../z_construct.c", 214); } if (gSaveContext.equips.buttonItems[3] < 0xF0) { - DmaMgr_SendRequest1(interfaceCtx->iconItemSegment + 0x3000, - (uintptr_t)_icon_item_staticSegmentRomStart + gSaveContext.equips.buttonItems[3] * 0x1000, - 0x1000, "../z_construct.c", 219); + DmaMgr_RequestSyncDebug(interfaceCtx->iconItemSegment + 3 * ICON_ITEM_TEX_SIZE, + (uintptr_t)_icon_item_staticSegmentRomStart + + gSaveContext.equips.buttonItems[3] * ICON_ITEM_TEX_SIZE, + ICON_ITEM_TEX_SIZE, "../z_construct.c", 219); } osSyncPrintf("EVENT=%d\n", ((void)0, gSaveContext.timerState)); @@ -182,7 +188,11 @@ void Message_Init(PlayState* play) { View_Init(&msgCtx->view, play->state.gfxCtx); - msgCtx->textboxSegment = GameState_Alloc(&play->state, 0x2200, "../z_construct.c", 349); + msgCtx->textboxSegment = + GameState_Alloc(&play->state, + MESSAGE_STATIC_TEX_SIZE + + MAX(MAX(ICON_ITEM_TEX_SIZE, ICON_ITEM_24_TEX_SIZE), 2 * MESSAGE_TEXTURE_STATIC_TEX_SIZE), + "../z_construct.c", 349); osSyncPrintf("message->fukidashiSegment=%x\n", msgCtx->textboxSegment); diff --git a/src/code/z_kanfont.c b/src/code/z_kanfont.c index 9c70651614..2da6c53a9a 100644 --- a/src/code/z_kanfont.c +++ b/src/code/z_kanfont.c @@ -9,9 +9,9 @@ void func_8006EE50(Font* font, u16 arg1, u16 arg2) { * at `codePointIndex`. The value of `character` is the ASCII codepoint subtract ' '/0x20. */ void Font_LoadChar(Font* font, u8 character, u16 codePointIndex) { - DmaMgr_SendRequest1(&font->charTexBuf[codePointIndex], - (u32)&_nes_font_staticSegmentRomStart[character * FONT_CHAR_TEX_SIZE], FONT_CHAR_TEX_SIZE, - "../z_kanfont.c", 93); + DmaMgr_RequestSyncDebug(&font->charTexBuf[codePointIndex], + (uintptr_t)_nes_font_staticSegmentRomStart + character * FONT_CHAR_TEX_SIZE, + FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 93); } /** @@ -20,9 +20,10 @@ 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) { - DmaMgr_SendRequest1(font->iconBuf, - (u32)&_message_staticSegmentRomStart[4 * MESSAGE_STATIC_TEX_SIZE + icon * FONT_CHAR_TEX_SIZE], - FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 100); + DmaMgr_RequestSyncDebug(font->iconBuf, + (uintptr_t)_message_staticSegmentRomStart + 4 * MESSAGE_STATIC_TEX_SIZE + + icon * FONT_CHAR_TEX_SIZE, + FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 100); } /** @@ -31,18 +32,18 @@ void Font_LoadMessageBoxIcon(Font* font, u16 icon) { */ void Font_LoadOrderedFont(Font* font) { u8* fontBuf; - u32 fontStatic; + uintptr_t fontStatic; s32 len; s32 jj; s32 codePointIndex; s32 fontBufIndex; - u32 offset; + size_t offset; font->msgOffset = _message_0xFFFC_nes - (const char*)_nes_message_data_staticSegmentStart; len = font->msgLength = _message_0xFFFD_nes - _message_0xFFFC_nes; - DmaMgr_SendRequest1(font->msgBuf, (u32)&_nes_message_data_staticSegmentRomStart[font->msgOffset], len, - "../z_kanfont.c", 122); + DmaMgr_RequestSyncDebug(font->msgBuf, (uintptr_t)_nes_message_data_staticSegmentRomStart + font->msgOffset, len, + "../z_kanfont.c", 122); osSyncPrintf("msg_data=%x, msg_data0=%x jj=%x\n", font->msgOffset, font->msgLength, jj = len); len = jj; @@ -54,12 +55,12 @@ void Font_LoadOrderedFont(Font* font) { if (font->msgBuf[codePointIndex] != MESSAGE_NEWLINE) { fontBuf = font->fontBuf + fontBufIndex * 8; - fontStatic = (u32)_nes_font_staticSegmentRomStart; + fontStatic = (uintptr_t)_nes_font_staticSegmentRomStart; osSyncPrintf("nes_mes_buf[%d]=%d\n", codePointIndex, font->msgBuf[codePointIndex]); - offset = (font->msgBuf[codePointIndex] - '\x20') * FONT_CHAR_TEX_SIZE; - DmaMgr_SendRequest1(fontBuf, fontStatic + offset, FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 134); + offset = (font->msgBuf[codePointIndex] - ' ') * FONT_CHAR_TEX_SIZE; + DmaMgr_RequestSyncDebug(fontBuf, fontStatic + offset, FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 134); fontBufIndex += FONT_CHAR_TEX_SIZE / 8; } } diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index cc6966f735..580052287d 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, skyboxCtx->staticSegments[0], + DmaMgr_RequestAsync(&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, skyboxCtx->staticSegments[1], + DmaMgr_RequestAsync(&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, skyboxCtx->palettes, + DmaMgr_RequestAsync(&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, (u8*)skyboxCtx->palettes + size, + DmaMgr_RequestAsync(&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, skyboxCtx->palettes, + DmaMgr_RequestAsync(&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, (u8*)skyboxCtx->palettes + size, + DmaMgr_RequestAsync(&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_map_exp.c b/src/code/z_map_exp.c index 3becb670f2..298a360e85 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -130,10 +130,10 @@ void Map_InitData(PlayState* play, s16 room) { osSyncPrintf("KKK=%d\n", extendedMapIndex); osSyncPrintf(VT_RST); sEntranceIconMapIndex = extendedMapIndex; - DmaMgr_SendRequest1(interfaceCtx->mapSegment, - (uintptr_t)_map_grand_staticSegmentRomStart + - gMapData->owMinimapTexOffset[extendedMapIndex], - gMapData->owMinimapTexSize[mapIndex], "../z_map_exp.c", 309); + DmaMgr_RequestSyncDebug(interfaceCtx->mapSegment, + (uintptr_t)_map_grand_staticSegmentRomStart + + gMapData->owMinimapTexOffset[extendedMapIndex], + gMapData->owMinimapTexSize[mapIndex], "../z_map_exp.c", 309); interfaceCtx->unk_258 = mapIndex; break; case SCENE_YDAN: @@ -159,10 +159,10 @@ void Map_InitData(PlayState* play, s16 room) { osSyncPrintf("デクの樹ダンジョンMAP テクスチャDMA(%x) scene_id_offset=%d VREG(30)=%d\n", room, mapIndex, VREG(30)); osSyncPrintf(VT_RST); - DmaMgr_SendRequest1(play->interfaceCtx.mapSegment, - (uintptr_t)_map_i_staticSegmentRomStart + - ((gMapData->dgnMinimapTexIndexOffset[mapIndex] + room) * 0xFF0), - 0xFF0, "../z_map_exp.c", 346); + DmaMgr_RequestSyncDebug(play->interfaceCtx.mapSegment, + (uintptr_t)_map_i_staticSegmentRomStart + + ((gMapData->dgnMinimapTexIndexOffset[mapIndex] + room) * MAP_I_TEX_SIZE), + MAP_I_TEX_SIZE, "../z_map_exp.c", 346); R_COMPASS_OFFSET_X = gMapData->roomCompassOffsetX[mapIndex][room]; R_COMPASS_OFFSET_Y = gMapData->roomCompassOffsetY[mapIndex][room]; Map_SetFloorPalettesData(play, VREG(30)); @@ -385,13 +385,15 @@ void Minimap_Draw(PlayState* play) { if (CHECK_DUNGEON_ITEM(DUNGEON_MAP, mapIndex)) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 100, 255, 255, interfaceCtx->minimapAlpha); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, interfaceCtx->mapSegment, G_IM_FMT_I, 96, 85, 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(OVERLAY_DISP++, interfaceCtx->mapSegment, G_IM_FMT_I, MAP_I_TEX_WIDTH, + MAP_I_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); gSPTextureRectangle(OVERLAY_DISP++, R_DGN_MINIMAP_X << 2, R_DGN_MINIMAP_Y << 2, - (R_DGN_MINIMAP_X + 96) << 2, (R_DGN_MINIMAP_Y + 85) << 2, G_TX_RENDERTILE, - 0, 0, 1 << 10, 1 << 10); + (R_DGN_MINIMAP_X + MAP_I_TEX_WIDTH) << 2, + (R_DGN_MINIMAP_Y + MAP_I_TEX_HEIGHT) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); } if (CHECK_DUNGEON_ITEM(DUNGEON_COMPASS, mapIndex)) { diff --git a/src/code/z_message_PAL.c b/src/code/z_message_PAL.c index 189ab1eeed..7dce3ecb61 100644 --- a/src/code/z_message_PAL.c +++ b/src/code/z_message_PAL.c @@ -1166,18 +1166,19 @@ 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(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, - (uintptr_t)_icon_item_staticSegmentRomStart + (itemId * 0x1000), 0x1000, - "../z_message_PAL.c", 1473); + DmaMgr_RequestSyncDebug(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, + (uintptr_t)_icon_item_staticSegmentRomStart + (itemId * ICON_ITEM_TEX_SIZE), + ICON_ITEM_TEX_SIZE, "../z_message_PAL.c", 1473); // "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; - DmaMgr_SendRequest1(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, - (uintptr_t)_icon_item_24_staticSegmentRomStart + (itemId - ITEM_MEDALLION_FOREST) * 0x900, - 0x900, "../z_message_PAL.c", 1482); + DmaMgr_RequestSyncDebug(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, + (uintptr_t)_icon_item_24_staticSegmentRomStart + + (itemId - ITEM_MEDALLION_FOREST) * ICON_ITEM_24_TEX_SIZE, + ICON_ITEM_24_TEX_SIZE, "../z_message_PAL.c", 1482); // "Item 24" osSyncPrintf("アイテム24=%d (%d) {%d}\n", itemId, itemId - ITEM_KOKIRI_EMERALD, 84); } @@ -1534,14 +1535,14 @@ 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(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, - (uintptr_t)_message_texture_staticSegmentRomStart + - msgCtx->textboxBackgroundIdx * 0x900, - 0x900, "../z_message_PAL.c", 1830); - DmaMgr_SendRequest1(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE + 0x900, - (uintptr_t)_message_texture_staticSegmentRomStart + - (msgCtx->textboxBackgroundIdx + 1) * 0x900, - 0x900, "../z_message_PAL.c", 1834); + DmaMgr_RequestSyncDebug(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE, + (uintptr_t)_message_texture_staticSegmentRomStart + + msgCtx->textboxBackgroundIdx * MESSAGE_TEXTURE_STATIC_TEX_SIZE, + MESSAGE_TEXTURE_STATIC_TEX_SIZE, "../z_message_PAL.c", 1830); + DmaMgr_RequestSyncDebug(msgCtx->textboxSegment + MESSAGE_STATIC_TEX_SIZE + MESSAGE_TEXTURE_STATIC_TEX_SIZE, + (uintptr_t)_message_texture_staticSegmentRomStart + + (msgCtx->textboxBackgroundIdx + 1) * MESSAGE_TEXTURE_STATIC_TEX_SIZE, + MESSAGE_TEXTURE_STATIC_TEX_SIZE, "../z_message_PAL.c", 1834); msgCtx->msgBufPos += 3; R_TEXTBOX_BG_YPOS = R_TEXTBOX_Y + 8; numLines = 2; @@ -1636,24 +1637,24 @@ void Message_OpenText(PlayState* play, u16 textId) { if (sTextIsCredits) { Message_FindCreditsMessage(play, textId); msgCtx->msgLength = font->msgLength; - DmaMgr_SendRequest1(font->msgBuf, (uintptr_t)_staff_message_data_staticSegmentRomStart + font->msgOffset, - font->msgLength, "../z_message_PAL.c", 1954); + DmaMgr_RequestSyncDebug(font->msgBuf, (uintptr_t)_staff_message_data_staticSegmentRomStart + font->msgOffset, + font->msgLength, "../z_message_PAL.c", 1954); } else { if (gSaveContext.language == LANGUAGE_ENG) { Message_FindMessage(play, textId); msgCtx->msgLength = font->msgLength; - DmaMgr_SendRequest1(font->msgBuf, (uintptr_t)_nes_message_data_staticSegmentRomStart + font->msgOffset, - font->msgLength, "../z_message_PAL.c", 1966); + DmaMgr_RequestSyncDebug(font->msgBuf, (uintptr_t)_nes_message_data_staticSegmentRomStart + font->msgOffset, + font->msgLength, "../z_message_PAL.c", 1966); } else if (gSaveContext.language == LANGUAGE_GER) { Message_FindMessage(play, textId); msgCtx->msgLength = font->msgLength; - DmaMgr_SendRequest1(font->msgBuf, (uintptr_t)_ger_message_data_staticSegmentRomStart + font->msgOffset, - font->msgLength, "../z_message_PAL.c", 1978); + DmaMgr_RequestSyncDebug(font->msgBuf, (uintptr_t)_ger_message_data_staticSegmentRomStart + font->msgOffset, + font->msgLength, "../z_message_PAL.c", 1978); } else { Message_FindMessage(play, textId); msgCtx->msgLength = font->msgLength; - DmaMgr_SendRequest1(font->msgBuf, (uintptr_t)_fra_message_data_staticSegmentRomStart + font->msgOffset, - font->msgLength, "../z_message_PAL.c", 1990); + DmaMgr_RequestSyncDebug(font->msgBuf, (uintptr_t)_fra_message_data_staticSegmentRomStart + font->msgOffset, + font->msgLength, "../z_message_PAL.c", 1990); } } msgCtx->textBoxProperties = font->charTexBuf[0]; @@ -1663,10 +1664,10 @@ void Message_OpenText(PlayState* play, u16 textId) { // "Text Box Type" osSyncPrintf("吹き出し種類=%d\n", msgCtx->textBoxType); if (textBoxType < TEXTBOX_TYPE_NONE_BOTTOM) { - DmaMgr_SendRequest1(msgCtx->textboxSegment, - (uintptr_t)_message_staticSegmentRomStart + - (messageStaticIndices[textBoxType] * MESSAGE_STATIC_TEX_SIZE), - MESSAGE_STATIC_TEX_SIZE, "../z_message_PAL.c", 2006); + DmaMgr_RequestSyncDebug(msgCtx->textboxSegment, + (uintptr_t)_message_staticSegmentRomStart + + (messageStaticIndices[textBoxType] * MESSAGE_STATIC_TEX_SIZE), + MESSAGE_STATIC_TEX_SIZE, "../z_message_PAL.c", 2006); if (textBoxType == TEXTBOX_TYPE_BLACK) { msgCtx->textboxColorRed = 0; msgCtx->textboxColorGreen = 0; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index f23bc93483..90996bc9f7 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -4,11 +4,6 @@ #include "assets/textures/do_action_static/do_action_static.h" #include "assets/textures/icon_item_static/icon_item_static.h" -// TODO extract this information from the texture definitions themselves -#define DO_ACTION_TEX_WIDTH 48 -#define DO_ACTION_TEX_HEIGHT 16 -#define DO_ACTION_TEX_SIZE ((DO_ACTION_TEX_WIDTH * DO_ACTION_TEX_HEIGHT) / 2) // (sizeof(gCheckDoActionENGTex)) - typedef struct { /* 0x00 */ u8 sceneId; /* 0x01 */ u8 flags1; @@ -1277,10 +1272,10 @@ void Interface_LoadItemIcon1(PlayState* play, u16 button) { InterfaceContext* interfaceCtx = &play->interfaceCtx; osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, 1); - DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, interfaceCtx->iconItemSegment + button * 0x1000, + DmaMgr_RequestAsync(&interfaceCtx->dmaRequest_160, interfaceCtx->iconItemSegment + button * ICON_ITEM_TEX_SIZE, (uintptr_t)_icon_item_staticSegmentRomStart + - (gSaveContext.equips.buttonItems[button] * 0x1000), - 0x1000, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1171); + (gSaveContext.equips.buttonItems[button] * ICON_ITEM_TEX_SIZE), + ICON_ITEM_TEX_SIZE, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1171); osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); } @@ -1288,10 +1283,10 @@ void Interface_LoadItemIcon2(PlayState* play, u16 button) { InterfaceContext* interfaceCtx = &play->interfaceCtx; osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, 1); - DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_180, interfaceCtx->iconItemSegment + button * 0x1000, + DmaMgr_RequestAsync(&interfaceCtx->dmaRequest_180, interfaceCtx->iconItemSegment + button * ICON_ITEM_TEX_SIZE, (uintptr_t)_icon_item_staticSegmentRomStart + - (gSaveContext.equips.buttonItems[button] * 0x1000), - 0x1000, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1193); + (gSaveContext.equips.buttonItems[button] * ICON_ITEM_TEX_SIZE), + ICON_ITEM_TEX_SIZE, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1193); osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); } @@ -2086,7 +2081,7 @@ void Interface_LoadActionLabel(InterfaceContext* interfaceCtx, u16 action, s16 l if ((action != DO_ACTION_NONE) && (action != DO_ACTION_MAX + DO_ACTION_NONE) && (action != 2 * DO_ACTION_MAX + DO_ACTION_NONE)) { osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, 1); - DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, + DmaMgr_RequestAsync(&interfaceCtx->dmaRequest_160, interfaceCtx->doActionSegment + (loadOffset * DO_ACTION_TEX_SIZE), (uintptr_t)_do_action_staticSegmentRomStart + (action * DO_ACTION_TEX_SIZE), DO_ACTION_TEX_SIZE, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 2145); @@ -2150,7 +2145,7 @@ void Interface_LoadActionLabelB(PlayState* play, u16 action) { interfaceCtx->unk_1FC = action; osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, 1); - DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE, + DmaMgr_RequestAsync(&interfaceCtx->dmaRequest_160, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE, (uintptr_t)_do_action_staticSegmentRomStart + (action * DO_ACTION_TEX_SIZE), DO_ACTION_TEX_SIZE, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 2228); osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); diff --git a/src/code/z_play.c b/src/code/z_play.c index b2fd9d5aaf..b08f4c61cc 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1388,7 +1388,7 @@ void* Play_LoadFile(PlayState* this, RomFile* file) { size = file->vromEnd - file->vromStart; allocp = GameState_Alloc(&this->state, size, "../z_play.c", 4692); - DmaMgr_SendRequest1(allocp, file->vromStart, size, "../z_play.c", 4694); + DmaMgr_RequestSyncDebug(allocp, file->vromStart, size, "../z_play.c", 4694); return allocp; } diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 5ccf3aae81..00fbf40e0b 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1644,11 +1644,11 @@ u32 func_80091738(PlayState* play, u8* segment, SkelAnime* skelAnime) { size = gObjectTable[OBJECT_GAMEPLAY_KEEP].vromEnd - gObjectTable[OBJECT_GAMEPLAY_KEEP].vromStart; ptr = segment + PAUSE_EQUIP_BUFFER_SIZE; - DmaMgr_SendRequest1(ptr, gObjectTable[OBJECT_GAMEPLAY_KEEP].vromStart, size, "../z_player_lib.c", 2982); + DmaMgr_RequestSyncDebug(ptr, gObjectTable[OBJECT_GAMEPLAY_KEEP].vromStart, size, "../z_player_lib.c", 2982); size = gObjectTable[linkObjectId].vromEnd - gObjectTable[linkObjectId].vromStart; ptr = segment + PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE; - DmaMgr_SendRequest1(ptr, gObjectTable[linkObjectId].vromStart, size, "../z_player_lib.c", 2988); + DmaMgr_RequestSyncDebug(ptr, gObjectTable[linkObjectId].vromStart, size, "../z_player_lib.c", 2988); ptr = (void*)ALIGN16((u32)ptr + size); diff --git a/src/code/z_room.c b/src/code/z_room.c index 9746dba6b2..dcfc35748c 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -603,7 +603,7 @@ s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) { roomCtx->unk_34 = (void*)ALIGN16((u32)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7)); osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1); - DmaMgr_SendRequest2(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, + DmaMgr_RequestAsync(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, &roomCtx->loadQueue, NULL, "../z_room.c", 1036); roomCtx->unk_30 ^= 1; diff --git a/src/code/z_sample.c b/src/code/z_sample.c index 5baafb6f9b..3b5e1c208f 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -80,7 +80,7 @@ void Sample_LoadTitleStatic(SampleState* this) { u32 size = _title_staticSegmentRomEnd - _title_staticSegmentRomStart; this->staticSegment = GameState_Alloc(&this->state, size, "../z_sample.c", 163); - DmaMgr_SendRequest1(this->staticSegment, (uintptr_t)_title_staticSegmentRomStart, size, "../z_sample.c", 164); + DmaMgr_RequestSyncDebug(this->staticSegment, (uintptr_t)_title_staticSegmentRomStart, size, "../z_sample.c", 164); } void Sample_Init(GameState* thisx) { diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 7a376f519f..9cc1975474 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -19,8 +19,8 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId) { "this->num < OBJECT_EXCHANGE_BANK_MAX && (this->status[this->num].Segment + size) < this->endSegment", "../z_scene.c", 142); - DmaMgr_SendRequest1(objectCtx->status[objectCtx->num].segment, gObjectTable[objectId].vromStart, size, - "../z_scene.c", 145); + DmaMgr_RequestSyncDebug(objectCtx->status[objectCtx->num].segment, gObjectTable[objectId].vromStart, size, + "../z_scene.c", 145); if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) { objectCtx->status[objectCtx->num + 1].segment = @@ -89,7 +89,7 @@ void Object_UpdateBank(ObjectContext* objectCtx) { objectFile = &gObjectTable[-status->id]; size = objectFile->vromEnd - objectFile->vromStart; osSyncPrintf("OBJECT EXCHANGE BANK-%2d SIZE %8.3fK SEG=%08x\n", i, size / 1024.0f, status->segment); - DmaMgr_SendRequest2(&status->dmaRequest, status->segment, objectFile->vromStart, size, 0, + DmaMgr_RequestAsync(&status->dmaRequest, status->segment, objectFile->vromStart, size, 0, &status->loadQueue, NULL, "../z_scene.c", 266); } else if (osRecvMesg(&status->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { status->id = -status->id; @@ -131,7 +131,7 @@ void func_800981B8(ObjectContext* objectCtx) { objectCtx->status[i].segment); osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (s32)objectCtx->status[i].segment + size, objectCtx->spaceEnd); - DmaMgr_SendRequest1(objectCtx->status[i].segment, gObjectTable[id].vromStart, size, "../z_scene.c", 342); + DmaMgr_RequestSyncDebug(objectCtx->status[i].segment, gObjectTable[id].vromStart, size, "../z_scene.c", 342); } } diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 92e2e0d834..43e7e02d80 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -841,7 +841,7 @@ void AnimationContext_SetLoadFrame(PlayState* play, LinkAnimationHeader* animati s32 pad; osCreateMesgQueue(&entry->data.load.msgQueue, &entry->data.load.msg, 1); - DmaMgr_SendRequest2(&entry->data.load.req, frameTable, + DmaMgr_RequestAsync(&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 417e23e55c..56cd74cb38 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -410,16 +410,16 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1055); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], gNormalSkyFiles[skybox1Index].file.vromStart, size, - "../z_vr_box.c", 1058); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], gNormalSkyFiles[skybox1Index].file.vromStart, size, + "../z_vr_box.c", 1058); size = gNormalSkyFiles[skybox2Index].file.vromEnd - gNormalSkyFiles[skybox2Index].file.vromStart; skyboxCtx->staticSegments[1] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1060); ASSERT(skyboxCtx->staticSegments[1] != NULL, "vr_box->vr_box_staticSegment[1] != NULL", "../z_vr_box.c", 1061); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[1], gNormalSkyFiles[skybox2Index].file.vromStart, size, - "../z_vr_box.c", 1064); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[1], gNormalSkyFiles[skybox2Index].file.vromStart, size, + "../z_vr_box.c", 1064); if ((skybox1Index & 1) ^ ((skybox1Index & 4) >> 2)) { size = gNormalSkyFiles[skybox1Index].palette.vromEnd - gNormalSkyFiles[skybox1Index].palette.vromStart; @@ -428,10 +428,10 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1073); - DmaMgr_SendRequest1(skyboxCtx->palettes, gNormalSkyFiles[skybox1Index].palette.vromStart, size, - "../z_vr_box.c", 1075); - DmaMgr_SendRequest1((u8*)skyboxCtx->palettes + size, gNormalSkyFiles[skybox2Index].palette.vromStart, - size, "../z_vr_box.c", 1077); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, gNormalSkyFiles[skybox1Index].palette.vromStart, size, + "../z_vr_box.c", 1075); + DmaMgr_RequestSyncDebug((u8*)skyboxCtx->palettes + size, + gNormalSkyFiles[skybox2Index].palette.vromStart, size, "../z_vr_box.c", 1077); } else { size = gNormalSkyFiles[skybox1Index].palette.vromEnd - gNormalSkyFiles[skybox1Index].palette.vromStart; @@ -439,10 +439,10 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1086); - DmaMgr_SendRequest1(skyboxCtx->palettes, gNormalSkyFiles[skybox2Index].palette.vromStart, size, - "../z_vr_box.c", 1088); - DmaMgr_SendRequest1((u8*)skyboxCtx->palettes + size, gNormalSkyFiles[skybox1Index].palette.vromStart, - size, "../z_vr_box.c", 1090); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, gNormalSkyFiles[skybox2Index].palette.vromStart, size, + "../z_vr_box.c", 1088); + DmaMgr_RequestSyncDebug((u8*)skyboxCtx->palettes + size, + gNormalSkyFiles[skybox1Index].palette.vromStart, size, "../z_vr_box.c", 1090); } break; @@ -455,14 +455,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1128); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1129); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1129); start = (uintptr_t)_vr_SP1a_pal_staticSegmentRomStart; size = (uintptr_t)_vr_SP1a_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1132); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1133); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1134); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1134); skyboxCtx->rot.y = 0.8f; break; case SKYBOX_OVERCAST_SUNSET: @@ -472,21 +472,21 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1156); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1159); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1159); skyboxCtx->staticSegments[1] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1162); ASSERT(skyboxCtx->staticSegments[1] != NULL, "vr_box->vr_box_staticSegment[1] != NULL", "../z_vr_box.c", 1163); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[1], start, size, "../z_vr_box.c", 1166); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[1], start, size, "../z_vr_box.c", 1166); start = (uintptr_t)_vr_cloud2_pal_staticSegmentRomStart; size = (uintptr_t)_vr_cloud2_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size * 2, "../z_vr_box.c", 1170); 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((u8*)skyboxCtx->palettes + size, start, size, "../z_vr_box.c", 1175); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1173); + DmaMgr_RequestSyncDebug((u8*)skyboxCtx->palettes + size, start, size, "../z_vr_box.c", 1175); break; case SKYBOX_MARKET_ADULT: skyboxCtx->unk_140 = 1; @@ -497,7 +497,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1183); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1184); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1184); start = (uintptr_t)_vr_RUVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_RUVR_pal_staticSegmentRomEnd - start; @@ -506,7 +506,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1188); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1189); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1190); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1190); break; case SKYBOX_CUTSCENE_MAP: start = (uintptr_t)_vr_holy0_staticSegmentRomStart; @@ -515,7 +515,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1197); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1200); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1200); start = (uintptr_t)_vr_holy1_staticSegmentRomStart; size = (uintptr_t)_vr_holy1_staticSegmentRomEnd - start; @@ -523,16 +523,16 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[1] != NULL, "vr_box->vr_box_staticSegment[1] != NULL", "../z_vr_box.c", 1204); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[1], start, size, "../z_vr_box.c", 1207); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[1], start, size, "../z_vr_box.c", 1207); start = (uintptr_t)_vr_holy0_pal_staticSegmentRomStart; size = (uintptr_t)_vr_holy0_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size * 2, "../z_vr_box.c", 1211); 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((u8*)skyboxCtx->palettes + size, (uintptr_t)_vr_holy1_pal_staticSegmentRomStart, size, - "../z_vr_box.c", 1216); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1214); + DmaMgr_RequestSyncDebug((u8*)skyboxCtx->palettes + size, (uintptr_t)_vr_holy1_pal_staticSegmentRomStart, + size, "../z_vr_box.c", 1216); break; case SKYBOX_HOUSE_LINK: skyboxCtx->unk_140 = 1; @@ -543,14 +543,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1227); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1228); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1228); start = (uintptr_t)_vr_LHVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_LHVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1231); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1232); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1233); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1233); break; case SKYBOX_MARKET_CHILD_DAY: skyboxCtx->unk_140 = 1; @@ -561,14 +561,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1258); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1259); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1259); start = (uintptr_t)_vr_MDVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_MDVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1262); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1263); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1264); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1264); break; case SKYBOX_MARKET_CHILD_NIGHT: skyboxCtx->unk_140 = 1; @@ -579,7 +579,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1272); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1273); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1273); start = (uintptr_t)_vr_MNVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_MNVR_pal_staticSegmentRomEnd - start; @@ -588,7 +588,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1277); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1278); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1279); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1279); break; case SKYBOX_HAPPY_MASK_SHOP: skyboxCtx->unk_140 = 1; @@ -599,14 +599,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1287); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1288); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1288); start = (uintptr_t)_vr_FCVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_FCVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1291); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1292); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1293); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1293); skyboxCtx->rot.y = 0.8f; break; case SKYBOX_HOUSE_KNOW_IT_ALL_BROTHERS: @@ -618,14 +618,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1302); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1303); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1303); start = (uintptr_t)_vr_KHVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_KHVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1306); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1307); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1308); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1308); break; case SKYBOX_HOUSE_OF_TWINS: skyboxCtx->unk_140 = 2; @@ -636,14 +636,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1332); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1333); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1333); start = (uintptr_t)_vr_K3VR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_K3VR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1336); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1337); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1338); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1338); break; case SKYBOX_STABLES: skyboxCtx->unk_140 = 1; @@ -654,14 +654,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1346); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1347); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1347); start = (uintptr_t)_vr_MLVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_MLVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1350); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1351); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1352); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1352); break; case SKYBOX_HOUSE_KAKARIKO: skyboxCtx->unk_140 = 1; @@ -672,14 +672,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1360); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1361); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1361); start = (uintptr_t)_vr_KKRVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_KKRVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1364); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1365); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1366); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1366); break; case SKYBOX_KOKIRI_SHOP: skyboxCtx->unk_140 = 1; @@ -690,14 +690,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1374); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1375); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1375); start = (uintptr_t)_vr_KSVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_KSVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1378); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1379); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1380); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1380); skyboxCtx->rot.y = 0.8f; break; case SKYBOX_GORON_SHOP: @@ -709,14 +709,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1406); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1407); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1407); start = (uintptr_t)_vr_GLVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_GLVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1410); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1411); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1412); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1412); skyboxCtx->rot.y = 0.8f; break; case SKYBOX_ZORA_SHOP: @@ -728,14 +728,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1421); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1422); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1422); start = (uintptr_t)_vr_ZRVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_ZRVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1425); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1426); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1427); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1427); skyboxCtx->rot.y = 0.8f; break; case SKYBOX_POTION_SHOP_KAKARIKO: @@ -747,14 +747,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1452); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1453); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1453); start = (uintptr_t)_vr_DGVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_DGVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1456); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1457); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1458); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1458); skyboxCtx->rot.y = 0.8f; break; case SKYBOX_POTION_SHOP_MARKET: @@ -766,14 +766,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1467); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1468); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1468); start = (uintptr_t)_vr_ALVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_ALVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1471); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1472); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1473); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1473); skyboxCtx->rot.y = 0.8f; break; case SKYBOX_BOMBCHU_SHOP: @@ -785,14 +785,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1482); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1483); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1483); start = (uintptr_t)_vr_NSVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_NSVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1486); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1487); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1488); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1488); skyboxCtx->rot.y = 0.8f; break; case SKYBOX_HOUSE_RICHARD: @@ -804,14 +804,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1513); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1514); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1514); start = (uintptr_t)_vr_IPVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_IPVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1517); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1518); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1519); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1519); break; case SKYBOX_HOUSE_IMPA: skyboxCtx->unk_140 = 1; @@ -822,14 +822,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1527); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1528); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1528); start = (uintptr_t)_vr_LBVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_LBVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1531); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1532); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1533); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1533); break; case SKYBOX_TENT: skyboxCtx->unk_140 = 2; @@ -840,14 +840,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1541); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1542); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1542); start = (uintptr_t)_vr_TTVR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_TTVR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1545); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1546); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1547); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1547); break; case SKYBOX_HOUSE_MIDO: skyboxCtx->unk_140 = 2; @@ -858,14 +858,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1561); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1562); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1562); start = (uintptr_t)_vr_K4VR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_K4VR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1565); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1566); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1567); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1567); break; case SKYBOX_HOUSE_SARIA: skyboxCtx->unk_140 = 2; @@ -876,14 +876,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1575); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1576); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1576); start = (uintptr_t)_vr_K5VR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_K5VR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1579); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1580); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1581); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1581); break; case SKYBOX_HOUSE_ALLEY: skyboxCtx->unk_140 = 2; @@ -894,14 +894,14 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1589); - DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1590); + DmaMgr_RequestSyncDebug(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1590); start = (uintptr_t)_vr_KR3VR_pal_staticSegmentRomStart; size = (uintptr_t)_vr_KR3VR_pal_staticSegmentRomEnd - start; skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1593); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1594); - DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1595); + DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1595); break; case SKYBOX_UNSET_27: break; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index c3616c310a..a3f22be60f 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -5139,7 +5139,7 @@ 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, this->giObjectSegment, gObjectTable[objectId].vromStart, size, 0, + DmaMgr_RequestAsync(&this->giObjectDmaRequest, this->giObjectSegment, gObjectTable[objectId].vromStart, size, 0, &this->giObjectLoadQueue, NULL, "../z_player.c", 9099); } } diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 49514a17b8..fd638a0054 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -1879,13 +1879,14 @@ void FileSelect_Init(GameState* thisx) { this->staticSegment = GameState_Alloc(&this->state, size, "../z_file_choose.c", 3392); ASSERT(this->staticSegment != NULL, "this->staticSegment != NULL", "../z_file_choose.c", 3393); - DmaMgr_SendRequest1(this->staticSegment, (uintptr_t)_title_staticSegmentRomStart, size, "../z_file_choose.c", 3394); + DmaMgr_RequestSyncDebug(this->staticSegment, (uintptr_t)_title_staticSegmentRomStart, size, "../z_file_choose.c", + 3394); size = (uintptr_t)_parameter_staticSegmentRomEnd - (uintptr_t)_parameter_staticSegmentRomStart; this->parameterSegment = GameState_Alloc(&this->state, size, "../z_file_choose.c", 3398); ASSERT(this->parameterSegment != NULL, "this->parameterSegment != NULL", "../z_file_choose.c", 3399); - DmaMgr_SendRequest1(this->parameterSegment, (uintptr_t)_parameter_staticSegmentRomStart, size, "../z_file_choose.c", - 3400); + DmaMgr_RequestSyncDebug(this->parameterSegment, (uintptr_t)_parameter_staticSegmentRomStart, size, + "../z_file_choose.c", 3400); Matrix_Init(&this->state); View_Init(&this->view, this->state.gfxCtx); diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 50626b0299..48b712d5f8 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -761,7 +761,8 @@ void MapSelect_Init(GameState* thisx) { R_UPDATE_RATE = 1; this->staticSegment = GameState_Alloc(&this->state, size, "../z_select.c", 1114); - DmaMgr_SendRequest1(this->staticSegment, (uintptr_t)_z_select_staticSegmentRomStart, size, "../z_select.c", 1115); + DmaMgr_RequestSyncDebug(this->staticSegment, (uintptr_t)_z_select_staticSegmentRomStart, size, "../z_select.c", + 1115); gSaveContext.cutsceneIndex = 0x8000; gSaveContext.linkAge = LINK_AGE_CHILD; } diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 43ff1281d2..30bb737d66 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -160,8 +160,8 @@ void ConsoleLogo_Init(GameState* thisx) { this->staticSegment = GameState_Alloc(&this->state, size, "../z_title.c", 611); osSyncPrintf("z_title.c\n"); ASSERT(this->staticSegment != NULL, "this->staticSegment != NULL", "../z_title.c", 614); - DmaMgr_SendRequest1(this->staticSegment, (uintptr_t)_nintendo_rogo_staticSegmentRomStart, size, "../z_title.c", - 615); + DmaMgr_RequestSyncDebug(this->staticSegment, (uintptr_t)_nintendo_rogo_staticSegmentRomStart, size, "../z_title.c", + 615); R_UPDATE_RATE = 1; Matrix_Init(&this->state); View_Init(&this->view, this->state.gfxCtx); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c index 799b88bb34..2155493a70 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map_PAL.c @@ -710,7 +710,9 @@ void KaleidoScope_DrawWorldMap(PlayState* play, GraphicsContext* gfxCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 150, 255, 255, pauseCtx->alpha); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); - POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, pauseCtx->nameSegment + 0x400, 80, 32, 4); + POLY_OPA_DISP = KaleidoScope_QuadTextureIA8(POLY_OPA_DISP, + pauseCtx->nameSegment + MAX(MAP_NAME_TEX1_SIZE, ITEM_NAME_TEX_SIZE), + MAP_NAME_TEX2_WIDTH, MAP_NAME_TEX2_HEIGHT, 4); } gDPPipeSync(POLY_OPA_DISP++); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index e44767ed9b..8185fb2640 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -1140,7 +1140,10 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); } - POLY_OPA_DISP = KaleidoScope_QuadTextureIA4(POLY_OPA_DISP, pauseCtx->nameSegment, 128, 16, 0); + // Note that this is used to draw both item name and map name textures, it expects that the dimensions and + // format for both sets of textures are identical. + POLY_OPA_DISP = KaleidoScope_QuadTextureIA4(POLY_OPA_DISP, pauseCtx->nameSegment, ITEM_NAME_TEX_WIDTH, + ITEM_NAME_TEX_HEIGHT, 0); } if (pauseCtx->pageIndex == PAUSE_MAP) { @@ -1352,12 +1355,13 @@ void KaleidoScope_UpdateNamePanel(PlayState* play) { sp2A += 12; } - DmaMgr_SendRequest1(pauseCtx->nameSegment, (uintptr_t)_map_name_staticSegmentRomStart + (sp2A * 0x400), - 0x400, "../z_kaleido_scope_PAL.c", 2093); + DmaMgr_RequestSyncDebug(pauseCtx->nameSegment, + (uintptr_t)_map_name_staticSegmentRomStart + (sp2A * MAP_NAME_TEX1_SIZE), + MAP_NAME_TEX1_SIZE, "../z_kaleido_scope_PAL.c", 2093); } else { osSyncPrintf("zoom_name=%d\n", pauseCtx->namedItem); - if (gSaveContext.language) { + if (gSaveContext.language) { // != LANGUAGE_ENG sp2A += 123; } if (gSaveContext.language == LANGUAGE_FRA) { @@ -1366,8 +1370,9 @@ void KaleidoScope_UpdateNamePanel(PlayState* play) { osSyncPrintf("J_N=%d point=%d\n", gSaveContext.language, sp2A); - DmaMgr_SendRequest1(pauseCtx->nameSegment, (uintptr_t)_item_name_staticSegmentRomStart + (sp2A * 0x400), - 0x400, "../z_kaleido_scope_PAL.c", 2120); + DmaMgr_RequestSyncDebug(pauseCtx->nameSegment, + (uintptr_t)_item_name_staticSegmentRomStart + (sp2A * ITEM_NAME_TEX_SIZE), + ITEM_NAME_TEX_SIZE, "../z_kaleido_scope_PAL.c", 2120); } pauseCtx->nameDisplayTimer = 0; @@ -2441,13 +2446,13 @@ void KaleidoScope_LoadDungeonMap(PlayState* play) { InterfaceContext* interfaceCtx = &play->interfaceCtx; s32 pad; - DmaMgr_SendRequest1(interfaceCtx->mapSegment, - (uintptr_t)_map_48x85_staticSegmentRomStart + (R_MAP_TEX_INDEX * 2040), 2040, - "../z_kaleido_scope_PAL.c", 3467); + DmaMgr_RequestSyncDebug(interfaceCtx->mapSegment, + (uintptr_t)_map_48x85_staticSegmentRomStart + ((R_MAP_TEX_INDEX + 0) * MAP_48x85_TEX_SIZE), + MAP_48x85_TEX_SIZE, "../z_kaleido_scope_PAL.c", 3467); - DmaMgr_SendRequest1(interfaceCtx->mapSegment + 0x800, - (uintptr_t)_map_48x85_staticSegmentRomStart + ((R_MAP_TEX_INDEX + 1) * 2040), 2040, - "../z_kaleido_scope_PAL.c", 3471); + DmaMgr_RequestSyncDebug(interfaceCtx->mapSegment + ALIGN16(MAP_48x85_TEX_SIZE), + (uintptr_t)_map_48x85_staticSegmentRomStart + ((R_MAP_TEX_INDEX + 1) * MAP_48x85_TEX_SIZE), + MAP_48x85_TEX_SIZE, "../z_kaleido_scope_PAL.c", 3471); } void KaleidoScope_UpdateDungeonMap(PlayState* play) { @@ -2461,13 +2466,15 @@ void KaleidoScope_UpdateDungeonMap(PlayState* play) { if ((play->sceneId >= SCENE_YDAN) && (play->sceneId <= SCENE_TAKARAYA)) { if ((VREG(30) + 3) == pauseCtx->cursorPoint[PAUSE_MAP]) { - KaleidoScope_OverridePalIndexCI4(interfaceCtx->mapSegment, 2040, interfaceCtx->mapPaletteIndex, 14); + KaleidoScope_OverridePalIndexCI4(interfaceCtx->mapSegment, MAP_48x85_TEX_SIZE, + interfaceCtx->mapPaletteIndex, 14); } } if ((play->sceneId >= SCENE_YDAN) && (play->sceneId <= SCENE_TAKARAYA)) { if ((VREG(30) + 3) == pauseCtx->cursorPoint[PAUSE_MAP]) { - KaleidoScope_OverridePalIndexCI4(interfaceCtx->mapSegment + 0x800, 2040, interfaceCtx->mapPaletteIndex, 14); + KaleidoScope_OverridePalIndexCI4(interfaceCtx->mapSegment + ALIGN16(MAP_48x85_TEX_SIZE), MAP_48x85_TEX_SIZE, + interfaceCtx->mapPaletteIndex, 14); } } } @@ -2536,8 +2543,8 @@ void KaleidoScope_Update(PlayState* play) { size0 = (uintptr_t)_icon_item_staticSegmentRomEnd - (uintptr_t)_icon_item_staticSegmentRomStart; osSyncPrintf("icon_item size0=%x\n", size0); - DmaMgr_SendRequest1(pauseCtx->iconItemSegment, (uintptr_t)_icon_item_staticSegmentRomStart, size0, - "../z_kaleido_scope_PAL.c", 3662); + DmaMgr_RequestSyncDebug(pauseCtx->iconItemSegment, (uintptr_t)_icon_item_staticSegmentRomStart, size0, + "../z_kaleido_scope_PAL.c", 3662); gSegments[8] = VIRTUAL_TO_PHYSICAL(pauseCtx->iconItemSegment); @@ -2551,8 +2558,8 @@ void KaleidoScope_Update(PlayState* play) { size = (uintptr_t)_icon_item_24_staticSegmentRomEnd - (uintptr_t)_icon_item_24_staticSegmentRomStart; osSyncPrintf("icon_item24 size=%x\n", size); - DmaMgr_SendRequest1(pauseCtx->iconItem24Segment, (uintptr_t)_icon_item_24_staticSegmentRomStart, size, - "../z_kaleido_scope_PAL.c", 3675); + DmaMgr_RequestSyncDebug(pauseCtx->iconItem24Segment, (uintptr_t)_icon_item_24_staticSegmentRomStart, size, + "../z_kaleido_scope_PAL.c", 3675); pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItem24Segment + size); @@ -2579,9 +2586,9 @@ void KaleidoScope_Update(PlayState* play) { size2 = (uintptr_t)_icon_item_dungeon_staticSegmentRomEnd - (uintptr_t)_icon_item_dungeon_staticSegmentRomStart; osSyncPrintf("icon_item_dungeon dungeon-size2=%x\n", size2); - DmaMgr_SendRequest1(pauseCtx->iconItemAltSegment, - (uintptr_t)_icon_item_dungeon_staticSegmentRomStart, size2, - "../z_kaleido_scope_PAL.c", 3712); + DmaMgr_RequestSyncDebug(pauseCtx->iconItemAltSegment, + (uintptr_t)_icon_item_dungeon_staticSegmentRomStart, size2, + "../z_kaleido_scope_PAL.c", 3712); interfaceCtx->mapPalette[28] = 6; interfaceCtx->mapPalette[29] = 99; @@ -2593,8 +2600,9 @@ void KaleidoScope_Update(PlayState* play) { size2 = (uintptr_t)_icon_item_field_staticSegmentRomEnd - (uintptr_t)_icon_item_field_staticSegmentRomStart; osSyncPrintf("icon_item_field field-size2=%x\n", size2); - DmaMgr_SendRequest1(pauseCtx->iconItemAltSegment, (uintptr_t)_icon_item_field_staticSegmentRomStart, - size2, "../z_kaleido_scope_PAL.c", 3726); + DmaMgr_RequestSyncDebug(pauseCtx->iconItemAltSegment, + (uintptr_t)_icon_item_field_staticSegmentRomStart, size2, + "../z_kaleido_scope_PAL.c", 3726); break; } @@ -2603,18 +2611,18 @@ void KaleidoScope_Update(PlayState* play) { if (gSaveContext.language == LANGUAGE_ENG) { size = (uintptr_t)_icon_item_nes_staticSegmentRomEnd - (uintptr_t)_icon_item_nes_staticSegmentRomStart; osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); - DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_nes_staticSegmentRomStart, - size, "../z_kaleido_scope_PAL.c", 3739); + DmaMgr_RequestSyncDebug(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_nes_staticSegmentRomStart, + size, "../z_kaleido_scope_PAL.c", 3739); } else if (gSaveContext.language == LANGUAGE_GER) { size = (uintptr_t)_icon_item_ger_staticSegmentRomEnd - (uintptr_t)_icon_item_ger_staticSegmentRomStart; osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); - DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_ger_staticSegmentRomStart, - size, "../z_kaleido_scope_PAL.c", 3746); + DmaMgr_RequestSyncDebug(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_ger_staticSegmentRomStart, + size, "../z_kaleido_scope_PAL.c", 3746); } else { size = (uintptr_t)_icon_item_fra_staticSegmentRomEnd - (uintptr_t)_icon_item_fra_staticSegmentRomStart; osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); - DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_fra_staticSegmentRomStart, - size, "../z_kaleido_scope_PAL.c", 3753); + DmaMgr_RequestSyncDebug(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_fra_staticSegmentRomStart, + size, "../z_kaleido_scope_PAL.c", 3753); } pauseCtx->nameSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemLangSegment + size); @@ -2626,24 +2634,28 @@ void KaleidoScope_Update(PlayState* play) { if (((void)0, gSaveContext.worldMapArea) < 22) { if (gSaveContext.language == LANGUAGE_ENG) { - DmaMgr_SendRequest1(pauseCtx->nameSegment + 0x400, - (uintptr_t)_map_name_staticSegmentRomStart + - (((void)0, gSaveContext.worldMapArea) * 0xA00) + 0x9000, - 0xA00, "../z_kaleido_scope_PAL.c", 3776); + DmaMgr_RequestSyncDebug(pauseCtx->nameSegment + MAX(MAP_NAME_TEX1_SIZE, ITEM_NAME_TEX_SIZE), + (uintptr_t)_map_name_staticSegmentRomStart + + (((void)0, gSaveContext.worldMapArea) * MAP_NAME_TEX2_SIZE) + + 36 * MAP_NAME_TEX1_SIZE + 22 * LANGUAGE_ENG * MAP_NAME_TEX2_SIZE, + MAP_NAME_TEX2_SIZE, "../z_kaleido_scope_PAL.c", 3776); } else if (gSaveContext.language == LANGUAGE_GER) { - DmaMgr_SendRequest1(pauseCtx->nameSegment + 0x400, - (uintptr_t)_map_name_staticSegmentRomStart + - (((void)0, gSaveContext.worldMapArea) * 0xA00) + 0x16C00, - 0xA00, "../z_kaleido_scope_PAL.c", 3780); + DmaMgr_RequestSyncDebug(pauseCtx->nameSegment + MAX(MAP_NAME_TEX1_SIZE, ITEM_NAME_TEX_SIZE), + (uintptr_t)_map_name_staticSegmentRomStart + + (((void)0, gSaveContext.worldMapArea) * MAP_NAME_TEX2_SIZE) + + 36 * MAP_NAME_TEX1_SIZE + 22 * LANGUAGE_GER * MAP_NAME_TEX2_SIZE, + MAP_NAME_TEX2_SIZE, "../z_kaleido_scope_PAL.c", 3780); } else { - DmaMgr_SendRequest1(pauseCtx->nameSegment + 0x400, - (uintptr_t)_map_name_staticSegmentRomStart + - (((void)0, gSaveContext.worldMapArea) * 0xA00) + 0x24800, - 0xA00, "../z_kaleido_scope_PAL.c", 3784); + DmaMgr_RequestSyncDebug(pauseCtx->nameSegment + MAX(MAP_NAME_TEX1_SIZE, ITEM_NAME_TEX_SIZE), + (uintptr_t)_map_name_staticSegmentRomStart + + (((void)0, gSaveContext.worldMapArea) * MAP_NAME_TEX2_SIZE) + + 36 * MAP_NAME_TEX1_SIZE + 22 * LANGUAGE_FRA * MAP_NAME_TEX2_SIZE, + MAP_NAME_TEX2_SIZE, "../z_kaleido_scope_PAL.c", 3784); } } - sPreRenderCvg = (void*)ALIGN16((uintptr_t)pauseCtx->nameSegment + 0x400 + 0xA00); + sPreRenderCvg = (void*)ALIGN16((uintptr_t)pauseCtx->nameSegment + + MAX(MAP_NAME_TEX1_SIZE, ITEM_NAME_TEX_SIZE) + MAP_NAME_TEX2_SIZE); PreRender_Init(&sPlayerPreRender); PreRender_SetValuesSave(&sPlayerPreRender, PAUSE_EQUIP_PLAYER_WIDTH, PAUSE_EQUIP_PLAYER_HEIGHT, @@ -3150,39 +3162,39 @@ void KaleidoScope_Update(PlayState* play) { pauseCtx->iconItemSegment = (void*)(((uintptr_t)play->objectCtx.spaceStart + 0x30) & ~0x3F); size0 = (uintptr_t)_icon_item_staticSegmentRomEnd - (uintptr_t)_icon_item_staticSegmentRomStart; osSyncPrintf("icon_item size0=%x\n", size0); - DmaMgr_SendRequest1(pauseCtx->iconItemSegment, (uintptr_t)_icon_item_staticSegmentRomStart, size0, - "../z_kaleido_scope_PAL.c", 4356); + DmaMgr_RequestSyncDebug(pauseCtx->iconItemSegment, (uintptr_t)_icon_item_staticSegmentRomStart, size0, + "../z_kaleido_scope_PAL.c", 4356); pauseCtx->iconItem24Segment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); size = (uintptr_t)_icon_item_24_staticSegmentRomEnd - (uintptr_t)_icon_item_24_staticSegmentRomStart; osSyncPrintf("icon_item24 size=%x\n", size); - DmaMgr_SendRequest1(pauseCtx->iconItem24Segment, (uintptr_t)_icon_item_24_staticSegmentRomStart, size, - "../z_kaleido_scope_PAL.c", 4363); + DmaMgr_RequestSyncDebug(pauseCtx->iconItem24Segment, (uintptr_t)_icon_item_24_staticSegmentRomStart, size, + "../z_kaleido_scope_PAL.c", 4363); pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItem24Segment + size); size2 = (uintptr_t)_icon_item_gameover_staticSegmentRomEnd - (uintptr_t)_icon_item_gameover_staticSegmentRomStart; osSyncPrintf("icon_item_dungeon gameover-size2=%x\n", size2); - DmaMgr_SendRequest1(pauseCtx->iconItemAltSegment, (uintptr_t)_icon_item_gameover_staticSegmentRomStart, - size2, "../z_kaleido_scope_PAL.c", 4370); + DmaMgr_RequestSyncDebug(pauseCtx->iconItemAltSegment, (uintptr_t)_icon_item_gameover_staticSegmentRomStart, + size2, "../z_kaleido_scope_PAL.c", 4370); pauseCtx->iconItemLangSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemAltSegment + size2); if (gSaveContext.language == LANGUAGE_ENG) { size = (uintptr_t)_icon_item_nes_staticSegmentRomEnd - (uintptr_t)_icon_item_nes_staticSegmentRomStart; osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); - DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_nes_staticSegmentRomStart, - size, "../z_kaleido_scope_PAL.c", 4379); + DmaMgr_RequestSyncDebug(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_nes_staticSegmentRomStart, + size, "../z_kaleido_scope_PAL.c", 4379); } else if (gSaveContext.language == LANGUAGE_GER) { size = (uintptr_t)_icon_item_ger_staticSegmentRomEnd - (uintptr_t)_icon_item_ger_staticSegmentRomStart; osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); - DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_ger_staticSegmentRomStart, - size, "../z_kaleido_scope_PAL.c", 4386); + DmaMgr_RequestSyncDebug(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_ger_staticSegmentRomStart, + size, "../z_kaleido_scope_PAL.c", 4386); } else { size = (uintptr_t)_icon_item_fra_staticSegmentRomEnd - (uintptr_t)_icon_item_fra_staticSegmentRomStart; osSyncPrintf("icon_item_dungeon dungeon-size=%x\n", size); - DmaMgr_SendRequest1(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_fra_staticSegmentRomStart, - size, "../z_kaleido_scope_PAL.c", 4393); + DmaMgr_RequestSyncDebug(pauseCtx->iconItemLangSegment, (uintptr_t)_icon_item_fra_staticSegmentRomStart, + size, "../z_kaleido_scope_PAL.c", 4393); } D_8082AB8C = 255;