This commit implements a vertical menu widget, which should be quite a bit more flexible than
what we currently have.
It defines interfaces in order to respond to selection changes, show and hide. And has a i_item_widget
interface class to allow you to use custom item widgets.
This is done in preparation for adding a debug menu, in which I kinda want to add toggle options
while using the same vertical_menu widget.
Right now, vertical_menu is only used in Select_Menu. Needless to say that Select_Menu was reworked quite a bit.
Still, in terms of visuals or functionality, the changes should be invisible for now. I mean, I didn't do anything *new* with it yet.
This commit integrates the MaxMod sound engine into PTGB.
Some test code already existed, but now it's done for real.
I added a thin API wrapper in sound.c/sound.h to abstract the sound engine.
One of AquaticAlloy's test songs was added to the main menu as a proof of concept.
We may want to disable it before the actual merge though.
Instead of each macro being a ternary (which can't be constant folded),
the values are now stored sequentially.
Additionally, I use byte instead of int and made the tables static
-1300 bytes.
The problem was that our custom_malloc was not marking these functions as extern "C".
Therefore libc's malloc function and everything linked to it was still getting pulled into our
rom.
Fix: mark these functions as extern "C". This ensures that these functions aren't getting pulled in
from libc. This reduces our rom size by 3KB
This eliminates duplicate code. - Only maintain the code in one place!
To make sure the submodule is getting cloned too after cloning Poke_Transporter_GB, execute:
git submodule update --init --recursive
To update the submodule to a newer commit/different branch:
cd PCCS
git pull
git checkout <commit_or_branchname>
cd ..
git add PCCS
git commit
git push
The way it works is that a specific commit is tied to your Poke_Transporter_GB repository's PCCS folder.
LZ10 decompression is builtin to the GBA's bios, so we don't need ZX0. It's also significantly faster
(618 usec instead of 2311 usec in my personal benchmark code for decompression of the same data)
And it seems like by doing so, we saved 1 KB as well!
So, seems like replacing ZX0 is the right move.
The reason I didn't initially is because I misunderstood the documentation. I assumed LZ77UnCompWram could only uncompress into EWRAM, not IWRAM.
But it turns out it can do both.
And using standardized tools is usually better than using a custom implementation.
The only downside of this right now, is that we can no longer stream text tables through a smaller buffer than the entire decompressed size.
Anyway, things seem to work fine, so bye bye ZX0. It's been fun.
This commit moves payload_builder and the z80_asm code to the data-generator subproject in order to generate the gameboy payloads
at compile time instead of at runtime.
In addition, we select a couple of base payloads (more than 1 for compressibility's sake) and generate binary patches to transform them into
other payloads. We then generate a binary file with both the base payload and binary patches and compress these files with zx0.
This reduces the rom size by about 8 KB.
To protect the world from the soft float library...
To unite all arithmetic within our binary...
To denounce the evils of floating point precision...
To save more kilobytes - that's our vision....
(god this is cringe)
All floating point math has been eliminated, and replaced with
equivalent or near-equivalent fixed-point math.
sprite_data.cpp uses Q16, and get_rand_range uses a full Q32 to
ensure that the exact same results are generated as before, at
the cost of some inline assembly to do a umull (__aeabi_lmul is a
little excessive when the lower 32 bits are discarded)
This eliminates all of the expensive double precision float library,
saving a few kilobytes.
Additionally, the unneccessary parts of nanoprintf have been
disabled. There is no need for precision specifiers, long longs, or
floats.
I eliminated these fonts by redefining code from tte_init_chr4c.c and tte_main.c files in libtonc.
Both the original tte_init_chr4c and tte_init_base functions had some code to use either verdana9 or sys8Font as default if the user
did not specify a font instance.
But we don't need it.
To eliminate this code, we not only had to define a custom version that omits this code, but also had to redefine other functions from those .c files
in order to make the linker not try to pull in those .o files from libtonc and use our versions instead.
I found another way to optimize the rom space by implementing a custom malloc, free, realloc and calloc
function.
This reduces rom size by 3 KB and IWRAM usage by 1 KB. (elimination of __malloc_av). The original
implementation is much more complex and larger than it needs to be.
The custom malloc is implemented as a bitmap allocator. It keeps a bitmap to track which pages of the
heap are allocated. Like the original allocator, it uses the free space in EWRAM after the multiboot gba
rom. But unlike the original allocator, we control the size with CUSTOM_MALLOC_POOL_SIZE.
The custom malloc can be disabled with USE_CUSTOM_MALLOC.