-
-
Notifications
You must be signed in to change notification settings - Fork 17
[OGC] Add support for Custom Aspect Ratios #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ogc-sdl-2.28
Are you sure you want to change the base?
Changes from 27 commits
8eaebcf
37151df
62191d5
19e2688
e1f2bfd
6570d34
4a73bb7
fc69931
ab85398
d6efcad
4dc34db
7afc872
016de5f
a5d6187
7fc3f5c
052e287
027d5d2
5219b8f
d1b37b4
412eb51
e254a96
072708b
95c62a7
40e5e47
984d25b
ad259a7
a8beb9c
04d0218
9563a94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
|
||
#include <malloc.h> | ||
#include <ogc/color.h> | ||
#include <ogc/conf.h> | ||
#include <ogc/gx.h> | ||
#include <ogc/system.h> | ||
#include <ogc/video.h> | ||
|
@@ -87,13 +88,20 @@ static void OGC_VideoQuit(_THIS); | |
|
||
static void init_display_mode(SDL_DisplayMode *mode, const GXRModeObj *vmode) | ||
{ | ||
float aspect = OGC_get_aspect_ratio(); | ||
|
||
u32 format = VI_FORMAT_FROM_MODE(vmode->viTVMode); | ||
|
||
/* Use a fake 32-bpp desktop mode */ | ||
SDL_zero(*mode); | ||
mode->format = SDL_PIXELFORMAT_ARGB8888; | ||
mode->w = vmode->fbWidth; | ||
|
||
mode->h = vmode->efbHeight; | ||
if (aspect != 4.0f/3.0f) { | ||
mode->w = mode->h * aspect; | ||
mode->w = (mode->w + 1) & ~1; | ||
} else | ||
mode->w = vmode->fbWidth; | ||
switch (format) { | ||
case VI_DEBUG: | ||
case VI_NTSC: | ||
|
@@ -170,7 +178,8 @@ static void setup_video_mode(_THIS, GXRModeObj *vmode) | |
VIDEO_Flush(); | ||
|
||
VIDEO_WaitVSync(); | ||
if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); | ||
if (vmode->viTVMode & VI_NON_INTERLACE) | ||
VIDEO_WaitVSync(); | ||
|
||
/* Setup the EFB -> XFB copy operation */ | ||
GX_SetDispCopySrc(0, 0, vmode->fbWidth, vmode->efbHeight); | ||
|
@@ -287,6 +296,15 @@ int OGC_VideoInit(_THIS) | |
VIDEO_Init(); | ||
|
||
vmode = VIDEO_GetPreferredMode(NULL); | ||
vmode->viWidth = VI_MAX_WIDTH_NTSC; // VI_MAX_WIDTH is the same for all regions | ||
// set Center point | ||
if (VI_FORMAT_FROM_MODE(vmode->viTVMode) == VI_PAL) { | ||
vmode->viXOrigin = (VI_MAX_WIDTH_PAL - vmode->viWidth) / 2; | ||
vmode->viYOrigin = (VI_MAX_HEIGHT_PAL - vmode->viHeight) / 2; | ||
} else { | ||
vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - vmode->viWidth) / 2; | ||
vmode->viYOrigin = (VI_MAX_HEIGHT_NTSC - vmode->viHeight) / 2; | ||
} | ||
|
||
|
||
videodata->gp_fifo = memalign(32, DEFAULT_FIFO_SIZE); | ||
memset(videodata->gp_fifo, 0, DEFAULT_FIFO_SIZE); | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that GX_SetViewport and GX_SetScissor can be set to the EFB size (that is, we can consider
w
andh
to be in pixels), and if we want to play with the aspect ratio we can play with the width parameter passed to guOrtho.In other words, I would set leave the calls to GX_SetViewport and GX_SetScissor exactly as they were, then call OGC_get_aspect_ratio_dimensions right from within this function and call
Of course, this needs to be checked. :-) The thing is, if you pass the same values to both functions (GX_SetViewport and guOrtho) you get a 1:1 mapping, which is not what we want for widescreen cases (or for any case where the ratio is not 4/3).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave up aspect correcting apps that aren't using 16:9
Fixing this here would cause issues, as I've showed before it makes VVVVVVV less wide than it should.
The whole guOrtho thing being a new var really felt like a hack, and I think leaving it as is is the best approach, especially since some apps resize the viewport twice every frame and it will distort the image more than it should if we do it