bsnes/higan/target-tomoko/program/program.cpp

104 lines
2.8 KiB
C++
Raw Normal View History

#include "../tomoko.hpp"
#include <fc/interface/interface.hpp>
#include <sfc/interface/interface.hpp>
#include <gb/interface/interface.hpp>
#include <gba/interface/interface.hpp>
#include "interface.cpp"
#include "media.cpp"
#include "state.cpp"
#include "utility.cpp"
Program* program = nullptr;
Program::Program(lstring args) {
program = this;
directory::create({configpath(), "tomoko/"});
Application::onMain({&Program::main, this});
Application::Windows::onModalChange([](bool modal) { if(modal && audio) audio->clear(); });
emulators.append(new Famicom::Interface);
emulators.append(new SuperFamicom::Interface);
emulators.append(new GameBoy::Interface);
emulators.append(new GameBoyAdvance::Interface);
for(auto& emulator : emulators) emulator->bind = this;
new InputManager;
new SettingsManager;
new CheatDatabase;
new ToolsManager;
new Presentation;
presentation->setVisible();
video = Video::create(settings["Video/Driver"].text());
video->set(Video::Handle, presentation->viewport.handle());
video->set(Video::Synchronize, settings["Video/Synchronize"].boolean());
if(!video->init()) {
delete video;
video = Video::create("None");
}
audio = Audio::create(settings["Audio/Driver"].text());
audio->set(Audio::Device, settings["Audio/Device"].text());
audio->set(Audio::Handle, presentation->viewport.handle());
audio->set(Audio::Synchronize, settings["Audio/Synchronize"].boolean());
audio->set(Audio::Frequency, 96000u);
audio->set(Audio::Latency, 80u);
if(!audio->init()) {
delete audio;
audio = Audio::create("None");
}
input = Input::create(settings["Input/Driver"].text());
input->set(Input::Handle, presentation->viewport.handle());
input->onChange({&InputManager::onChange, inputManager});
if(!input->init()) {
delete input;
input = Input::create("None");
}
dsp.setPrecision(16);
dsp.setBalance(0.0);
dsp.setFrequency(32040);
dsp.setResampler(DSP::ResampleEngine::Sinc);
dsp.setResamplerFrequency(96000);
Update to v094r12 release. byuu says: Changelog: * added driver selection * added video scale + aspect correction settings * added A/V sync + audio mute settings * added configuration file * fixed compilation bugs under Windows and Linux * fixed window sizing * removed HSU1 * the system menu stays as "System", because "Game Boy Advance" was too long a string for the smallest scale size * some more stuff You guys probably won't be ecstatic about the video sizing options, but it's basically your choice of 1x, 2x or 4x scale with optional aspect correction. 3x was intentionally skipped because it looks horrible on hires SNES games. The window is resized and recentered upon loading games. The window doesn't resize otherwise. I never really liked the way v094 always left you with black screen areas and left you with off-centered window positions. I might go ahead and add the pseudo-fullscreen toggle that will jump into 4x mode (respecting your aspect setting.) Short-term: * add input port changing support * add other input types (mouse-based, etc) * add save states * add cheat codes * add timing configuration (video/audio sync) * add hotkeys (single state) We can probably do a new release once the short-term items are completed. Long-term: * add slotted cart loader (SGB, BSX, ST) * add DIP switch selection window (NSS) * add cheat code database * add state manager * add overscan masking Not planned: * video color adjustments (will allow emulated color vs raw color; but no more sliders) * pixel shaders * ananke integration (will need to make a command-line version to get my games in) * fancy audio adjustment controls (resampler, latency, volume) * input focus settings * relocating game library (not hard, just don't feel like it) * localization support (not enough users) * window geometry memory * anything else not in higan v094
2015-03-03 10:14:49 +00:00
presentation->drawSplashScreen();
updateVideoFilter();
updateAudioVolume();
Update to v094r43 release. byuu says: Updated to compile with all of the new hiro changes. My next step is to write up hiro API documentation, and move the API from alpha (constantly changing) to beta (rarely changing), in preparation for the first stable release (backward-compatible changes only.) Added "--fullscreen" command-line option. I like this over a configuration file option. Lets you use the emulator in both modes without having to modify the config file each time. Also enhanced the command-line game loading. You can now use any of these methods: higan /path/to/game-folder.sfc higan /path/to/game-folder.sfc/ higan /path/to/game-folder.sfc/program.rom The idea is to support launchers that insist on loading files only. Technically, the file can be any name (manifest.bml also works); the only criteria is that the file actually exists and is a file, and not a directory. This is a requirement to support the first version (a directory lacking the trailing / identifier), because I don't want my nall::string class to query the file system to determine if the string is an actual existing file or directory for its pathname() / dirname() functions. Anyway, every game folder I've made so far has program.rom, and that's very unlikely to change, so this should be fine. Now, of course, if you drop a regular "game.sfc" file on the emulator, it won't even try to load it, unless it's in a folder that ends in .fc, .sfc, etc. In which case, it'll bail out immediately by being unable to produce a manifest for what is obviously not really a game folder.
2015-08-30 02:08:26 +00:00
args.takeFirst(); //ignore program location in argument parsing
for(auto& argument : args) {
if(argument == "--fullscreen") {
presentation->toggleFullScreen();
} else {
auto location = argument;
if(file::exists(location)) location = dirname(location);
if(directory::exists(location)) loadMedia(location);
}
}
}
auto Program::main() -> void {
updateStatusText();
inputManager->poll();
if(!emulator || !emulator->loaded() || pause) {
audio->clear();
usleep(20 * 1000);
return;
}
emulator->run();
}
auto Program::quit() -> void {
unloadMedia();
settings.quit();
inputManager->quit();
delete video;
delete audio;
delete input;
Update to v094r12 release. byuu says: Changelog: * added driver selection * added video scale + aspect correction settings * added A/V sync + audio mute settings * added configuration file * fixed compilation bugs under Windows and Linux * fixed window sizing * removed HSU1 * the system menu stays as "System", because "Game Boy Advance" was too long a string for the smallest scale size * some more stuff You guys probably won't be ecstatic about the video sizing options, but it's basically your choice of 1x, 2x or 4x scale with optional aspect correction. 3x was intentionally skipped because it looks horrible on hires SNES games. The window is resized and recentered upon loading games. The window doesn't resize otherwise. I never really liked the way v094 always left you with black screen areas and left you with off-centered window positions. I might go ahead and add the pseudo-fullscreen toggle that will jump into 4x mode (respecting your aspect setting.) Short-term: * add input port changing support * add other input types (mouse-based, etc) * add save states * add cheat codes * add timing configuration (video/audio sync) * add hotkeys (single state) We can probably do a new release once the short-term items are completed. Long-term: * add slotted cart loader (SGB, BSX, ST) * add DIP switch selection window (NSS) * add cheat code database * add state manager * add overscan masking Not planned: * video color adjustments (will allow emulated color vs raw color; but no more sliders) * pixel shaders * ananke integration (will need to make a command-line version to get my games in) * fancy audio adjustment controls (resampler, latency, volume) * input focus settings * relocating game library (not hard, just don't feel like it) * localization support (not enough users) * window geometry memory * anything else not in higan v094
2015-03-03 10:14:49 +00:00
Application::quit();
}