mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
Switch linkdefs from scattered arrays to an array of structs
The info is better organized this way
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "link/section.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "linkdefs.h"
|
||||
|
||||
FILE *linkerScript;
|
||||
char *includeFileName;
|
||||
@@ -299,7 +300,7 @@ static struct LinkerScriptToken *nextToken(void)
|
||||
if (token.type == TOKEN_INVALID) {
|
||||
/* Try to match a bank specifier */
|
||||
for (enum SectionType type = 0; type < SECTTYPE_INVALID; type++) {
|
||||
if (!strcmp(typeNames[type], str)) {
|
||||
if (!strcmp(sectionTypeInfo[type].name, str)) {
|
||||
token.type = TOKEN_BANK;
|
||||
token.attr.secttype = type;
|
||||
break;
|
||||
@@ -376,7 +377,7 @@ struct SectionPlacement *script_NextSection(void)
|
||||
for (enum SectionType i = 0; i < SECTTYPE_INVALID; i++) {
|
||||
curaddr[i] = malloc(sizeof(*curaddr[i]) * nbbanks(i));
|
||||
for (uint32_t b = 0; b < nbbanks(i); b++)
|
||||
curaddr[i][b] = startaddr[i];
|
||||
curaddr[i][b] = sectionTypeInfo[i].startAddr;
|
||||
}
|
||||
|
||||
placement.type = SECTTYPE_INVALID;
|
||||
@@ -394,12 +395,12 @@ struct SectionPlacement *script_NextSection(void)
|
||||
if (placement.type != SECTTYPE_INVALID) {
|
||||
if (curaddr[placement.type][bankID] > endaddr(placement.type) + 1)
|
||||
errx("%s(%" PRIu32 "): Sections would extend past the end of %s ($%04" PRIx16 " > $%04" PRIx16 ")",
|
||||
linkerScriptName, lineNo, typeNames[placement.type],
|
||||
linkerScriptName, lineNo, sectionTypeInfo[placement.type].name,
|
||||
curaddr[placement.type][bankID], endaddr(placement.type));
|
||||
if (curaddr[placement.type][bankID] < startaddr[placement.type])
|
||||
if (curaddr[placement.type][bankID] < sectionTypeInfo[placement.type].startAddr)
|
||||
errx("%s(%" PRIu32 "): PC underflowed ($%04" PRIx16 " < $%04" PRIx16 ")",
|
||||
linkerScriptName, lineNo,
|
||||
curaddr[placement.type][bankID], startaddr[placement.type]);
|
||||
curaddr[placement.type][bankID], sectionTypeInfo[placement.type].startAddr);
|
||||
}
|
||||
|
||||
switch (parserState) {
|
||||
@@ -483,17 +484,17 @@ struct SectionPlacement *script_NextSection(void)
|
||||
errx("%s(%" PRIu32 "): Didn't specify a bank number",
|
||||
linkerScriptName, lineNo);
|
||||
else if (!hasArg)
|
||||
arg = bankranges[placement.type][0];
|
||||
else if (arg < bankranges[placement.type][0])
|
||||
arg = sectionTypeInfo[placement.type].firstBank;
|
||||
else if (arg < sectionTypeInfo[placement.type].firstBank)
|
||||
errx("%s(%" PRIu32 "): specified bank number is too low (%" PRIu32 " < %" PRIu32 ")",
|
||||
linkerScriptName, lineNo,
|
||||
arg, bankranges[placement.type][0]);
|
||||
else if (arg > bankranges[placement.type][1])
|
||||
arg, sectionTypeInfo[placement.type].firstBank);
|
||||
else if (arg > sectionTypeInfo[placement.type].lastBank)
|
||||
errx("%s(%" PRIu32 "): specified bank number is too high (%" PRIu32 " > %" PRIu32 ")",
|
||||
linkerScriptName, lineNo,
|
||||
arg, bankranges[placement.type][1]);
|
||||
arg, sectionTypeInfo[placement.type].lastBank);
|
||||
bank = arg;
|
||||
bankID = arg - bankranges[placement.type][0];
|
||||
bankID = arg - sectionTypeInfo[placement.type].firstBank;
|
||||
}
|
||||
|
||||
/* If we read a token we shouldn't have... */
|
||||
|
||||
Reference in New Issue
Block a user