shithub: rgbds

Download patch

ref: 76bb950be581e9fda94f231f235954290780665a
parent: f29c5d81ec304813fd5be546b7802eddc191cb52
author: ISSOtm <eldredhabert0@gmail.com>
date: Sat Mar 12 09:02:13 EST 2022

Parse bank capacities

--- a/man/rgbgfx.1
+++ b/man/rgbgfx.1
@@ -161,7 +161,7 @@
 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
--- a/src/gfx/main.cpp
+++ b/src/gfx/main.cpp
@@ -307,7 +307,30 @@
 			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