1#include "Library/System/SystemKit.h"
2
3#include <heap/seadHeapMgr.h>
4#include <resource/seadParallelSZSDecompressor.h>
5#include <resource/seadResourceMgr.h>
6#include <resource/seadSZSDecompressor.h>
7#include <resource/seadSharcArchiveRes.h>
8
9#include "Project/File/FileLoader.h"
10#include "Project/Memory/MemorySystem.h"
11#include "Project/Resource/ResourceSystem.h"
12#include "Project/SaveData/SaveDataDirector.h"
13
14namespace al {
15
16SystemKit::SystemKit() = default;
17
18void SystemKit::createFileLoader(s32 threadPriority) {
19 mFileLoader = new FileLoader(threadPriority);
20}
21
22void SystemKit::createMemorySystem(sead::Heap* heap) {
23 sead::ScopedCurrentHeapSetter setter(heap);
24 mMemorySystem = new MemorySystem(heap);
25}
26
27void SystemKit::createResourceSystem(const char* archivePath, s32 threadPriority,
28 s32 decompressDestinationSize, bool useSubCore) {
29 sead::ResourceMgr::instance()->registerFactory(
30 factory: new sead::DirectResourceFactory<sead::SharcArchiveRes>(), name: "sarc");
31 sead::ResourceMgr::instance()->registerFactory(
32 factory: new sead::DirectResourceFactory<sead::SharcArchiveRes>(), name: "aras");
33
34 decompressDestinationSize =
35 decompressDestinationSize >= 0 ? decompressDestinationSize : 0x400000;
36 u8* decompressDestination = new (0x20) u8[decompressDestinationSize];
37
38 sead::ResourceMgr* instance = sead::ResourceMgr::instance();
39 if (threadPriority == -1) {
40 instance->registerDecompressor(
41 decompressor: new sead::SZSDecompressor(decompressDestinationSize / 2, decompressDestination), name: "szs");
42 } else {
43 sead::CoreId mask = useSubCore ? sead::CoreId::cSub2 : sead::CoreId::cMain;
44 instance->registerDecompressor(decompressor: new sead::ParallelSZSDecompressor(
45 decompressDestinationSize / 2, threadPriority, nullptr,
46 decompressDestination, sead::CoreIdMask(mask)),
47 name: "szs");
48 }
49
50 mResourceSystem = new ResourceSystem(archivePath);
51}
52
53void SystemKit::createSaveDataSystem(u32 workBufferSize, s32 threadPriority) {
54 mSaveDataDirector = new SaveDataDirector(workBufferSize, threadPriority);
55}
56
57} // namespace al
58