Commit Graph

59 Commits

Author SHA1 Message Date
GearsProgress
e9784c88ed Fixing cable printout 2026-03-20 23:26:08 -04:00
GearsProgress
e10d4cc044 Fixing starting newlines 2026-03-19 19:38:46 -04:00
GearsProgress
a7ebcd06fe Updating text engine backend 2026-03-18 22:55:38 -04:00
GearsProgress
1f29379810 Linking textbox creation to string display 2026-03-14 10:16:16 -04:00
Philippe Symons
10350179db Move debug info screen and text debug screen to debug menu 2026-03-09 23:12:32 +01:00
Philippe Symons
b84939b49a Add debug menu UI when you press L+R in the main menu.
It's only the UI yet. It only shows a couple of dummy options right now.
2026-03-09 19:56:32 +01:00
The Gears of Progress
2482bb486b Modifying decompression function to be based on indexes 2026-01-11 17:09:30 -05:00
The Gears of Progress
1055094ab9 Modifying text_helper to not have static text sections 2026-01-11 15:02:16 -05:00
The Gears of Progress
fff4588d4a Updating packet debug features and restricting data offset to positive numbers 2026-01-03 17:29:36 -05:00
The Gears of Progress
9ca5c650d0 Working on debugging 2025-12-03 22:08:35 -05:00
The Gears of Progress
ba1a075701 Adding PCCS 2025-10-12 15:08:33 -04:00
The Gears of Progress
a0793c72c0 Fixing issues before implementing the CPCS 2025-09-20 17:17:20 -04:00
The Gears of Progress
ed6ee974f8 Fixing connection textbox 2025-08-06 23:08:00 -04:00
The Gears of Progress
ba9e30e8d0 Fixing a few bugs before merge 2025-07-28 16:18:51 -04:00
Philippe Symons
2689ffd3cf Optimize Gameboy payloads for size by generating the payloads at runtime and generate binary patches
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.
2025-07-18 12:48:50 +02:00
Philippe Symons
5e7118c0c7 Compress the gb_rom_values and gba_rom_values tables with ZX0. 2025-06-27 16:04:04 +02:00
Philippe Symons
eef173b0d2 Fix crash + unrelated buffer overflow + some optimizations
There was a crash happening with ptgb::vector when you'd press A on the CONFIRM button of the box screen. It only occurred on actual gba hardware and
was a real heisenbug: as soon as you'd add code to display logs on screen, the problem would disappear. So it was very difficult to figure this one
out. We're not even entirely sure why, but it looks like the malloc/realloc/free use in ptgb::vector would cause issues.

Maybe it was alignment, but after messing with the code we also saw a warning appear in the terminal telling us that realloc wouldn't properly
deal with non-POD types. It complained about this very thing while referring to the add_track() function, which stores ptgb::vectors inside another
ptgb::vector. We also didn't have a custom copy constructor yet to actually copy the buffer instead of its pointer.
All of these could potentially have led to the crash. But debugging during the link cable flow was difficult, so we were never able to confirm it in
a debugger, log or dump.

Because I suspected the high IWRAM consumption (especially now with ZX0 decompression) for a while, I also did an optimization in mystery_gift_builder
to pass global_memory_buffer as its section_30_data buffer instead. This reduces IWRAM consumption by 4 KB.

There was another problem I discovered during my crash hunt: the out_array (now payload_buffer) was allocated as a 672 byte array, but the payloads
were actually 707 bytes. Therefore writing this to the buffer caused a buffer overflow, thereby corrupting the global variables appearing after it in
IWRAM. It turned out eventually that none of these variables were really critical, but it could explain some minor bugs GearsProgress has seen.

I also did a few performance optimizations:

- At various stages in the code, for loops were used to copy data from one buffer into another byte-by-byte. This was far from optimal because the gba
cpu can load/copy 4 bytes at a time if you ask it to. So I replaced those with memcpy(), which is a hand-optimized assembly function to copy data
using this principle.

- generate_payload was being called twice: once at start_link and once at continue_link, giving the exact same result, even though it was already
being stored in a global buffer allocated in IWRAM. This was also a fairly heavy function. So I optimized the code to only initialize it once in
the script chain and then just retrieve the buffer.

- generate_payload was constructing the eventual payload twice even within the same call. That's because it first merged z80_rng_seed, z80_payload
and z80_patchlist into a full_data ptgb::vector, after which it then copied the data again to out_array (now called payload_buffer). I eliminated the
full_data vector now.
2025-06-18 10:23:03 +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
6d60fb8901 Merge branch 'optimizations/reduce-binarysize-remove-libstdc++' into optimizations/implement-zx0-compression 2025-05-25 22:34:45 +02: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
Philippe Symons
903ccb0d21 Some minor optimizations 2025-05-21 17:29:12 +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
8160bcd276 updating box menu, pre sprite grabbing 2025-03-22 15:57:22 -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
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
The Gears of Progress
884ebc9216 Adding data packets to GSC 2024-10-31 10:59:36 -04:00
The Gears of Progress
cd2a9971a5 Adding data packets to Red/Blue 2024-10-30 14:56:44 -04:00
The Gears of Progress
1ec09842ad Updating tons of graphics 2024-08-19 14:47:29 -04:00
The Gears of Progress
7e82dd7b65 Adding support for gen 2 2024-06-11 16:34:58 -04:00
The Gears of Progress
2cfec76b3c Adding support for Yellow and fixing other bugs 2024-06-07 13:55:01 -04:00
Remnants of Forgotten Disney
5cb282c8a7 Implementing Yellow and Gold/Silver Payloads 2024-04-29 08:29:09 -05:00
Remnants of Forgotten Disney
888c257e49 Implementing internal payload builder 2024-04-21 21:44:14 -05:00
Remnants of Forgotten Disney
611d78d23a Finalizing Link Cable Connection 2024-04-14 12:26:04 -05:00
Remnants of Forgotten Disney
301ccf602b Finalizing Red/Blue Payload 2024-04-07 16:46:39 -05:00
Remnants of Forgotten Disney
13450924c2 Implementing new payload system 2024-03-29 23:39:58 -05:00
Remnants of Forgotten Disney
6bef2b58f2 Reworking global frames 2024-03-27 12:04:18 -05:00
Remnants of Forgotten Disney
d7d8648eb4 Finalizing the RB transfer rewrite 2024-03-27 11:20:54 -05:00
Remnants of Forgotten Disney
53e7748d48 Organizing files 2024-03-19 13:52:23 -05:00
Remnants of Forgotten Disney
020d27433d Preparing for ASM rewrite 2024-02-24 14:53:12 -06:00
Remnants of Forgotten Disney
1b5f30087a Modifying Pokemon Injection 2024-02-19 08:29:37 -06:00
Remnants of Forgotten Disney
584c7862c3 Updating Link Cable Implementation 2024-02-12 13:28:06 -06:00
Remnants of Forgotten Disney
df1df7ea7f Pre-link rewrite 2024-02-04 12:35:54 -06:00
Remnants of Forgotten Disney
8bb76ca58c Double checking formatting 2023-11-29 08:28:55 -06:00
Remnants of Forgotten Disney
e7fd5f1aba Dialouge system update and text formatting 2023-10-28 17:38:58 -05:00
Starport75
16d4fd642c Implemented Generation 1 2023-08-07 23:38:16 -05:00