Welcome! Log In Create A New Profile

Advanced

I'm having trouble getting widescreen to work with libogc

Posted by TheCodingBrony 
I'm having trouble getting widescreen to work with libogc
March 31, 2014 04:24PM
I'm new to Wii homebrew programming and have been trying to get the hang of using devkitppc recently... No, I'm not some average newbie (despite my username sounding like one, just tryin' to be a lil' silly for fun :)) like what most new members are as I've been a hobbyist game programmer for 5 years and have also made some pretty impressive homebrew for the Sony PlayStation lately.

Anyway, I'm currently having trouble getting widescreen to work in my tiny GX test program because VIDEO_GetPreferredMode() doesn't seem to return the appropriate video mode parameters even though my Wii is set to run in Widescreen mode... Is it because libogc does not support it? Or do I have to do a fake 'anamorphic widescreen' trick which to me looks terrible because there is still a small boarder on the sides of the screen.

Any useful help will be gladly appreciated.
- TheCodingBrony
Re: I'm having trouble getting widescreen to work with libogc
March 31, 2014 08:22PM
VIDEO_GetPreferredMode() doesn't have anything to do with widescreen, it just selects the most appropriate video format (NTSC/PAL/PAL60).
Only anamorphic widescreen is supported by the wii since the internal/embedded framebuffer has a fixed maximum width of 640 pixels.
The overscan borders are controlled by the video encoder; they can be changed by adjusting the viWidth member of the GXRModeObj struct returned by VIDEO_GetPreferredMode() before passing it to VIDEO_Configure(). Maximum width is 720 pixels (before accounting for viXOrigin and any horizontal offset in the system settings) with larger widths having smaller black borders.
Re: I'm having trouble getting widescreen to work with libogc
April 01, 2014 02:23AM
Quote
tueidj
Only anamorphic widescreen is supported by the wii since the internal/embedded framebuffer has a fixed maximum width of 640 pixels.
Well, that's a stinker... Oh well, I mostly want to get rid of the borders anyway.

Thanks a lot for your helpful response. And by the way, how can I detect whether the Wii is set to normal or widescreen mode?

- TheCodingBrony
Re: I'm having trouble getting widescreen to work with libogc
April 01, 2014 04:03AM
You have to read the value from sysconf, if it is 0 then it's 4:3 (standard) and if it is 1 then it's 16:9 (widescreen). I believe there's a function part of libogc that lets you do that (should be in conf.c i think?) which is something like:
s32 SYSCONF_Get(const char *name, void *buffer, u32 length)
{
	u8 *entry;
	s32 len;
	if(!__sysconf_inited) return SYSCONF_ENOTINIT;
	
	entry = __SYSCONF_Find(name);
	if(!entry) return SYSCONF_ENOENT;
	
	len = SYSCONF_GetLength(name);
	if(len<0) return len;
	if(len>length) return SYSCONF_ETOOBIG;
	
	switch(*entry>>5) {
		case SYSCONF_BIGARRAY:
			memcpy(buffer, &entry[strlen(name)+3], len);
			break;
		case SYSCONF_SMALLARRAY:
			memcpy(buffer, &entry[strlen(name)+2], len);
			break;
		case SYSCONF_BYTE:
		case SYSCONF_SHORT:
		case SYSCONF_LONG:
		case SYSCONF_BOOL:
			memset(buffer, 0, length);
			memcpy(buffer, &entry[strlen(name)+1], len);
			break;
		default:
			return SYSCONF_ENOTIMPL;
	}
	return len;
}
s32 SYSCONF_GetAspectRatio(void)
{
	int res;
	u8 val = 0;

	res = SYSCONF_Get("IPL.AR", &val, 1);
	if(res < 0) return res;
	if(res!=1) return SYSCONF_EBADVALUE;
	return val;
}

That above code was in sysconf.c from AnyRegion Changer but should be in libogc by now.
Re: I'm having trouble getting widescreen to work with libogc
April 01, 2014 08:41AM
It's slightly different in libogc. Look in conf.h for function names, enums etc...

if (CONF_GetAspectRatio() == CONF_ASPECT_16_9) {
// do widescreen specific stuff
} else { // CONF_ASPECT_4_3 or error/unknown value
// do non-widescreen stuff
}

From my experience it's pretty safe to assume a widescreen tv will have a smaller overscan area so you can use that as a basis for expanding viWidth before calling VIDEO_Configure(), e.g. [code.google.com]
(Note that VI_MAX_WIDTH_NTSC == VI_MAX_WIDTH_PAL == VI_MAX_WIDTH_MPAL, they're all 720 pixels wide.)
Re: I'm having trouble getting widescreen to work with libogc
April 11, 2014 06:03AM
Just last week I realized that all I had to do is adjust the scaling factor of all my 2d images down to 85% when widescreen is active and solves the whole stretchy widescreen graphics problem in GRRLIB.
Sorry, only registered users may post in this forum.

Click here to login