Overscan on CRT

Let’s start off with a clean slate and try this again with my latest setres file, its still in testing so no guarantees. Run each line that does not have a hash at the start as it’s a comment one-by-one in SSH.

# remove setres override.
rm /emuelec/bin/setres.sh
# remove cvbs internal res override.
rm /storage/.config/cvbs_resolution.txt
# clear ee_videowindow from emuelec.conf
sed -i "s|ee_videowindow=.*||g" /emuelec/configs/emuelec.conf

# get latest setres file.
wget https://raw.githubusercontent.com/Langerz82/EmuELEC/dev-amlogic-diff-res-fix/packages/sx05re/emuelec/bin/setres.sh -O /emuelec/bin/setres.sh
# add execute permissions.
chmod +x /emuelec/bin/setres.sh

# add a shift and resize to output resolution.
echo "60 20 659 459" > /storage/.config/480cvbs_offsets

That should be all you need to change and set 480cvbs in EmuStation and reboot. Each line should work and not produce an error. Best of luck.

updated one line was incorrect.

edi2: updated again sorry last line was wrong.


Window-2023-04-15 21_00_56


Looks very close to perfect now, now that text isn’t be chopped up I could probably get away with just making it slightly larger overall so it touches the sides.

Why did you choose the resolution 659x459 for the scaling? That isn’t the same aspect ratio as 640x480, I the first two arguments 60 20 did not actually change the ratio they are supposed to just shift it I thought.

Even weirder now that I think about it, that this picture appears to be too tall, but the ratio you put in the file is wider than 4:3.

Here is what it looks like on my actual PS1 for comparison.

It looks just slightly more zoomed in maybe and wider. I think the aspect ratio is incorrect on the android box.

Calculating offsets isnt easy man, there is a bit of math to work it out. Basically the devices output is 720x480, though your tv only likes displaying a portion of that, which can vary from tv to tv. Direct offsets which I used follow the format of: left pixel, top pixel, right pixel, and bottom pixel numbers.
If it can be zoomed just a little more I suggest this:

echo “56 15 655 464” > /storage/.config/480cvbs_offsets

I don’t think you will be able to get much more accurate than that. :stuck_out_tongue:

The numbers above preserve 4:3, the differences is it’s 600x450.

edit: corrected numbers.

or maybe try:
echo “55 18 664 461” > /storage/.config/480cvbs_offsets

I really don’t get why this process is so absurdly overcomplicated. The setres.sh file seems to indicate, now that you modified the values, that it’s rendering in 1076x768, scaling down to 640 x 480, but you are also telling me it is being output as 720x480, which then needs to be shifted and scaled again, but it’s also not clear what this left pixel top pixel right pixel scaling is actually doing either. Move the picture 55 pixels to the right, then 21 pixels up, then change resolution to 609 x 457? The command is unintelligible.

AFAIK PSX just outputs 640x480 interlaced, and it fits mostly correctly, why all the scaling and higher internal resolution shenanigans?

These devices were never meant to be used on CRTs what you are doing right now is just hacks to force it to do something that it was not meant to do. hence why its “so absurdly overcomplicated” while some devices might have AV outputs in the end all they are doing is converting a digital signal to analog it is not TRUE analog and for that to work the kernel needs to support it, since the kernel used in EE is meant for HDMI you get the idea. Now if you want to, you can always go deep into the kernel and add the support needed, but if you think these hacks are “so absurdly overcomplicated” well… I don’t think I need to mention how complicated it would be in the kernel itself.

1 Like

I wasn’t meaning to come off as flippant, I mean seriously what are these hacks doing? I’ve tinkered with technology and programming for decades and can’t even begin to imagine what operating with 4 different resolutions at once is accomplishing, or why the CRT being an analog device would require that. I do understand that this is a very niche thing, and that these devices aren’t that popular to begin with, so it’s not easy, it’s not the intended design, and nobody owes me anything here, so it’s not surprising to me that it’s an uphill battle an all, I just want to get some idea of what these commands are doing.

I also wonder if there is anything that is designed to work with CRT sans the literal PSX and PS2.

Like I said, hacks to make it do stuff that is not supposed to do, as you, we are also experimenting, there is no flip a switch and it will work, they are not meant for CRTs all of these steps are hacks, and so its trial-and-error kind of thing. framebuffer is being tricked into doing stuff it does not recognize, nothing more nothing less, but it does not mean that one size fits all unfortunately.

Makes sense I guess. It’s pretty much close enough in its current state, if its this much of a chaotic black box under the hood I’m not going to be perfectionist about it.

Thanks for the help!

I think I’m getting wonky results, it was pretty severely overscanned again when I tried this, but when I read the text file for 480cvbs_offsets it reads as a string with the quotes. Should it list as just numerical arguments? - PuTTY-2023-04-16 18_28_50

ah, the double quotes should be removed. Not sure why they are showing up, try just:

echo 56 15 655 464 > 480cvbs_offsets

And like shantigilbert just said, it is quite complicated what its doing. Internally it will run at 1024x768 by default then it gets scaled down and shifted, that resolution should be fine for most devices, and it’s ratio 4:3 is the same. NTSC was never really friendly and simple all TV’s had some degree of clipping. You can’t expect 100% perfect emulation. We can always change the internal resolution later anyway, first off we are trying to get the display dimensions correct.
Anyway see how it goes, hopefully it’s much better than the values supplied that had too much black border. If it is satisfactory I can include the same values inside the setres.sh file so you won’t have to mess with these values again.
If I had an NTSC TV I could work it out much quicker but sadly I don’t have one handy to test with. We use PAL TV’s here and even then not many around these days.

Results using echo 56 15 655 464 > /storage/.config/480cvbs_offsets

Results using echo 55 18 664 461 > /storage/.config/480cvbs_offsets

At this point it looks like it’s off by maybe 5-10 horizontal pixels on either side, it’s very very close. Compared to the PSX image, this one appears to be shifted down slightly too much, as there is much more room above the “Tactical Espionage Action” Text on the current setup than on the PSX. Probably just expanding the picture slightly and a slight shift up would do it.

echo 52 17 667 462 > /storage/.config/480cvbs_offsets

Note - this will break the aspect slightly, not by much though.

Just wondering does the TV itself have settings to move or zoom the picture? You might be able to fine tune that way.

It has some settings to do stretching, but I don’t want to touch them at this point because I already had to make significant modifications to make it fit PS2 correctly, it was quite off when I bought it.

I wonder if this new command will work with less shift and 1 pixel either way on resolution. What a weird system.

yes to move the screen left, right add or subtract from both the X-axis digits, 1st and 3rd. up and down is the 2nd and 4th.

so for 10 pixels down it would be add to the existing numbers:
10 0 10 0

for 10 pixels right it would be:
0 10 0 10

up and left would be the same except you have to subtract instead of add.

these offset follow the format:
X1 Y1 X2 Y2
They do not use width they are the exact pixels on which to start and which to end, on a 720x480 output screen, though your physical TV shows only the middle section, which is why the awkard pixel numbers.

So the width of the total picture should be the third value minus the first value, so 664-55 = 609. That would make the ratio of 609 x 443 = 1.37, not quite 4:3.

Is the idea that the visible game window is a 3:2 resolution that has been squeezed to 4:3, or is it a 3:2 picture zoomed in and shifted such that the sides are off screen?

If my understanding is right, X1 shifts the left side, X2 shifts the right side, if they are kept in exact proportion it just moves the entire 3:2 frame over to the right, if not it changes the aspect ratio and shifts it too.

Yep, that way is pretty much how it works. An exact 4:3 I don’t think will fit on your tv exactly. It could be possible your PS2 transformation settings have something to do with it. But if you get kind of close to 4:3 that should be ok, might not be pixel perfect but Analog TV’s don’t need pixel perfect anyway.

Shouldn’t I be keeping it 3:2, not 4:3, if the 4:3 video game is actually just the middle of a 3:2 frame?