mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Reduce more nesting depth, and fix an error message
This commit is contained in:
@@ -880,31 +880,33 @@ static void outputUnoptimizedTileData(
|
|||||||
|
|
||||||
for (auto [tile, attr] : zip(png.visitAsTiles(), attrmap)) {
|
for (auto [tile, attr] : zip(png.visitAsTiles(), attrmap)) {
|
||||||
// Do not emit fully-background tiles.
|
// Do not emit fully-background tiles.
|
||||||
if (!attr.isBackgroundTile()) {
|
if (attr.isBackgroundTile()) {
|
||||||
// If the tile is fully transparent, this defaults to palette 0.
|
++tileIdx;
|
||||||
Palette const &palette = palettes[attr.getPalID(mappings)];
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
bool empty = true;
|
// If the tile is fully transparent, this defaults to palette 0.
|
||||||
for (uint32_t y = 0; y < 8; ++y) {
|
Palette const &palette = palettes[attr.getPalID(mappings)];
|
||||||
uint16_t bitplanes = TileData::rowBitplanes(tile, palette, y);
|
|
||||||
if (bitplanes != 0) {
|
bool empty = true;
|
||||||
empty = false;
|
for (uint32_t y = 0; y < 8; ++y) {
|
||||||
}
|
uint16_t bitplanes = TileData::rowBitplanes(tile, palette, y);
|
||||||
if (tileIdx < nbKeptTiles) {
|
if (bitplanes != 0) {
|
||||||
output->sputc(bitplanes & 0xFF);
|
empty = false;
|
||||||
if (options.bitDepth == 2) {
|
}
|
||||||
output->sputc(bitplanes >> 8);
|
if (tileIdx < nbKeptTiles) {
|
||||||
}
|
output->sputc(bitplanes & 0xFF);
|
||||||
|
if (options.bitDepth == 2) {
|
||||||
|
output->sputc(bitplanes >> 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty && tileIdx >= nbKeptTiles) {
|
if (!empty && tileIdx >= nbKeptTiles) {
|
||||||
warning(
|
warning(
|
||||||
WARNING_TRIM_NONEMPTY,
|
WARNING_TRIM_NONEMPTY, "Trimming a nonempty tile (configure with '-x/--trim-end')"
|
||||||
"Trimming a nonempty tile (configure with '-x/--trim-end'"
|
);
|
||||||
);
|
break; // Don't repeat the warning for subsequent tiles
|
||||||
break; // Don't repeat the warning for subsequent tiles
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
++tileIdx;
|
++tileIdx;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,34 +263,31 @@ static void writeROM() {
|
|||||||
|
|
||||||
static void writeSymName(std::string const &name, FILE *file) {
|
static void writeSymName(std::string const &name, FILE *file) {
|
||||||
for (char const *ptr = name.c_str(); *ptr != '\0';) {
|
for (char const *ptr = name.c_str(); *ptr != '\0';) {
|
||||||
char c = *ptr;
|
// Output legal ASCII characters as-is
|
||||||
|
if (char c = *ptr; continuesIdentifier(c)) {
|
||||||
if (continuesIdentifier(c)) {
|
|
||||||
// Output legal ASCII characters as-is
|
|
||||||
putc(c, file);
|
putc(c, file);
|
||||||
++ptr;
|
++ptr;
|
||||||
} else {
|
continue;
|
||||||
// Output illegal characters using Unicode escapes ('\u' or '\U')
|
|
||||||
// Decode the UTF-8 codepoint; or at least attempt to
|
|
||||||
uint32_t state = UTF8_ACCEPT, codepoint;
|
|
||||||
|
|
||||||
do {
|
|
||||||
decode(&state, &codepoint, *ptr);
|
|
||||||
if (state == UTF8_REJECT) {
|
|
||||||
// This sequence was invalid; emit a U+FFFD, and recover
|
|
||||||
codepoint = 0xFFFD;
|
|
||||||
// Skip continuation bytes
|
|
||||||
// A NUL byte does not qualify, so we're good
|
|
||||||
while ((*ptr & 0xC0) == 0x80) {
|
|
||||||
++ptr;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++ptr;
|
|
||||||
} while (state != UTF8_ACCEPT);
|
|
||||||
|
|
||||||
fprintf(file, codepoint <= 0xFFFF ? "\\u%04" PRIx32 : "\\U%08" PRIx32, codepoint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Output illegal characters using Unicode escapes ('\u' or '\U')
|
||||||
|
// Decode the UTF-8 codepoint; or at least attempt to
|
||||||
|
uint32_t state = UTF8_ACCEPT, codepoint;
|
||||||
|
do {
|
||||||
|
decode(&state, &codepoint, *ptr);
|
||||||
|
if (state == UTF8_REJECT) {
|
||||||
|
// This sequence was invalid; emit a U+FFFD, and recover
|
||||||
|
codepoint = 0xFFFD;
|
||||||
|
// Skip continuation bytes
|
||||||
|
// A NUL byte does not qualify, so we're good
|
||||||
|
while ((*ptr & 0xC0) == 0x80) {
|
||||||
|
++ptr;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++ptr;
|
||||||
|
} while (state != UTF8_ACCEPT);
|
||||||
|
fprintf(file, codepoint <= 0xFFFF ? "\\u%04" PRIx32 : "\\U%08" PRIx32, codepoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
warning: [-Wtrim-nonempty]
|
warning: [-Wtrim-nonempty]
|
||||||
Trimming a nonempty tile (configure with '-x/--trim-end'
|
Trimming a nonempty tile (configure with '-x/--trim-end')
|
||||||
|
|||||||
Reference in New Issue
Block a user