IDvdRequest is fake, remove it

Former-commit-id: 7c47499116
This commit is contained in:
Phillip Stephens 2023-01-29 14:16:26 -08:00
parent fb4b103879
commit f33395b657
8 changed files with 172 additions and 32 deletions

View File

@ -10,7 +10,14 @@
"cppStandard": "c++98", "cppStandard": "c++98",
"intelliSenseMode": "linux-clang-x86", "intelliSenseMode": "linux-clang-x86",
"compilerPath": "", "compilerPath": "",
"configurationProvider": "ms-vscode.makefile-tools" "configurationProvider": "ms-vscode.makefile-tools",
"browse": {
"path": [
"${workspaceFolder}/include",
"${workspaceFolder}/libc"
],
"limitSymbolsToIncludedHeaders": true
}
} }
], ],
"version": 4 "version": 4

View File

@ -2,8 +2,15 @@
#define _CDVDFILE #define _CDVDFILE
#include "types.h" #include "types.h"
#include "Kyoto/CDvdRequest.hpp"
#include "Kyoto/IDvdRequest.hpp" #include "rstl/string.hpp"
enum ESeekOrigin {
kSO_Set,
kSO_Cur,
kSO_End
};
struct DVDFileInfo; struct DVDFileInfo;
class CDvdFile { class CDvdFile {
@ -11,20 +18,35 @@ public:
CDvdFile(const char* name); CDvdFile(const char* name);
~CDvdFile(); ~CDvdFile();
uint Length() { return x14_size; } uint Length() { return x14_size; }
IDvdRequest* SyncRead(void* buf, uint len);
static bool FileExists(const char*);
static void DVDARAMXferCallback(long, DVDFileInfo*);
static void ARAMARAMXferCallback(u32 addr);
void HandleDVDInterrupt(); void HandleDVDInterrupt();
void HandleARAMInterrupt(); void HandleARAMInterrupt();
void PingARAMTransfer();
void TryARAMFile();
void PushARAMFileLoad();
void PopARAMFileLoad();
void StartARAMFileLoad();
void StallForARAMFile();
CDvdRequest* SyncRead(void* buf, uint len);
CDvdRequest* SyncSeekRead(void* buf, uint len, ESeekOrigin, int offset);
CDvdRequest* AsyncSeekRead(void* buf, uint len, ESeekOrigin, int offset);
void CloseFile();
void CalcFileOffset(int offset, ESeekOrigin origin);
void UpdateFilePos(int pos);
const int GetFileSize() const { return x14_size; }
static bool FileExists(const char*);
static void DVDARAMXferCallback(long, DVDFileInfo*);
static void ARAMARAMXferCallback(u32 addr);
static void internalCallback(s32, DVDFileInfo*);
private: private:
uchar pad[0x14]; int x0_fileEntry;
uint x14_size; void* x4_;
uchar pad2[0x10]; uchar x8_;
uchar x9_;
int xc_;
int x10_offset;
int x14_size;
rstl::string x18_filename;
}; };
CHECK_SIZEOF(CDvdFile, 0x28) CHECK_SIZEOF(CDvdFile, 0x28)

View File

@ -1,10 +1,26 @@
#ifndef _CDVDREQUEST #ifndef _CDVDREQUEST
#define _CDVDREQUEST #define _CDVDREQUEST
#include "Kyoto/IDvdRequest.hpp" #include "types.h"
class CDvdRequest : public IDvdRequest { class CDvdRequest {
public:
virtual ~CDvdRequest() = 0; // 8
virtual void WaitUntilComplete() = 0; // c
virtual bool IsComplete() = 0; // 10
virtual void PostCancelRequest() = 0; // 14
virtual int GetMediaType() const = 0; // 18
};
class CARAMDvdRequest : public CDvdRequest {
public:
CARAMDvdRequest(uint i) : x4_dmaReq(i) {}
void WaitUntilComplete() {};
bool IsComplete() {};
void PostCancelRequest() {};
int GetMediaType() const { return 1; }
private:
uint x4_dmaReq;
}; };
#endif // _CDVDREQUEST #endif // _CDVDREQUEST

View File

@ -1,12 +0,0 @@
#ifndef _IDVDREQUEST
#define _IDVDREQUEST
class IDvdRequest {
public:
virtual ~IDvdRequest() = 0; // 8
virtual void Unknown1(bool) = 0; // c
virtual bool IsComplete() = 0; // 10
};
#endif // _IDVDREQUEST

View File

@ -24,7 +24,7 @@ private:
CDvdFile x0_file; CDvdFile x0_file;
uint x28_fileSize; uint x28_fileSize;
rstl::single_ptr<uchar> x2c_buffer; rstl::single_ptr<uchar> x2c_buffer;
rstl::single_ptr<IDvdRequest> x30_dvdReq; rstl::single_ptr<CDvdRequest> x30_dvdReq;
EPhase x34_phase; EPhase x34_phase;
float x38_timeout; float x38_timeout;
uchar x3c_status; uchar x3c_status;

View File

@ -90,6 +90,8 @@ BOOL DVDClose(DVDFileInfo* f);
BOOL DVDSetAutoFatalMessaging(BOOL); BOOL DVDSetAutoFatalMessaging(BOOL);
void DVDReset(); void DVDReset();
s32 DVDCancel(DVDCommandBlock* block); s32 DVDCancel(DVDCommandBlock* block);
BOOL DVDOpen(char* fileName, DVDFileInfo* fileInfo);
BOOL DVDFastOpen(s32 entrynum, DVDFileInfo* fileInfo);
BOOL DVDPrepareStreamAsync(DVDFileInfo* fInfo, u32 length, u32 offset, DVDCallback callback); BOOL DVDPrepareStreamAsync(DVDFileInfo* fInfo, u32 length, u32 offset, DVDCallback callback);
s32 DVDPrepareStream(DVDFileInfo* fInfo, u32 length, u32 offset); s32 DVDPrepareStream(DVDFileInfo* fInfo, u32 length, u32 offset);
@ -108,6 +110,8 @@ s32 DVDGetStreamPlayAddr(DVDCommandBlock* block);
s32 DVDGetDriveStatus(); s32 DVDGetDriveStatus();
s32 DVDConvertPathToEntrynum(char* pathPtr);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -57,7 +57,7 @@ static BOOL isSame(const char* path, const char* string) {
return FALSE; return FALSE;
} }
s32 DVDConvertPathToEntrynum(const char* pathPtr) { s32 DVDConvertPathToEntrynum(char* pathPtr) {
const char* ptr; const char* ptr;
char* stringPtr; char* stringPtr;
BOOL isDir; BOOL isDir;
@ -169,7 +169,7 @@ BOOL DVDFastOpen(s32 entrynum, DVDFileInfo* fileInfo) {
return TRUE; return TRUE;
} }
BOOL DVDOpen(const char* fileName, DVDFileInfo* fileInfo) { BOOL DVDOpen(char* fileName, DVDFileInfo* fileInfo) {
s32 entry; s32 entry;
char currentDir[128]; char currentDir[128];

View File

@ -1,6 +1,11 @@
#include "Kyoto/CDvdFile.hpp" #include "Kyoto/CDvdFile.hpp"
#include "dolphin/dvd.h"
#include "Kyoto/CDvdRequest.hpp"
#include "Kyoto/CARAMManager.hpp"
#include "dolphin/arq.h" #include "dolphin/arq.h"
#include "dolphin/dvd.h"
#include "dolphin/os.h" #include "dolphin/os.h"
#include "string.h" #include "string.h"
@ -41,6 +46,104 @@ void CDvdFile::HandleARAMInterrupt() {
void CDvdFile::HandleDVDInterrupt() { void CDvdFile::HandleDVDInterrupt() {
BOOL enabled = OSDisableInterrupts(); BOOL enabled = OSDisableInterrupts();
OSRestoreInterrupts(enabled); OSRestoreInterrupts(enabled);
} }
void CDvdFile::PingARAMTransfer() {}
void CDvdFile::TryARAMFile() {}
void CDvdFile::PushARAMFileLoad() {}
void CDvdFile::PopARAMFileLoad() {}
extern "C" void sub_8034ff7c() {}
void CDvdFile::StartARAMFileLoad() {}
void CDvdFile::StallForARAMFile() {}
CDvdFile::CDvdFile(const char* filename)
: x0_fileEntry(-1)
, x4_(0)
, x8_(0)
, x9_(0)
, xc_(nullptr)
, x10_offset(0)
, x14_size(0)
, x18_filename(filename, -1) {
const char* decodedName = DecodeARAMFile(filename);
x0_fileEntry = DVDConvertPathToEntrynum(const_cast< char* >(decodedName));
DVDFileInfo fileInfo;
if (x0_fileEntry != -1) {
DVDFastOpen(x0_fileEntry, &fileInfo);
}
x14_size = fileInfo.length;
DVDClose(&fileInfo);
if (filename != decodedName) {
TryARAMFile();
}
}
CDvdFile::~CDvdFile() { CloseFile(); }
IDvdRequest* CDvdFile::SyncRead(void* dest, uint len) { AsyncSeekRead(dest, len, kSO_Cur, 0); }
IDvdRequest* CDvdFile::SyncSeekRead(void* buf, uint len, ESeekOrigin origin, int offset) {}
IDvdRequest* CDvdFile::AsyncSeekRead(void* dest, uint len, ESeekOrigin origin, int offset) {
IDvdRequest* request;
StallForARAMFile();
CalcFileOffset(offset, origin);
if (x8_) {
} else {
int roundedLen = (len + 31) & ~31;
DCFlushRange(dest, roundedLen);
request = new CARAMDvdRequest(0);
}
UpdateFilePos(len);
return request;
}
void CDvdFile::CloseFile() {
if (!x8_) {
return;
}
StallForARAMFile();
CARAMManager::Free(x4_);
}
bool CDvdFile::FileExists(const char* filename) {
return DVDConvertPathToEntrynum(const_cast< char* >(DecodeARAMFile(filename))) != -1;
}
void CDvdFile::internalCallback(s32, DVDFileInfo*) {}
void CDvdFile::CalcFileOffset(int offset, ESeekOrigin origin) {
switch(origin) {
case kSO_Set:
x10_offset = offset;
break;
case kSO_Cur:
x10_offset += offset;
break;
case kSO_End:
x10_offset = offset + x14_size;
break;
}
}
void CDvdFile::UpdateFilePos(int pos) {
x10_offset += (pos + 31) & ~31;
int filesize = GetFileSize();
if (x10_offset > filesize) {
x10_offset = filesize;
}
}