2020-12-12 12:22:17 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "frontends/common2/speed.h"
|
2020-12-23 19:36:11 +00:00
|
|
|
#include "frontends/libretro/environment.h"
|
2021-11-27 11:39:55 +00:00
|
|
|
#include "frontends/libretro/diskcontrol.h"
|
2020-12-12 12:22:17 +00:00
|
|
|
|
2021-05-23 20:06:36 +01:00
|
|
|
#include "linux/context.h"
|
|
|
|
|
2020-12-26 20:38:07 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-02-25 16:24:52 +00:00
|
|
|
namespace ra2
|
2020-12-12 12:22:17 +00:00
|
|
|
{
|
|
|
|
|
2021-02-25 16:24:52 +00:00
|
|
|
class RetroFrame;
|
|
|
|
|
|
|
|
class Game
|
|
|
|
{
|
|
|
|
public:
|
2021-05-23 20:06:36 +01:00
|
|
|
Game();
|
2021-11-22 18:53:39 +00:00
|
|
|
~Game();
|
2021-02-25 16:24:52 +00:00
|
|
|
|
|
|
|
bool loadSnapshot(const std::string & path);
|
2020-12-12 12:22:17 +00:00
|
|
|
|
2021-02-25 16:24:52 +00:00
|
|
|
void executeOneFrame();
|
|
|
|
void processInputEvents();
|
2020-12-12 12:22:17 +00:00
|
|
|
|
2021-02-25 16:24:52 +00:00
|
|
|
void drawVideoBuffer();
|
2020-12-12 12:22:17 +00:00
|
|
|
|
2021-11-24 18:02:27 +00:00
|
|
|
double getMousePosition(int i) const;
|
|
|
|
|
2021-11-27 11:39:55 +00:00
|
|
|
DiskControl & getDiskControl();
|
|
|
|
|
2021-02-25 16:24:52 +00:00
|
|
|
static void keyboardCallback(bool down, unsigned keycode, uint32_t character, uint16_t key_modifiers);
|
2020-12-12 12:22:17 +00:00
|
|
|
|
2021-02-25 16:24:52 +00:00
|
|
|
static void frameTimeCallback(retro_usec_t usec);
|
|
|
|
static constexpr size_t FPS = 60;
|
|
|
|
static unsigned ourInputDevices[MAX_PADS];
|
|
|
|
static retro_usec_t ourFrameTime;
|
2020-12-23 18:55:26 +00:00
|
|
|
|
2021-02-25 16:24:52 +00:00
|
|
|
private:
|
2021-11-19 11:26:00 +00:00
|
|
|
// keep them in this order!
|
|
|
|
std::shared_ptr<LoggerContext> myLoggerContext;
|
|
|
|
std::shared_ptr<RegistryContext> myRegistryContext;
|
|
|
|
std::shared_ptr<RetroFrame> myFrame;
|
2021-01-13 17:48:25 +00:00
|
|
|
|
2021-02-25 16:24:52 +00:00
|
|
|
common2::Speed mySpeed; // fixed speed
|
2020-12-12 19:25:43 +00:00
|
|
|
|
2021-02-25 16:24:52 +00:00
|
|
|
std::vector<int> myButtonStates;
|
2020-12-23 18:55:26 +00:00
|
|
|
|
2021-11-24 18:02:27 +00:00
|
|
|
struct MousePosition_t
|
|
|
|
{
|
|
|
|
double position; // -1 to 1
|
|
|
|
double multiplier;
|
|
|
|
unsigned id;
|
|
|
|
};
|
|
|
|
|
|
|
|
MousePosition_t myMouse[2];
|
|
|
|
|
2021-11-27 11:39:55 +00:00
|
|
|
DiskControl myDiskControl;
|
|
|
|
|
2021-02-25 16:24:52 +00:00
|
|
|
bool checkButtonPressed(unsigned id);
|
|
|
|
void keyboardEmulation();
|
2021-11-24 18:02:27 +00:00
|
|
|
void mouseEmulation();
|
2020-12-12 19:27:28 +00:00
|
|
|
|
2021-02-25 16:24:52 +00:00
|
|
|
static void processKeyDown(unsigned keycode, uint32_t character, uint16_t key_modifiers);
|
|
|
|
static void processKeyUp(unsigned keycode, uint32_t character, uint16_t key_modifiers);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|