diff --git a/sdk/bin/Png2Rcs.exe b/sdk/bin/Png2Rcs.exe new file mode 100755 index 0000000..38287b7 Binary files /dev/null and b/sdk/bin/Png2Rcs.exe differ diff --git a/sdk/bin/Png2Rcs.exe.license b/sdk/bin/Png2Rcs.exe.license new file mode 100644 index 0000000..4dc3b12 --- /dev/null +++ b/sdk/bin/Png2Rcs.exe.license @@ -0,0 +1,11 @@ +SPDX-FileName: Png2Rcs.exe + +SPDX-FileType: BINARY + +SPDX-FileChecksum: SHA1: b4e6b170505332ac11ddc0e163a3de6a6a4cfd3a + +SPDX-FileCopyrightText: Copyright (C) 2014, 2015, 2021 Antonio Villena + +SPDX-License-Identifier: GPL-3.0-only + +SPDX-FileComment: Png2Rcs version 1.20 (31 May 2015) - Image to ZX Spectrum RCS screen. diff --git a/sdk/src/tools/Makefile b/sdk/src/tools/Makefile index 535d941..8197cc7 100644 --- a/sdk/src/tools/Makefile +++ b/sdk/src/tools/Makefile @@ -36,10 +36,14 @@ BINS:=\ fpad$(EXESUFFIX)\ fpoke$(EXESUFFIX)\ rcs$(EXESUFFIX)\ + Png2Rcs$(EXESUFFIX)\ GenRom$(EXESUFFIX)\ AddItem$(EXESUFFIX)\ Bit2Bin$(EXESUFFIX) +INCLUDEDIR = $(ZXSDK)/include +LIBDIR = $(ZXSDK)/lib + .PHONY: all all: $(foreach t,$(BINS),build/$(t)) @@ -47,6 +51,13 @@ build\ $(DESTDIR)$(bindir): mkdir -p $@ +build/Png2Rcs$(EXESUFFIX):\ + $(srcdir)/Png2Rcs.c\ + $(INCLUDEDIR)/lodepng.h\ + $(LIBDIR)/liblodepng$(DLLSUFFIX)\ + Makefile | build + $(CC) -I$(INCLUDEDIR) -L$(LIBDIR) -l:liblodepng$(DLLSUFFIX) $(CFLAGS) -o $@ $< + build/%$(EXESUFFIX): $(srcdir)/%.c Makefile | build $(CC) $(CFLAGS) -o $@ $< diff --git a/firmware/scroll/Png2Rcs.c b/sdk/src/tools/Png2Rcs.c similarity index 56% rename from firmware/scroll/Png2Rcs.c rename to sdk/src/tools/Png2Rcs.c index 64f4ba3..ecbad2f 100644 --- a/firmware/scroll/Png2Rcs.c +++ b/sdk/src/tools/Png2Rcs.c @@ -1,6 +1,43 @@ +/* + * Png2Rcs - convert image to ZX Spectrum RCS screen. + * + * Copyright (C) 2014, 2015, 2021 Antonio Villena + * Contributors: + * 2015 David Skywalker + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-FileCopyrightText: Copyright (C) 2014, 2015, 2021 Antonio Villena + * + * SPDX-FileContributor: 2015 David Skywalker + * + * SPDX-License-Identifier: GPL-3.0-only + */ + #include #include -#include "lodepng.c" +#include "lodepng.h" + +#define PROGRAM "Png2Rcs" +#define DESCRIPTION "Image to ZX Spectrum RCS screen." +#define VERSION "1.20 (31 May 2015)" +#define COPYRIGHT "Copyright (C) 2014, 2015, 2021 Antonio Villena" +#define LICENSE \ +"This program is free software: you can redistribute it and/or modify\n" \ +"it under the terms of the GNU General Public License as published by\n" \ +"the Free Software Foundation, version 3." +#define HOMEPAGE "https://github.com/zxdos/zxuno/" + unsigned char *image, *pixel, output[0x5b00], input[0x300]; unsigned error, width, height, i, j, k, l, m, fondo, tinta, outpos= 0, input1= 0, input2= 0, output1= 0, output2= 0, inverse= 0; @@ -15,16 +52,29 @@ int tospec(int r, int g, int b){ return ((r|g|b)==255 ? 8 : 0) | g>>7<<2 | r>>7<<1 | b>>7; } +void show_help() { + printf( + PROGRAM " version " VERSION " - " DESCRIPTION "\n" + COPYRIGHT "\n" + LICENSE "\n" + "Home page: " HOMEPAGE "\n" + "\n" + "Usage:\n" + " " PROGRAM " [output_attr] [-i] [-a input_attr]\n" + "\n" + " 256x64, 256x128 or 256x192 png file\n" + " ZX spectrum output in RCS format\n" + " If specified, output attributes here\n" + " -i Inverse behaviour, force darker inks\n" + " -a Force attributes specifying the file\n" + "\n" + "Example: " PROGRAM " loading.png loading.rcs\n" + ); +} + int main(int argc, char *argv[]){ if( argc==1 ) - printf("\nPng2Rcs v1.20. Image to ZX Spectrum RCS screen by AntonioVillena, 7 Jul 2014\n\n" - " Png2Rcs [output_attr] [-i] [-a input_attr]\n\n" - " 256x64, 256x128 or 256x192 png file\n" - " ZX spectrum output in RCS format\n" - " If specified, output attributes here\n" - " -i Inverse behaviour, force darker inks\n" - " -a Force attributes specifying the file\n\n" - "Example: Png2Rcs loading.png loading.rcs\n"), + show_help(), exit(0); for ( i= 0; i192 || height&63 ) - printf("\nError. Incorrect size on %s, must be 256x64, 256x128 or 256x192", argv[input1]); + printf("Error. Incorrect size on %s, must be 256x64, 256x128 or 256x192", argv[input1]); if( input2 ) fo= fopen(argv[input2], "rb"), 0!=fread(input, 1, 0x300, fo), fclose(fo); fo= fopen(argv[output1], "wb+"); if( !fo ) - printf("\nCannot create output file: %s\n", argv[output1]), + printf("Cannot create output file: %s\n", argv[output1]), exit(-1); for ( i= 0; i < height>>6; i++ ) for ( j= 0; j < 32; j++ ) @@ -83,12 +133,12 @@ int main(int argc, char *argv[]){ pixel= &image[(i<<14 | j<<3 | k<<11 | l<<8 | m)<<2]; if( !(check(pixel[0]) && check(pixel[1]) && check(pixel[2])) || ((char)pixel[0]*-1 | (char)pixel[1]*-1 | (char)pixel[2]*-1)==65 ) - printf("\nThe pixel (%d, %d) has an incorrect color\n" , m|j<<3, l|k<<3|i<<6), + printf("The pixel (%d, %d) has an incorrect color\n" , m|j<<3, l|k<<3|i<<6), exit(-1); if( input2 ){ if( (tinta|8) != (tospec(pixel[0], pixel[1], pixel[2])|8) && (fondo|8) != (tospec(pixel[0], pixel[1], pixel[2])|8) ) - printf("\nThe pixel (%d, %d) has a third color in the cell\n", m|j<<3, l|k<<3|i<<6), + printf("The pixel (%d, %d) has a third color in the cell\n", m|j<<3, l|k<<3|i<<6), exit(-1); celda<<= 1; celda|= (fondo|8) != (tospec(pixel[0], pixel[1], pixel[2])|8); @@ -97,7 +147,7 @@ int main(int argc, char *argv[]){ if( tinta != tospec(pixel[0], pixel[1], pixel[2]) ) if( fondo != tospec(pixel[0], pixel[1], pixel[2]) ){ if( tinta != fondo ) - printf("\nThe pixel (%d, %d) has a third color in the cell\n", m|j<<3, l|k<<3|i<<6), + printf("The pixel (%d, %d) has a third color in the cell\n", m|j<<3, l|k<<3|i<<6), exit(-1); tinta= tospec(pixel[0], pixel[1], pixel[2]); } @@ -139,14 +189,14 @@ int main(int argc, char *argv[]){ fclose(fo); fo= fopen(argv[output2], "wb+"); if( !fo ) - printf("\nCannot create output file: %s\n", argv[output2]), + printf("Cannot create output file: %s\n", argv[output2]), exit(-1); fwrite(output+(height<<5), 1, height<<2, fo); - printf("\nFiles %s and %s generated from %s\n", argv[output1], argv[output2], argv[input1]); + printf("Files %s and %s generated from %s\n", argv[output1], argv[output2], argv[input1]); } else fwrite(output, 1, height*36, fo), - printf("\nFile %s filtered from %s\n", argv[output1], argv[input1]); + printf("File %s filtered from %s\n", argv[output1], argv[input1]); fclose(fo); free(image); }