Guest User

Untitled

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