mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Run clang-format
This commit is contained in:
@@ -72,7 +72,7 @@ void charmap_New(std::string const &name, std::string const *baseName) {
|
|||||||
Charmap &charmap = charmapList.emplace_back();
|
Charmap &charmap = charmapList.emplace_back();
|
||||||
|
|
||||||
if (baseIdx != (size_t)-1) {
|
if (baseIdx != (size_t)-1) {
|
||||||
charmap.nodes = charmapList[baseIdx].nodes; // Copies `charmapList[baseIdx].nodes`
|
charmap.nodes = charmapList[baseIdx].nodes; // Copies `charmapList[baseIdx].nodes`
|
||||||
charmap.mappings = charmapList[baseIdx].mappings; // Copies `charmapList[baseIdx].mappings`
|
charmap.mappings = charmapList[baseIdx].mappings; // Copies `charmapList[baseIdx].mappings`
|
||||||
} else {
|
} else {
|
||||||
charmap.nodes.emplace_back(); // Zero-init the root node
|
charmap.nodes.emplace_back(); // Zero-init the root node
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ int main(int argc, char *argv[]) {
|
|||||||
: !strcasecmp(feature, "equs") ? STATE_EQUS
|
: !strcasecmp(feature, "equs") ? STATE_EQUS
|
||||||
: !strcasecmp(feature, "char") ? STATE_CHAR
|
: !strcasecmp(feature, "char") ? STATE_CHAR
|
||||||
: !strcasecmp(feature, "macro") ? STATE_MACRO
|
: !strcasecmp(feature, "macro") ? STATE_MACRO
|
||||||
: NB_STATE_FEATURES;
|
: NB_STATE_FEATURES;
|
||||||
if (value == NB_STATE_FEATURES) {
|
if (value == NB_STATE_FEATURES) {
|
||||||
errx("Invalid feature for option 's': \"%s\"", feature);
|
errx("Invalid feature for option 's': \"%s\"", feature);
|
||||||
} else if (std::find(RANGE(features), value) != features.end()) {
|
} else if (std::find(RANGE(features), value) != features.end()) {
|
||||||
|
|||||||
@@ -76,11 +76,11 @@ void sect_CheckSizes() {
|
|||||||
for (Section const § : sectionList) {
|
for (Section const § : sectionList) {
|
||||||
if (uint32_t maxSize = sectionTypeInfo[sect.type].size; sect.size > maxSize)
|
if (uint32_t maxSize = sectionTypeInfo[sect.type].size; sect.size > maxSize)
|
||||||
error(
|
error(
|
||||||
"Section '%s' grew too big (max size = 0x%" PRIX32 " bytes, reached 0x%" PRIX32
|
"Section '%s' grew too big (max size = 0x%" PRIX32 " bytes, reached 0x%" PRIX32
|
||||||
").\n",
|
").\n",
|
||||||
sect.name.c_str(),
|
sect.name.c_str(),
|
||||||
maxSize,
|
maxSize,
|
||||||
sect.size
|
sect.size
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -837,8 +837,7 @@ void sect_BinaryFile(std::string const &name, int32_t startPos) {
|
|||||||
while (startPos--) {
|
while (startPos--) {
|
||||||
if (fgetc(file) == EOF) {
|
if (fgetc(file) == EOF) {
|
||||||
error(
|
error(
|
||||||
"Specified start position is greater than length of file '%s'\n",
|
"Specified start position is greater than length of file '%s'\n", name.c_str()
|
||||||
name.c_str()
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -908,8 +907,7 @@ void sect_BinaryFileSlice(std::string const &name, int32_t startPos, int32_t len
|
|||||||
while (startPos--) {
|
while (startPos--) {
|
||||||
if (fgetc(file) == EOF) {
|
if (fgetc(file) == EOF) {
|
||||||
error(
|
error(
|
||||||
"Specified start position is greater than length of file '%s'\n",
|
"Specified start position is greater than length of file '%s'\n", name.c_str()
|
||||||
name.c_str()
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -750,7 +750,7 @@ public:
|
|||||||
if (options.allowMirroringX) {
|
if (options.allowMirroringX) {
|
||||||
// Count the line itself as mirrorred horizontally; vertical mirroring is already
|
// Count the line itself as mirrorred horizontally; vertical mirroring is already
|
||||||
// taken care of because the symmetric line will be XOR'd the same way.
|
// taken care of because the symmetric line will be XOR'd the same way.
|
||||||
// (...this reduces the hash's efficiency, but seems benign with most real-world data.)
|
// (This reduces the hash's efficiency, but seems benign with most real-world data.)
|
||||||
_hash ^= flipTable[bitplanes >> 8] << 8 | flipTable[bitplanes & 0xFF];
|
_hash ^= flipTable[bitplanes >> 8] << 8 | flipTable[bitplanes & 0xFF];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,8 +183,7 @@ static ssize_t getPlacement(Section const §ion, MemoryLocation &location) {
|
|||||||
location.bank = scrambleROMX + 1;
|
location.bank = scrambleROMX + 1;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
} else if (scrambleWRAMX && section.type == SECTTYPE_WRAMX
|
} else if (scrambleWRAMX && section.type == SECTTYPE_WRAMX && location.bank <= scrambleWRAMX) {
|
||||||
&& location.bank <= scrambleWRAMX) {
|
|
||||||
if (location.bank > typeInfo.firstBank)
|
if (location.bank > typeInfo.firstBank)
|
||||||
location.bank--;
|
location.bank--;
|
||||||
else if (scrambleWRAMX < typeInfo.lastBank)
|
else if (scrambleWRAMX < typeInfo.lastBank)
|
||||||
@@ -237,8 +236,9 @@ static void placeSection(Section §ion) {
|
|||||||
assignSection(section, location);
|
assignSection(section, location);
|
||||||
|
|
||||||
// Update the free space
|
// Update the free space
|
||||||
|
uint16_t sectionEnd = section.org + section.size;
|
||||||
bool noLeftSpace = freeSpace.address == section.org;
|
bool noLeftSpace = freeSpace.address == section.org;
|
||||||
bool noRightSpace = freeSpace.address + freeSpace.size == section.org + section.size;
|
bool noRightSpace = freeSpace.address + freeSpace.size == sectionEnd;
|
||||||
if (noLeftSpace && noRightSpace) {
|
if (noLeftSpace && noRightSpace) {
|
||||||
// The free space is entirely deleted
|
// The free space is entirely deleted
|
||||||
bankMem.erase(bankMem.begin() + spaceIdx);
|
bankMem.erase(bankMem.begin() + spaceIdx);
|
||||||
@@ -247,12 +247,11 @@ static void placeSection(Section §ion) {
|
|||||||
// Append the new space after the original one
|
// Append the new space after the original one
|
||||||
bankMem.insert(
|
bankMem.insert(
|
||||||
bankMem.begin() + spaceIdx + 1,
|
bankMem.begin() + spaceIdx + 1,
|
||||||
{.address = (uint16_t)(section.org + section.size),
|
{.address = sectionEnd,
|
||||||
.size = (uint16_t)(freeSpace.address + freeSpace.size - section.org - section.size)
|
.size = (uint16_t)(freeSpace.address + freeSpace.size - sectionEnd)}
|
||||||
}
|
|
||||||
);
|
);
|
||||||
// **`freeSpace` cannot be reused from this point on**, because `bankMem.insert`
|
// **`freeSpace` cannot be reused from this point on, because `bankMem.insert`
|
||||||
// invalidates all references to itself!
|
// invalidates all references to itself!**
|
||||||
|
|
||||||
// Resize the original space (address is unmodified)
|
// Resize the original space (address is unmodified)
|
||||||
bankMem[spaceIdx].size = section.org - bankMem[spaceIdx].address;
|
bankMem[spaceIdx].size = section.org - bankMem[spaceIdx].address;
|
||||||
|
|||||||
@@ -625,7 +625,8 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) {
|
|||||||
Label &label = fileSymbols[i].data.get<Label>();
|
Label &label = fileSymbols[i].data.get<Label>();
|
||||||
if (Section *section = label.section; section->modifier != SECTION_NORMAL) {
|
if (Section *section = label.section; section->modifier != SECTION_NORMAL) {
|
||||||
if (section->modifier == SECTION_FRAGMENT) {
|
if (section->modifier == SECTION_FRAGMENT) {
|
||||||
// Add the fragment's offset to the symbol's (`section->offset` is computed by `sect_AddSection`)
|
// Add the fragment's offset to the symbol's
|
||||||
|
// (`section->offset` is computed by `sect_AddSection`)
|
||||||
label.offset += section->offset;
|
label.offset += section->offset;
|
||||||
}
|
}
|
||||||
// Associate the symbol with the main section, not the "component" one
|
// Associate the symbol with the main section, not the "component" one
|
||||||
|
|||||||
@@ -880,7 +880,8 @@ void sdobj_ReadFile(FileStackNode const &where, FILE *file, std::vector<Symbol>
|
|||||||
Label &label = sym.data.get<Label>();
|
Label &label = sym.data.get<Label>();
|
||||||
if (Section *section = label.section; section->modifier != SECTION_NORMAL) {
|
if (Section *section = label.section; section->modifier != SECTION_NORMAL) {
|
||||||
if (section->modifier == SECTION_FRAGMENT) {
|
if (section->modifier == SECTION_FRAGMENT) {
|
||||||
// Add the fragment's offset to the symbol's (`section->offset` is computed by `sect_AddSection`)
|
// Add the fragment's offset to the symbol's
|
||||||
|
// (`section->offset` is computed by `sect_AddSection`)
|
||||||
label.offset += section->offset;
|
label.offset += section->offset;
|
||||||
}
|
}
|
||||||
// Associate the symbol with the main section, not the "component" one
|
// Associate the symbol with the main section, not the "component" one
|
||||||
|
|||||||
@@ -231,7 +231,12 @@ static void doSanityChecks(Section §ion) {
|
|||||||
if (section.type < 0 || section.type >= SECTTYPE_INVALID) {
|
if (section.type < 0 || section.type >= SECTTYPE_INVALID) {
|
||||||
// This is trapped early in RGBDS objects (because then the format is not parseable),
|
// This is trapped early in RGBDS objects (because then the format is not parseable),
|
||||||
// which leaves SDAS objects.
|
// which leaves SDAS objects.
|
||||||
error(nullptr, 0, "Section \"%s\" has not been assigned a type by a linker script", section.name.c_str());
|
error(
|
||||||
|
nullptr,
|
||||||
|
0,
|
||||||
|
"Section \"%s\" has not been assigned a type by a linker script",
|
||||||
|
section.name.c_str()
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user