Commit Graph

182 Commits

Author SHA1 Message Date
GearsProgress
f56d697831 Adding final text update before release 2026-10-02 16:43:51 -04:00
GearsProgress
f1cf11f2cf Final set of bug fixes before release 2026-10-02 12:20:03 -04:00
GearsProgress
99bf032751 Fixing a few more bugs for release 2026-10-01 22:41:04 -04:00
Philippe Symons
91791243a1 Merge branch 'release-candidate' into have-build-lang-independent-gba-payload-translations 2026-09-30 17:07:30 +02:00
GearsProgress
61cb3f4a26 Adding in Japanese LVL placeholder 2026-09-30 09:07:11 -04:00
GearsProgress
492c14b74f General fixes 2026-09-29 15:41:32 -04:00
GearsProgress
4d39ce30d0 Adding entrypoint values 2026-09-29 15:40:06 -04:00
GearsProgress
8f495b4ea1 Fixing spacing issues 2026-09-29 11:18:36 -04:00
GearsProgress
1ddedeaae0 Updating Jpn ROM values 2026-09-29 10:47:19 -04:00
Philippe Symons
0b86d836b4 Add more logs about text lengths when they're too long! 2026-09-28 23:30:14 +02:00
Philippe Symons
53dddb7f9e Fix bug with BUILD_LANG version
The gba payload was broken for the BUILD_LANG variant of the gba payload. So if the PTGB rom was english, the english payload would be broken.

The reason for this was because the text_helper ended up trying to convert the same entries twice, because the <BUILD_LANG> RSEFRLG table
would be converted during generate_text_tables() first, and then it would be converted again during generate_rsefrlg_tables_for_all_langs()

But convert_item is a destructive operation, because it replaces the ['bytes'] dictionary field.

Fix: add a "converted" boolean to guard against converting more than once.
2026-09-28 22:37:44 +02:00
GearsProgress
503478d665 Adding global compression header 2026-09-28 16:15:09 -04:00
Philippe Symons
a6b34279f1 Work on multilang gba payloads (WIP/broken)
Do some more work for multilang gba payloads. Revise the patch structure and make it use the right RSEFRLG table.

But it's broken. For some reason the english text doesn't show up when running the payload. Don't ask me why yet.
2026-09-28 17:09:44 +02:00
Philippe Symons
f11c11d5bf Make gba payload translations independent from BUILD_LANG (WIP/untested) 2026-09-25 21:20:21 +02:00
GearsProgress
f4696d7009 Adding error message for mixing JPN and Latin 2026-09-25 14:43:02 -04:00
Philippe Symons
1b0efc2166 Use a 4096 byte chunkSize for the bps patch containers to maximize compression 2026-09-25 09:25:29 +02:00
Philippe Symons
3884d4b5da Strip some more fields from the BPS patches and make easyaspi314's implementation deal with it. 2026-09-24 23:07:48 +02:00
Philippe Symons
c12b478596 Merge branch 'isolate_mystery_gift_builder' into trim-bps-patches 2026-09-24 21:08:52 +02:00
Philippe Symons
11a581061f Fix first_time text entries in payload (untested)
first_time entries would be longer, therefore the reference pointers inside the payload would shift.

To avoid that, we now reserve space for the longest entry, knowing that the texts will get stripped after
the payloads have been generated.

Doing so ensures that the text offsets remain constant, no matter if we're dealing with the first_time or othertimes payload.

This also means we need to take that reservation into account on the PTGB rom side of things of course.
To do so, I created a pair array indicating the first time entries and there non-first_time counterparts.

We'll determine which entry is the longest and ensure we use that length for the offset of the next entry.
2026-09-22 17:10:20 +02:00
Philippe Symons
8015d8187b Merge branch 'isolate_mystery_gift_builder' into strip-texts-from-generated-payloads 2026-09-22 14:16:39 +02:00
Philippe Symons
0e5cf21010 Merge remote-tracking branch 'upstream/release-candidate' into isolate_mystery_gift_builder 2026-09-22 14:15:58 +02:00
Philippe Symons
3579fe6658 Reinject RSEFRLG table entries into the GBA payload at runtime. (untested)
This commit makes mystery_gift_injector re-insert the text entries into the gba payload at runtime.

You may or may not remember that I made gba-payload-generator strip the text entries again after generating the payloads.
I did this to improve compression: it removes the variability of the text lengths. It also ensures that texts are not really part of the BPS patch files
that are generated to transform the base payload into a specific language and game variant.

Therefore, we don't run at risk of storing certain text entries multiple times (or partially multiple times) due to them being stored at FileContainer boundaries.
It should make patch files smaller and more predictable.

Stripping the text entries also made it easy to reinsert: almost every rom uses the same offset for the first entry.
We now only need to store each language variant of the RSEFRLG (variants aren't being generated yet) once. That should be a big boon.

By first generating the payloads and THEN stripping the texts, we also ensure that the pointers/references within the payload remain intact and will become valid
again once the texts get reinserted.

Anyway, this specific commit does the re-insertion of those text entries into the payload (script + section30) using the RSEFRLG table.

Because the text stripping takes out these variable length texts, the text insertion offsets always end up the same, no matter the language:

Section30: 0x97E
Script:
- Ruby/Sapphire: 0x268
- Fire Red/Leaf Green: 0x278
- Emerald: 0x298
2026-09-17 16:13:08 +02:00
GearsProgress
10bad431fa Updating credits to include JPN Crystal 2026-09-12 10:27:43 -04:00
Philippe Symons
da21f614e6 Strip injected texts from generated payloads in gba-payload-generator (WIP)
So, one of my concerns is that the BPS patches are too big and become even worse once the first_time flag and actual other payload translations
are being taken into account (which is not the case yet). Especially because we have to store our patch files into FileDataContainer chunks
and as a chunk boundary is crossed, compression context is lost. That means we might end up storing the same texts multiple times.

What we always wanted to do is to inject the texts at runtime into the payload, but have the payload itself generated at build time.
But what stopped us before is that not injecting the text shifts pointers (variable references, text offsets, ...) around.

But I had an idea: what if we DO inject the texts at first, thereby establishing the right reference addresses inside the generated payload
and THEN strip the texts again?

This way, our BPS patches would only have to account for the pointer differences between game/language variants.
And we would only have to store one compressed RSEFRLG text table per language. This will allow us to inject the texts at runtime to fixed
payload offsets and take care of both the compression problem and the "first_time" text difference all in one go.

As referenced in the title, this is still a work-in-progress commit. While the text stripping seems to be complete, there are still tasks to be done:

- Generate all language variants of the RSEFRLG text table
- Determine the text injection offset per game type. Many will be the same, but I mostly expect differences
  between Ruby/Sapphire vs Emerald vs FireRed/LeafGreen.
- Inject the texts accordingly at runtime in the mystery_gift_injector.cpp
2026-09-10 16:59:47 +02:00
Philippe Symons
ac257b314f Fix transfer issue in isolate_mystery_gift_builder branch
Problem: several variables were used in mystery_gift_builder before they were initialized.
Fix: initialize them.

I also made sure to memset the entire buffer before generating a payload to avoid garbage data to seep in.
2026-09-09 15:30:07 +02:00
Philippe Symons
99922691fb Merge remote-tracking branch 'upstream/release-candidate' into isolate_mystery_gift_builder 2026-09-08 13:28:11 +02:00
TimoVM
00ecde564f tools/gb-payload-generator: cleanup scr and include files, removing unused symbols and hardcoded addresses. 2026-09-08 13:18:11 +02:00
Philippe Symons
45ce178762 Merge remote-tracking branch 'upstream/release-candidate' into isolate_mystery_gift_builder 2026-09-08 09:10:15 +02:00
TimoVM
727125e99d tools/gb-payload-generator/src: fix softlock on gen 2 transfers by moving packet buffers to a safer location. 2026-09-08 01:47:34 +02:00
Philippe Symons
82d394d1bb Eliminate some code duplication in reconstruct_pregenerated_payloads and rename generate_payloads.sh 2026-09-04 15:47:33 +02:00
Philippe Symons
afe0b5cc68 Merge remote-tracking branch 'upstream/gameboy-payload-update' into isolate_mystery_gift_builder 2026-09-02 15:06:32 +02:00
GearsProgress
daeaa4d59c Deleting link_helper.lua 2026-09-01 11:44:49 -04:00
Philippe Symons
0f02614e12 Improve error output in gba-payload-generor when the script/section30 is too large 2026-08-31 15:07:55 +02:00
Philippe Symons
db1b83a29b Merge remote-tracking branch 'upstream/gameboy-payload-update' into gears-merge 2026-08-31 13:21:29 +02:00
Philippe Symons
6c4c8e72b9 Trim BPS patches. Remove 4 bytes from the header and 12 from the trailer. 2026-08-28 23:19:14 +02:00
Philippe Symons
e96821aed5 Fix bug and improve logs
Bugfix: do not apply the same base payload patch twice.

I also improved the mystery_gift_builder log messages a bit.
2026-08-28 16:15:11 +02:00
Philippe Symons
ed741fb5d3 Make the generate_payloads.sh script fail if gba-payload-generator fails (assert) 2026-08-28 15:52:04 +02:00
Philippe Symons
3145fe69d2 Make us have less base payloads.
For example, Fire Red and Leaf green are (almost?) identical. But if we create separate base payloads, it takes up way more space.
2026-08-28 15:12:39 +02:00
Philippe Symons
26108f2332 Forgot to commit bps-asm-thumb.s and generate_payloads.sh 2026-08-28 14:28:08 +02:00
Philippe Symons
353359455a Integrate Pi's bps_patch function to apply bps patches to our base payloads and turn them into the game-specific ones. 2026-08-28 14:27:09 +02:00
Philippe Symons
75a0028cd2 Merge branch 'bugfix/gb-payload-lockup-on-transfer' into isolate_mystery_gift_builder
and convert PokeBox BEFORE injection (to separate IWRAM consumption)
2026-08-20 13:58:44 +02:00
Philippe Symons
b8b0dd25e4 Integrate the pregenerated payload into mystery_gift_injector (WIP, untested)
This commit integrates the pregenerated payload into mystery_gift_injector.

It currently hardcodes the English Ruby v1.2 payload for testing purposes though.

The next test I'll have to do is to see if the transfer process works with this specific rom.

If it works, I can start integrating Pi's work in regards to delta patching using BPS.
2026-08-11 13:40:07 +02:00
Philippe Symons
ba2aa3c672 Fix copypasta bug: I accidentally seem to have pasted a changePaletteMacro call. 2026-08-05 22:57:17 +02:00
Philippe Symons
db38ce19a3 Replace uncompressed_text_data_table with UncompressedFileContainerReader (WIP)
The text_data_table concept was replaced in the gameboy-payload-update branch. Therefore I have to replace it here as well!
2026-08-05 16:36:26 +02:00
Philippe Symons
65edf7e205 More work on gba-payload-generator main (WIP) 2026-08-03 15:24:53 +02:00
Philippe Symons
bb962b84fa Merge remote-tracking branch 'upstream/gameboy-payload-update' into isolate_mystery_gift_builder 2026-08-03 14:12:34 +02:00
Philippe Symons
bda2f51407 Start working on main.cpp (WIP/unfinished) 2026-07-30 17:02:52 +02:00
Philippe Symons
cf1e68a9c9 Replace looker sprite files with uncompressed variants, so we can completely replace the LZ77UnCompWram call. 2026-07-30 15:10:45 +02:00
Philippe Symons
b0cbf0e725 More work on the mystery_gift_builder isolation
I changed the approach a bit.

I realized that injection of stuff like text and the looker sprite at runtime, would result in every var
reference requiring an address shift.

That would be much more difficult to track and patch at runtime.

So I decided to do things a little differently:

- Copied the grit-*generated* lookerRSE.c, lookerFRLG.c and associated headers.

- text injection will also be done at compile time. To do so, I'll take the path to the uncompressed
RSEFRLG table (which is generated by text_helper) as a cmdline arg and use it to inject those strings
at compile time.

So the only runtime injection required would be the pokémon themselves. And the size of those is static.
So that works out!
2026-07-29 21:49:27 +02:00
Philippe Symons
99d196825d Work on isolating mystery_gift_builder from PTGB (WIP, doesn't compile yet)
This is the start of reworking mystery_gift_builder to run outside of PTGB and generate (most) of the payload
at compile time.

The idea is to leave most of the code intact, but inject some things at runtime.

It looks currently like that would be:

- Looker sprite (avoid LZ77UnCompWram AND having to bin2o the sprite file)
- text (avoid LZ77UnCompWram AND having to bin2o the text into this tool project)
- Pokémon box data

To that end, the goal is to generate a metadata struct with offsets of where to insert those things
at runtime.

But this commit is incomplete. It already tackles a bunch of stuff, but it can't be compiled yet.

TODO:

- Replace injection of the aforementioned things at compile time with something to record the offsets into
struct.
- Make it compileable
- output the payload to a (set of?) file(s)
- replace mystery_gift_builder IN PTGB with the pregenerated payload
- Inject the aforementioned things into the pregenerated payload at runtime in PTGB.
- Validate the pregenerated payload by comparing with mg_array and section30 dumps
 from the previous implementation.
2026-07-28 21:42:26 +02:00