diff --git a/man/rgbgfx.1 b/man/rgbgfx.1 index c768a82d..5cec72d6 100644 --- a/man/rgbgfx.1 +++ b/man/rgbgfx.1 @@ -161,7 +161,7 @@ Implies Set a maximum number of tiles that can be placed in each VRAM bank. .Ar nb_tiles should be one or two numbers between 0 and 256, separated by a comma; if the latter is omitted, it defaults to 0. -Setting either number to 0 prevents any tiles froom being output in that bank. +Setting either number to 0 prevents any tiles from being output in that bank. .Pp If more tiles are generated than can fit in the two banks combined, .Nm diff --git a/src/gfx/main.cpp b/src/gfx/main.cpp index ad187ff0..77d54e7d 100644 --- a/src/gfx/main.cpp +++ b/src/gfx/main.cpp @@ -307,7 +307,30 @@ int main(int argc, char *argv[]) { options.allowDedup = true; break; case 'N': - options.maxNbTiles = {0, 0}; // TODO + options.maxNbTiles[0] = parseNumber(arg, "Number of tiles in bank 0", 256); + if (options.maxNbTiles[0] > 256) { + error("Bank 0 cannot contain more than 256 tiles"); + } + if (*arg == '\0') { + options.maxNbTiles[1] = 0; + break; + } + skipWhitespace(arg); + if (*arg != ',') { + error("Bank capacity must be one or two comma-separated numbers, not \"%s\"", + musl_optarg); + break; + } + skipWhitespace(arg); + options.maxNbTiles[1] = parseNumber(arg, "Number of tiles in bank 1", 256); + if (options.maxNbTiles[1] > 256) { + error("Bank 1 cannot contain more than 256 tiles"); + } + if (*arg != '\0') { + error("Bank capacity must be one or two comma-separated numbers, not \"%s\"", + musl_optarg); + break; + } break; case 'n': options.nbPalettes = 0; // TODO