all repos — mgba @ 64b396aff9fd048bc5b3c9bc158d2c22b67faf13

mGBA Game Boy Advance Emulator

src/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 SIO_LOCKSTEP_H
 7#define SIO_LOCKSTEP_H
 8
 9#include "gba/sio.h"
10
11#include "util/threading.h"
12
13enum LockstepState {
14	LOCKSTEP_IDLE = 0,
15	LOCKSTEP_STARTED = 1,
16	LOCKSTEP_FINISHED = 2
17};
18
19struct GBASIOLockstep {
20	struct GBASIOLockstepNode* players[MAX_GBAS];
21	int attached;
22	int loaded;
23
24	uint16_t multiRecv[MAX_GBAS];
25	bool transferActive;
26	int32_t transferCycles;
27	int32_t nextEvent;
28
29	int waiting;
30	Mutex mutex;
31	Condition barrier;
32};
33
34struct GBASIOLockstepNode {
35	struct GBASIODriver d;
36	struct GBASIOLockstep* p;
37
38	int32_t nextEvent;
39	uint16_t multiSend;
40	enum LockstepState state;
41	int id;
42};
43
44void GBASIOLockstepInit(struct GBASIOLockstep*);
45void GBASIOLockstepDeinit(struct GBASIOLockstep*);
46
47void GBASIOLockstepNodeCreate(struct GBASIOLockstepNode*);
48
49bool GBASIOLockstepAttachNode(struct GBASIOLockstep*, struct GBASIOLockstepNode*);
50void GBASIOLockstepDetachNode(struct GBASIOLockstep*, struct GBASIOLockstepNode*);
51
52#endif