From 2cae47a5a2120315b40f01a8464bf3a65a4c9286 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Tue, 5 Aug 2025 00:00:57 -0400 Subject: [PATCH] Color verbose output as magenta Output RGBASM's lexed tokens at level 5 (TRACE) --- include/verbosity.hpp | 4 ++++ src/asm/lexer.cpp | 5 +++-- src/asm/main.cpp | 4 ++++ src/gfx/main.cpp | 4 ++++ src/gfx/pal_packing.cpp | 2 ++ src/gfx/png.cpp | 2 ++ src/gfx/process.cpp | 8 ++++++++ src/link/main.cpp | 4 ++++ src/verbosity.cpp | 4 ++++ 9 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/verbosity.hpp b/include/verbosity.hpp index 5b48c3ff..45e0fd33 100644 --- a/include/verbosity.hpp +++ b/include/verbosity.hpp @@ -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) diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index 4f92878a..04d3079b 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -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(token.value)) { return yy::parser::symbol_type(token.type, std::get(token.value)); diff --git a/src/asm/main.cpp b/src/asm/main.cpp index 1cd923cb..c9919e4f 100644 --- a/src/asm/main.cpp +++ b/src/asm/main.cpp @@ -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 diff --git a/src/gfx/main.cpp b/src/gfx/main.cpp index 4f5a7a43..a0f62143 100644 --- a/src/gfx/main.cpp +++ b/src/gfx/main.cpp @@ -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 diff --git a/src/gfx/pal_packing.cpp b/src/gfx/pal_packing.cpp index aea9aa67..b73c18d1 100644 --- a/src/gfx/pal_packing.cpp +++ b/src/gfx/pal_packing.cpp @@ -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 diff --git a/src/gfx/png.cpp b/src/gfx/png.cpp index 4ba777b8..46866dea 100644 --- a/src/gfx/png.cpp +++ b/src/gfx/png.cpp @@ -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"); diff --git a/src/gfx/process.cpp b/src/gfx/process.cpp index 52bef10a..5ecf8271 100644 --- a/src/gfx/process.cpp +++ b/src/gfx/process.cpp @@ -338,12 +338,14 @@ static std::tuple, std::vector> // 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> static void outputPalettes(std::vector 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 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 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 diff --git a/src/link/main.cpp b/src/link/main.cpp index 0b89388a..fd8f7665 100644 --- a/src/link/main.cpp +++ b/src/link/main.cpp @@ -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 diff --git a/src/verbosity.cpp b/src/verbosity.cpp index 79b5e2c1..6e7645aa 100644 --- a/src/verbosity.cpp +++ b/src/verbosity.cpp @@ -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, 21> gfx{ @@ -70,6 +72,8 @@ void printVVVVVVerbosity() { putc('\n', stderr); } putc('\n', stderr); + + style_Set(stderr, STYLE_MAGENTA, false); } // LCOV_EXCL_STOP