Commit Graph

69 Commits

Author SHA1 Message Date
Philippe Symons
2d743f0aa2 Update libPCCS and make debug_box_data const 2026-03-11 16:11:15 +01:00
GearsProgress
209dbcf2ce Fixing merge conflicts for PR 117 2026-03-11 11:02:02 -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
97e1333078 Removing extra debug info 2026-01-03 17:31:30 -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
Philippe Symons
47cd143de6 Replace ZX0 by the builtin LZ10 compression.
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.
2025-07-18 16:19:34 +02: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
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
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
The Gears of Progress
b267912687 Continuing box updating 2025-03-27 14:37:47 -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
a805bbad0a Releasing wood gecko 2025-01-11 17:23:09 -05:00
The Gears of Progress
41f7fcb1aa *Finally* fixing the EXP bug 2024-12-19 18:15:04 -05:00
The Gears of Progress
b382aec0dc pre Pokemon and Party rewrite 2024-12-19 13:29:47 -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
3b945ecf3e v1.1.0 2024-11-01 22:54:05 -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
e3c5898683 Fixing contest hall data bug 2024-09-25 14:51:20 -04:00
The Gears of Progress
8cee78e384 Adding Gen 3 Languages 2024-09-05 19:50:28 -04:00
The Gears of Progress
3728db9f72 Final push!! 2024-08-23 17:50:17 -04:00
The Gears of Progress
1ec09842ad Updating tons of graphics 2024-08-19 14:47:29 -04:00
The Gears of Progress
22f7aaac26 Pre-saving space 2024-08-13 15:49:04 -04:00
The Gears of Progress
a5ed8b5bda Prep for Z80-ASM 2024-07-26 12:13:39 -04:00
The Gears of Progress
aa4d2573b8 Fixing bugs 2024-07-11 11:18:38 -04:00
The Gears of Progress
7aa6933dd6 Fixing crash 2024-07-05 19:20:05 -04:00
The Gears of Progress
add977cf02 Prep for bug testing 2024-07-03 17:44:33 -04:00
The Gears of Progress
e5ad1e25cf Changing background and fixing bugs 2024-07-02 16:55:47 -04:00
The Gears of Progress
290fdf22a4 Updating DreamDex 2024-06-28 16:24:01 -04:00
The Gears of Progress
a8a8edefb3 Finalizing event compatibility 2024-06-28 11:50:22 -04:00
The Gears of Progress
5950e53e88 Continuing work on updated event 2024-06-22 11:24:43 -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
The Gears of Progress
e0f78a3195 Finalizing beta v2 2024-05-29 13:11:44 -05:00
The Gears of Progress
bf7f7f401c Continuing Payload Work 2024-05-02 12:18:24 -05: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
a4bda4c673 Adding in event stabilization 2024-04-17 09:17:15 -05:00
Remnants of Forgotten Disney
301ccf602b Finalizing Red/Blue Payload 2024-04-07 16:46:39 -05:00
Remnants of Forgotten Disney
a27f1c2c37 Continuing transfer menu implementation 2024-04-02 12:19:06 -05:00
Remnants of Forgotten Disney
13450924c2 Implementing new payload system 2024-03-29 23:39:58 -05:00
Remnants of Forgotten Disney
0a27d23ba5 Updating buttons and implementing offset rows 2024-03-29 19:33:10 -05:00
Remnants of Forgotten Disney
4768f72a50 Moving Pokemon data to Sector 30 2024-03-03 17:42:59 -06:00
Remnants of Forgotten Disney
257fe54a76 Finalizing ASM variable rewrite 2024-03-01 19:52:46 -06:00