On SCART monitors, if there is no way to adjust the monitor itself, we can change the screen position (horizontal/vertical), within certain limits, on an individual base by altering modeline settings. Stretching or squeezing is not possible. The same procedure is applicable to Arcade monitors as well, certainly, to fine tune video 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 320x224 (60.02 Hz)
which tells Mame, what to do with games running a 256x224 resolution at 60 Hz refresh rate. It tells Mame to use display_mode 320x224 (60.02 Hz).
We look up this display mode and find the line
device_video_modeline "320x224 (60.02 Hz)" 6.4 320 321 352 407 224 229 236 262 -hsync -vsync # 15.72 kHz
which tells Mame how to handle the display mode named 320x224 (60.02 Hz), how to actually output the analogue video signal to the monitor.
Following the 6.4 MHz pixel clock frequency, 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 "320x224 (60.02 Hz)" 6.4 320 341 372 407 224 229 236 262 -hsync -vsync # 15.72 kHz
Now lets additionally shift the image down on the short side of the monitor by subtracting 5 pixels:
device_video_modeline "320x224 (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 "1920x240 (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.
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.
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.