rh-hideout / pokeemerald-expansion

Feature branche for the pokeemerald decompilation. See the wiki for more info.
340 stars 1.02k forks source link

Can't use #define-d constants in event.inc macros #4757

Open mrgriffin opened 3 months ago

mrgriffin commented 3 months ago

Description

Context

I think the problem is that the test system .includes event.inc, which means that cpp doesn't run over it, so if you use, e.g. PARTY_SIZE or SPECIES_NONE or whatever in that file you'll get a linker error.

To fix this we could move all the scripts out into .s files, and assemble them the usual way. That change would end up looking like:

-    RUN_OVERWORLD_SCRIPT(
-        hasgigantamaxfactor 0;
-    );
+   extern const u8 TestScript_HasGigantamaxFactor0[];
+   RunScriptImmediately(RunScriptImmediately);
+TestScript_HasGigantamaxFactor0::
+  hasgigantamaxfactor 0
+  end

So, makes the tests more annoying to read and write because now you're juggling two files and need to give names to all the scripts. But I think it will allow us to use constants. Alex and I aren't sure if it's currently worth doing, but I've raised the issue so that we don't forget how to fix it in the future if we want to.

Version

1.8.4 (Latest release)

Upcoming/master Version

No response

Discord contact info

No response

mrgriffin commented 1 month ago

5033 has a hacky workaround: .setting the constants that we need: https://github.com/rh-hideout/pokeemerald-expansion/pull/5033/files#diff-dc229fb98aa82e4418f93a183ac1637de405898e3ed72eab4bfb6bc49cd791f2

Obviously this is not a particularly good solution, so I'm leaving this issue open.