mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-28 19:25:27 +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:
parent
271eff9234
commit
b6d8aae2a5
3 changed files with 62 additions and 13 deletions
|
@ -1,6 +1,8 @@
|
|||
#ifndef N64DD_H
|
||||
#define N64DD_H
|
||||
|
||||
#include "ultra64.h"
|
||||
#include "z64dma.h"
|
||||
#include "z64pause.h"
|
||||
#include "z64scene.h"
|
||||
|
||||
|
@ -31,6 +33,7 @@ typedef struct n64ddStruct_80121AF0 {
|
|||
s32 (*unk_44)(struct PlayState*);
|
||||
char unk_48[0x24];
|
||||
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 = ?
|
||||
|
||||
void func_800ADA80(void);
|
||||
|
@ -47,6 +50,8 @@ extern n64ddStruct_80121AF0* B_80121AF0;
|
|||
extern u8 B_80121AE0;
|
||||
extern s8 B_80121AE1;
|
||||
extern u8 B_80121AE2;
|
||||
extern vu8 B_80121AE3;
|
||||
extern vu8 B_80121AE4;
|
||||
|
||||
extern char D_801DA410; // type ?
|
||||
extern char D_801E8090; // type ?
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
*/
|
||||
#include "global.h"
|
||||
#include "terminal.h"
|
||||
#if PLATFORM_N64
|
||||
#include "n64dd.h"
|
||||
#endif
|
||||
|
||||
StackEntry sDmaMgrStackInfo;
|
||||
OSMesgQueue sDmaMgrMsgQueue;
|
||||
|
@ -44,7 +47,7 @@ const char* sDmaMgrFileNames[] = {
|
|||
|
||||
#undef DEFINE_DMA_ENTRY
|
||||
|
||||
#if OOT_DEBUG
|
||||
#if PLATFORM_N64 || OOT_DEBUG
|
||||
/**
|
||||
* 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(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) {
|
||||
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));
|
||||
|
@ -209,6 +220,9 @@ s32 DmaMgr_AudioDmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) {
|
|||
* @param size Size of transfer.
|
||||
*/
|
||||
void DmaMgr_DmaFromDriveRom(void* ram, uintptr_t rom, size_t size) {
|
||||
#if PLATFORM_N64
|
||||
s32 pad;
|
||||
#endif
|
||||
OSPiHandle* handle = osDriveRomInit();
|
||||
OSMesgQueue queue;
|
||||
OSMesg msg;
|
||||
|
@ -273,11 +287,15 @@ NORETURN void DmaMgr_Error(DmaRequest* req, const char* filename, const char* er
|
|||
Fault_AddHungupAndCrashImpl(buff1, buff2);
|
||||
}
|
||||
|
||||
#define DMA_ERROR(req, filename, errorName, errorDesc, file, line) DmaMgr_Error(req, filename, errorName, errorDesc)
|
||||
#else
|
||||
#define DMA_ERROR(req, filename, errorName, errorDesc, file, line) Fault_AddHungupAndCrash(file, line)
|
||||
#define DMA_ERROR(req, filename, errorName, errorDesc, file, n64Line, gcLine) \
|
||||
DmaMgr_Error(req, filename, errorName, errorDesc)
|
||||
#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
|
||||
|
||||
#if PLATFORM_GC
|
||||
/**
|
||||
* Searches the filesystem for the entry containing the address `vrom`. Retrieves the name of this entry from
|
||||
* the array of file names.
|
||||
|
@ -307,6 +325,7 @@ const char* DmaMgr_FindFileName(uintptr_t vrom) {
|
|||
return NULL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
const char* DmaMgr_GetFileName(uintptr_t vrom) {
|
||||
#if OOT_DEBUG
|
||||
|
@ -322,8 +341,17 @@ const char* DmaMgr_GetFileName(uintptr_t vrom) {
|
|||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
#else
|
||||
#elif PLATFORM_N64
|
||||
return "??";
|
||||
// Unused strings
|
||||
(void)"";
|
||||
(void)"kanji";
|
||||
(void)"";
|
||||
(void)"link_animetion";
|
||||
#elif PLATFORM_GC
|
||||
return "";
|
||||
// Unused strings
|
||||
(void)"";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -336,13 +364,11 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
|
|||
u8 found = false;
|
||||
DmaEntry* iter;
|
||||
const char* filename;
|
||||
s32 i = 0;
|
||||
|
||||
#if OOT_DEBUG
|
||||
// Get the filename (for debugging)
|
||||
filename = DmaMgr_GetFileName(vrom);
|
||||
#else
|
||||
// An unused empty string is defined in .rodata of retail builds, suggesting it was used near here.
|
||||
filename = "";
|
||||
#endif
|
||||
|
||||
// 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",
|
||||
T("セグメント境界をまたがってDMA転送することはできません",
|
||||
"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);
|
||||
|
@ -388,7 +414,7 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
|
|||
DMA_ERROR(req, filename, "Can't Transfer Segment",
|
||||
T("圧縮されたセグメントの途中からはDMA転送することはできません",
|
||||
"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) {
|
||||
|
@ -397,7 +423,7 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
|
|||
DMA_ERROR(req, filename, "Can't Transfer Segment",
|
||||
T("圧縮されたセグメントの一部だけをDMA転送することはできません",
|
||||
"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
|
||||
|
@ -413,6 +439,13 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#if PLATFORM_N64
|
||||
if (i != 0) {
|
||||
i += 4;
|
||||
}
|
||||
#endif
|
||||
|
||||
iter++;
|
||||
}
|
||||
|
||||
|
@ -423,7 +456,8 @@ void DmaMgr_ProcessRequest(DmaRequest* req) {
|
|||
// Error, rom is compressed so DMA may only be requested within the filesystem bounds
|
||||
|
||||
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;
|
||||
} else {
|
||||
// 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.
|
||||
//! @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",
|
||||
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
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ s8 func_801C7740_unknown(void);
|
|||
u8 B_80121AE0;
|
||||
s8 B_80121AE1;
|
||||
u8 B_80121AE2;
|
||||
vu8 B_80121AE3;
|
||||
vu8 B_80121AE4;
|
||||
|
||||
void func_800ADA80(void) {
|
||||
if (!B_80121AE0) {
|
||||
|
|
Loading…
Reference in a new issue