1 #ifndef _GFORCE_H_ 2 #define _GFORCE_H_ 3 4 #include "GForcePixPort.h" 5 #include "FileSpecList.h" 6 #include "ArgList.h" 7 #include "Expression.h" 8 #include "WaveShape.h" 9 #include "DeltaField.h" 10 #include "GF_Palette.h" 11 #include "XLongList.h" 12 #include "ScreenDevice.h" 13 14 #include "Prefs.h" 15 16 17 enum { 18 19 cDispTrackTitle = 1, 20 cGetConfigInfo = 2, 21 cFrameRate = 3, 22 cSpawnNewParticle = 4, 23 cToggleFullsceen = 5, 24 cToggleConfigName = 6, 25 cToggleNormalize = 7, 26 cStartSlideshowAll = 8, 27 cStopSlideshowAll = 9, 28 cPrevDeltaField = 10, 29 cNextDeltaField = 11, 30 cToggleFieldShow = 12, 31 cPrevColorMap = 13, 32 cNextColorMap = 14, 33 cToggleColorShow = 15, 34 cPrevWaveShape = 16, 35 cNextWaveShape = 17, 36 cToggleShapeShow = 18, 37 cDecMagScale = 19, 38 cIncMagScale = 20, 39 cDecNumSSteps = 21, 40 cIncNumSSteps = 22, 41 cToggleParticles = 23, 42 cSetPreset0 = 30, 43 cSetPreset1 = 31, 44 cSetPreset2 = 32, 45 cSetPreset3 = 33, 46 cSetPreset4 = 34, 47 cSetPreset5 = 35, 48 cSetPreset6 = 36, 49 cSetPreset7 = 37, 50 cSetPreset8 = 38, 51 cSetPreset9 = 39, 52 cPreset0 = 40, 53 cPreset1 = 41, 54 cPreset2 = 42, 55 cPreset3 = 43, 56 cPreset4 = 44, 57 cPreset5 = 45, 58 cPreset6 = 46, 59 cPreset7 = 47, 60 cPreset8 = 48, 61 cPreset9 = 49 62 }; 63 64 65 66 class PortPage { 67 68 PixPort* mPort; 69 70 }; 71 72 73 74 class GForce { 75 76 public: 77 GForce( void* inRefCon = 0 ); 78 ~GForce(); 79 80 81 void SetOutVideoBuffer( unsigned char *inVideoBuffer); GetPalette()82 PixPalEntry* GetPalette() { return mPalette; } 83 84 void SetFullscreen( bool inFullScreen ); IsFullscreen()85 inline bool IsFullscreen() { return mAtFullScreen; } 86 87 // Pre: mSample[] has contains a sample/copy of the freq spectrum 88 // void RecordSample( long inCurTime, float* inFourier, long inNumBins ); 89 void RecordSample( long inCurTime, float* inSound, float inScale, long inNumBins, float* inFFT, float inFFTScale, long inFFTNumBin ); 90 void RecordZeroSample( long inCurTime ); 91 BorderlessWindow()92 bool BorderlessWindow() { return mBorderlessWind; } 93 94 // This blackens the entire plugin/window area Refresh()95 void Refresh() { mNeedsPaneErased = true; } 96 97 bool HandleKey( long inChar ); 98 99 StoreWinRect()100 void StoreWinRect() { if ( ! IsFullscreen() ) GetWinRect( mWinRectHolder ); } 101 102 void SetPort( GrafPtr inPort, const Rect& inRect, bool inAtFullsceen ); 103 104 void SetWinPort( WindowPtr inPort, const Rect* inRect = 0 ); 105 106 void GetWinRect( Rect& outRect ); 107 DefaultNum_FFT_Steps()108 long DefaultNum_FFT_Steps() { return mNum_FFT_Steps; } 109 DefaultNum_S_Steps()110 long DefaultNum_S_Steps() { return mNum_S_Steps; } 111 112 GetFullscreenSize()113 Point GetFullscreenSize() { return mFullscreenSize; } GetFullscreenDepth()114 long GetFullscreenDepth() { return mFullscreenDepth; } 115 116 /* NewSong() tells GForce a new track has started and that the following four strings may contain info. */ 117 UtilStr mArtist; 118 UtilStr mAlbum; 119 UtilStr mSongTitle; 120 void NewSong(); 121 122 protected: 123 unsigned char* mVideoBuffer; 124 GrafPtr mOutPort; 125 WindowPtr mWind; 126 127 void* mRefCon; 128 bool mDoingSetPortWin; // true when a thread is currently inside SetPortWin() 129 Rect mWinRectHolder; // Win rect holder while we're n FS mode 130 Rect mDispRect; // Local cords rect that specify where the blt area is 131 Rect mPaneRect; // Local cords rect within mOSPort we can draw in 132 Prefs mPrefs; 133 134 135 GForcePixPort mPortA, mPortB; 136 GForcePixPort* mCurPort; 137 138 // Console related members 139 XStrList mConsoleLines; 140 XLongList mLineExpireTimes; 141 UtilStr mTemp; 142 long mConsoleDelay; 143 long mConsoleLineDur; 144 long mConsoleExpireTime; 145 void DrawConsole(); 146 void Print( char* inStr ); Print(UtilStr * inStr)147 void Print( UtilStr* inStr ) { if ( inStr ) Print( inStr -> getCStr() ); } 148 void Println( char* inStr ); Println(UtilStr * inStr)149 void Println( UtilStr* inStr ) { Println( inStr ? inStr -> getCStr() : 0 ); } 150 151 // Palette stuff 152 PixPalEntry mPalette[ 256 ]; 153 GF_Palette mPal1, mPal2, *mGF_Palette, *mNextPal; 154 float mNextPaletteUpdate; 155 float mIntensityParam; 156 157 158 // Plugin prefs 159 float mScrnSaverDelay; 160 long mTransitionLo; 161 long mTransitionHi; 162 long mHandleKeys; 163 float mMagScale; 164 long mBorderlessWind; 165 long mNum_S_Steps; 166 long mNum_FFT_Steps; 167 bool mNewConfigNotify; 168 bool mNormalizeInput; 169 bool mParticlesOn; 170 Point mMaxSize; 171 Point mFullscreenSize; 172 long mFullscreenDepth; 173 long mFullscreenDevice; 174 UtilStr mKeyMap; 175 UtilStr mParticleDuration; // Num secs a particle will stay around 176 UtilStr mParticleProbability; // Probability a new sausage will start 177 UtilStr mTrackMetaText; 178 UtilStr mTrackFont; 179 UtilStr mTrackTextStartStr; 180 UtilStr mTrackTextDurationStr; 181 long mTrackTextPosMode; 182 long mTrackTextSize; 183 184 185 // Particle stuff 186 long mNextParticleCheck; 187 float mLastParticleStart; // LAST_PARTICLE_START 188 float mNumRunningParticles; // NUM_PARTICLES 189 Expression mParticleProbabilityFcn; // mParticleProbability compiled 190 Expression mParticleDurationFcn; // mParticleDuration compiles 191 ExpressionDict mDict; 192 nodeClass mStoppedParticlePool; 193 nodeClass mRunningParticlePool; 194 195 FileSpecList mDeltaFields, mColorMaps, mWaveShapes, mParticles; 196 long mCurFieldNum, mCurColorMapNum, mCurShapeNum, mCurParticleNum; 197 float mNextFieldChange, mNextColorChange, mNextShapeChange; 198 XLongList mFieldPlayList, mColorPlayList, mShapePlayList, mParticlePlayList; 199 UtilStr mFieldIntervalStr, mColorIntervalStr, mShapeIntervalStr; 200 long mColorTransEnd, mShapeTransEnd; 201 long mColorTransTime, mShapeTransTime; // When > 0, transition is in progress 202 float mColorTrans; 203 bool mFieldSlideShow, mColorSlideShow, mShapeSlideShow; 204 UtilStr mColorMapName, mWaveShapeName; 205 Expression mFieldInterval, mColorInterval, mShapeInterval; 206 #define TRANSITION_ALPHA 1.45 207 208 209 // Linked dict vars/addressed data spaces 210 float mT; 211 212 // Field stuff 213 DeltaField* mField, *mNextField; 214 DeltaField mField1, mField2; 215 216 // WaveShape stuff 217 float mWaveXScale; 218 float mWaveYScale; 219 WaveShape mWave1, mWave2, *mWave, *mNextWave; 220 long mT_MS, mT_MS_Base; 221 UtilStr mSamplesBuf; 222 UtilStr mFFTBuf; 223 UtilStr mSineBuf; 224 float* mSine; 225 226 ExprUserFcn* mSampleFcn; 227 ExprUserFcn* mFFTFcn; 228 229 ScreenDevice mScreen; 230 231 void loadDeltaField( long inFieldNum ); 232 void loadWaveShape( long inShapeNum, bool inAllowMorph ); 233 void loadColorMap( long inColorMapNum, bool inAllowMorph ); 234 void loadParticle( long inParticleNum ); 235 236 237 void RecordSample( long inCurTime ); 238 void BuildConfigLists(); 239 void DrawWave( PixPort& inDest ); 240 241 // Frame rate/calc members 242 long mCurFrameRate; 243 float mFrameCountStart; 244 long mFrameCount; 245 246 // Stuff dealing with full screen & screensaver mode 247 bool mAtFullScreen; 248 bool mMouseWillAwaken; 249 Point mLastMousePt; 250 float mLastActiveTime, mLastKeyPollTime; 251 KeyMap mCurKeys, mPastKeys; 252 void IdleMonitor(); 253 254 255 256 // GUI related stuff 257 long mLastCursorUpdate; 258 long mLastGetKeys; 259 bool mNeedsPaneErased; 260 void ErasePane(); 261 void DrawFrame(); 262 263 void StoreConfigState( long inParamName ); 264 bool RestoreConfigState( long inParamName ); 265 void ShowHelp(); 266 267 // Track text related 268 float mLastSongStart; 269 float mTrackTextStartTime; 270 float mTrackTextDur; 271 Expression mTrackTextStartFcn, mTrackTextDurFcn; 272 Point mTrackTextPos; 273 UtilStr mTrackText; 274 void CalcTrackTextPos(); 275 void StartTrackText(); 276 277 void DrawParticles( PixPort& inPort ); 278 279 void SetNumSampleBins( long inNumBins ); 280 void SetNumFFTBins( long inNumBins ); 281 282 void ManageColorChanges(); 283 void ManageShapeChanges(); 284 void ManageFieldChanges(); 285 void ManageParticleChanges(); 286 287 void SpawnNewParticle(); 288 289 }; 290 291 #endif 292