include/mgba/internal/ds/gx.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_H
7#define DS_GX_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba/core/log.h>
14#include <mgba/core/timing.h>
15#include <mgba-util/circle-buffer.h>
16
17mLOG_DECLARE_CATEGORY(DS_GX);
18
19enum DSGXCommand {
20 DS_GX_CMD_NOP = 0,
21 DS_GX_CMD_MTX_MODE = 0x10,
22 DS_GX_CMD_MTX_PUSH = 0x11,
23 DS_GX_CMD_MTX_POP = 0x12,
24 DS_GX_CMD_MTX_STORE = 0x13,
25 DS_GX_CMD_MTX_RESTORE = 0x14,
26 DS_GX_CMD_MTX_IDENTITY = 0x15,
27 DS_GX_CMD_MTX_LOAD_4x4 = 0x16,
28 DS_GX_CMD_MTX_LOAD_4x3 = 0x17,
29 DS_GX_CMD_MTX_MULT_4x4 = 0x18,
30 DS_GX_CMD_MTX_MULT_4x3 = 0x19,
31 DS_GX_CMD_MTX_MULT_3x3 = 0x1A,
32 DS_GX_CMD_MTX_SCALE = 0x1B,
33 DS_GX_CMD_MTX_TRANS = 0x1C,
34 DS_GX_CMD_COLOR = 0x20,
35 DS_GX_CMD_NORMAL = 0x21,
36 DS_GX_CMD_TEXCOORD = 0x22,
37 DS_GX_CMD_VTX_16 = 0x23,
38 DS_GX_CMD_VTX_10 = 0x24,
39 DS_GX_CMD_VTX_XY = 0x25,
40 DS_GX_CMD_VTX_XZ = 0x26,
41 DS_GX_CMD_VTX_YZ = 0x27,
42 DS_GX_CMD_VTX_DIFF = 0x28,
43 DS_GX_CMD_POLYGON_ATTR = 0x29,
44 DS_GX_CMD_TEXIMAGE_PARAM = 0x2A,
45 DS_GX_CMD_PLTT_BASE = 0x2B,
46 DS_GX_CMD_DIF_AMB = 0x30,
47 DS_GX_CMD_SPE_EMI = 0x31,
48 DS_GX_CMD_LIGHT_VECTOR = 0x32,
49 DS_GX_CMD_LIGHT_COLOR = 0x33,
50 DS_GX_CMD_SHININESS = 0x34,
51 DS_GX_CMD_BEGIN_VTXS = 0x40,
52 DS_GX_CMD_END_VTXS = 0x41,
53 DS_GX_CMD_SWAP_BUFFERS = 0x50,
54 DS_GX_CMD_VIEWPORT = 0x60,
55 DS_GX_CMD_BOX_TEST = 0x70,
56 DS_GX_CMD_POS_TEST = 0x71,
57 DS_GX_CMD_VEC_TEST = 0x72,
58
59 DS_GX_CMD_MAX
60};
61
62#pragma pack(push, 1)
63struct DSGXEntry {
64 uint8_t command;
65 uint8_t params[4];
66};
67#pragma pack(pop)
68
69struct DS;
70struct DSGX {
71 struct DS* p;
72 struct DSGXEntry pipe[4];
73 struct CircleBuffer fifo;
74
75 struct mTimingEvent fifoEvent;
76};
77
78void DSGXInit(struct DSGX*);
79void DSGXDeinit(struct DSGX*);
80void DSGXReset(struct DSGX*);
81
82uint16_t DSGXWriteRegister(struct DSGX*, uint32_t address, uint16_t value);
83uint32_t DSGXWriteRegister32(struct DSGX*, uint32_t address, uint32_t value);
84
85CXX_GUARD_END
86
87#endif