diff --git a/src/nostalgia/player/CMakeLists.txt b/src/nostalgia/player/CMakeLists.txt index 9676bb7d..86d49872 100644 --- a/src/nostalgia/player/CMakeLists.txt +++ b/src/nostalgia/player/CMakeLists.txt @@ -23,7 +23,6 @@ endif() target_link_libraries( nostalgia NostalgiaWorld - NostalgiaCore ${NOSTALGIA_PLAYER_DEPS} ) diff --git a/src/nostalgia/player/main.cpp b/src/nostalgia/player/main.cpp index 0fa6a75c..94472f56 100644 --- a/src/nostalgia/player/main.cpp +++ b/src/nostalgia/player/main.cpp @@ -42,10 +42,40 @@ int main() { #else +#include +#include + +std::vector loadFileBuff(const char *path) { + auto file = fopen(path, "r"); + if (file) { + fseek(file, 0, SEEK_END); + const auto size = ftell(file); + rewind(file); + std::vector buff(size); + fread(buff.data(), size, 1, file); + fclose(file); + return buff; + } else { + return {}; + } +} + int main(int argc, const char **argv) { if (argc > 1) { - ox::PassThroughFS fs(argv[1]); - auto err = run(&fs); + std::unique_ptr fs; + std::vector rom; + std::string path = argv[1]; + const std::string fsExt = path.substr(path.find_last_of('.')); + if (fsExt == ".oxfs") { + rom = loadFileBuff(path.c_str()); + if (!rom.size()) { + return 1; + } + fs = std::make_unique(ox::FileStore32(rom.data(), 32 * ox::units::MB)); + } else { + fs = std::make_unique(path.c_str()); + } + auto err = run(fs.get()); oxAssert(err, "Something went wrong..."); return err; }