mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-24 20:12:07 +00:00
@@ -286,8 +286,7 @@ static void readPatch(FILE *file, struct Patch *patch, char const *fileName, cha
|
||||
tryGetc(type, file,
|
||||
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s type: %s",
|
||||
fileName, sectName, i);
|
||||
patch->type = type & 0x7F;
|
||||
patch->isOperand = type & PATCH_ISOPERAND;
|
||||
patch->type = type;
|
||||
tryReadlong(patch->rpnSize, file,
|
||||
"%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s RPN size: %s",
|
||||
fileName, sectName, i);
|
||||
|
||||
@@ -421,10 +421,6 @@ static int32_t computeRPNExpr(struct Patch const *patch,
|
||||
isError = true;
|
||||
} else {
|
||||
value = patch->pcOffset + patch->pcSection->org;
|
||||
// If the patch is an operand, PC is not at the patch's
|
||||
// location, but at the (opcode) byte right before it
|
||||
if (patch->isOperand)
|
||||
value--;
|
||||
}
|
||||
} else {
|
||||
symbol = getSymbol(fileSymbols, value);
|
||||
@@ -520,9 +516,10 @@ static void applyFilePatches(struct Section *section, struct Section *dataSectio
|
||||
|
||||
/* `jr` is quite unlike the others... */
|
||||
if (patch->type == PATCHTYPE_JR) {
|
||||
/* Target 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
|
||||
uint16_t address = patch->pcSection->org
|
||||
+ patch->pcOffset + 1;
|
||||
+ patch->pcOffset + 2;
|
||||
int16_t jumpOffset = value - address;
|
||||
|
||||
if (!isError && (jumpOffset < -128 || jumpOffset > 127))
|
||||
|
||||
Reference in New Issue
Block a user