commit 989dab726622903bdf98bf38b7304e287802dd0e
parent 0abd4fab15a9fd01d804d4e250147434520af696
Author: Brian Swetland <swetland@frotz.net>
Date: Sat, 2 Nov 2019 20:50:00 -0700
hello: slightly more exciting test program
Diffstat:
M | hello.c | | | 32 | +++++++++++++++++++++++--------- |
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/hello.c b/hello.c
@@ -1,13 +1,27 @@
-// Copyright 2019, Brian Swetland <swetland@frotz.net>
-// Licensed under the Apache License, Version 2.0.
+#include "system.h"
-volatile unsigned *uart = (void*) 0x80001000;
+int main(int argc, char** argv) {
+ int top = 1000, bottom = -1000, ystep = 50;
+ int left = -2500, right = 1000, xstep = 30;
+ int maxiter = 1000;
-int main() {
- unsigned n;
- for (n = 0; n < 10; n++) {
- *uart = n;
+ for (int y0 = top; y0 > bottom; y0 -= ystep) {
+ for (int x0 = left; x0 < right; x0 += xstep) {
+ int i = 0, x = 0, y = 0, ch = ' ';
+ while (i < maxiter) {
+ int x2 = x * x / 1000;
+ int y2 = y * y / 1000;
+ if ((x2 + y2) > 4000) {
+ ch = (i > 9) ? '@' : (i + '0');
+ break;
+ }
+ y = 2 * x * y / 1000 + y0;
+ x = x2 - y2 + x0;
+ i++;
+ }
+ dputc(ch);
+ }
+ dputc('\n');
}
- return 42;
+ return 0;
}
-