amiga_imgv

diff src/sdl/gfx.c @ 4:0fd37effde29

progress
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 27 Oct 2017 11:36:18 +0300
parents 663471a80c21
children 0d3d7b020e6a
line diff
     1.1 --- a/src/sdl/gfx.c	Thu Oct 26 15:49:56 2017 +0300
     1.2 +++ b/src/sdl/gfx.c	Fri Oct 27 11:36:18 2017 +0300
     1.3 @@ -24,6 +24,7 @@
     1.4  		SDL_Quit();
     1.5  		return -1;
     1.6  	}
     1.7 +	SDL_WM_SetCaption("imgv SDL version", 0);
     1.8  
     1.9  	return 0;
    1.10  }
    1.11 @@ -115,6 +116,13 @@
    1.12  #define AGREEN(x)	(((x) & 0xf0) | (((x) & 0xf0) >> 4))
    1.13  #define ABLUE(x)	((((x) & 0xf) << 4) | ((x) & 0xf))
    1.14  
    1.15 +#define RSHIFT		(fbsurf->format->Rshift)
    1.16 +#define GSHIFT		(fbsurf->format->Gshift)
    1.17 +#define BSHIFT		(fbsurf->format->Bshift)
    1.18 +#define RMASK		(fbsurf->format->Rmask)
    1.19 +#define GMASK		(fbsurf->format->Gmask)
    1.20 +#define BMASK		(fbsurf->format->Bmask)
    1.21 +
    1.22  void gfx_show_image(struct ham_image *img)
    1.23  {
    1.24  	int i, j, k;
    1.25 @@ -127,8 +135,8 @@
    1.26  		int red = ARED(pcol);
    1.27  		int green = AGREEN(pcol);
    1.28  		int blue = ABLUE(pcol);
    1.29 -		palette[i] = (red << fbsurf->format->Rshift) | (green << fbsurf->format->Gshift) |
    1.30 -			(blue << fbsurf->format->Bshift);
    1.31 +		palette[i] = (red << RSHIFT) | (green << GSHIFT) | (blue << BSHIFT);
    1.32 +		printf("palette[%d]: %d %d %d\n", i, red, green, blue);
    1.33  	}
    1.34  
    1.35  	if(SDL_MUSTLOCK(fbsurf)) {
    1.36 @@ -139,18 +147,43 @@
    1.37  	src = img->pixels;
    1.38  	for(i=0; i<img->height; i++) {
    1.39  		for(j=0; j<img->width; j++) {
    1.40 +			uint32_t color;
    1.41  			unsigned char idx = 0;
    1.42 -			int bit = j & 7;
    1.43 +			unsigned char ham;
    1.44 +			int bit = 7 - (j & 7);
    1.45 +
    1.46  			for(k=0; k<img->nbitplanes; k++) {
    1.47  				idx = (idx << 1) | ((*(src + k * img->width / 8) >> bit) & 1);
    1.48  			}
    1.49 -			*dest++ = palette[idx];
    1.50 -			if(bit == 7) {
    1.51 +
    1.52 +			printf("%d ", idx);
    1.53 +			color = palette[idx];
    1.54 +			/*ham = (idx >> 4) & 3;
    1.55 +			color = (i & j) ? dest[-1] : 0;
    1.56 +
    1.57 +			switch(ham) {
    1.58 +			case 0:
    1.59 +				color = palette[idx];
    1.60 +				break;
    1.61 +			case 1:
    1.62 +				color = (color & ~BMASK) | (((uint32_t)idx & 0xf) << BSHIFT);
    1.63 +				break;
    1.64 +			case 2:
    1.65 +				color = (color & ~RMASK) | (((uint32_t)idx & 0xf) << RSHIFT);
    1.66 +				break;
    1.67 +			case 3:
    1.68 +				color = (color & ~GMASK) | (((uint32_t)idx & 0xf) << GSHIFT);
    1.69 +			}
    1.70 +			*/
    1.71 +
    1.72 +			*dest++ = color;
    1.73 +			if(!bit) {
    1.74  				++src;
    1.75  			}
    1.76  		}
    1.77  		src += img->width / 8 * (img->nbitplanes - 1);
    1.78  	}
    1.79 +	putchar('\n');
    1.80  
    1.81  	if(SDL_MUSTLOCK(fbsurf)) {
    1.82  		SDL_UnlockSurface(fbsurf);