Color verbose output as magenta

Output RGBASM's lexed tokens at level 5 (TRACE)
This commit is contained in:
Rangi42
2025-08-05 00:00:57 -04:00
parent ac75a085fa
commit 2cae47a5a2
9 changed files with 35 additions and 2 deletions

View File

@@ -3,11 +3,15 @@
#ifndef RGBDS_VERBOSITY_HPP
#define RGBDS_VERBOSITY_HPP
#include "style.hpp"
// This macro does not evaluate its arguments unless the condition is true.
#define verbosePrint(level, ...) \
do { \
if (checkVerbosity(level)) { \
style_Set(stderr, STYLE_MAGENTA, false); \
fprintf(stderr, __VA_ARGS__); \
style_Reset(stderr); \
} \
} while (0)

View File

@@ -2255,8 +2255,9 @@ yy::parser::symbol_type yylex() {
lexerState->lastToken = token.type;
lexerState->atLineStart = token.type == T_(NEWLINE) || token.type == T_(EOB);
// Uncomment this if you want to debug what the lexer is lexing:
// fprintf(stderr, "{lexing %s}\n", yy::parser::symbol_type(token.type).name());
// LCOV_EXCL_START
verbosePrint(VERB_TRACE, "Lexed '%s' token\n", yy::parser::symbol_type(token.type).name());
// LCOV_EXCL_STOP
if (std::holds_alternative<uint32_t>(token.value)) {
return yy::parser::symbol_type(token.type, std::get<uint32_t>(token.value));

View File

@@ -100,6 +100,8 @@ static void verboseOutputConfig(int argc, char *argv[]) {
return;
}
style_Set(stderr, STYLE_MAGENTA, false);
fprintf(stderr, "rgbasm %s\n", get_package_version_string());
printVVVVVVerbosity();
@@ -216,6 +218,8 @@ static void verboseOutputConfig(int argc, char *argv[]) {
// [-MG] [-MC]
}
fputs("Ready.\n", stderr);
style_Reset(stderr);
}
// LCOV_EXCL_STOP

View File

@@ -592,6 +592,8 @@ static void verboseOutputConfig() {
return;
}
style_Set(stderr, STYLE_MAGENTA, false);
fprintf(stderr, "rgbgfx %s\n", get_package_version_string());
printVVVVVVerbosity();
@@ -718,6 +720,8 @@ static void verboseOutputConfig() {
fprintf(stderr, "\tReverse image width: %" PRIu16 " tiles\n", options.reversedWidth);
}
fputs("Ready.\n", stderr);
style_Reset(stderr);
}
// LCOV_EXCL_STOP

View File

@@ -252,6 +252,7 @@ static void verboseOutputAssignments(
return;
}
style_Set(stderr, STYLE_MAGENTA, false);
for (AssignedSets const &assignment : assignments) {
fputs("{ ", stderr);
for (ColorSetAttrs const &attrs : assignment) {
@@ -262,6 +263,7 @@ static void verboseOutputAssignments(
}
fprintf(stderr, "} (volume = %zu)\n", assignment.volume());
}
style_Reset(stderr);
}
// LCOV_EXCL_STOP

View File

@@ -142,11 +142,13 @@ Png::Png(char const *filename, std::streambuf &file) {
}
if (checkVerbosity(VERB_INFO)) {
style_Set(stderr, STYLE_MAGENTA, false);
fprintf(stderr, "Embedded PNG palette has %d colors: [", nbColors);
for (int i = 0; i < nbColors; ++i) {
fprintf(stderr, "%s#%08x", i > 0 ? ", " : "", palette[i].toCSS());
}
fprintf(stderr, "]\n");
style_Reset(stderr);
}
} else {
verbosePrint(VERB_INFO, "No embedded PNG palette\n");

View File

@@ -338,12 +338,14 @@ static std::tuple<std::vector<size_t>, std::vector<Palette>>
// LCOV_EXCL_START
if (checkVerbosity(VERB_INFO)) {
style_Set(stderr, STYLE_MAGENTA, false);
fprintf(
stderr, "Color set mappings: (%zu palette%s)\n", nbPalettes, nbPalettes != 1 ? "s" : ""
);
for (size_t i = 0; i < mappings.size(); ++i) {
fprintf(stderr, "%zu -> %zu\n", i, mappings[i]);
}
style_Reset(stderr);
}
// LCOV_EXCL_STOP
@@ -440,6 +442,7 @@ static std::tuple<std::vector<size_t>, std::vector<Palette>>
static void outputPalettes(std::vector<Palette> const &palettes) {
// LCOV_EXCL_START
if (checkVerbosity(VERB_INFO)) {
style_Set(stderr, STYLE_MAGENTA, false);
for (Palette const &palette : palettes) {
fputs("{ ", stderr);
for (uint16_t colorIndex : palette) {
@@ -447,6 +450,7 @@ static void outputPalettes(std::vector<Palette> const &palettes) {
}
fputs("}\n", stderr);
}
style_Reset(stderr);
}
// LCOV_EXCL_STOP
@@ -915,6 +919,7 @@ void process() {
// LCOV_EXCL_START
if (checkVerbosity(VERB_INFO)) {
style_Set(stderr, STYLE_MAGENTA, false);
fputs("Image colors: [ ", stderr);
for (std::optional<Rgba> const &slot : image.colors) {
if (!slot.has_value()) {
@@ -923,6 +928,7 @@ void process() {
fprintf(stderr, "#%08x, ", slot->toCSS());
}
fputs("]\n", stderr);
style_Reset(stderr);
}
// LCOV_EXCL_STOP
@@ -1034,6 +1040,7 @@ continue_visiting_tiles:;
);
// LCOV_EXCL_START
if (checkVerbosity(VERB_INFO)) {
style_Set(stderr, STYLE_MAGENTA, false);
for (ColorSet const &colorSet : colorSets) {
fputs("[ ", stderr);
for (uint16_t color : colorSet) {
@@ -1041,6 +1048,7 @@ continue_visiting_tiles:;
}
fputs("]\n", stderr);
}
style_Reset(stderr);
}
// LCOV_EXCL_STOP

View File

@@ -95,6 +95,8 @@ static void verboseOutputConfig(int argc, char *argv[]) {
return;
}
style_Set(stderr, STYLE_MAGENTA, false);
fprintf(stderr, "rgblink %s\n", get_package_version_string());
printVVVVVVerbosity();
@@ -173,6 +175,8 @@ static void verboseOutputConfig(int argc, char *argv[]) {
// -n/--sym
printPath("Output sym file", options.symFileName);
fputs("Ready.\n", stderr);
style_Reset(stderr);
}
// LCOV_EXCL_STOP

View File

@@ -27,6 +27,8 @@ void printVVVVVVerbosity() {
return;
}
style_Set(stderr, STYLE_CYAN, true); // "Viridian"
putc('\n', stderr);
// clang-format off: vertically align values
static std::array<std::bitset<10>, 21> gfx{
@@ -70,6 +72,8 @@ void printVVVVVVerbosity() {
putc('\n', stderr);
}
putc('\n', stderr);
style_Set(stderr, STYLE_MAGENTA, false);
}
// LCOV_EXCL_STOP