There was a lot of gp2x-specific code which was built for
all platform. For instance, the code was compiled for all
the platforms with the constant "TARGET_GP2X" defined.
This obviously had to be fixed.
It ensures that GMenu2X can restart after a SDL program segfaulted or crashed.
It also allow GMenu2X to exit without clearing the screen, so that the "loading" screen appears
until the launched binary starts using the framebuffer.
writeSkinConfig() had a very naughty bug when RGBA values were written
to config file unpadded. This lead to a problem that, for example,
0x00000080 was written as 0x00080 in config file (Somehow gmenu2x
reads and re-saves config on selection). This, in turn, led
to problem when reading skin config file in strtorgba function,
because it parses the color string in token of two symbols
(substr(0,2) and etc).
Instead of having the copy constructor convert to display format, the new
copy constructor preserves the pixel format and a separate method was
introduced to convert surfaces to display format.
The code was made more robust as well: it should no longer crash if the
wallpaper cannot be loaded.
I cheated a bit by declaring ASFont as friend, but all other outside
access now happens via methods.
I removed the "saveScreenshot" method since the code calling it is
commented out and I never heard anyone complain about missing this
feature.
If loading fails, the factory method returns NULL, while previously the
constructor would create a Surface object with a NULL "raw" field.
However, since most of the methods dereference "raw" without checking,
such a Surface would likely crash the application when used.
Use real double buffering instead.
I checked the SDL code and if the hardware cannot provide double buffering
it will use a shadow surface to ensure that a frame is not displayed until
it has been fully painted.
Also disable mouse cursor before opening the output surface. The reason it
was disabled after the surface was opened is that SDL on GP2X has a bug.
However, this means the cursor is visible for a short time during startup
which looks ugly.
The unnecessary alpha channel might harm performance but is not a big deal.
However, the fact that the alpha flag (bool) is somehow automatically
converted by C++ into a skin name (string) causes the entire screen to
stay black.
The black screen was fixed by removing the alpha flag.
For optimum blitting performance, the wallpaper surface is then converted
to the pixel format of the frame buffer.
Bug was introduced in 52c89d6005.
There is no point in precalculating something so cheap to recalculate.
Also, the majority of uses was to compensate for passing the wrong alignment argument.
This is useful when the files/directories lists are not cleared; then it is possible to define priorities between the files.
For instance, the skin "Default" will be shown only once, even if the directory "Default" exists both in the system and the user directories.
As the skin and translation loading functions does check both directories, there is no problem in doing that.