Skip to content

Conversation

@Fancy2209
Copy link

@Fancy2209 Fancy2209 commented Feb 4, 2025

Description

Adds a video mode for widescreen

Existing Issue(s)

Fixes #73

@Fancy2209
Copy link
Author

The cursor displays properly, but games seem to still have issues
image

@Fancy2209 Fancy2209 marked this pull request as ready for review February 5, 2025 10:23
@Fancy2209
Copy link
Author

Fancy2209 commented Feb 5, 2025

I believe this is now ready for review
Only tested VVVVVV as most SDL2 Apps use OpenGX and that also needs changes (guOrtho width has to be different from viewport width)
Can defineteley use some cleanup but I want to make sure I am not doing something wrong

Stuff was setting the viewport and scissor to 854
Renderer now only adjusts projection if it's trying to set the viewport to 640*480 (this feels like not the intended way but I haven't found a better one)
@Fancy2209
Copy link
Author

Fancy2209 commented Feb 5, 2025

Correction: NOW it's ready for review
imagem
I feel like the logic to adjust the orthoWidth on the SDL Renderer is wrong but multiple render targets are a pain since only what's rendered to the screen needs adjusting

@Fancy2209 Fancy2209 changed the title WIP: Widescreen Video Mode [OGC] WIP: Wii Widescreen Feb 5, 2025
@Fancy2209 Fancy2209 requested a review from mardy February 5, 2025 23:43
@Fancy2209
Copy link
Author

Fancy2209 commented Feb 6, 2025

Btw there's something wrong with the code for centering the window, on widescreen VVVVVVV is setting the window x pos to 207, seems related to SDL_WINDOWPOS_CENTERED_DISPLAY (the x was smaller when I sent the picture above but it changed and I haven't found out why )

@Fancy2209
Copy link
Author

Fancy2209 commented Feb 7, 2025

:)
(Pictured is 21:9, wanted to make sure out of the bat something other than 16:9 worked)
imagem

Example usage

SDL_setenv("SDL_OGC_ASPECT_RATIO", "21:9", 1); // Normal setenv works, but no reason to include an extra header if you include SDL in your code directly already

mind you the format is w:h and w > h needs to be true or it will not work since the math doesn't work for when the height is what has to change
Also you can have 2 floats like 21.5:10.1 but I am praying no app does that since no screen does that so it'd just never look right

@Fancy2209 Fancy2209 requested a review from mardy February 7, 2025 22:19
@Fancy2209
Copy link
Author

By the way, something that is really bothering me is that when I set the window to widescreen the mouse starts having pixels jitter, like depending where it is some pixels get cut off in one of the sides

@mardy
Copy link
Collaborator

mardy commented Feb 8, 2025

By the way just curious, why did you use the std lib directly for OGC_JoystickInit? I thougth that SDL was meant to use the SDL stdlib (as in getenv and strcmp instead of SDL_getenv and SDL_strcmp like the rest of the lib)

SDL is trying to be as portable as possible, so it redefines these functions to allow platforms to reimplement them, if needed. But for us it just introduces a slow-down, since while the stdlib functions can be optimized away from the compiler, the SDL equivalent can not (that's my guess, at least, since it does not know them). I would suggest avoiding them, unless you are writing code in the SDL common modules and you plan to submit it upstream.

{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;

// TODO: Should I make this only happen if the aspect ratio isn't 4:3?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To simplify things I suggest forgetting about the VI changes for now (have them in a separate PR later), because handing of the CONF_GetAspectRatio() is a bit orthogonal to setting the best video mode. It will make testing and reviewing easier, if we tackle one issue at a time.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Fancy2209
Copy link
Author

Fancy2209 commented Feb 9, 2025

I just tested Wii screen on my TV
692*460 is what worked, I have a component cable but I guess not good enough since I can't disable over scan (on LG TVs it's enabling Just Scan)
I guess I'll have to add an env var to optionally adjust for overscan :/

@Fancy2209
Copy link
Author

So since I can't just correct all viewports, what changes do I need to do appart from aspect ratio caching?

@mardy
Copy link
Collaborator

mardy commented Feb 17, 2025

So since I can't just correct all viewports, what changes do I need to do appart from aspect ratio caching?

I've been quiet on the last few days because I've got several conflicting thoughts, and I'm not even sure what the original problem is (or maybe, there's more than one). I've wanted to test this myself, but I'm busy with some other stuff now, so I've to wait a few more days to get my hands on this. Meanwhile, if you have time, you might be able to answer this question: how does the TV detects aspect ratio? If the TV is set to auto-detect the aspect ratio, is it possible from the Wii to set the mode in such a way that the TV detects it with the aspect ratio we want (4:3 and 16:9 only, obviously)?

As for the cursor being cut, well, that is because you are shrinking the image in order to compensate for the stretching operated by the TV set. I think that your change which sets the interpolation mode to linear should fix it, doesn't it?

@Fancy2209
Copy link
Author

Fancy2209 commented Feb 17, 2025

It's understandable to not have time
Let me answer your questions though
The issue was that if an app wanted to use widescreen, they couldn't, setting a window to 854 by 480 would just get cut off or get garbled. At one point I also tried to fix the issue that in 16:9 if an window wasn't a widescreen res it'd get streched, but I realized it wasn't worth it as it was a bit hacky and I wasn't happy with the results.
About the tv detection, it'll always be detected as 4:3, the Wii always outputs a 4:3 signal.

The cursor being set to linear made it be less noticeable but not 100% like it should, the homebrew channel cursor behaves much less weirdly

@Fancy2209
Copy link
Author

Any chance for a new review of this?

@DacoTaco
Copy link
Member

Any chance for a new review of this?

that should be depended @mardy i think. they are basically the sdl->ogc expert here i think :p

@mardy
Copy link
Collaborator

mardy commented Aug 27, 2025

Any chance for a new review of this?

Oh, actually now I would have some time to test this, so thanks for the ping :-) By the way do you have some tests apps for this, or did you only try with VVVVVV?

@Fancy2209
Copy link
Author

Fancy2209 commented Aug 27, 2025

Any chance for a new review of this?

Oh, actually now I would have some time to test this, so thanks for the ping :-) By the way do you have some tests apps for this, or did you only try with VVVVVV?

I used Neverball and had a Raylib Hello World sample working with it
Raylib and the sample build without changes using the SDL2 Backend as long as you disable raudio
Neverball worked but I had to add 854x480 as a option
mardy/neverball#1
though I think I based on the wrong branch as the one I modifed had mouse controls and not Accelerometer ones
VVVVVV I gave up on as correcting. It was getting Squished instead of beeing 4:3

@Fancy2209
Copy link
Author

Should I make a test app?

@mardy
Copy link
Collaborator

mardy commented Aug 28, 2025

Should I make a test app?

That would be helpful indeed!

@Fancy2209
Copy link
Author

Should I make a test app?

That would be helpful indeed!

How would I allow the aspect ratio to be changed if that has to happen before init though?

@mardy
Copy link
Collaborator

mardy commented Aug 29, 2025

Should I make a test app?

That would be helpful indeed!

How would I allow the aspect ratio to be changed if that has to happen before init though?

Just hardcode an aspect ratio, build the app, save it under a different name, change the aspect ratio in the code, build again :-) So we get two apps we can test.

@Fancy2209
Copy link
Author

Should I make a test app?

That would be helpful indeed!

How would I allow the aspect ratio to be changed if that has to happen before init though?

Just hardcode an aspect ratio, build the app, save it under a different name, change the aspect ratio in the code, build again :-) So we get two apps we can test.

ah I see
what ratios do you want?
4:3, 16:9 and 16:10?

@mardy
Copy link
Collaborator

mardy commented Aug 30, 2025

ah I see what ratios do you want? 4:3, 16:9 and 16:10?

I would only care about 4:3 and 16:9, personally.

@Fancy2209
Copy link
Author

ah I see what ratios do you want? 4:3, 16:9 and 16:10?

I would only care about 4:3 and 16:9, personally.

Fair
Something is broken, when I set the aspect ratio and test on dolphin something breaks if I set the env var, addr2line doesn't say where though

@Fancy2209
Copy link
Author

Fancy2209 commented Oct 6, 2025

@mardy Sorry for the wait, I got the code to not crash anymore, had done some mistakes when rebasing (that I'm not sure how they didn't throw a compiler error)

Pretty simple test, renders a Red Square at 0,0, Square maintains ratio but can be drawn in the right place when accounting the ratio

I think the slight strech in 16:9 is probably from me forcing 720 VI Width if the ratio is not 4/3, I guess it's not really worth it to keep that if we don't account for it anywhere?

169.dol
image
43.dol
image

Here's the Zip with the Dol's and Source
WidescreenSDL2Test.zip

@mardy
Copy link
Collaborator

mardy commented Oct 8, 2025

Here's the Zip with the Dol's and Source WidescreenSDL2Test.zip

Thanks @Fancy2209, that was useful! I modified it slightly, to actually draw a square, and not on the corner (where it could be cut), and also added a background color and a thin border (to understand whether the TV is cutting some rows / columns). Here's the modified main.c, in case you want to test it as well.

Unfortunately my TV is really awful, and it cuts a few rows off the top and the bottom (both if I set it to 4:3 or 16:9), so it's really hard to test this stuff with it. One thing I can definitely confirm, is that your fix to for the cursor distortion is correct :-)

But setting the VI width to the maximum causes several columns to be cut off the margins (on my TV, at least) and I don't even see the yellow border that I added, on the sides.

It would be nice if you could take a couple of pictures from your TV, one where you set the TV to 16:9, one to 4:3 (and change the aspect ratio environment variable in main.c accordingly). My TV is unfortunately useless to test this :-(

@Fancy2209
Copy link
Author

I'll hook up my Wii this weekend, I should definitely add some sort of Overscan adjustment though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants