1
/* Synaescope - a pretty noatun visualization (based on P. Harrison's Synaesthesia)
2
Copyright (C) 1997 Paul Francis Harrison <pfh@yoyo.cc.monash.edu.au>
3
2001 Charles Samuels <charles@kde.org>
5
This program is free software; you can redistribute it and/or modify it
6
under the terms of the GNU General Public License as published by the
7
Free Software Foundation; either version 2 of the License, or (at your
8
option) any later version.
10
This program is distributed in the hope that it will be useful, but
11
WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
General Public License for more details.
15
You should have received a copy of the GNU General Public License along
16
with this program; if not, write to the Free Software Foundation, Inc.,
17
675 Mass Ave, Cambridge, MA 02139, USA.
27
//**************************************
28
// For the incurably fiddle prone:
30
// log2 of sample size
33
// overlap amount between samples. Set to 1 or 2 if you have a fast computer
37
#define Brightness 150
40
#define Frequency 22050
42
//***************************************
44
#define DefaultWidth 260
45
#define DefaultHeight 260
47
#define NumSamples (1<<LogSize)
48
#define RecSize (1<<LogSize-Overlap)
51
#warning This target has not been tested!
55
#include <machine/endian.h>
56
typedef unsigned short sampleType;
59
typedef short sampleType;
62
#if BYTE_ORDER == BIG_ENDIAN
68
void error(const char *str, bool syscall=false);
69
void warning(const char *str, bool syscall=false);
74
Play, Pause, Stop, SkipFwd, SkipBack,
75
Handle, Pointer, Open, NoCD, Exit,
76
Zero, One, Two, Three, Four,
77
Five, Six, Seven, Eight, Nine,
78
Slider, Selector, Plug, Loop, Box, Bar,
79
Flame, Wave, Stars, Star, Diamond, Size, FgColor, BgColor,
80
Save, Reset, TrackSelect,
87
virtual bool init(int xHint, int yHint, int widthHint, int heightHint, bool fullscreen) = 0;
88
virtual void setPalette(unsigned char *palette) = 0;
89
virtual void end() = 0;
90
virtual int sizeUpdate() = 0;
91
virtual bool inputUpdate(int &mouseX,int &mouseY,int &mouseButtons,char &keyHit) = 0;
92
virtual void show() = 0;
95
struct SdlScreen : public BaseScreen
97
bool init(int xHint, int yHint, int widthHint, int heightHint, bool fullscreen);
98
void setPalette(unsigned char *palette);
101
bool inputUpdate(int &mouseX,int &mouseY,int &mouseButtons,char &keyHit);
110
static unsigned short combine(unsigned short a,unsigned short b)
112
//Not that i want to give the compiler a hint or anything...
113
unsigned char ah = a>>8, al = a&255, bh = b>>8, bl = b&255;
114
if (ah < 64) ah *= 4; else ah = 255;
115
if (al < 64) al *= 4; else al = 255;
116
if (bh > ah) ah = bh;
117
if (bl > al) al = bl;
130
inline unsigned char *output() { return (unsigned char*)outputBmp.data; }
131
inline unsigned char *lastOutput() { return (unsigned char*)lastOutputBmp.data; }
132
inline unsigned char *lastLastOutput() { return (unsigned char*)lastLastOutputBmp.data; }
134
void allocOutput(int w,int h);
135
void interfaceInit();
137
void setStarSize(double size);
138
void setupPalette(double);
146
inline void fadePixelWave(int x, int y, int where, int step);
148
inline void fadePixelHeat(int x,int y,int where,int step);
151
void fft(double*, double*);
153
inline void addPixel(int x, int y, int br1, int br2);
154
inline void addPixelFast(unsigned char *p, int br1, int br2);
155
inline unsigned char getPixel(int x, int y, int where);
157
static int bitReverser(int);
162
Interface *interface;
164
Bitmap<unsigned short> outputBmp, lastOutputBmp, lastLastOutputBmp;
165
PolygonEngine<unsigned short,Combiner,2> polygonEngine;
167
double cosTable[NumSamples], negSinTable[NumSamples];
168
int bitReverse[NumSamples];
174
int outWidth, outHeight;
176
bool pointsAreDiamonds;
178
double brightnessTwiddler;
181
double fgRedSlider, fgGreenSlider, bgRedSlider, bgGreenSlider;
184
int windX, windY, windWidth, windHeight;
189
inline unsigned char Core::getPixel(int x,int y,int where)
191
if (x < 0 || y < 0 || x >= outWidth || y >= outHeight) return 0;
192
return lastOutput()[where];
200
int visibleMask, activeMask;
201
double x,y,width,height;
204
virtual int go(bool mouseDown,bool mouseClick,bool mouseOver,
205
double x, double y, double scale, char &hotKey, int &action)
208
virtual void handleKey(char key, int &action) = 0;
221
void putString(char *string,int x,int y,int red,int blue);
224
void addUI(UIObject *obj);
225
void changeState(int transitionSymbol);
228
QList<UIObject> uiObjects;
229
Button *stateButton, *starsButton, *waveButton, *flameButton, *starButton, *diamondButton;
233
int mouseX, mouseY, lastX, lastY, countDown;