Explicitly allow JR offsets to wrap around in RGBLINK

This reverts commit f27a8132d9.
This commit is contained in:
Rangi
2026-07-20 19:23:11 -04:00
parent 3b1606c63c
commit d9c0d37fd5
6 changed files with 26 additions and 2 deletions
+4 -2
View File
@@ -588,12 +588,14 @@ static void applyFilePatches(Section &section, Section &dataSection) {
// Offset is relative to the byte *after* the operand
// PC as operand to `jr` is lower than reference PC by 2
uint16_t address = patch.pcSection->org + patch.pcOffset + 2;
int32_t jumpOffset = value - address;
// The truncation of `value - address` is intentional, since
// a low ROM0 address may `jr` to a high HRAM one.
int16_t jumpOffset = value - address;
if (jumpOffset < -128 || jumpOffset > 127) {
firstErrorAt(
patch,
"`JR` target must be between -128 and 127 bytes away, not %" PRId32
"`JR` target must be between -128 and 127 bytes away, not %" PRId16
"; use `JP` instead",
jumpOffset
);