clang-format

This commit is contained in:
wheremyfoodat 2023-06-28 01:48:34 +03:00
parent 71582eff6d
commit 29806ff8e5
3 changed files with 257 additions and 266 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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) {