diff --git a/gr-utils/Makefile b/gr-utils/Makefile index 6bd60477..b3c87a9e 100644 --- a/gr-utils/Makefile +++ b/gr-utils/Makefile @@ -2,7 +2,7 @@ include ../Makefile.inc CFLAGS = -g -Wall -O2 -all: png2gr png2gr_text png2rle png_to_40x48d png_to_40x96 +all: png2gr png2gr_text png2rle png2lz4 png_to_40x48d png_to_40x96 ### @@ -36,6 +36,16 @@ png2rle.o: png2rle.c loadpng.h $(CC) $(CFLAGS) -c png2rle.c +### + +png2lz4: png2lz4.o loadpng.o + $(CC) $(LFLAGS) -lpng -o png2lz4 png2lz4.o loadpng.o + +png2lz4.o: png2lz4.c loadpng.h + $(CC) $(CFLAGS) -c png2lz4.c + + + ### png_to_40x48d: png_to_40x48d.o @@ -56,8 +66,8 @@ png_to_40x96.o: png_to_40x96.c ### install: - cp png2gr png2gr_text png2rle png_to_40x48d png_to_40x96 $(INSTALL_LOC) + cp png2gr png2gr_text png2rle png2lz4 png_to_40x48d png_to_40x96 $(INSTALL_LOC) clean: - rm -f *~ *.o png2gr png2gr_text png2rle png_to_40x48d png_to_40x96 + rm -f *~ *.o png2gr png2gr_text png2rle png2lz4 png_to_40x48d png_to_40x96 diff --git a/gr-utils/png2lz4.c b/gr-utils/png2lz4.c new file mode 100644 index 00000000..ee289b1e --- /dev/null +++ b/gr-utils/png2lz4.c @@ -0,0 +1,76 @@ +/*****************************************/ +/* Converts a PNG to LZ4 compressed data */ +/*****************************************/ +/* Note, it ignores memory holes so only */ +/* safe to load high and copy to the right location */ + + +#include +#include + +#include +#include +#include +#include +#include + +#include "loadpng.h" + +#define OUTPUT_C 0 +#define OUTPUT_ASM 1 +#define OUTPUT_RAW 2 + + +int gr_lz4(int out_type, char *name, int xsize, int ysize, + unsigned char *image) { + + /* our image pointer is not-interleaved, but it does */ + /* have the top/bottom pixels properly packed for us */ + + return 0; +} + + +/* Converts a PNG to LZ4 compressed data */ + +int main(int argc, char **argv) { + + unsigned char *image; + int xsize,ysize; + int size=0; + int out_type=OUTPUT_C; + + if (argc<4) { + fprintf(stderr,"Usage:\t%s type INFILE varname\n\n",argv[0]); + fprintf(stderr,"\ttype: c or asm or raw\n"); + fprintf(stderr,"\tvarname: label for graphic\n"); + fprintf(stderr,"\n"); + + exit(-1); + } + + if (!strcmp(argv[1],"c")) { + out_type=OUTPUT_C; + } + else if (!strcmp(argv[1],"asm")) { + out_type=OUTPUT_ASM; + } + else if (!strcmp(argv[1],"raw")) { + out_type=OUTPUT_RAW; + } + + if (loadpng(argv[2],&image,&xsize,&ysize)<0) { + fprintf(stderr,"Error loading png!\n"); + exit(-1); + } + + fprintf(stderr,"Loaded image %d by %d\n",xsize,ysize); + + size=gr_lz4(out_type,argv[3], + xsize,ysize,image); + + fprintf(stderr,"Size %d bytes\n",size); + + return 0; +} + diff --git a/ootw/Makefile b/ootw/Makefile index 5dd6dcdf..92631334 100644 --- a/ootw/Makefile +++ b/ootw/Makefile @@ -2,16 +2,18 @@ include ../Makefile.inc DOS33 = ../dos33fs-utils/dos33 PNG2RLE = ../gr-utils/png2rle +PNG2LZ4 = ../gr-utils/png2lz4 all: ootw.dsk -ootw.dsk: HELLO LOADER INTRO OOTW OOTW_C2 +ootw.dsk: HELLO LOADER INTRO OOTW OOTW_C2 COMPRESS-TEST $(DOS33) -y ootw.dsk SAVE A HELLO $(DOS33) -y ootw.dsk BSAVE -a 0x1800 LOADER $(DOS33) -y ootw.dsk BSAVE -a 0x2000 INTRO $(DOS33) -y ootw.dsk BSAVE -a 0x2000 OOTW $(DOS33) -y ootw.dsk BSAVE -a 0x2000 OOTW_C2 + $(DOS33) -y ootw.dsk BSAVE -a 0x2000 COMPRESS-TEST #### @@ -122,5 +124,17 @@ ootw_c2_cage.inc: $(PNG2RLE) ootw_c2_cage.png ##### +compress_test.inc: intro_graphics/07_soda/drinking01.png + $(PNG2RLE) asm intro_graphics/07_soda/drinking01.png test_rle > compress_test.inc + $(PNG2LZ4) asm intro_graphics/07_soda/drinking01.png test_lz4 >> compress_test.inc + +COMPRESS-TEST: compress_test.o + ld65 -o COMPRESS-TEST compress_test.o -C ../linker_scripts/apple2_2000.inc + +compress_test.o: compress_test.s compress_test.inc + ca65 -o compress_test.o compress_test.s -l compress_test.lst + +##### + clean: rm -f *~ *.o *.lst HELLO OOTW OOTW_C2 INTRO LOADER diff --git a/ootw/README b/ootw/README index fa8b569c..88b3fb47 100644 --- a/ootw/README +++ b/ootw/README @@ -7,3 +7,10 @@ it justice. Of course you could just play on your IIgs, but what's the fun in that. + + + +Up to tunnel1, using RLE: + 35875 INTRO + + using LZ4: diff --git a/ootw/compress_test.s b/ootw/compress_test.s new file mode 100644 index 00000000..a65b60fd --- /dev/null +++ b/ootw/compress_test.s @@ -0,0 +1,4 @@ + + +start: + rts