From ecae3cfa3b3f0112fb3caa86caa0da129f5903d0 Mon Sep 17 00:00:00 2001 From: Jasper Renow-Clarke Date: Thu, 26 Oct 2023 15:57:51 +0100 Subject: [PATCH] Support 2bpp and 4bpp modes --- beeb/img2beeb.c | 49 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/beeb/img2beeb.c b/beeb/img2beeb.c index 5afb953..a40b839 100644 --- a/beeb/img2beeb.c +++ b/beeb/img2beeb.c @@ -38,6 +38,7 @@ int remap=0; long colours=0; long ext_colours=0; unsigned char quantpal[MAX_CMAP_SIZE*3]; +long bpp=2; // Default to 4-colour mode void loadpalette(const char *filename) { @@ -284,7 +285,7 @@ int numeric(const char c) void showsyntax() { fprintf(stderr, "img2beeb v%s - Jasper Renow-Clarke (c) 2022\n", REVISION); - fprintf(stderr, " Usage : img2beeb [-c] [-d] [-X] [-Y] [-f ] \n"); + fprintf(stderr, " Usage : img2beeb [-c] [-d] [-b] [-X] [-Y] [-f ] \n"); } int main(int argc, char **argv) @@ -340,6 +341,20 @@ int main(int argc, char **argv) switch (argv[argn][1]) { + case 'b': // bits per pixel + sscanf(&argv[argn][parampos], "%ld", &bpp); + + // Make sure bpp is a supported value + // + // 2 colours - not supported - MODES 0/4 + // 4 colours - 2bpp - MODES 1/5 + // 8 colours - 4bpp - MODE 2 + + if (bpp>4) bpp=4; + if (bpp==3) bpp=2; + if (bpp<2) bpp=2; + break; + case 'c': // max colours sscanf(&argv[argn][parampos], "%ld", &targetcolours); @@ -570,7 +585,7 @@ int main(int argc, char **argv) for (offs=0; offs