bsnes/target-tomoko/program/media.cpp

40 lines
1.2 KiB
C++

auto Program::loadMedia(string location) -> void {
location.transform("\\", "/");
if(!directory::exists(location)) return;
string type = suffixname(location).ltrim(".");
for(auto& emulator : emulators) {
for(auto& media : emulator->media) {
if(media.bootable == false) continue;
if(media.type != type) continue;
return loadMedia(*emulator, media, location);
}
}
}
auto Program::loadMedia(Emulator::Interface& _emulator, Emulator::Interface::Media& media, const string& location) -> void {
unloadMedia();
mediaPaths(0) = {userpath(), "Emulation/System/", media.name, ".sys/"};
mediaPaths(media.id) = location;
setEmulator(&_emulator);
emulator().paletteUpdate(Emulator::Interface::PaletteMode::Standard);
emulator().load(media.id);
emulator().power();
presentation->setTitle(emulator().title());
presentation->systemMenu.setText(emulator().information.name).setVisible(true);
}
auto Program::unloadMedia() -> void {
if(activeEmulator == nullptr) return;
emulator().unload();
setEmulator(nullptr);
presentation->setTitle({"tomoko v", Emulator::Version});
presentation->systemMenu.setVisible(false);
drawSplashScreen();
}