all repos — mgba @ c62d913e233e7ea3bb23a3f52fcb7b481f2faed5

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	unsigned polyId;
 21	DSGXPolygonAttrs polyParams;
 22	DSGXTexParams texParams;
 23	const uint16_t* texBase;
 24	const uint16_t* palBase;
 25	int texFormat;
 26	int blendFormat;
 27	int texW;
 28	int texH;
 29	int minY;
 30	int maxY;
 31};
 32
 33struct DSGXSoftwareEdge {
 34	unsigned polyId;
 35	int32_t y0; // 20.12
 36	int32_t x0; // 20.12
 37	int32_t z0; // 20.12
 38	int32_t w0; // 20.12
 39	int64_t wr0;
 40	uint8_t cr0;
 41	uint8_t cg0;
 42	uint8_t cb0;
 43	int16_t s0;
 44	int16_t t0;
 45
 46	int32_t y1; // 20.12
 47	int32_t x1; // 20.12
 48	int32_t z1; // 20.12
 49	int32_t w1; // 20.12
 50	int64_t wr1;
 51	uint8_t cr1;
 52	uint8_t cg1;
 53	uint8_t cb1;
 54	int16_t s1;
 55	int16_t t1;
 56};
 57
 58struct DSGXSoftwareEndpoint {
 59	int32_t coord[4]; // 20.12
 60	int64_t wRecip;
 61	uint8_t cr;
 62	uint8_t cg;
 63	uint8_t cb;
 64	int16_t s;
 65	int16_t t;
 66
 67	int64_t stepZ;
 68	int64_t stepW;
 69	int64_t stepR;
 70	int64_t stepG;
 71	int64_t stepB;
 72	int64_t stepS;
 73	int64_t stepT;
 74};
 75
 76struct DSGXSoftwareSpan {
 77	struct DSGXSoftwarePolygon* poly;
 78	int polyId;
 79	struct DSGXSoftwareEndpoint ep[2];
 80	struct DSGXSoftwareEndpoint step;
 81};
 82
 83DECLARE_VECTOR(DSGXSoftwarePolygonList, struct DSGXSoftwarePolygon);
 84DECLARE_VECTOR(DSGXSoftwareEdgeList, struct DSGXSoftwareEdge);
 85
 86struct DSGXSoftwareRenderer {
 87	struct DSGXRenderer d;
 88
 89	struct DSGXSoftwarePolygonList activePolys;
 90	struct DSGXSoftwareEdgeList activeEdges;
 91
 92	int32_t* depthBuffer;
 93	uint16_t* stencilBuffer;
 94	color_t* scanlineCache;
 95	int sort;
 96	uint16_t clearStencil;
 97	color_t clearColor;
 98	uint32_t clearDepth;
 99	bool flushPending;
100
101	struct DSGXVertex* verts;
102};
103
104void DSGXSoftwareRendererCreate(struct DSGXSoftwareRenderer* renderer);
105
106CXX_GUARD_END
107
108#endif