Batocera Native CRT Output
Batocera Native CRT Output
Foreword
This Guide would not have been possible without the following people to name a few:
Prerequisites
Here are some recommended transcoders if you need to go all the way to composite/S-video/RF:
The first step is to be able to connect your Batocera computer to the CRT display itself.
During the boot process and resizing of the partition it will boot up in a non-supported
resolution. Keep your TV/monitor off for the moment or on another AV channel so we
don't send out dangerous signals to your TV/monitor. These signals can destroy
your TV.
Also keep in mind that during the BIOS boot process the same rule applies. Have your
TV/monitor off or on another input when first booting up.
Have your TV/monitor turned off, or on another channel during the boot.
Have a look at gambaman's excellent solution The ultimate VGA to SCART adapter over at Build
Your Own Arcade Controls Forum (BYOAC).
Use buttersoft's passthrough dongle based on gambaman's design in the link above.
Flash you AMD/ATI card with ATOM-15.
The first step will be to change the syslinux file to be able to use Batocera at a lower resolution. To
achieve this, we need to modify the boot partition:
1. Connect to Batocera using SSH. See Access Batocera Linux via ssh for more information.
2. Make the boot partition writable. In the SSH session, run mount -o remount,rw /boot.
1. Get your graphics card's analog DVI/VGA output (without the `card#` string) using the
following command: ls /sys/class/drm/
This will return something like
In our example:
would become
For other supported boot resolutions, see this documentation on Github. Here is an example
syslinux.cfg file:
syslinux.cfg
UI menu.c32
TIMEOUT 50
TOTALTIMEOUT 300
MENU CLEAR
MENU TITLE Batocera.linux
MENU SHIFTKEY
LABEL batocera
MENU LABEL Batocera.linux (^normal)
MENU DEFAULT
LINUX /boot/linux
APPEND label=BATOCERA console=tty3 quiet loglevel=0
vt.global_cursor_default=0 mitigations=off video=DVI-I-1:640x480ieS
INITRD /boot/initrd.gz
LABEL verbose
MENU lABEL Batocera.linux (^verbose)
LINUX /boot/linux
APPEND label=BATOCERA vt.global_cursor_default=0
INITRD /boot/initrd.gz
It is highly recommended to disable the digital outputs (HDMI/DisplayPort (DP) port) to get video
exclusively out of the analog outputs (VGA/DVI-I port):
1. Get all the outputs on your graphics card that are capable of digital output (with the `card#`
string this time) using the ls /sys/class/drm/ command.
This will return something like:
2. Get port name for the connector using xrandr: xrandr -display :0.0 | grep
"connected"
This will return something like
In this example our card output is DisplayPort-0 (notice how it is marked as currently
disconnected?)
10-monitor.conf
Section "Monitor"
Identifier "[card-output]"
Option "Ignore" "true"
EndSection
Section "Monitor"
Identifier "[port-name]"
Option "Ignore" "true"
EndSection
10-monitor.conf
Section "Monitor"
Identifier "card0-DP-1"
Option "Ignore" "true"
EndSection
Section "Monitor"
Identifier "DisplayPort-0"
Option "Ignore" "true"
EndSection
batocera-save-overlay
This will make the changes persist to the next boot (updating Batocera will remove them, however).
fi
3. Uncomment the three lines in that section. For example, this code:
########################
#####-CRT CONFIG-#######
########################
##-Default Resolution-##
########################
#xrandr -display :0.0 --newmode "640x480i" 13.10 640 664 728 832 480
484 490 525 interlace -hsync -vsync
#xrandr -display :0.0 --addmode DVI-0 "640x480i"
#xrandr -display :0.0 --output DVI-0 --mode "640x480i"
########################
########################
would become
########################
#####-CRT CONFIG-#######
########################
##-Default Resolution-##
########################
xrandr -display :0.0 --newmode "640x480i" 13.10 640 664 728 832 480 484
490 525 interlace -hsync -vsync
xrandr -display :0.0 --addmode DVI-0 "640x480i"
xrandr -display :0.0 --output DVI-0 --mode "640x480i"
########################
########################
Save the changes with batocera-save-overlay again, and reboot. You are now booting up in
640x480i mode. In MAIN MENU → SYSTEM SETTINGS → VIDEO OUTPUT, set your default video
output to “DVI-0”. Reboot one more time.
I highly recommend using an external editor like Notepad++ and WinScp for editing
We don't want to force a vertical frequency of 60Hz all the time. This can have adverse effects on
games like frame pacing (uneven scrolling), audio (crackling) and timing (speed of gameplay, physics)
issues. So let's fix it by editing a few lines.
Make a backup of
/usr/bin/emulationstation-standalone
cp /usr/bin/emulationstation-standalone /usr/bin/emulationstation-
standalone.bak
From
To
As you might have noticed some of EmulationStation's menu is cut off and not centered. You may
have gotten lucky and have a really well tuned TV so these steps may not be necessary, but for most
TVs they will be. For this configuration you need to be able to look at your TV/monitor directly to see
the changes we are going to make.
Scaling (size)
We are going to use xrandr and a function called –scale-from wxh. You can refer to the “xrandr
–scale-from” section in this manual for more info.
Horizontal Resolution: Increasing/Decreasing this will make the image shrink or expand to the left.
Vertical Resolution: Increasing/Decreasing this will make the image shrink or expand from the
bottom.
When you are satisfied with your results we need to add this setting to etc/X11/xinit/xinitrc
Edit
etc/X11/xinit/xinitrc
Example
########################
#####-CRT CONFIG-#######
########################
xrandr -display :0.0 --newmode "640x480i" 13.10 640 664 728 832 480 484 490
525 interlace -hsync -vsync
xrandr -display :0.0 --addmode DVI-0 "640x480i"
xrandr -display :0.0 --output DVI-0 --mode "640x480i"
xrandr -display :0.0 --output DVI-0 --scale-from 640x480
#####################
#####################
We also need to make a script so this setting persists even after exiting an Emulator. Make a folder
inside
/userdata/system/
/userdata/system/scripts
/userdata/system/scripts/first_script.sh
first_script.sh
#!/bin/bash
#This is an example file how Events on START or STOP can be uses
#
gameStop)
xrandr -display :0.0 --output DVI-0 --mode "640x480i"
xrandr -display :0.0 --output DVI-0 --scale-from "640x480i"
;;
esac
Explanation: When the game exit it will return to the boot resolution we set in syslinux.cfg and also
recenter the image.
Finish with
batocera-save-overlay
reboot
Let's start by using the same resolution in xrand –scale-from as show in the example above. In
this case 640x480i
We are going to manipulate the Screen Size X, Y & Screen Position X, Y of the
Emulationstation window.
Edit
userdata/system/batocera.conf
Go down to
## ES Settings
es.customsargs=--screensize 640 480 --screenoffset 00 00
–screensize [width] [height] = For a canvas smaller than the full resolution.
Start by looking at you picture to see if the image needs to be bigger or smaller. Change
–screensize 640 480 to a higher or lower value and change accordingly.
batocera-es-swissknife --restart
When you are satisfied with the result do the same for Screen Position by changing the values
–screenoffset 00 00
Right now we only have one usable modeline and that is 640x480i.
We would like to add more modelines for external Emulators like for example PS2, PSP, GameCube,
Wii, Wine (PC) and so on.
To do this we are going to use a program called Switchres made by Calamity that's now apart of
Batocera as of v30.
First we need to create a file named switchres.ini inside the folder /usr/bin/
nano /etc/switchres.ini
#
# Switchres config
#
# Set the operational refresh range for LCD monitor, e.g. lcd_range 50-61
lcd_range auto
# Forces an user mode, in the format: width x height @ refresh. Here, 0 can
used as a wildcard. At least one of the three values
# must be defined. E.g. user_mode 0x240 -> SR can freely choose any width
based on the game's requested video mode, but will
# force height as 240.
user_mode auto
#
# Display config
#
# Lock system (non-custom) video modes, only use modes that have full
detailed timings available
lock_system_modes 0
#
# Custom video backend config
#
# [X11] adjusts the crtc position after a new video mode is set, maintaining
the relative position of screens in a multi-monitor setup.
screen_compositing 0
# Pass a custom video timing string in the native backend's format. E.g.
pstring timing for Powerstrip
custom_timing auto
#
# Logging
#
Finish with
batocera-save-overlay
There are several types of Monitor types to choose from. Here is just a selected few. The one we are
going to use is arcade_15 that works good for a standard crt. generic_15 is also a good alternative.
If your display device does not match one of the built-in presets, then you'll need to use the custom
monitor type here
We have now generated the modeline based on our monitor preset arcade_15.
Modeline "320x240_60 15.660000KHz 60.000000Hz" 6.514560 320 333 364 416 240
242 245 261 -hsync -vsync
"320x240_60" 6.514560 320 333 364 416 240 242 245 261 -hsync -vsync
Edit
etc/X11/xinit/xinitrc
Go down to
########################
#####-CRT CONFIG-#######
########################
##-Default Resolution-##
########################
xrandr -display :0.0 --newmode "640x480i" 13.10 640 664 728 832 480 484 490
525 interlace -hsync -vsync
xrandr -display :0.0 --addmode DVI-0 "640x480i"
xrandr -display :0.0 --output DVI-0 --mode "640x480i"
########################
########################
Example
########################
#####-CRT CONFIG-#######
########################
##-Default Resolution-##
########################
xrandr -display :0.0 --newmode "640x480i" 13.10 640 664 728 832 480 484 490
525 interlace -hsync -vsync
xrandr -display :0.0 --addmode DVI-0 "640x480i"
xrandr -display :0.0 --output DVI-0 --mode "640x480i"
########################
#####-Modelines-########
########################
xrandr -display :0.0 --newmode "320x240_60" 6.514560 320 333 364 416 240 242
245 261 -hsync -vsync
xrandr -display :0.0 --addmode "320x240_60"
Finish with
batocera-save-overlay
reboot
Modelines
Calculate Resolution using setting in switchres.ini and force the generation of the modeline
switchres 854 480 60 -f 854×480@60 -i switchres.ini -c
Super Resolutions
2560×240@60
2560×248@58
2560×256@57
2560×264@55
2560×272@54
2560×280@52
2560×288@51
2560×448@60
2560×464@60
2560×480@60
2560×496@58
2560×512@57
2560×544@54
2560×560@52
Emulator/Wine/PC
240×240@60
256×192@60
288×224@60
320×180@60
320×200@60
320×240@60
320×240@60i
320×256@55
320×256@60
352×240@60
360×200@60
360×240@60
380×284@60
384×216@60
384×480@60i
400×240@60
416×240@60
426×240@60
428×240@60
456×256@55
460×200@60
464@272@50
480×270@50
480×270@60
480×272@60
512×480@60i
640×240@60
640×360@60
640×480@60
640×480@60i
854×480@60i (4:3 from 16:9)
Retroarch now uses SwitchresSwitchres instead of the old method. Some changes have been made
but for the better.
Be sure you have configured your Switchres.ini before going any further in the Guide.
Retroarch will not work properly if used with overlays and shaders and we don't need to use them on
a CRT. We are going to disable them by default for all Emulators and set the default UI for Retroarch
to Rgui.
Edit
/userdata/system/batocera.conf
Add this
## CRT CONFIG
global.retroarch.menu_driver=rgui
global.retroarch.menu_show_advanced_settings = "true"
global.retroarch.menu_enable_widgets = "false"
global.integerscale=0
global.smooth=0
global.rewind=0
global.shaderset=none
global.autosave=0
global.bezel_stretch=0
global.bezel=none
##
—-
So if you want to have these enabled by default just leave them out.
Make a backup of
/userdata/system/configs/retroarch/retroarchcustom.cfg
/userdata/system/configs/retroarch/retroarchcustom.cfg.backup
Edit
/userdata/system/configs/retroarch/retroarchcustom.cfg
Add
menu_enable_widgets = "false"
menu_show_advanced_settings = "true"
Choose any libretro core and game inside Batocera using your gamepad or keyboard.
Choose any libretro core and game inside Batocera using your gamepad or keyboard.
Main Menu -- Settings -- Configuration -- Use Global Core Option Files [OFF]
Main Menu -- Video -- CRT SwitchRes -- Use High Resolution Menu (Optional)
Main Menu -- Video -- CRT SwitchRes -- CRT Super Resolution (Native,
1920,2560,3840)
Main Menu -- Video -- CRT SwitchRes -- CRT SwitchRes [INI]
Troubleshooting
Should anything go wrong during the configuration you can always delete your Core setting for a
specific core in the directory
/userdata/system/.config/retroarch/config/"Core_Name"
You can also complete remove the directory and start again (Only remove the retroarch folder)
/userdata/system/.config/
/userdata/system/configs/
batocera-es-swissknife --reset-ra
Lets' say you want to make Portable Consoles like GameBoy Advance not display an output resolution
of 480i but instead want do display it in progressive scan but still keep the correct aspect ratio.
Create a Core Override file for the emulator you are going to use. In this example we are going to use
mGBA.
/userdata/system/.config/retroarch/config/mGBA/
In this folder copy you switchres.ini file and rename it to the same name as the core override file
ending with .switchres.ini
/userdata/system/.config/retroarch/config/mGBA/mGBA.switchres.ini
# Forces an user mode, in the format: width x height @ refresh. Here, 0 can
used as a wildcard. At least one of the three values
# must be defined. E.g. user_mode 0x240 -> SR can freely choose any width
based on the game's requested video mode, but will
# force height as 240.
user_mode auto
Change it to
user_mode 320x240
The next step can be done via the Retroarch RGUI, but for easy of use and convenience we are going
to instead edit the core override file mGBA.cfg
custom_viewport_height = "160"
custom_viewport_width = "240"
video_scale_integer = "true"
By doing this we are overriding switchres scaling and instead forces a resolution of 320×240 and
placing the image of the perfectly scaled Gameboy Adcance in a black box/window.
More information on how use Core and directory overrides can be found here
Let's say you have a PC Crt Monitor and like to add the boot resolution 1024×768@60hz. This can be
done by using a custom Extended Display Identification Data (EDID).
This will use the Monitor preset pc_31_120 Pc Crt 31-120hz at 1024×768@60hz
Configure GroovyMame
We are now going to manually configure GroovyMame for use with a CRT.
mame.ini
plugin.ini
ui.ini
For this we need to download a Font called uismall.bdf. (Place the file uismall.bdf you just
download in to /usr/share/fonts/TTF )
batocera-save-overlay
fontpath .
Change it to.
fontpath /usr/share/fonts/TTF/
skip_gameinfo 0
uifont default
(Change to)
skip_gameinfo 1
uifont uismall.bdf
modesetting 0
(Change to)
modesetting 1
infos_text_size 0.75
font_rows 30
Change it to.
infos_text_size 1.00
font_rows 19
Let's choose Mame (GroovyMame) as the default emulator for Mame roms in Batocera.
EMULATOR: MAME
VIDEO MODE: AUTO
DECORATION: NONE
STRETCH BEZELS (4K & ULTRAWIDE): NONE
GRAPHICS BACKEND: AUTO
BGFX BACKEND: AUTO
BGFX VIDEO FILTER: AUTO
CRT SWITCHRES: ON
TATE MODE: AUTO (Change if you are rotating your TV/Monitor when playing in Vertical TATE
MODE)
By default dolphins aspect ratio for 4:3 is set to AspectRatio = 2 to force the aspect ratio to 4:3,
but this don't actually fill the screen on a CRT and will sometimes leave black borders on the left and
right sides. To solve this we need to edit the file dolphinGenerator.py and change the value for
Aspect 4:3 to AspectRatio = 3 to set the aspect ratio to “Stretch to window”.
Navigate to
/usr/lib/python3.9/site-packages/configgen/generators/dolphin/
Edit
dolphinGenerator.py
# Ratio
def getGfxRatioFromConfig(config, gameResolution):
# 2: 4:3 ; 1: 16:9 ; 0: auto
if "ratio" in config:
if config["ratio"] == "4/3":
return 2
if config["ratio"] == "16/9":
return 1
return 0
Change to
# Ratio
def getGfxRatioFromConfig(config, gameResolution):
# 3: 4:3 ; 1: 16:9 ; 0: auto
if "ratio" in config:
if config["ratio"] == "4/3":
return 3
if config["ratio"] == "16/9":
return 1
return 0
Finish with
batocera-save-overlay
From
# PanicHandlers displaymessages
dolphinSettings.set("Interface", "UsePanicHandlers", '"False"')
To
# PanicHandlers displaymessages
dolphinSettings.set("Interface", "UsePanicHandlers", '"False"')
dolphinSettings.set("Interface", "OnScreenDisplayMessages", '"False"')
Finish with
batocera-save-overlay
By default Batocera configgen is forcing notification messages. This can lead to unwanted effects
when trying to disable them in the retroarchcustom.cfg file as described here
/usr/lib/python3.9/site-packages/configgen/generators/libretro/
retroarchConfig['video_font_enable'] = '"true"'
Change to
retroarchConfig['video_font_enable'] = '"false"'
Finish with
batocera-save-overlay
This will completely disable the dynamic adjustment of resolutions and horizontal frequency that
switchres gives us and is highly not recommended.
With Switchres you can't use the emulators internal resolution up-scaling because that would
double/triple and so on the output resolution.
But what you can do instead is to launch the emulator in a fixed resolution like 640×480 for N64 then
upscale the image inside the emulator without using Switchres.
From:
https://wiki.batocera.org/ - Batocera.linux - Wiki
Permanent link:
https://wiki.batocera.org/user:rion?rev=1631066639