initial
[fpgammix.git] / workloads / hilbert.c
blob7485d94a2160f658642b5aeb3c2c8f01ebb086cd
1 // As long as we stay in the first segment, we won't have to deal with the crazy segments.
2 unsigned char *fb = (unsigned char *) (128 * 1024);
3 unsigned long cursor_x = 0;
4 unsigned long cursor_y = 0;
5 long int point_x, point_y;
7 void clear(void)
9 unsigned i;
10 for (i = 0; i < 10 * 480; ++i)
11 ((long *)fb)[i] = 0;
12 cursor_y = cursor_x = point_x = point_y = 0;
15 static inline void point(long int x, long int y)
17 unsigned char *p = fb + (x >> 3) + y * (640/8);
18 *p |= 1 << (~x & 7);
21 static inline void moveto(long int x, long int y)
23 point_x = x;
24 point_y = y;
27 void drawto(long int x, long int y)
29 long int i, from, to;
30 if (x == point_x) {
31 if (point_y > y)
32 from = y, to = point_y;
33 else
34 from = point_y, to = y;
36 for (i = from; i <= to; ++i)
37 point(x, i);
38 point_y = y;
39 } else if (y == point_y) {
40 if (point_x > x)
41 from = x, to = point_x;
42 else
43 from = point_x, to = x;
45 for (i = from; i <= to; ++i)
46 point(i, y);
47 point_x = x;
51 void a(long int), b(long int), c(long int), d(long int);
53 long int h0 = 8;
54 long int h, x, y, x0, y0;
56 void a(long int i)
58 if (i > 0) {
59 d(i-1); x -= h; drawto(x,y);
60 a(i-1); y -= h; drawto(x,y);
61 a(i-1); x += h; drawto(x,y);
62 b(i-1);
66 void b(long int i)
68 if (i > 0) {
69 c(i-1); y += h; drawto(x,y);
70 b(i-1); x += h; drawto(x,y);
71 b(i-1); y -= h; drawto(x,y);
72 a(i-1);
76 void c(long int i)
78 if (i > 0) {
79 b(i-1); x += h; drawto(x,y);
80 c(i-1); y += h; drawto(x,y);
81 c(i-1); x -= h; drawto(x,y);
82 d(i-1);
86 void d(long int i)
88 if (i > 0) {
89 a(i-1); y -= h; drawto(x,y);
90 d(i-1); x -= h; drawto(x,y);
91 d(i-1); y += h; drawto(x,y);
92 c(i-1);
96 #define IOSPACE ((volatile int *) 0x1000000000000ULL)
97 #define set_fbaddr0(x) IOSPACE[21] = (x)
99 int dummy;
101 main()
103 int d, i;
105 set_fbaddr0(fb);
107 for (;;)
108 for (d = 0; d <= 6; ++d) {
109 clear();
111 h0 = 8;
112 h = h0; x0 = h/2; y0 = x0; h = h/ 2;
113 x0 += h/2; y0 += h/2;
115 x = x0 + 400; y = y0 + 350; moveto(x,y);
116 a(d);
118 for (i = 0; i < 1000000; ++i)
119 ++dummy;