-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '428532865387840fdb11874d1c7dd27c42aa7400' as 'deps/swit…
…chres'
- Loading branch information
Showing
54 changed files
with
16,511 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Switchres CIv2 | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
buildx86_64: | ||
runs-on: ubuntu-latest | ||
name: ${{ matrix.platform.name }} ${{ matrix.config.name }} | ||
strategy: | ||
matrix: | ||
platform: | ||
- { name: Linux GCC } | ||
- { name: Windows MINGW, make_opts: PLATFORM=NT CROSS_COMPILE=x86_64-w64-mingw32- } | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install Linux dependencies | ||
if: matrix.platform.name == 'Linux GCC' | ||
run: sudo apt-get install libxrandr-dev libdrm-dev libsdl2-dev | ||
- name: Install Windows dependencies | ||
if: matrix.platform.name == 'Windows MINGW' | ||
run: | | ||
sudo apt-get install mingw-w64 wget tar | ||
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix | ||
wget https://github.com/libsdl-org/SDL/releases/download/release-2.26.2/SDL2-devel-2.26.2-mingw.tar.gz | ||
tar xvzf SDL2-devel-2.26.2-mingw.tar.gz | ||
sudo make -C SDL2-2.26.2 CROSS_PATH=/usr ARCHITECTURES=x86_64-w64-mingw32 cross | ||
wget https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.20.1/SDL2_ttf-devel-2.20.1-mingw.tar.gz | ||
tar xvzf SDL2_ttf-devel-2.20.1-mingw.tar.gz | ||
sudo make -C SDL2_ttf-2.20.1 CROSS_PATH=/usr ARCHITECTURES=x86_64-w64-mingw32 cross | ||
- name: Build libs and binary | ||
run: | | ||
make libswitchres ${{matrix.platform.make_opts}} | ||
make ${{matrix.platform.make_opts}} | ||
- name: Build grid.exe (Windows only) | ||
if: matrix.platform.name == 'Windows MINGW' | ||
run: | | ||
make ${{matrix.platform.make_opts}} clean | ||
make ${{matrix.platform.make_opts}} grid | ||
- name: Prepare artifacts | ||
run: mkdir artifacts && cp -v libswitchres.{so,a,dll,lib} switchres{,.exe,.ini} grid{,.exe} /usr/x86_64-w64-mingw32/bin/SDL2{,_ttf}.dll /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll artifacts/ || true | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3.1.0 | ||
with: | ||
name: switchres-${{matrix.platform.name}}-x86_64 | ||
path: artifacts/ | ||
|
||
win32-build-x86_64-geometry: | ||
|
||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
- name: Build geometry.exe | ||
run: | | ||
pip install pyinstaller | ||
pyinstaller --onefile geometry.py --icon=tv.ico | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3.1.0 | ||
with: | ||
name: geometry-win32-x86_64 | ||
path: dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*.o | ||
*.exe | ||
*.a | ||
*.so.* | ||
*.lib | ||
*.dll | ||
switchres_main | ||
grid | ||
switchres | ||
switchres.pc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# This file is a template, and might need editing before it works on your project. | ||
# use the official gcc image, based on debian | ||
# can use verions as well, like gcc:5.2 | ||
# see https://hub.docker.com/_/gcc/ | ||
image: gcc:latest | ||
|
||
before_script: | ||
- apt update | ||
- apt -y install make | ||
|
||
.pre_requisites_linux: &prerequisiteslinux | ||
before_script: | ||
- apt update | ||
- apt -y install make | ||
|
||
.pre_requisites_win32: &prerequisiteswin32 | ||
image: "ubuntu:rolling" | ||
before_script: | ||
- apt update | ||
- apt -y install make mingw-w64 | ||
|
||
|
||
linux:x86_64:standalone: | ||
stage: build | ||
<<: *prerequisiteslinux | ||
script: | ||
- make | ||
|
||
linux:x86_64:lib: | ||
stage: build | ||
<<: *prerequisiteslinux | ||
script: | ||
- make libswitchres | ||
|
||
win32:x86_64:standalone: | ||
stage: build | ||
<<: *prerequisiteswin32 | ||
script: | ||
- make PLATFORM=NT CROSS_COMPILE=x86_64-w64-mingw32- | ||
|
||
win32:x86_64:lib: | ||
stage: build | ||
<<: *prerequisiteswin32 | ||
script: | ||
- make PLATFORM=NT CROSS_COMPILE=x86_64-w64-mingw32- libswitchres | ||
|
||
|
||
win32:i686:standalone: | ||
stage: build | ||
<<: *prerequisiteswin32 | ||
script: | ||
- make PLATFORM=NT CROSS_COMPILE=i686-w64-mingw32- | ||
|
||
|
||
win32:i686:lib: | ||
stage: build | ||
<<: *prerequisiteswin32 | ||
script: | ||
- make PLATFORM=NT CROSS_COMPILE=i686-w64-mingw32- libswitchres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# What is Switchres 2.0 | ||
Switchres is a modeline generation engine for emulation. | ||
|
||
Its purpose is on-the-fly creation of fully customized video modes that accurately reproduce those of the emulated systems. Based on a monitor profile, it will provide the best video mode for a given width, height, and refresh rate. | ||
|
||
Switchres features the most versatile modeline generation ever, ranging from 15-kHz low resolutions up to modern 8K, with full geometry control, smart scaling, refresh scaling, mode rotation, aspect ratio correction and much more. | ||
|
||
Switchres can be integrated into open-source emulators either as a library, or used as a standalone emulator launcher. It's written in C++ and a C wrapper is also available. | ||
|
||
Switchres 2.0 is a rewrite of the original Switchres code used in GroovyMAME. It currently supports mode switching on the following platforms, with their respective backends: | ||
- **Windows**: | ||
- AMD ADL (AMD Radeon HD 5000+) | ||
- ATI legacy (ATI Radeon pre-HD 5000) | ||
- PowerStrip (ATI, Nvidia, Matrox, etc., models up to 2012) | ||
- **Linux**: | ||
- X11/Xorg | ||
- KMS/DRM (WIP) | ||
|
||
Each platform supports a different feature set, being X11/Xorg the most performant currently. In general, AMD video cards offer the best compatibility, and are a real requirement for the Windows platform. | ||
|
||
# Using Switchres as a library | ||
If you are an emulator writer, you can integrate Switchres into your emulator in two ways: | ||
|
||
- **Switchres shared library** (.dll or .so). This method offers a simplified way to add advanced mode switching features to your emulator, with minimal knowledge of Switchres internals. | ||
|
||
- **Full Switchres integration**. If your emulator is written in C++, you can gain full access to Switchres' gears by including a Switchres manager class into your project, à la GroovyMAME. | ||
|
||
Ask our devs for help and advice. | ||
|
||
# Using Switchres standalone | ||
The standalone binary supports the following options: | ||
``` | ||
Usage: switchres <width> <height> <refresh> [options] | ||
Options: | ||
-c, --calc Calculate video mode and exit | ||
-s, --switch Switch to video mode | ||
-l, --launch <command> Launch <command> | ||
-m, --monitor <preset> Monitor preset (generic_15, arcade_15, pal, ntsc, etc.) | ||
-a --aspect <num:den> Monitor aspect ratio | ||
-r --rotated Original mode's native orientation is rotated | ||
-d, --display <OS_display_name> Use target display (Windows: \\\\.\\DISPLAY1, ... Linux: VGA-0, ...) | ||
-f, --force <w>x<h>@<r> Force a specific video mode from display mode list | ||
-i, --ini <file.ini> Specify an ini file | ||
-b, --backend <api_name> Specify the api name | ||
-k, --keep Keep changes on exit (warning: this disables cleanup) | ||
``` | ||
|
||
A default `switchres.ini` file will be searched in the current working directory, then in `.\ini` on Windows, `./ini` then `/etc` on Linux. The repo has a switchres.ini example. | ||
|
||
## Examples | ||
`switchres 320 240 60 --calc` will calculate and show a modeline for 320x240@60, computed using the current monitor preset in `switchres.ini`. | ||
|
||
`switchres 320 240 60 -m ntsc -s` will switch your primary screen to 320x240 at 60Hz using the ntsc monitor model. Then it will wait until you press enter, and restore your initial screen resolution on exit. | ||
|
||
`switchres 384 256 55.017605 -m arcade_15 -s -d \\.\DISPLAY1 -l "mame rtype"` will switch your display #1 to 384x256@55.017605 using the arcade_15 preset, then launch ``mame rtype``. Once mame has exited, it will restore the original resolution. | ||
|
||
`switchres 640 480 57 -d 0 -m arcade_15 -d 1 -m arcade_31 -s` will set 640x480@57i (15-kHz preset) on your first display (index #0), 640x480@57p (31-kHz preset) on your second display (index #1) | ||
|
||
# License | ||
GNU General Public License, version 2 or later (GPL-2.0+). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
/************************************************************** | ||
custom_video.cpp - Custom video library | ||
--------------------------------------------------------- | ||
Switchres Modeline generation engine for emulation | ||
License GPL-2.0+ | ||
Copyright 2010-2021 Chris Kennedy, Antonio Giner, | ||
Alexandre Wodarczyk, Gil Delescluse | ||
**************************************************************/ | ||
|
||
|
||
|
||
#include <stdio.h> | ||
#include "custom_video.h" | ||
#include "log.h" | ||
|
||
#if defined(_WIN32) | ||
#include "custom_video_ati.h" | ||
#include "custom_video_adl.h" | ||
#include "custom_video_pstrip.h" | ||
#elif defined(__linux__) | ||
#ifdef SR_WITH_XRANDR | ||
#include "custom_video_xrandr.h" | ||
#endif | ||
#ifdef SR_WITH_KMSDRM | ||
#include "custom_video_drmkms.h" | ||
#endif | ||
#endif | ||
|
||
|
||
extern bool ati_is_legacy(int vendor, int device); | ||
|
||
//============================================================ | ||
// custom_video::make | ||
//============================================================ | ||
|
||
custom_video *custom_video::make(char *device_name, char *device_id, int method, custom_video_settings *vs) | ||
{ | ||
#if defined(_WIN32) | ||
if (method == CUSTOM_VIDEO_TIMING_POWERSTRIP) | ||
{ | ||
m_custom_video = new pstrip_timing(device_name, vs); | ||
if (m_custom_video) | ||
{ | ||
m_custom_method = CUSTOM_VIDEO_TIMING_POWERSTRIP; | ||
return m_custom_video; | ||
} | ||
} | ||
else | ||
{ | ||
int vendor, device; | ||
sscanf(device_id, "PCI\\VEN_%x&DEV_%x", &vendor, &device); | ||
|
||
if (vendor == 0x1002) // ATI/AMD | ||
{ | ||
if (ati_is_legacy(vendor, device)) | ||
{ | ||
m_custom_video = new ati_timing(device_name, vs); | ||
if (m_custom_video) | ||
{ | ||
m_custom_method = CUSTOM_VIDEO_TIMING_ATI_LEGACY; | ||
return m_custom_video; | ||
} | ||
} | ||
else | ||
{ | ||
m_custom_video = new adl_timing(device_name, vs); | ||
if (m_custom_video) | ||
{ | ||
m_custom_method = CUSTOM_VIDEO_TIMING_ATI_ADL; | ||
return m_custom_video; | ||
} | ||
} | ||
} | ||
else | ||
log_info("Video chipset is not compatible.\n"); | ||
} | ||
#elif defined(__linux__) | ||
if (device_id != NULL) | ||
log_info("Device value is %s.\n", device_id); | ||
|
||
#ifdef SR_WITH_XRANDR | ||
if (method == CUSTOM_VIDEO_TIMING_XRANDR || method == 0) | ||
{ | ||
try | ||
{ | ||
m_custom_video = new xrandr_timing(device_name, vs); | ||
} | ||
catch (...) {}; | ||
if (m_custom_video) | ||
{ | ||
m_custom_method = CUSTOM_VIDEO_TIMING_XRANDR; | ||
return m_custom_video; | ||
} | ||
} | ||
#endif /* SR_WITH_XRANDR */ | ||
|
||
#ifdef SR_WITH_KMSDRM | ||
if (method == CUSTOM_VIDEO_TIMING_DRMKMS || method == 0) | ||
{ | ||
m_custom_video = new drmkms_timing(device_name, vs); | ||
if (m_custom_video) | ||
{ | ||
m_custom_method = CUSTOM_VIDEO_TIMING_DRMKMS; | ||
return m_custom_video; | ||
} | ||
} | ||
#endif /* SR_WITH_KMSDRM */ | ||
#endif | ||
|
||
return this; | ||
} | ||
|
||
//============================================================ | ||
// custom_video::init | ||
//============================================================ | ||
|
||
bool custom_video::init() { return false; } | ||
|
||
//============================================================ | ||
// custom_video::get_timing | ||
//============================================================ | ||
|
||
bool custom_video::get_timing(modeline *mode) | ||
{ | ||
log_verbose("system mode\n"); | ||
mode->type |= CUSTOM_VIDEO_TIMING_SYSTEM; | ||
return false; | ||
} | ||
|
||
//============================================================ | ||
// custom_video::set_timing | ||
//============================================================ | ||
|
||
bool custom_video::set_timing(modeline *) | ||
{ | ||
return false; | ||
} | ||
|
||
//============================================================ | ||
// custom_video::add_mode | ||
//============================================================ | ||
|
||
bool custom_video::add_mode(modeline *) | ||
{ | ||
return false; | ||
} | ||
|
||
//============================================================ | ||
// custom_video::delete_mode | ||
//============================================================ | ||
|
||
bool custom_video::delete_mode(modeline *) | ||
{ | ||
return false; | ||
} | ||
|
||
//============================================================ | ||
// custom_video::update_mode | ||
//============================================================ | ||
|
||
bool custom_video::update_mode(modeline *) | ||
{ | ||
return false; | ||
} | ||
|
||
//============================================================ | ||
// custom_video::process_modelist | ||
//============================================================ | ||
|
||
bool custom_video::process_modelist(std::vector<modeline *>) | ||
{ | ||
return false; | ||
} |
Oops, something went wrong.