Time for another update. No screen shot yet but soon.

Release Mode

I have spent quite some time figuring out why TGE would not start up when built in release mode, and to be honest I have not fixed the problem yet. I do know what is wrong though: The programmers of TGE has assumed that all local variables are put on the stack, which is also true on x86 and probably also with earlier versions of GCC. Remember TGE is old.

Unfortunately with the latest OS4.1 SDK, the GCC optimiser has changed and local variables might be put into registers. So when TGE tries to find the address of a local variable which has been put into a register, GCC generates strange code. I don’t know if this is a bug in GCC or what to make of it, but finding and fixing these problems has taken a long time and right I am stuck on a single issue where TGE wants to endian swap a double, write it to disk, read it back and endian swap it back. It sounds simple enough and it works fine when the optimiser is disabled, but with optimisations enabled it fails. Still looking into this.

Multithreading

At first I thought this was going to be difficult to get to work, because earlier trials had shown that TGE would lockup before main() was reached. Luckily it was quite simple:  My first implementation of the mutex wrapper in TGE was using the mutex implementation in pthreads, but it turns out that these mutex’s cannot be locked multiple times by the same task, which a lot of mutex implementations usually allow and which TGE relies on.

The solution was, of course, to use the mutex implementation in Exec which does allow for the mutex to be locked multiple times by the same task. Only requirement is that the mutex is unlocked as many times at it is locked, which TGE does, so no problem there.

I will be moving on, to the rendering bugs now and still try to fix the remaining optimisation bugs.