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.

No comments: