Commit Graph

197 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
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
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
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
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
92020b228d Starting implementation of transfer options 2025-04-21 11:28:33 -04: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
c7aa7b3dca Modifying the remote multiboot loader 2025-04-06 17:09:52 -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
The Gears of Progress
8160bcd276 updating box menu, pre sprite grabbing 2025-03-22 15:57:22 -04:00
The Gears of Progress
91b2534b70 Updating text rendering 2025-03-19 20:55:09 -04:00
The Gears of Progress
af21da42b5 continuing work on updated text engine 2025-03-04 11:33:02 -05:00
The Gears of Progress
9f2dc4f653 Add a separate file for dialogue 2025-01-26 17:46:26 -05:00
The Gears of Progress
f4f64d0e07 Fixing button palette and modifying credits 2025-01-26 14:43:55 -05:00
easyaspi314
e4ef25e20e Compress the graphics (mostly), fix potential vram memcpy issue
This greatly decreases the ROM size, from 245 KB to 198 KB with no visual
changes (that I am aware of)

Changes:
- Enable compression on every graphic but the Pokemon sprites (which are
  too large for the GBA to decompress).
- Change grit from emitting .s files to .c files so GCC can strip unused
  palettes and maps
- Fix the empty tiles
- Trim down the font to skip 00-1F and 80-FF which were all zeroes
  - needs a slight workaround because the Pokemon name display was printing
    an invisible FF byte
- Switch memcpy to tonccpy which is vram safe
- Limit palette sizes.

Signed-off-by: easyaspi314 <6258309+easyaspi314@users.noreply.github.com>
2025-01-17 19:32:48 -05:00
The Gears of Progress
a805bbad0a Releasing wood gecko 2025-01-11 17:23:09 -05:00
The Gears of Progress
1662ed37e3 Fixing weird split changes 2024-12-19 18:39:37 -05:00
The Gears of Progress
422641c62b Merge branch 'master' of https://github.com/GearsProgress/Poke_Transporter_GB 2024-12-19 18:27:44 -05:00
The Gears of Progress
41f7fcb1aa *Finally* fixing the EXP bug 2024-12-19 18:15:04 -05:00
The Gears of Progress
a5e4e9401c Partial rewrite 2024-12-19 16:30:08 -05:00
The Gears of Progress
b382aec0dc pre Pokemon and Party rewrite 2024-12-19 13:29:47 -05:00
The Gears of Progress
5eb4321513 Final edits for v1.1.1 2024-12-13 12:08:09 -05:00
The Gears of Progress
fa56964f34 Adding in Yellow to new data transfer 2024-12-13 10:58:11 -05:00
The Gears of Progress
6a8184d2e7 Updating Red/Blue FE/FD code 2024-12-11 18:10:43 -05:00