Skip to content

Remove trailing spaces from all fillers#8

Draft
it-is-final wants to merge 1 commit intoE-Sh4rk:mainfrom
it-is-final:trailing_spaces_filler
Draft

Remove trailing spaces from all fillers#8
it-is-final wants to merge 1 commit intoE-Sh4rk:mainfrom
it-is-final:trailing_spaces_filler

Conversation

@it-is-final
Copy link
Copy Markdown
Contributor

This pull request implements removing all trailing spaces from the default fillers in Boxes 2, 3, 4, 6, 7, 8, 10, 11, 12, and 14 across all game versions, using the more conservative option. This should allow typing codes to be slightly easier and faster as the user will no longer need to double check their trailing spaces, only the leading ones. Though something will need to be done about possibly prettifying the box name codes output from the "Result" when trailing spaces are removed.

At the moment, the common prevailing practice for the Switch rereleases of FireRed and LeafGreen is removing all trailing spaces and replacing _ _ _ … _ _ _ _ fillers with A. However this new advice (meant specifically for Switch versions) is inconsistent with the older practice of writing all box name codes as exactly shown in the CodeGenerator.

While this advice of removing trailing spaces works fine for the vast majority of codes, blindly following this advice (and only for Switch version) has the potential to break codes that depend on these trailing spaces, with one example brought up being some of Sleipnir17's codes. Furthermore the advice of removing all trailing spaces (with exception to the ones in Box 4, 8, and 12 which were already removed for FR/LG in the CodeGenerator) does not seem to have a technical basis that makes that makes this practice only applicable to the Switch (which is how it is presented right now), because removing them actually works fine on all games and platforms for most codes.

By making removing trailing spaces the default, they will only be shown when they are needed for the code to function as intended, making clear in the code when they are required. This means that people can continue following the advice of writing box names exactly as shown, while benefiting from the optimisation that comes with removing trailing spaces. Users might need to be retrained to actually type the box names exactly as shown so that the required trailing spaces are typed in, rather than manually removing trailing spaces.

Codes that might break from this change really should have defined an int32 within the code, rather than relying on the filler's default value for their functionality.

There has been further discussion in the Glitch City Research Institute server to potentially replace these fillers with the ones shown below. These have the benefit of being easier to type and debug than spaces and . This means less chance of a crashing typo from missing a space or misplacing a . However the singular A filler might be a bit of work to implement in CodeGenerator, but would be easier to type than a variant of _ _ _ … _ _ _ _ . These fillers would fail in the exact same conditions as the current fillers for Ruby and Sapphire since these are LT condition code fillers, as opposed to the EQ condition code (used in FR/LG and Emerald).

  • All boxes (no instructions): A (no spaces after)
  • Box 1/5/9/13 (one instruction): * * * * (no spaces after)
  • Box 2/6/10/14 (one instruction): A A A * * * * (no spaces after)
  • Box 3/7/11 (one instruction): A A * * * * (no spaces after)
  • Box 4/8/12 (one instruction): A * * * * (no spaces after)

@E-Sh4rk
Copy link
Copy Markdown
Owner

E-Sh4rk commented Mar 19, 2026

Sorry I missed this PR (I did not receive mail notification), do you think we should merge?

@it-is-final
Copy link
Copy Markdown
Contributor Author

Not quite yet, the PR message does discuss more options that might be better than what's presented in the PR (but of which I don't know how to implement yet).

@it-is-final
Copy link
Copy Markdown
Contributor Author

I also realise the might be an edge case of having no instructions after 0xFF instruction within same box name but the code still continues. e.g.

Box 2: A . o [A.o]

@E-Sh4rk
Copy link
Copy Markdown
Owner

E-Sh4rk commented Mar 20, 2026

I am not sure to understand the edge case?

So if I summarize we would like a config like:

@@ filler0_alt = 0xFFFFFFBB
@@ filler0 = 0xFFFFFFFF
@@ filler1 = 0xBBBBBBFF
@@ filler2 = 0xBBBBFFFF
@@ filler3 = 0xBBFFFFFF
@@ filler4 = 0xFFFFFFFF

But currently it does not quite work because:

  • filler0_alt should also be used when box name is full of 0xFF (not only when full of spaces)
  • tweaker seems to fill with 0x00000000 sometimes, it should use filler0 instead
  • this configuration would not always yields A for no instruction but sometimes AA or AAA, but maybe it is not a big deal?

Am I right or did I miss something?

@it-is-final
Copy link
Copy Markdown
Contributor Author

it-is-final commented Mar 20, 2026

Let me know if the below still isn't clear.

I am not sure to understand the edge case?

Basically there is advice going around that tells people to partially disregard the output of the CodeGenerator, e.g. removing trailing spaces or replacing empty box names within codes. While this advice works most of the time, there are a few codes that will not work as expected precisely because users didn't type them out exactly as intended.

By having CodeGenerator remove the trailing spaces and shorten box names for the user, the user can just type the box names as is rather than risking a game crash by not typing the box names as is. Because shortening these box names also come with benefits such as typing the box name faster. It also lessens mistakes from users who didn't shorten their box names properly that leads to a game crash.


So if I summarize we would like a config like:

@@ filler0_alt = 0xFFFFFFBB
@@ filler0 = 0xFFFFFFFF
@@ filler1 = 0xBBBBBBFF
@@ filler2 = 0xBBBBFFFF
@@ filler3 = 0xBBFFFFFF
@@ filler4 = 0xFFFFFFFF

Kind of, though I fear that particular configuration may lead to this error: Boxes.BoxFittingError("Some codes cannot be positionned due to non-consecutive 0xFF bytes."). As far as I understand, a box name code like the one below is currently impossible on CodeGenerator due to aforementioned error. It's quite contrived but it's basically making every box name with no real instructions (filler) output as A, which is the current advice as shown in Papa Jefe's video.

Box  1: z L o o k F R n [zLookFRn]
Box  2: 5 R n n U U n   [5RnnUUn]
Box  3: A A y 2 ? q     [AAy2?q]
Box  4: A               [A]
Box  5: A               [A]
Box  6: A               [A]
Box  7: A               [A]
Box  8: A               [A]
Box  9: A               [A]
Box 10: A               [A]
Box 11: A               [A]
Box 12: A               [A]
Box 13: A               [A]
Box 14: _ F o           [ Fo]

The code for above example would look something like

@@ filler1 = 0xBBBBBBFF
@@ filler2 = 0xBBBBFFFF
@@ filler3 = 0xBBFFFFFF
@@ filler4 = 0xFFFFFFFF
@@ fill = false
@@
0xE3E3C6EE
SBC r12, r12, #0xdf
SBC r10, r12, #0xff00000
SBC r12, r15, #0x388
STR r12, [r10, #0x3ed]
0xBBFFFFFF
0xFFFFFFFF
0xFFFFFFFF
0xFFFFFFBB
0xFFFFFFFF
0xFFFFBBFF
0xFFFFFFFF
0xFFBBFFFF
0xFFFFFFFF
0xBBFFFFFF
0xFFFFFFFF
0xFFFFFFFF
0xFFFFFFBB
0xFFFFFFFF
0xFFFFBBFF
0xFFFFFFFF
0xFFBBFFFF
0xFFFFFFFF
0xBBFFFFFF
0xFFFFFFFF
0xFFFFFFFF
0xFFFFFFBB
0xFFFFFFFF
BIC r0, r0, #0xff

@E-Sh4rk
Copy link
Copy Markdown
Owner

E-Sh4rk commented Mar 21, 2026

I improved the way filler0 and filler0_alt are handled in retrocompatible way (I hope so).
Now, when padding in a location that does not intersect with the end of a box name, it will always try to use filler0 and only when it is not possible to do so it will use filler0_alt instead (and if still not possible, it will use spaces). The other fillers are still used when padding in a location that does intersect with the end of a box name.

This makes it possible to use these fillers:

@@ filler0 = 0xFFFFFFFF
@@ filler0_alt = 0xFFFFFFBB
@@ filler1 = 0xBBBBBBFF
@@ filler2 = 0xBBBBFFFF
@@ filler3 = 0xBBFFFFFF
@@ filler4 = 0xFFFFFFFF
@@ fill = false

which I think do what you want except that empty box names 2, 6, 10, 14 will be AAA instead of A and 3, 7, 11 will be AA.
But except this difference, it should accomodate all the different situations.

For instance the code you mentionned:

@@ filler0 = 0xFFFFFFFF
@@ filler0_alt = 0xFFFFFFBB
@@ filler1 = 0xBBBBBBFF
@@ filler2 = 0xBBBBFFFF
@@ filler3 = 0xBBFFFFFF
@@ filler4 = 0xFFFFFFFF
@@ fill = false
@@ exit = "BIC"
@@
0xE3E3C6EE
SBC r12, r12, #0xdf
SBC r10, r12, #0xff00000
SBC r12, r15, #0x388
STR r10, [r12, #0x3ed]!

with the exit code

@@ filename = "BIC"
@@ start = 116
@@

BIC r0, r0, #0xff

generates what you said, except for the difference I mentionned.

Would this be okay or do you really need all empty boxes to be only A ? (in which case I can add a separate mechanism to implement that specifically).

Also I haven't tested it extensively so please tell me if you find an issue with this filler configuration.

@it-is-final
Copy link
Copy Markdown
Contributor Author

it-is-final commented Mar 22, 2026

Single A would be ideal (it still doesn't like my sample), but this kind of filler seems to be better than what was there before. I might need to test a bit more (used your sample).

Edit: I noticed a bug where All commands (with exit code and fillers): still reports 0x00000000 instructions when there aren't any (they were replaced with 0xffffffff or something like that).

@E-Sh4rk
Copy link
Copy Markdown
Owner

E-Sh4rk commented Mar 22, 2026

I made the box fitting algorithm more flexible, now your example works:

@@ filler0 = 0xFFFFFFFF
@@ filler0_alt = 0xFFFFFFBB
@@ filler1 = 0xBBBBBBFF
@@ filler2 = 0xBBBBFFFF
@@ filler3 = 0xBBFFFFFF
@@ filler4 = 0xFFFFFFFF
@@ fill = false
@@

0xE3E3C6EE
SBC r12, r12, #0xdf
SBC r10, r12, #0xff00000
SBC r12, r15, #0x388
STR r10, [r12, #0x3ed]!
0xBBFFFFFF
0xFFFFFFFF
0xFFFFFFFF
0xFFFFFFBB
0xFFFFFFFF
0xFFFFBBFF
0xFFFFFFFF
0xFFBBFFFF
0xFFFFFFFF
0xBBFFFFFF
0xFFFFFFFF
0xFFFFFFFF
0xFFFFFFBB
0xFFFFFFFF
0xFFFFBBFF
0xFFFFFFFF
0xFFBBFFFF
0xFFFFFFFF
0xBBFFFFFF
0xFFFFFFFF
0xFFFFFFFF
0xFFFFFFBB
0xFFFFFFFF
BIC r0, r0, #0xff

@it-is-final
Copy link
Copy Markdown
Contributor Author

What kind of work would be needed to allow something like a single A filler for "empty" box names (i.e. no other instructions using that box name) to be possible to configure (e.g. as a header parameter)?

@E-Sh4rk
Copy link
Copy Markdown
Owner

E-Sh4rk commented Mar 23, 2026

I do not think it can be handled by the "box fitting" algorithm, because when it inserts a filler it does not know yet whether there will be instructions after in the box name or not. So maybe the easiest would be to use the fillers I mentionned above, together with some additional box name rewriting rules (e.g. AA -> A, AAA -> A). I can implement it, I just have to figure out a good syntax to input these rewriting rules in the headers.

@E-Sh4rk
Copy link
Copy Markdown
Owner

E-Sh4rk commented Mar 28, 2026

@it-is-final I implemented some rewritting rules. It can be changed in the headers but I have added some default ones to implement the behavior you want. Can you check if codes with the following headers are written as expected?

@@ filler0 = 0xFFFFFFFF
@@ filler0_alt = 0xFFFFFFBB
@@ filler1 = 0xBBBBBBFF
@@ filler2 = 0xBBBBFFFF
@@ filler3 = 0xBBFFFFFF
@@ filler4 = 0xFFFFFFFF
@@ fill = false
@@

@it-is-final
Copy link
Copy Markdown
Contributor Author

it-is-final commented Mar 29, 2026

As far as I can tell, the new fillers seem to work pretty well. I tried it with codes (e.g. Make any Pokemon shiny) that became bugged (from reading the Discord) the last time you changed the code that dealt with fillers, and they work.

I think I can now force push this branch to have those filler settings be default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants