cabi.c
void draw_compressed_sprite_ascii(const uint8_t *src)
{
	int col;
	int pos;
	int bl, len;
	int i;
	int w, h;
	int x, y;
	int total = 0;
	
	memset(&cs, 0, sizeof(cs));
	cs.src = src;
	cs.bit = 0x100;
	cs.src_pos = 0;
	
	// header
	
	w = getval(8) + 1;
	h = getval(8) + 1;
	col = getval(1); // starting colour
	
	x = y = 0;
	
	while (y < h)
	{
		bl = 1;
		while (!getval(1))
			bl += 2;
		
		len = getval(bl)+1; // span length
		
		for (i = 0; i < len; i++)
		{
			//if ((x%8) == 0) // every 8th bit (format test)
			printf("%s", col ? "#":".");
			
			if (col) total++;
			x++;
			if (x >= w)
			{
				printf("\n");
				y ++;
				x = 0;
			}
			
			//if ((x+y*w)%(w*8) == 0) printf("\n"); // print every 8th line (format test)
				
		}
		
		col = 1-col; // toggle
	}
	printf("\ntotal: %d\n", total);
}
// decompress_rle
// if not NULL, w and h give back the size of the sprite.
decompress_rle
if not NULL, w and h give back the size of the sprite.
decompress_rle if not NULL w and h give back the size of the sprite .
void draw_compressed_sprite_ascii(const uint8_t *src)
{
	int col;
	int pos;
	int bl, len;
	int i;
	int w, h;
	int x, y;
	int total = 0;
	memset(&cs, 0, sizeof(cs));
	cs.src = src;
	cs.bit = 0x100;
	cs.src_pos = 0;
	w = getval(8) + 1;
	h = getval(8) + 1;
	col = getval(1); 
	x = y = 0;
	while (y < h)
	{
		bl = 1;
		while (!getval(1))
			bl += 2;
		len = getval(bl)+1; 
		for (i = 0; i < len; i++)
		{
			printf("%s", col ? "#":".");
			if (col) total++;
			x++;
			if (x >= w)
			{
				printf("\n");
				y ++;
				x = 0;
			}
		}
		col = 1-col; 
	}
	printf("\ntotal: %d\n", total);
}
void draw_compressed_sprite_ascii ( const uint8_t * src ) { int col ; int pos ; int bl , len ; int i ; int w , h ; int x , y ; int total = 0 ; memset ( & cs , 0 , sizeof ( cs ) ) ; cs . src = src ; cs . bit = 0x100 ; cs . src_pos = 0 ; w = getval ( 8 ) + 1 ; h = getval ( 8 ) + 1 ; col = getval ( 1 ) ; x = y = 0 ; while ( y < h ) { bl = 1 ; while ( ! getval ( 1 ) ) bl += 2 ; len = getval ( bl ) + 1 ; for ( i = 0 ; i < len ; i ++ ) { printf ( " " , col ? " " : " " ) ; if ( col ) total ++ ; x ++ ; if ( x >= w ) { printf ( " \n " ) ; y ++ ; x = 0 ; } } col = 1 - col ; } printf ( " \n \n " , total ) ; }
decompress_rle
if not NULL, w and h give back the size of the sprite.
decompress_rle if not NULL w and h give back the size of the sprite .
// header // starting colour // span length //if ((x%8) == 0) // every 8th bit (format test) //if ((x+y*w)%(w*8) == 0) printf("\n"); // print every 8th line (format test) // toggle