Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Friday, April 8, 2011

How to use mod_wpad when compiling your code in other platforms

Following the entry on how to compile directly from the Wii's Homebrew Channel, I'd like to comment on a little "trick" that'll allow you to compile code that uses mod_wpad both on your computer and in your Wii.
The idea is to use preprocessor macros to "hide" the code when compiling in platforms other than the Wii.
Following with the meta.xml from that example, the new one would be as follows:


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<app version="1">
    <name>Compile Fancy Game</name>
    <coder>Your name</coder>
    <version>Version number</version>
    <release_date>Release date</release_date>
    <short_description>A short description.</short_description>
    <long_description>A longer description for the entry that'll compile your code.</long_description>
<arguments>
             <arg>boot.prg</arg>
             <arg>-o</arg>
             <arg>/apps/fancy_game/boot.dcb</arg>
             <arg>-D</arg>
             <arg>TARGET_WII</arg>
     </arguments>
</app>

That code would be pretty much like compiling your code in the PC like this:


bgdc boot.prg -o /apps/fancy_game/boot.dcb -D TARGET_WII

And in the code, where you do the mod_wpad import, you'd change it to:

#ifdef TARGET_WII
import "mod_wpad"
#endif


And, a little bit below that:

#ifndef TARGET_WII
#define wpad_is_ready(a) 0
#define wpad_info(a, b) 0
#define wpad_info_nunchuk(a,b) 0
#define wpad_info_classic(a,b) 0
#define wpad_info_guitar(a,b) 0
#define wpad_info_bb(a,b) 0
#define wpad_rumble(a,b) 0
#endif


The first block will only import mod_wpad in case the compiler defines the TARGET_WII macro, and that'll only happen in the Wii, if you adapted the code above.
The second block will void the wpad_* functions. For your program's logic, it'd be as if no Wiimote was connected.

Hope this helps you with the Nintendomax Wii Dev Competition 2011, where you can win a Nintendo 3DS console, and much more".

Happy coding!

Friday, March 25, 2011

Compiling your code directly from the Homebrew Channel

The recommended method for compiling BennuGD games in your Wii is by using wiiload to both upload your code and to execute commands there.
If your Wii is not connected to your Wifi network (or you don't have one) things get a bit more complicated and previously I created a method for compiling that was a bit complicated. Today I'm going to show you a simpler one.

First of all, make sure that your Homebrew Channel is updated as this method requires one of the latest versions available.

Then, we'll create two entries in your Homebrew Channel: one for the game itself and another one for compiling.
The first one is created just normally, and the boot.elf file that you must put there is the normalbgdi.elf file, as found in the latest available BennuGD release and you'd just copy all the game's resources there, as usual. The meta.xml file for that entry would be something like:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<app version="1">
    <name>Fancy Game Runtime</name>
    <coder>Your name</coder>
    <version>Version number</version>
    <release_date>Release date</release_date>
    <short_description>A short description.</short_description>
    <long_description>A longer, more detailed description of your game.</long_description>
</app>

Now, in the other entry (just another directory in the "APPS" folder of your SD card) you'd place your game's source code. The boot.elf file corresponding to that entry would be bgdc.elf from the release and the meta.xml file would go as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<app version="1">
    <name>Compile Fancy Game</name>
    <coder>Your name</coder>
    <version>Version number</version>
    <release_date>Release date</release_date>
    <short_description>A short description.</short_description>
    <long_description>A longer description for the entry that'll compile your code.</long_description>
<arguments>
             <arg>boot.prg</arg>
             <arg>-o</arg>
             <arg>/apps/fancy_game/boot.dcb</arg>
     </arguments>
</app>


Where, obviously, "/apps/fancy_game" corresponds to the location in your SD card for your game's runtime (the first entry in this example). Also, "boot.prg" is the name of your main source code file.

If everything went fine, you can now insert your SD card in your Wii and you should now see two entries: one called "Fancy Game Runtime" and another one called "Compile Fancy Game". When you click on the compilation entry, your code will be compiled and the DCB file will be generated -assuming BennuGD liked your code- in the runtime entry, which you can click right away to test your code.

This process won't save your from having to grab the SD card from your console, copying the new files and putting it back in your Wii, but I'm sure it'll somehow make testing easier for you.

Hope you liked it!

PS: Remember you can win a Nintendo 3DS console just for coding by entering the Nintendomax Wii Dev Competition 2011! Good luck to everyone!

Monday, January 31, 2011

Tutorial in french

Just writing to note that work will resume after I finish my exams (I plan to work on fixing FNT loading, improving input handling and Wiimotion Plus support).

Anyway, if you are new to the project and speak french, you might want to check out beredezebe's tutorial about working with BennuGD in the Wii here.