Match and link CDvdRequest, Split and match CDvdRequestManager

Former-commit-id: b24751b60c
This commit is contained in:
Phillip Stephens 2023-01-29 14:58:21 -08:00
parent f33395b657
commit 4797ccc332
13 changed files with 142 additions and 48 deletions

View File

@ -3,8 +3,8 @@
.section .data
.balign 8
.global lbl_803ED578
lbl_803ED578:
.global __vt__15CARAMDvdRequest
__vt__15CARAMDvdRequest:
# ROM: 0x3EA578
.4byte 0
.4byte 0
@ -14,8 +14,8 @@ lbl_803ED578:
.4byte PostCancelRequest__15CARAMDvdRequestFv
.4byte GetMediaType__15CARAMDvdRequestCFv
.global lbl_803ED594
lbl_803ED594:
.global __vt__15CRealDvdRequest
__vt__15CRealDvdRequest:
# ROM: 0x3EA594
.4byte 0
.4byte 0
@ -25,14 +25,6 @@ lbl_803ED594:
.4byte PostCancelRequest__15CRealDvdRequestFv
.4byte GetMediaType__15CRealDvdRequestCFv
.section .sbss, "wa"
.balign 8
# TODO CDvdRequestManager
.global mManagerInstalled__14CDvdRequestSys
mManagerInstalled__14CDvdRequestSys:
.skip 0x8
.section .text, "ax"
.global __dt__15CARAMDvdRequestFv
@ -43,12 +35,12 @@ __dt__15CARAMDvdRequestFv:
/* 802FE5E0 002FB540 93 E1 00 0C */ stw r31, 0xc(r1)
/* 802FE5E4 002FB544 7C 7F 1B 79 */ or. r31, r3, r3
/* 802FE5E8 002FB548 41 82 00 30 */ beq lbl_802FE618
/* 802FE5EC 002FB54C 3C 60 80 3F */ lis r3, lbl_803ED578@ha
/* 802FE5F0 002FB550 38 03 D5 78 */ addi r0, r3, lbl_803ED578@l
/* 802FE5EC 002FB54C 3C 60 80 3F */ lis r3, __vt__15CARAMDvdRequest@ha
/* 802FE5F0 002FB550 38 03 D5 78 */ addi r0, r3, __vt__15CARAMDvdRequest@l
/* 802FE5F4 002FB554 90 1F 00 00 */ stw r0, 0(r31)
/* 802FE5F8 002FB558 41 82 00 10 */ beq lbl_802FE608
/* 802FE5FC 002FB55C 3C 60 80 3E */ lis r3, lbl_803D9FF8@ha
/* 802FE600 002FB560 38 03 9F F8 */ addi r0, r3, lbl_803D9FF8@l
/* 802FE5FC 002FB55C 3C 60 80 3E */ lis r3, __vt__11CDvdRequest@ha
/* 802FE600 002FB560 38 03 9F F8 */ addi r0, r3, __vt__11CDvdRequest@l
/* 802FE604 002FB564 90 1F 00 00 */ stw r0, 0(r31)
lbl_802FE608:
/* 802FE608 002FB568 7C 80 07 35 */ extsh. r0, r4
@ -188,8 +180,8 @@ __dt__15CRealDvdRequestFv:
/* 802FE794 002FB6F4 93 C1 00 08 */ stw r30, 8(r1)
/* 802FE798 002FB6F8 7C 7E 1B 79 */ or. r30, r3, r3
/* 802FE79C 002FB6FC 41 82 00 7C */ beq lbl_802FE818
/* 802FE7A0 002FB700 3C 80 80 3F */ lis r4, lbl_803ED594@ha
/* 802FE7A4 002FB704 38 04 D5 94 */ addi r0, r4, lbl_803ED594@l
/* 802FE7A0 002FB700 3C 80 80 3F */ lis r4, __vt__15CRealDvdRequest@ha
/* 802FE7A4 002FB704 38 04 D5 94 */ addi r0, r4, __vt__15CRealDvdRequest@l
/* 802FE7A8 002FB708 90 1E 00 00 */ stw r0, 0(r30)
/* 802FE7AC 002FB70C 81 83 00 00 */ lwz r12, 0(r3)
/* 802FE7B0 002FB710 81 8C 00 10 */ lwz r12, 0x10(r12)
@ -212,8 +204,8 @@ lbl_802FE7EC:
/* 802FE7F0 002FB750 48 07 2F 5D */ bl DVDClose
/* 802FE7F4 002FB754 28 1E 00 00 */ cmplwi r30, 0
/* 802FE7F8 002FB758 41 82 00 10 */ beq lbl_802FE808
/* 802FE7FC 002FB75C 3C 60 80 3E */ lis r3, lbl_803D9FF8@ha
/* 802FE800 002FB760 38 03 9F F8 */ addi r0, r3, lbl_803D9FF8@l
/* 802FE7FC 002FB75C 3C 60 80 3E */ lis r3, __vt__11CDvdRequest@ha
/* 802FE800 002FB760 38 03 9F F8 */ addi r0, r3, __vt__11CDvdRequest@l
/* 802FE804 002FB764 90 1E 00 00 */ stw r0, 0(r30)
lbl_802FE808:
/* 802FE808 002FB768 7F E0 07 35 */ extsh. r0, r31

View File

@ -0,0 +1,8 @@
.include "macros.inc"
.section .sbss, "wa"
.balign 8
.global mManagerInstalled__14CDvdRequestSys
mManagerInstalled__14CDvdRequestSys:
.skip 0x1

View File

@ -165,11 +165,11 @@ AsyncSeekRead__8CDvdFileFPvUi11ESeekOrigini:
/* 8034FA44 0034C9A4 38 C0 00 01 */ li r6, 1
/* 8034FA48 0034C9A8 7C 63 02 14 */ add r3, r3, r0
/* 8034FA4C 0034C9AC 4B FF 4E 05 */ bl DMAToMRAM__12CARAMManagerFPvPvUiQ212CARAMManager12EDMAPriority
/* 8034FA50 0034C9B0 3C A0 80 3E */ lis r5, lbl_803D9FF8@ha
/* 8034FA54 0034C9B4 3C 80 80 3F */ lis r4, lbl_803ED578@ha
/* 8034FA58 0034C9B8 38 05 9F F8 */ addi r0, r5, lbl_803D9FF8@l
/* 8034FA50 0034C9B0 3C A0 80 3E */ lis r5, __vt__11CDvdRequest@ha
/* 8034FA54 0034C9B4 3C 80 80 3F */ lis r4, __vt__15CARAMDvdRequest@ha
/* 8034FA58 0034C9B8 38 05 9F F8 */ addi r0, r5, __vt__11CDvdRequest@l
/* 8034FA5C 0034C9BC 90 1C 00 00 */ stw r0, 0(r28)
/* 8034FA60 0034C9C0 38 04 D5 78 */ addi r0, r4, lbl_803ED578@l
/* 8034FA60 0034C9C0 38 04 D5 78 */ addi r0, r4, __vt__15CARAMDvdRequest@l
/* 8034FA64 0034C9C4 90 1C 00 00 */ stw r0, 0(r28)
/* 8034FA68 0034C9C8 90 7C 00 04 */ stw r3, 4(r28)
lbl_8034FA6C:
@ -183,11 +183,11 @@ lbl_8034FA74:
/* 8034FA84 0034C9E4 4B FC 5D E9 */ bl __nw__FUlPCcPCc
/* 8034FA88 0034C9E8 7C 7C 1B 79 */ or. r28, r3, r3
/* 8034FA8C 0034C9EC 41 82 00 1C */ beq lbl_8034FAA8
/* 8034FA90 0034C9F0 3C 80 80 3E */ lis r4, lbl_803D9FF8@ha
/* 8034FA94 0034C9F4 3C 60 80 3F */ lis r3, lbl_803ED594@ha
/* 8034FA98 0034C9F8 38 04 9F F8 */ addi r0, r4, lbl_803D9FF8@l
/* 8034FA90 0034C9F0 3C 80 80 3E */ lis r4, __vt__11CDvdRequest@ha
/* 8034FA94 0034C9F4 3C 60 80 3F */ lis r3, __vt__15CRealDvdRequest@ha
/* 8034FA98 0034C9F8 38 04 9F F8 */ addi r0, r4, __vt__11CDvdRequest@l
/* 8034FA9C 0034C9FC 90 1C 00 00 */ stw r0, 0(r28)
/* 8034FAA0 0034CA00 38 03 D5 94 */ addi r0, r3, lbl_803ED594@l
/* 8034FAA0 0034CA00 38 03 D5 94 */ addi r0, r3, __vt__15CRealDvdRequest@l
/* 8034FAA4 0034CA04 90 1C 00 00 */ stw r0, 0(r28)
lbl_8034FAA8:
/* 8034FAA8 0034CA08 3B 7C 00 04 */ addi r27, r28, 4

View File

@ -25,8 +25,8 @@ lbl_803D9FC0:
.4byte IGetDefaultAudioTrack__11CDummyWorldCFv
.4byte IGetAreaCount__11CDummyWorldFv
.global lbl_803D9FF8
lbl_803D9FF8:
.global __vt__11CDvdRequest
__vt__11CDvdRequest:
# ROM: 0x3D6FF8
.4byte 0
.4byte 0

View File

@ -532,7 +532,8 @@ LIBS = [
"Kyoto/Animation/CTimeScaleFunctions",
"Kyoto/Animation/IAnimReader",
"Kyoto/Animation/CAllFormatsAnimSource",
"Kyoto/CDvdRequest",
["Kyoto/CDvdRequestManager", True],
["Kyoto/CDvdRequest", True],
["Kyoto/Text/CColorInstruction", True],
["Kyoto/Text/CColorOverrideInstruction", True],
["Kyoto/Text/CDrawStringOptions", True],

View File

@ -29,8 +29,6 @@ public:
static void Free(const void* ptr);
static int DMAToARAM(void*, void*, uint, EDMAPriority);
static int DMAToMRAM(void*, void*, uint, EDMAPriority);
private:
static uint mPreInitializeAlloc;
static const int kInvalidAlloc;

View File

@ -1,24 +1,38 @@
#ifndef _CDVDREQUEST
#define _CDVDREQUEST
#include "dolphin/dvd.h"
#include "types.h"
class CDvdRequest {
public:
virtual ~CDvdRequest() = 0; // 8
virtual ~CDvdRequest(){}; // 8
virtual void WaitUntilComplete() = 0; // c
virtual bool IsComplete() = 0; // 10
virtual bool IsComplete() = 0; // 10
virtual void PostCancelRequest() = 0; // 14
virtual int GetMediaType() const = 0; // 18
};
class CRealDvdRequest : public CDvdRequest {
public:
~CRealDvdRequest();
void WaitUntilComplete();
bool IsComplete();
void PostCancelRequest();
int GetMediaType() const;
private:
DVDFileInfo mFileInfo;
};
class CARAMDvdRequest : public CDvdRequest {
public:
CARAMDvdRequest(uint i) : x4_dmaReq(i) {}
void WaitUntilComplete() {};
bool IsComplete() {};
void PostCancelRequest() {};
int GetMediaType() const { return 1; }
void WaitUntilComplete();
bool IsComplete();
void PostCancelRequest();
int GetMediaType() const;
private:
uint x4_dmaReq;
};

View File

@ -0,0 +1,10 @@
#ifndef _CDVDREQUESTMANAGER
#define _CDVDREQUESTMANAGER
class CDvdRequestSys {
public:
static bool mManagerInstalled;
};
#endif // _CDVDREQUESTMANAGER

View File

@ -92,7 +92,11 @@ void DVDReset();
s32 DVDCancel(DVDCommandBlock* block);
BOOL DVDOpen(char* fileName, DVDFileInfo* fileInfo);
BOOL DVDFastOpen(s32 entrynum, DVDFileInfo* fileInfo);
s32 DVDGetCommandBlockStatus(DVDCommandBlock* block);
BOOL DVDCancelAsync(DVDCommandBlock* block, DVDCBCallback callback);
s32 DVDCancel(DVDCommandBlock* block);
BOOL DVDCancelAllAsync(DVDCBCallback callback);
s32 DVDCancelAll(void);
BOOL DVDPrepareStreamAsync(DVDFileInfo* fInfo, u32 length, u32 offset, DVDCallback callback);
s32 DVDPrepareStream(DVDFileInfo* fInfo, u32 length, u32 offset);

View File

@ -279,7 +279,7 @@ BOOL DVDGetCurrentDir(char* path, u32 maxlen) {
return DVDConvertEntrynumToPath((s32)currentDirectory, path, maxlen);
}
BOOL DVDChangeDir(const char* dirName) {
BOOL DVDChangeDir(char* dirName) {
s32 entry;
entry = DVDConvertPathToEntrynum(dirName);
if ((entry < 0) || (entryIsDir(entry) == FALSE)) {
@ -440,7 +440,7 @@ s32 DVDSeekPrio(DVDFileInfo* fileInfo, s32 offset, s32 prio) {
static void cbForSeekSync(s32 result, DVDCommandBlock* block) { OSWakeupThread(&__DVDThreadQueue); }
/* This is based on the revolution SDK, these may not match in all cases */
s32 DVDGetFileInfoStatus(const DVDFileInfo* fileInfo) {
s32 DVDGetFileInfoStatus(DVDFileInfo* fileInfo) {
return DVDGetCommandBlockStatus(&fileInfo->cb);
}
@ -459,7 +459,7 @@ BOOL DVDFastOpenDir(s32 entrynum, DVDDir* dir) {
}
/* This is based on the revolution SDK, these may not match in all cases */
BOOL DVDOpenDir(const char* dirName, DVDDir* dir) {
BOOL DVDOpenDir(char* dirName, DVDDir* dir) {
s32 entry;
char currentDir[128];
entry = DVDConvertPathToEntrynum(dirName);

64
src/Kyoto/CDvdRequest.cpp Normal file
View File

@ -0,0 +1,64 @@
#include "Kyoto/CDvdRequest.hpp"
#include "Kyoto/CARAMManager.hpp"
#include "Kyoto/Alloc/CMemory.hpp"
CRealDvdRequest::~CRealDvdRequest() {
if (!IsComplete()) {
PostCancelRequest();
WaitUntilComplete();
}
DVDClose(&mFileInfo);
}
void CRealDvdRequest::WaitUntilComplete() {
while (!CRealDvdRequest::IsComplete()) {}
}
bool CRealDvdRequest::IsComplete() {
s32 status = DVDGetCommandBlockStatus(&mFileInfo.cb);
bool ret = false;
if (status == DVD_STATE_END || status == DVD_STATE_CANCELED) {
ret = true;
}
return ret;
}
void CRealDvdRequest::PostCancelRequest() {
DVDCancelAsync(&mFileInfo.cb, nullptr);
}
int CRealDvdRequest::GetMediaType() const {
return 1;
}
void CARAMDvdRequest::WaitUntilComplete() {
if (CARAMManager::GetInvalidDMAHandle() == x4_dmaReq) {
return;
}
CARAMManager::WaitForDMACompletion(x4_dmaReq);
x4_dmaReq = CARAMManager::GetInvalidDMAHandle();
}
bool CARAMDvdRequest::IsComplete() {
if (x4_dmaReq != CARAMManager::GetInvalidDMAHandle()) {
if (!CARAMManager::IsDMACompleted(x4_dmaReq)) {
return false;
}
x4_dmaReq = CARAMManager::GetInvalidDMAHandle();
}
return true;
}
void CARAMDvdRequest::PostCancelRequest() {
}
int CARAMDvdRequest::GetMediaType() const {
return 0;
}

View File

@ -0,0 +1,3 @@
#include "Kyoto/CDvdRequestManager.hpp"
bool CDvdRequestSys::mManagerInstalled = false;

View File

@ -89,17 +89,17 @@ CDvdFile::CDvdFile(const char* filename)
CDvdFile::~CDvdFile() { CloseFile(); }
IDvdRequest* CDvdFile::SyncRead(void* dest, uint len) { AsyncSeekRead(dest, len, kSO_Cur, 0); }
CDvdRequest* CDvdFile::SyncRead(void* dest, uint len) { AsyncSeekRead(dest, len, kSO_Cur, 0); }
IDvdRequest* CDvdFile::SyncSeekRead(void* buf, uint len, ESeekOrigin origin, int offset) {}
CDvdRequest* CDvdFile::SyncSeekRead(void* buf, uint len, ESeekOrigin origin, int offset) {}
IDvdRequest* CDvdFile::AsyncSeekRead(void* dest, uint len, ESeekOrigin origin, int offset) {
IDvdRequest* request;
CDvdRequest* CDvdFile::AsyncSeekRead(void* dest, uint len, ESeekOrigin origin, int offset) {
CDvdRequest* request;
StallForARAMFile();
CalcFileOffset(offset, origin);
if (x8_) {
} else {
int roundedLen = (len + 31) & ~31;
DCFlushRange(dest, roundedLen);