-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.cpp
9557 lines (8225 loc) · 344 KB
/
main.cpp
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This file is part of: Geiss screensaver and Winamp music visualization plug-in
// ___ ___ ___ ___ ___
// / __| __|_ _/ __/ __|
// | (_ | _| | |\__ \__ \
// \___|___|___|___/___/
// 3-Clause BSD License
//
// Copyright (c) 1998-2022 Ryan Geiss (@geissomatik)
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// GEISS 4.25 SCREENSAVER/PLUGIN - main.cpp
//
/*
BUILD BOTH with VS 2003 .NET, *release* builds.
PLUGIN:
-make sure you don't change code gen settings; you must use BLEND processor and 'Use Global Optimizations'==NO.
-otherwise, whenever any of the effect[]s are on, you'll see a flashing white dot in the upper-left pixel!
-(in VC++ 6.0, you get this always, no matter what your project settings/optimizations are. It's a compiler bug.)
SAVER:
-same notes about code gen settings.
UPDATING VERSION NUMBER:
-update CURRENT_GEISS_VERSION below
-update dialog title(s)
-update documentation/etc.
*/
// VS6 project settings:
// ---------------------
// libs: comctl32.lib ddraw.lib dsound.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dxguid.lib winmm.lib LIBCMT.LIB
// settings: C/C++ -> code generation -> calling convention is __stdcall.
// plugin:
// saver: dsound.lib winmm.lib LIBCMT.LIB
#define CURRENT_GEISS_VERSION 430
#ifndef PLUGIN
#ifndef SAVER
#error one of those must be defined by the project!!!
#endif
#endif
#define GRFX 1
/*
hard-to-test list
-----------------
check all video modes, mmx and non-mmx
check all color depths, and go up to 1024x768 full-screen
test in machine w/o sound card - okay
TEST IN MACHINE W/O CD-ROM DRIVE - okay
test in machine w/o directx - make sure the message pops up.
to update version number
------------------------
1. change titles of config & about dialogs (in resources)
2. change the #define of CURRENT_GEISS_VERSION
3. change it on geiss.html (the download link)
v4.00
-----
1. added passwords to screensaver
2. added level trigger to screensaver
3. fixed bug in level trigger for plugin
4. added new maps
5. added presets - use '[##' to load and ']##' to save
6. added a new waveform (oscilloscope X-Y mode)
7. added true Beat Detection... now, when a "beat" is detected in the music, the wave
brightness is more sharply linked to the beat volume, so the beats really come
out. When no beat is detected, you see flat color, to emphasize the waveform.
8. map now changes on beat (when beat detected)
9. further thinned out the DirectX code (QueryInterface).. could have fixed NT
DirectX problems. ?
10. NOTE: plugin now requires Winamp 2.10 for extended map keys (SHIFT-1 through
SHIFT-0) to function.
11. added dymanic map modification (linked to beats), and checkbox for default setting
of this feature, in config panel.
12. added info about FULLSCREEN/EXCLUSIVE failure for plugin: "don't use DirectSound
output from Winamp! Use waveout!"
13. added palette locking ('T')
14. added option to suppress ALL text messages (for nightclub-type displays)
15. added customizable messages... place them in GEISS.INI like so: (range 0-99)
[CUSTOM MESSAGES]
MESSAGE 1=Hello Dad - I'm in Jail!
MESSAGE 99= --- Welcome to Club Vinyl ---
16. hopefully fixed a bug where certain (bright) greyscale palettes would cause
the song title popups to become a solid white block when they faded out.
17. made an 'advanced options' panel to thin out the config panel... added a few
sliders too.
18. added dynamic map shifting - VERY, VERY COOL. Use the 'I' key to
turn it on and off. It only takes effect when a good beat is
detected. You can set thresholds for how sensitive it is from
the config panel.
19. spectrum analyzer: scaled bass by 0.2x, treble by 5x (linear interp)
20. fps is finally fixed
21. added rating system for the various maps
22. toned down the 'shifting' amount
23. removed call to getDXVersion(), because NT4/SP4 users were still getting the
'ordinal 6 not found' message at times. Hopefully, 99% of users will have
at least DirectX 3 or later, which should be all that is required now.
24. made the new 'beat detection' for wave brightness toggle-able from the main
config panel, since some people liked it more, and others preferred the old
mode.
25. config panel items now 'tab' in order.
26. fixed bug w/presets for mode 14 (on load, it always had a really huge rotation).
27. fixed bug w/presets where palette would load wrong 20% of the time
4.01
----
1. fixed bug w/config panel's "use shifting effect" slider
2. fixed bug w/saver where it sometimes failed to autostart
(WM_SYSKEYUP came in errantly on frame 0... now ignored)
3. plugin & saver now use GEISS.INI in your WINDOWS directory.
(plugin previously used your winamp/plugins directory, which
was sometimes impossible to detect)
4. removed old usage of 't' key from help screen (no longer shows song title)
5. set default gamma correction to 10%.
6. screensaver no longer exits on mouse movement
7. some effects can now be controlled by moving the mouse
4.20
----
1. shifting effect improvements... marked by 'new_tech'
2. hicolor waves now linked to freq... marked by 'fourier' and
'g_power_smoothed'
3. IMPORTANT: restore functionality of SPACE key:
case ' ':
FX_Loadimage("fx.tga");
--> g_hit/song_title stuff
4. aligned VS1, VS2, DATA_FX, DATA_FX2 to 8-byte boundaries.
5. MMX 32-bit proc_map() is now MEGA-FAST!!!!!!! (and one code
base serves all screen widths!)
6. MMX 32-bit proc_map() now also supports DITHER!!!!!!!!!!!
7. 8-bit Intel proc_map() loops are now aligned to 8 bytes.
(Cyrix loops already were).
8. 32-bit wave color is now 60% freq, 40% random.
9. 32-bit wave colors are now 35% brighter
10. changed the way x/y pos of messages/songtitles are positioned.
(more freedom now)
11. fixed modeprefs bug (screen 16 wasn't ever loading)
12+ BIG CHANGE: Changed map packet size from 6 to 8. No speed hit...
now massively strange maps are possible, however!
13. added new modes (17-25)
14. added new palette curve (#6) - darkish - allows for fire/sun palette
15. improved beat detection (for shifting)
16. shifting freq. default is now 33% of the time
4.21
----
1. removed bCyrix, CyrixInstead()
2. added map damping (0.5=soft music, 1.0=no damping=fast music)
based on the 'spectral variance' BUT it is disabled for now...
have to ask Dave Ulmer for permission to use it. To enable it,
make freq. analysis occur in 8-bit mode as well, (comment out
'if (iDispBits > 8)') and make 'suggested_damping' not always equal 1.0f.
To make this easy, just look for the two lines enclosed with
'----disable map damping----' and comment them out.
3. updated freq. ranges for truecolor sound-freq. correlation (too much red before)
4.22/4.23
---------
1. fixed bug that had disabled the FPS display; already released plugin v4.23.
2. removed initial_map_offset, and proc_map_asm() no longer multiplies the
offsets by 4 in 32-bit mode (it's stored in DATA_FX[] as offset*4).
3. removed slider2 (slider1 is now +/-)
4.24
----
1. updated web link (geisswerks.com) and e-mail address.
2. changed registry key from HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER
3. bug: maps 21+ weren't selectable; you can now access them directly.
-press '##' to select a mode directly (ex: mode 5 is entered as '05').
-press 'm##' to select a custom message
-press '[##' to load a preset
-press ']##' to save a preset
-you can press ESC at any time to cancel an in-progress command.
-pressing ESC again will exit.
4.24b
-----
1. used DEFAULT_CHARSET instead of ANSI_CHARSET in CreateFont() call,
so now, more foreign text (song titles) should display properly.
2. made some small changes to make exiting the plugin a bit safer
(changed the way winamp is minimized/restored; waited to destroy
plugin window until window class was unregistered; removed
a gratuitous 'setcursor' call at the very end.)
3. a while back I changed it so the wave colors went to the frequencies
in the music, instead of oscillating on their own, and a lot of people
have yelled at me over the years for not making this optional, so
here ya go - now it's an option - see the lower-left corner of the
config panel. =)
4. marked the 'frame idle delay' more clearly in the advanced config
panel: now says "Frame idle delay: (*crank this up if it runs
too fast!!*)".
5. in system settings/code generation, told it to use a multithreaded
DLL run-time library (was set to single-threaded [non-DLL]).
4.24c
-----
1. plug-in: recreated the Visual C++ project file for the plug-in, and in the
process, changed code gen. from 'multithreaded DLL' to just 'multithreaded'
(this was the default suggested by VC++ for a DLL, though it does differ
from what was in 4.24: 'single-threaded [non-DLL]'.) (plug-in was reported
to not work at all on many systems, saying it couldn't find 'msvcrtd.dll' -
the debug runtime library, which is a developers-only dll.)
2. screensaver: reverted code gen. from multithreaded DLL to single-threaded
non-DLL (plug-in [sic] was reported to not work at all on many systems,
saying it couldn't find 'msvcrtd.dll' - the debug runtime library, which
is a developers-only dll. Didn't hear any feedback on the screensaver,
but I'm assuming it would have had the same problem.)
3. fixed annoying pause when the screensaver was run with /p (preview mode)
by delay-loading dsound.lib and WINMM.LIB (the key). The delay loading
was set up by 1) adding DelayImp.lib to the project, and 2) specifying
/DELAYLOAD:XYZ.LIB in Project Settings -> Link -> Customize -> Project Options
for each lib file you want to delay-load.
4.25
----
1. there are no longer any restrictions on screen resolution. (Before, we had to
write a separate loop for each possible res, because we were out of registers
and couldn't hold that info in a register. Now, the code just modifies itself
to poke in the right variable into an immediate value in the code itself.)
2. the default resolution is now whatever your desktop is at.
3. when the framerate exceeds 30 fps, we now slow down the motion (per frame)
so that it appears to be the same rate of motion as if you were running at 30
fps - just smoother.
4. the overall image darkening-over-time rate (the sum of the 4 weights for bilinear
interpolation) is now tuned based on the # of pixels. At high resolutions,
there is very little loss (weightsum == 256), while at 800x600, the weights
total about 253, and at low resolutions (320x240), it goes down as low as 251.
5. 'frames_til_auto_switch' is now actually adjusted to the current framerate, so,
set its value as if the plugin/screensaver were going to be running at 30 fps,
and it will do the right thing. (This way, you don't have to mess with that
value to correct for whatever fps you're getting.)
6. updated the waveforms to draw properly at higher resolutions, by smoothly upsampling
(to 2X or 4X the # of dots). This also keeps them nice and mostly-solid.
7. made a bunch of hte other little special effects work nicely at higher resolutions
(that usually means fatter dots), for both 8-bit and >8-bit color.
8. wow - fixed a bug in the screensaver version that proves I hardly knew what a
thread *was* back in 1998. Oops. Keypresses are actually SAFE now!
9. also cranked up default wave brightness/scaling for the screensaver.
4.26
----
-added 'S'huffle and 'R'epeat toggle keys to plugin version.
-*plugin* no longer flashes the help message at you when you move the mouse.
-made waveform colors richer in >8bpp modes
-'shifting' effect now runs correctly at >30 fps. (it got a bit spastic before.)
-default 'frames_til_auto_switch' is a little longer now.
-fixed a bug in 8-bit modes where last ~256 pixels on last scanline weren't updating.
-when you set it to use 100% of the screen, it now uses a bit more (before it was actually like 96%;
now it's about 98%. My sincere apologies, but I just don't have time to revamp it all to use 100%...
trying to do what I can in limited time...)
-we no longer call DrawText() on the front buffer. (Embarrassing... I know... I was
*very* new to programming and graphics back in '98!) This was causing problems on
some machines whenever you tried to draw text.
-increased the chromatic dispersion on the 'bar' effect ('u' key), and slowed it down a bit,
for 32-bit modes.
-worked on the chases a bit - slowed them down in high-fps situations, and they new draw more dots
when the res. is high (proportional to the resolution), so the overall feel is the same.
-default mode preferences (ratings) now biased so that modes 5-9 show up more often (4 stars)
than the others. Mode 15 shows up less often (2 stars). (Defaults only)
-in mode 6, you now get swirlies more often.
-worked around a compiler bug that was sometimes putting a flashing white dot in the upper-left corner.
(had to move from VC++6 to VS2003 .NET; had to make sure processor was set to 'Blend' and Global Optimizations
were off.)
-disabled all message processing that might interfere with power functions (monitor turning off,
sleep, etc).
-some of the more colorful effects now show up a little more often, in hi-color modes; and the grid
effect now shows up ~1% more often, in all modes.
-fixed aspect ratio of 'grid' effect
-changed text color to a more pleasant yellow
-mouse cursor is now hidden on every frame (...before, if you hit a winamp play/pause/etc key, the cursor
would show, and you'd have to wiggle the mouse to make it go away).
-moved the 'A' dots a little further away from the center of the screen when at larger resolutions.
-if you try to run the plugin without music, it now gives you a messagebox telling you why it's not going
to work (instead of just leaving you with a black screen, wondering why nothing is happening).
4.27
----
-added support for multiple monitors!
-select which monitor from the config panel
-geiss will run on that monitor, and you can work freely in the other(s)
-removed the 'minimize winamp' option from plugin (not necessary)
-added instructions to the config panel on how to run with live input, as well as
a button to run 'sndvol32 /r' for you.
-default video mode is now 32-bit (was 8-bit), and the 32-bit modes now say "[recommended]" next to them,
instead of the 8-bit ones.
-we now clear the edges on one of the main buffers [front or back - it will alternate]
every 11 frames, so if you're working on another monitor and something accidentally paints
over part of the visualizer window, it'll be gone within a second or less.
-fixed bug where waveform #1, with really loud music, could sometimes draw pixels just beyond the
bottom line of the screen, which would cause them to bleed into the image [at least, in modes such as mode 6].
-duration (and frequency, if randomization is on) of song title popups
is now sync'd to the framerate.
-fixed bug where pausing the music would sometimes cause song title popup
to appear with " - Winamp [Paused]" at the end of the song title.
-tuned some spatial and temporal settings on the Grid effect so that it looks nicer at
fast framerates and/or higher resolutions. (Looks the same at old/slow/low framerates/resolutions.)
-when you start the plugin, or when you start the config panel, or (when on the config panel)
select a new monitor while it is up, it now auto-finds the closest match to the previously-selected
resolution and color depth, if the exact match can not be found. (Rather than just giving you
an error and quitting, in the case of running the plugin; or selecting some lazy default,
for the config panel.)
4.30
----------
TODO:
-UNIFNISHED: see NEW_COLORS_430 - great!!!
-decrease rate of map changes? it's great to sit for minutes at a time...
-also, crank down # effects in high color modes - better with just waves...
4.29
----------
-Video mode list is now sorted.
-Default video mode selection now matches whatever your primary monitor is set to.
-On advanced settings panel, changed 'frames between mode switches' to
'seconds between mode switches', and made the new range from 1..60 seconds.
Also fixed the saving of this value (in 4.28, there was a bug, and
it wouldn't save the value if you changed it).
4.28
----------
-In VS2003 project settings, switched from multi-threaded DLL
to multi-threaded (oops)... was causing an unnecessary MSVCR71.DLL
dependency, which some systems do not have.
DDraw documentation: http://msdn.microsoft.com/en-us/library/aa917130.aspx
NEXT REV:
// silly: screensaver, in multimon config, only affects the SELECTED monitor...
// if they try to run @ a res that is no longer supported, it will give them an error
// ( -> and probably not the best error message)
// ALT+TAB is janky; if you click it once quickly, it doesn't really exit.
// If you hold ALT and keep tabbing, it minimizes the plugin.
// ALT+TABbing back will restore it.
// (NOTE: only the monitors that are part of windows desktop show up in the list.)
* -play around with "COFFEE FILTER"
-latest msg from work:
-text can start/stop just fine, EXCEPT for the help *screen*, which, when it goes away, turns the screen black. Going to a new map still fixes it. Note that other single-line text messages can come up and go away without a problem; so there is something special about the help screen (10 lines). Are we not releasing the DC or something?
-VERY INTERESTING: the help-msg-going-away bug only happens in 8-bit color! In 32-bit modes, it comes and goes without a problem. So, is it just a driver bug, or maybe a palette thing?
to do:
-why does plugin make desktop icons flash on exit? (win2k)
-make beat det. focus on low-range frequencies (bass!), not the composite volume.
-beat det. still sucks (especially w/high fps)
-random 'custom message' popups
-*specify* which monitor to run on
-MTV-style song info + time @ bottom-left corner?
-option to turn off freq-color sync. in hicolor modes
-change the font/size on custom messages/song titles
-remap keys; [ and ] cause trouble on German keyboards.
-"can't set 0x0x0 video mode" bug after 1st run...
-LOTS of reports, just search for 0x0x0
-12/24/99: Roland McIntosh
-12/31/99: Tha Shaydiest
-lot of people still complaining that it stops after each song.
future work:
-make it so you can have a preset generate in the background & pop up when you hit
some special key (---> concerts!)
0. optimize 32-bit mmx loop (reorder instructions...?)
1. restore dither to 32-bit mmx loop
2. createDIBitmap from the VS, then use DC to blit to video.
this will enable DMA! However, then have to worry about
brightening (x2) the 32-bit images... =(
3. make it run in a window (easy once (1) is complete)
4. make it run in desktop background! (GetDesktopWindow())
-presets are in;
1. need a 'random' mode
2. save mode #6 swirl positions, types, etc.
-need a slider-bar for freq. of random custom message popups
Final big tasks
---------------
I. add multimon support.
controling the colors by pressing keys(R,G,B,+/-)
no hanging screen by the start of a new track
no hanging screen if a number or n is pressed
no unlocking when number or n id pressed
no change of wave/effects/color when a number is pressed
additional keyboard-LED spectrum
nice looking text(position selection, antialiasing, maybe blurring)
self defined keys
start presets to songs(+keys to save/load presets)
saving favorite combinations (10 or so)
-NT4 still hates directsound
-sound bug: sometimes Sound is initially disabled on saver (on certain systems).
-some guy is going to send debug file - should say why sound is initially off.
-(w won't work because 'o' needs pressed first)
->made special version has items marked with 'tempsound' for extra debug info.
Sent to Piotr cxvsdfas... waiting for debug file from him.
*/
//int weightsum = 253;
// items commented out:
// #define STRICT
//#define STRICT
#define WIN32_LEAN_AND_MEAN
//#include <afx.h> // for CString
//#if PLUGIN
//#include <afxwin.h> // for drawing text to virtual screen (CDC objects)
//#endif
#include <windows.h>
#include <regstr.h>
#include <stdlib.h>
#pragma hdrstop
#include "resource.h"
#include <stdio.h> // for sprintf() for fps display
#include <stdarg.h>
#if SAVER
#include <mmsystem.h> // for mci/cd stuff
#endif
//#if SAVER
//#define _MT // for multithreading
//#include <process.h> // for multithreading
//#endif
//for Geiss:
#if SAVER
#define NAME "Geiss screensaver"
#define TITLE "Geiss screensaver"
#else
#define NAME "Geiss for Winamp"
//#define NAME2 "Geiss Subwindow"
#define TITLE "Geiss for Winamp"
#endif
#include <windowsx.h>
#include <ddraw.h>
//#include <stdarg.h> //RECENT
#include <time.h>
#include <math.h>
#if SAVER
#include <mmreg.h>
#include <dsound.h>
//#include "outsound.h"
#endif
#include <commctrl.h>
#include <shellapi.h>
#include "helper.h" //for GetNumCores
int g_nCores = 1;
int g_desktop_w = 800;
int g_desktop_h = 600;
int g_desktop_bpp = 8;
int g_desktop_hz = 60;
float AdjustRateToFPS(float per_frame_decay_rate_at_fps1, float fps1, float actual_fps)
{
// returns the equivalent per-frame decay rate at actual_fps
// basically, do all your testing at fps1 and get a good decay rate;
// then, in the real application, adjust that rate by the actual fps each time you use it.
float per_second_decay_rate_at_fps1 = powf(per_frame_decay_rate_at_fps1, fps1);
float per_frame_decay_rate_at_fps2 = powf(per_second_decay_rate_at_fps1, 1.0f/actual_fps);
return per_frame_decay_rate_at_fps2;
}
void GetDesktopDisplayMode()
{
DEVMODE dm;
dm.dmSize = sizeof(dm);
dm.dmDriverExtra = 0;
if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
{
g_desktop_w = dm.dmPelsWidth;
g_desktop_h = dm.dmPelsHeight;
g_desktop_bpp = dm.dmBitsPerPel;//(dm.dmBitsPerPel==16) ? D3DFMT_R5G6B5 : D3DFMT_X8R8G8B8;
g_desktop_hz = dm.dmDisplayFrequency;
}
}
#if PLUGIN
/*
#define NUM_BLOBS 8
float blob_x[NUM_BLOBS];
float blob_y[NUM_BLOBS];
float blob_str[NUM_BLOBS];
float blob_str2[NUM_BLOBS];
int matrix[40][30];
*/
enum visModeEnum { spectrum, wave };
visModeEnum visMode;
//RECT g_WinampWindowRect;
#define APPREGPATH "SOFTWARE\\geissplugin"
#include "vis.h"
struct winampVisModule *g_this_mod = NULL;
HWND this_mod_hwndParent = NULL;
HINSTANCE this_mod_hDllInstance = NULL;
void ReadConfigRegistry();
void WriteConfigRegistry();
BOOL CALLBACK ConfigDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK Config2DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
// plug-in functions
void config(struct winampVisModule *this_mod); // configuration dialog
int init(struct winampVisModule *this_mod); // initialization for module
#endif
int render1(struct winampVisModule *this_mod); // rendering for module 1
#ifdef PLUGIN
void quit(struct winampVisModule *this_mod); // deinitialization for module
// configuration declarations
int param_1=0, param_2=50; // param_1: CRUIZIN (0/1). param_2: free
void config_read(struct winampVisModule *this_mod); // reads the configuration
void config_write(struct winampVisModule *this_mod); // writes the configuration
//void config_getinifn(struct winampVisModule *this_mod, char *ini_file); // makes the .ini file filename
// returns a winampVisModule when requested. Used in hdr, below
winampVisModule *getModule(int which);
// our window procedure
//LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
HWND hMainWnd; // main window handle
//HWND hSecondWnd; // handle to keypress-processing window
// Double buffering data
//HDC memDC; // memory device context
//HBITMAP memBM, // memory bitmap (for memDC)
// oldBM; // old bitmap (from memDC)
// Module header, includes version, description, and address of the module retriever function
winampVisHeader hdr = { VIS_HDRVER, NAME, getModule };
int PreReadDelayFromRegistry();
// first module (oscilliscope)
winampVisModule mod1 =
{
NAME,
NULL, // hwndParent
NULL, // hDllInstance
0, // sRate
0, // nCh
0,// 18, // latencyMS... the higher this number ,the earlier the graphics react.
// 70 seems to match perfectly.
// 0 will make the graphics a little sluggish.
PreReadDelayFromRegistry(), //0,//18, // delayMS
2, // spectrumNch
2, // waveformNch
{ 0, }, // spectrumData
{ 0, }, // waveformData
config,
init,
render1,
quit
};
// this is the only exported symbol. returns our main header.
// if you are compiling C++, the extern "C" { is necessary, so we just #ifdef it
//#ifdef __cplusplus
extern "C" {
//#endif
__declspec( dllexport ) winampVisHeader *winampVisGetHeader()
{
//MessageBox(NULL, "TEXT", "CAPTION", MB_OK);
return &hdr;
}
//#ifdef __cplusplus
}
//#endif
#else //---------------- SCREENSAVER-SPECIFIC---------------------
#define APPREGPATH "SOFTWARE\\geissscreensaver"
#endif
//#define TIMER_ID 1
//#define TIMER_RATE 200 // # of ms; was 500
//#define FX_YCUT 15 //skip this many vert. lines in calculation
//#define FX_YCUT_HIDE 20 //skip this many vert. lines when SHOWING (=FX_YCUT+7)
/*-------------------------------------------------*/
bool CheckMMXTechnology();
//bool CyrixInstead();
#if SAVER
DSCBUFFERDESC dscbd;
LPDIRECTSOUNDCAPTURE pDSC;
LPDIRECTSOUNDCAPTUREBUFFER pDSCB;
WAVEFORMATEX wfx =
{ WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0 };
int g_DDRAW_ERRORS = 0;
bool g_DDRAW_FRAGGED_req = false;
bool g_DDRAW_FRAGGED_ack = false;
HWND hSaverMainWindow;
// wFormatTag, nChannels, nSamplesPerSec, mAvgBytesPerSec = nSamplesPerSec*nBlockAlign,
// nBlockAlign = nChannels*wBitsPerSample/8, wBitsPerSample, cbSize
#endif
//DDSURFACEDESC g_ddsd;
char g_song_title[256]; // also used to display custom messages
//#define g_song_tooltip_frames 20
int g_song_tooltip_frames = 20;
HFONT g_title_font = NULL;
int g_song_title_y;
int g_song_title_x;
int g_title_R;// = 190 + rand() % 50;
int g_title_G;// = 190 + rand() % 50;
int g_title_B;// = 190 + rand() % 50;
bool g_LastMessageWasCustom = false;
#if PLUGIN
BOOL g_bDisableSongTitlePopups = false;
BOOL g_WinampMinimizedByHand = false;
BOOL g_bMinimizeWinamp = false;//true;
HCURSOR hOldCursor = NULL;
WINDOWPLACEMENT wp_winamp;
int g_random_songtitle_freq = 0;
#endif
int last_frame_v = 0; // for sound level-triggering
int last_frame_slope = 0;
#if SAVER
BOOL g_bAutostartCD = false;
BOOL g_bDisableCdControls = false;
#endif
///int wave_brightness = 0;
#define NUM_FREQS 3
#define FREQ_SAMPLES 192
__int16 g_SoundBuffer[16384];
float g_phase_inc[NUM_FREQS];
float g_fSoundBuffer[16384];
LPGUID g_lpGuid;
BOOL SoundEnabled=TRUE;
BOOL SoundReady=FALSE;
BOOL SoundActive=FALSE;
BOOL SoundEmpty=FALSE;
int oldSoundBufPos=0;
int oldSoundBufNum=0;
//BOOL fOnWin95;
char szSoundDrivers[10][1024];
int iNumSoundDrivers = 0;
int iCurSoundDriver = 0;
int frames_since_silence = 0;
float avg_peaks = 100;
float current_vol = 0;
#define PAST_VOL_N 120
float past_vol[PAST_VOL_N];
int past_vol_pos = 0;
float avg_vol = 1.0;
float avg_vol_wide = 1.0;
float avg_vol_narrow = 1.0;
unsigned long iVolumeSum = 1;
float debug_param = 1.0;
float damped_std_dev = 5;
bool bBeatMode = false;
bool bBigBeat = false;
float fBigBeatThreshold = 1.10;
float rand_array[2345];
float sqrt_tab[21][21];
int rand_array_pos = 0;
int iTrack = 0; // current CD track
int iNumTracks = 0; // # cd tracks
enum DISC_STATES { STOPPED, PLAYING, PAUSED, UNKNOWN, BUSY };
DISC_STATES eDiscState = UNKNOWN;
//BUSY means that Windows CD player is running & we can't control the cd.
//when BUSY is set, g_bDisableCdControls will also get set (for that execution)
// user volume control
int volpos = 10; // from 0 to 20... 10 is middle.
float volscale = 0.20;//1.0; // designed for Windows' line-in to be at 1/2 position.
int slider1 = 0;
int g_FramesSinceShift = 0;
bool g_bSlideShift = true;
int g_SlideShiftFreq = 33; // 33% of the time
int g_SlideShiftMinFrames = 5; // min. no. of frames between shifts
// new shifting technique...
float g_ShiftMaxVol = 0;
#define FOURIER_DETAIL 24
float g_power[FOURIER_DETAIL];
float g_power_smoothed[FOURIER_DETAIL];
int g_hit = 0;
int AUTOMIN = 0;
//BOOL bScrollMap = false;
//BOOL new_bScrollMap = false;
float gF[6];
#define SCATTERVALS 226
float fScatter[SCATTERVALS];
int g_iScatterPos = 0;
// globals for bkg map generation:
float f1, f2, f3, f4;
float old_f1, old_f2, old_f3, old_f4;
//unsigned char p1, p2, p3, p4;
float cx[10], cy[10], ci[10], cj[10], cr[10], cr_inv[10];
int ctype[10];
int R_offset, old_R_offset;
int y_map_pos = -1;
float max_rad_inv;// = 1.0/sqrtf(FXW*FXW+FXH*FXH);
float rmult;// = 640.0/(float)FXW;
float rdiv;// = 1.0/rmult;
float protective_factor;// = (FXW > 640) ? 640.0/(float)FXW : 1;
//----------------------------------------------------
#define num_vid_modes 11 //12
int VidMode = -1;
BOOL VidModeAutoPicked = false;
int iNumVidModes = 0; // set by DDraw's enumeration
int iDispBits=32;
//BOOL bModeX=false;
#if SAVER
long FXW = -1; // to set default pick, go to EnumModesCallback()
long FXH = -1; // to set default pick, go to EnumModesCallback()
int iVSizePercent = 100;//45;
#endif
#if PLUGIN
long FXW = -1;//320; // to set default pick, go to EnumModesCallback()
long FXH = -1;//240; // to set default pick, go to EnumModesCallback()
int iVSizePercent = 100;//35;//100;
#endif
typedef struct
{
int lo_band;
int hi_band;
bool bFXPalette;
int iFXPaletteNum;
int c1, c2, c3;
} pal_td;
pal_td old_palette;
typedef struct
{
int iMode;
int iParam1;
int iParam2;
int iParam3;
float fParam1;
float fParam2;
float fParam3;
//int palType; // 0
} preset;
preset g_Preset[10];
typedef struct
{
int iDispBits;
int FXW;
int FXH;
BOOL VIDEO_CARD_FUCKED;
//BOOL bModeX;
char name[64];
} VidModeInfo;
#define MAX_VID_MODES 512
VidModeInfo VidList[MAX_VID_MODES];
typedef struct
{
GUID guid;
char szDesc[256];
char szName[256];
} DDrawDeviceInfo;
#define MAX_DEVICES 16
DDrawDeviceInfo g_device[MAX_DEVICES];
int g_nDevices = 0;
GUID g_DDrawDeviceGUID;
enum modesel_state { NONE_SEL, MODE_SEL_1 };
enum preset_state { NONE, LOAD_1, LOAD_2, SAVE_1, SAVE_2 };
modesel_state eModeSelState = { NONE_SEL };
preset_state ePresetState = { NONE };
preset_state eCustomMsgState = { NONE };
int iModeSelection = 0;
int iPresetNum = 0;
int iCustomMsgNum = 0;
//int ThreadNr = 0;
BOOL g_rush_map = false;
BOOL g_QuitASAP = false;
BOOL g_GeissProcFinished = false;
BOOL g_bFirstRun = false;
BOOL g_bDumpFileCleared = false;
BOOL g_bDebugMode = false;
BOOL g_bSuppressHelpMsg = false;
BOOL g_bSuppressAllMsg = false;
BOOL g_DisclaimerAgreed = true;
BOOL g_ConfigAccepted = false;
BOOL g_Capturing = false;
BOOL g_bUseBeatDetection = true;
BOOL g_bSyncColorToSound = false;
bool g_bLoadPreset = false;
int g_iPresetNum = -1;
/*-------------------------------------------------*/
//int iBands = 4; // 0=always...5=never
int iRegistryDelay = 0; // milliseconds per frame
bool bMMX;
//bool bCyrix;
bool bBypassAssembly = FALSE;
bool bExitOnMouse = FALSE;
bool bLocked = FALSE;
bool bPalLocked = FALSE;
//dither//BOOL bDither = TRUE;
//dither//BOOL bRandomDither = FALSE;
//dither//BOOL bMEGARandomDither = FALSE;
int waveform, new_waveform;
int last_mouse_x = -1;
int last_mouse_y = -1;
#define NUM_WAVES 6
//void RestoreCtrlAlt(void);
void __cdecl RestoreCtrlAlt(void);
void GetWaveData();
void RenderDots(unsigned char *VS1);
void RenderWave(unsigned char *VS1);
#define WAVE_5_BLEND_RANGE 50
const int MINBUFSIZE = ((314+WAVE_5_BLEND_RANGE)*2 + 20);
long FX_YCUT =90; //skip this many vert. lines in calculation
long FX_YCUT_HIDE =92; //= FX_YCUT + 2;
long FX_YCUT_NUM_LINES =FXW*(FXH-FX_YCUT*2);
long FX_YCUT_xFXW_x8 =FX_YCUT*FXW*8;
long FX_YCUT_xFXW =FX_YCUT*FXW;
long FX_YCUT_HIDE_xFXW =FX_YCUT_HIDE*FXW;
long FXW_x_FXH =FXW*FXH;
long BUFSIZE =max(FXW*2, MINBUFSIZE);
//int FX_YCUT_HIDE_xLINESIZE = FX_YCUT_HIDE*1280;
int modeprefs[128]; // values range from 0 to 5 stars; default is 3.
int modeprefs_total = -1; // ---REMEMBER, RANGE is [1,NUM_MODES], INCLUSIVE!---
float fps = 40.0f;
float fps_at_last_mode_switch = 40.0f;
//float fps_core = 30;
float time_array[30];
int time_array_pos = 0;
bool time_array_ready = false;
clock_t start_clock = 0; //DEPRECATED
clock_t clock_debt = 0; //DEPRECATED
clock_t core_clock_time = 0; //DEPRECATED
clock_t blit_clock_time = 0; //DEPRECATED
clock_t flip_clock_time = 0; //DEPRECATED
//clock_t temp_clock;//, start_clock = -1;
char inifile[512];
char szDEBUG[512];
char szFPS[] = "abcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijk";
#if SAVER
char szMCM[] = " [click mouse button to exit - press h for help] ";
#endif
#if PLUGIN
char szMCM[] = " [press ESC to exit - press h for help] ";
#endif
char szLM[] = " - screen is LOCKED - ";
char szULM[] = " - screen is unlocked - ";