Code Monkey home page Code Monkey logo

switchres's Introduction

What is Switchres

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 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                     Rotate axes, preserving aspect ratio
  -d, --display <display_index>     Use target display (index = 0, 1, 2...)
  -f, --force <w>x<h>@<r>           Force a specific video mode from display mode list
  -i, --ini <file.ini>              Specify an ini file
  -k, --keep                        Keep changes on exit (warning: this disables cleanup)
  -g, --geometry <adjustment>       Adjust geometry of generated modeline
                                    adjustment = <h_size>:<h_shift>:<v_shift>
                                    e.g. switchres 640 480 60 -c -g 1.1:-1:2

For more options, refer to switchres.ini. All options in switchres.ini can be applied in
command line as long options, e.g.: switchres 256 224 57.55 -c --dotclock_min 8.0

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 [email protected] 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+).

switchres's People

Contributors

alphanu1 avatar antonioginer avatar d0023r avatar elijahpepe avatar kopert avatar oomek avatar substring avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

switchres's Issues

Hsize/hoffset/voffset don't work

Hello @antonioginer
thanks for your work! i want to use it on my Ubuntu arcade machine.
I'm trying to calibrate the modeline in order to have a correct size on CRT; i'm using the python script and grid tool.
Unfortunately, changing hsize and h/v offsets seems to have any effect :'(

I have a Radeon HD 6450; it works fine with the modeline generated for 320x240@60, my CRT is in synch.

I don't know If there is something i'm doing wrong with that tools.
Next days i can check if the vga signal is really changing with my oscilloscope on synch signals.

Thanks

Add a readme

Add a readme to swtichres. Here is a WIP that everyone can edit


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 [email protected] 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+).

Debian 10 build compilation error

The project does not build under Debian 10 stable:

  • GCC 8.30
  • Binutils 2.31.1
  • GLIBC 2.28
  • libdrm 2.4.97-1
  • libxrandr 1.5.1-1

with the following error message:

In file included from custom_video.cpp:27:
custom_video_drmkms.h:76:14: error: 'drmIsMaster' was not declared in this scope
   __typeof__(drmIsMaster) *p_drmIsMaster;
              ^~~~~~~~~~~
custom_video_drmkms.h:76:14: note: suggested alternative: 'drmSetMaster'
   __typeof__(drmIsMaster) *p_drmIsMaster;
              ^~~~~~~~~~~
              drmSetMaster

It looks like my version of libdrm has no drmIsMaster defintion. Opening issue to point out project is not compiling on Debian 10 right now. I will try to find a solution if possible and send a pull request.

Switchres on Steam Deck

Hello!

I'm trying to get switchres and 15khz output from Steam Deck. I've actually successfully patched the Steam Deck's kernel with the following repo https://github.com/D0023R/linux_kernel_15khz . Steam Deck is on 5.13 kernel atm if that helps.

Anyway I compiled the swithres repo here and tried to just test it on the built in screen and once with a external lcd screen in KMS/DRM gamescope mode (while in the normal Steam Deck UI game mode) (with non 15khz outputs) but looks like I'm having issues , I've added the debug logging below including the drm card devices. eDP is the laptop where DP is the external adapter.

I understand that the steam deck's custom APU may not work here but wanted to see if it could haha. let me know if I'm on the right direction or not even close.

(Steam deck uses Xwayland for the gamescope session)

image

image

xwayland while connected to external monitor through DP-1

image

xwayland while connected to internal monitor through eDP-1

image

Add a release for compiled binary files

Since I can't be the only one struggeling with compiling code on windows, I'd like to ask kindly for adding the latest compiled binaries to the releases tab.
Thank you very much, your work is very much appreciated!

Switchres should use correct monitor type and alter between NTSC and PAL properly

I have identified the issue in SwitchRes, including RetroArch dependency SwitchRes and recorded Youtube video.

Here I present the cause as well as solution!

But further development will be probably necessary to provide a better user experience and configuration properties.

https://www.youtube.com/watch?v=Xv5u-JPKDS0

In a nutshell:
generic_15 and arcade_15 are now the same, which does not make any sense.

arcade_15 has different frequency range than regular NTSC/PAL

generic_15 should encapsulate regular NTSC/PAL frequencies, which it currently doesn't.

Acceptance criteria:
generic_15 profile will use 15.625000KHz 50.000000Hz for PAL resolutions and 15.73KHz 59.94Hz for NTSC

Initialy I started my bug hunt here: libretro/RetroArch#14441

how to use switchres / groovymame in Xwayland ?

Hello,

I'm aware that switchres requires X11, so this is more a question (or feature request ?)
I have found no equivalent of switchres for Wayland, but Wayland is using X11 session (Xwayland) to launch X11 apps.
So maybe there is a way to use switchres in Xwayland (for groovymame) ?

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.