1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-29 03:34:07 +00:00

[ntsc-1.2] Match z_std_dma.c (#2082)

* Match ntsc-1.2 z_std_dma.c

* Add B_80121AE3
This commit is contained in:
cadmic 2024-08-24 22:04:53 -07:00 committed by GitHub
parent 271eff9234
commit b6d8aae2a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 62 additions and 13 deletions

View file

@ -1,6 +1,8 @@
#ifndef N64DD_H #ifndef N64DD_H
#define N64DD_H #define N64DD_H
#include "ultra64.h"
#include "z64dma.h"
#include "z64pause.h" #include "z64pause.h"
#include "z64scene.h" #include "z64scene.h"
@ -31,6 +33,7 @@ typedef struct n64ddStruct_80121AF0 {
s32 (*unk_44)(struct PlayState*); s32 (*unk_44)(struct PlayState*);
char unk_48[0x24]; char unk_48[0x24];
void (*unk_6C)(struct PlayState*, SceneDrawConfigFunc*); void (*unk_6C)(struct PlayState*, SceneDrawConfigFunc*);
s32 (*unk_70)(DmaRequest* req, void* ram, uintptr_t vrom, size_t size, u32 unk, OSMesgQueue* queue, OSMesg msg);
} n64ddStruct_80121AF0; // size = ? } n64ddStruct_80121AF0; // size = ?
void func_800ADA80(void); void func_800ADA80(void);
@ -47,6 +50,8 @@ extern n64ddStruct_80121AF0* B_80121AF0;
extern u8 B_80121AE0; extern u8 B_80121AE0;
extern s8 B_80121AE1; extern s8 B_80121AE1;
extern u8 B_80121AE2; extern u8 B_80121AE2;
extern vu8 B_80121AE3;
extern vu8 B_80121AE4;
extern char D_801DA410; // type ? extern char D_801DA410; // type ?
extern char D_801E8090; // type ? extern char D_801E8090; // type ?

View file

@ -20,6 +20,9 @@
*/ */
#include "global.h" #include "global.h"
#include "terminal.h" #include "terminal.h"
#if PLATFORM_N64
#include "n64dd.h"
#endif
StackEntry sDmaMgrStackInfo; StackEntry sDmaMgrStackInfo;
OSMesgQueue sDmaMgrMsgQueue; OSMesgQueue sDmaMgrMsgQueue;
@ -44,7 +47,7 @@ const char* sDmaMgrFileNames[] = {
#undef DEFINE_DMA_ENTRY #undef DEFINE_DMA_ENTRY
#if OOT_DEBUG #if PLATFORM_N64 || OOT_DEBUG
/** /**
* Compares `str1` and `str2`. * Compares `str1` and `str2`.
* *
@ -189,6 +192,14 @@ s32 DmaMgr_AudioDmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) {
ASSERT(direction == OS_READ, "direction == OS_READ", "../z_std_dma.c", 531); ASSERT(direction == OS_READ, "direction == OS_READ", "../z_std_dma.c", 531);
ASSERT(mb != NULL, "mb != NULL", "../z_std_dma.c", 532); ASSERT(mb != NULL, "mb != NULL", "../z_std_dma.c", 532);
#if PLATFORM_N64
if (B_80121AE2) {
while (B_80121AE4) {
Sleep_Msec(1000);
}
}
#endif
if (gDmaMgrVerbose == 10) { if (gDmaMgrVerbose == 10) {
PRINTF(T("%10lld サウンドDMA %08x %08x %08x (%d)\n", "%10lld Sound DMA %08x %08x %08x (%d)\n"), PRINTF(T("%10lld サウンドDMA %08x %08x %08x (%d)\n", "%10lld Sound DMA %08x %08x %08x (%d)\n"),
OS_CYCLES_TO_USEC(osGetTime()), mb->dramAddr, mb->devAddr, mb->size, MQ_GET_COUNT(&gPiMgrCmdQueue)); OS_CYCLES_TO_USEC(osGetTime()), mb->dramAddr, mb->devAddr, mb->size, MQ_GET_COUNT(&gPiMgrCmdQueue));
@ -209,6 +220,9 @@ s32 DmaMgr_AudioDmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) {
* @param size Size of transfer. * @param size Size of transfer.
*/ */
void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, size_t size) { void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, size_t size) {
#if PLATFORM_N64
s32 pad;
#endif
OSPiHandle* handle = osDriveRomInit(); OSPiHandle* handle = osDriveRomInit();
OSMesgQueue queue; OSMesgQueue queue;
OSMesg msg; OSMesg msg;
@ -273,11 +287,15 @@ NORETURN void DmaMgr_Error(DmaRequest* req, const char* filename, const char* er
Fault_AddHungupAndCrashImpl(buff1, buff2); Fault_AddHungupAndCrashImpl(buff1, buff2);
} }
#define DMA_ERROR(req, filename, errorName, errorDesc, file, line) DmaMgr_Error(req, filename, errorName, errorDesc) #define DMA_ERROR(req, filename, errorName, errorDesc, file, n64Line, gcLine) \
#else DmaMgr_Error(req, filename, errorName, errorDesc)
#define DMA_ERROR(req, filename, errorName, errorDesc, file, line) Fault_AddHungupAndCrash(file, line) #elif PLATFORM_N64
#define DMA_ERROR(req, filename, errorName, errorDesc, file, n64Line, gcLine) Fault_AddHungupAndCrash(file, n64Line)
#elif PLATFORM_GC
#define DMA_ERROR(req, filename, errorName, errorDesc, file, n64Line, gcLine) Fault_AddHungupAndCrash(file, gcLine)
#endif #endif
#if PLATFORM_GC
/** /**
* Searches the filesystem for the entry containing the address `vrom`. Retrieves the name of this entry from * Searches the filesystem for the entry containing the address `vrom`. Retrieves the name of this entry from
* the array of file names. * the array of file names.
@ -307,6 +325,7 @@ const char* DmaMgr_FindFileName(uintptr_t vrom) {
return NULL; return NULL;
#endif #endif
} }
#endif
const char* DmaMgr_GetFileName(uintptr_t vrom) { const char* DmaMgr_GetFileName(uintptr_t vrom) {
#if OOT_DEBUG #if OOT_DEBUG
@ -322,8 +341,17 @@ const char* DmaMgr_GetFileName(uintptr_t vrom) {
return NULL; return NULL;
} }
return ret; return ret;
#else #elif PLATFORM_N64
return "??";
// Unused strings
(void)"";
(void)"kanji";
(void)"";
(void)"link_animetion";
#elif PLATFORM_GC
return ""; return "";
// Unused strings
(void)"";
#endif #endif
} }
@ -336,13 +364,11 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
u8 found = false; u8 found = false;
DmaEntry* iter; DmaEntry* iter;
const char* filename; const char* filename;
s32 i = 0;
#if OOT_DEBUG #if OOT_DEBUG
// Get the filename (for debugging) // Get the filename (for debugging)
filename = DmaMgr_GetFileName(vrom); filename = DmaMgr_GetFileName(vrom);
#else
// An unused empty string is defined in .rodata of retail builds, suggesting it was used near here.
filename = "";
#endif #endif
// Iterate through the DMA data table until the region containing the vrom address for this request is found // Iterate through the DMA data table until the region containing the vrom address for this request is found
@ -367,7 +393,7 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
DMA_ERROR(req, filename, "Segment Alignment Error", DMA_ERROR(req, filename, "Segment Alignment Error",
T("セグメント境界をまたがってDMA転送することはできません", T("セグメント境界をまたがってDMA転送することはできません",
"DMA transfers cannot cross segment boundaries"), "DMA transfers cannot cross segment boundaries"),
"../z_std_dma.c", 726); "../z_std_dma.c", 578, 726);
} }
DmaMgr_DmaRomToRam(iter->romStart + (vrom - iter->file.vromStart), ram, size); DmaMgr_DmaRomToRam(iter->romStart + (vrom - iter->file.vromStart), ram, size);
@ -388,7 +414,7 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
DMA_ERROR(req, filename, "Can't Transfer Segment", DMA_ERROR(req, filename, "Can't Transfer Segment",
T("圧縮されたセグメントの途中からはDMA転送することはできません", T("圧縮されたセグメントの途中からはDMA転送することはできません",
"DMA transfer cannot be performed from the middle of a compressed segment"), "DMA transfer cannot be performed from the middle of a compressed segment"),
"../z_std_dma.c", 746); "../z_std_dma.c", 598, 746);
} }
if (size != iter->file.vromEnd - iter->file.vromStart) { if (size != iter->file.vromEnd - iter->file.vromStart) {
@ -397,7 +423,7 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
DMA_ERROR(req, filename, "Can't Transfer Segment", DMA_ERROR(req, filename, "Can't Transfer Segment",
T("圧縮されたセグメントの一部だけをDMA転送することはできません", T("圧縮されたセグメントの一部だけをDMA転送することはできません",
"It is not possible to DMA only part of a compressed segment"), "It is not possible to DMA only part of a compressed segment"),
"../z_std_dma.c", 752); "../z_std_dma.c", 604, 752);
} }
// Reduce the thread priority and decompress the file, the decompression routine handles the DMA // Reduce the thread priority and decompress the file, the decompression routine handles the DMA
@ -413,6 +439,13 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
} }
break; break;
} }
#if PLATFORM_N64
if (i != 0) {
i += 4;
}
#endif
iter++; iter++;
} }
@ -423,7 +456,8 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
// Error, rom is compressed so DMA may only be requested within the filesystem bounds // Error, rom is compressed so DMA may only be requested within the filesystem bounds
DMA_ERROR(req, NULL, "DATA DON'T EXIST", DMA_ERROR(req, NULL, "DATA DON'T EXIST",
T("該当するデータが存在しません", "Corresponding data does not exist"), "../z_std_dma.c", 771); T("該当するデータが存在しません", "Corresponding data does not exist"), "../z_std_dma.c", 624,
771);
return; return;
} else { } else {
// ROM is uncompressed, allow arbitrary DMA even if the region is not marked in the filesystem // ROM is uncompressed, allow arbitrary DMA even if the region is not marked in the filesystem
@ -495,7 +529,15 @@ s32 DmaMgr_RequestAsync(DmaRequest* req, void* ram, uintptr_t vrom, size_t size,
// its line number is unknown. // its line number is unknown.
//! @bug `req` is passed to `DMA_ERROR` without rom, ram and size being set //! @bug `req` is passed to `DMA_ERROR` without rom, ram and size being set
DMA_ERROR(req, NULL, "ILLIGAL DMA-FUNCTION CALL", T("パラメータ異常です", "Parameter error"), "../z_std_dma.c", DMA_ERROR(req, NULL, "ILLIGAL DMA-FUNCTION CALL", T("パラメータ異常です", "Parameter error"), "../z_std_dma.c",
0); 0, 0);
}
#endif
#if PLATFORM_N64
if ((B_80121AF0 != NULL) && (B_80121AF0->unk_70 != NULL)) {
if (B_80121AF0->unk_70(req, ram, vrom, size, unk, queue, msg) != 0) {
return 0;
}
} }
#endif #endif

View file

@ -12,6 +12,8 @@ s8 func_801C7740_unknown(void);
u8 B_80121AE0; u8 B_80121AE0;
s8 B_80121AE1; s8 B_80121AE1;
u8 B_80121AE2; u8 B_80121AE2;
vu8 B_80121AE3;
vu8 B_80121AE4;
void func_800ADA80(void) { void func_800ADA80(void) {
if (!B_80121AE0) { if (!B_80121AE0) {