diff --git a/src/nostalgia/core/gba/media.cpp b/src/nostalgia/core/gba/media.cpp index 238c5cb46..6104ecd60 100644 --- a/src/nostalgia/core/gba/media.cpp +++ b/src/nostalgia/core/gba/media.cpp @@ -32,4 +32,7 @@ uint8_t *loadRom(const char*) { return nullptr; } +void unloadRom(uint8_t*) { +} + } diff --git a/src/nostalgia/core/media.hpp b/src/nostalgia/core/media.hpp index f2908bb59..d1502fbfb 100644 --- a/src/nostalgia/core/media.hpp +++ b/src/nostalgia/core/media.hpp @@ -14,4 +14,6 @@ namespace nostalgia::core { uint8_t *loadRom(const char *path = ""); +void unloadRom(uint8_t*); + } diff --git a/src/nostalgia/core/userland/media.cpp b/src/nostalgia/core/userland/media.cpp index 819602dba..f900d20f3 100644 --- a/src/nostalgia/core/userland/media.cpp +++ b/src/nostalgia/core/userland/media.cpp @@ -6,15 +6,29 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include -#include +#include #include "../media.hpp" namespace nostalgia::core { -uint8_t *loadRom(const char*) { - return nullptr; +uint8_t *loadRom(const char *path) { + auto file = fopen(path, "r"); + if (file) { + fseek(file, 0, SEEK_END); + const auto size = ftell(file); + rewind(file); + auto buff = new uint8_t[size]; + fread(buff, size, 1, file); + fclose(file); + return buff; + } else { + return nullptr; + } +} + +void unloadRom(uint8_t *rom) { + delete rom; } }