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.
This avoids forgetting about it when doing a release.
I also modified the documentation to reflect this new name.
BONUS change: I also documented the cartridge swap reset problem in the README.md
Split up data-generator into payload-generator (PTGB) and table-generator (PCCS)
The reason for this is because we don't want the dependencies to the payload stuff in PCCS.
And the tables are embedded inside libPCCS now.
Because we want to use libPCCS as a proper static lib, we now use its new Makefile to build it
before we build Poke_Transporter_GB.
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.
- Fix make clean by adding -f flag when removing output.json
- Fix broken compress_lz10.sh script: it had a check to avoid compressing when the
input bin file hasn't changed. But the -nt operator also returns false if the output
file doesn't exist.
- Fix compilation error on conflicting u32 typedef: libtonc defines one and so does data-generator.
We shouldn't redefine it if the one from libtonc exists. The one in data-generator exists for compiling
the tool for pc.
- Fix Dockerfile. For some reason the Dockerfile was now failing because Ubuntu manages the python pip
packages. I fixed it with the --break-system-packages shortcut. It should be fine.
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.
Add a binary table format and convert the text entries into this format in text_helper/main.py. It then gets compressed with zx0.
The new text_data_table and streamed_data_table classes exist to read the various entries from this binary table. streamed_data_table specifically
exists to use a decompression buffer that is smaller than the actual binary table. But it requires a decompression buffer that is
still larger than ZX0_DEFAULT_WINDOW_SIZE (default: 2048 bytes) and will only be able to decompress in
chunks of (<decompression_buffer_size> - <ZX0_DEFAULT_WINDOW_SIZE>) bytes
Try to keep the binary text tables sufficiently small though, because since zx0 doesn't actually support random access,
getting to the last entry is significantly more expensive than reading the first one. And unless you use streamed_data_table,
it also requires <uncompressed_size> bytes of stack space, therefore IWRAM to decompress them.
I also had to rework script_array because it can no longer reference the strings directly. Instead we now reference the DIA_* "enum" values.
We also no longer store an array of script_obj instances, because these were getting stored in IWRAM since they're non-const global variables
originally. Instead we now have const arrays of script_obj_params structs, which should end up in .rodata -> therefore EWRAM.
Right now, script_obj only supports the PTGB text table (originally the dialogue array). But if the need arises to support other tables as well,
I'd consider adding a separate enum to script_obj_params to indicate the specific table.
The compilation process will also output .su files in the build folder from now on. These files indicate the stack frame size for every function in
every compilation unit, so be sure to check them from time to time. Note that they will only show the stack consumption for that specific function.
So to get the worst case stack consumption, you need to manually add all the functions in a certain stack flow.
libsysbase_libsysbase_a-handle_manager.o
So, I optimized the MOVESETS table to only store the "overriding" bits in the movesets of the evolutions
in relation to their base forms. That only improved compression slightly (about 300 bytes)
I also eliminated 4 KB of IWRAM usage by libsysbase_libsysbase_a-handle_manager.o because of the "handles"
buffer. We're not using it and we REALLY need our IWRAM. (and it also reduces the rom size with 4KB too!)