Friday, March 5, 2010

What Does A Fea Look Like

Developing applications for the Wii

For Christmas my sister gave me a Nintendo Wii, which is not expected at all:) These days I've been "playing" around with it and I've created a simple little program to read the pulse of the WiiMote.

In this post I will explain how to install the development environment, how to make a simple program and run it on the Wii;)

The first is to install the development environment, devkitPRO (we only need the devKitPPC), which you can download free from its official website . Once installed we must set the environment variable "Wiil" with the ip of the Wii. To This option is to open a command interpreter (cmd) and type: set Wiil = tcp: 192.168.1.64 ip by replacing your course: P

After this we load the Programmers Notepad from the same command interpreter (which is variable that has the Wiil). Is in devkitPRO \\ Programmers Notepad \\ pn.exe

Once done, you have a hello world example devkitPRO \\ examples \\ wii \\ template \\ template.pnproj. Hello world code is well documented, which is much appreciated, but for clarity here will eliminate these comments, remember they are in sample code that comes with devkit:) The code I inserted just print the screen which button is pressed on the Wiimote, it would be as follows:

  
# include # include # include



# include static void * XFB = NULL;
static GXRModeObj * RMODE = NULL;

int main (int argc, char ** argv) {
VIDEO_Init ();
WPAD_Init ();
VIDEO_GetPreferredMode RMODE = (NULL);
XFB = MEM_K0_TO_K1 (SYS_AllocateFramebuffer (RMODE));
console_init (XFB, 20.20, RMODE -> fbWidth, RMODE-> xfbHeight, RMODE-> fbWidth * VI_DISPLAY_PIX_SZ)
VIDEO_Configure (RMODE)
VIDEO_SetNextFramebuffer (XFB)
VIDEO_SetBlack (FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
printf("\x1b[2;0H");
printf("I have been conquered by Carballude. Greetings master!");
while(1) {

WPAD_ScanPads();
u32 pressed = WPAD_ButtonsDown(0);

switch(pressed)
{
case WPAD_BUTTON_1:
printf("\nONE");
break;
case WPAD_BUTTON_2:
printf("\nTWO");
break;
case WPAD_BUTTON_PLUS:
printf("\nPLUS");
break;
case WPAD_BUTTON_MINUS:
printf("\nMINUS");
break;
case WPAD_BUTTON_A:
printf("\nA");
break;
case WPAD_BUTTON_B:
printf("\nB");
break;
case WPAD_BUTTON_UP:
printf("\nUP");
break;
case WPAD_BUTTON_DOWN:
printf("\nDOWN");
break;
case WPAD_BUTTON_LEFT:
printf("\nLEFT");
break;
case WPAD_BUTTON_RIGHT:
printf("\nRIGHT");
break;
case WPAD_BUTTON_HOME:
exit(0);
break;
}
// Wait for the next frame
VIDEO_WaitVSync();


} return 0;}


Now we can compile it with Tools -> Make. To run on the Wii we have only to enter the Homebrew Channel and from pn to use Tools -> Run. The Wii will receive the wireless program and load it automatically:)

If you have any questions, chances are that I have no clue how to fix it, but I'm sure the homebrew boys themselves. I encourage you to take a peek your wiki.

0 comments:

Post a Comment