mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-06-08 19:49:34 -04:00
Add & Link JKernel (#142)
* match and link JKRAram.cpp * match and link JKRExpHeap * match and link JKRAramStream.cpp * match and link JKRFileLoader.cpp * match and link JKRFileFinder.cpp * JKernel Dump * match and link JKRAramArchive.cpp * match and link JKRDvdArchive.cpp * match and link JKRCompArchive.cpp * match but not link JKRDvdAramRipper * small refactors * match and link JKRThread.cpp * fix and link JKRDvdAramStream.cpp * Formatting fixes --------- Co-authored-by: SwareJonge <olaf23okken@gmail.com>
This commit is contained in:
@@ -29,12 +29,12 @@ void JKRDvdFile::initiate() {
|
||||
/* Reference to self. Used to retrieve reference in the DVDReadAsync
|
||||
* DVDCallback func. */
|
||||
this->mDvdFileInfo.mFile = this;
|
||||
OSInitMutex(&this->mMutex1);
|
||||
OSInitMutex(&this->mMutex2);
|
||||
OSInitMessageQueue(&this->mMessageQueue2, &this->mMsg2, 1);
|
||||
OSInitMessageQueue(&this->mMessageQueue1, &this->mMsg1, 1);
|
||||
this->mThread2 = nullptr;
|
||||
this->mThread1 = nullptr;
|
||||
OSInitMutex(&this->mDvdMutex);
|
||||
OSInitMutex(&this->mAramMutex);
|
||||
OSInitMessageQueue(&this->mDvdMessageQueue, &this->mDvdMessage, 1);
|
||||
OSInitMessageQueue(&this->mAramMessageQueue, &this->mAramMessage, 1);
|
||||
this->mDvdThread = nullptr;
|
||||
this->mAramThread = nullptr;
|
||||
this->_58 = 0;
|
||||
}
|
||||
|
||||
@@ -68,29 +68,31 @@ bool JKRDvdFile::close() {
|
||||
if (DVDClose(&this->mDvdFileInfo)) {
|
||||
this->mFileOpen = false;
|
||||
return sDvdList.remove(&this->mLink);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
OSErrorLine(212, "cannot close DVD file\n"); /* JKRDvdFile.cpp line 212 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int JKRDvdFile::readData(void* data, s32 length, s32 ofs) {
|
||||
OSLockMutex(&this->mMutex1);
|
||||
OSLockMutex(&this->mDvdMutex);
|
||||
s32 retAddr;
|
||||
|
||||
if (this->mThread2 != nullptr) {
|
||||
OSUnlockMutex(&this->mMutex1);
|
||||
if (this->mDvdThread != nullptr) {
|
||||
OSUnlockMutex(&this->mDvdMutex);
|
||||
return -1;
|
||||
} else {
|
||||
this->mThread2 = OSGetCurrentThread();
|
||||
}
|
||||
else {
|
||||
this->mDvdThread = OSGetCurrentThread();
|
||||
retAddr = -1;
|
||||
if (DVDReadAsync(&this->mDvdFileInfo, data, length, ofs,
|
||||
JKRDvdFile::doneProcess)) {
|
||||
JKRDvdFile::doneProcess)) {
|
||||
retAddr = this->sync();
|
||||
}
|
||||
|
||||
this->mThread2 = nullptr;
|
||||
OSUnlockMutex(&this->mMutex1);
|
||||
this->mDvdThread = nullptr;
|
||||
OSUnlockMutex(&this->mDvdMutex);
|
||||
}
|
||||
|
||||
return retAddr;
|
||||
@@ -101,14 +103,14 @@ int JKRDvdFile::writeData(const void* data, s32 length, s32 ofs) { return -1; }
|
||||
s32 JKRDvdFile::sync() {
|
||||
OSMessage m;
|
||||
|
||||
OSLockMutex(&this->mMutex1);
|
||||
OSReceiveMessage(&this->mMessageQueue2, &m, OS_MESSAGE_BLOCK);
|
||||
this->mThread2 = nullptr;
|
||||
OSUnlockMutex(&this->mMutex1);
|
||||
OSLockMutex(&this->mDvdMutex);
|
||||
OSReceiveMessage(&this->mDvdMessageQueue, &m, OS_MESSAGE_BLOCK);
|
||||
this->mDvdThread = nullptr;
|
||||
OSUnlockMutex(&this->mDvdMutex);
|
||||
return (s32)m;
|
||||
}
|
||||
|
||||
void JKRDvdFile::doneProcess(s32 result, DVDFileInfo* info) {
|
||||
OSSendMessage(&static_cast<JKRDvdFileInfo*>(info)->mFile->mMessageQueue2,
|
||||
(OSMessage)result, OS_MESSAGE_NOBLOCK);
|
||||
OSSendMessage(&static_cast<JKRDvdFileInfo*>(info)->mFile->mDvdMessageQueue,
|
||||
(OSMessage)result, OS_MESSAGE_NOBLOCK);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user