pinHP edit modelines

# pinHP Arcade image

On Pi2SCART monitors, if there is no way to adjust the monitor itself, we can change the screen position (horizontal/vertical) on an individual base by altering modeline settings.

Let’s use Donkey Kong as example. Video mode according to Advance Mame’s game info:
256 x 224 (V) 60 Hz

In advmame.rc we look up the value for our game resolution.
We find the line

256x224x60/display_mode 320×224 (60.02 Hz)

which tells Mame, what to do with games running a 256×224 resolution at 60 Hz refresh rate. It tells Mame to use display_mode 320×224 (60.02 Hz).

We find the line

device_video_modeline “320×224 (60.02 Hz)” 6.4 320 321 352 407 224 229 236 262 -hsync -vsync # 15.72 kHz

which tells Mame how to set the video mode named “320×224 (60.02 Hz)”.

The group of the first four values 320 321 352 407 is for horizontal (long side) screen resolution, the second group 224 229 236 262 for vertical (short side) screen resolution.

Within each group, we change the second and third numbers by the same value. To shift the long side of the screen to the left (which is up on a vertical monitor), we increase the numbers. Let’s shift the whole screen image 20 pixels to the left on the long side of the monitor: We increase the numbers by 20:

device_video_modeline “320×224 (60.02 Hz)” 6.4 320 341 372 407 224 229 236 262 -hsync -vsync # 15.72 kHz

Now let’s additionally shift the image down on the short side of the monitor by subtracting 5 pixels:

device_video_modeline “320×224 (60.02 Hz)” 6.4 320 341 372 407 224 224 231 262 -hsync -vsync # 15.72 kHz

There are limitations: We cannot go below the first value or above the fourth value of each group. So, in our example, we cannot move the image down the short side anymore. 224 is the limit here.

Some games make use of “super resolution” settings, where Mame downscales the actual image. This is a workaround due to Raspberry Pi (up to 3B+) hardware limitations, making it possible to get almost exact resolutions and refresh rates. Usually we are more flexible in shifting the screen image as well.

We see modelines like
device_video_modeline “1920×240 (60.00 Hz)” 41.50 1920 2000 2288 2640 240 240 247 262 -hsync -vsync # 15.72 kHz

Since Mame scales the value of 1920 down by factor 6 to 320 pixels screen width, a horizontal shift by 1 pixel requires the value to be changed by 6.

Hint:
When a game is using a “super resolution”, if we TAB into the settings, unreadable small lines will be shown on a vertical monitor. We need to temporarily change the game’s resolution before entering the menu. While in the game, we press “.” (dot) or “,” (comma) to cycle through available resolutions, until the menu becomes readable. Then we can TAB in.

Adjusting the menu screen

To adjust screen positon of the pinHP menu, we need to edit the file config.txt on the SD card’s DOS boot partition.

We find the line
hdmi_timings=320 1 32 47 17 240 1 2 6 8 0 0 0 60 0 6400000 1 #240p #H-Rate 15.38kHz #V-Rate 60.10Hz

Here we need to change values #3 and #5 (32 and 17 in our example) for horizontal screen position, values #8 and #10 (2 and 8) for vertical position.
Be careful: If you ADD to one value, you have to SUBTRACT from the other and vice versa.