mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-06 05:47:07 +00:00
Explicitly allow JR offsets to wrap around in RGBLINK
This reverts commit f27a8132d9.
This commit is contained in:
+4
-2
@@ -588,12 +588,14 @@ static void applyFilePatches(Section §ion, Section &dataSection) {
|
|||||||
// Offset is relative to the byte *after* the operand
|
// Offset is relative to the byte *after* the operand
|
||||||
// PC as operand to `jr` is lower than reference PC by 2
|
// PC as operand to `jr` is lower than reference PC by 2
|
||||||
uint16_t address = patch.pcSection->org + patch.pcOffset + 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) {
|
if (jumpOffset < -128 || jumpOffset > 127) {
|
||||||
firstErrorAt(
|
firstErrorAt(
|
||||||
patch,
|
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",
|
"; use `JP` instead",
|
||||||
jumpOffset
|
jumpOffset
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
SECTION "low", ROM0[$0048]
|
||||||
|
LCDInterrupt:
|
||||||
|
jr hLCDInterruptHandler
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
SECTION "high", HRAM[$FFE0]
|
||||||
|
hLCDInterruptHandler::
|
||||||
|
.jp: db ; should be $c3 (jp)
|
||||||
|
.address: dw
|
||||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
|||||||
|
; File generated by rgblink
|
||||||
|
00:0048 LCDInterrupt
|
||||||
|
00:ffe0 hLCDInterruptHandler
|
||||||
|
00:ffe0 hLCDInterruptHandler.jp
|
||||||
|
00:ffe1 hLCDInterruptHandler.address
|
||||||
@@ -191,6 +191,16 @@ tryDiff "$test"/ref.out.map "$outtemp"
|
|||||||
tryDiff "$test"/ref.out.sym "$outtemp2"
|
tryDiff "$test"/ref.out.sym "$outtemp2"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
|
test="jr-wraparound"
|
||||||
|
startTest
|
||||||
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
|
"$RGBASM" -o "$outtemp" "$test"/b.asm
|
||||||
|
continueTest
|
||||||
|
rgblinkQuiet -o "$gbtemp" -n "$outtemp2" "$otemp" "$outtemp"
|
||||||
|
tryCmpRom "$test"/ref.out.bin
|
||||||
|
tryDiff "$test"/ref.out.sym "$outtemp2"
|
||||||
|
evaluateTest
|
||||||
|
|
||||||
test="high-low"
|
test="high-low"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" "$test"/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
|
|||||||
Reference in New Issue
Block a user