1 /*
2   LICENSE
3   -------
4 Copyright 2005-2013 Nullsoft, Inc.
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10   * Redistributions of source code must retain the above copyright notice,
11     this list of conditions and the following disclaimer.
12 
13   * Redistributions in binary form must reproduce the above copyright notice,
14     this list of conditions and the following disclaimer in the documentation
15     and/or other materials provided with the distribution.
16 
17   * Neither the name of Nullsoft nor the names of its contributors may be used to
18     endorse or promote products derived from this software without specific prior written permission.
19 
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
21 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
27 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29 
30 #ifndef __NULLSOFT_DX9_EXAMPLE_PLUGIN_H__
31 #define __NULLSOFT_DX9_EXAMPLE_PLUGIN_H__ 1
32 
33 #include "pluginshell.h"
34 #include "md_defines.h"
35 #include "menu.h"
36 #include "support.h"
37 #include "texmgr.h"
38 #include "state.h"
39 #include "../nu/Vector.h"
40 
41 #include "gstring.h"
42 #include "../ns-eel2/ns-eel.h"
43 
44 
45 
46 extern "C" int (*warand)(void);
47 
48 typedef enum { TEX_DISK, TEX_VS, TEX_BLUR0, TEX_BLUR1, TEX_BLUR2, TEX_BLUR3, TEX_BLUR4, TEX_BLUR5, TEX_BLUR6, TEX_BLUR_LAST } tex_code;
49 typedef enum { UI_REGULAR, UI_MENU, UI_LOAD, UI_LOAD_DEL, UI_LOAD_RENAME, UI_SAVEAS, UI_SAVE_OVERWRITE, UI_EDIT_MENU_STRING, UI_CHANGEDIR, UI_IMPORT_WAVE, UI_EXPORT_WAVE, UI_IMPORT_SHAPE, UI_EXPORT_SHAPE, UI_UPGRADE_PIXEL_SHADER, UI_MASHUP } ui_mode;
50 typedef struct { float rad; float ang; float a; float c;  } td_vertinfo; // blending: mix = max(0,min(1,a*t + c));
51 typedef char* CHARPTR;
52 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
53 
54 #define MY_FFT_SAMPLES 512     // for old [pre-vms] milkdrop sound analysis
55 typedef struct
56 {
57 	float   imm[3];			// bass, mids, treble (absolute)
58 	float	imm_rel[3];		// bass, mids, treble (relative to song; 1=avg, 0.9~below, 1.1~above)
59 	float	avg[3];			// bass, mids, treble (absolute)
60 	float	avg_rel[3];		// bass, mids, treble (relative to song; 1=avg, 0.9~below, 1.1~above)
61 	float	long_avg[3];	// bass, mids, treble (absolute)
62     float   fWave[2][576];
63     float   fSpecLeft[MY_FFT_SAMPLES];
64 } td_mysounddata;
65 
66 typedef struct
67 {
68 	int 	bActive;
69 	int 	bFilterBadChars;	// if true, it will filter out any characters that don't belong in a filename, plus the & symbol (because it doesn't display properly with DrawText)
70 	int 	bDisplayAsCode;		// if true, semicolons will be followed by a newline, for display
71 	int		nMaxLen;			// can't be more than 511
72 	int		nCursorPos;
73 	int		nSelAnchorPos;		// -1 if no selection made
74 	int 	bOvertypeMode;
75 	wchar_t	szText[48000];
76 	wchar_t	szPrompt[512];
77 	wchar_t	szToolTip[512];
78 	char	szClipboard[48000];
79 	wchar_t	szClipboardW[48000];
80 } td_waitstr;
81 
82 typedef struct
83 {
84 	int 	bBold;
85 	int 	bItal;
86 	wchar_t	szFace[128];
87 	int		nColorR;    // 0..255
88 	int		nColorG;    // 0..255
89 	int		nColorB;    // 0..255
90 }
91 td_custom_msg_font;
92 
93 enum
94 {
95 	MD2_PS_NONE = 0,
96 	MD2_PS_2_0 = 2,
97 	MD2_PS_2_X = 3,
98 	MD2_PS_3_0 = 4,
99 	MD2_PS_4_0 = 5, // not supported by milkdrop
100 };
101 /*
102 typedef struct
103 {
104     char szFace[256];
105     int nSize;
106     int bBold;
107     int bItalic;
108 } td_titlefontinfo;*/
109 
110 typedef struct
111 {
112 	int		nFont;
113 	float	fSize;	// 0..100
114 	float	x;
115 	float	y;
116 	float	randx;
117 	float   randy;
118 	float	growth;
119 	float	fTime;	// total time to display the message, in seconds
120 	float	fFade;	// % (0..1) of the time that is spent fading in
121 
122 	// overrides
123 	int     bOverrideBold;
124 	int     bOverrideItal;
125 	int     bOverrideFace;
126 	int     bOverrideColorR;
127 	int     bOverrideColorG;
128 	int     bOverrideColorB;
129 	int		nColorR;    // 0..255
130 	int		nColorG;    // 0..255
131 	int		nColorB;    // 0..255
132 	int  	nRandR;
133 	int     nRandG;
134 	int  	nRandB;
135 	int     bBold;
136 	int     bItal;
137 	wchar_t szFace[128];
138 
139 	wchar_t	szText[256];
140 }
141 td_custom_msg;
142 
143 typedef struct
144 {
145 	int 	bRedrawSuperText;	// true if it needs redraw
146 	int 	bIsSongTitle;		// false for custom message, true for song title
147 	//char	szText[256];
148 	wchar_t	szTextW[256];
149 	wchar_t	nFontFace[128];
150 	int 	bBold;
151 	int 	bItal;
152 	float	fX;
153 	float   fY;
154 	float	fFontSize;			// [0..100] for custom messages, [0..4] for song titles
155 	float   fGrowth;			// applies to custom messages only
156 	int		nFontSizeUsed;		// height IN PIXELS
157 	float	fStartTime;
158 	float	fDuration;
159 	float	fFadeTime;			// applies to custom messages only; song title fade times are handled specially
160 	int  	nColorR;
161 	int     nColorG;
162 	int  	nColorB;
163 }
164 td_supertext;
165 
166 typedef struct
167 {
168     wchar_t        texname[256];   // ~filename, but without path or extension!
169     LPDIRECT3DBASETEXTURE9 texptr;
170     int                w,h,d;
171     //D3DXHANDLE         texsize_param;
172     bool               bEvictable;
173     int                 nAge;   // only valid if bEvictable is true
174     int                 nSizeInBytes;    // only valid if bEvictable is true
175 } TexInfo;
176 
177 typedef struct
178 {
179     GString    texname;  // just for ref
180     D3DXHANDLE texsize_param;
181     int        w,h;
182 } TexSizeParamInfo;
183 
184 typedef struct
185 {
186     LPDIRECT3DBASETEXTURE9 texptr;
187     bool               bBilinear;
188     bool               bWrap;
189 } SamplerInfo;
190 
191 typedef struct
192 {
193     GString   msg;
194     bool      bBold;  // true == red bkg; false == black bkg
195     float     birthTime;
196     float     expireTime;
197     int       category;
198 } ErrorMsg;
199 typedef Vector<ErrorMsg> ErrorMsgList;
200 
201 typedef Vector<CShaderParams*> CShaderParamsList;
202 
203 class CShaderParams
204 {
205 public:
206     // float4 handles:
207     D3DXHANDLE rand_frame ;
208     D3DXHANDLE rand_preset;
209     D3DXHANDLE const_handles[24];
210     D3DXHANDLE q_const_handles[(NUM_Q_VAR+3)/4];
211     D3DXHANDLE rot_mat[24];
212 
213     typedef Vector<TexSizeParamInfo> TexSizeParamInfoList;
214     TexSizeParamInfoList texsize_params;
215 
216     // sampler stages for various PS texture bindings:
217     //int texbind_vs;
218     //int texbind_disk[32];
219     //int texbind_voronoi;
220     //...
221     SamplerInfo   m_texture_bindings[16];  // an entry for each sampler slot.  These are ALIASES - DO NOT DELETE.
222     tex_code      m_texcode[16];  // if ==TEX_VS, forget the pointer - texture bound @ that stage is the double-buffered VS.
223 
224     void Clear();
225     void CacheParams(LPD3DXCONSTANTTABLE pCT, bool bHardErrors);
226     void OnTextureEvict(LPDIRECT3DBASETEXTURE9 texptr);
227     CShaderParams();
228     ~CShaderParams();
229 };
230 
231 class VShaderInfo
232 {
233 public:
234     IDirect3DVertexShader9* ptr;
235     LPD3DXCONSTANTTABLE     CT;
236     CShaderParams           params;
VShaderInfo()237     VShaderInfo()  { ptr=NULL; CT=NULL; params.Clear(); }
~VShaderInfo()238     ~VShaderInfo() { Clear(); }
239     void Clear();
240 };
241 
242 class PShaderInfo
243 {
244 public:
245     IDirect3DPixelShader9*  ptr;
246     LPD3DXCONSTANTTABLE     CT;
247     CShaderParams           params;
PShaderInfo()248     PShaderInfo()  { ptr=NULL; CT=NULL; params.Clear(); }
~PShaderInfo()249     ~PShaderInfo() { Clear(); }
250     void Clear();
251 };
252 
253 typedef struct
254 {
255     VShaderInfo vs;
256     PShaderInfo ps;
257 } ShaderPairInfo;
258 
259 typedef struct
260 {
261     PShaderInfo warp;
262     PShaderInfo comp;
263 } PShaderSet;
264 
265 typedef struct
266 {
267     VShaderInfo warp;
268     VShaderInfo comp;
269 } VShaderSet;
270 
271 /*
272 typedef struct
273 {
274     void*                ptr;  // to IDirect3DPixelShader9 or IDirect3DVertexShader9
275     LPD3DXCONSTANTTABLE  CT;
276     CShaderParams        params;
277 } ShaderInfo;
278 
279 typedef struct
280 {
281     ShaderInfo warp;
282     ShaderInfo comp;
283 } ShaderSet;
284 */
285 
286 typedef struct
287 {
288     GString  szFilename;    // without path
289     float    fRatingThis;
290     float    fRatingCum;
291 } PresetInfo;
292 typedef Vector<PresetInfo> PresetList;
293 
294 
295 class CPlugin : public CPluginShell
296 {
297 public:
298 
299     //====[ 1. members added to create this specific example plugin: ]================================================
300 
301         /// CONFIG PANEL SETTINGS THAT WE'VE ADDED (TAB #2)
302         bool		m_bFirstRun;
303         float		m_fBlendTimeAuto;		// blend time when preset auto-switches
304         float		m_fBlendTimeUser;		// blend time when user loads a new preset
305         float		m_fTimeBetweenPresets;		// <- this is in addition to m_fBlendTimeAuto
306         float		m_fTimeBetweenPresetsRand;	// <- this is in addition to m_fTimeBetweenPresets
307         bool        m_bSequentialPresetOrder;
308         bool		m_bHardCutsDisabled;
309         float		m_fHardCutLoudnessThresh;
310         float		m_fHardCutHalflife;
311         float		m_fHardCutThresh;
312         //int			m_nWidth;
313         //int			m_nHeight;
314         //int			m_nDispBits;
315         int         m_nCanvasStretch;   // 0=Auto, 100=None, 125 = 1.25X, 133, 150, 167, 200, 300, 400 (4X).
316         int			m_nTexSizeX;			// -1 = exact match to screen; -2 = nearest power of 2.
317         int			m_nTexSizeY;
318         float       m_fAspectX;
319         float       m_fAspectY;
320         float       m_fInvAspectX;
321         float       m_fInvAspectY;
322 		int         m_nTexBitsPerCh;
323         int			m_nGridX;
324         int			m_nGridY;
325 
326         bool		m_bShowPressF1ForHelp;
327         //char		m_szMonitorName[256];
328         bool		m_bShowMenuToolTips;
329         int			m_n16BitGamma;
330         bool		m_bAutoGamma;
331         //int		m_nFpsLimit;
332         //int			m_cLeftEye3DColor[3];
333         //int			m_cRightEye3DColor[3];
334         bool		m_bEnableRating;
335         //bool        m_bInstaScan;
336         bool		m_bSongTitleAnims;
337         float		m_fSongTitleAnimDuration;
338         float		m_fTimeBetweenRandomSongTitles;
339         float		m_fTimeBetweenRandomCustomMsgs;
340         int			m_nSongTitlesSpawned;
341         int			m_nCustMsgsSpawned;
342 
343         //bool		m_bAlways3D;
344         //float       m_fStereoSep;
345         //bool		m_bAlwaysOnTop;
346         //bool		m_bFixSlowText;
347         //bool		m_bWarningsDisabled;		// messageboxes
348         bool		m_bWarningsDisabled2;		// warnings/errors in upper-right corner (m_szUserMessage)
349         //bool        m_bAnisotropicFiltering;
350         bool        m_bPresetLockOnAtStartup;
351 		bool		m_bPreventScollLockHandling;
352         int         m_nMaxPSVersion_ConfigPanel;  // -1 = auto, 0 = disable shaders, 2 = ps_2_0, 3 = ps_3_0
353         int         m_nMaxPSVersion_DX9;          // 0 = no shader support, 2 = ps_2_0, 3 = ps_3_0
354         int         m_nMaxPSVersion;              // this one will be the ~min of the other two.  0/2/3.
355         int         m_nMaxImages;
356         int         m_nMaxBytes;
357 
358         /*
359         char		m_szFontFace[NUM_FONTS][128];
360         int			m_nFontSize[NUM_FONTS];
361         bool		m_bFontBold[NUM_FONTS];
362         bool		m_bFontItalic[NUM_FONTS];
363         char		 m_szTitleFontFace[128];
364         int			 m_nTitleFontSize;			// percentage of screen width (0..100)
365         bool		 m_bTitleFontBold;
366         bool		 m_bTitleFontItalic;
367         */
368         HFONT       m_gdi_title_font_doublesize;
369         LPD3DXFONT  m_d3dx_title_font_doublesize;
370 
371         // PIXEL SHADERS
372         DWORD                   m_dwShaderFlags;       // Shader compilation/linking flags
373         //ID3DXFragmentLinker*    m_pFragmentLinker;     // Fragment linker interface
374         //LPD3DXBUFFER            m_pCompiledFragments;  // Buffer containing compiled fragments
375         LPD3DXBUFFER            m_pShaderCompileErrors;
376         VShaderSet              m_fallbackShaders_vs;  // *these are the only vertex shaders used for the whole app.*
377         PShaderSet              m_fallbackShaders_ps;  // these are just used when the preset's pixel shaders fail to compile.
378         PShaderSet              m_shaders;     // includes shader pointers and constant tables for warp & comp shaders, for cur. preset
379         PShaderSet              m_OldShaders;  // includes shader pointers and constant tables for warp & comp shaders, for prev. preset
380         PShaderSet              m_NewShaders;  // includes shader pointers and constant tables for warp & comp shaders, for coming preset
381         ShaderPairInfo          m_BlurShaders[2];
382         bool                    m_bWarpShaderLock;
383         bool                    m_bCompShaderLock;
384         //bool LoadShaderFromFile( char* szFile, char* szFn, char* szProfile,
385         //                         LPD3DXCONSTANTTABLE* ppConstTable, void** ppShader );
386         #define SHADER_WARP  0
387         #define SHADER_COMP  1
388         #define SHADER_BLUR  2
389         #define SHADER_OTHER 3
390         bool LoadShaderFromMemory( const char* szShaderText, char* szFn, char* szProfile,
391                                    LPD3DXCONSTANTTABLE* ppConstTable, void** ppShader, int shaderType, bool bHardErrors );
392         bool RecompileVShader(const char* szShadersText, VShaderInfo *si, int shaderType, bool bHardErrors);
393         bool RecompilePShader(const char* szShadersText, PShaderInfo *si, int shaderType, bool bHardErrors, int PSVersion);
394         bool EvictSomeTexture();
395         typedef Vector<TexInfo> TexInfoList;
396         TexInfoList     m_textures;
397         bool m_bNeedRescanTexturesDir;
398         // vertex declarations:
399         IDirect3DVertexDeclaration9* m_pSpriteVertDecl;
400         IDirect3DVertexDeclaration9* m_pWfVertDecl;
401         IDirect3DVertexDeclaration9* m_pMyVertDecl;
402 
403         D3DXVECTOR4 m_rand_frame;  // 4 random floats (0..1); randomized once per frame; fed to pixel shaders.
404 
405         // RUNTIME SETTINGS THAT WE'VE ADDED
406         float       m_prev_time;
407         bool		m_bTexSizeWasAutoPow2;
408 		bool        m_bTexSizeWasAutoExact;
409         bool		m_bPresetLockedByUser;
410         bool		m_bPresetLockedByCode;
411         float		m_fAnimTime;
412         float		m_fStartTime;
413         float		m_fPresetStartTime;
414         float		m_fNextPresetTime;
415         float       m_fSnapPoint;
416         CState		*m_pState;				// points to current CState
417         CState		*m_pOldState;			// points to previous CState
418         CState		*m_pNewState;			// points to the coming CState - we're not yet blending to it b/c we're still compiling the shaders for it!
419         int         m_nLoadingPreset;
420         wchar_t     m_szLoadingPreset[MAX_PATH];
421         float       m_fLoadingPresetBlendTime;
422         int         m_nPresetsLoadedTotal; //important for texture eviction age-tracking...
423         CState		m_state_DO_NOT_USE[3];	// do not use; use pState and pOldState instead.
424         ui_mode		m_UI_mode;				// can be UI_REGULAR, UI_LOAD, UI_SAVEHOW, or UI_SAVEAS
425 
426         #define MASH_SLOTS 5
427         #define MASH_APPLY_DELAY_FRAMES 1
428         int         m_nMashSlot;    //0..MASH_SLOTS-1
429         //char        m_szMashDir[MASH_SLOTS][MAX_PATH];
430         int         m_nMashPreset[MASH_SLOTS];
431         int         m_nLastMashChangeFrame[MASH_SLOTS];
432 
433         //td_playlist_entry *m_szPlaylist;	// array of 128-char strings
434         //int		m_nPlaylistCurPos;
435         //int		m_nPlaylistLength;
436         //int		m_nTrackPlaying;
437         //int		m_nSongPosMS;
438         //int		m_nSongLenMS;
439         bool		m_bUserPagedUp;
440         bool		m_bUserPagedDown;
441         float		m_fMotionVectorsTempDx;
442         float		m_fMotionVectorsTempDy;
443 
444         td_waitstr  m_waitstring;
445         void		WaitString_NukeSelection();
446         void		WaitString_Cut();
447         void		WaitString_Copy();
448         void		WaitString_Paste();
449         void		WaitString_SeekLeftWord();
450         void		WaitString_SeekRightWord();
451         int			WaitString_GetCursorColumn();
452         int			WaitString_GetLineLength();
453         void		WaitString_SeekUpOneLine();
454         void		WaitString_SeekDownOneLine();
455 
456         int			m_nPresets;			// the # of entries in the file listing.  Includes directories and then files, sorted alphabetically.
457         int			m_nDirs;			// the # of presets that are actually directories.  Always between 0 and m_nPresets.
458         int			m_nPresetListCurPos;// Index of the currently-HIGHLIGHTED preset (the user must press Enter on it to select it).
459         int			m_nCurrentPreset;	// Index of the currently-RUNNING preset.
460 								        //   Note that this is NOT the same as the currently-highlighted preset! (that's m_nPresetListCurPos)
461 								        //   Be careful - this can be -1 if the user changed dir. & a new preset hasn't been loaded yet.
462         wchar_t		m_szCurrentPresetFile[512];	// w/o path.  this is always valid (unless no presets were found)
463         PresetList  m_presets;
464 	    void		UpdatePresetList(bool bBackground=false, bool bForce=false, bool bTryReselectCurrentPreset=true);
465         wchar_t     m_szUpdatePresetMask[MAX_PATH];
466         bool        m_bPresetListReady;
467 	    //void		UpdatePresetRatings();
468         //int         m_nRatingReadProgress;  // equals 'm_nPresets' if all ratings are read in & ready to go; -1 if uninitialized; otherwise, it's still reading them in, and range is: [0 .. m_nPresets-1]
469         bool        m_bInitialPresetSelected;
470 
471         // PRESET HISTORY
472         #define PRESET_HIST_LEN (64+2)     // make this 2 more than the # you REALLY want to be able to go back.
473         GString     m_presetHistory[PRESET_HIST_LEN];   //circular
474         int         m_presetHistoryPos;
475         int         m_presetHistoryBackFence;
476         int         m_presetHistoryFwdFence;
477         void        PrevPreset(float fBlendTime);
478         void        NextPreset(float fBlendTime);  // if not retracing our former steps, it will choose a random one.
479         void        OnFinishedLoadingPreset();
480 
481         FFT            myfft;
482         td_mysounddata mysound;
483 
484         // stuff for displaying text to user:
485         //int			m_nTextHeightPixels;	// this is for the menu/detail font; NOT the "fancy font"
486         //int			m_nTextHeightPixels_Fancy;
487         bool		m_bShowFPS;
488         bool		m_bShowRating;
489         bool		m_bShowPresetInfo;
490         bool		m_bShowDebugInfo;
491         bool		m_bShowSongTitle;
492         bool		m_bShowSongTime;
493         bool		m_bShowSongLen;
494         float		m_fShowRatingUntilThisTime;
495         //float		m_fShowUserMessageUntilThisTime;
496         //char		m_szUserMessage[512];
497          //bool        m_bUserMessageIsError;
498 
499         #define ERR_ALL    0
500         #define ERR_INIT   1  //specifically, loading a preset
501         #define ERR_PRESET 2  //specifically, loading a preset
502         #define ERR_MISC   3
503         #define ERR_NOTIFY 4  // a simple notification - not an error at all. ("shuffle is now ON." etc.)
504                               // NOTE: each NOTIFY msg clears all the old NOTIFY messages!
505         #define ERR_SCANNING_PRESETS 5
506         ErrorMsgList m_errors;
507         void        AddError(wchar_t* szMsg, float fDuration, int category=ERR_ALL, bool bBold=true);
508         void        ClearErrors(int category=ERR_ALL);  // 0=all categories
509 
510         char		m_szDebugMessage[512];
511         wchar_t		m_szSongTitle    [512];
512         wchar_t		m_szSongTitlePrev[512];
513         //HFONT		m_hfont[3];	// 0=fancy font (for song titles, preset name)
514 						        // 1=legible font (the main font)
515 						        // 2=tooltip font (for tooltips in the menu system)
516         //HFONT       m_htitlefont[NUM_TITLE_FONTS]; // ~25 different sizes
517         // stuff for menu system:
518         CMilkMenu	*m_pCurMenu;	// should always be valid!
519         CMilkMenu	 m_menuPreset;
520         CMilkMenu	  m_menuWave;
521         CMilkMenu	  m_menuAugment;
522         CMilkMenu	  m_menuCustomWave;
523         CMilkMenu	  m_menuCustomShape;
524         CMilkMenu	  m_menuMotion;
525         CMilkMenu	  m_menuPost;
526         CMilkMenu    m_menuWavecode[MAX_CUSTOM_WAVES];
527         CMilkMenu    m_menuShapecode[MAX_CUSTOM_SHAPES];
528         bool         m_bShowShaderHelp;
529 
530 
531 
532         wchar_t		m_szMilkdrop2Path[MAX_PATH];		// ends in a backslash
533         wchar_t		m_szMsgIniFile[MAX_PATH];
534         wchar_t     m_szImgIniFile[MAX_PATH];
535         wchar_t		m_szPresetDir[MAX_PATH];
536         float		m_fRandStart[4];
537 
538         // DIRECTX 9:
539         IDirect3DTexture9 *m_lpVS[2];
540         #define NUM_BLUR_TEX 6
541         #if (NUM_BLUR_TEX>0)
542 	    IDirect3DTexture9 *m_lpBlur[NUM_BLUR_TEX]; // each is successively 1/2 size of prev.
543         int               m_nBlurTexW[NUM_BLUR_TEX];
544         int               m_nBlurTexH[NUM_BLUR_TEX];
545         #endif
546         int m_nHighestBlurTexUsedThisFrame;
547         IDirect3DTexture9 *m_lpDDSTitle;    // CAREFUL: MIGHT BE NULL (if not enough mem)!
548         int               m_nTitleTexSizeX, m_nTitleTexSizeY;
549         MYVERTEX          *m_verts;
550         MYVERTEX          *m_verts_temp;
551         td_vertinfo       *m_vertinfo;
552         int               *m_indices_strip;
553         int               *m_indices_list;
554 
555         // for final composite grid:
556         #define FCGSX 32 // final composite gridsize - # verts - should be EVEN.
557         #define FCGSY 24 // final composite gridsize - # verts - should be EVEN.
558                          // # of grid *cells* is two less,
559                          // since we have redundant verts along the center line in X and Y (...for clean 'ang' interp)
560         MYVERTEX    m_comp_verts[FCGSX*FCGSY];
561         int         m_comp_indices[(FCGSX-2)*(FCGSY-2)*2*3];
562 
563         bool		m_bMMX;
564         //bool		m_bSSE;
565         bool        m_bHasFocus;
566         bool        m_bHadFocus;
567         bool		m_bOrigScrollLockState;
568         //bool      m_bMilkdropScrollLockState;  // saved when focus is lost; restored when focus is regained
569 
570         int         m_nNumericInputMode;	// NUMERIC_INPUT_MODE_CUST_MSG, NUMERIC_INPUT_MODE_SPRITE
571         int         m_nNumericInputNum;
572         int			m_nNumericInputDigits;
573         td_custom_msg_font   m_CustomMessageFont[MAX_CUSTOM_MESSAGE_FONTS];
574         td_custom_msg        m_CustomMessage[MAX_CUSTOM_MESSAGES];
575 
576         texmgr      m_texmgr;		// for user sprites
577 
578         td_supertext m_supertext;	// **contains info about current Song Title or Custom Message.**
579 
580         IDirect3DTexture9 *m_tracer_tex;
581 
582         int         m_nFramesSinceResize;
583 
584         char        m_szShaderIncludeText[32768];     // note: this still has char 13's and 10's in it - it's never edited on screen or loaded/saved with a preset.
585         int         m_nShaderIncludeTextLen;          //  # of chars, not including the final NULL.
586         char        m_szDefaultWarpVShaderText[32768]; // THIS HAS CHAR 13/10 CONVERTED TO LINEFEED_CONTROL_CHAR
587         char        m_szDefaultWarpPShaderText[32768]; // THIS HAS CHAR 13/10 CONVERTED TO LINEFEED_CONTROL_CHAR
588         char        m_szDefaultCompVShaderText[32768]; // THIS HAS CHAR 13/10 CONVERTED TO LINEFEED_CONTROL_CHAR
589         char        m_szDefaultCompPShaderText[32768]; // THIS HAS CHAR 13/10 CONVERTED TO LINEFEED_CONTROL_CHAR
590         char        m_szBlurVS[32768];
591         char        m_szBlurPSX[32768];
592         char        m_szBlurPSY[32768];
593         //const char* GetDefaultWarpShadersText() { return m_szDefaultWarpShaderText; }
594         //const char* GetDefaultCompShadersText() { return m_szDefaultCompShaderText; }
595         void        GenWarpPShaderText(char *szShaderText, float decay, bool bWrap);
596         void        GenCompPShaderText(char *szShaderText, float brightness, float ve_alpha, float ve_zoom, int ve_orient, float hue_shader, bool bBrighten, bool bDarken, bool bSolarize, bool bInvert);
597 
598    //====[ 2. methods added: ]=====================================================================================
599 
600         void RefreshTab2(HWND hwnd);
601         void RenderFrame(int bRedraw);
602         void AlignWave(int nSamples);
603 
604         void        DrawTooltip(wchar_t* str, int xR, int yB);
605         void        RandomizeBlendPattern();
606         void        GenPlasma(int x0, int x1, int y0, int y1, float dt);
607         void        LoadPerFrameEvallibVars(CState* pState);
608         void        LoadCustomWavePerFrameEvallibVars(CState* pState, int i);
609         void        LoadCustomShapePerFrameEvallibVars(CState* pState, int i, int instance);
610     	void		WriteRealtimeConfig();	// called on Finish()
611 	    void		dumpmsg(wchar_t *s);
612 	    void		Randomize();
613 	    void		LoadRandomPreset(float fBlendTime);
614 	    void		LoadPreset(const wchar_t *szPresetFilename, float fBlendTime);
615         void        LoadPresetTick();
616         void        FindValidPresetDir();
617 	    //char*		GetConfigIniFile() { return m_szConfigIniFile; };
GetMsgIniFile()618 	    wchar_t*	GetMsgIniFile()    { return m_szMsgIniFile; };
GetPresetDir()619 	    wchar_t*    GetPresetDir()     { return m_szPresetDir; };
620 	    void		SavePresetAs(wchar_t *szNewFile);		// overwrites the file if it was already there.
621 	    void		DeletePresetFile(wchar_t *szDelFile);
622 	    void		RenamePresetFile(wchar_t *szOldFile, wchar_t *szNewFile);
623 	    void		SetCurrentPresetRating(float fNewRating);
624 	    void		SeekToPreset(wchar_t cStartChar);
625 	    bool		ReversePropagatePoint(float fx, float fy, float *fx2, float *fy2);
626 	    int 		HandleRegularKey(WPARAM wParam);
627 	    bool		OnResizeGraphicsWindow();
628 	    bool		OnResizeTextWindow();
629 	    //bool		InitFont();
630 	    //void		ToggleControlWindow();	// for Desktop Mode only
631 	    //void		DrawUI();
632 	    void		ClearGraphicsWindow();	// for windowed mode only
633         //bool    Update_Overlay();
634 	    //void		UpdatePlaylist();
635 	    void		LaunchCustomMessage(int nMsgNum);
636 	    void		ReadCustomMessages();
637 	    void		LaunchSongTitleAnim();
638 
639 	    bool		RenderStringToTitleTexture();
640 	    void		ShowSongTitleAnim(/*IDirect3DTexture9* lpRenderTarget,*/ int w, int h, float fProgress);
641 	    void		DrawWave(float *fL, float *fR);
642         void        DrawCustomWaves();
643         void        DrawCustomShapes();
644 	    void		DrawSprites();
645         void        ComputeGridAlphaValues();
646         //void        WarpedBlit();
647                      // note: 'bFlipAlpha' just flips the alpha blending in fixed-fn pipeline - not the values for culling tiles.
648 	    void		 WarpedBlit_Shaders  (int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling);
649         void		 WarpedBlit_NoShaders(int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling);
650 	    void		 ShowToUser_Shaders  (int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling);
651 	    void		 ShowToUser_NoShaders();
652         void        BlurPasses();
653         void        GetSafeBlurMinMax(CState* pState, float* blur_min, float* blur_max);
654 	    void		RunPerFrameEquations(int code);
655 	    void		DrawUserSprites();
656 	    void		MergeSortPresets(int left, int right);
657 	    void		BuildMenus();
658         void        SetMenusForPresetVersion(int WarpPSVersion, int CompPSVersion);
659 	    //void  ResetWindowSizeOnDisk();
660 	    bool		LaunchSprite(int nSpriteNum, int nSlot);
661 	    void		KillSprite(int iSlot);
662         void        DoCustomSoundAnalysis();
663         void        DrawMotionVectors();
664 
665         bool        LoadShaders(PShaderSet* sh, CState* pState, bool bTick);
666         void        UvToMathSpace(float u, float v, float* rad, float* ang);
667         void        ApplyShaderParams(CShaderParams* p, LPD3DXCONSTANTTABLE pCT, CState* pState);
668         void        RestoreShaderParams();
669         bool        AddNoiseTex(const wchar_t* szTexName, int size, int zoom_factor);
670         bool        AddNoiseVol(const wchar_t* szTexName, int size, int zoom_factor);
671 
672 
673     //====[ 3. virtual functions: ]===========================================================================
674 
675         virtual void OverrideDefaults();
676         virtual void MyPreInitialize();
677         virtual void MyReadConfig();
678         virtual void MyWriteConfig();
679         virtual int  AllocateMyNonDx9Stuff();
680         virtual void  CleanUpMyNonDx9Stuff();
681         virtual int  AllocateMyDX9Stuff();
682         virtual void  CleanUpMyDX9Stuff(int final_cleanup);
683         virtual void MyRenderFn(int redraw);
684         virtual void MyRenderUI(int *upper_left_corner_y, int *upper_right_corner_y, int *lower_left_corner_y, int *lower_right_corner_y, int xL, int xR);
685         virtual LRESULT MyWindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam);
686         virtual BOOL    MyConfigTabProc(int nPage, HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
687         virtual void OnAltK();
688 
689         //====[ 4. methods from base class: ]===========================================================================
690     /*
691         // 'GET' METHODS
692         // ------------------------------------------------------------
693         int     GetFrame();            // returns current frame # (starts at zero)
694         float   GetTime();             // returns current animation time (in seconds) (starts at zero) (updated once per frame)
695         float   GetFps();              // returns current estimate of framerate (frames per second)
696         eScrMode GetScreenMode();      // returns WINDOWED, FULLSCREEN, FAKE_FULLSCREEN, or NOT_YET_KNOWN (if called before or during OverrideDefaults()).
697         HWND    GetWinampWindow();     // returns handle to Winamp main window
698         HINSTANCE GetInstance();       // returns handle to the plugin DLL module; used for things like loading resources (dialogs, bitmaps, icons...) that are built into the plugin.
699         char*   GetPluginsDirPath();   // usually returns 'c:\\program files\\winamp\\plugins\\'
700         char*   GetConfigIniFile();    // usually returns 'c:\\program files\\winamp\\plugins\\something.ini' - filename is determined from identifiers in 'defines.h'
701 
702         // GET METHODS THAT ONLY WORK ONCE DIRECTX IS READY
703         // ------------------------------------------------------------
704         //  The following 'Get' methods are only available after DirectX has been initialized.
705         //  If you call these from OverrideDefaults, MyPreInitialize, or MyReadConfig,
706         //    they will fail and return NULL (zero).
707         // ------------------------------------------------------------
708         HWND         GetPluginWindow();    // returns handle to the plugin window.  NOT persistent; can change.
709         int          GetWidth();           // returns width of plugin window interior, in pixels.
710         int          GetHeight();          // returns height of plugin window interior, in pixels.
711         D3DFORMAT    GetBackBufFormat();   // returns the pixelformat of the back buffer (probably D3DFMT_R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5, D3DFMT_A1R5G5B5, D3DFMT_A4R4G4B4, D3DFMT_R3G3B2, D3DFMT_A8R3G3B2, D3DFMT_X4R4G4B4, or D3DFMT_UNKNOWN)
712         D3DFORMAT    GetBackBufZFormat();  // returns the pixelformat of the back buffer's Z buffer (probably D3DFMT_D16_LOCKABLE, D3DFMT_D32, D3DFMT_D15S1, D3DFMT_D24S8, D3DFMT_D16, D3DFMT_D24X8, D3DFMT_D24X4S4, or D3DFMT_UNKNOWN)
713         D3DCAPS8*    GetCaps();            // returns a pointer to the D3DCAPS8 structer for the device.  NOT persistent; can change.
714         LPDIRECT3DDEVICE8 GetDevice();     // returns a pointer to the DirectX 8 Device.  NOT persistent; can change.
715 
716         // FONTS & TEXT
717         // ------------------------------------------------------------
718         LPD3DXFONT   GetFont(eFontIndex idx);        // returns a handle to a D3DX font you can use to draw text on the screen
719         int          GetFontHeight(eFontIndex idx);  // returns the height of the font, in pixels
720 
721         // MISC
722         // ------------------------------------------------------------
723         td_soundinfo m_sound;                   // a structure always containing the most recent sound analysis information; defined in pluginshell.h.
724         void         SuggestHowToFreeSomeMem(); // gives the user a 'smart' messagebox that suggests how they can free up some video memory.
725     */
726     //=====================================================================================================================
727 };
728 
729 #endif