mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Implement SIZEOF("Section") and STARTOF("Section") (#766)
Updates the object file revision to 8 Fixes #765
This commit is contained in:
@@ -292,6 +292,11 @@ static int32_t computeRPNExpr(struct Patch const *patch,
|
||||
break;
|
||||
|
||||
case RPN_BANK_SECT:
|
||||
/*
|
||||
* `expression` is not guaranteed to be '\0'-terminated. If it is not,
|
||||
* `getRPNByte` will have a fatal internal error.
|
||||
* In either case, `getRPNByte` will not free `expression`.
|
||||
*/
|
||||
name = (char const *)expression;
|
||||
while (getRPNByte(&expression, &size, patch->src, patch->lineNo))
|
||||
;
|
||||
@@ -320,6 +325,44 @@ static int32_t computeRPNExpr(struct Patch const *patch,
|
||||
}
|
||||
break;
|
||||
|
||||
case RPN_SIZEOF_SECT:
|
||||
/* This has assumptions commented in the `RPN_BANK_SECT` case above. */
|
||||
name = (char const *)expression;
|
||||
while (getRPNByte(&expression, &size, patch->src, patch->lineNo))
|
||||
;
|
||||
|
||||
sect = sect_GetSection(name);
|
||||
|
||||
if (!sect) {
|
||||
error(patch->src, patch->lineNo,
|
||||
"Requested SIZEOF() of section \"%s\", which was not found",
|
||||
name);
|
||||
isError = true;
|
||||
value = 1;
|
||||
} else {
|
||||
value = sect->size;
|
||||
}
|
||||
break;
|
||||
|
||||
case RPN_STARTOF_SECT:
|
||||
/* This has assumptions commented in the `RPN_BANK_SECT` case above. */
|
||||
name = (char const *)expression;
|
||||
while (getRPNByte(&expression, &size, patch->src, patch->lineNo))
|
||||
;
|
||||
|
||||
sect = sect_GetSection(name);
|
||||
|
||||
if (!sect) {
|
||||
error(patch->src, patch->lineNo,
|
||||
"Requested STARTOF() of section \"%s\", which was not found",
|
||||
name);
|
||||
isError = true;
|
||||
value = 1;
|
||||
} else {
|
||||
value = sect->org;
|
||||
}
|
||||
break;
|
||||
|
||||
case RPN_HRAM:
|
||||
value = popRPN();
|
||||
if (!isError && (value < 0
|
||||
|
||||
Reference in New Issue
Block a user