Skip to content

Instantly share code, notes, and snippets.

@substring
Created April 8, 2020 10:06
Show Gist options
  • Save substring/47a95f463979b89b32ff705be9559d2f to your computer and use it in GitHub Desktop.
Save substring/47a95f463979b89b32ff705be9559d2f to your computer and use it in GitHub Desktop.
Switchres readme

What is Switchres 2.0

Switchres is a C++ library dedicated to CRT low resolutions switching.

It's main purpose is, based on a monitor profile, provide the best possible resolution given a height, width and refresh rate.

Switchres 2.0 is a rewrite of the original switchres code used in GroovyMAME. It currently supports mode switching on the following OS with their respective backends:

  • Windows:
    • powerstrip
    • ADL
    • ATI cards
  • Linux:
    • X11/Xorg
    • KMS/DRM

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 a ini file

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 show the modeline computed for the default monitor (generic_15)

switchres 320 240 60 -m ntsc -s will switch your primary screen to 320x240 at 60Hz using the ntsc monitor model. The switch will be quite brief and switres will restore your initial screen resolution.

switchres 384 288 50 -m arcade_15 -d \\\\.\\DISPLAY1 -l mame will switch to 384x288@50 your display #1, launch mame. Once mame has exited, restore the original resolution.

Using switchres as a library

Currently work in progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment