Batocera 15kHz Video Output
This guide only applies to Batocera v30/v31. For v32 and above, refer to the current guide.
Foreword
This Guide would not have been possible without the following people to name a few.
- jfroco's work to output Batocera on a Crts.
- rtissera's knowledge, enthusiasm and willingness to add 15khz patches.
- Calamity for his knowledge, drivers, tools, GroovyMame.
- D0023R Doozer continued work at adding 15khz to the linux kernel.
Pre-requisites
To achieve this on your setup, the following elements are needed :
- Wired Network Connection
- AMD/ATI/INTEL card with VGA or DVI-I connection
- Analog connection to your CRT/Monitor
- VGA → Scart/BNC/Component
- DVI-I → DVI-I to VGA adapter → Scart/BNC/Component
- Putty, WinScp and Notepad++ for editing or similar software.
Connecting the PC to the CRT
The first step is to be able to connect your Batocera computer to the CRT 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. This is very important.
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.
To solve this we have 4 options
- 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 BYOAC (Build Your Own Arcade Controls Forum)
- Use buttersoft's passthrough dongle based on gambaman's design in the link above.
- Flash you AMD/ATI card with ATOM-15.
Editing the configuration files
Change the main resolution
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 be able to modify the boot partition:
- Connect to Batocera using SSH. See : Access Batocera Linux via ssh for more informations.
- Make the boot partition writable : While still connected to the Pc type
mount -o remount,rw /boot
Then, we have to identify the video output we will be using
- Get your graphics card DVI/VGA output using the following command :
ls /sys/class/drm/
- this will return something like
card0 card0-DP-1 card0-DVI-I-1 renderD128 ttm version
- (In this example: DVI-I-1)
- To make the next step a little bit easier for windows users, connect to Batocera using WinScp and install Notepad++
- Search for the
syslinux
file to enable booting in low resolution- If legacy, the file will be at
/boot/syslinux.cfg
or/boot/boot/syslinux.cfg
- If UEFI, the file will be at
/boot/EFI/syslinux.cfg
or/boot/EFI/BOOT/syslinux.cfg
- Add the resolution for your graphic card output
video=YourCardOutput:640x480ieS
- In our example :
APPEND label=BATOCERA console=tty3 quiet loglevel=0 vt.global_cursor_default=0 video=DVI-I-1:640x480ieS
For other supported boot resolutions, see the documentation here: https://github.com/D0023R/linux_kernel_15khz
Disabling the other video output
Now we need to disable the displayport DP to get video exclusively out of the VGA/DVI-I port.
- Get your graphics card DP output using the following command :
ls /sys/class/drm/
- this will return something like
card0 card0-DP-1 card0-DVI-I-1 renderD128 ttm version
(in this example: card0-DP-1)
- Get your display output using xrand :
xrandr -display :0.0 | grep “connected”
- this will return something like
DisplayPort-0 disconnected primary (normal left inverted right x axis y axis) DVI-0 connected 655x500+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
(in this example: DisplayPort-0)
- We then need to create a config file in
/etc/X11/xorg.conf.d/
named10-monitor.conf
- Paste these line in to the file (replace the
Identifier
by the values you found previously) and save.Section "Monitor" Identifier "card0-DP-1" Option "Ignore" "true" EndSection Section "Monitor" Identifier "DisplayPort-0" Option "Ignore" "true" EndSection
Add Boot Modeline
Now we need to add the modeline “640x480i”
mount -o remount,rw /boot
This will make the partition writable so we can make the changes.
Edit
etc/X11/xinit/xinitrc
Go down to
##################### ## CUSTOMISATIONS ###
Add
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"
Example
<code> # xrandr -s 640x480 -r 60 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" ##################### ##################### </code>
—-
- Save the changes you made to batocera so far with
batocera-save-overlay
: When you edit anything outside of the SHARE partition, the changes are lost when rebooting unless this command is used. - Reboot the system : Your are now booting up in 640x480i
- Set your default video output to DVI-0 : MAIN MENU→SYSTEM SETTINGS→HARDWARE→VIDEO OUTPUT
- Reboot again.
Manage the EmulationStation Overscan and Centering
As you might have noticed there is some overscan and the picture in EmulationStation might not be centered. For this configuration you need to be able to look at your TV/Monitor directly to see the changes we are going to make.
We are going to use xrand and a funtion called –scale-from wxh xrandr --scale-from
Connect via SSH and from the terminal and type
xrandr -display :0.0 --output DVI-0 --scale-from 640x480
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
mount -o remount,rw /boot
This will make the partition writable so we can make the changes.
Edit
etc/X11/xinit/xinitrc
Go down to
##################### ## CUSTOMISATIONS ###
Add xrandr -display :0.0 –output DVI-0 –scale-from 640×480
Example
# xrandr -s 640x480 -r 60 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 --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/
called “scripts” and name it “first_script.sh”
/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 # #Set logfile location and filename #logfile=/tmp/scriptlog.txt #Case selection for first parameter parsed case $1 in # gameStart) # echo "START" > $logfile # echo "$@" >> $logfile # ;; gameStop) xrandr -display :0.0 --output DVI-0 --mode "640x480i" xrandr -display :0.0 --output DVI-0 --scale-from "640x480i" ;; esac
Make the script executable with chmod +x /userdata/system/scripts/first_script.sh
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
This will save the changes we made.
reboot
Advanced Fine Tuning
This will give you 1x pixel accuracy.
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.
mount -o remount,rw /boot
This will make the partition writable so we can make the changes.
Edit
etc/X11/xinit/xinitrc
Go down to
cd /userdata # es needs a PWD openbox --config-file /etc/openbox/rc.xml --startup "emulationstation --windowed ${EXTRA_OPTS}"
add and replace to this
cd /userdata # es needs a PWD openbox --config-file /etc/openbox/rc.xml --startup "emulationstation --windowed --screensize 640 480 --screenoffset 00 00 ${EXTRA_OPTS}"
–screensize [width] [height] = For a canvas smaller than the full resolution.
–screenoffset [x] [y] = Move the canvas by x,y pixels.
Start by loking 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.
Finish with
batocera-save-overlay
This will save the changes we made.
reboot to see the changes.
When you are satisfied with the result do the same for Screen Position by changing the values –screenoffset 00 00
Finish with
batocera-save-overlay
This will save the changes we made.
reboot to see the changes.
Configure Libretro Cores for use with Crt Switchres
mount -o remount,rw /boot
Edit
/userdata/system/batocera.conf
Add this
## Configurations generated by Batocera.linux" global.integerscale=1 global.smooth=0 global.retroarch.menu_driver=rgui
Finish with
batocera-save-overlay
This will save the changes we made.
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"
This will disable On-Screen Notifications and is optional
menu_show_advanced_settings = "true"
Configure Libretro CRT switchres in RetroArch
Choose any libretro core and game inside Batocera using your gamepad or keyboard.
Example: Core: Atari 2600 Game: H.E.R.O.
Access the menu and configure (in this order):
Main Menu -- Settings -- Configuration -- Save Configuration on Quit [ON] Main Menu -- Video -- Bilinear Filtering [OFF] Main Menu -- Video -- Scaling --Integer Scaling [ON] Main Menu -- Video -- Scaling --Aspect ratio 4:3 Main Menu -- Video -- CRT SwitchRes -- Use custom Refresh Rate [ON] Main Menu -- Video -- CRT SwitchRes -- CRT Super Resolution: 1920/2560/3830/Native/Dynamic (Dynamic is preferred) Main Menu -- Video -- CRT SwitchRes -- CRT SwitchRes [ON]
It should change to 240p/480i
Now you can adjust your scaling
Main Menu -- Video -- Scaling
Finally, save the configuration for this core:
Quick Menu -- Overrides -- Save Core overrides
Do the same with the other libretro cores.
Adding Modelines (Read Resolutions) for Emulators
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/
From the terminal type
mount -o remount,rw /boot nano /usr/bin/switchres.ini
Paste this into the file
# # Switchres config # verbose 0 monitor generic_15 crt_range0 auto crt_range1 auto crt_range2 auto crt_range3 auto crt_range4 auto crt_range5 auto crt_range6 auto crt_range7 auto crt_range8 auto crt_range9 auto lcd_range auto modeline auto user_mode auto # # Display config # display auto api auto lock_unsupported_modes 1 lock_system_modes 0 refresh_dont_care 0 keep_changes 0 # # Modeline generation config # modeline_generation 1 interlace 1 doublescan 0 dotclock_min 0 sync_refresh_tolerance 2.0 super_width 2560 aspect 4:3 v_shift_correct 0 pixel_precision 1 # # Custom video backend config # screen_compositing 0 screen_reordering 0 allow_hardware_refresh 0 custom_timing auto
then end with crtrl+x to save and type Y then enter.
Finish with
batocera-save-overlay
This will save the changes we made.
There are several types of Monitor types to choose from. Here is just a selected few. The one we are going to use is generic_15 that works good for a standard crt. arcade_15 is also a good alternative.
generic_15 = Generic 15.7 kHz arcade_15 = Arcade 15.7 kHz - standard resolution pal = PAL TV - 50 Hz/625 ntsc = NTSC TV - 60 Hz/525 arcade_15ex = Arcade 15.7-16.5 kHz - extended resolution pc_31_120 = PC CRT 70kHz/120Hz pc_70_120 = PC CRT 70kHz/120Hz
In this example we are going to generate the modeline 320×240@60hz
switchres 320 240 60 -i switchres.ini -c Switchres: Modeline "320x240_60 15.660000KHz 60.000000Hz" 6.514560 320 333 364 416 240 242 245 261 -hsync -vsync
We have now generated the modeline based on our monitor preset generic_15.
Copy the modeline and save it temporarily to a text file.
Modeline "320x240_60 15.660000KHz 60.000000Hz" 6.514560 320 333 364 416 240 242 245 261 -hsync -vsync
Lets make it easier to read in EmulationStation and shorten the name.
Modeline "320x240_60" 6.514560 320 333 364 416 240 242 245 261 -hsync -vsync
Now we need to add the modeline to
etc/X11/xinit/xinitrc
mount -o remount,rw /boot
This will make the partition writable so we can make the changes.
Edit
etc/X11/xinit/xinitrc
Go down to
##################### ## CUSTOMISATIONS ###
Example
# xrandr -s 640x480 -r 60 xrandr -display :0.0 --newmode "320x240_60" 6.514560 320 333 364 416 240 242 245 261 -hsync -vsync xrandr -display :0.0 --addmode DVI-0 "320x240_60" 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 --scale-from 640x480 ##################### #####################
Finish with
batocera-save-overlay
This will save the changes we made.
reboot
Creating you own Boot Resolution with Switchres
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
switchres 1024 768 60 -m pc_31_120 -e
The file will be named pc_31_120.bin
.
- Create the folder
mkdir /lib/firmware/edid/
- Move the file
mv pc_31_120.bin /lib/firmware/edid/
- Search for the
syslinux
file- If legacy, the file will be at
/boot/syslinux.cfg
or/boot/boot/syslinux.cfg
- If UEFI, the file will be at
/boot/EFI/syslinux.cfg
or/boot/EFI/BOOT/syslinux.cfg
- Replace the boot resolution with your edid file
video=YourCardOutput:e drm.edid_firmware=YourCardOutput:edid/pc_31_120.bin
- In our exemple :
APPEND label=BATOCERA console=tty3 quiet loglevel=0 vt.global_cursor_default=0 video=DVI-I-1:e drm.edid_firmware=DVI-I-1:edid/pc_31_120.bin
Modelines
Here are some resolutions to use
- Calculate Resolution using Monitor generic_15
switchres 320 240 60 -m generic_15 -c
- Calculate Resolution using setting in switchres.ini
switchres 320 240 60 -i switchres.ini -c
- 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)
Configure GroovyMame
As of Batocera v30 we now have GroovyMame support.
We are now going to manually configure GroovyMame for use with a CRT.
- Go to the mame folder using the command
cd /usr/bin/mame
- Generate the ini files needed
./mame -cc
- this will create the following files
mame.ini plugin.ini ui.ini
(Now we need to move them)
- Create the folder
mkdir /userdata/system/.mame/
- Move the files
mv /usr/bin/mame/*.ini /userdata/system/.mame/
- Making GroovyMame's Gui display correctly on a CRT.
mount -o remount,rw /boot
- For this we need to download a Font called Hack. (Place the folder
TTF
you just download in to/usr/share/fonts
)
batocera-save-overlay
Now let's configure GroovyMame.
- Edit mame.ini using nano :
nano /userdata/system/.mame/mame.ini
or Notepad++ for example.- # CORE SEARCH PATH OPTIONS
fontpath .
- Change it to.
fontpath /usr/share/fonts/TTF/
- # CORE MISC OPTIONS
skip_gameinfo 0
uifont default
(Change to)
skip_gameinfo 1
uifont Hack-Regular.ttf
- # OSD FULL SCREEN OPTIONS
modesetting 0
(Change to)
modesetting 1
- Edit ui.ini using nano :
nano /userdata/system/.mame/ui.ini
or Notepad++ for example. - # UI OPTIONS
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.
MAIN MENU→GAMES SETTINGS→DEFAULT SETTINGS→PER SYSTEM ADVANCED CONFIGURATION→Mame
- 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)
- batocera-and-crt-old.txt
- Last modified: 3 years ago
- by atari