-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.h
66 lines (58 loc) · 1.67 KB
/
state.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef STATE_INCLUDED
#define STATE_INCLUDED
#include "core.h"
#include "config.h"
#include "sgbDefs.h"
#include "controller.h"
#include "tpakio.h"
#include "types.h"
typedef struct {
uLong FrameCount;
} MetaState;
typedef struct {
Mode ActiveMode;
Border SelectedBorder;
GbButton ButtonMap[N64_BUTTON_COUNT];
N64Button SystemMenuButton;
N64Button GbStartButton;
N64Button GbSelectButton;
bool AudioEnabled;
GbState EmulationState;
SuperGameboyState SGBState;
sByte InitState;
sByte OptionsCursorRow;
sByte MenuCursorRow;
sByte MenuCursorColumn;
byte MenuLayout[2];
bool WasFrameSkipped;
MetaState Meta;
string ErrorMessage;
} PlayerState;
typedef struct {
sByte ErrorCode;
byte pad0:2;
bool RequiresRepaint:1;
bool RequiresControllerRead:1;
byte PlayerCount:4;
natural ControllersPresent;
N64ControllerState KeysPressed;
N64ControllerState KeysReleased;
float PixelSize;
display_context_t Frame;
PlayerState Players[MAX_PLAYERS]; // Really not aiming for anything other than 2, but you never know.
} RootState;
// Global program state.
extern RootState rootState;
/**
* Sets a Gameboy button to a particular N64 button, unsetting it from the previous mapping.
* @param playerState state containing controller mapping to update.
* @param gbButton gameboy button to set.
* @param n64Button n64 button to set gb button to.
*/
void setButtonToMap(PlayerState* playerState, const GbButton gbButton, const N64Button n64Button);
/**
* Initialise the state struct for a new player.
* @param playerState struct to initialise.
*/
void generatePlayerState(PlayerState* playerState);
#endif