include/mgba/internal/ds/gx/software.h (view raw)
1/* Copyright (c) 2013-2017 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef DS_GX_SOFTWARE_H
7#define DS_GX_SOFTWARE_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba/internal/ds/gx.h>
14#include <mgba/internal/ds/video.h>
15#include <mgba-util/table.h>
16#include <mgba-util/vector.h>
17
18struct DSGXSoftwarePolygon {
19 struct DSGXPolygon* poly;
20 uint16_t* texBase;
21 uint16_t* palBase;
22 int texFormat;
23 int texW;
24 int texH;
25 int32_t topY;
26 int32_t bottomY;
27 int32_t topZ;
28};
29
30struct DSGXSoftwareEdge {
31 unsigned polyId;
32 int32_t y0; // 20.12
33 int32_t x0; // 20.12
34 int32_t w0; // 20.12
35 uint8_t cr0;
36 uint8_t cg0;
37 uint8_t cb0;
38 int16_t s0;
39 int16_t t0;
40
41 int32_t y1; // 20.12
42 int32_t x1; // 20.12
43 int32_t w1; // 20.12
44 uint8_t cr1;
45 uint8_t cg1;
46 uint8_t cb1;
47 int16_t s1;
48 int16_t t1;
49};
50
51struct DSGXSoftwareEndpoint {
52 int32_t x; // 20.12
53 int64_t w;
54 uint8_t cr;
55 uint8_t cg;
56 uint8_t cb;
57 int16_t s;
58 int16_t t;
59};
60
61struct DSGXSoftwareSpan {
62 struct DSGXSoftwarePolygon* poly;
63 struct DSGXSoftwareEndpoint ep[2];
64};
65
66DECLARE_VECTOR(DSGXSoftwarePolygonList, struct DSGXSoftwarePolygon);
67DECLARE_VECTOR(DSGXSoftwareEdgeList, struct DSGXSoftwareEdge);
68DECLARE_VECTOR(DSGXSoftwareSpanList, struct DSGXSoftwareSpan);
69
70struct DSGXSoftwareRenderer {
71 struct DSGXRenderer d;
72
73 struct DSGXSoftwarePolygonList activePolys;
74 struct DSGXSoftwareEdgeList activeEdges;
75 struct DSGXSoftwareSpanList activeSpans;
76 struct DSGXSoftwareSpan** bucket;
77
78 uint16_t depthBuffer[DS_VIDEO_HORIZONTAL_PIXELS];
79 color_t* scanlineCache;
80 bool flushPending;
81
82 struct DSGXVertex* verts;
83};
84
85CXX_GUARD_END
86
87#endif