summaryrefslogtreecommitdiff
path: root/src/gUnkClass20.cpp
blob: 960e5938cb451e1617834ca9f5f21ed88c05f01d (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "ctorStruct.h"
#include <string.h>
#include <SDK/os.h>
#include "GSfilterModule.h"
#include "gUnkClass20.h"

static ctorStruct gUnk8063F370(1, 4, 0);

extern "C"
{
// TODO: move to proper header
void* func_8023B058(u8);
void func_8023B3B8(void*, u32);
void func_8023B420(void*, u32);
}

// "constructor" ?
gUnkClass20* gUnkClass20::func_801E0810(u32 p2, u8 p3, u8 p4)
{
    u32 r30;
    
    if (!lbl_8063F410)
        return NULL;
    gUnkClass20* r29 = func_801FB80C(lbl_8063F410);
    if (!r29)
        return NULL;
    r29->unk1 = 1;
    r29->unk2 = p3;
    r29->unk3 = p4;
    r29->unk4 = p2;
    if (r29->unk3) {
        r30 = lbl_8063F410->unk10;
        void* r3 = func_8023B058(static_cast<u8>(r30 >> 16));
        if (r3)
            func_8023B3B8(r3, r30);
    }
    
    const GSfilterModule* r3 = lbl_8063F410;
    gUnkClass21* r4 = (r29->unk1) ? &r3->unk3F0[r29->unk0] : NULL;
    
    r4->unk0 = unk0;
    r4->unk1 = unk1;
    r4->unk2 = unk2;
    r4->unk3 = unk3;
    return r29;
}

// "destructor" ?
void gUnkClass20::func_801E0904()
{
    if (unk1) {
        if (unk3) {
            u32 r31 = lbl_8063F410->unk10;
            void* r3 = func_8023B058(static_cast<u8>(r31 >> 16));
            if (r3)
                func_8023B420(r3, r31);
        }
        unk1 = 0;
        unk4 = NULL;
    }
}

// read into p2
void gUnkClass20::func_801E0978(gUnkClass21* p2) const
{
    if (unk1) {
        const GSfilterModule* r5 = lbl_8063F410;
        const gUnkClass21* r3 = (unk1) ? &r5->unk3F0[unk0] : NULL;
        *p2 = *r3;
        return;
    }
    memset(p2, 0, sizeof(gUnkClass21));
}

// write from p2
void gUnkClass20::func_801E09DC(gUnkClass21* p2) const
{
    if (!unk1)
        return;
    const GSfilterModule* r5 = lbl_8063F410;
    gUnkClass21* r3 = (unk1) ? &r5->unk3F0[unk0] : NULL;
    *r3 = *p2;
    DCFlushRange(r3, sizeof(gUnkClass21));
}