mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Allow JR between sections
Previously, JR was only allowed if the destination label was in the same section as the JR. This patch removes this restriction. The check to see if the relative value overflows is now done when linking the ROM. Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
@@ -267,6 +267,7 @@ void Patch(void)
|
||||
pPatch = pSect->pPatches;
|
||||
while (pPatch) {
|
||||
int32_t t;
|
||||
int32_t nPatchOrg;
|
||||
|
||||
nPC = pSect->nOrg + pPatch->nOffset;
|
||||
t = calcrpn(pPatch);
|
||||
@@ -306,6 +307,24 @@ void Patch(void)
|
||||
pSect->pData[pPatch->nOffset + 3] =
|
||||
(t >> 24) & 0xFF;
|
||||
break;
|
||||
case PATCH_BYTE_JR:
|
||||
/* Calculate absolute address of the patch */
|
||||
nPatchOrg = pSect->nOrg + pPatch->nOffset;
|
||||
|
||||
/* t contains the destination of the jump */
|
||||
t = (int16_t)((t & 0xFFFF) - (nPatchOrg + 1));
|
||||
|
||||
if (t >= -128 && t <= 255) {
|
||||
t &= 0xFF;
|
||||
pSect->pData[pPatch->nOffset] =
|
||||
(uint8_t)t;
|
||||
} else {
|
||||
errx(1,
|
||||
"%s(%ld) : Value must be 8-bit",
|
||||
pPatch->pzFilename,
|
||||
pPatch->nLineNo);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
pPatch = pPatch->pNext;
|
||||
|
||||
Reference in New Issue
Block a user