include/mgba/internal/gba/sio/lockstep.h (view raw)
1/* Copyright (c) 2013-2015 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 GBA_SIO_LOCKSTEP_H
7#define GBA_SIO_LOCKSTEP_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba/core/lockstep.h>
14#include <mgba/core/timing.h>
15#include <mgba/internal/gba/sio.h>
16
17struct GBASIOLockstep {
18 struct mLockstep d;
19 struct GBASIOLockstepNode* players[MAX_GBAS];
20 int attachedMulti;
21 int attachedNormal;
22
23 uint16_t multiRecv[MAX_GBAS];
24 uint32_t normalRecv[MAX_GBAS];
25};
26
27struct GBASIOLockstepNode {
28 struct GBASIODriver d;
29 struct GBASIOLockstep* p;
30 struct mTimingEvent event;
31
32 volatile int32_t nextEvent;
33 int32_t eventDiff;
34 bool normalSO;
35 int id;
36 enum GBASIOMode mode;
37 bool transferFinished;
38#ifndef NDEBUG
39 int transferId;
40 enum mLockstepPhase phase;
41#endif
42};
43
44void GBASIOLockstepInit(struct GBASIOLockstep*);
45
46void GBASIOLockstepNodeCreate(struct GBASIOLockstepNode*);
47
48bool GBASIOLockstepAttachNode(struct GBASIOLockstep*, struct GBASIOLockstepNode*);
49void GBASIOLockstepDetachNode(struct GBASIOLockstep*, struct GBASIOLockstepNode*);
50
51CXX_GUARD_END
52
53#endif