1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
/* Synaescope - a pretty noatun visualization (based on P. Harrison's Synaesthesia)
Copyright (C) 1997 Paul Francis Harrison <pfh@yoyo.cc.monash.edu.au>
2001 Charles Samuels <charles@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <pwd.h>
#include <string.h>
#include <math.h>
#include "syna.h"
void Core::allocOutput(int w,int h)
{
#if 0
delete[] output;
delete[] lastOutput;
delete[] lastLastOutput;
output = new unsigned char[w*h*2];
lastOutput = new unsigned char[w*h*2];
lastLastOutput = new unsigned char[w*h*2];
memset(output,32,w*h*2);
memset(lastOutput,32,w*h*2);
outWidth = w;
outHeight = h;
#endif
outputBmp.size(w,h);
lastOutputBmp.size(w,h);
lastLastOutputBmp.size(w,h);
polygonEngine.size(w,h);
outWidth = w;
outHeight = h;
}
void Core::toDefaults()
{
fadeMode = Stars;
pointsAreDiamonds = true;
brightnessTwiddler = 0.33; //0.125;
starSize = 0.125;
fgRedSlider=0.0;
fgGreenSlider=0.5;
bgRedSlider=1.0;
bgGreenSlider=0.2;
}
Core::Core() : StereoScope(40)
{
setSamples(NumSamples);
core = this;
int i;
data = new sampleType[NumSamples*2+16];
for(i=0;i<NumSamples;i++)
{
negSinTable[i] = -sin(3.141592*2.0/NumSamples*i);
cosTable[i] = cos(3.141592*2.0/NumSamples*i);
bitReverse[i] = bitReverser(i);
}
}
bool Core::init ( void )
{
windX = 1;
windY = 1;
screen = new SdlScreen;
if (!screen->init(windX,windY,windWidth,windHeight,false))
{
delete screen;
screen = 0;
return false;
}
allocOutput(outWidth,outHeight);
setStarSize(starSize);
interface = new Interface;
return true;
}
Core::~Core()
{
delete interface;
screen->end();
delete screen;
}
bool Core::go()
{
time_t startTime = time(0);
time_t currentTime = time(0);
time_t lastTime = 0;
char fpsString[32];
int frames = 0;
double fps=0;
// printf("%u\n", static_cast<SdlScreen *>(screen)->winID());
// fflush(stdout);
while (1)
{
fade();
if (!calculate())
break;
if (!interface->go()) break;
screen->show();
frames++;
currentTime = time(0) - startTime;
if ((currentTime - lastTime) > 1) // update fps display every 2 seconds
{
fps = double(frames) / currentTime;
lastTime = currentTime;
snprintf(fpsString, 32, "Noatun - Synaescope: %.2f fps", fps);
screen->updateWindowCaption(&fpsString[0]);
}
if (fps>25.0)
usleep(5);
}
return true;
}
bool start()
{
return true;
}
void error(const char *str, bool)
{
fprintf(stderr, "synaescope: Error %s\n",str);
// if (syscall)
// fprintf(stderr,"(reason for error: %s)\n",strerror(errno));
exit(1);
}
void warning(const char *str, bool)
{
fprintf(stderr, "synaescope: Possible error %s\n",str);
// if (syscall)
// fprintf(stderr,"(reason for error: %s)\n",strerror(errno));
}
#include <kinstance.h>
#include <kglobal.h>
#include <kconfig.h>
int main(void)
{
TDEInstance in("noatunsynaescope");
core = new Core;
KConfig mConfig("noatunrc");
mConfig.setGroup("Synaescope");
core->windWidth = mConfig.readNumEntry("xResolution", 320);
core->windHeight = mConfig.readNumEntry("yResolution", 240);
if ( core->init() )
core->go();
delete core;
exit(0);
}
|