Commit Graph
3726 Commits
Author SHA1 Message Date
Rangi a2dd318f1d Remove executable status from non-script files (git update-index --chmod=-x) 2026-09-20 19:46:40 -04:00
Rangi ace8db1b73 Fix RGBGFX -t/--trim-end combined with -B/--background-color for non-deduplicated output (#2130) 2026-09-20 15:05:06 -04:00
Rangi 408e861ecc Correct warning message about different RGBGFX -L and -r widths 2026-09-20 14:32:04 -04:00
ISSOtm e1ed304e6b Apply the same enabling logic for UBSan as for ASan 2026-09-19 23:30:35 +02:00
ISSOtm bb0fc08980 Enable our default ASan flags on macOS
Except for the leak detection (Clang complains it's not supported there),
for which I have corrected the comment and its location.
2026-09-19 23:30:35 +02:00
Rangi b7f6c641f1 Define more debug options for make develop (#2124) 2026-09-19 22:07:10 +02:00
Rangi b80bbe0fe6 Correct documentation for rgbgfx -x re: interaction with -N (#2126) 2026-09-19 14:40:02 -04:00
Rangi c151450d9f Fix underflowing SECTION FRAGMENT fixed address in RGBLINK (#2122) 2026-09-18 22:00:27 -04:00
Rangi 76bba2809b Fix incorrect EMPTY space in .map files (#2119) 2026-09-19 03:17:15 +02:00
Eldred Habert 44328d522b Avoid using snprintf where GCC can check sizes (#2121)
Interestingly, Clang's `-Wformat-overflow` seems to only warn
about buffers so small they will *always* underflow,
whereas GCC tries to infer whether they can overflow *at all*.
(I'm guessing they lean towards false-negatives and false-positives resp.)

Anyway, calling `sprintf` here remains safe, since GCC (notably, via CI)
checks our work, and it simplifies the code ever so slightly while
also providing an (admittedly negligible) performance improvement.

Note that there may be more locations where we could use `sprintf`,
but a cursory glance at our other uses of `snprintf` didn't seem fruitful.
(One way to test is to set the target buffer size to 1, and see if a
warning pops up for such a trivially-wrong size. If not, you can be certain
the compiler won't be able to help you with a more realistic size.)
2026-09-19 03:15:07 +02:00
Rangi 142eae4558 Fix repeated "And N more" in overlay error message (#2118) 2026-09-18 17:35:30 -04:00
Rangi 89403ca23b Fix RGBGFX to support -C/--color-curve in -r/--reverse mode (#2110)
Clarifies error message when RGBGFX reverse mode has `-c` mismatching `-p`.
2026-09-18 17:35:22 -04:00
Eldred Habert 0286d4119e Check out less of the repo for contrib verification
Shorter checkout time = good, I think.
2026-09-18 21:45:35 +02:00
Eldred Habert c803a20259 Only check contrib scripts when one of them changes
Less unnecessary CI!
2026-09-18 21:39:30 +02:00
ISSOtm aab22852d3 Factor out free space manipulation 2026-09-18 21:19:37 +02:00
ISSOtm 0e41ace1e3 Refactor section placement algorithm
Massively simplified, by not trying to shoehorn differently-behaving
cases into the same one loop!

This may have introduced bugs (the test suite has caught three different
oversights, two of which via external projects, in fact!), but this also
makes the logic clearer and more streamlined, so that we are also less
likely to have any latent or future bugs.

In particular, previously, the first iteration of the loop could attempt
placement at an address not matching the section's constraints,
which made advancing to the next target address unnecessarily complicated
(https://github.com/gbdev/rgbds/pull/2064#discussion_r3985466596),
among other weirdness. The code ended up being defensive, and thus the
overall logic was murky.

I'm also expecting that this should provide a performance improvement due
to being essentially a form of loop-invariant code motion (and very likely
one a compiler couldn't have performed automatically), though I haven't
measured.
2026-09-18 21:19:37 +02:00
ISSOtm ce5c8ce8ac Respect zero-size sections' align offsets
Fixes #2095

This code pre-dates the introduction of alignment offsets,
so it was never updated to take it into account.

That said, some of the code that I have factored out is a little awkward because
it will be used in an upcoming refactoring of the whole assignment loop,
since that turns out to be more byzantine than it ought to be due to
trying to handle a too disparate set of cases in a single loop.
2026-09-18 21:19:37 +02:00
ISSOtm c49828f7c9 Fix memory region alignment checks
Turns out the checks could fail spuriously if the starting alignment is non-zero,
e.g. `align 8,$C0` in HRAM. (Fixes #2113.)
This was tripped up by a test added to exercise the linker's section placement algorithm
on a similar aligment-related issue. :D

Note that this may be caused by the code in question pre-dating alignment offsets,
and we never checked. That said, these checks only work due to the regions' starting
addresses being no more aligned than their size (..if that makes sense?), so allowing
custom memory regions (#524) could violate that assumption and make those checks incorrect.
2026-09-18 21:19:37 +02:00
ISSOtm 5b9903f358 Mark a link test as failed if assembling fails
Assembling is never *supposed* to fail, but in this case I ended up adding
a test case that triggered a bug in the assembler, and that caused the rest
of the test to become garbled. This is thus more robust.
2026-09-18 21:19:37 +02:00
ISSOtm d43ef53745 Remove unreachable bank range check
The only case where it is not generated by our own code
(which we ought to be `assume`ing is correct) is when the bank
is used-specified, but that is caught by an earlier check.
2026-09-18 21:19:37 +02:00
ISSOtm ef709fade6 Refactor and fix sect packing's bank iteration
Moving both pieces of related code together, as it were.
This also ends up changing the behaviour of scrambling,
where sections could “leak” out of the scrambling's bank pool
and resume being placed normally.

We have discussed it offline, and decided that this was a bug.
The test suite has been updated accordingly, which even gives
the occasion to move this test from a special case to the main
generic loop!
2026-09-18 21:19:37 +02:00
ISSOtm 8685bcbfbf Refactor all scrambling-related dispatch into a single func
Yay for (poor man's) pattern matching! 🦀
2026-09-18 21:19:37 +02:00
ISSOtm 1ca4282e31 Move a function closer to its usage point
Trying to keep code grouped together well.
2026-09-18 21:19:37 +02:00
Eldred Habert afe1f01d00 Fix linker script align 16 in floating address context (#2115)
Turns out we were just using the wrong var lmao
2026-09-17 20:46:55 -04:00
Rangi 8bf5957c83 Fix RGBLINK assertion failure when -s and -c invalidly match (#2109) 2026-09-18 01:34:14 +02:00
ISSOtm f234796428 Avoid allocating for our linkdef names (#2111)
This reverts a change introduced in fd78a9ae8, though it wasn't that commit's main point
so I'm feeling okay with undoing that.

This feels like an overkill change, using a static string is good enough for this
since we never modify this. I have considered using `string_view` instead, to have
the best of both worlds, but that's not NUL-terminated so our print functions
get a little grumpy.
2026-09-17 13:58:30 -04:00
ISSOtm 0b9f8ab523 Use Section::typeInfo() more 2026-09-17 13:19:26 -04:00
Eldred Habert 3b250d5386 Emit auxiliary files even if asserts fail (#2104)
Closes #2100
2026-09-17 17:47:53 +02:00
Rangi b4988afc8a Fix RGBLINK ignoring alignment constraints when placing empty sections
Fixes #2095
2026-09-17 11:16:18 -04:00
ISSOtm 6f69867d04 Make more RGBLINK tests use at-files
Less special handling = good

Possibly this can be done to more tests, but this is what I found.
2026-09-17 10:25:47 -04:00
ISSOtm 960f82126f Fix to actually allow one-past-the-end zero-sized sections in linker scripts 2026-09-17 10:19:47 -04:00
ISSOtm b9b5c9a2b4 Avoid reporting redundant errors on too-large fixed sect addr
This would happen for any such section of non-zero size.
2026-09-17 10:17:26 -04:00
Rangi aa657cd481 Make array buffers for snprintf just large enough for their uint32_t and uint16_t types
Note that `bank` can store 9 bytes (8 digits plus NUL terminator)
even though `section.bank` should never go above 16-bit (4 digits).
2026-09-17 10:12:05 -04:00
ISSOtm e39dbe1752 Remove no-op in link test script
No, `printf` does not do that.
This works because making it read from stdin suppresses
any words after the first one.
2026-09-17 09:35:32 -04:00
ISSOtm 9f175f7923 Use SectionTypeInfo struct member functions for section type info 2026-09-17 09:33:21 -04:00
Rangi b2967ff509 Correct rgblink(5) linkerscript doc to match behavior of unbanked ROMX/WRAMX (#2103) 2026-09-17 05:32:15 +02:00
RangiandEldred Habert e8d9eb4511 Document how multiple rgblink -S get merged (#2098)
Co-authored-by: Eldred Habert <[email protected]>
2026-09-17 01:52:10 +02:00
Rangi 589616338f Remove redundant conditional check (#2099)
If `nbBanks > 1` is true, then `sectionTypeInfo[type].firstBank !=
sectionTypeInfo[type].lastBank` must also be true, so checking
whether either is true is unnecessary.

(On the other hand, if `nbBanks == 1`, then we might still have
`sectionTypeInfo[type].firstBank != sectionTypeInfo[type].lastBank`,
since only one of many valid banks for `type` could be in use.)
2026-09-17 00:27:22 +02:00
ISSOtm 6587941512 Allow scrambling SRAM banks up to the full 8-bit range 2026-09-15 23:06:19 -04:00
Rangi 004749ea75 Halt processing when any ambiguous-transparency colors exist (#2093) 2026-09-16 04:03:56 +02:00
Rangi f4c6221eb1 Fix underflow of ALIGN[16, offset] (#2090) 2026-09-15 20:22:33 -04:00
Rangi d81ab2fb23 Fix underflowing SECTION FRAGMENT fixed address (#2091) 2026-09-15 20:22:19 -04:00
Rangi febdf63896 Fix invalid UTF-8 byte $E2 at the end of a symbol name reading past the string's end (#2092)
This is only possible in an invalid object file, but we do have other safety checks for those.

Assisted-by: opencode:big-pickle
2026-09-15 20:22:06 -04:00
Rangi b0f49a36b7 Fix -t/--tiny for ROMX in bank 1, and -w/--wramx for WRAMX in bank 1 (#2089) 2026-09-14 15:53:45 -04:00
Rangi ed1ac7309b Fix overflow with high fixed-point magnitudes 2026-09-14 14:27:16 -04:00
Rangi d082f24a2d Fix rounding of fixed-point constants where fractional digits should carry into integer part (#2088) 2026-09-14 13:52:39 -04:00
Rangi 7746ddbf2b Fix reverse-graphics check for whether the tilemap references too-high tile IDs in bank 1 (#2086) 2026-09-14 10:26:57 -04:00
Eldred Habert 0fe43bf0cb Use CMake-native methods to do our static-build macOS trickery (#2083)
This should remain equivalent for our current setups,
but play nicer with anyone wanting to experiment further.

It *may* break for someone building on an Intel Mac,
but this is a libpng limitation and thus out of our control.
2026-09-14 09:55:34 -04:00
Eldred Habert c8e8a2f522 Avoid duplicating warning flags when linking with the Makefile (#2085)
The warning flag list with `make develop` is quite long,
and this duplication is making those command lines particularly indigestible.
2026-09-13 20:35:54 -04:00
Eldred Habert de1e1ff688 Actually silence -Wformat et al. on MinGW (#2084)
Thus far, we have just ensured they wouldn't fail the build,
but they still pollute the build log, so we should silence them entirely.
2026-09-13 20:25:13 -04:00