Welcome! Log In Create A New Profile

Advanced

Porting an SDL game from Linux to the Wii

Posted by spookz 
Porting an SDL game from Linux to the Wii
May 04, 2009 08:18PM
Hi there,

Does anyone know where I might find some general advice about what parts of the code would need modifying in order for a game based on SDL to work on the Wii? Consider the changes needed so that the game can be controlled via a Wii controller as being obvious and taken for granted. Right now, I'd just be happy for the game to load and be able to modify the code so that the graphics the game uses can be loaded and used.

The game is here: [airpong.sourceforge.net]
It's really really basic, with SDL being the only requirement. I chose it for my first attempt specifically because of this fact.

Is this idea of mine too big a jump to expect to make easily? I was expecting it to be relatively easy. I'm hoping that I'm right and that I'm just lacking some small but important details. I've actually got it to compile OK, it just complains about not being able to load some graphics it needs, despite me being sure that I've included them in the .dol file via a tweak to the makefile.

Dennis



Edited 1 time(s). Last edit at 05/04/2009 08:19PM by spookz.
Re: Porting an SDL game from Linux to the Wii
May 04, 2009 11:04PM
It shouldn't be terribly difficult to get more-or-less working. About 2 weeks ago I started playing around with making my first real Wii game. It started out in console mode, but I eventually decided on porting it to SDL because it had most everything I'd want for a game. Even though I didn't know SDL prior to that, it only took me a day or two to port over the code.

To be honest, the differences between my Wii and PC version are minimal:

* Wiimote code is conditionally compiled
* A call to "fatInitDefault()" is conditionally compiled
* Wii-specific headers like gccore.h are conditionally included for the Wii
* I don't-yet-but-should conditionally change the paths to graphics files

Since you're having problems loading graphics, I'd see if you can get your program to load the graphics off the SD card instead of from the DOL. You'll need to include fat.h and run fatInitDefault() so that it can read from the SD card. After you do that, the program should load files like "file.ext" from the root of the SD card.

PS: What are you doing to include your graphics in the DOL? That sounds like it'd be pretty neat!

JigPu
Re: Porting an SDL game from Linux to the Wii
May 05, 2009 12:03AM
I guess I should say first of all that I'm guessing that something I did in the makefile means that data files are included in the dol. I'll have to compile twice, once with the changes and once without to confirm whether or not it really is the case.

I've not got access to my dev environment at the moment, and don't know when I'll get to tinker some more, but when I do I'll post in here what I did. I think my problems, if it did include the files in the dol, likely illustrate that it didn't do what I thought it did and I have to learn how to access them.

Is the root directory the default location where the wii will look for any files, then? I thought it was the folder where the dol is loaded from. It might just be a case of me sticking those files in the root folder :s
Re: Porting an SDL game from Linux to the Wii
May 05, 2009 12:19AM
I did it, sort of. I've got the game up and running on my Wii. I'm looking at it on my TV right now :-D

All I need to do now is sort out the controls, so it's possible to play the game, and then it will be my first wii homebrew release(well, port actually, but never mind) :-D

If there's many more games that are equally easy to port, then I'll do some more.
Re: Porting an SDL game from Linux to the Wii
May 05, 2009 12:26AM
Quote

Is the root directory the default location where the wii will look for any files, then? I thought it was the folder where the dol is loaded from. It might just be a case of me sticking those files in the root folder :s

yes that's default. What I do is create a little helper function :

char* make_path(const char* path_rel)
{
#ifdef _WII_
	static char abs_path[100] = {0};
	sprintf(abs_path,"sd:/apps/radiow/%s",path_rel);

	return abs_path;
#else
	return (char*)path_rel;
#endif

}

.....
image =  IMG_Load(make_path("my_image.png"));

Sorry, only registered users may post in this forum.

Click here to login