From fbc58c70ae90810f5b404eead2e5d994aa3dc91f Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Sun, 24 Sep 2017 11:01:48 +1000 Subject: [PATCH] Update to v104r14 release. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit byuu says: Changelog: - Emulator::Interface::videoResolution() -\> VideoResolution renamed to videoInformation() -\> VideoInformation - added double VideoInformation::refreshRate - higan: added `binary := (application|library)` — set this to `library` to produce a dynamic link library - higan: removed `-march=native` for macOS application builds; and for all library builds - higan: removed `console` build flag; uncomment `link += -mwindows` instead - nall/GNUmakefile: `macosx` platform renamed `macos` - still need to do this for nall/intrinsics.hpp - Game Gear: return region=NTSC as the only option, so that the system frequency is always set correctly - hiro/cocoa: fixed typo [Sintendo] - hiro/Windows: removed GetDpiForMonitor, as it's Windows 8+ only; DPI is no longer per-monitor aware - icarus: core Icarus class now has virtual functions for directory::create, , , - icarus: Sufami Turbo can import save RAM files now - icarus: setting `ICARUS_LIBRARY` define will compile icarus without main(), GUI components - ruby/video/Direct3D: choose the current monitor instead of top-left monitor for fullscreen exclusive [Cydrak] - ruby/video/Direct3D: do not set `WS_EX_TOPMOST` on fullscreen exclusive window [Cydrak] - this isn't necessary for exclusive mode, and it just makes getting out of the application more difficult --- higan/GNUmakefile | 36 ++++++++++++------- higan/emulator/emulator.hpp | 2 +- higan/emulator/interface.hpp | 16 ++++----- higan/fc/interface/interface.cpp | 11 ++++-- higan/fc/interface/interface.hpp | 2 +- higan/gb/interface/interface.cpp | 11 ++++-- higan/gb/interface/interface.hpp | 2 +- higan/gba/interface/interface.cpp | 17 ++++++--- higan/gba/interface/interface.hpp | 2 +- higan/md/interface/interface.cpp | 11 ++++-- higan/md/interface/interface.hpp | 2 +- higan/md/vdp/vdp.hpp | 2 ++ higan/ms/cartridge/cartridge.cpp | 2 +- higan/ms/interface/game-gear.cpp | 11 ++++-- higan/ms/interface/interface.hpp | 4 +-- higan/ms/interface/master-system.cpp | 12 +++++-- higan/pce/interface/interface.cpp | 11 ++++-- higan/pce/interface/interface.hpp | 2 +- higan/sfc/interface/interface.cpp | 12 +++++-- higan/sfc/interface/interface.hpp | 2 +- higan/target-tomoko/GNUmakefile | 8 ++--- .../presentation/presentation.cpp | 8 ++--- higan/target-tomoko/program/interface.cpp | 6 ++-- higan/ws/interface/interface.cpp | 17 ++++++--- higan/ws/interface/interface.hpp | 2 +- hiro/cocoa/font.cpp | 2 +- hiro/cocoa/monitor.cpp | 2 +- hiro/core/application.cpp | 4 +++ hiro/core/core.hpp | 1 + hiro/gtk/font.cpp | 4 +-- hiro/qt/font.cpp | 2 +- hiro/windows/font.cpp | 2 +- hiro/windows/monitor.cpp | 18 ++++------ hiro/windows/widget/button.cpp | 7 +++- hiro/windows/widget/frame.cpp | 4 +-- icarus/GNUmakefile | 8 ++--- icarus/core/bs-memory.cpp | 12 +++---- icarus/core/core.hpp | 24 +++++++++++++ icarus/core/famicom.cpp | 15 ++++---- icarus/core/game-boy-advance.cpp | 11 +++--- icarus/core/game-boy-color.cpp | 11 +++--- icarus/core/game-boy.cpp | 11 +++--- icarus/core/game-gear.cpp | 11 +++--- icarus/core/master-system.cpp | 11 +++--- icarus/core/mega-drive.cpp | 11 +++--- icarus/core/pc-engine.cpp | 11 +++--- icarus/core/sufami-turbo.cpp | 15 ++++---- icarus/core/super-famicom.cpp | 13 ++++--- icarus/core/supergrafx.cpp | 11 +++--- icarus/core/wonderswan-color.cpp | 11 +++--- icarus/core/wonderswan.cpp | 11 +++--- icarus/icarus.cpp | 6 +++- nall/GNUmakefile | 8 ++--- ruby/video/direct3d.cpp | 5 ++- ruby/video/wgl.cpp | 1 - 55 files changed, 287 insertions(+), 187 deletions(-) diff --git a/higan/GNUmakefile b/higan/GNUmakefile index aa2e88e9..b0ad6d29 100644 --- a/higan/GNUmakefile +++ b/higan/GNUmakefile @@ -1,28 +1,38 @@ build := optimize include ../nall/GNUmakefile +binary := application target := tomoko objects := libco emulator audio video resource -# console := true flags += -I. -I.. ifeq ($(platform),windows) - ifeq ($(console),true) - link += -mconsole - else - link += -mwindows + link += -mwindows + ifeq ($(binary),application) + link += -mthreads -lpthread -luuid -lkernel32 -luser32 -lgdi32 -lcomctl32 -lcomdlg32 -lshell32 + link += -Wl,-enable-auto-import + link += -Wl,-enable-runtime-pseudo-reloc + else ifeq ($(binary),library) + link += -shared + endif +else ifeq ($(platform),macos) + ifeq ($(binary),application) + else ifeq ($(binary),library) + flags += -fPIC + link += -dynamiclib endif - link += -mthreads -lpthread -luuid -lkernel32 -luser32 -lgdi32 -lcomctl32 -lcomdlg32 -lshell32 - link += -Wl,-enable-auto-import - link += -Wl,-enable-runtime-pseudo-reloc -else ifeq ($(platform),macosx) - flags += -march=native else ifneq ($(filter $(platform),linux bsd),) - flags += -march=native -fopenmp + flags += -fopenmp link += -fopenmp - link += -Wl,-export-dynamic - link += -lX11 -lXext + ifeq ($(binary),application) + flags += -march=native + link += -Wl,-export-dynamic + link += -lX11 -lXext + else ifeq ($(binary),library) + flags += -fPIC + link += -shared + endif else $(error "unsupported platform") endif diff --git a/higan/emulator/emulator.hpp b/higan/emulator/emulator.hpp index 6ced2cc6..063df3f1 100644 --- a/higan/emulator/emulator.hpp +++ b/higan/emulator/emulator.hpp @@ -12,7 +12,7 @@ using namespace nall; namespace Emulator { static const string Name = "higan"; - static const string Version = "104.13"; + static const string Version = "104.14"; static const string Author = "byuu"; static const string License = "GPLv3"; static const string Website = "https://byuu.org/"; diff --git a/higan/emulator/interface.hpp b/higan/emulator/interface.hpp index 9c294291..8d284061 100644 --- a/higan/emulator/interface.hpp +++ b/higan/emulator/interface.hpp @@ -37,15 +37,15 @@ struct Interface { virtual auto manifest() -> string = 0; virtual auto title() -> string = 0; - //video information - struct VideoResolution { - uint width; - uint height; - uint internalWidth; - uint internalHeight; - double aspectCorrection; + struct VideoInformation { + uint width = 0; + uint height = 0; + uint internalWidth = 0; + uint internalHeight = 0; + double aspectCorrection = 0; + double refreshRate = 0; }; - virtual auto videoResolution() -> VideoResolution = 0; + virtual auto videoInformation() -> VideoInformation = 0; virtual auto videoColors() -> uint32 = 0; virtual auto videoColor(uint32 color) -> uint64 = 0; diff --git a/higan/fc/interface/interface.cpp b/higan/fc/interface/interface.cpp index 7af4e9a5..7943236e 100644 --- a/higan/fc/interface/interface.cpp +++ b/higan/fc/interface/interface.cpp @@ -44,8 +44,15 @@ auto Interface::title() -> string { return cartridge.title(); } -auto Interface::videoResolution() -> VideoResolution { - return {256, 240, 256, 240, 8.0 / 7.0}; +auto Interface::videoInformation() -> VideoInformation { + VideoInformation vi; + vi.width = 256; + vi.height = 240; + vi.internalWidth = 256; + vi.internalHeight = 240; + vi.aspectCorrection = 8.0 / 7.0; + vi.refreshRate = system.frequency() / (ppu.vlines() * ppu.rate() * 341.0); + return vi; } auto Interface::videoColors() -> uint32 { diff --git a/higan/fc/interface/interface.hpp b/higan/fc/interface/interface.hpp index 3ce8110e..6fb05d82 100644 --- a/higan/fc/interface/interface.hpp +++ b/higan/fc/interface/interface.hpp @@ -26,7 +26,7 @@ struct Interface : Emulator::Interface { auto manifest() -> string override; auto title() -> string override; - auto videoResolution() -> VideoResolution override; + auto videoInformation() -> VideoInformation override; auto videoColors() -> uint32 override; auto videoColor(uint32 color) -> uint64 override; diff --git a/higan/gb/interface/interface.cpp b/higan/gb/interface/interface.cpp index 61492f08..3d0a41f6 100644 --- a/higan/gb/interface/interface.cpp +++ b/higan/gb/interface/interface.cpp @@ -36,8 +36,15 @@ auto Interface::title() -> string { return cartridge.title(); } -auto Interface::videoResolution() -> VideoResolution { - return {160, 144, 160, 144, 1.0}; +auto Interface::videoInformation() -> VideoInformation { + VideoInformation vi; + vi.width = 160; + vi.height = 144; + vi.internalWidth = 160; + vi.internalHeight = 144; + vi.aspectCorrection = 1.0; + vi.refreshRate = (4.0 * 1024.0 * 1024.0) / (154.0 * 456.0); + return vi; } auto Interface::loaded() -> bool { diff --git a/higan/gb/interface/interface.hpp b/higan/gb/interface/interface.hpp index 9da3820e..e229aebb 100644 --- a/higan/gb/interface/interface.hpp +++ b/higan/gb/interface/interface.hpp @@ -23,7 +23,7 @@ struct Interface : Emulator::Interface { auto manifest() -> string override; auto title() -> string override; - auto videoResolution() -> VideoResolution override; + auto videoInformation() -> VideoInformation override; auto loaded() -> bool override; auto sha256() -> string override; diff --git a/higan/gba/interface/interface.cpp b/higan/gba/interface/interface.cpp index 504c1ad3..dabffd16 100644 --- a/higan/gba/interface/interface.cpp +++ b/higan/gba/interface/interface.cpp @@ -39,12 +39,19 @@ auto Interface::title() -> string { return cartridge.title(); } -auto Interface::videoResolution() -> VideoResolution { - if(!settings.rotateLeft) { - return {240, 160, 240, 160, 1.0}; - } else { - return {160, 240, 160, 240, 1.0}; +auto Interface::videoInformation() -> VideoInformation { + VideoInformation vi; + vi.width = 240; + vi.height = 160; + vi.internalWidth = 240; + vi.internalHeight = 160; + vi.aspectCorrection = 1.0; + vi.refreshRate = system.frequency() / (228.0 * 1232.0); + if(settings.rotateLeft) { + swap(vi.width, vi.height); + swap(vi.internalWidth, vi.internalHeight); } + return vi; } auto Interface::videoColors() -> uint32 { diff --git a/higan/gba/interface/interface.hpp b/higan/gba/interface/interface.hpp index ca85e284..bfba2859 100644 --- a/higan/gba/interface/interface.hpp +++ b/higan/gba/interface/interface.hpp @@ -23,7 +23,7 @@ struct Interface : Emulator::Interface { auto manifest() -> string override; auto title() -> string override; - auto videoResolution() -> VideoResolution override; + auto videoInformation() -> VideoInformation override; auto videoColors() -> uint32 override; auto videoColor(uint32 color) -> uint64 override; diff --git a/higan/md/interface/interface.cpp b/higan/md/interface/interface.cpp index c40841b8..3beff4a9 100644 --- a/higan/md/interface/interface.cpp +++ b/higan/md/interface/interface.cpp @@ -64,8 +64,15 @@ auto Interface::title() -> string { return cartridge.title(); } -auto Interface::videoResolution() -> VideoResolution { - return {320, 240, 1280, 480, 1.0}; +auto Interface::videoInformation() -> VideoInformation { + VideoInformation vi; + vi.width = 320; + vi.height = 240; + vi.internalWidth = 1280; + vi.internalHeight = 480; + vi.aspectCorrection = 1.0; + vi.refreshRate = (system.frequency() / 2.0) / (vdp.frameHeight() * 1710.0); + return vi; } auto Interface::videoColors() -> uint32 { diff --git a/higan/md/interface/interface.hpp b/higan/md/interface/interface.hpp index dc70a8ba..6d555f32 100644 --- a/higan/md/interface/interface.hpp +++ b/higan/md/interface/interface.hpp @@ -27,7 +27,7 @@ struct Interface : Emulator::Interface { auto manifest() -> string override; auto title() -> string override; - auto videoResolution() -> VideoResolution override; + auto videoInformation() -> VideoInformation override; auto videoColors() -> uint32 override; auto videoColor(uint32 color) -> uint64 override; diff --git a/higan/md/vdp/vdp.hpp b/higan/md/vdp/vdp.hpp index b0d8b593..8bafbf60 100644 --- a/higan/md/vdp/vdp.hpp +++ b/higan/md/vdp/vdp.hpp @@ -262,6 +262,8 @@ private: uint32 buffer[1280 * 512]; uint32* output = nullptr; + + friend class Interface; }; extern VDP vdp; diff --git a/higan/ms/cartridge/cartridge.cpp b/higan/ms/cartridge/cartridge.cpp index 75027961..8cff8acd 100644 --- a/higan/ms/cartridge/cartridge.cpp +++ b/higan/ms/cartridge/cartridge.cpp @@ -17,7 +17,7 @@ auto Cartridge::load() -> bool { } if(Model::GameGear()) { - if(auto loaded = platform->load(ID::GameGear, "Game Gear", "gg")) { + if(auto loaded = platform->load(ID::GameGear, "Game Gear", "gg", {"NTSC"})) { information.pathID = loaded.pathID(); } else return false; } diff --git a/higan/ms/interface/game-gear.cpp b/higan/ms/interface/game-gear.cpp index fdb2a01d..4865a401 100644 --- a/higan/ms/interface/game-gear.cpp +++ b/higan/ms/interface/game-gear.cpp @@ -21,8 +21,15 @@ GameGearInterface::GameGearInterface() { ports.append(move(hardware)); } -auto GameGearInterface::videoResolution() -> VideoResolution { - return {160, 144, 160, 144, 1.0}; +auto GameGearInterface::videoInformation() -> VideoInformation { + VideoInformation vi; + vi.width = 160; + vi.height = 144; + vi.internalWidth = 160; + vi.internalHeight = 144; + vi.aspectCorrection = 1.0; + vi.refreshRate = (system.colorburst() * 15.0 / 5.0) / (262.0 * 684.0); + return vi; } auto GameGearInterface::videoColors() -> uint32 { diff --git a/higan/ms/interface/interface.hpp b/higan/ms/interface/interface.hpp index 998cfc0f..54473267 100644 --- a/higan/ms/interface/interface.hpp +++ b/higan/ms/interface/interface.hpp @@ -50,7 +50,7 @@ struct MasterSystemInterface : Interface { MasterSystemInterface(); - auto videoResolution() -> VideoResolution override; + auto videoInformation() -> VideoInformation override; auto videoColors() -> uint32 override; auto videoColor(uint32 color) -> uint64 override; @@ -64,7 +64,7 @@ struct GameGearInterface : Interface { GameGearInterface(); - auto videoResolution() -> VideoResolution override; + auto videoInformation() -> VideoInformation override; auto videoColors() -> uint32 override; auto videoColor(uint32 color) -> uint64 override; diff --git a/higan/ms/interface/master-system.cpp b/higan/ms/interface/master-system.cpp index 9ef6213c..25c6d62c 100644 --- a/higan/ms/interface/master-system.cpp +++ b/higan/ms/interface/master-system.cpp @@ -36,8 +36,16 @@ MasterSystemInterface::MasterSystemInterface() { ports.append(move(hardware)); } -auto MasterSystemInterface::videoResolution() -> VideoResolution { - return {256, 240, 256, 240, 8.0 / 7.0}; +auto MasterSystemInterface::videoInformation() -> VideoInformation { + VideoInformation vi; + vi.width = 256; + vi.height = 240; + vi.internalWidth = 256; + vi.internalHeight = 240; + vi.aspectCorrection = 8.0 / 7.0; + if(Region::NTSC()) vi.refreshRate = (system.colorburst() * 15.0 / 5.0) / (262.0 * 684.0); + if(Region::PAL()) vi.refreshRate = (system.colorburst() * 15.0 / 5.0) / (312.0 * 684.0); + return vi; } auto MasterSystemInterface::videoColors() -> uint32 { diff --git a/higan/pce/interface/interface.cpp b/higan/pce/interface/interface.cpp index 5de84f22..092b9dc9 100644 --- a/higan/pce/interface/interface.cpp +++ b/higan/pce/interface/interface.cpp @@ -39,8 +39,15 @@ auto Interface::title() -> string { return cartridge.title(); } -auto Interface::videoResolution() -> VideoResolution { - return {280, 240, 1120, 240, 8.0 / 7.0}; +auto Interface::videoInformation() -> VideoInformation { + VideoInformation vi; + vi.width = 280; + vi.height = 240; + vi.internalWidth = 1120; + vi.internalHeight = 240; + vi.aspectCorrection = 8.0 / 7.0; + vi.refreshRate = (system.colorburst() * 6.0) / (262.0 * 1365.0); + return vi; } auto Interface::videoColors() -> uint32 { diff --git a/higan/pce/interface/interface.hpp b/higan/pce/interface/interface.hpp index 103838ef..0e79f304 100644 --- a/higan/pce/interface/interface.hpp +++ b/higan/pce/interface/interface.hpp @@ -23,7 +23,7 @@ struct Interface : Emulator::Interface { auto manifest() -> string override; auto title() -> string override; - auto videoResolution() -> VideoResolution override; + auto videoInformation() -> VideoInformation override; auto videoColors() -> uint32 override; auto videoColor(uint32 color) -> uint64 override; diff --git a/higan/sfc/interface/interface.cpp b/higan/sfc/interface/interface.cpp index a9585dc1..11cd7cb1 100644 --- a/higan/sfc/interface/interface.cpp +++ b/higan/sfc/interface/interface.cpp @@ -118,8 +118,16 @@ auto Interface::title() -> string { return cartridge.title(); } -auto Interface::videoResolution() -> VideoResolution { - return {256, 240, 512, 480, 8.0 / 7.0}; +auto Interface::videoInformation() -> VideoInformation { + VideoInformation vi; + vi.width = 256; + vi.height = 240; + vi.internalWidth = 512; + vi.internalHeight = 480; + vi.aspectCorrection = 8.0 / 7.0; + if(Region::NTSC()) vi.refreshRate = system.cpuFrequency() / (262.0 * 1364.0); + if(Region::PAL()) vi.refreshRate = system.cpuFrequency() / (312.0 * 1364.0); + return vi; } auto Interface::videoColors() -> uint32 { diff --git a/higan/sfc/interface/interface.hpp b/higan/sfc/interface/interface.hpp index 7502a9bf..8fa6bedb 100644 --- a/higan/sfc/interface/interface.hpp +++ b/higan/sfc/interface/interface.hpp @@ -38,7 +38,7 @@ struct Interface : Emulator::Interface { auto manifest() -> string override; auto title() -> string override; - auto videoResolution() -> VideoResolution override; + auto videoInformation() -> VideoInformation override; auto videoColors() -> uint32 override; auto videoColor(uint32 color) -> uint64 override; diff --git a/higan/target-tomoko/GNUmakefile b/higan/target-tomoko/GNUmakefile index d78a2795..bfdcbe2f 100644 --- a/higan/target-tomoko/GNUmakefile +++ b/higan/target-tomoko/GNUmakefile @@ -21,7 +21,7 @@ ifeq ($(platform),windows) ruby += video.wgl video.direct3d video.directdraw video.gdi ruby += audio.asio audio.wasapi audio.xaudio2 audio.directsound ruby += input.windows -else ifeq ($(platform),macosx) +else ifeq ($(platform),macos) ruby += video.cgl ruby += audio.openal ruby += input.quartz input.carbon @@ -68,7 +68,7 @@ obj/ui-resource.o: # targets build: $(objects) $(strip $(compiler) -o out/$(name) $(objects) $(link)) -ifeq ($(platform),macosx) +ifeq ($(platform),macos) @if [ -d out/$(name).app ]; then rm -r out/$(name).app; fi mkdir -p out/$(name).app/Contents/MacOS/ mkdir -p out/$(name).app/Contents/Resources/ @@ -81,7 +81,7 @@ install: ifeq ($(shell id -un),root) $(error "make install should not be run as root") else ifeq ($(platform),windows) -else ifeq ($(platform),macosx) +else ifeq ($(platform),macos) mkdir -p ~/Library/Application\ Support/$(name)/ mkdir -p ~/Emulation/System/ cp -R out/$(name).app /Applications/$(name).app @@ -101,7 +101,7 @@ uninstall: ifeq ($(shell id -un),root) $(error "make uninstall should not be run as root") else ifeq ($(platform),windows) -else ifeq ($(platform),macosx) +else ifeq ($(platform),macos) if [ -d /Applications/$(name).app ]; then rm -r /Applications/$(name).app; fi else ifneq ($(filter $(platform),linux bsd),) if [ -f $(prefix)/bin/$(name) ]; then rm $(prefix)/bin/$(name); fi diff --git a/higan/target-tomoko/presentation/presentation.cpp b/higan/target-tomoko/presentation/presentation.cpp index 21ce0270..d0c4c889 100644 --- a/higan/target-tomoko/presentation/presentation.cpp +++ b/higan/target-tomoko/presentation/presentation.cpp @@ -248,10 +248,10 @@ auto Presentation::resizeViewport(bool resizeWindow) -> void { double emulatorHeight = 240; double aspectCorrection = 1.0; if(emulator) { - auto resolution = emulator->videoResolution(); - emulatorWidth = resolution.width; - emulatorHeight = resolution.height; - aspectCorrection = resolution.aspectCorrection; + auto information = emulator->videoInformation(); + emulatorWidth = information.width; + emulatorHeight = information.height; + aspectCorrection = information.aspectCorrection; if(emulator->information.overscan) { uint overscanHorizontal = settings["Video/Overscan/Horizontal"].natural(); uint overscanVertical = settings["Video/Overscan/Vertical"].natural(); diff --git a/higan/target-tomoko/program/interface.cpp b/higan/target-tomoko/program/interface.cpp index 54245143..a72ef49a 100644 --- a/higan/target-tomoko/program/interface.cpp +++ b/higan/target-tomoko/program/interface.cpp @@ -59,9 +59,9 @@ auto Program::videoRefresh(const uint32* data, uint pitch, uint width, uint heig if(emulator->information.overscan) { uint overscanHorizontal = settings["Video/Overscan/Horizontal"].natural(); uint overscanVertical = settings["Video/Overscan/Vertical"].natural(); - auto resolution = emulator->videoResolution(); - overscanHorizontal *= resolution.internalWidth / resolution.width; - overscanVertical *= resolution.internalHeight / resolution.height; + auto information = emulator->videoInformation(); + overscanHorizontal *= information.internalWidth / information.width; + overscanVertical *= information.internalHeight / information.height; data += overscanVertical * pitch + overscanHorizontal; width -= overscanHorizontal * 2; height -= overscanVertical * 2; diff --git a/higan/ws/interface/interface.cpp b/higan/ws/interface/interface.cpp index 78bfbd9c..7fa2f67c 100644 --- a/higan/ws/interface/interface.cpp +++ b/higan/ws/interface/interface.cpp @@ -35,12 +35,19 @@ auto Interface::title() -> string { return cartridge.information.title; } -auto Interface::videoResolution() -> VideoResolution { - if(!settings.rotateLeft) { - return {224, 144, 224, 144, 1.0}; - } else { - return {144, 224, 144, 224, 1.0}; +auto Interface::videoInformation() -> VideoInformation { + VideoInformation vi; + vi.width = 224; + vi.height = 144; + vi.internalWidth = 224; + vi.internalHeight = 144; + vi.aspectCorrection = 1.0; + vi.refreshRate = 3'072'000.0 / (159.0 * 256.0); + if(settings.rotateLeft) { + swap(vi.width, vi.height); + swap(vi.internalWidth, vi.internalHeight); } + return vi; } auto Interface::loaded() -> bool { diff --git a/higan/ws/interface/interface.hpp b/higan/ws/interface/interface.hpp index 05893b02..1d10137b 100644 --- a/higan/ws/interface/interface.hpp +++ b/higan/ws/interface/interface.hpp @@ -22,7 +22,7 @@ struct Interface : Emulator::Interface { auto manifest() -> string override; auto title() -> string override; - auto videoResolution() -> VideoResolution override; + auto videoInformation() -> VideoInformation override; auto loaded() -> bool override; auto sha256() -> string override; diff --git a/hiro/cocoa/font.cpp b/hiro/cocoa/font.cpp index 98071895..ad900395 100644 --- a/hiro/cocoa/font.cpp +++ b/hiro/cocoa/font.cpp @@ -30,7 +30,7 @@ auto pFont::family(const string& family) -> string { auto pFont::create(const Font& font) -> NSFont* { auto fontName = family(font.family()); NSString* family = [NSString stringWithUTF8String:fontName]; - CGFloat size = (float)(font.size() ? font.size() : 8); + CGFloat size = Application::scale(font.size() ? font.size() : 8); NSFontTraitMask traits = 0; if(font.bold()) traits |= NSBoldFontMask; diff --git a/hiro/cocoa/monitor.cpp b/hiro/cocoa/monitor.cpp index e230604b..0805ab75 100644 --- a/hiro/cocoa/monitor.cpp +++ b/hiro/cocoa/monitor.cpp @@ -11,7 +11,7 @@ auto pMonitor::count() -> uint { auto pMonitor::dpi(uint monitor) -> Position { @autoreleasepool { NSScreen* screen = [[NSScreen screens] objectAtIndex:monitor]; - NSDistionary* dictionary = [screen deviceDescription]; + NSDictionary* dictionary = [screen deviceDescription]; NSSize dpi = [[dictionary objectForKey:NSDeviceSize] sizeValue]; return {dpi.width, dpi.height}; } diff --git a/hiro/core/application.cpp b/hiro/core/application.cpp index a8f02b68..036be55f 100644 --- a/hiro/core/application.cpp +++ b/hiro/core/application.cpp @@ -55,6 +55,10 @@ auto Application::setScale(float scale) -> void { state.scale = scale; } +auto Application::unscale(float value) -> float { + return value * (1.0 / state.scale); +} + //Windows //======= diff --git a/hiro/core/core.hpp b/hiro/core/core.hpp index c8a5e635..97073687 100644 --- a/hiro/core/core.hpp +++ b/hiro/core/core.hpp @@ -385,6 +385,7 @@ struct Application { static auto setFont(const Font& font = {}) -> void; static auto setName(const string& name = "") -> void; static auto setScale(float scale = 1.0) -> void; + static auto unscale(float value) -> float; struct Windows { static auto doModalChange(bool modal) -> void; diff --git a/hiro/gtk/font.cpp b/hiro/gtk/font.cpp index 1a85e97f..e2488cfb 100644 --- a/hiro/gtk/font.cpp +++ b/hiro/gtk/font.cpp @@ -14,7 +14,7 @@ auto pFont::size(PangoFontDescription* font, const string& text) -> Size { PangoLayout* layout = pango_layout_new(context); pango_layout_set_font_description(layout, font); pango_layout_set_text(layout, text, -1); - signed width = 0, height = 0; + int width = 0, height = 0; pango_layout_get_pixel_size(layout, &width, &height); g_object_unref((gpointer)layout); return {width, height}; @@ -39,7 +39,7 @@ auto pFont::family(const string& family) -> string { auto pFont::create(const Font& font) -> PangoFontDescription* { auto p = pango_font_description_new(); pango_font_description_set_family(p, family(font.family())); - pango_font_description_set_size(p, (font.size() ? font.size() : 8) * PANGO_SCALE); + pango_font_description_set_size(p, Application::scale(font.size() ? font.size() : 8) * PANGO_SCALE); pango_font_description_set_weight(p, font.bold() ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL); pango_font_description_set_style(p, font.italic() ? PANGO_STYLE_OBLIQUE : PANGO_STYLE_NORMAL); return p; diff --git a/hiro/qt/font.cpp b/hiro/qt/font.cpp index 62667f0b..14f66b47 100644 --- a/hiro/qt/font.cpp +++ b/hiro/qt/font.cpp @@ -26,7 +26,7 @@ auto pFont::family(const string& family) -> QString { auto pFont::create(const Font& font) -> QFont { QFont qtFont; qtFont.setFamily(family(font.family())); - qtFont.setPointSize(font.size() ? font.size() : 8); + qtFont.setPointSize(Application::scale(font.size() ? font.size() : 8)); qtFont.setBold(font.bold()); qtFont.setItalic(font.italic()); return qtFont; diff --git a/hiro/windows/font.cpp b/hiro/windows/font.cpp index f3c87851..e752d64b 100644 --- a/hiro/windows/font.cpp +++ b/hiro/windows/font.cpp @@ -27,7 +27,7 @@ auto pFont::family(const string& family) -> string { auto pFont::create(const Font& font) -> HFONT { return CreateFont( - -((font.size() ? font.size() : 8) * 96.0 / 72.0 + 0.5), + -(Application::scale(font.size() ? font.size() : 8) * 96.0 / 72.0 + 0.5), 0, 0, 0, font.bold() ? FW_BOLD : FW_NORMAL, font.italic(), 0, 0, 0, 0, 0, 0, 0, utf16_t(family(font.family())) ); diff --git a/hiro/windows/monitor.cpp b/hiro/windows/monitor.cpp index a3049e7f..5ade851a 100644 --- a/hiro/windows/monitor.cpp +++ b/hiro/windows/monitor.cpp @@ -5,24 +5,19 @@ namespace hiro { struct MonitorInfo { uint monitor = 0; uint primary = 0; - float dpiX = 0; - float dpiY = 0; Geometry geometry; uint index = 0; }; static auto CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -> BOOL { MonitorInfo& info = *(MonitorInfo*)dwData; - MONITORINFOEX mi{sizeof(MONITORINFOEX)}; + MONITORINFOEX mi{}; + mi.cbSize = sizeof(MONITORINFOEX); GetMonitorInfo(hMonitor, &mi); string displayName = (const char*)utf8_t(mi.szDevice); if(displayName.beginsWith(R"(\\.\DISPLAYV)")) return true; //ignore pseudo-monitors if(mi.dwFlags & MONITORINFOF_PRIMARY) info.primary = info.index; if(info.monitor == info.index) { - UINT dpiX = 0, dpiY = 0; - GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY); - info.dpiX = dpiX; - info.dpiY = dpiY; info.geometry = {lprcMonitor->left, lprcMonitor->top, lprcMonitor->right - lprcMonitor->left, lprcMonitor->bottom - lprcMonitor->top}; } info.index++; @@ -34,10 +29,11 @@ auto pMonitor::count() -> uint { } auto pMonitor::dpi(uint monitor) -> Position { - MonitorInfo info; - info.monitor = monitor; - EnumDisplayMonitors(nullptr, nullptr, MonitorEnumProc, (LPARAM)&info); - return {info.dpiX, info.dpiY}; + HDC hdc = GetDC(0); + auto dpiX = (float)GetDeviceCaps(hdc, LOGPIXELSX); + auto dpiY = (float)GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(0, hdc); + return {dpiX, dpiY}; } auto pMonitor::geometry(uint monitor) -> Geometry { diff --git a/hiro/windows/widget/button.cpp b/hiro/windows/widget/button.cpp index 4a2b8edf..251cf184 100644 --- a/hiro/windows/widget/button.cpp +++ b/hiro/windows/widget/button.cpp @@ -173,7 +173,12 @@ auto Button_CustomDraw(HWND hwnd, PAINTSTRUCT& ps, bool bordered, bool checked, SetTextColor(ps.hdc, GetSysColor(IsWindowEnabled(hwnd) ? COLOR_BTNTEXT : COLOR_GRAYTEXT)); auto hFont = pFont::create(font); SelectObject(ps.hdc, hFont); - RECT rcText{textGeometry.x(), textGeometry.y(), textGeometry.x() + textGeometry.width(), textGeometry.y() + textGeometry.height()}; + RECT rcText{ + LONG(textGeometry.x()), + LONG(textGeometry.y()), + LONG(textGeometry.x() + textGeometry.width()), + LONG(textGeometry.y() + textGeometry.height()) + }; DrawText(ps.hdc, wText, -1, &rcText, DT_NOPREFIX | DT_END_ELLIPSIS); DeleteObject(hFont); } diff --git a/hiro/windows/widget/frame.cpp b/hiro/windows/widget/frame.cpp index e844c118..8ae4584c 100644 --- a/hiro/windows/widget/frame.cpp +++ b/hiro/windows/widget/frame.cpp @@ -31,9 +31,9 @@ auto pFrame::setGeometry(Geometry geometry) -> void { auto size = pFont::size(hfont, state().text); pWidget::setGeometry({ geometry.x(), - geometry.y() - (empty ? size.height() >> 1 : 0), + geometry.y() - (empty ? size.height() / 2 : 0), geometry.width(), - geometry.height() + (empty ? size.height() >> 1 : 0) + geometry.height() + (empty ? size.height() / 2 : 0) }); if(auto layout = state().layout) { if(empty) size.setHeight(1); diff --git a/icarus/GNUmakefile b/icarus/GNUmakefile index 1b9b70a9..d01465e2 100644 --- a/icarus/GNUmakefile +++ b/icarus/GNUmakefile @@ -16,7 +16,7 @@ objects += $(if $(call streq,$(platform),windows),obj/resource.o) all: $(objects) $(strip $(compiler) -o out/$(name) $(objects) $(link) $(hirolink)) -ifeq ($(platform),macosx) +ifeq ($(platform),macos) @if [ -d out/$(name).app ]; then rm -r out/$(name).app; fi mkdir -p out/$(name).app/Contents/MacOS/ mkdir -p out/$(name).app/Contents/Resources/ @@ -35,14 +35,14 @@ obj/resource.o: $(windres) data/icarus.rc obj/resource.o clean: -ifeq ($(platform),macosx) +ifeq ($(platform),macos) @if [ -d out/$(name).app ]; then rm out/$(name).app; fi endif -@$(call delete,obj/*) -@$(call delete,out/*) install: -ifeq ($(platform),macosx) +ifeq ($(platform),macos) cp -R out/$(name).app /Applications/$(name).app else ifneq ($(filter $(platform),linux bsd),) mkdir -p $(prefix)/bin/ @@ -56,7 +56,7 @@ else ifneq ($(filter $(platform),linux bsd),) endif uninstall: -ifeq ($(platform),macosx) +ifeq ($(platform),macos) if [ -d /Applications/$(name).app ]; then rm -r /Applications/$(name).app; fi else ifneq ($(filter $(platform),linux bsd),) if [ -f $(prefix)/bin/$(name) ]; then rm $(prefix)/bin/$(name); fi diff --git a/icarus/core/bs-memory.cpp b/icarus/core/bs-memory.cpp index 65a46d64..9e54bb24 100644 --- a/icarus/core/bs-memory.cpp +++ b/icarus/core/bs-memory.cpp @@ -35,13 +35,13 @@ auto Icarus::bsMemoryImport(vector& buffer, string location) -> string auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "BS Memory/", name, ".bs/"}; -//if(directory::exists(target)) return failure("game already exists"); - auto markup = bsMemoryManifest(buffer, location); - if(!markup) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); + auto manifest = bsMemoryManifest(buffer, location); + if(!manifest) return failure("failed to parse ROM image"); - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, markup); - file::write({target, "program.rom"}, buffer); + if(!create(target)) return failure("library path unwritable"); + + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, manifest); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/core/core.hpp b/icarus/core/core.hpp index 1b6ddac7..d495de30 100644 --- a/icarus/core/core.hpp +++ b/icarus/core/core.hpp @@ -1,4 +1,28 @@ struct Icarus { + virtual auto create(const string& pathname) -> bool { + return directory::create(pathname); + } + + virtual auto exists(const string& filename) -> bool { + return file::exists(filename); + } + + virtual auto copy(const string& target, const string& source) -> bool { + return file::copy(target, source); + } + + virtual auto write(const string& filename, const uint8_t* data, uint size) -> bool { + return file::write(filename, data, size); + } + + auto write(const string& filename, const vector& buffer) -> bool { + return write(filename, buffer.data(), buffer.size()); + } + + auto write(const string& filename, const string& text) -> bool { + return write(filename, (const uint8_t*)text.data(), text.size()); + } + //core.cpp Icarus(); diff --git a/icarus/core/famicom.cpp b/icarus/core/famicom.cpp index 34f28517..c8f07f56 100644 --- a/icarus/core/famicom.cpp +++ b/icarus/core/famicom.cpp @@ -41,22 +41,21 @@ auto Icarus::famicomImport(vector& buffer, string location) -> string { auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "Famicom/", name, ".fc/"}; -//if(directory::exists(target)) return failure("game already exists"); uint prgrom = 0; uint chrrom = 0; auto markup = famicomManifest(buffer, location, &prgrom, &chrrom); if(!markup) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".sav"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".sav"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, markup); - file::write({target, "ines.rom"}, buffer.data(), 16); - file::write({target, "program.rom"}, buffer.data() + 16, prgrom); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, markup); + write({target, "ines.rom"}, buffer.data(), 16); + write({target, "program.rom"}, buffer.data() + 16, prgrom); if(!chrrom) return success(target); - file::write({target, "character.rom"}, buffer.data() + 16 + prgrom, chrrom); + write({target, "character.rom"}, buffer.data() + 16 + prgrom, chrrom); return success(target); } diff --git a/icarus/core/game-boy-advance.cpp b/icarus/core/game-boy-advance.cpp index 40cfdbbe..9e347ff4 100644 --- a/icarus/core/game-boy-advance.cpp +++ b/icarus/core/game-boy-advance.cpp @@ -35,17 +35,16 @@ auto Icarus::gameBoyAdvanceImport(vector& buffer, string location) -> s auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "Game Boy Advance/", name, ".gba/"}; -//if(directory::exists(target)) return failure("game already exists"); auto markup = gameBoyAdvanceManifest(buffer, location); if(!markup) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".sav"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".sav"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, markup); - file::write({target, "program.rom"}, buffer); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, markup); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/core/game-boy-color.cpp b/icarus/core/game-boy-color.cpp index db18c821..62858768 100644 --- a/icarus/core/game-boy-color.cpp +++ b/icarus/core/game-boy-color.cpp @@ -35,17 +35,16 @@ auto Icarus::gameBoyColorImport(vector& buffer, string location) -> str auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "Game Boy Color/", name, ".gbc/"}; -//if(directory::exists(target)) return failure("game already exists"); auto markup = gameBoyColorManifest(buffer, location); if(!markup) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".sav"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".sav"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, markup); - file::write({target, "program.rom"}, buffer); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, markup); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/core/game-boy.cpp b/icarus/core/game-boy.cpp index 126c824a..34d6038e 100644 --- a/icarus/core/game-boy.cpp +++ b/icarus/core/game-boy.cpp @@ -35,17 +35,16 @@ auto Icarus::gameBoyImport(vector& buffer, string location) -> string { auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "Game Boy/", name, ".gb/"}; -//if(directory::exists(target)) return failure("game already exists"); auto markup = gameBoyManifest(buffer, location); if(!markup) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".sav"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".sav"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, markup); - file::write({target, "program.rom"}, buffer); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, markup); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/core/game-gear.cpp b/icarus/core/game-gear.cpp index 40b7b6b1..476c1f78 100644 --- a/icarus/core/game-gear.cpp +++ b/icarus/core/game-gear.cpp @@ -29,17 +29,16 @@ auto Icarus::gameGearImport(vector& buffer, string location) -> string auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "Game Gear/", name, ".gg/"}; -//if(directory::exists(target)) return failure("game already exists"); auto manifest = gameGearManifest(buffer, location); if(!manifest) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".sav"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".sav"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, manifest); - file::write({target, "program.rom"}, buffer); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, manifest); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/core/master-system.cpp b/icarus/core/master-system.cpp index c0d75c82..8da283f0 100644 --- a/icarus/core/master-system.cpp +++ b/icarus/core/master-system.cpp @@ -29,17 +29,16 @@ auto Icarus::masterSystemImport(vector& buffer, string location) -> str auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "Master System/", name, ".ms/"}; -//if(directory::exists(target)) return failure("game already exists"); auto manifest = masterSystemManifest(buffer, location); if(!manifest) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".sav"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".sav"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, manifest); - file::write({target, "program.rom"}, buffer); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, manifest); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/core/mega-drive.cpp b/icarus/core/mega-drive.cpp index 2bd849ff..266a5f21 100644 --- a/icarus/core/mega-drive.cpp +++ b/icarus/core/mega-drive.cpp @@ -29,17 +29,16 @@ auto Icarus::megaDriveImport(vector& buffer, string location) -> string auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "Mega Drive/", name, ".md/"}; -//if(directory::exists(target)) return failure("game already exists"); auto manifest = megaDriveManifest(buffer, location); if(!manifest) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".sav"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".sav"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, manifest); - file::write({target, "program.rom"}, buffer); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, manifest); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/core/pc-engine.cpp b/icarus/core/pc-engine.cpp index 679cfb4d..cb86eda4 100644 --- a/icarus/core/pc-engine.cpp +++ b/icarus/core/pc-engine.cpp @@ -29,17 +29,16 @@ auto Icarus::pcEngineImport(vector& buffer, string location) -> string auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "PC Engine/", name, ".pce/"}; -//if(directory::exists(target)) return failure("game already exists"); auto manifest = pcEngineManifest(buffer, location); if(!manifest) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".sav"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".sav"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, manifest); - file::write({target, "program.rom"}, buffer); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, manifest); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/core/sufami-turbo.cpp b/icarus/core/sufami-turbo.cpp index 6179297f..5b0eea16 100644 --- a/icarus/core/sufami-turbo.cpp +++ b/icarus/core/sufami-turbo.cpp @@ -35,13 +35,16 @@ auto Icarus::sufamiTurboImport(vector& buffer, string location) -> stri auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "Sufami Turbo/", name, ".st/"}; -//if(directory::exists(target)) return failure("game already exists"); - auto markup = sufamiTurboManifest(buffer, location); - if(!markup) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); + auto manifest = sufamiTurboManifest(buffer, location); + if(!manifest) return failure("failed to parse ROM image"); - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, markup); - file::write({target, "program.rom"}, buffer); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); + } + + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, manifest); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/core/super-famicom.cpp b/icarus/core/super-famicom.cpp index cd144919..bced83ed 100644 --- a/icarus/core/super-famicom.cpp +++ b/icarus/core/super-famicom.cpp @@ -24,7 +24,7 @@ auto Icarus::superFamicomManifest(vector& buffer, string location, stri } if(settings["icarus/UseHeuristics"].boolean() && !markup) { - bool hasMSU1 = file::exists({location, "msu1.rom"}); + bool hasMSU1 = exists({location, "msu1.rom"}); SuperFamicomCartridge cartridge{buffer.data(), buffer.size(), hasMSU1}; if(markup = cartridge.markup) { if(firmwareMissing) *firmwareMissing = cartridge.firmware_missing; @@ -49,19 +49,18 @@ auto Icarus::superFamicomImport(vector& buffer, string location) -> str auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "Super Famicom/", name, ".sfc/"}; -//if(directory::exists(target)) return failure("game already exists"); string firmwareMissing; auto markup = superFamicomManifest(buffer, location, &firmwareMissing); if(!markup) return failure("failed to parse ROM image"); if(firmwareMissing) return failure({"ROM image is missing ", firmwareMissing, " firmware data"}); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".srm"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".srm"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".srm"}) && !exists({target, "save.ram"})) { + copy({source, name, ".srm"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, markup); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, markup); uint offset = (buffer.size() & 0x7fff) == 512 ? 512 : 0; //skip header if present auto document = BML::unserialize(markup); vector roms; @@ -70,7 +69,7 @@ auto Icarus::superFamicomImport(vector& buffer, string location) -> str auto name = rom["name"].text(); auto size = rom["size"].natural(); if(size > buffer.size() - offset) return failure("ROM image is missing data"); - file::write({target, name}, buffer.data() + offset, size); + write({target, name}, buffer.data() + offset, size); offset += size; } return success(target); diff --git a/icarus/core/supergrafx.cpp b/icarus/core/supergrafx.cpp index 7042cb5f..ef748bea 100644 --- a/icarus/core/supergrafx.cpp +++ b/icarus/core/supergrafx.cpp @@ -29,17 +29,16 @@ auto Icarus::superGrafxImport(vector& buffer, string location) -> strin auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "SuperGrafx/", name, ".sg/"}; -//if(directory::exists(target)) return failure("game already exists"); auto manifest = superGrafxManifest(buffer, location); if(!manifest) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".sav"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".sav"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, manifest); - file::write({target, "program.rom"}, buffer); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, manifest); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/core/wonderswan-color.cpp b/icarus/core/wonderswan-color.cpp index 212daddd..f0111f63 100644 --- a/icarus/core/wonderswan-color.cpp +++ b/icarus/core/wonderswan-color.cpp @@ -29,17 +29,16 @@ auto Icarus::wonderSwanColorImport(vector& buffer, string location) -> auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "WonderSwan Color/", name, ".wsc/"}; -//if(directory::exists(target)) return failure("game already exists"); auto manifest = wonderSwanColorManifest(buffer, location); if(!manifest) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".sav"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".sav"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, manifest); - file::write({target, "program.rom"}, buffer); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, manifest); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/core/wonderswan.cpp b/icarus/core/wonderswan.cpp index df8199be..860f7972 100644 --- a/icarus/core/wonderswan.cpp +++ b/icarus/core/wonderswan.cpp @@ -29,17 +29,16 @@ auto Icarus::wonderSwanImport(vector& buffer, string location) -> strin auto name = Location::prefix(location); auto source = Location::path(location); string target{settings["Library/Location"].text(), "WonderSwan/", name, ".ws/"}; -//if(directory::exists(target)) return failure("game already exists"); auto manifest = wonderSwanManifest(buffer, location); if(!manifest) return failure("failed to parse ROM image"); - if(!directory::create(target)) return failure("library path unwritable"); - if(file::exists({source, name, ".sav"}) && !file::exists({target, "save.ram"})) { - file::copy({source, name, ".sav"}, {target, "save.ram"}); + if(!create(target)) return failure("library path unwritable"); + if(exists({source, name, ".sav"}) && !exists({target, "save.ram"})) { + copy({source, name, ".sav"}, {target, "save.ram"}); } - if(settings["icarus/CreateManifests"].boolean()) file::write({target, "manifest.bml"}, manifest); - file::write({target, "program.rom"}, buffer); + if(settings["icarus/CreateManifests"].boolean()) write({target, "manifest.bml"}, manifest); + write({target, "program.rom"}, buffer); return success(target); } diff --git a/icarus/icarus.cpp b/icarus/icarus.cpp index 9c1e7d9b..663c3e12 100644 --- a/icarus/icarus.cpp +++ b/icarus/icarus.cpp @@ -47,8 +47,10 @@ Settings settings; #include "core/wonderswan-color.cpp" #include "core/bs-memory.cpp" #include "core/sufami-turbo.cpp" -Icarus icarus; +#if !defined(ICARUS_LIBRARY) + +Icarus icarus; #include "ui/ui.hpp" #include "ui/scan-dialog.cpp" #include "ui/settings-dialog.cpp" @@ -126,3 +128,5 @@ auto nall::main(string_vector args) -> void { scanDialog->show(); Application::run(); } + +#endif diff --git a/nall/GNUmakefile b/nall/GNUmakefile index e8c4df41..79e73fd1 100644 --- a/nall/GNUmakefile +++ b/nall/GNUmakefile @@ -23,7 +23,7 @@ ifeq ($(platform),) platform := windows delete = del $(subst /,\,$1) else ifneq ($(findstring Darwin,$(uname)),) - platform := macosx + platform := macos delete = rm -f $1 else ifneq ($(findstring Linux,$(uname)),) platform := linux @@ -48,7 +48,7 @@ ifeq ($(compiler),) ifeq ($(platform),windows) compiler := g++ cppflags := -x c++ -std=gnu++14 - else ifeq ($(platform),macosx) + else ifeq ($(platform),macos) compiler := clang++ else ifeq ($(platform),linux) compiler := g++-4.9 @@ -92,8 +92,8 @@ ifeq ($(platform),windows) windres := windres endif -# macosx settings -ifeq ($(platform),macosx) +# macos settings +ifeq ($(platform),macos) flags += -stdlib=libc++ link += -lc++ -lobjc endif diff --git a/ruby/video/direct3d.cpp b/ruby/video/direct3d.cpp index 04f76585..f5685231 100644 --- a/ruby/video/direct3d.cpp +++ b/ruby/video/direct3d.cpp @@ -226,8 +226,7 @@ private: terminate(); if(!_context) return false; - POINT point = {0, 0}; - HMONITOR monitor = MonitorFromPoint(point, MONITOR_DEFAULTTOPRIMARY); + HMONITOR monitor = MonitorFromWindow((HWND)_context, MONITOR_DEFAULTTOPRIMARY); MONITORINFOEX information = {}; information.cbSize = sizeof(MONITORINFOEX); GetMonitorInfo(monitor, &information); @@ -247,7 +246,7 @@ private: windowClass.style = CS_HREDRAW | CS_VREDRAW; RegisterClass(&windowClass); - _exclusiveContext = (uintptr)CreateWindowEx(WS_EX_TOPMOST, L"VideoDirect3D_Window", L"", WS_POPUP, + _exclusiveContext = (uintptr)CreateWindow(L"VideoDirect3D_Window", L"", WS_POPUP, information.rcMonitor.left, information.rcMonitor.top, _monitorWidth, _monitorHeight, nullptr, nullptr, GetModuleHandle(0), nullptr); diff --git a/ruby/video/wgl.cpp b/ruby/video/wgl.cpp index e20591e3..2a85c5ab 100644 --- a/ruby/video/wgl.cpp +++ b/ruby/video/wgl.cpp @@ -127,6 +127,5 @@ private: HDC _display = nullptr; HGLRC _wglContext = nullptr; - HWND _window = nullptr; HINSTANCE _glWindow = nullptr; };