all repos — mgba @ daaa2fa5236df5e8976e7e0ba7ac39e0d9233422

mGBA Game Boy Advance Emulator

src/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 "util/common.h"
10
11#include "core/lockstep.h"
12#include "core/timing.h"
13#include "gb/sio.h"
14
15struct GBSIOLockstep {
16	struct mLockstep d;
17	struct GBSIOLockstepNode* players[MAX_GBS];
18
19	uint8_t pendingSB[MAX_GBS];
20	bool masterClaimed;
21};
22
23struct GBSIOLockstepNode {
24	struct GBSIODriver d;
25	struct GBSIOLockstep* p;
26	struct mTimingEvent event;
27
28	volatile int32_t nextEvent;
29	int32_t eventDiff;
30	int id;
31	bool transferFinished;
32#ifndef NDEBUG
33	int transferId;
34	enum mLockstepPhase phase;
35#endif
36};
37
38void GBSIOLockstepInit(struct GBSIOLockstep*);
39
40void GBSIOLockstepNodeCreate(struct GBSIOLockstepNode*);
41
42bool GBSIOLockstepAttachNode(struct GBSIOLockstep*, struct GBSIOLockstepNode*);
43void GBSIOLockstepDetachNode(struct GBSIOLockstep*, struct GBSIOLockstepNode*);
44
45#endif