mirror of https://github.com/zeldaret/botw.git
loadArcResource
This commit is contained in:
parent
36d114214d
commit
e5119d9f35
|
|
@ -88344,15 +88344,15 @@ Address,Quality,Size,Name
|
|||
0x00000071010a32e0,U,001584,LayoutResourceMgr::loadALotOfResources
|
||||
0x00000071010a3910,W,000064,_ZN4sead12PerfJobQueue13measureEndRunEv
|
||||
0x00000071010a3950,W,000072,_ZN4ksys2ui17LayoutResourceMgr23loadCommonLayoutArchiveEPN4sead7ExpHeapE
|
||||
0x00000071010a3998,U,000288,LayoutResourceMgr::loadArcResource
|
||||
0x00000071010a3ab8,U,000104,LayoutResourceMgr::deleteSOmething
|
||||
0x00000071010a3998,O,000288,_ZN4ksys2ui17LayoutResourceMgr15loadArcResourceERNS1_7ArchiveEPKc
|
||||
0x00000071010a3ab8,O,000104,_ZN4ksys2ui17LayoutResourceMgr8unloadA8Ev
|
||||
0x00000071010a3b20,O,000208,_ZN4ksys2ui17LayoutResourceMgr15loadTitleLayoutEPN4sead4HeapE
|
||||
0x00000071010a3bf0,O,000016,_ZN4ksys2ui17LayoutResourceMgr23loadTitleLayoutResourceEv
|
||||
0x00000071010a3c00,O,000104,_ZN4ksys2ui17LayoutResourceMgr25unloadTitleLayoutResourceEv
|
||||
0x00000071010a3c68,U,000264,LayoutResourceMgr::x
|
||||
0x00000071010a3d70,U,000076,LayoutResourceMgr::x_0
|
||||
0x00000071010a3dbc,U,000068,LayoutResourceMgr::checkHorse
|
||||
0x00000071010a3e00,U,000168,LayoutResourceMgr::pending
|
||||
0x00000071010a3c00,O,000104,_ZN4ksys2ui17LayoutResourceMgr17unloadTitleLayoutEv
|
||||
0x00000071010a3c68,O,000264,_ZN4ksys2ui17LayoutResourceMgr15loadHorseLayoutEPN4sead4HeapE
|
||||
0x00000071010a3d70,O,000076,_ZN4ksys2ui17LayoutResourceMgr23loadHorseLayoutResourceEv
|
||||
0x00000071010a3dbc,O,000068,_ZNK4ksys2ui17LayoutResourceMgr25hasHorseLayoutLoadFailureEv
|
||||
0x00000071010a3e00,O,000168,_ZN4ksys2ui17LayoutResourceMgr17unloadHorseLayoutEv
|
||||
0x00000071010a3ea8,U,000104,ScreenLoadSaveIcon::ctor
|
||||
0x00000071010a3f10,U,000044,
|
||||
0x00000071010a3f3c,U,000048,
|
||||
|
|
|
|||
|
Can't render this file because it is too large.
|
|
|
@ -2,20 +2,31 @@
|
|||
|
||||
#include <heap/seadDisposer.h>
|
||||
#include <prim/seadSafeString.h>
|
||||
#include "KingSystem/System/UI/ArcResourceMgr.h"
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace ksys::ui {
|
||||
namespace ksys {
|
||||
namespace res {
|
||||
class Handle;
|
||||
}
|
||||
namespace ui {
|
||||
|
||||
class ArcResourceMgr;
|
||||
|
||||
class ArcResource : public sead::IDisposer {
|
||||
public:
|
||||
ArcResource() = default;
|
||||
|
||||
void init(ArcResourceMgr* mgr, const sead::SafeString& name, u8* data, res::Handle* handle);
|
||||
private:
|
||||
void* _20;
|
||||
void* _28;
|
||||
ArcResourceMgr* mArcResourceMgr;
|
||||
sead::FixedSafeString<0x40> mName;
|
||||
u8* mData;
|
||||
void* mResource;
|
||||
void* mFile;
|
||||
res::Handle* mHandle;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(ArcResource, 0xA8);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <container/seadTList.h>
|
||||
#include <prim/seadSafeString.h>
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
#include "KingSystem/System/UI/ArcResource.h"
|
||||
|
||||
namespace sead {
|
||||
class ExpHeap;
|
||||
|
|
@ -16,6 +17,10 @@ public:
|
|||
virtual ~ArcResourceMgr();
|
||||
|
||||
virtual void loadArchive(sead::ExpHeap* heap, const sead::SafeString& path);
|
||||
virtual void sub_18();
|
||||
virtual void sub_20();
|
||||
virtual void sub_28();
|
||||
virtual void addArchive(ArcResource* archive);
|
||||
|
||||
private:
|
||||
// TODO: fields
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#include <prim/seadScopedLock.h>
|
||||
#include <devenv/seadEnvUtil.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include "KingSystem/Resource/resLoadRequest.h"
|
||||
#include "KingSystem/System/StarterPackMgr.h"
|
||||
|
||||
#include "LayoutResourceMgr.h"
|
||||
#include "KingSystem/System/UI/ArcResource.h"
|
||||
#include "KingSystem/System/UI/LayoutResourceMgr.h"
|
||||
|
||||
namespace ksys::ui {
|
||||
|
||||
|
|
@ -181,14 +181,87 @@ void LayoutResourceMgr::loadTitleLayout(sead::Heap* heap) {
|
|||
req._c = 2;
|
||||
|
||||
res::Handle::Status status = res::Handle::Status::NoFile;
|
||||
mTitleLayout.getHandle().requestLoad("Layout/Title.blarc", &req, &status);
|
||||
mTitleLayout.getHandle()->requestLoad("Layout/Title.blarc", &req, &status);
|
||||
}
|
||||
|
||||
bool LayoutResourceMgr::loadTitleLayoutResource() {
|
||||
return loadArcResource(mTitleLayout, "Title");
|
||||
}
|
||||
|
||||
void LayoutResourceMgr::unloadTitleLayoutResource() {
|
||||
void LayoutResourceMgr::unloadTitleLayout() {
|
||||
mTitleLayout.deallocate();
|
||||
}
|
||||
|
||||
bool LayoutResourceMgr::loadHorseLayout(sead::Heap* heap) {
|
||||
sead::ScopedLock<sead::CriticalSection> lock(&mCriticalSection);
|
||||
|
||||
if (mHorseLayoutLoadCount++) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mHorseLayout.allocate(heap);
|
||||
|
||||
res::LoadRequest req;
|
||||
req.mRequester = "ui::LayoutResourceMgr";
|
||||
req.mLoadDataAlignment = 0x1000;
|
||||
req._22 = false;
|
||||
req._26 = true;
|
||||
req._c = 2;
|
||||
|
||||
res::Handle::Status status = res::Handle::Status::NoFile;
|
||||
mHorseLayout.getHandle()->requestLoad("Layout/Horse.blarc", &req, &status);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LayoutResourceMgr::loadHorseLayoutResource() {
|
||||
sead::ScopedLock<sead::CriticalSection> lock(&mCriticalSection);
|
||||
return loadArcResource(mHorseLayout, "Horse");
|
||||
}
|
||||
|
||||
bool LayoutResourceMgr::hasHorseLayoutLoadFailure() const {
|
||||
if (mHorseLayout.getHandle()) {
|
||||
if (mHorseLayout.getHandle()->isReady() && !mHorseLayout.getHandle()->isSuccess()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LayoutResourceMgr::unloadHorseLayout() {
|
||||
sead::ScopedLock<sead::CriticalSection> lock(&mCriticalSection);
|
||||
int old_count = mHorseLayoutLoadCount--;
|
||||
|
||||
if (mHorseLayoutLoadCount == 0) {
|
||||
mHorseLayout.deallocate();
|
||||
return true;
|
||||
}
|
||||
|
||||
return old_count < 2;
|
||||
}
|
||||
|
||||
bool LayoutResourceMgr::loadArcResource(Archive& archive, const char* name) {
|
||||
if (!archive.getResource()) {
|
||||
if (!archive.getHandle()->isReady()) {
|
||||
return false;
|
||||
}
|
||||
if (archive.getHandle()->isSuccess()) {
|
||||
auto* resource = sead::DynamicCast<sead::DirectResource>(archive.getHandle()->getResource());
|
||||
if (resource) {
|
||||
auto* arc_resource = reinterpret_cast<ArcResource*>(archive.mResourceStorage);
|
||||
arc_resource->init(mArcResourceMgr, name, resource->getRawData(), archive.mHandle);
|
||||
archive.mResource = arc_resource;
|
||||
mArcResourceMgr->addArchive(archive.getResource());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void LayoutResourceMgr::unloadA8() {
|
||||
_a8.deallocate();
|
||||
}
|
||||
|
||||
|
||||
} // namespace ksys::ui
|
||||
|
|
|
|||
|
|
@ -23,10 +23,11 @@ class LayoutResourceMgr {
|
|||
virtual ~LayoutResourceMgr();
|
||||
private:
|
||||
class Archive {
|
||||
friend class LayoutResourceMgr;
|
||||
public:
|
||||
void allocate(sead::Heap* heap) {
|
||||
mHandle = new (heap) res::Handle;
|
||||
_sizeA8Buf = new (heap) u8[0xA8];
|
||||
mResourceStorage = new (heap) u8[sizeof(ArcResource)];
|
||||
}
|
||||
void deallocate() {
|
||||
if (mResource) {
|
||||
|
|
@ -34,17 +35,21 @@ private:
|
|||
mResource = nullptr;
|
||||
} else {
|
||||
delete mHandle;
|
||||
delete[] _sizeA8Buf;
|
||||
delete[] mResourceStorage;
|
||||
}
|
||||
mHandle = nullptr;
|
||||
_sizeA8Buf = nullptr;
|
||||
mResourceStorage = nullptr;
|
||||
}
|
||||
|
||||
res::Handle& getHandle() { return *mHandle; }
|
||||
res::Handle* getHandle() { return mHandle; }
|
||||
const res::Handle* getHandle() const { return mHandle; }
|
||||
ArcResource* getResource() { return mResource; }
|
||||
const ArcResource* getResource() const { return mResource; }
|
||||
|
||||
private:
|
||||
res::Handle* mHandle = nullptr;
|
||||
ArcResource* mResource = nullptr;
|
||||
u8* _sizeA8Buf = nullptr;
|
||||
u8* mResourceStorage = nullptr;
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
@ -60,7 +65,12 @@ public:
|
|||
void loadCommonLayoutArchive(sead::ExpHeap* heap);
|
||||
void loadTitleLayout(sead::Heap* heap);
|
||||
bool loadTitleLayoutResource();
|
||||
void unloadTitleLayoutResource();
|
||||
void unloadTitleLayout();
|
||||
bool loadHorseLayout(sead::Heap* heap);
|
||||
bool loadHorseLayoutResource();
|
||||
bool hasHorseLayoutLoadFailure() const;
|
||||
bool unloadHorseLayout();
|
||||
void unloadA8();
|
||||
|
||||
bool loadArcResource(Archive& archive, const char* name);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue