Re: eye-candy hack - warp_saver changing direction :)
OK, OK, I *promise* I'll think twice before posting next time :) Here's a revised patch - a kern.warp_period = 0 signifies no direction change, for those who prefer the old behavior. G'luck, Peter -- This sentence no verb. Patch against -current: 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.9 diff -u -r1.9 warp_saver.c --- src/sys/modules/syscons/warp/warp_saver.c 2000/06/25 09:39:11 1.9 +++ src/sys/modules/syscons/warp/warp_saver.c 2000/12/11 14:00:29 @@ -35,6 +35,7 @@ #include sys/syslog.h #include sys/consio.h #include sys/fbio.h +#include sys/sysctl.h #include dev/fb/fbreg.h #include dev/fb/splashreg.h @@ -58,19 +59,35 @@ /* the rest is zero-filled by the compiler */ }; +static int warp_dir = 1, warp_period = 1; +SYSCTL_INT(_kern, OID_AUTO, warp_dir, CTLFLAG_RW, warp_dir, 0, "") +SYSCTL_INT(_kern, OID_AUTO, warp_period, CTLFLAG_RW, warp_period, 0, "") + static void -warp_update(void) +warp_update(int *pdir, 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) - star[k] -= SCRW*SCRH; + if (*pdir) { + star[k] += i; + if (star[k] SCRW*SCRH) + star[k] -= SCRW*SCRH; + } else { + star[k] -= i; + if (star[k] 0) + star[k] += SCRW*SCRH; + } vid[star[k]] = i; } + +if ((period 0) (++cur_state = period)) { + *pdir = !*pdir; + cur_state = 0; +} } static int @@ -94,7 +111,7 @@ } /* update display */ - warp_update(); + warp_update(warp_dir, warp_period); } else { blanked = 0; ... .. and against 4.2-STABLE.. 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 13:58:14 @@ -36,6 +36,7 @@ #include sys/consio.h #include sys/fbio.h #include sys/random.h +#include sys/sysctl.h #include dev/fb/fbreg.h #include dev/fb/splashreg.h @@ -59,19 +60,35 @@ /* the rest is zero-filled by the compiler */ }; +static int warp_dir = 1, warp_period = 1; +SYSCTL_INT(_kern, OID_AUTO, warp_dir, CTLFLAG_RW, warp_dir, 0, "") +SYSCTL_INT(_kern, OID_AUTO, warp_period, CTLFLAG_RW, warp_period, 0, "") + static void -warp_update(void) +warp_update(int *pdir, 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) - star[k] -= SCRW*SCRH; + if (*pdir) { + star[k] += i; + if (star[k] SCRW*SCRH) + star[k] -= SCRW*SCRH; + } else { + star[k] -= i; + if (star[k] 0) + star[k] += SCRW*SCRH; + } vid[star[k]] = i; } + +if ((period 0) (++cur_state = period)) { + *pdir = !*pdir; + cur_state = 0; +} } static int @@ -95,7 +112,7 @@ } /* update display */ - warp_update(); + warp_update(warp_dir, warp_period); } else { blanked = 0; To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
eye-candy hack - warp_saver changing direction :)
So.. if anybody else is using the warp screen saver, here's a little patch to make it reverse direction from time to time; as my boss put it, "I don't know about you, but an hour of your screen rolling over to the right makes me dizzy." :) This one defines two sysctl's - kern.warp_dir (zero to roll to the left, non-zero to roll the other way), and kern.warp_period (number of iterations before changing direction). The warp_period is measured in.. seconds, isn't it - how often the saver is called to do its dance.. Attached are patches against -current and 4.2-STABLE; hope this does not look too ugly :) G'luck, Peter -- "yields falsehood, when appended to its quotation." yields falsehood, when appended to its quotation. Patch against -current: 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.9 diff -u -r1.9 warp_saver.c --- src/sys/modules/syscons/warp/warp_saver.c 2000/06/25 09:39:11 1.9 +++ src/sys/modules/syscons/warp/warp_saver.c 2000/12/11 14:00:29 @@ -35,6 +35,7 @@ #include sys/syslog.h #include sys/consio.h #include sys/fbio.h +#include sys/sysctl.h #include dev/fb/fbreg.h #include dev/fb/splashreg.h @@ -58,19 +59,35 @@ /* the rest is zero-filled by the compiler */ }; +static int warp_dir = 1, warp_period = 1; +SYSCTL_INT(_kern, OID_AUTO, warp_dir, CTLFLAG_RW, warp_dir, 0, "") +SYSCTL_INT(_kern, OID_AUTO, warp_period, CTLFLAG_RW, warp_period, 0, "") + static void -warp_update(void) +warp_update(int *pdir, 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) - star[k] -= SCRW*SCRH; + if (*pdir) { + star[k] += i; + if (star[k] SCRW*SCRH) + star[k] -= SCRW*SCRH; + } else { + star[k] -= i; + if (star[k] 0) + star[k] += SCRW*SCRH; + } vid[star[k]] = i; } + +if (++cur_state = period) { + *pdir = !*pdir; + cur_state = 0; +} } static int @@ -94,7 +111,7 @@ } /* update display */ - warp_update(); + warp_update(warp_dir, warp_period); } else { blanked = 0; ... ...and against 4.2-STABLE.. 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 13:58:14 @@ -36,6 +36,7 @@ #include sys/consio.h #include sys/fbio.h #include sys/random.h +#include sys/sysctl.h #include dev/fb/fbreg.h #include dev/fb/splashreg.h @@ -59,19 +60,35 @@ /* the rest is zero-filled by the compiler */ }; +static int warp_dir = 1, warp_period = 1; +SYSCTL_INT(_kern, OID_AUTO, warp_dir, CTLFLAG_RW, warp_dir, 0, "") +SYSCTL_INT(_kern, OID_AUTO, warp_period, CTLFLAG_RW, warp_period, 0, "") + static void -warp_update(void) +warp_update(int *pdir, 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) - star[k] -= SCRW*SCRH; + if (*pdir) { + star[k] += i; + if (star[k] SCRW*SCRH) + star[k] -= SCRW*SCRH; + } else { + star[k] -= i; + if (star[k] 0) + star[k] += SCRW*SCRH; + } vid[star[k]] = i; } + +if (++cur_state = period) { + *pdir = !*pdir; + cur_state = 0; +} } static int @@ -95,7 +112,7 @@ } /* update display */ - warp_update(); + warp_update(warp_dir, warp_period); } else { blanked = 0; To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
Re: eye-candy hack - warp_saver changing direction :)
Peter Pentchev [EMAIL PROTECTED] writes: This one defines two sysctl's - kern.warp_dir (zero to roll to the left, non-zero to roll the other way), and kern.warp_period (number of iterations before changing direction). The warp_period is measured in.. seconds, isn't it - how often the saver is called to do its dance.. kern.* is not the right place for this. It should go in user.*, unless that is reserved for userland, in which case a subtree of kern.* is probably the Right Thing. DES -- Dag-Erling Smorgrav - [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
Re: eye-candy hack - warp_saver changing direction :)
On Mon, Dec 11, 2000 at 05:01:22PM +0100, Dag-Erling Smorgrav wrote: Peter Pentchev [EMAIL PROTECTED] writes: This one defines two sysctl's - kern.warp_dir (zero to roll to the left, non-zero to roll the other way), and kern.warp_period (number of iterations before changing direction). The warp_period is measured in.. seconds, isn't it - how often the saver is called to do its dance.. kern.* is not the right place for this. It should go in user.*, unless that is reserved for userland, in which case a subtree of kern.* is probably the Right Thing. Yes, I was wondering about user.*, but I decided it was reserved for userland. OK, I'll put it in a subtree. How does kern.ss.warp.* sound? Or kern.saver.warp.*? Or maybe even kern.syscons.saver.warp.*? (oif!) G'luck, Peter -- You have, of course, just begun reading the sentence that you have just finished reading. To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
Re: eye-candy hack - warp_saver changing direction :)
On Mon, Dec 11, 2000 at 06:03:46PM +0200, Peter Pentchev wrote: On Mon, Dec 11, 2000 at 05:01:22PM +0100, Dag-Erling Smorgrav wrote: Peter Pentchev [EMAIL PROTECTED] writes: This one defines two sysctl's - kern.warp_dir (zero to roll to the left, non-zero to roll the other way), and kern.warp_period (number of iterations before changing direction). The warp_period is measured in.. seconds, isn't it - how often the saver is called to do its dance.. kern.* is not the right place for this. It should go in user.*, unless that is reserved for userland, in which case a subtree of kern.* is probably the Right Thing. Yes, I was wondering about user.*, but I decided it was reserved for userland. OK, I'll put it in a subtree. How does kern.ss.warp.* sound? Or kern.saver.warp.*? Or maybe even kern.syscons.saver.warp.*? (oif!) Well, I can't quite make it work with a kern.* sysctl subtree.. It's obvious that this has something to do with SYSCTL_DECL(), but - how? :) I currently have these in my warp_saver.c (just kern.saver for simplicity): SYSCTL_DECL(_kern_saver); SYSCTL_INT(_kern_saver, OID_AUTO, dir, CTLFLAG_RW, warp_dir, 0, "") SYSCTL_INT(_kern_saver, OID_AUTO, step, CTLFLAG_RW, warp_step, 0, "") SYSCTL_INT(_kern_saver, OID_AUTO, period, CTLFLAG_RW, warp_period, 0, "") It builds and installs fine, and then: [root@ringworld:v0 /usr/mysrc/sys/modules/syscons/warp]# make load /sbin/kldload -v ./warp_saver.ko link_elf: symbol sysctl__kern_saver_children undefined kldload: can't load ./warp_saver.ko: Exec format error *** Error code 1 Stop in /usr/mysrcx/sys/modules/syscons/warp. [root@ringworld:v0 /usr/mysrc/sys/modules/syscons/warp]# Apparently I'm missing something.. whine Help? /whine G'luck, Peter -- If wishes were fishes, the antecedent of this conditional would be true. To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
Re: eye-candy hack - warp_saver changing direction :)
Peter Pentchev [EMAIL PROTECTED] writes: SYSCTL_DECL(_kern_saver); SYSCTL_DECL is for declaring a node that's defined elsewhere. You should use the following instead: SYSCTL_NODE(_kern, OID_AUTO, saver, CTLFLAG_RW, NULL, "Screensavers"); There's no substitute for reading src/sys/sys/sysctl.h. DES -- Dag-Erling Smorgrav - [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
Re: eye-candy hack - warp_saver changing direction :)
On Mon, Dec 11, 2000 at 06:03:00PM +0100, Dag-Erling Smorgrav wrote: Peter Pentchev [EMAIL PROTECTED] writes: SYSCTL_DECL(_kern_saver); SYSCTL_DECL is for declaring a node that's defined elsewhere. You should use the following instead: SYSCTL_NODE(_kern, OID_AUTO, saver, CTLFLAG_RW, NULL, "Screensavers"); There's no substitute for reading src/sys/sys/sysctl.h. Yes, mea culpa :( All right then, here's a revised patch that: - adds a kern.saver.* sysctl subtree in syscons.c (I *think* this belongs there, it's not each and every screensaver's job to define the global sysctl tree); - defines 8 directions instead of just 2; - adds 4 sysctl's: warp_dir - current movement direction; warp_step - increment to warp_dir on each direction change; warp_period - how long before a direction change; warp_random - boolean flag for random direction changes. If warp_period is 0, then each warp_period steps, the direction is changed by the following rules: - if warp_random is non-zero, the new direction is random; - if warp_random is zero, warp_dir = (warp_dir + warp_step) modulo 8. The 'standard' behavior is achieved by: warp_dir=0 warp_period=0 The currently default behavior (go round and round and round) is: warp_dir=0 warp_step=1 warp_period=100 warp_random=0 Left-and-right behavior: warp_dir=0 warp_step=4 warp_period=1000 warp_random=0 Random walk: warp_period=100 warp_random=1 G'luck, Peter -- If I were you, who would be reading this sentence? Patch against -current: Index: src/sys/dev/syscons/syscons.c === RCS file: /home/ncvs/src/sys/dev/syscons/syscons.c,v retrieving revision 1.349 diff -u -r1.349 syscons.c --- src/sys/dev/syscons/syscons.c 2000/12/08 21:49:55 1.349 +++ src/sys/dev/syscons/syscons.c 2000/12/11 18:19:04 @@ -120,6 +120,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.9 diff -u -r1.9 warp_saver.c --- src/sys/modules/syscons/warp/warp_saver.c 2000/06/25 09:39:11 1.9 +++ src/sys/modules/syscons/warp/warp_saver.c 2000/12/11 18:20:04 @@ -35,6 +35,7 @@ #include sys/syslog.h #include sys/consio.h #include sys/fbio.h +#include sys/sysctl.h #include dev/fb/fbreg.h #include dev/fb/splashreg.h @@ -58,19 +59,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 @@ -94,7 +136,7 @@ } /* update display */ - warp_update(); + warp_update(warp_dir, warp_step, warp_period); } else { blanked = 0; .. ..and against 4.2-STABLE.. Index: src/sys/dev/syscons/syscons.c === RCS file:
Re: eye-candy hack - warp_saver changing direction :)
unsubscribe [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message