40 lines
977 B
C++
40 lines
977 B
C++
/*
|
|
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
*/
|
|
|
|
#include <fstream>
|
|
|
|
#include <ox/std/trace.hpp>
|
|
|
|
#include "../media.hpp"
|
|
|
|
namespace nostalgia::core {
|
|
|
|
ox::Result<char*> loadRom(ox::CRStringView path) noexcept {
|
|
std::ifstream file(std::string(toStdStringView(path)), std::ios::binary | std::ios::ate);
|
|
if (!file.good()) {
|
|
oxErrorf("Could not find ROM file: {}", path);
|
|
return OxError(1, "Could not find ROM file");
|
|
}
|
|
try {
|
|
const auto size = file.tellg();
|
|
file.seekg(0, std::ios::beg);
|
|
auto buff = new char[static_cast<std::size_t>(size)];
|
|
file.read(buff, size);
|
|
return buff;
|
|
} catch (const std::ios_base::failure &e) {
|
|
oxErrorf("Could not read ROM file: {}", e.what());
|
|
return OxError(2, "Could not read ROM file");
|
|
}
|
|
}
|
|
|
|
void unloadRom(char *rom) noexcept {
|
|
ox::safeDelete(rom);
|
|
}
|
|
|
|
ox::Result<void*> findPreloadSection() noexcept {
|
|
return OxError(1, "findPreloadSection is unsupported on this platform");
|
|
}
|
|
|
|
}
|