summaryrefslogtreecommitdiff
path: root/include/egg/core/eggThreadMgr.h
blob: b1b21e2f8357bde9747f66d17c4a81dc360861b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef EGG_THREAD_MGR_H
#define EGG_THREAD_MGR_H

#include "common.h"

#include "rvl/OS.h" // IWYU pragma: export

// This is seen in Animal Crossing: City Folk also. Idk where it belongs

// Seen between EGG::Thread and EGG::ConfigurationData (eggThread and eggSystem)
// dSysNandThread (or NandRequestThread ) inherits from eggThread,
//          with part of that thread referencing tsome of these funcs

namespace EGG {

// Color? Tag?
struct UnknownStruct {
    u8 _00;
    u8 _01;
    u8 _02;
    u8 _03;
};

struct ThreadInfo {
    OSThread *mThread;
    UnknownStruct _04;
    bool _08;
    char _09[32]; // Buffer for name?
    u32 _2C;
};

// This is a complete guess
class ThreadMgr {
public:
    void registerThread(OSThread *thread, UnknownStruct);

    static ThreadMgr *getInstance() {
        return sInstance;
    }

private:
    s32 getThreadIndex(OSThread *thread);
    s32 doRegisterThread(OSThread *thread);
    void sortByPriority();

private:
    u8 _placeholder_00[0x8];
    /* 0x08 */ s32 mMaxThreads;
    u8 _placeholder_0C[0x3C - 0xC];
    /* 0x3C */ ThreadInfo *mThreadList;
    u8 _placeholder_40[0x44 - 0x40];
    /* 0x44 */ s32 mThreadCount;
    u8 _placeholder_48[0xEC - 0x48];
    /* 0xEC */ UnknownStruct _EC; // Default color/tag?
    u8 _placeholder_F0[0xF4 - 0xF0];
    /* 0xF4 */ u32 _F4;
    /* 0xF8 */ bool mSortEnabled;
    // size unsure, but this is the limit seen

    static ThreadMgr *sInstance;
};

} // namespace EGG

#endif // EGG_THREAD_MGR_H