Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Cafe/HW/Latte/Core/LatteTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,8 +1307,9 @@ LatteTexture::LatteTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddre
}
}
}
// determine if this texture should ever be mirrored to CPU RAM
if (this->tileMode == Latte::E_HWTILEMODE::TM_LINEAR_ALIGNED)
// determine if this texture should ever be mirrored to CPU RAM.
if (this->tileMode == Latte::E_HWTILEMODE::TM_LINEAR_ALIGNED ||
this->tileMode == Latte::E_HWTILEMODE::TM_LINEAR_GENERAL)
{
this->enableReadback = true;
}
Expand Down
41 changes: 31 additions & 10 deletions src/Cafe/OS/libs/coreinit/coreinit_FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,23 +275,37 @@ namespace coreinit
cemuLog_log(LogType::Force, "FSShutdown called");
}

FS_RESULT FSAddClientEx(FSClient_t* fsClient, uint32 uknR4, uint32 errHandling)
struct AttachCallbackData
{
/* +0x00 */ uint8 unk[0x1c];
/* +0x1c */ char mountName[8];
};

SysAllocator<AttachCallbackData> s_fsAttachCallbackData;

void invokeAttachCallback(FSAttachParams& attachParams)
{
*s_fsAttachCallbackData = { .mountName = "sdcard" /* expected by Mii Maker */ };
PPCCoreCallback(attachParams.userCallback,
0 /* r3 = unknown */, 1 /* r4 = non-zero means device is attached */,
s_fsAttachCallbackData.GetMPTR(), attachParams.userContext);
}

FS_RESULT FSAddClientEx(FSClient_t* fsClient, FSAttachParams* attachParams, uint32 errHandling)
{
if (!sFSInitialized || sFSShutdown || !fsClient)
{
__FSErrorAndBlock("Called FSAddClient(Ex) with invalid parameters or while FS is not initialized");
return FS_RESULT::FATAL_ERROR;
}
FSLockMutex();
if (uknR4 != 0)
if (attachParams != nullptr &&
attachParams->userCallback == nullptr)
{
uint32 uknValue = memory_readU32(uknR4 + 0x00);
if (uknValue == 0)
{
FSUnlockMutex();
__FSErrorAndBlock("FSAddClientEx - unknown error");
return FS_RESULT::FATAL_ERROR;
}
FSUnlockMutex();
// "FS: FSAddClient: attachParams->userCallback must be set.\n"
__FSErrorAndBlock("FSAddClientEx - unknown error");
return FS_RESULT::FATAL_ERROR;
}
if (__FSIsClientRegistered(__FSGetClientBody(fsClient)))
{
Expand Down Expand Up @@ -324,12 +338,16 @@ namespace coreinit
fsClientBody->fsClientBodyNext = nullptr;
}
FSUnlockMutex();

if (attachParams != nullptr) // invoke right before returning
invokeAttachCallback(*attachParams);

return FS_RESULT::SUCCESS;
}

FS_RESULT FSAddClient(FSClient_t* fsClient, uint32 errHandling)
{
return FSAddClientEx(fsClient, 0, errHandling);
return FSAddClientEx(fsClient, nullptr, errHandling);
}

FS_RESULT FSDelClient(FSClient_t* fsClient, uint32 errHandling)
Expand Down Expand Up @@ -570,6 +588,7 @@ namespace coreinit
case FSA_CMD_OPERATION_TYPE::MAKEDIR:
case FSA_CMD_OPERATION_TYPE::REMOVE:
case FSA_CMD_OPERATION_TYPE::RENAME:
case FSA_CMD_OPERATION_TYPE::REWINDDIR:
case FSA_CMD_OPERATION_TYPE::CLOSEDIR:
case FSA_CMD_OPERATION_TYPE::READ:
case FSA_CMD_OPERATION_TYPE::WRITE:
Expand Down Expand Up @@ -2718,6 +2737,8 @@ namespace coreinit
cafeExportRegister("coreinit", FSReadDir, LogType::CoreinitFile);
cafeExportRegister("coreinit", FSCloseDirAsync, LogType::CoreinitFile);
cafeExportRegister("coreinit", FSCloseDir, LogType::CoreinitFile);
cafeExportRegister("coreinit", FSRewindDirAsync, LogType::CoreinitFile);
cafeExportRegister("coreinit", FSRewindDir, LogType::CoreinitFile);

// stat
cafeExportRegister("coreinit", FSGetFreeSpaceSizeAsync, LogType::CoreinitFile);
Expand Down
11 changes: 10 additions & 1 deletion src/Cafe/OS/libs/coreinit/coreinit_FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ struct FSAsyncParams
};
static_assert(sizeof(FSAsyncParams) == 0xC);

struct FSAttachParams
{
MEMPTR<void> userCallback;
MEMPTR<void> userContext;
};
static_assert(sizeof(FSAttachParams) == 0x8);

namespace coreinit
{
struct FSCmdBlockBody;
Expand Down Expand Up @@ -242,7 +249,7 @@ namespace coreinit
sint32 __FSQueryInfoAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* queryString, uint32 queryType, void* queryResult, uint32 errHandling, FSAsyncParams* fsAsyncParams);

// coreinit exports
FS_RESULT FSAddClientEx(FSClient_t* fsClient, uint32 uknR4, uint32 errHandling);
FS_RESULT FSAddClientEx(FSClient_t* fsClient, FSAttachParams* attachParams, uint32 errHandling);
FS_RESULT FSAddClient(FSClient_t* fsClient, uint32 errHandling);
FS_RESULT FSDelClient(FSClient_t* fsClient, uint32 errHandling);

Expand Down Expand Up @@ -292,6 +299,8 @@ namespace coreinit
sint32 FSReadDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, FSDirEntry_t* dirEntryOut, uint32 errorMask, FSAsyncParams* fsAsyncParams);
sint32 FSCloseDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams);
sint32 FSCloseDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask);
sint32 FSRewindDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams);
sint32 FSRewindDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask);

sint32 FSFlushQuotaAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask, FSAsyncParams* fsAsyncParams);
sint32 FSFlushQuota(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask);
Expand Down
2 changes: 0 additions & 2 deletions src/Cafe/OS/libs/gx2/GX2_RenderTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ void gx2Export_GX2SetColorBuffer(PPCInterpreter_t* hCPU)
gx2WriteGather_submitU32AsBE(mmCB_COLOR0_SIZE - 0xA000 + hCPU->gpr[4]);
gx2WriteGather_submitU32AsBE((uint32)colorBufferBE->reg_size);

cemu_assert_debug(tileMode != Latte::E_GX2TILEMODE::TM_LINEAR_SPECIAL);

// set mmCB_COLOR*_VIEW
gx2WriteGather_submit(
pm4HeaderType3(IT_SET_CONTEXT_REG, 2),
Expand Down