From owner-freebsd-hackers Mon Dec 11 6:19:45 2000 From owner-freebsd-hackers@FreeBSD.ORG Mon Dec 11 06:19:39 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from ringworld.nanolink.com (pool249-tch-1.Sofia.0rbitel.net [212.95.170.249]) by hub.freebsd.org (Postfix) with SMTP id CC87637B400 for ; Mon, 11 Dec 2000 06:19:36 -0800 (PST) Received: (qmail 1969 invoked by uid 1000); 11 Dec 2000 14:18:47 -0000 Date: Mon, 11 Dec 2000 16:18:47 +0200 From: Peter Pentchev To: hackers@FreeBSD.org Subject: eye-candy hack - warp_saver changing direction :) Message-ID: <20001211161847.A606@ringworld.oblivion.bg> Mail-Followup-To: hackers@FreeBSD.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 #include #include +#include #include #include @@ -58,19 +59,35 @@ /* the rest is zero-filled by the compiler */ }; +static int warp_dir = 1, warp_period = 10000; +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 #include #include +#include #include #include @@ -59,19 +60,35 @@ /* the rest is zero-filled by the compiler */ }; +static int warp_dir = 1, warp_period = 10000; +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 majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message