Guest User

Untitled

a guest
Jul 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. // Compressed ASCII art characters!
  2. // If I wasn't lazy, i could rewrite this to decode a stream
  3. // instead of a chunk of data, but I am.
  4. // Or maybe add BWT.
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <sys/types.h>
  10.  
  11. #define DATA_LEN 47
  12.  
  13. int main() {
  14. u_int32_t line_len = 0;
  15.  
  16. char data[DATA_LEN] = {
  17. 0x1D, 0x00, 0x00, 0x00, 0x56, 0x36, 0x51, 0x56,
  18. 0x36, 0x56, 0x37, 0x31, 0x01, 0x51, 0x37, 0x51,
  19. 0x52, 0x12, 0x63, 0x62, 0x26, 0x22, 0x10, 0x56,
  20. 0x36, 0x51, 0x5B, 0x5F, 0x10, 0x04, 0x73, 0x15,
  21. 0x15, 0x73, 0x73, 0x73, 0x73, 0x10, 0x51, 0x51,
  22. 0x51, 0x56, 0x37, 0x37, 0x37, 0x31, 0x00
  23. };
  24.  
  25. // Grab linelen
  26. memcpy( &line_len, data, sizeof(u_int32_t) );
  27.  
  28. // Unfumble the data stream
  29. char *sussmann2 = malloc( 5 * line_len );
  30. for( int i = 0; i < DATA_LEN; i++ ) {
  31. sussmann2[i*2] = (data[i+4]&0xF0)>>4;
  32. sussmann2[i*2+1] = data[i+4]&0x0F;
  33. }
  34.  
  35. // Preprocess, fancy outer RLE.
  36. char *sussmann = malloc( 5 * line_len );
  37. int sc = 0;
  38. int c = 0;
  39. while( sc < 5*29 ) {
  40. if( sussmann2[c] == 0x0 ) {
  41. sussmann[sc] = 0x0;
  42. sc++;
  43. c++;
  44. }
  45. do {
  46. if( sussmann2[c] < 0x6 ) {
  47. sussmann[sc] = sussmann2[c];
  48. sc++;
  49. }
  50. else {
  51. for( int i = 0; i < sussmann2[c] - 0x4; i++ ) {
  52. sussmann[sc] = 0x1;
  53. sc++;
  54. }
  55. }
  56. c++;
  57. } while( sussmann2[c] != 0x0 && sc % 29 != 0 );
  58. while( sc % 29 != 0 ) {
  59. sussmann[sc] = 0x0;
  60. sc++;
  61. }
  62. c++;
  63. }
  64.  
  65. // Inner RLE with switching char.
  66. for( int r = 0; r < 5; r++ ) {
  67. for( int i = 0; i < 29; i++ ) {
  68. for( int j = 0; j < sussmann[r*29+i]; j++ ) {
  69. putchar(i%2?' ':'#');
  70. }
  71. }
  72. puts("");
  73. }
  74.  
  75. // FREE SUSSMANN
  76. free( sussmann );
  77. free( sussmann2 );
  78. }
Add Comment
Please, Sign In to add comment