mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
clang-format
This commit is contained in:
parent
71582eff6d
commit
29806ff8e5
3 changed files with 257 additions and 266 deletions
|
@ -1,20 +1,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <filesystem>
|
|
||||||
#include <fstream>
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "PICA/gpu.hpp"
|
||||||
#include "cpu.hpp"
|
#include "cpu.hpp"
|
||||||
#include "crypto/aes_engine.hpp"
|
#include "crypto/aes_engine.hpp"
|
||||||
#include "io_file.hpp"
|
#include "io_file.hpp"
|
||||||
#include "memory.hpp"
|
#include "memory.hpp"
|
||||||
#include "opengl.hpp"
|
#include "opengl.hpp"
|
||||||
#include "PICA/gpu.hpp"
|
|
||||||
|
|
||||||
enum class ROMType {
|
enum class ROMType { None, ELF, NCSD };
|
||||||
None, ELF, NCSD
|
|
||||||
};
|
|
||||||
|
|
||||||
class Emulator {
|
class Emulator {
|
||||||
CPU cpu;
|
CPU cpu;
|
||||||
|
@ -44,7 +43,7 @@ class Emulator {
|
||||||
std::ifstream loadedELF;
|
std::ifstream loadedELF;
|
||||||
NCSD loadedNCSD;
|
NCSD loadedNCSD;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Emulator() : kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory), memory(cpu.getTicksRef()) {
|
Emulator() : kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory), memory(cpu.getTicksRef()) {
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
|
||||||
Helpers::panic("Failed to initialize SDL2");
|
Helpers::panic("Failed to initialize SDL2");
|
||||||
|
@ -72,7 +71,7 @@ public:
|
||||||
Helpers::panic("OpenGL context creation failed: %s", SDL_GetError());
|
Helpers::panic("OpenGL context creation failed: %s", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress))) {
|
if (!gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress))) {
|
||||||
Helpers::panic("OpenGL init failed: %s", SDL_GetError());
|
Helpers::panic("OpenGL init failed: %s", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,13 +87,8 @@ public:
|
||||||
void pressKey(u32 mask) { newButtons |= mask; }
|
void pressKey(u32 mask) { newButtons |= mask; }
|
||||||
void releaseKey(u32 mask) { newButtons &= ~mask; }
|
void releaseKey(u32 mask) { newButtons &= ~mask; }
|
||||||
|
|
||||||
s16 getCirclepadX() {
|
s16 getCirclepadX() { return circlePadX; }
|
||||||
return circlePadX;
|
s16 getCirclepadY() { return circlePadY; }
|
||||||
}
|
|
||||||
|
|
||||||
s16 getCirclepadY() {
|
|
||||||
return circlePadY;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setCirclepadX(s16 x) {
|
void setCirclepadX(s16 x) {
|
||||||
circlePadX = x;
|
circlePadX = x;
|
||||||
|
|
|
@ -16,10 +16,7 @@ void Emulator::reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emulator::step() {}
|
void Emulator::step() {}
|
||||||
|
void Emulator::render() {}
|
||||||
void Emulator::render() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Emulator::run() {
|
void Emulator::run() {
|
||||||
while (running) {
|
while (running) {
|
||||||
|
@ -42,6 +39,7 @@ void Emulator::run() {
|
||||||
printf("Bye :(\n");
|
printf("Bye :(\n");
|
||||||
running = false;
|
running = false;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
switch (event.key.keysym.sym) {
|
switch (event.key.keysym.sym) {
|
||||||
case SDLK_l: srv.pressKey(Keys::A); break;
|
case SDLK_l: srv.pressKey(Keys::A); break;
|
||||||
|
@ -81,6 +79,7 @@ void Emulator::run() {
|
||||||
case SDLK_BACKSPACE: srv.pressKey(Keys::Select); break;
|
case SDLK_BACKSPACE: srv.pressKey(Keys::Select); break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
switch (event.key.keysym.sym) {
|
switch (event.key.keysym.sym) {
|
||||||
case SDLK_l: srv.releaseKey(Keys::A); break;
|
case SDLK_l: srv.releaseKey(Keys::A); break;
|
||||||
|
@ -126,8 +125,7 @@ void Emulator::run() {
|
||||||
u16 y_converted = static_cast<u16>(y) - 240;
|
u16 y_converted = static_cast<u16>(y) - 240;
|
||||||
|
|
||||||
srv.setTouchScreenPress(x_converted, y_converted);
|
srv.setTouchScreenPress(x_converted, y_converted);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
srv.releaseTouchScreen();
|
srv.releaseTouchScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,9 +209,7 @@ void Emulator::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emulator::runFrame() {
|
void Emulator::runFrame() { cpu.runFrame(); }
|
||||||
cpu.runFrame();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Emulator::loadROM(const std::filesystem::path& path) {
|
bool Emulator::loadROM(const std::filesystem::path& path) {
|
||||||
// Get path for saving files (AppData on Windows, /home/user/.local/share/ApplcationName on Linux, etc)
|
// Get path for saving files (AppData on Windows, /home/user/.local/share/ApplcationName on Linux, etc)
|
||||||
|
@ -277,8 +273,9 @@ bool Emulator::loadELF(std::ifstream& file) {
|
||||||
loadedELF.seekg(0);
|
loadedELF.seekg(0);
|
||||||
|
|
||||||
std::optional<u32> entrypoint = memory.loadELF(loadedELF);
|
std::optional<u32> entrypoint = memory.loadELF(loadedELF);
|
||||||
if (!entrypoint.has_value())
|
if (!entrypoint.has_value()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
cpu.setReg(15, entrypoint.value()); // Set initial PC
|
cpu.setReg(15, entrypoint.value()); // Set initial PC
|
||||||
if (entrypoint.value() & 1) {
|
if (entrypoint.value() & 1) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue