mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
Format the hydra
This commit is contained in:
parent
d19a00d97d
commit
977ab53b68
2 changed files with 84 additions and 112 deletions
|
@ -60,6 +60,7 @@ class Emulator {
|
|||
|
||||
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
||||
HttpServer httpServer;
|
||||
friend struct HttpServer;
|
||||
#endif
|
||||
|
||||
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include <hydra/core.hxx>
|
||||
#include <emulator.hpp>
|
||||
#include <hydra/core.hxx>
|
||||
#include <renderer_gl/renderer_gl.hpp>
|
||||
|
||||
class HC_GLOBAL HydraCore final : public hydra::IBase, public hydra::IOpenGlRendered, public hydra::IFrontendDriven, public hydra::IInput
|
||||
{
|
||||
class HC_GLOBAL HydraCore final : public hydra::IBase, public hydra::IOpenGlRendered, public hydra::IFrontendDriven, public hydra::IInput {
|
||||
HYDRA_CLASS
|
||||
public:
|
||||
public:
|
||||
HydraCore();
|
||||
private:
|
||||
|
||||
private:
|
||||
// IBase
|
||||
bool loadFile(const char* type, const char* path) override;
|
||||
void reset() override;
|
||||
|
@ -23,8 +23,8 @@ private:
|
|||
void runFrame() override;
|
||||
|
||||
// IInput
|
||||
void setPollInputCallback(void(*callback)()) override;
|
||||
void setCheckButtonCallback(int32_t(*callback)(uint32_t player, hydra::ButtonType button)) override;
|
||||
void setPollInputCallback(void (*callback)()) override;
|
||||
void setCheckButtonCallback(int32_t (*callback)(uint32_t player, hydra::ButtonType button)) override;
|
||||
|
||||
std::unique_ptr<Emulator> emulator;
|
||||
RendererGL* renderer;
|
||||
|
@ -32,27 +32,22 @@ private:
|
|||
int32_t (*checkButtonCallback)(uint32_t player, hydra::ButtonType button) = nullptr;
|
||||
};
|
||||
|
||||
HydraCore::HydraCore() : emulator(new Emulator)
|
||||
{
|
||||
if (emulator->getRendererType() != RendererType::OpenGL)
|
||||
{
|
||||
HydraCore::HydraCore() : emulator(new Emulator) {
|
||||
if (emulator->getRendererType() != RendererType::OpenGL) {
|
||||
throw std::runtime_error("HydraCore: Renderer is not OpenGL");
|
||||
}
|
||||
renderer = static_cast<RendererGL*>(emulator->getRenderer());
|
||||
}
|
||||
|
||||
bool HydraCore::loadFile(const char* type, const char* path)
|
||||
{
|
||||
if (std::string(type) == "rom")
|
||||
{
|
||||
bool HydraCore::loadFile(const char* type, const char* path) {
|
||||
if (std::string(type) == "rom") {
|
||||
return emulator->loadROM(path);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void HydraCore::runFrame()
|
||||
{
|
||||
void HydraCore::runFrame() {
|
||||
renderer->resetStateManager();
|
||||
|
||||
pollInputCallback();
|
||||
|
@ -78,65 +73,41 @@ void HydraCore::runFrame()
|
|||
emulator->runFrame();
|
||||
}
|
||||
|
||||
void HydraCore::reset()
|
||||
{
|
||||
emulator->reset(Emulator::ReloadOption::Reload);
|
||||
}
|
||||
void HydraCore::reset() { emulator->reset(Emulator::ReloadOption::Reload); }
|
||||
|
||||
hydra::Size HydraCore::getNativeSize()
|
||||
{
|
||||
return { 400, 480 };
|
||||
}
|
||||
hydra::Size HydraCore::getNativeSize() { return {400, 480}; }
|
||||
|
||||
// Size doesn't matter as the glBlitFramebuffer call is commented out for the core
|
||||
void HydraCore::setOutputSize(hydra::Size size) {}
|
||||
|
||||
void HydraCore::setGetProcAddress(void* function)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
void HydraCore::setGetProcAddress(void* function) {
|
||||
#ifdef __ANDROID__
|
||||
if (!gladLoadGLES2Loader(reinterpret_cast<GLADloadproc>(function))) {
|
||||
Helpers::panic("OpenGL ES init failed");
|
||||
}
|
||||
#else
|
||||
#else
|
||||
if (!gladLoadGLLoader(reinterpret_cast<GLADloadproc>(function))) {
|
||||
Helpers::panic("OpenGL init failed");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
// SDL_Window is not used, so we pass nullptr
|
||||
emulator->initGraphicsContext(nullptr);
|
||||
}
|
||||
|
||||
void HydraCore::setContext(void*) {}
|
||||
|
||||
void HydraCore::setFbo(unsigned handle)
|
||||
{
|
||||
renderer->setFBO(handle);
|
||||
}
|
||||
void HydraCore::setFbo(unsigned handle) { renderer->setFBO(handle); }
|
||||
|
||||
void HydraCore::setPollInputCallback(void(*callback)())
|
||||
{
|
||||
pollInputCallback = callback;
|
||||
}
|
||||
void HydraCore::setPollInputCallback(void (*callback)()) { pollInputCallback = callback; }
|
||||
|
||||
void HydraCore::setCheckButtonCallback(int32_t(*callback)(uint32_t player, hydra::ButtonType button))
|
||||
{
|
||||
checkButtonCallback = callback;
|
||||
}
|
||||
void HydraCore::setCheckButtonCallback(int32_t (*callback)(uint32_t player, hydra::ButtonType button)) { checkButtonCallback = callback; }
|
||||
|
||||
HC_API hydra::IBase* createEmulator()
|
||||
{
|
||||
return new HydraCore;
|
||||
}
|
||||
HC_API hydra::IBase* createEmulator() { return new HydraCore; }
|
||||
|
||||
HC_API void destroyEmulator(hydra::IBase* emulator)
|
||||
{
|
||||
delete emulator;
|
||||
}
|
||||
HC_API void destroyEmulator(hydra::IBase* emulator) { delete emulator; }
|
||||
|
||||
HC_API const char* getInfo(hydra::InfoType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
HC_API const char* getInfo(hydra::InfoType type) {
|
||||
switch (type) {
|
||||
case hydra::InfoType::CoreName: return "Panda3DS";
|
||||
case hydra::InfoType::SystemName: return "Nintendo 3DS";
|
||||
case hydra::InfoType::Description: return "HLE 3DS emulator. There's a little Alber in your computer and he runs Nintendo 3DS games.";
|
||||
|
|
Loading…
Add table
Reference in a new issue