diff --git a/001.simple_image/Makefile b/001.simple_image/Makefile index 41e51c0..060348c 100644 --- a/001.simple_image/Makefile +++ b/001.simple_image/Makefile @@ -1,11 +1,11 @@ MAKEADF=../tools/makeadf FLOPPY=bin/image.adf -EXTRA=out/image-copper.s out/image-data.bin +EXTRA=out/image-copper-list.s out/image.bin +IMAGEFILE=../assets/hello.png MODULE=image.s include ../base.mk -$(EXTRA): ../assets/hello.png ../tools/bitplanify.py - ../tools/bitplanify.py ../assets/hello.png --copper $(EXTRA) - +$(EXTRA): $(IMAGECON) $(IMAGEFILE) + $(IMAGECON) $(IMAGEFILE) out/image diff --git a/001.simple_image/image.s b/001.simple_image/image.s index e86c0b2..82a08d5 100644 --- a/001.simple_image/image.s +++ b/001.simple_image/image.s @@ -61,9 +61,9 @@ copper: dc.w BPL1MOD,SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES dc.w BPL2MOD,SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES - include "out/image-copper.s" + include "out/image-copper-list.s" dc.l $fffffffe bitplanes: - incbin "out/image-data.bin" + incbin "out/image.bin" \ No newline at end of file diff --git a/README.md b/README.md index 946547b..7c2fb7a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ (re)Learning how to program an Amiga after a 20 year break ========================================================== +Introduction +------------ +This repo is not meant to be an amiga programming guide. Documentation ------------- @@ -71,3 +74,23 @@ Notes: # make # make install ``` + +5. libtool + ``` + # wget http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz + # tar zxfv libtool-2.4.6.tar.gz + # cd libtool-2.4.6 + # ./configure --prefix=/usr/local + # make + # make install +``` + +6. libpng + ``` + # wget ftp://ftp.simplesystems.org/pub/png/src/libpng16/libpng-1.6.21.tar.gz + # tar zxfv libpng-1.6.21.tar.gz + # cd libpng-1.6.21 + # ./configure --prefix=/usr/local + # make + # make install +``` diff --git a/base.mk b/base.mk index 62fd25e..e2935c4 100644 --- a/base.mk +++ b/base.mk @@ -1,5 +1,7 @@ HOST_WARNINGS=-pedantic-errors -Wfatal-errors -Wall -Werror -Wextra -Wno-unused-parameter -Wshadow HOST_CFLAGS=-g $(HOST_WARNINGS) +IMAGECONDIR=../tools/imagecon +IMAGECON=$(IMAGECONDIR)/bin/imagecon all: bin out $(MAKEADF) $(FLOPPY) @@ -21,6 +23,9 @@ bin: out: mkdir out +$(IMAGECON): + make -C $(IMAGECONDIR) + $(MAKEADF): ../tools/makeadf.c gcc ../tools/makeadf.c -o $(MAKEADF) diff --git a/tools/imagecon/Makefile b/tools/imagecon/Makefile index c712eaf..e12a0f5 100644 --- a/tools/imagecon/Makefile +++ b/tools/imagecon/Makefile @@ -1,6 +1,23 @@ +IMAGECON=./bin/imagecon SRCS=imagecon.c HOST_WARNINGS=-pedantic-errors -Wfatal-errors -Wall -Werror -Wextra -Wno-unused-parameter -Wshadow HOST_CFLAGS=$(HOST_WARNINGS) -imagecon: $(SRCS) - gcc $(HOST_CFLAGS) $(SRCS) -o imagecon -lpng \ No newline at end of file +imagecon: out bin $(SRCS) + gcc $(HOST_CFLAGS) $(SRCS) -o $(IMAGECON) -lpng + +out: + mkdir out + +bin: + mkdir bin + +bitplane.bin copper-list.s: bin/imagecon + $(IMAGECON) ../../assets/hello.png out/hello + +test: bitplane.bin copper-list.s + diff out/hello.bin reference/bitplane.bin + diff out/hello-copper-list.s reference/copper-list.s + +clean: + rm -r out bin \ No newline at end of file diff --git a/tools/imagecon/imagecon.c b/tools/imagecon/imagecon.c index e9dc647..23c2503 100644 --- a/tools/imagecon/imagecon.c +++ b/tools/imagecon/imagecon.c @@ -16,88 +16,73 @@ #define PNG_DEBUG 3 #include +char** _argv; + void abort_(const char * s, ...) { + fprintf(stderr, "%s: ", _argv[0]); va_list args; va_start(args, s); vfprintf(stderr, s, args); fprintf(stderr, "\n"); va_end(args); - abort(); + exit(1); } -//int x, y; -int width, height, rowbytes; -png_byte color_type; -png_byte bit_depth; -png_structp png_ptr; -png_infop info_ptr; -int number_of_passes; -png_bytep * row_pointers; - - +int width, height; +png_bytep* rowPointers; +#define MAX_PALETTE 16 typedef struct { unsigned char r; unsigned char g; unsigned char b; } amiga_color_t; -#define MAX_PALETTE 16 -int blah[MAX_PALETTE] = {0xfff, 0xd12, 0x744, 0xe20, 0x362, 0x06a, 0x0b0, 0x1ae, 0x2b5, 0xf92, 0xe9a, 0xfa7, 0x9dc, 0xddd , 0xfe0 , 0xee9}; amiga_color_t palette[MAX_PALETTE]; int paletteIndex = 0; unsigned* amigaImage = 0; -void read_png_file(char* file_name) +void readFile(char* file_name) { - - /* for (int i = 0; i < MAX_PALETTE; i++) { - palette[i].r = blah[i] >> 8 & 0xf; - palette[i].g = blah[i] >> 4 & 0xf; - palette[i].b = blah[i] & 0xf; - } - paletteIndex = 16; - */ + png_structp png_ptr; + png_byte color_type; + png_byte bit_depth; + png_infop info_ptr; + int number_of_passes, rowbytes; unsigned char header[8]; // 8 is the maximum size that can be checked /* open file and test for it being a png */ FILE *fp = fopen(file_name, "rb"); if (!fp) - abort_("[read_png_file] File %s could not be opened for reading", file_name); + abort_("Failed to open %s", file_name); fread(header, 1, 8, fp); if (png_sig_cmp(header, 0, 8)) - abort_("[read_png_file] File %s is not recognized as a PNG file", file_name); - - - /* initialize stuff */ - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - + abort_("File %s is not recognized as a PNG file", file_name); + + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!png_ptr) - abort_("[read_png_file] png_create_read_struct failed"); + abort_("png_create_read_struct failed"); info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) - abort_("[read_png_file] png_create_info_struct failed"); + abort_("png_create_info_struct failed"); if (setjmp(png_jmpbuf(png_ptr))) - abort_("[read_png_file] Error during init_io"); + abort_("Error during init_io"); png_init_io(png_ptr, fp); png_set_sig_bytes(png_ptr, 8); png_read_info(png_ptr, info_ptr); - - width = png_get_image_width(png_ptr, info_ptr); height = png_get_image_height(png_ptr, info_ptr); color_type = png_get_color_type(png_ptr, info_ptr); bit_depth = png_get_bit_depth(png_ptr, info_ptr); - printf("width = %d\n", width); printf("height = %d\n", height); printf("color_type = %d (palette = %s)\n", color_type, color_type == PNG_COLOR_TYPE_PALETTE ? "yes" : "no"); @@ -129,12 +114,10 @@ void read_png_file(char* file_name) color_type = png_get_color_type(png_ptr, info_ptr); bit_depth = png_get_bit_depth(png_ptr, info_ptr); - - /* read file */ if (setjmp(png_jmpbuf(png_ptr))) - abort_("[read_png_file] Error during read_image"); + abort_("Error during read_image"); - row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height); + rowPointers = (png_bytep*) malloc(sizeof(png_bytep) * height); if (bit_depth == 16) rowbytes = width*8; @@ -142,9 +125,9 @@ void read_png_file(char* file_name) rowbytes = width*4; for (int y=0; y "); - - read_png_file(argv[1]); - process_file(); - // write_png_file(argv[2]); + _argv = argv; + + if (argc != 3) + abort_("usage: %s: ", argv[0]); + readFile(argv[1]); + processFile(argv[2]); + return 0; } diff --git a/tools/imagecon/reference/bitplane.bin b/tools/imagecon/reference/bitplane.bin new file mode 100644 index 0000000..3564258 Binary files /dev/null and b/tools/imagecon/reference/bitplane.bin differ diff --git a/tools/imagecon/reference/copper-list.s b/tools/imagecon/reference/copper-list.s new file mode 100644 index 0000000..c5310eb --- /dev/null +++ b/tools/imagecon/reference/copper-list.s @@ -0,0 +1,16 @@ + dc.w $180,$fff + dc.w $182,$ee9 + dc.w $184,$ddd + dc.w $186,$fe0 + dc.w $188,$fa7 + dc.w $18a,$9dc + dc.w $18c,$f92 + dc.w $18e,$2b5 + dc.w $190,$e20 + dc.w $192,$e9a + dc.w $194,$b0 + dc.w $196,$d12 + dc.w $198,$1ae + dc.w $19a,$6a + dc.w $19c,$744 + dc.w $19e,$362