Thursday, December 31, 2009

Finally! The all-text release

Today I integrated the last three text-mode-only modules left I had planned to integrate before starting work in the graphical part of Bennu: mod_sort, mod_mem & mod_timers.

This means that most of the non-graphics related part of Bennu for the Wii is now done -just in time to celebrate the new year- and now it's time for me to focus on the part of Bennu that you can actually show to other people.

I also updated mod_sound and fixed a couple of bugs I had put there.

Last but not least, I did the same offsetting for the GLOBALs as I had to do for the LOCALs.

Happy new year, and say welcome 2010: the year of graphics for Bennu in the Wii! :)

PS: Just like it happens with the MacOSX platform (which isn't compiling right now in Bennu but has a lot of supporting code inside) memory_total() and memory_free() are placeholders and always return 0. I might be able to implement those, but I am not sure.
PS2: The text-only modules I have not yet implemented fall in one of these categories:

  • Either they don't make sense in the Wii (mod_wm, mod_sys). These will just be a list of placeholder functions that will only return default values and run no code.
  • Or they provide functionality not always present in the Wii (mod_key, mod_cd).
  • They're mod_debug, This one is big&complex and even if it's very useful, I want to focus on the rest of Bennu first.

Monday, December 28, 2009

Upsss! mod_proc is now working

mod_proc seems to be working now. I will have to do more testing, but LOCALs such as FATHER seem to work now.
The problem was that when I inserted the code for the LOCALs defined in mod_proc, I had not taken into the account how their values where referred in the DCB (file offsets.h).

This was quite a complex bug in the sense that it would've been very hard for me to find. I have created a modified Makefile so that now I can compile and test most of the code without having to be in front of my Wii.
That helped a bit to find the bug but it was my brother who did most of the debugging this time, so thanks to him :)

So now, only mod_sort, mod_mem and mod_timers are left before I start with the graphical part of Bennu!

Sunday, December 13, 2009

mod_proc is in, but it has problems with signal...

mod_proc is now in, but there seems to be a problem with signal...
Processes seem to be affected by signal, but they won't die; their id changes but nothing else.
Also, when a process is called, their father local var is not set correctly (it's always set to 0).

let_me_alone does kill the processes that you didn't try to kill with signal before.

There's also some other function that I've not yet isolated that results in an unhandled exception...

Will have to look into this....

A bit of hacking with globals, locals and DLVARFIXUP, in general

I'm not having much time lately to work on Bennu, but today I got to hack a bit on it.
Basically, what I've done is finish the mod_sound module (remember some time ago I said there were some bits left?).

What I've one is implement the code that initializes the global variables. The mechanism is the same as used for initializing local vars, so those should be easy to do now, too.

This is, however, a more important change that it can appear to be, as this was basically the only thing I didn't really understand about the new Bennu modular architecture (as opposed to the old Fenix static design). This means that I can finally also try to finish mod_proc.

So I'm hoping on having all applicable non-video related modules done very soon so that I can start with the code that makes Bennu so great: graphics :)

Happy coding!

Saturday, November 28, 2009

Mod_dir is in & you don't want to move files

Mod_dir is in, just remember that you don't want to move files around the filesystem or rename them.... It seems like those functions won't work as we're dealing with a very minimal C library.
You can create those functions with Bennu code, though, by opening the destination file+copying contents+deleting original file.

Long time, a few modules

Got a bit of time to work on this today:

  • I worked a bit more on mod_proc. Now bgdc, bgdrtm and bgdi compile. I wouldn't say it's working yet, as there are some values that have to be defined at runtime that are not yet being defined, but it's a start.
    Also, this modules defines some LOCAL vars. They're defined right after the GLOBALs.
    A funny thing I noticed about how Bennu works is that these vars are defined, from within C code, with Bennu syntax. What that means is that the compiler adds that Bennu code in the Process declaration, as if you'd written it there.
  • Got mod_rand in. This one was really easy :)
  • Started working on mod_mouse. mod_mouse has no real code or definitions, all the code is in libmouse. It won't work, yet, as libmouse depends in the graphical part of Bennu and work on that has not yet started.
    The compiler & interpreter will, however, be fine with you messing around with the MOUSE struct. Obviously the values you'll get are default ones and won't bear any resemblance with your mouse's position.
  • Fixed a few warnings.
I plan on getting all the modules that don't depend in libgrbase in soon, make sure they work and then proceed with the remaining modules.

Wednesday, November 4, 2009

BennuGD-wii, "Comes With Music" edition

After the guys from SDL-Wii fixed the sound initialization code, sound is working better than ever (well, it's working for the first time).

To commemorate this event, I've uploaded a new version of BennuGD-WII code-named "Comes With Music". Basically, what this is is a version of Bennu that integrates the functionality found in mod_sound (minus a few bits related to the definition of these globals that I'll hopefully add sooner than later).

The code uploaded comes with a module tracker example song that will play when you unpack the contents of the archive to the APPS folder of your SD card and load it through the Homebrew Channel on your Wii, but the binary should allow playback of many other song formats: OGG, WAV, MP3, MIDI...

Hope you like it!

mod_sound might get fixed soon

Looks like I might be able to fix the problem with mod_sound soon. There was a bug in the SDL code for Wii that caused the sound to initialize incorrectly when trying to play an ogg sound... This resulted in a very crappy sound, as described here.
Will report on progress and upload some test code when I get time to test this.

PS: To clarify, the code is really inside the binaries I uploaded a few days ago, I just need to link that code to a newer revision of the SDL code and hopefully, that will give us sound support.

Sunday, November 1, 2009

Binary release for the Homebrew Channel with bundled happiness. mod_joy is in :)

Haven't fixed mod_sound yet, but I've included mod_joy and think it might be a good time to release a binary version of the package, as it starts to be usable.

I have provided, as with most modules, some test code for the functionality inside mod_joy.
This library has been a bit more difficult than previous ones to integrate, as I had to do a few new things:

  • mod_joy depends in libjoy, so I had to get libjoy working first.
  • libjoy depends in libsdlhandler, so I had to get libsdlhandler working first.
  • The initialization code for libjoy is a bit more complex than the one found in other libs, so I had to add some functions to the header for libjoy.c that declared the initialization and finalization functions.
  • That also made me think that the way I was initializating the module code was not correct (as I was doing it from within bgdi code, not bgdrtm code).
    So I moved all the initialization code into the correct place in core/bgdrtm/src/sysprocs.c.
  • Also, libsdlhandler gets in charge of updating the SDL event list (a "list" that keeps track of things that change and should be noted, like pressing a key in your keyboard, moving your mouse or using you joystick, to name a few). So it has a function that must be ran every FRAME.
    I had to find the way to tell bennugd-wii to do it.
    Basically, you just have to use hook_add() in the initialization code with the correct hook, but that hook was in modules/libsdlhandler/libsdlhandler.c, so I had to declare the HOOK in modules/libsdlhandler/libsdlhandler.h.
By the way, I must take the function declaration out of core/bgdrtm/src/sysprocs.c as the code is getting pretty nasty. I will probably create a header for every modules (that doesn't have it) to declare all those needed externs.

For the brave, I've released a package with a binary snapshot of today's SVN code and the test code.
You can directly use it in the Homebrew Channel provided you read the included README file.
You can get it from the project homepage here.
Hope you like it.

sound is crappy

I more or less integrated mod_sound into bennugd-wii. The functions are there, and sound playback starts, but the only sound playback is a horrible static noise.
It might be related to this advice on the SDL doc and other people seem to have this same problem...

I will post any updates when I get it working.

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.