amiga_imgv

diff src/main.c @ 7:4c36d0f44aa6

lbm loading
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 29 Oct 2017 13:21:11 +0200
parents 663471a80c21
children
line diff
     1.1 --- a/src/main.c	Fri Oct 27 15:42:58 2017 +0300
     1.2 +++ b/src/main.c	Sun Oct 29 13:21:11 2017 +0200
     1.3 @@ -11,13 +11,37 @@
     1.4  
     1.5  int main(int argc, char **argv)
     1.6  {
     1.7 +	int i;
     1.8 +	unsigned int flags = 0;
     1.9 +	const char *fname = 0;
    1.10  	struct ham_image *img;
    1.11  
    1.12 -	if(argv[1]) {
    1.13 -		if(!(img = load_ham_image(argv[1]))) {
    1.14 -			fprintf(stderr, "failed to load image: %s\n", argv[1]);
    1.15 -			return 1;
    1.16 +	for(i=1; i<argc; i++) {
    1.17 +		if(argv[i][0] == '-') {
    1.18 +			if(strcmp(argv[i], "-ilace") == 0) {
    1.19 +				flags |= GFX_ILACE;
    1.20 +			} else {
    1.21 +				fprintf(stderr, "invalid option: %s\n", argv[i]);
    1.22 +				return 1;
    1.23 +			}
    1.24 +		} else {
    1.25 +			if(fname) {
    1.26 +				fprintf(stderr, "unexpected argument: %s\n", argv[i]);
    1.27 +				return 1;
    1.28 +			}
    1.29 +			fname = argv[i];
    1.30  		}
    1.31 +	}
    1.32 +
    1.33 +	if(fname) {
    1.34 +		if(!(img = load_ilbm(fname))) {
    1.35 +			if(!(img = load_ham_image(fname))) {
    1.36 +				fprintf(stderr, "failed to load image: %s\n", fname);
    1.37 +				return 1;
    1.38 +			}
    1.39 +		}
    1.40 +		logmsg("loaded %s: %dx%d, %d bitplanes%s\n", fname, img->width, img->height,
    1.41 +				img->nbitplanes, img->ham ? " (HAM)" : "");
    1.42  	} else {
    1.43  		printf("generating test image ...\n");
    1.44  		if(!(img = gen_ham_image(320, 256, 6))) {
    1.45 @@ -26,9 +50,13 @@
    1.46  		}
    1.47  	}
    1.48  
    1.49 -	if(gfx_init(6, GFX_HAM) == -1) {
    1.50 +	if(img->nbitplanes >= 6) img->ham = 1;	/* XXX */
    1.51 +	if(img->ham) flags |= GFX_HAM;
    1.52 +
    1.53 +	if(gfx_init(img->nbitplanes, flags) == -1) {
    1.54  		return 1;
    1.55  	}
    1.56 +	gfx_set_framebuffer(0, img->width, img->height);
    1.57  	gfx_wait_vblank();
    1.58  	gfx_show_image(img);
    1.59