-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathEmulator.h
109 lines (89 loc) · 2.43 KB
/
Emulator.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef EMULATOR_H_
#define EMULATOR_H_
#include <ppltasks.h>
#include <collection.h>
#include "VirtualControllerInput.h"
#include "KeyboardInput.h"
#include "ControllerInput.h"
#include "GameTime.h"
#include <System.h>
#include "HIDControllerInput.h"
using namespace Platform::Collections;
using namespace concurrency;
using namespace Windows::Storage;
using namespace Windows::Storage::Streams;
using namespace Windows::Storage::FileProperties;
using namespace Windows::UI::Input;
using namespace Windows::System::Threading;
using namespace Windows::System;
extern CRITICAL_SECTION pauseSync;
namespace VBA10
{
struct ROMData
{
unsigned char *ROM;
size_t Length;
};
class EmulatorGame
{
public:
static EmulatedSystem emulator;
EmulatorGame(bool restore);
~EmulatorGame(void);
void Start(void);
void ReleaseAllResources(void);
static EmulatorGame *GetInstance();
VirtualControllerInput *GetVirtualController(void) const;
KeyboardInput *GetKeyboardInput(void) const;
#ifndef NO_XBOX
ControllerInput *GetControllerInput(void) const;
#endif
HIDControllerInput ^GetHidControllerInput(void) const;
int GetWidth(void);
int GetHeight(void);
void FocusChanged(bool focus);
void ResizeBuffer(float width, float height);
void Initialize();
task<void> StopROMAsync(void);
bool IsPaused(void);
void Pause(void);
void Unpause(void);
void Update(float timeDelta);
bool LastFrameSkipped(void);
void StartEmulatorThread();
void StopEmulatorThread();
void ResetXboxTimer();
float GetXboxTimer();
HIDControllerInput ^HidInput;
bool RestoreHidConfig();
void EnterButtonEditMode();
bool IsButtonEditMode();
void LeaveButtonEditMode(bool accept);
private:
static EmulatorGame *instance;
uint32_t frontbuffer, backbuffer;
bool stopThread;
Windows::Foundation::IAsyncAction ^threadAction;
HANDLE updateEvent;
HANDLE flipBufferEvent;
HANDLE sleepEvent;
uint32_t width, height;
BYTE *gfxbuffer;
bool focus;
bool graphicsResourcesReleased;
bool restoreState;
float xboxElapsed;
#ifndef NO_XBOX
ControllerInput *p1Controller;
#endif
KeyboardInput *keyboard;
VirtualControllerInput *virtualInput;
int updateCount;
bool frameSkipped;
void UpdateAsync(void);
void InitSound(void);
void DeInitSound(void);
void FlipBuffers(void *buffer, size_t rowPitch);
};
}
#endif