Skip to content

Instantly share code, notes, and snippets.

@ao-kenji
Created October 5, 2024 14:33
Show Gist options
  • Save ao-kenji/b7f7c23fb696eeac4f7a49bfdcc83da8 to your computer and use it in GitHub Desktop.
Save ao-kenji/b7f7c23fb696eeac4f7a49bfdcc83da8 to your computer and use it in GitHub Desktop.
Mandelbrot ASCII art for FUZIX
/*
* ASCIIART: Mandelbrot set
* originally from https://kyo-ta04.github.io/memo/
* modified to run on FUZIX
*/
#include <stdio.h>
#include <time.h>
#define putch(a) putchar(a)
char junk[256];
time_t st, et;
main()
{
int f, i, x, y;
int c, d, a, b, q, s, t, p;
#if 0
printf("hit Enter key:");
fflush(stdout);
gets(junk);
#endif
time(&st);
f = 50;
for (y = -12; y <= 12; y++) {
for (x = -39; x <= 39; x++) {
c = x * 229 / 100;
d = y * 416 / 100;
a = c;
b = d;
for (i = 0; i <=15; i++) {
q = b / f;
s = b - q * f;
t = (a * a - b * b) / f + c;
b = 2 * (a * q + a * s / f) + d;
a = t;
p = a / f;
q = b / f;
if ((p * p + q * q) > 4) {
break;
}
}
putch("0123456789ABCDEF "[i]);
}
putch('\n');
}
time(&et);
printf("Start: %s", ctime(&st)); /* ctime(&st) includes '\n' */
printf("End : %s", ctime(&et)); /* ctime(&et) includes '\n' */
#if 0
printf("OK\n");
printf("\n");
gets(junk);
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment