summaryrefslogtreecommitdiff
path: root/include/egg/gfx/eggDrawGX.h
blob: 862792f8dd81e740481f0de3f9242d2a8482fa2d (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#ifndef EGG_DRAWGX_H
#define EGG_DRAWGX_H

#include "common.h"
#include "egg/core/eggHeap.h"
#include "egg/gfx/eggTexture.h"
#include "egg/math/eggMatrix.h"
#include "nw4r/g3d/res/g3d_restex.h"
#include "nw4r/math/math_types.h"
#include "rvl/GX/GXTexture.h"
#include "rvl/GX/GXTypes.h"

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

namespace EGG {

class DrawGX {
public:
    DrawGX() {}
    // made up
    struct DLData {
        u8 *mpList;
        u32 mLen;
    };

    // made up, stride 0xC
    struct ZModeConfig {
        bool mTest;
        GXCompare mCompare;
        bool mUpdate;
    };

    // made up, stride 0x10
    struct BlendModeConfig {
        GXBlendMode mBlendMode;
        GXBlendFactor mBlendFactorSrc;
        GXBlendFactor mBlendFactorDst;
        GXLogicOp mLogicOp;
    };

    enum DL {
        DL_0,
        DL_1,
        DL_2,
        DL_3,
        DL_4,
        DL_5,
        DL_6,
        DL_7,
        DL_8,
        DL_9,
        DL_10,
        DL_11,
        DL_12,
        DL_13,
        DL_14,
        DL_15,
        DL_16,
        DL_17,

        DL_MAX
    };

    enum VtxType {
        VTX_TYPE_0,
        VTX_TYPE_1,
        VTX_TYPE_2,
        VTX_TYPE_3,
        VTX_TYPE_4,
        VTX_TYPE_5,
        VTX_TYPE_6,
        VTX_TYPE_7,
        VTX_TYPE_8,
        VTX_TYPE_9,
        VTX_TYPE_10,
        VTX_TYPE_11,
        VTX_TYPE_12,
        VTX_TYPE_13
    };

    enum Blend {
        BLEND_0,
        BLEND_1,
        BLEND_2,
        BLEND_3,
        BLEND_4,
        BLEND_5,
        BLEND_6,
        BLEND_7,
        BLEND_8,
        BLEND_9,
        BLEND_10,
        BLEND_11,
        BLEND_12,
        BLEND_13,
        BLEND_14,

        BLEND_MAX
    };

    enum ZMode {
        ZMODE_0,
        ZMODE_1,
        ZMODE_2,
        ZMODE_3,

        ZMODE_MAX,
    };

    enum TevSetting {
        TEV_0,
        TEV_1,
        TEV_2,
    };

    enum TexGen {
        TEXGEN_0,
        TEXGEN_1,
    };

    enum ColorChannel {
        COLORCHAN_0,
        COLORCHAN_1,
    };

    static void Initialize(Heap *);

    static GXTexMapID GetTexMapDefault();
    static GXLightID GetLightMaskDefault();

    static void BeginDrawLine(ColorChannel, ZMode);
    static void BeginDrawCircleZ(ColorChannel, ZMode);
    static void BeginDrawQuad(ColorChannel, ZMode, Blend, bool, bool);
    static void BeginDrawScreen(bool, bool, bool);

    static void DrawLineStrip(const EGG::Vector3f *, u16, GXColor, u8);
    static void DrawLine(const EGG::Vector3f *, u16, GXColor, u8);
    static void ClearEfb(const nw4r::math::MTX34 &, bool, bool, bool, GXColor, bool);
    static void ResetMaterial(enum ColorChannel);
    static void SetMat_ColorChannel(enum ColorChannel);
    static void SetMat_TexGen(enum TexGen);
    static void SetMat_Ind();
    static void SetMat_Tev(GXTevStageID, enum TevSetting);
    static void SetMat_PE(enum ZMode, enum Blend);

    static void LoadTexture(const EGG::ResTIMG *, GXTexMapID);
    static void LoadTexture(nw4r::g3d::ResTex, GXTexMapID);

    static void CreateDisplayList(EGG::Heap *);
    static void DrawDL(enum DL, const nw4r::math::MTX34 &, GXColor);
    static void SetVtxState(enum VtxType);
    static void SetZMode(enum ZMode);
    static void SetBlendMode(enum Blend);
    static void DrawDLWorld(DL dl, const EGG::Matrix34f &mtx, GXColor color);

    static void DrawDL16(const nw4r::math::MTX34 &mtx, GXColor clr) {
        DrawDL(DL_16, mtx, clr);
    }
    static void DrawDL17(const nw4r::math::MTX34 &mtx, GXColor clr) {
        DrawDL(DL_17, mtx, clr);
    }
    // TODO MORE

    static void SetTevColor(GXTevRegID regId, GXColor tevClr, GXTevKColorID colorId, GXColor tevkClr) {
        GXSetTevColor(regId, tevClr);
        GXSetTevKColor(colorId, tevkClr);
    }

    // not sure
    static DLData s_DL[DL_MAX];
    static const DL s_DL0;
    static const DL s_DL7;
    static const DL s_DL8;

    static nw4r::math::MTX34 s_cameraMtx;

    static u32 s_flag;

    static const GXColor BLACK;
    static const GXColor WHITE;
    static const GXColor GREEN;
    static const GXColor RED;
    static const GXColor BLUE;
};

} // namespace EGG

#endif