Saturday, October 31, 2009

mod_file is in, in the form of a poem

I got mod_file inside Bennu.

The example code for this module is just the typical code that opens a file, read it's content and printf's -well, say()'s- it. As I had to choose some random text to put in the file, I chose José de Espronceda's famouse Canción del Pirata poem (instead of the typical lorem ipsum stuff; there's a small artist inside me :).

Also, I found a bug somewhere (libfat?). If you try to fopen() a file whose name is long, it will crash :(

Stay tuned for more updates on the Wii front.

SDL has now been initialized

I finally got a bit of time to get mod_time working.
The functions seem to work fine, so now the three functions it contains (ftime, get_timer and time) seem to work fine.

The nice thing is that this means that SDL is being initialized at the program startup. This is important as SDL is the main library behind Bennu, so it's always nice to see it not crashing.

I also added the test case for this library (examples/05_mod_time.prg, 04_mod_math.prg is missing, sorry for that) in case you wanna give it a try.

More updates to come.

Tuesday, October 27, 2009

mod_time in (will crash) and mod_proc thoughts

Spent a bit of time today getting mod_time to work with Bennu.
This module makes use of SDL for the ftime function, therefore I've had to make bgdi link to it.
bgdi will crash if you try to use it as it is (get_timer and time should work fine, though) because I SDL must be running for this function to work, and I don't yet initialize it, but that shouldn't be too hard to do.

Also, spent a few minutes looking at mod_proc. It defines a few LOCALs and GLOBALs, so I have to find the place where they belong to.

Stay tuned for more updates.

PS: re-reading this, get_timer will also crash, as it also uses SDL. Initializing SDL isn't hard to do, at all, so these crashes should be easy to fix.

Thursday, October 22, 2009

mod_math is in, or how to define constants

I just committed a new revision of the code that integrates mod_math.

For mod_say and mod_string, integrating the module involved:

  • Adding the function definitions and callback functions to the sysprocs table in core/include/sysprocs.h. This is easy because that info is already defined in the mod_*.c file and I just have to add a few other fields that are trivial to guess.
  • Adding the function prototype to core/bgdrtm/src/sysprocs.c. This is also quite trivial. I will probably add another header to the source base with the new function prototypes so that I don't spam the code too much.
  • Adding a #ifndef __STATIC__ block around the __bgdexport block in modules/mod_*.c so that code is ignored during compilation (as the functions are now declared in core/includes/sysprocs.h).
  • Modifying the Makefiles so that the appropriate files are compiled into bgdrtm.a
I chose to go with mod_math this time as it declares one global variable (the value of PI. For whatever reason, Bennu seems to define PI to 180 degrees instead of the classic 3.141592654.... radians, which is kind of weird) which is something mod_say and mod_string didn't do.
To define such constants you have to add them to the table in core/bgdc/src/main_core.c with the appropriate value, which involves copying the line directly from the module source code.

As you can see, its pretty straightforward to integrate modules inside Bennu once you understand how it's done.
Looking forward, I have to find where to define functions that are run on specific moments (most importantly, functions that are run each FRAME) for other modules that need such functionality like those drawing into the screen.

On the following days, I'll write and upload a test case for the functions included with mod_math and make sure it runs in my Wii as today's commit has not been tested in the real hardware yet.

Wednesday, October 21, 2009

Welcome to my worklog

Welcome to this worklog. Here I'll write about my progress with getting Bennu to work natively in the Wii.
If you want to know more about Bennu, go here and if you want to go to the project page for the port, go here.