Index: src/sys/dev/syscons/syscons.c =================================================================== RCS file: /home/ncvs/src/sys/dev/syscons/syscons.c,v retrieving revision 1.336.2.3 diff -u -r1.336.2.3 syscons.c --- src/sys/dev/syscons/syscons.c 2000/10/29 16:59:27 1.336.2.3 +++ src/sys/dev/syscons/syscons.c 2000/12/11 17:41:30 @@ -118,6 +118,8 @@ SYSCTL_INT(_machdep, OID_AUTO, enable_panic_key, CTLFLAG_RW, &enable_panic_key, 0, ""); +SYSCTL_NODE(_kern, OID_AUTO, saver, CTLFLAG_RW, NULL, "Console screensavers") + #define SC_CONSOLECTL 255 #define VIRTUAL_TTY(sc, x) (SC_DEV((sc), (x))->si_tty) Index: src/sys/modules/syscons/warp/warp_saver.c =================================================================== RCS file: /home/ncvs/src/sys/modules/syscons/warp/warp_saver.c,v retrieving revision 1.7.2.1 diff -u -r1.7.2.1 warp_saver.c --- src/sys/modules/syscons/warp/warp_saver.c 2000/05/10 16:26:47 1.7.2.1 +++ src/sys/modules/syscons/warp/warp_saver.c 2000/12/11 17:42:06 @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -59,19 +60,60 @@ /* the rest is zero-filled by the compiler */ }; +static int warp_dirs[8] = { + 1, /* E */ + SCRW+1, /* SE */ + SCRW, /* S */ + SCRW-1, /* SW */ + -1, /* W */ + -SCRW-1, /* NW */ + -SCRW, /* N */ + -SCRW+1 /* NE */ +}; +#define WARP_DIRCNT (sizeof(warp_dirs)/sizeof(warp_dirs[0])) + +static int warp_dir = 0, warp_step = 1, warp_period = 100; +static int warp_random = 0; + +/* Make use of syscons's screen saver subtree.. */ +SYSCTL_DECL(_kern_saver); +/* Add our sysctls there */ +SYSCTL_INT(_kern_saver, OID_AUTO, warp_dir, CTLFLAG_RW, &warp_dir, 0, "") +SYSCTL_INT(_kern_saver, OID_AUTO, warp_step, CTLFLAG_RW, &warp_step, 0, "") +SYSCTL_INT(_kern_saver, OID_AUTO, warp_period, CTLFLAG_RW, &warp_period, 0, "") +SYSCTL_INT(_kern_saver, OID_AUTO, warp_random, CTLFLAG_RW, &warp_random, 0, "") + static void -warp_update(void) +warp_update(int *pdir, int step, int period) { int i, j, k, n; + static int cur_state = 0; for (i = 1, k = 0, n = SPP*8; i < 5; i++, n /= 2) for (j = 0; j < n; j++, k++) { vid[star[k]] = 0; - star[k] += i; - if (star[k] > SCRW*SCRH) + + /* calculate the new position */ + star[k] += warp_dirs[*pdir]*i; + /* do not fall off the screen */ + if (star[k] >= SCRW*SCRH) star[k] -= SCRW*SCRH; + else if (star[k] < 0) + star[k] += SCRW*SCRH; + vid[star[k]] = i; } + + if ((period > 0) && (++cur_state >= period)) { + cur_state = 0; + + /* hope gcc is smart enough to optimize the %-by-power-of-two.. */ + /* (not that the random() call is less of a bottleneck :) */ + if (warp_random) + *pdir = random() % WARP_DIRCNT; + else + *pdir = (*pdir + step) % WARP_DIRCNT; + } } static int @@ -95,7 +137,7 @@ } /* update display */ - warp_update(); + warp_update(&warp_dir, warp_step, warp_period); } else { blanked = 0;