diff --git a/include/gfx/pal_spec.hpp b/include/gfx/pal_spec.hpp index 9423b97f..04fff542 100644 --- a/include/gfx/pal_spec.hpp +++ b/include/gfx/pal_spec.hpp @@ -3,9 +3,12 @@ #ifndef RGBDS_GFX_PAL_SPEC_HPP #define RGBDS_GFX_PAL_SPEC_HPP +#include + void parseInlinePalSpec(char const * const rawArg); void parseExternalPalSpec(char const *arg); void parseDmgPalSpec(char const * const rawArg); +void parseDmgPalSpec(uint8_t palSpecDmg); void parseBackgroundPalSpec(char const *arg); diff --git a/man/rgbgfx.1 b/man/rgbgfx.1 index fef83e09..6b191362 100644 --- a/man/rgbgfx.1 +++ b/man/rgbgfx.1 @@ -178,6 +178,13 @@ the low two bits 0-1 specify which gray shade goes in color index 0, the next two bits 2-3 specify which gray shade goes in color index 1, and so on. Gray shade 0 is the lightest (white), 3 is the darkest (black). +If +.Ar pal_spec +is the case-insensitive word +.Cm dmg , +then it acts like +.Cm dmg=E4 , +i.e. the darkest gray will end up in color index 0, and so on. The same gray shade cannot go in two color indexes. To specify a DMG palette, the input PNG must have all its colors in shades of gray, without any transparent colors. .It Sy automatic palette generation diff --git a/src/gfx/main.cpp b/src/gfx/main.cpp index 44e7a523..cf2ead20 100644 --- a/src/gfx/main.cpp +++ b/src/gfx/main.cpp @@ -322,6 +322,9 @@ static char *parseArgv(int argc, char *argv[]) { options.palSpecType = Options::EMBEDDED; } else if (strcasecmp(musl_optarg, "auto") == 0) { options.palSpecType = Options::NO_SPEC; + } else if (strcasecmp(musl_optarg, "dmg") == 0) { + options.palSpecType = Options::DMG; + parseDmgPalSpec(0xE4); // Same darkest-first order as `sortGrayscale` } else if (strncasecmp(musl_optarg, "dmg=", literal_strlen("dmg=")) == 0) { options.palSpecType = Options::DMG; parseDmgPalSpec(&musl_optarg[literal_strlen("dmg=")]); diff --git a/src/gfx/pal_spec.cpp b/src/gfx/pal_spec.cpp index 0fedea08..3b64762e 100644 --- a/src/gfx/pal_spec.cpp +++ b/src/gfx/pal_spec.cpp @@ -692,7 +692,11 @@ void parseDmgPalSpec(char const * const rawArg) { return; } - options.palSpecDmg = toHex(arg[0], arg[1]); + parseDmgPalSpec(toHex(arg[0], arg[1])); +} + +void parseDmgPalSpec(uint8_t palSpecDmg) { + options.palSpecDmg = palSpecDmg; // Map gray shades to their DMG color indexes for fast lookup by `Rgba::grayIndex` for (uint8_t i = 0; i < 4; ++i) { diff --git a/test/gfx/dmg_plte.flags b/test/gfx/dmg_plte.flags index bd22040c..6e015861 100644 --- a/test/gfx/dmg_plte.flags +++ b/test/gfx/dmg_plte.flags @@ -1,2 +1,3 @@ --c embedded --c DMG=E4 + # Override embedded with DMG + -c embedded + -c DMG