Welcome! Log In Create A New Profile


Trying to do true 16:9 mode in homebrew

Posted by iSubaru 
Trying to do true 16:9 mode in homebrew
September 19, 2014 01:14PM

I'm trying to make a *very* simple homebrew (few buttons, a little math, really) but I have bumped into that little problem, I have 16:9 aka widescreen TV now so 4:3 background would end up either centered or stretched (dunno what's worse).
I got the idea that maybe there is a way to load widescreen background without stretching it so with proper "IF" which I have found already on the forums, it would automatically load proper background depending on the screen.

The "IF" was delivered from this topic
and goes more or less like this
if (CONF_GetAspectRatio() == CONF_ASPECT_16_9) {
// do widescreen specific stuff
} else { // CONF_ASPECT_4_3 or error/unknown value
// do non-widescreen stuff
Exact attempt was like this:
if (CONF_GetAspectRatio() == CONF_ASPECT_16_9)
	// do widescreen specific stuff
	ML_SetBackgroundSize(&boardBGw, 850, 480);
else // CONF_ASPECT_4_3 or error/unknown value
	// do non-widescreen stuff
	ML_SetBackgroundSize(&boardBGs, 640, 480);
I have tried using MLLib because it was very simple and swift to use so far but I'm willing to use any other libraries/frameworks/other-stuff for this, it doesn't have to be MLLib.

The code I have tried was giving different results, either stretched and cut background or no background at all (the quoted version).

What else to add...
I have a component cable plugged into Wii and TV (finally, I tought I will get crazy with composite all this years).
Wii is set up to EDTV/HDTV 480p or whatnot (third option at Screen Type) and of course 16:9 mode.

If any other info is necessary I will try to provide it ASAP.

Thank You in advance and have a nice day


Fixed formatting in the code tags

Edited 1 time(s). Last edit at 09/19/2014 01:15PM by iSubaru.
Re: Trying to do true 16:9 mode in homebrew
September 20, 2014 06:38PM
I use GRRLIB because its the only thing I use really. lol but anyway.

This is what I do. Widescreen mostly seems to affect the 2d sprites.

    // 16:9 and 4:3 Screen Adjustment
    if (CONF_GetAspectRatio() == CONF_ASPECT_16_9) {

if it is in widescreen mode I change the x scale of all the sprites from 1 to a factor of 0.85

float engine_xscale(){
	if(engine_widescreen){		return 0.85f;	} else  return 1;

Now whenever I draw a sprite I adjust the x scale of the images (which seems to be what fzeroGX does). GRRLIB allows you to change the scale of the images you draw in 2d mode. This is how it works in GRRLIB. You might need to hack you own function into ML or one might already be there to allow you to adjust image scale.

GRRLIB_DrawImg( screen_center_x, screen_center_y, spritesheet_get_pointer(S_TITLE), 0, engine_xscale(), 1, background_col );

The Y scale can stay at 1 because it doesn't need to change. You can download and test the effect in a few of my games. You will notice the fonts, title graphic and menus are smaller because I use the same 0.85 to affect the width of the menus as well when I am widescreen mode. Try [wiibrew.org] it should show it

Edited 2 time(s). Last edit at 09/20/2014 06:41PM by owen.
Re: Trying to do true 16:9 mode in homebrew
September 21, 2014 02:07AM
Hm~ seems logical.
Do I get this right:
GRRLIB_DrawImg can be used to both draw background as well as sprites (and probably cursor-pointer)?
If so then it's pretty good, everything in one place ^_^

I'm trying to re-do the code now (I have to change for now background stuff to GRRLib way, for quick check, later maybe whole code, GRRLib seems to be up-to-date with devkit libraries).

It will take a bit of time, I must dig through GRRLIB documentation (which is pretty well organised).
I will edit post as the progress will be made :)

Thank You very much for help :)
Re: Trying to do true 16:9 mode in homebrew
September 21, 2014 02:26AM
Yes, it is used to draw everything 2d. Grrlib is simple to set up but it is also easy to modify you current library depending on your situation. I have a project called starfield on wiibrew that has source that u can use.
Re: Trying to do true 16:9 mode in homebrew
September 21, 2014 11:23AM
It looks like your boardBGw image might be 850x480? I don't know the limitations of the library you're using but it's generally a good idea to stick with dimensions that are multiples of 16, so try 848 instead of 850.
Re: Trying to do true 16:9 mode in homebrew
September 22, 2014 04:56PM
I have contacted with the author of the MLLib and he agreed that moving to GRRLIB is good idea since it's more updated &c.
Therefore I will do last few attempts with 848 instead of 850 or something and then update my libraries to latest GRRLIB (especially that there were some errors when trying to compile GRRLIB project, I suspect that one of things is some mysterious conversion of images to .c .h files which I couldn't do)

I will write as soon as I get some results :)
Re: Trying to do true 16:9 mode in homebrew
September 22, 2014 05:09PM
I mostly use png images directly. Saves a bit of conversion and update time (luckily grrlib can read them directly from disk). Also just use one set of images instead of different images for Widescreen. You don't want to add unnecessary complications to your homebrew project.

I did not see any real advantages to compiling you assets. You mostly get a big bol file and less stuff in your apps folder.
Re: Trying to do true 16:9 mode in homebrew
September 24, 2014 12:58PM
I hate to do many posts for little stuff so I will write one bigger this time in style of ship's logbook :P

Day 1:
Hmm true on that...
Even tough it's super small project (it won't reach 4 MB total or I will chew my socks), I will learn the "good way" of coding it and reading from the card.
The trick however is how to emulate it on Dolphin (shuffling all the time on real Wii is kind of painful even with Wiiload which is great).

Day 2:
I couldn't make it work for a moment, but as manual stated, as Linux user I made it :P
Now then, the very basic code compiles it's time to make it properly work mwahahaha (cough cough cough).

Day 3:
Finally after the best method out there called "trial and error", png images are finally being compiled into final .dol and .elf file.
It's for the time being, later the code will be rewritten to use images from SDCard because why not or just next project that will use more files, will load them from the SDCard

Day 4:
Just finished boiling water for some tea, time to code stuff...
It should take an hour or so for the working "beta" code, the rest will be making some more images and some more instructions...
The compiled file has for now 1,1 MB so seriously, even Nintendo DS can chew this *nom nom nom*
However the Tea comes first

Day 5:
Tea break is over...
I did the stuff with checking for widescreen as you said, however errors are splitting out of nowhere, the fragment looks like this:
Before main()
float engine_xscale();
Inside while(1) loop:
		if (CONF_GetAspectRatio() == CONF_ASPECT_16_9)
		// widescreen either 848x480 or 850x480, trial and error
		// do widescreen specific stuff
					return 0.85f;
				} else  return 1;
			GRRLIB_DrawImg( 0, 0, &boardBGs_png, 0, engine_xscale(), 1, 000000 );
The errors given are:
main.c:149:4: warning: passing argument 3 of 'GRRLIB_DrawImg' from incompatible pointer type
GRRLIB__lib.h:108:7: note: expected 'const struct GRRLIB_texImg *' but argument is of type 'const u8 (*)[]'

Day 6:
Found out that maybe I was mistaken, probably I should go this way:
Inside main(), before while(1):
   	GRRLIB_texImg *tex_boardBGs   = GRRLIB_LoadTexture(boardBGs_png);
   	GRRLIB_texImg *tex_boardBGw   = GRRLIB_LoadTexture(boardBGw_png);
And then...
inside while(1):
			GRRLIB_DrawImg( 0, 0, tex_boardBGs, 0, 1, 1, 0xFFFFFFFF );
			GRRLIB_DrawImg( 0, 0, tex_boardBGs, 0, 1, 1, 000000 );
The code compiled so time to try this...

Day 7:
Almost ok, the background is still a little bit "cut off" but less then on previous attempts...
I may be able to manage from this point somehow...maybe =D

Day 8:
It works for background manually, I mean for now without that engine_xscale checking but that's matter of time and a little bit of tinkering, duh...
I will check if that works for sprites, but I guess it will work pretty good :)
Thank You for the help and patience with ill fox like myself xD (I have caught a cold and some headache, I forgot the better word for that...but it's classic illness at the Autumn time...)
Arigatou Gozaimasu~

Edited 5 time(s). Last edit at 09/25/2014 01:40AM by iSubaru.
Sorry, only registered users may post in this forum.

Click here to login