-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdonut.gaz
94 lines (80 loc) · 2.36 KB
/
donut.gaz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Translated from https://www.dropbox.com/s/79ga2m7p2bnj1ga/donut_deobfuscated.c?dl=0
*/
typedef integer int;
typedef real float;
typedef character char;
const ESC = as<char>(27);
const CHARS = ".,-~:;=!*#$@";
function sin(float x) returns float {
return x - (x^3 / 6) + (x^5 / 120) - (x^7 / 5040) + (x^9 / 362880);
}
function cos(float x) returns float {
return 1 - (x^2 / 2) + (x^4 / 24) - (x^6 / 720) + (x^8 / 40320);
}
procedure main() returns integer {
float A = 0;
float B = 0;
float i;
float j;
int k;
float[1761] z;
char[1761] b;
ESC || "[2J" -> std_output;
loop {
b = as<char[1761]>(32);
z = as<float[1761]>(0);
j = 0;
i = 0;
loop while (j < 6.28) {
loop while (i < 6.28 ) {
float c = sin(i);
float d = cos(j);
float e = sin(A);
float f = sin(j);
float g = cos(A);
float h = d + 2;
float D = 1 / (c * h * e + f * g + 5);
float l = cos(i);
float m = cos(B);
float n = sin(B);
float t = c * h * g - f * e;
int x = as<int>(40 + 30 * D * (l * h * m - t * n));
int y = as<int>(12 + 15 * D * (l * h * n + t * m));
int o = x + 80 * y;
int N = as<int>(8 * ((f * e - c * d * g) * m - c * d * e - f * g - l * d * n));
if (o < 0) {
o = -o;
}
if (22 > y and y > 1 and x > 1 and 80 > x and D > z[o % 1760 + 1]) {
int N_idx = N;
if (N <= 0) {
N_idx = 0;
}
z[o % 1761 + 1] = D;
b[o % 1761 + 1] = CHARS[N_idx + 1];
}
i = i + 0.02;
}
j = j + 0.07;
}
ESC || "[H" -> std_output;
loop k in 1..1760 {
if ((k % 80) != 0) {
b[k] -> std_output;
} else {
'\n' -> std_output;
}
A = A + .00004;
B = B + .00002;
}
{
//int sleep = 7483647;
int sleep = 87483647;
loop while (sleep > 0) {
sleep = sleep - 1;
}
}
}
return 0;
}