C++ or C?

Do any experienced Wii homebrew developers know whether C++ is the way to go, or if I should go with C? It seems like most of the libraries are written for C, so it might be a better idea to go with C. Also is C an easier language to learn? I do realize that the difference between C and C++ probably isn’t THAT much, but I guess its good to know which would be better for Wii (and possibly GP2X and Dreamcast) dev.

Thanks

Advertisements

June 24, 2008. Tags: , , , , , , , , , , , , . Uncategorized. 3 comments.

Good tutorials for total beginners

I didn’t realize that I was doing this, but when I looked back at my last post, I realized that I was using concepts (loops, if statements, boolean operators) that people with no prior programming experience would not be familiar with. So, in order to get up to speed, I suggest that people who are beginners to programming use the following tutorials:

Thanks

June 23, 2008. Tags: , , , , , , , , , , , , . Uncategorized. Leave a comment.

Baby steps

I’m using tutorials on CProgramming.com. They seem pretty good so far, but I’m still just on the first one.

A lot of what I knew from Java still seems to apply in C++, which helps, since that means I don’t have to go through the basics all over again. The first lesson I went through teaches the “cout” function, which is used to print instead of a print fuction. It also teaches variable declaration and operators with integers. If you’re not familiar with these concepts, you should probably go through the first lesson here.

I set up the Code::Blocks IDE for writing and compiling code for testing on my Windows PC. You can find a guide for doing that here. Its very simple; you pretty much just download the Code::Blocks IDE with the MinGW compiler and install. Once you open Code::Blocks, you can make a new project and start writing code. Press F9 to compile and run.

Using what I knew, I wrote this simple program:

#include <iostream>

using namespace std;

int main()
{

int lolcode = 0;
while(lolcode<10)
{
cout<<"Hello world! - Message number ";
cout<<lolcode;
cout<<"\n";
lolcode++;
}

cin.get();

}

It would output the following:

Hello world! - Message number 0
Hello world! - Message number 1
Hello world! - Message number 2
Hello world! - Message number 3
Hello world! - Message number 4
Hello world! - Message number 5
Hello world! - Message number 6
Hello world! - Message number 7
Hello world! - Message number 8
Hello world! - Message number 9

Process returned 0 (0x0)   execution time : 2.578 s
Press any key to continue.

Simple right? Now I tried running something really simple on the Wii. First, you’ll need to set up devkitPPC. This guide at WiiBrew.org will tell you how to set up devkitPPC on Windows. It also has links to guides for Mac and Linux at the bottom of the page.

The guide tells you how you should copy the template folder for the Wii application and compile it to test it. Go ahead and compile the .elf from the template. We’re going to launch the .elf wirelessly using The Homebrew Channel. I’ll assume you already have The Homebrew Channel installed.  Download this utility to your PC. Extract it, and open up the program. Select the .elf file you just compiled. Put in the IP address of your Wii (you can check this by hitting the Home button on your Wii remote after opening The Homebrew Channel. It’ll be listed at the top left.) Leave the Port field alone and have the Protocol set to “HB Channel”. Args should be left blank. Press “Send File!”, and you should see the application launch on your Wii, and “Hello World!” should be displayed on the screen. Press the Home button to exit back to The Homebrew Channel.

Now we can edit the Hello World template we just compiled with different code to test what we know. In the “helloworld” folder you had copied and pasted, go to the “source” folder. Rename template.c to template.cpp (since we’re using C++). Open up the template.cpp file. I added

#include <iostream>

to the top of the file with the rest of the includes. I also added a line containing

using namespace std;

below the includes. I’m not sure whether this is necessary, but I figured I should. Scroll down to where it says

if ( pressed & WPAD_BUTTON_HOME ) exit(0);

We can see now how we might be able to work with input from the Wii remote. I pulled up the wiiuse API and looked to see if I could make any sense of the code I saw in the template file. It looks like the API for Wiiuse has changed from when the library was included in devkitPPC, but its more likely that I just don’t fully understand the code I’m reading.

I decided to make it so that when I pushed a button, it would print something. So, I added the following lines:

if (pressed & WPAD_BUTTON_A)
{

cout<<"You pushed the A button \n";

}

“pressed” was defined as the controller having buttons pushed down. So, if buttons are pressed and if one of those buttons pressed is the A button on the Wii remote (WPAD_BUTTON_A), then “You pushed the A button” is printed on the screen.

Try this out yourself! Make the changes to template.c that I made, compile, and send it to your Wii. I know its not a big deal for a lot of developers, but being able to test input like this feels pretty cool.

So, like I said – this is all baby steps. Hopefully this helped out some of you. I’m going to continue learning and post more.

Thanks

UPDATE: I posted a video demonstration of what was done in this post

June 22, 2008. Tags: , , , , , , , , , , , . Uncategorized. 2 comments.

The Why

For some time, I’ve wanted to develop homebrew applications for the Wii. However, I’m not the best programmer, and the only language I’m currently familiar with is Java. I first tried learning Python, but that was getting boring. I figured Python on Wii would never really become nearly as usable as it is on PC, so I abandoned the prospect.

Now, I’m using tutorials to learn to develop for the Wii using C++. I’ll be posting snippets of code and such that little things I’ve learned (and for a while…they really will be very SMALL things). I hope that this blog will become a useful resource for those who also wish to learn to develop for the Wii.

Thanks

June 22, 2008. Tags: , , , , , , , , , , , . Uncategorized. Leave a comment.