ref: 9d8d932b97da40af6d4c21208f0e51ccccf093c4
parent: e0043ee088f227d5ce3cbf567ca8ddde53001c9f
author: glenda <glenda@narshaddaa>
date: Mon May 1 03:48:14 EDT 2023
careful not to cause a fault
--- a/main.c
+++ b/main.c
@@ -8,6 +8,7 @@
#define H 32
#define W 126
#define NDRAWFUNCS 7
+#define NITERFUNCS 1
typedef int drawfunc(int x, int x);
typedef Memimage* iterfunc(drawfunc, Memimage*);
@@ -113,10 +114,10 @@
{
Memimage *img;
# 126 x 32 oled ⇒ 4032 pixels
- int i;
+ int iteri, drawi;
h = 32;
w = 126;
- ms = 100;
+ ms = 100; // « change to ≤10 to get a kernel fault
//Point topleft;
//double angle;
//angle = 0.0;
@@ -137,6 +138,10 @@
ob5,
drand,
};
+
+ iterfunc *itertab[NITERFUNCS] = {
+ topdown,
+ };
ARGBEGIN{
default:
@@ -146,22 +151,20 @@
if (memimageinit())
sysfatal("memimageinit failed: %r");
-
- for(i = 0;; i++){
- if(i >= NDRAWFUNCS)
- i = 0;
- //print("i=%d\n", i);
-
- // clear rectangle brush position
-
- // clear the screen
+ // FOR EVER
+ for(;;){
+ iteri = ntruerand(NITERFUNCS);
+ drawi = ntruerand(NDRAWFUNCS);
+ // blank the screen
img = allocmemimage(Rect(0, 0, w, h), GREY1);
if (!img)
sysfatal("cannot allocate memimage: %r");
+
+ // white on black; bg is black
memfillcolor(img, DBlack);
/* call the independent drawing routine of choice */
- topdown(drawtab[i], img);
+ itertab[iteri](drawtab[drawi], img);
//angle = truerand();