Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Compressed ASCII art characters!
- // If I wasn't lazy, i could rewrite this to decode a stream
- // instead of a chunk of data, but I am.
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/types.h>
- #define DATA_LEN 47
- int main() {
- u_int32_t line_len = 0;
- char data[DATA_LEN] = {
- 0x1D, 0x00, 0x00, 0x00,
- 0x56, 0x36, 0x51, 0x56, 0x36, 0x56, 0x37, 0x31,
- 0x01, 0x51, 0x37, 0x51, 0x52, 0x12, 0x63, 0x62,
- 0x26, 0x22, 0x10, 0x56, 0x36, 0x51, 0x5B, 0x5F,
- 0x10, 0x04, 0x73, 0x15, 0x15, 0x73, 0x73, 0x73,
- 0x73, 0x10, 0x51, 0x51, 0x51, 0x56, 0x37, 0x37,
- 0x37, 0x31, 0x00
- };
- // Grab linelen
- memcpy( &line_len, data, sizeof(u_int32_t) );
- // Unfumble the data stream
- char *sussmann2 = malloc( 5 * line_len );
- for( int i = 0; i < DATA_LEN; i++ ) {
- sussmann2[i*2] = (data[i+4]&0xF0)>>4;
- sussmann2[i*2+1] = data[i+4]&0x0F;
- }
- // Preprocess, fancy outer RLE.
- char *sussmann = malloc( 5 * line_len );
- int sc = 0;
- int c = 0;
- while( sc < 5*29 ) {
- if( sussmann2[c] == 0x0 ) {
- sussmann[sc] = 0x0;
- sc++;
- c++;
- }
- do {
- if( sussmann2[c] < 0x6 ) {
- sussmann[sc] = sussmann2[c];
- sc++;
- }
- else {
- for( int i = 0; i < sussmann2[c] - 0x4; i++ ) {
- sussmann[sc] = 0x1;
- sc++;
- }
- }
- c++;
- } while( sussmann2[c] != 0x0 && sc % 29 != 0 );
- while( sc % 29 != 0 ) {
- sussmann[sc] = 0x0;
- sc++;
- }
- c++;
- }
- // Inner RLE with switching char.
- for( int r = 0; r < 5; r++ ) {
- for( int i = 0; i < 29; i++ ) {
- for( int j = 0; j < sussmann[r*29+i]; j++ ) {
- putchar(i%2?' ':'#');
- }
- }
- puts("");
- }
- // FREE SUSSMANN
- free( sussmann );
- free( sussmann2 );
- }
Add Comment
Please, Sign In to add comment