all repos — mgba @ c662b59e9942bfffd69ed6754cc334de86f89e63

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