all repos — mgba @ cee6569bde476ea94e05237baf62d3d4ce1d2cf9

mGBA Game Boy Advance Emulator

include/mgba/internal/gb/sio/lockstep.h (view raw)

 1/* Copyright (c) 2013-2016 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 GB_SIO_LOCKSTEP_H
 7#define GB_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/gb/sio.h>
16
17struct GBSIOLockstep {
18	struct mLockstep d;
19	struct GBSIOLockstepNode* players[MAX_GBS];
20
21	uint8_t pendingSB[MAX_GBS];
22	bool masterClaimed;
23};
24
25struct GBSIOLockstepNode {
26	struct GBSIODriver d;
27	struct GBSIOLockstep* p;
28	struct mTimingEvent event;
29
30	volatile int32_t nextEvent;
31	int32_t eventDiff;
32	int id;
33	bool transferFinished;
34#ifndef NDEBUG
35	int transferId;
36	enum mLockstepPhase phase;
37#endif
38};
39
40void GBSIOLockstepInit(struct GBSIOLockstep*);
41
42void GBSIOLockstepNodeCreate(struct GBSIOLockstepNode*);
43
44bool GBSIOLockstepAttachNode(struct GBSIOLockstep*, struct GBSIOLockstepNode*);
45void GBSIOLockstepDetachNode(struct GBSIOLockstep*, struct GBSIOLockstepNode*);
46
47CXX_GUARD_END
48
49#endif