2 Copyright (C) 1998 BJ Eirich (aka vecna)
\r
3 This program is free software; you can redistribute it and/or
\r
4 modify it under the terms of the GNU General Public License
\r
5 as published by the Free Software Foundation; either version 2
\r
6 of the License, or (at your option) any later version.
\r
7 This program is distributed in the hope that it will be useful,
\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
\r
10 See the GNU General Public Lic
\r
11 See the GNU General Public License for more details.
\r
12 You should have received a copy of the GNU General Public License
\r
13 along with this program; if not, write to the Free Software
\r
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
23 #include "vdriver.h"
\r
27 // ================================= Data ====================================
\r
29 static int *dmapx = NULL;
\r
30 static int *dmapy = NULL;
\r
31 static unsigned char *dscr = NULL;
\r
32 static int recalc_distort = 1;
\r
33 static long build = 0;
\r
35 // ================================= Code ====================================
\r
38 static void init_distort(void)
\r
45 if (dmapx) vfree(dmapx); dmapx=NULL;
\r
46 if (dmapy) vfree(dmapy); dmapy=NULL;
\r
47 if (dscr) vfree(dscr); dscr=NULL;
\r
49 // allocate distort lookups
\r
50 dmapx = (int *) valloc(tsx*tsy*4,"ssaver X",0);
\r
51 dmapy = (int *) valloc(tsx*tsy*4,"ssaver Y",0);
\r
53 // allocate distort image buffer
\r
54 dscr = (unsigned char *) valloc(tsx*tsy,"ssaver scrn",0);
\r
56 // copy viewport into distort buffer
\r
57 memcpy(dscr, screen, tsx*tsy);
\r
62 // generate distort lookups
\r
63 for (y=0; y<tsy; ++y) {
\r
64 for (x=0; x<tsx; ++x) {
\r
65 *dx++ = sin(y*5*(360.0/tsy)*(3.14/180))*10;
\r
66 *dy++ = sin(x*5*(360.0/tsx)*(3.14/180))*10;
\r
72 static void do_distort(void)
\r
74 unsigned char *ds=NULL;
\r
81 static int thresh=0;
\r
83 if (recalc_distort) {
\r
88 ds=screen; //+(tsx*16)+16;
\r
92 if (yy >= tsy) yy -= tsy;
\r
93 xt += (dmapx[(yy*tsx)+x] * build) >> 16;
\r
95 xx = (x+((thresh*tsx)/tsy));
\r
96 if (xx >= tsx) xx -= tsx;
\r
97 yt += (dmapy[(yy*tsx)+xx] * build) >> 16;
\r
99 if (xt < 0) xt += tsx;
\r
100 if (yt < 0) yt += tsy;
\r
101 if (xt >= tsx) xt -= tsx;
\r
102 if (yt >= tsy) yt -= tsy;
\r
104 *ds++ = dscr[(yt*tsx)+xt];
\r
122 if (build < 85196) //1.5
\r
126 void ScreenSaver(void)
\r
128 while (idlect > 750)
\r