mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 20:37:18 +12:00
Bonk headers
This commit is contained in:
parent
f65d9480a5
commit
d028c1cb64
5 changed files with 56 additions and 70 deletions
|
@ -44,48 +44,7 @@ class Emulator {
|
|||
NCSD loadedNCSD;
|
||||
|
||||
public:
|
||||
Emulator() : kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory), memory(cpu.getTicksRef()) {
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
|
||||
Helpers::panic("Failed to initialize SDL2");
|
||||
}
|
||||
|
||||
// Make SDL use consistent positional button mapping
|
||||
SDL_SetHint(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "0");
|
||||
if (SDL_Init(SDL_INIT_GAMECONTROLLER) < 0) {
|
||||
Helpers::warn("Failed to initialize SDL2 GameController: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
// Request OpenGL 4.1 Core (Max available on MacOS)
|
||||
// MacOS gets mad if we don't explicitly demand a core profile
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||
window = SDL_CreateWindow("Alber", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL);
|
||||
|
||||
if (window == nullptr) {
|
||||
Helpers::panic("Window creation failed: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
glContext = SDL_GL_CreateContext(window);
|
||||
if (glContext == nullptr) {
|
||||
Helpers::panic("OpenGL context creation failed: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
if (!gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress))) {
|
||||
Helpers::panic("OpenGL init failed: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER)) {
|
||||
gameController = SDL_GameControllerOpen(0);
|
||||
|
||||
if (gameController != nullptr) {
|
||||
SDL_Joystick* stick = SDL_GameControllerGetJoystick(gameController);
|
||||
gameControllerID = SDL_JoystickInstanceID(stick);
|
||||
}
|
||||
}
|
||||
|
||||
reset();
|
||||
}
|
||||
Emulator();
|
||||
|
||||
void step();
|
||||
void render();
|
||||
|
|
|
@ -8,38 +8,29 @@ class IOFile {
|
|||
static inline std::filesystem::path appData = ""; // Directory for holding app data. AppData on Windows
|
||||
|
||||
public:
|
||||
IOFile();
|
||||
IOFile(FILE* handle);
|
||||
IOFile() {}
|
||||
IOFile(FILE* handle) : handle(handle) {}
|
||||
IOFile(const std::filesystem::path& path, const char* permissions = "rb");
|
||||
|
||||
bool isOpen();
|
||||
|
||||
bool isOpen() { return handle != nullptr; }
|
||||
bool open(const std::filesystem::path& path, const char* permissions = "rb");
|
||||
|
||||
bool open(const char* filename, const char* permissions = "rb");
|
||||
|
||||
void close();
|
||||
|
||||
std::pair<bool, std::size_t> read(void* data, std::size_t length, std::size_t dataSize);
|
||||
|
||||
std::pair<bool, std::size_t> readBytes(void* data, std::size_t count);
|
||||
|
||||
std::pair<bool, std::size_t> write(const void* data, std::size_t length, std::size_t dataSize);
|
||||
|
||||
std::pair<bool, std::size_t> writeBytes(const void* data, std::size_t count);
|
||||
|
||||
std::optional<std::uint64_t> size();
|
||||
|
||||
bool seek(std::int64_t offset, int origin = SEEK_SET);
|
||||
|
||||
bool rewind();
|
||||
|
||||
FILE* getHandle();
|
||||
|
||||
static void setAppDataDir(const std::filesystem::path& dir);
|
||||
static std::filesystem::path getAppData() { return appData; }
|
||||
|
||||
// Sets the size of the file to "size" and returns whether it succeeded or not
|
||||
bool setSize(std::uint64_t size);
|
||||
|
||||
static std::filesystem::path getAppData();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue