summaryrefslogtreecommitdiff
path: root/include/JSystem/JMessage/data.h
blob: f14489c98ef2a5785aa01f9af952a49281d7f023 (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
#ifndef JMESSAGE_DATA_H
#define JMESSAGE_DATA_H

#include "JSystem/JGadget/binary.h"

namespace JMessage {

/**
 * @ingroup jsystem-jmessage
 * 
 */
struct data {
    struct TParse_THeader : public JGadget::binary::TParseData_aligned<4> {
        TParse_THeader(const void* data) : TParseData_aligned(data) {}

        const void* getContent() const { return (char*)getRaw() + 0x20; }
        char* get() const { return (char*)getRaw(); }

        u32* get_signature() const { return (u32*)(get() + 0x0); }
        u32 get_type() const { return *(u32*)(get() + 0x4); }
        u32 get_blockNumber() const { return *(u32*)(get() + 0xC); }
        u8 get_encoding() const { return *(u8*)(get() + 0x10); }
    };

    struct TParse_TBlock : public JGadget::binary::TParseData_aligned<4> {
        TParse_TBlock(const void* data) : TParseData_aligned(data) {}
    };

    struct TParse_TBlock_info : public TParse_TBlock {
        TParse_TBlock_info(const void* data) : TParse_TBlock(data) {}

        char* get() const { return (char*)getRaw(); }

        char* getContent() const { return (char*)getRaw() + 0x10; }

        u16 get_messageEntrySize() const { return *(u16*)(get() + 0xA); }

        u16 get_messageEntryNumber() const { return *(u16*)(get() + 0x8); }

        u16 get_groupID() const { return *(u16*)(get() + 0xC); }
    };

    struct TParse_TBlock_messageID : public TParse_TBlock {
        TParse_TBlock_messageID(const void* data) : TParse_TBlock(data) {}
    };

    struct TParse_TBlock_color : public TParse_TBlock {
        TParse_TBlock_color(const void* data) : TParse_TBlock(data) {}
    };

    static u32 getTagCode(u32 tag) { return tag & 0xFFFF; }
    static u32 getTagGroup(u32 tag) { return (tag >> 0x10) & 0xFF; }

    static u32 ga4cSignature;

    static const int gcTagBegin = '\x1A';
};
};  // namespace JMessage

#endif /* JMESSAGE_DATA_H */