diff --git a/config/RSBE01_02/splits.txt b/config/RSBE01_02/splits.txt index 759ecf9..62f15b3 100644 --- a/config/RSBE01_02/splits.txt +++ b/config/RSBE01_02/splits.txt @@ -62,6 +62,9 @@ sora/gf/gf_error_check.cpp: sora/gf/gf_file_io_handle.cpp: .text start:0x80020B38 end:0x80022054 +sora/gf/gf_file_io_request.cpp: + .text start:0x80022054 end:0x80022490 + sora/gf/gf_gameframe_counter.cpp: .text start:0x800241B4 end:0x800242DC diff --git a/config/RSBE01_02/symbols.txt b/config/RSBE01_02/symbols.txt index 1f7d278..a6c7a70 100644 --- a/config/RSBE01_02/symbols.txt +++ b/config/RSBE01_02/symbols.txt @@ -2428,8 +2428,8 @@ getSize__14gfFileIOHandleCFv = .text:0x80021F88; // type:function size:0xC getBuffer__14gfFileIOHandleCFv = .text:0x80021F94; // type:function size:0xC getPool__14gfFileIOHandleCFv = .text:0x80021FA0; // type:function size:0xC release__14gfFileIOHandleFv = .text:0x80021FAC; // type:function size:0xA8 -fn_80022054 = .text:0x80022054; // type:function size:0x16C -fn_800221C0 = .text:0x800221C0; // type:function size:0x78 +__ct__20gfFileIORequestQueueFv = .text:0x80022054; // type:function size:0x16C +__dt__15gfFileIORequestFv = .text:0x800221C0; // type:function size:0x78 setParam__15gfFileIORequestFPCc = .text:0x80022238; // type:function size:0xE4 setReadParam__15gfFileIORequestFPCcPCvii = .text:0x8002231C; // type:function size:0x80 setReadParam__15gfFileIORequestFPCcPvii = .text:0x8002239C; // type:function size:0x80 @@ -16032,7 +16032,7 @@ fn_803EF640 = .text:0x803EF640; // type:function size:0x414 fn_803EFA54 = .text:0x803EFA54; // type:function size:0x450 fn_803EFEA4 = .text:0x803EFEA4; // type:function size:0x1A8 fn_803F004C = .text:0x803F004C; // type:function size:0x5F4 -strlen__FPc = .text:0x803F0640; // type:function size:0x1C scope:weak +strlen = .text:0x803F0640; // type:function size:0x1C scope:weak __va_arg = .text:0x803F065C; // type:function size:0xC8 scope:global __register_global_object = .text:0x803F0724; // type:function size:0x18 scope:global __destroy_global_chain = .text:0x803F073C; // type:function size:0x48 scope:global @@ -16228,16 +16228,16 @@ fn_803FA078 = .text:0x803FA078; // type:function size:0x90 sscanf = .text:0x803FA108; // type:function size:0xC8 fn_803FA1D0 = .text:0x803FA1D0; // type:function size:0xB0 strcpy = .text:0x803FA280; // type:function size:0xC0 -strncpy__6StringF6StringPCcUl = .text:0x803FA340; // type:function size:0x44 +strncpy = .text:0x803FA340; // type:function size:0x44 strcat = .text:0x803FA384; // type:function size:0x2C strncat = .text:0x803FA3B0; // type:function size:0x4C strcmp = .text:0x803FA3FC; // type:function size:0x11C strncmp = .text:0x803FA518; // type:function size:0x40 -strchr__FPcPc = .text:0x803FA558; // type:function size:0x30 scope:global -strrchr__FPcPc = .text:0x803FA588; // type:function size:0x48 -strcspn__FPcPc = .text:0x803FA5D0; // type:function size:0xA4 -strtok__FPcPc = .text:0x803FA674; // type:function size:0x124 -strstr__FPcPc = .text:0x803FA798; // type:function size:0x6C +strchr = .text:0x803FA558; // type:function size:0x30 scope:global +strrchr = .text:0x803FA588; // type:function size:0x48 +strcspn = .text:0x803FA5D0; // type:function size:0xA4 +strtok = .text:0x803FA674; // type:function size:0x124 +strstr = .text:0x803FA798; // type:function size:0x6C fn_803FA804 = .text:0x803FA804; // type:function size:0x13F4 fn_803FBBF8 = .text:0x803FBBF8; // type:function size:0x84 fn_803FBC7C = .text:0x803FBC7C; // type:function size:0x430 diff --git a/configure.py b/configure.py index 541d1f4..440f748 100755 --- a/configure.py +++ b/configure.py @@ -299,6 +299,7 @@ def MatchingFor(*versions): Object(Matching, "sora/gf/gf_decomp.cpp"), Object(Matching, "sora/gf/gf_error_check.cpp"), Object(Matching, "sora/gf/gf_file_io_handle.cpp"), + Object(Matching, "sora/gf/gf_file_io_request.cpp"), Object(Matching, "sora/gf/gf_gameframe_counter.cpp"), Object(Matching, "sora/gf/gf_keep_fb.cpp"), Object(Matching, "sora/gf/gf_memory_util.cpp"), diff --git a/include/lib/BrawlHeaders b/include/lib/BrawlHeaders index fc62292..979fb89 160000 --- a/include/lib/BrawlHeaders +++ b/include/lib/BrawlHeaders @@ -1 +1 @@ -Subproject commit fc62292e773cc3157656ed7ad5dfaab226c1cb9a +Subproject commit 979fb8913a4859198738304c1b418feb0253820d diff --git a/src/sora/gf/gf_file_io_handle.cpp b/src/sora/gf/gf_file_io_handle.cpp index 9824651..f66810d 100644 --- a/src/sora/gf/gf_file_io_handle.cpp +++ b/src/sora/gf/gf_file_io_handle.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -24,7 +24,7 @@ bool gfFileIOHandle::createDirRequest(const char* filepath) { if (m_request) { m_request->setParam(filepath); m_request->m_kind = gfFileIORequest::CreateDir; - m_request->unk17_2 = false; + m_request->unk17_b1 = false; g_gfFileIOManager->push(m_request); return true; } @@ -72,7 +72,7 @@ bool gfFileIOHandle::checkDirRequest(const char* filepath) { if (m_request) { m_request->setParam(filepath); m_request->m_kind = gfFileIORequest::CheckDir; - m_request->unk17_2 = false; + m_request->unk17_b1 = false; g_gfFileIOManager->push(m_request); return true; } @@ -133,7 +133,7 @@ bool gfFileIOHandle::mountSD() { m_request->setParam(nullptr); m_request->m_kind = gfFileIORequest::MountSD; m_request->m_vfUnk = 0; - m_request->unk17_2 = false; + m_request->unk17_b1 = false; g_gfFileIOManager->push(m_request); return true; } @@ -146,7 +146,7 @@ bool gfFileIOHandle::unmountSD() { m_request->setParam(nullptr); m_request->m_kind = gfFileIORequest::UnmountSD; m_request->m_vfUnk = 0; - m_request->unk17_2 = false; + m_request->unk17_b1 = false; g_gfFileIOManager->push(m_request); return true; } @@ -194,7 +194,7 @@ bool gfFileIOHandle::readRequest(const char* filepath, HeapType heap, int length ensureLoaded(); if (m_request) { m_request->setReadParam(filepath, heapPtr, length, offset); - m_request->unk18_1 = true; + m_request->unk18_b5 = true; g_gfFileIOManager->push(m_request); return true; } @@ -205,7 +205,7 @@ bool gfFileIOHandle::readRequest(const char* filepath, const void* heapPtr, int ensureLoaded(); if (m_request) { m_request->setReadParam(filepath, heapPtr, length, offset); - m_request->unk18_1 = true; + m_request->unk18_b5 = true; g_gfFileIOManager->push(m_request); return true; } @@ -216,7 +216,7 @@ bool gfFileIOHandle::readRequest(const char* filepath, void* heapPtr, int length ensureLoaded(); if (m_request) { m_request->setReadParam(filepath, heapPtr, length, offset); - m_request->unk18_1 = true; + m_request->unk18_b5 = true; g_gfFileIOManager->push(m_request); return true; } @@ -229,7 +229,7 @@ bool gfFileIOHandle::readRequestCached(const char* filepath, HeapType heap, int if (m_request) { m_request->setReadParam(filepath, heapPtr, length, offset); m_request->m_isCached = true; - m_request->unk18_1 = true; + m_request->unk18_b5 = true; g_gfFileIOManager->push(m_request); return true; } @@ -241,7 +241,7 @@ bool gfFileIOHandle::readRequestCached(const char* filepath, const void* heapPtr if (m_request) { m_request->setReadParam(filepath, heapPtr, length, offset); m_request->m_isCached = true; - m_request->unk18_1 = true; + m_request->unk18_b5 = true; g_gfFileIOManager->push(m_request); return true; } @@ -253,7 +253,7 @@ bool gfFileIOHandle::readRequestCached(const char* filepath, void* heapPtr, int if (m_request) { m_request->setReadParam(filepath, heapPtr, length, offset); m_request->m_isCached = true; - m_request->unk18_1 = true; + m_request->unk18_b5 = true; g_gfFileIOManager->push(m_request); return true; } @@ -265,7 +265,7 @@ bool gfFileIOHandle::readRequestNoSync(const char* filepath, HeapType heap, int ensureLoaded(); if (m_request) { m_request->setReadParam(filepath, heapPtr, length, offset); - m_request->unk17_2 = false; + m_request->unk17_b1 = false; g_gfFileIOManager->push(m_request); return true; } @@ -276,7 +276,7 @@ bool gfFileIOHandle::readRequestNoSync(const char* filepath, void* heapPtr, int ensureLoaded(); if (m_request) { m_request->setReadParam(filepath, heapPtr, length, offset); - m_request->unk17_2 = false; + m_request->unk17_b1 = false; g_gfFileIOManager->push(m_request); return true; } @@ -287,8 +287,8 @@ bool gfFileIOHandle::read(const char* filepath, HeapType heap, int offset) { const void* heapPtr = gfHeapManager::getHeap(heap); ensureLoaded(); m_request->setReadParam(filepath, heapPtr, 0, offset); - m_request->unk17_2 = false; - m_request->unk18_0 = true; + m_request->unk17_b1 = false; + m_request->unk18_b7 = true; g_gfFileIOManager->push(m_request); goto loop; @@ -306,8 +306,8 @@ bool gfFileIOHandle::read(const char* filepath, HeapType heap, int offset) { bool gfFileIOHandle::read(const char* filepath, const void* heapPtr, int offset) { ensureLoaded(); m_request->setReadParam(filepath, heapPtr, 0, offset); - m_request->unk17_2 = false; - m_request->unk18_0 = true; + m_request->unk17_b1 = false; + m_request->unk18_b7 = true; g_gfFileIOManager->push(m_request); goto loop; @@ -325,8 +325,8 @@ bool gfFileIOHandle::read(const char* filepath, const void* heapPtr, int offset) bool gfFileIOHandle::read(const char* filepath, void* heapPtr, int offset) { ensureLoaded(); m_request->setReadParam(filepath, heapPtr, 0, offset); - m_request->unk17_2 = false; - m_request->unk18_0 = true; + m_request->unk17_b1 = false; + m_request->unk18_b7 = true; g_gfFileIOManager->push(m_request); goto loop; @@ -344,7 +344,7 @@ bool gfFileIOHandle::read(const char* filepath, void* heapPtr, int offset) { bool gfFileIOHandle::writeRequest(const char* filepath, void* heapPtr, int length, int offset) { ensureLoaded(); m_request->setWriteParam(filepath, heapPtr, length, offset); - m_request->unk17_2 = false; + m_request->unk17_b1 = false; g_gfFileIOManager->push(m_request); return true; } @@ -354,7 +354,7 @@ bool gfFileIOHandle::cancelRequest() { if (m_request) { if (!m_request->m_isCancelRequested) { int status = OSDisableInterrupts(); - bool r30 = m_request->unk17_0; + bool r30 = m_request->unk17_b5; if (!r30) { m_request->m_isCancelRequested = true; } @@ -406,7 +406,7 @@ void* gfFileIOHandle::getBuffer() const { return m_request->m_dest; } -void* gfFileIOHandle::getPool() const { +const void* gfFileIOHandle::getPool() const { return m_request->m_heap; } @@ -416,7 +416,7 @@ void gfFileIOHandle::release() { if (m_request->m_isCancelRequested && !m_request->m_isCanceled) { int status = OSDisableInterrupts(); if (!m_request->m_isCanceled) { - m_request->unk17_11 = true; + m_request->unk17_b2 = true; m_request->m_notifyCallback = nullptr; r31 = false; } diff --git a/src/sora/gf/gf_file_io_request.cpp b/src/sora/gf/gf_file_io_request.cpp new file mode 100644 index 0000000..b72ffaf --- /dev/null +++ b/src/sora/gf/gf_file_io_request.cpp @@ -0,0 +1,99 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +gfFileIORequestQueue::gfFileIORequestQueue() { + OSInitMutex(&m_mtx); + m_queue = new (Heaps::SystemFW) utQueue; +} + +gfFileIORequest::~gfFileIORequest() { + m_isReady = true; + unk17_b6 = false; + unk17_b5 = false; + m_isCancelRequested = false; + m_isCanceled = false; + unk17_b2 = false; + unk17_b1 = false; + unk17_b0 = false; + unk18_b7 = false; + unk18_b6 = false; + unk18_b5 = false; + unk18_b4 = false; + m_notifyCallback = nullptr; + m_pFilepath = nullptr; + m_filepath[0] = '\0'; +} + +void gfFileIORequest::setParam(const char* path) { + m_pFilepath = nullptr; + m_isReady = true; + + unk17_b6 = false; + unk17_b5 = false; + m_isCancelRequested = false; + m_isCanceled = false; + unk17_b2 = false; + unk17_b1 = false; + unk17_b0 = false; + + unk18_b7 = false; + unk18_b6 = false; + unk18_b5 = false; + unk18_b4 = false; + + m_returnStatus = 0; + m_isReady = false; + + unk17_b1 = g_gfFileIOManager->unk98; + unk17_b5 = false; + unk18_b5 = false; + m_dest = nullptr; + m_heap = nullptr; + unk18_b4 = false; + + m_filepath[0] = '\0'; + m_crc16 = 0; + if (path) { + m_pFilepath = m_filepath; + strncpy(m_filepath, path, sizeof(m_filepath) - 1); + m_crc16 = NETCalcCRC16(m_pFilepath, strlen(m_pFilepath)); + } +} + +void gfFileIORequest::setReadParam(const char* path, const void* addr, int len, int offs) { + setParam(path); + m_heap = addr; + m_kind = Read; + m_readLen = len; + m_offset = offs; + if (path[0] == '/' && path[1] == 'f') { + unk18_b4 = true; + } +} + +void gfFileIORequest::setReadParam(const char* path, void* addr, int len, int offs) { + setParam(path); + m_dest = addr; + m_kind = Read; + m_readLen = len; + m_offset = offs; + if (path[0] == '/' && path[1] == 'f') { + unk18_b4 = true; + } +} + +void gfFileIORequest::setWriteParam(const char* path, void* addr, int len, int offs) { + setParam(path); + m_kind = Write; + m_dest = addr; + m_heap = nullptr; + m_readLen = len; + m_offset = offs; +}