all repos — mgba @ 30cac2e24b271277d66b42041b0c8a5a95a89f6b

mGBA Game Boy Advance Emulator

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};
26
27struct DSGXSoftwareEdge {
28	unsigned polyId;
29	int32_t y0; // 20.12
30	int32_t x0; // 20.12
31	int32_t z0; // 20.12
32	int32_t w0; // 20.12
33	uint8_t cr0;
34	uint8_t cg0;
35	uint8_t cb0;
36	int16_t s0;
37	int16_t t0;
38
39	int32_t y1; // 20.12
40	int32_t x1; // 20.12
41	int32_t z1; // 20.12
42	int32_t w1; // 20.12
43	uint8_t cr1;
44	uint8_t cg1;
45	uint8_t cb1;
46	int16_t s1;
47	int16_t t1;
48};
49
50struct DSGXSoftwareEndpoint {
51	int32_t x; // 20.12
52	int64_t z;
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	bool wSort;
82
83	struct DSGXVertex* verts;
84};
85
86CXX_GUARD_END
87
88#endif