ares-openbsd/desktop-ui/desktop-ui.cpp

190 行
5.5 KiB
C++
Raw 通常表示 履歴

#include "desktop-ui.hpp"
2020-01-31 08:14:21 +09:00
namespace ruby {
Video video;
Audio audio;
Input input;
}
2020-02-01 09:28:14 +09:00
auto locate(const string& name) -> string {
// First check each path for the presence of the file we are looking for in the following order
// allowing users to override the default resources if they wish to do so.
// 1. The application directory
2020-02-01 09:28:14 +09:00
string location = {Path::program(), name};
if(inode::exists(location)) return location;
// 2. The user data directory
location = {Path::userData(), "ares/", name};
if(inode::exists(location)) return location;
// 3. The shared data directory
location = {Path::sharedData(), "ares/", name};
if(inode::exists(location)) return location;
// 4. The application bundle resource directory (macOS only)
#if defined(PLATFORM_MACOS)
location = {Path::resources(), name};
if(inode::exists(location)) return location;
#endif
// If the file was not found in any of the above locations, we may be intending to create it
// We must return a path to a user writable directory; on Windows, this is the executable directory
#if defined(PLATFORM_WINDOWS)
return {Path::program(), name};
#endif
// On other platforms, this is the "user data" directory
directory::create({Path::userData(), "ares/"});
return {Path::userData(), "ares/", name};
2020-02-01 09:28:14 +09:00
}
2020-01-31 08:14:21 +09:00
#include <nall/main.hpp>
auto nall::main(Arguments arguments) -> void {
//force early allocation for better proximity to executable code
ares::Memory::FixedAllocator::get();
#if defined(PLATFORM_WINDOWS)
bool createTerminal = arguments.take("--terminal");
terminal::redirectStdioToTerminal(createTerminal);
#endif
Application::setName("ares");
2020-01-31 08:14:21 +09:00
Application::setScreenSaver(false);
Update to ares v119 release. I'm releasing ares v119 today, which includes very preliminary Sega 32X emulation support. Compatibility is currently at around 50% with the dynamic recompiler, probably closer to 75% with the cached interpreter, and since the system requirements were a bit too steep (on account of my Mega Drive core being cycle/dot-accurate), I downclocked the SH2s a bit until I can speed up the emulator more. You'll currently need about a Ryzen 5 2600 to hit 60fps reliably. With the underclock, my Ryzen 7 5800X hits 120fps, and without it, 85fps. Although the compatibility for the new 32X core is a bit low, this is mostly due to pesky CPU bugs. The accuracy is quite high and I've emulated as much of the 32X and SH7604 peripheral functions as possible. I pass all 161 tests from the Mars Check Program. It should not take much more work to reach 98% compatibility in the future. Sega CD 32X emulation support is present, but is likely not functional, as I haven't tested it yet. Other major features in this release include Sega SVP support for Virtua Racing, plus improved Nintendo 64, Mega Drive, and Mega CD emulation compatibility. I'm going to start working on Sega Saturn emulation now, while Luke Usher works on Neo Geo emulation. No promises as to when or if these cores will become playable, I'm just giving you all a heads up since you'll see the skeletons for these systems in the source code now. Changelog: - Nintendo 64: improved Expansion Pak detection - Nintendo 64: fixed swapped L and R buttons [simer] - Nintendo 64: emulated the RST bit for gamepads - ruby: added library detection support for the Linux and BSD targets - lucia: gained support for game paks (custom file dialog only) - Super Famicom: added support for Super Game Boy, Sufami Turbo, and BS Memory packs - hiro: made SourceEdit optional for gtk2 and gtk3 targets (disabled for ares) - Nintendo 64: emulated 2048-byte EEPROM identifier and transfer protocol - Super Famicom: corrected ppu-performance widths table indexing to consider overscan - Mega CD: fixed a bug in register $ff8003; allows Popful Mail to boot [TascoDLX] - Mega Drive: fixed a bug with 256-width video modes - Mega Drive: improved VDP DMA emulation which should fix many games - Mega Drive: added SVP emulation - Mega Drive: added 32X emulation - Mega CD: fixed a bit-masking bug in register $ff8004; fixes Radical Rex [TascoDLX] - Nintendo 64: fixed C implementation of RSP VMACU instruction - Nintendo 64: use correct NTSC and PAL PIF ROM images based on the region - Mega Drive: fixed reset logic, Z80 interrupt timing + prefix timing + bus control [TascoDLX] - Mega CD: fixed word RAM access and CDC DMA word RAM transfers [TascoDLX] - Nintendo 64: improved RSP VMOV emulation [Rasky] - Nintendo 64: fixed RSP DMEM DMA alignment (&~7, not &~3) [Rasky] - Nintendo 64: upgraded to the latest version of ParaLLEl-RDP - nall: greatly expanded recompiler/amd64's supported intrinsics - mia: substantial refactoring around a new virtual filesystem implementation from nall
2021-03-31 13:38:00 +09:00
mia::setHomeLocation([]() -> string {
if(auto location = settings.paths.home) return location;
return locate("Systems/");
Update to ares v119 release. I'm releasing ares v119 today, which includes very preliminary Sega 32X emulation support. Compatibility is currently at around 50% with the dynamic recompiler, probably closer to 75% with the cached interpreter, and since the system requirements were a bit too steep (on account of my Mega Drive core being cycle/dot-accurate), I downclocked the SH2s a bit until I can speed up the emulator more. You'll currently need about a Ryzen 5 2600 to hit 60fps reliably. With the underclock, my Ryzen 7 5800X hits 120fps, and without it, 85fps. Although the compatibility for the new 32X core is a bit low, this is mostly due to pesky CPU bugs. The accuracy is quite high and I've emulated as much of the 32X and SH7604 peripheral functions as possible. I pass all 161 tests from the Mars Check Program. It should not take much more work to reach 98% compatibility in the future. Sega CD 32X emulation support is present, but is likely not functional, as I haven't tested it yet. Other major features in this release include Sega SVP support for Virtua Racing, plus improved Nintendo 64, Mega Drive, and Mega CD emulation compatibility. I'm going to start working on Sega Saturn emulation now, while Luke Usher works on Neo Geo emulation. No promises as to when or if these cores will become playable, I'm just giving you all a heads up since you'll see the skeletons for these systems in the source code now. Changelog: - Nintendo 64: improved Expansion Pak detection - Nintendo 64: fixed swapped L and R buttons [simer] - Nintendo 64: emulated the RST bit for gamepads - ruby: added library detection support for the Linux and BSD targets - lucia: gained support for game paks (custom file dialog only) - Super Famicom: added support for Super Game Boy, Sufami Turbo, and BS Memory packs - hiro: made SourceEdit optional for gtk2 and gtk3 targets (disabled for ares) - Nintendo 64: emulated 2048-byte EEPROM identifier and transfer protocol - Super Famicom: corrected ppu-performance widths table indexing to consider overscan - Mega CD: fixed a bug in register $ff8003; allows Popful Mail to boot [TascoDLX] - Mega Drive: fixed a bug with 256-width video modes - Mega Drive: improved VDP DMA emulation which should fix many games - Mega Drive: added SVP emulation - Mega Drive: added 32X emulation - Mega CD: fixed a bit-masking bug in register $ff8004; fixes Radical Rex [TascoDLX] - Nintendo 64: fixed C implementation of RSP VMACU instruction - Nintendo 64: use correct NTSC and PAL PIF ROM images based on the region - Mega Drive: fixed reset logic, Z80 interrupt timing + prefix timing + bus control [TascoDLX] - Mega CD: fixed word RAM access and CDC DMA word RAM transfers [TascoDLX] - Nintendo 64: improved RSP VMOV emulation [Rasky] - Nintendo 64: fixed RSP DMEM DMA alignment (&~7, not &~3) [Rasky] - Nintendo 64: upgraded to the latest version of ParaLLEl-RDP - nall: greatly expanded recompiler/amd64's supported intrinsics - mia: substantial refactoring around a new virtual filesystem implementation from nall
2021-03-31 13:38:00 +09:00
});
mia::setSaveLocation([]() -> string {
return settings.paths.saves;
});
if(arguments.take("--fullscreen")) {
program.startFullScreen = true;
}
if(string system; arguments.take("--system", system)) {
program.startSystem = system;
}
if(string shader; arguments.take("--shader", shader)) {
program.startShader = shader;
}
if(arguments.take("--no-file-prompt")) {
program.noFilePrompt = true;
}
2020-02-04 07:28:34 +09:00
inputManager.create();
Emulator::construct();
settings.load();
if(arguments.find("--setting")) {
string settingValue;
while(arguments.take("--setting", settingValue)) {
auto kv = settingValue.split("=", 1L);
if(kv.size() == 2) {
auto node = settings[kv[0]];
if(node) {
node.setValue(kv[1]);
} else {
print("Invalid setting: ", settingValue, "\n");
return;
}
} else {
print("Invalid setting: ", settingValue, "\n");
return;
}
}
settings.process(true);
}
if(arguments.take("--help")) {
print("Usage: ares [OPTIONS]... game(s)\n\n");
2022-09-06 12:43:51 +09:00
print("Options:\n");
print(" --help Displays available options and exit\n");
#if defined(PLATFORM_WINDOWS)
print(" --terminal Create new terminal window\n");
#endif
2022-09-06 12:43:51 +09:00
print(" --fullscreen Start in full screen mode\n");
2023-03-07 14:31:25 +09:00
print(" --system name Specify the system name\n");
print(" --shader name Specify the name of the shader to use\n");
print(" --setting name=value Specify a value for a setting\n");
print(" --dump-all-settings Show a list of all existing settings and exit\n");
print(" --no-file-prompt Do not prompt to load (optional) additional roms (eg: 64DD)\n");
2022-09-06 12:43:51 +09:00
print("\n");
print("Available Systems:\n");
print(" ");
for(auto& emulator : emulators) {
print(emulator->name, ", ");
}
print("\n");
return;
}
if(arguments.take("--dump-all-settings")) {
function<void(const Markup::Node&, string)> dump;
dump = [&](const Markup::Node& node, string prefix) -> void {
for(const auto& setting : node) {
print(prefix, setting.name(), "\n");
dump(setting, string(prefix, setting.name(), "/"));
}
};
dump(settings, "");
return;
}
program.startGameLoad.reset();
for(auto argument : arguments) {
if(file::exists(argument)) program.startGameLoad.append(argument);
}
2020-01-31 08:14:21 +09:00
Instances::presentation.construct();
2020-02-01 09:28:14 +09:00
Instances::settingsWindow.construct();
Instances::toolsWindow.construct();
Instances::gameBrowserWindow.construct();
2020-01-31 08:14:21 +09:00
program.create();
Application::onMain({&Program::main, &program});
Application::run();
2020-02-01 09:28:14 +09:00
settings.save();
2020-01-31 08:14:21 +09:00
Instances::presentation.destruct();
2020-02-01 09:28:14 +09:00
Instances::settingsWindow.destruct();
Instances::toolsWindow.destruct();
Instances::gameBrowserWindow.destruct();
2020-01-31 08:14:21 +09:00
}
#if defined(PLATFORM_WINDOWS) && defined(ARCHITECTURE_AMD64) && !defined(BUILD_LOCAL)
#include <nall/windows/windows.hpp>
#include <intrin.h>
//this code must run before C++ global initializers
//it works with any valid combination of GCC, Clang, or MSVC and MingW or MSVCRT
//ref: https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-initialization
auto preCppInitializer() -> int {
int data[4] = {};
__cpuid(data, 1);
bool sse42 = data[2] & 1 << 20;
if(!sse42) FatalAppExitA(0, "This build of ares requires a CPU that supports SSE4.2.");
return 0;
}
extern "C" {
#if defined(_MSC_VER)
#pragma comment(linker, "/include:preCppInitializerEntry")
#pragma section(".CRT$XCT", read)
__declspec(allocate(".CRT$XCT"))
#else
__attribute__((section (".CRT$XCT"), used))
#endif
decltype(&preCppInitializer) preCppInitializerEntry = preCppInitializer;
}
#endif