Commit Graph

537 Commits

Author SHA1 Message Date
Philippe Symons
00261cd8d8 Merge branch 'optimizations/reduce-binarysize-remove-libstdc++' into optimizations/implement-zx0-compression 2025-05-28 21:07:36 +02:00
Philippe Symons
a261760c59 Fix regression
ptgb::vector::resize() had a bug which caused it to incorrectly add/erase elements.

The reason was a loop end condition that was modified during iterations of said loop. This end condition
was intended to be static, but because it used a variable that was modified during the loop, it didn't
repeat the intended number of times.

Fix: before starting the for loop, calculate the end condition once.
2025-05-28 21:04:45 +02:00
The Gears of Progress
42815f166f Starting to add sprite compatibility 2025-05-27 16:48:04 -04:00
Philippe Symons
53662cff9d Merge remote-tracking branch 'upstream/text-and-box-rewrite' into optimizations/reduce-binarysize-remove-libstdc++ 2025-05-27 22:44:18 +02:00
Philippe Symons
13d4b3f7d5 Fix ptgb_write_debug() after merge 2025-05-27 22:39:16 +02:00
Philippe Symons
7f20f6f58e Merge remote-tracking branch 'upstream/text-and-box-rewrite' into optimizations/implement-zx0-compression 2025-05-27 22:31:05 +02:00
The Gears of Progress
03c3e0540b Applying patch for graphics issues 2025-05-27 15:13:42 -04:00
Philippe Symons
ce4c807bab Merge branch 'optimizations/reduce-binarysize-remove-libstdc++' into optimizations/implement-zx0-compression 2025-05-25 22:45:47 +02:00
Philippe Symons
1d77f8f848 Merge remote-tracking branch 'upstream/text-and-box-rewrite' into optimizations/reduce-binarysize-remove-libstdc++ 2025-05-25 22:45:26 +02:00
Philippe Symons
9c7288702c Fix merge compile error 2025-05-25 22:40:53 +02:00
Philippe Symons
6d60fb8901 Merge branch 'optimizations/reduce-binarysize-remove-libstdc++' into optimizations/implement-zx0-compression 2025-05-25 22:34:45 +02:00
The Gears of Progress
e5375b9155 Fixing post-transfer text box 2025-05-25 15:41:09 -04:00
Philippe Symons
c918f20f19 Merge remote-tracking branch 'upstream/text-and-box-rewrite' into optimizations/reduce-binarysize-remove-libstdc++ 2025-05-25 21:03:59 +02:00
The Gears of Progress
dd0dc20837 Fixing sprite corruption and adding game pak sprite debug toggle 2025-05-25 13:00:07 -04:00
The Gears of Progress
868b23ba45 Disabling new conversion 2025-05-21 11:43:16 -04:00
Philippe Symons
a8d2575f5d Move reading dialogue text out of the text_loop() to conserve IWRAM 2025-05-21 17:39:52 +02:00
Philippe Symons
903ccb0d21 Some minor optimizations 2025-05-21 17:29:12 +02:00
Philippe Symons
851be36b0d Merge branch 'master' into optimizations/implement-zx0-compression 2025-05-21 13:16:45 +02:00
Philippe Symons
26fd1e2dd3 Add compression for the text data, output stack usage .su files and rework script_array
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.
2025-05-21 12:21:06 +02:00
Philippe Symons
12d1d10fc7 Revert MOVESETS -> bring it back as uncompressed data in pokemon_data.cpp
... and add a comment why.
2025-04-30 12:41:46 +02:00
Philippe Symons
4c93ff869c Optimize the MOVESETS table for compression + eliminate 4 KB "handles" buffer from
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!)
2025-04-29 22:22:38 +02:00
Philippe Symons
8e55a2bd52 Bundle charsets per gen for slightly better compression and move some tables back as uncompressed
The ones I moved back as uncompressed tables (EVOLUTIONS and gen_1_index_array) simply didn't compress well
at all. It wasn't worth the runtime decompression cost.
2025-04-28 20:47:55 +02:00
Philippe Symons
652f781454 More optimization: move code to IWRAM.
We can now decompress a 512 byte charset in 1 ms. (well, 1.370 ms to be exact)
2025-04-28 12:34:19 +02:00
Philippe Symons
75f8e5a26a More optimization:
Remove the RingBuffer entirely.

We can now decompress 512 bytes in 3 ms.
2025-04-27 23:32:02 +02:00
Philippe Symons
0b5bd11680 More speed optimization
Although the fact that I'm now using -O2 for zx0_decompressor will probably make the binary size larger
2025-04-27 01:03:25 +02:00
Philippe Symons
08454cd1fa Optimize zx0 decompression for speed instead of code size:
- Read more than 1 byte at a time: read by uint32_ts
- Make use of the native uint32_t type for the whole algorithm instead of uint16_t
2025-04-26 23:15:54 +02:00
Philippe Symons
67797daf66 Merge branch 'master' into optimizations/reduce-binarysize-remove-libstdc++ 2025-04-24 21:26:14 +02:00
Philippe Symons
532a095d77 Implement zx0 compression
Compress data tables with the ZX0 compression algorithm
2025-04-24 21:14:48 +02:00
The Gears of Progress
dac8939373 Updating pokemon.cpp 2025-04-21 11:29:54 -04:00
The Gears of Progress
a98262b852 Merge branch 'master' of https://github.com/GearsProgress/Poke_Transporter_GB 2025-04-21 11:28:42 -04:00
The Gears of Progress
92020b228d Starting implementation of transfer options 2025-04-21 11:28:33 -04:00
The Gears of Progress
20c5b93f66
Update pokemon.cpp 2025-04-21 11:27:48 -04:00
The Gears of Progress
50520724e8
Merge pull request #40 from risingPhil/documentation/add-EZ-Flash-documentation
Add EZ Flash Omega Definitive Edition documentation
2025-04-12 13:32:20 -04:00
Philippe Symons
061591d691 More words and images 2025-04-10 13:34:48 +02:00
Philippe Symons
0249f073d5 Words 2025-04-10 13:31:44 +02:00
Philippe Symons
8cd0088d7d Add some documentation about using the EZ Flash Omega Definitive Edition flashcart with PTGB. 2025-04-10 13:26:17 +02:00
Philippe Symons
ba8738fc4b Remove useless reinterpret_cast 2025-04-10 08:06:15 +02:00
Philippe Symons
c755615d65 Merge branch 'master' into optimizations/reduce-binarysize-remove-libstdc++ 2025-04-09 20:19:39 +02:00
Philippe Symons
9268cbd42e Reduce binary size by eliminating libstdc++
This commit removes all references to things in the libstdc++ library to remove a decent chunk of bloat.

This means every std::to_string() call, std::string and std::vector. (as well as iostream related stuff).

I replaced those with my own versions ptgb::to_string() and ptgb::vector. Especially the latter is not exactly the same,
but close enough.

I also replaced operator new and delete with my own implementation to avoid pulling in everything related to exceptions
from libstdc++

Another problem was the fact that libtonc uses siscanf, which pulls in everything related to the scanf family of functions
and locale support. The worst part of that was that it included a 13KB "categories" symbol from libc_a-categories.o,
which was pulled in because of the locale support integrated into newlibc's siscanf() function. To fix that, I created a
custom, extremely restricted implementation of siscanf. libtonc only used this function to parse at most 2 integers from a
string anyway.
2025-04-09 20:04:08 +02:00
The Gears of Progress
08f6838c91 Fixing some graphics tearing 2025-04-08 14:28:30 -04:00
The Gears of Progress
7338828331 Removing graphics from loader 2025-04-06 17:29:22 -04:00
The Gears of Progress
1a68b30c8b
Merge pull request #36 from risingPhil/feature/load-without-multiboot
Proof Of Concept: Load PokeTransporterGB WITHOUT multiboot
2025-04-06 17:10:41 -04:00
The Gears of Progress
c7aa7b3dca Modifying the remote multiboot loader 2025-04-06 17:09:52 -04:00
The Gears of Progress
680459489e
Merge pull request #38 from risingPhil/feature/upload-rom-as-multiboot-to-other-gba
Add functionality to upload Poke Transporter GB to another gba after it has started on the current one [EZ Flash Omega]
2025-04-06 12:43:20 -04:00
The Gears of Progress
a369e08093
Merge branch 'master' into feature/upload-rom-as-multiboot-to-other-gba 2025-04-06 12:37:47 -04:00
The Gears of Progress
a278bfb355 Updating Dream Dex 2025-04-06 11:57:37 -04:00
Philippe Symons
93a6c0f3fe Add functionality to upload Poke Transporter GB to another gba after it has started on the current one [EZ Flash Omega]
The reason for this functionality is that some flashcarts *cough* EZ Flash Omega (DE) *cough* can't be hotswapped IN. When you try this, they will trigger a reset of the gba.
This is only relevant for the use case in which you first launch the rom from a flashcart in the first place.

I suppose this can only be relevant for flashcarts which offer "single cart mode". (mode B for EZ Flash Omega).

So, I added an option to upload the rom to another GBA from the "game_load_error" screen if you press the SELECT button.

So, with this change, you could

- launch Poke Transporter GB on GBA 1 from a flashcart.
- eject the flashcart on GBA 1
- make sure the EZ Flash Omega or other "single cart mode/mode B" capable flashcart is set to this mode.
- insert this flashcart into GBA 2
- connect GBA link cable (narrow plug on GBA 1, wide plug on GBA 2)
- Power on GBA 2 and press both SELECT and START while the gameboy logo is still shown
- On GBA 1, in the "game_load_error" screen, press SELECT
- On GBA 1, now press A -> The multiboot upload will now start
- Once finished, GBA 2 will now be running Poke Transporter GB as well
- GBA 2 will recognize the gen III save!
- You can now disconnect the GBA link cable and turn off GBA 1. (you may use it later for the GBC game alongside a GBC link cable to start the actual PKMN transfer)
2025-04-03 23:31:24 +02:00
The Gears of Progress
1ee46e1719 Resolving build warnings 2025-03-30 11:56:32 -04:00
The Gears of Progress
b267912687 Continuing box updating 2025-03-27 14:37:47 -04:00
Philippe Symons
9663c13f24 Make it work on my Supercard SD 2025-03-25 21:04:10 +01:00