#include #include #include #include static char buffer[129 * 80]; static int head = 0; static int tail = 0; static int line_cursor = 79; static double last_x = 40; static int last_y = 100; static double Rand(double range) { return (rand() * range) / (double)RAND_MAX; } static int GetNextTemplateChar() { int i, j, ix, iy; double cx, distance, size0, size1, phase, ta, r, tr, x, y; /* Initialize template buffer ring on first call */ if( head == tail ) { for(i = 0; i < 129; i++) { for(j = 0; j < 79; j++) buffer[i * 80 + j] = 'X'; buffer[i * 80 + j] = '\n'; } tail = 37; for(i = 0; i < 31; i++) buffer[1 * 80 + i] = ' '; for(; i < 48; i++) buffer[1 * 80 + i] = 'X'; buffer[1 * 80 + i] = '\n'; } /* Generate new row */ if( line_cursor > 0 && buffer[head * 80 + line_cursor - 1] == '\n' ) { for(i = 0; i < 79; i++) buffer[tail * 80 + i] = 'X'; buffer[tail * 80 + i] = '\n'; tail = (tail + 1) % 128; cx = Rand(70) + 5; distance = sqrt((cx - last_x) * (cx - last_x) + last_y * last_y); if( last_y > 30 && distance > 40 ) { size0 = 1 + Rand(2); size1 = 12 - size0 + Rand(8); phase = Rand(2 * M_PI); for(ta = 0; ta < 10 * M_PI; ta += 0.05) { r = size0 + size1 + size1 * 0.5 * sin(ta + phase); for(tr = 0; tr < r; tr += 0.1) { x = cx + tr * cos(ta / 5); y = tail + 108 + 0.5 * tr * sin(ta / 5); ix = x + 0.5; iy = y + 0.5; iy %= 128; if( ix >= 0 && ix < 79 ) buffer[iy * 80 + ix] = ' '; } } last_x = cx; last_y = 0; } else { last_y += 2; } head = (head + 1) % 128; line_cursor = 0; } return buffer[head * 80 + line_cursor++]; } static void OutputChar(int c) { int t; while( (t = GetNextTemplateChar()) != 'X' ) putchar(t); putchar(c); } static void OutputString(const char *s) { for(; *s; s++) OutputChar(*s); } int main() { int i, p = 0, q, steps, parity = 0; char op, oq; srand(time(NULL)); /* Decoder header */ OutputString("#include" "typedef int O;" "void o(O _){putchar(_);}" "O main()" "{" "O*_[512],**p=_,**d,b,q;" "for(b=0;b++<512;p=_+q)" "_[q=(p-_+1)*9%512]=(O*)p;"); /* Encode bytes */ while( (i = getchar()) != EOF ) { q = p; for(steps = 0; abs(p - q) != i; steps++) q = (q + 1) * 9 % 512; steps = 512 - steps; op = parity ? 'd' : 'p'; oq = parity ? 'p' : 'd'; OutputString("o("); if( p > q ) { OutputChar(op); OutputString("-("); OutputChar(oq); OutputChar('='); for(i = 0; i < steps; i++) OutputChar('*'); OutputString("(O**"); for(i = 0; i < steps; i++) OutputChar('*'); OutputChar(')'); OutputChar(op); OutputChar(')'); } else { OutputChar('('); OutputChar(oq); OutputChar('='); for(i = 0; i < steps; i++) OutputChar('*'); OutputString("(O**"); for(i = 0; i < steps; i++) OutputChar('*'); OutputChar(')'); OutputChar(op); OutputString(")-"); OutputChar(op); } OutputString(");"); parity ^= 1; p = q; } /* Decoder footer */ for(;;) { for(i = 0; i < 6; i++) { if( buffer[head * 80 + line_cursor + i] != 'X' ) break; } if( i == 6 ) break; OutputString("{;}"); } OutputString("return+0;}\n"); return 0; }