ootw: work on lz4 compression

This commit is contained in:
Vince Weaver 2019-02-25 12:28:42 -05:00
parent 0b2bb9ef49
commit 08769fc540
5 changed files with 115 additions and 4 deletions

View File

@ -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

76
gr-utils/png2lz4.c Normal file
View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#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;
}

View File

@ -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

View File

@ -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:

4
ootw/compress_test.s Normal file
View File

@ -0,0 +1,4 @@
start:
rts