home *** CD-ROM | disk | FTP | other *** search
/ Resource for Source: C/C++ / Resource for Source - C-C++.iso / misc_src / manyth31 / manythng.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-11-01  |  99.0 KB  |  3,069 lines

  1. VERSION 2.00
  2. Begin Form ManyThings 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   0  'None
  5.    ClientHeight    =   4605
  6.    ClientLeft      =   1845
  7.    ClientTop       =   1710
  8.    ClientWidth     =   7995
  9.    ControlBox      =   0   'False
  10.    Height          =   5010
  11.    Icon            =   MANYTHNG.FRX:0000
  12.    Left            =   1785
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   307
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   533
  17.    Top             =   1365
  18.    Width           =   8115
  19.    Begin Timer Tick 
  20.       Enabled         =   0   'False
  21.       Interval        =   50
  22.       Left            =   10
  23.       Top             =   10
  24.    End
  25.    Begin Label PasswordLabel 
  26.       Alignment       =   1  'Right Justify
  27.       BackColor       =   &H00FFFFFF&
  28.       BorderStyle     =   1  'Fixed Single
  29.       Caption         =   "Need Password    "
  30.       FontBold        =   -1  'True
  31.       FontItalic      =   0   'False
  32.       FontName        =   "Times New Roman"
  33.       FontSize        =   24.75
  34.       FontStrikethru  =   0   'False
  35.       FontUnderline   =   0   'False
  36.       Height          =   690
  37.       Left            =   2430
  38.       TabIndex        =   0
  39.       Top             =   3510
  40.       Visible         =   0   'False
  41.       Width           =   4470
  42.    End
  43. ' BackGround -- this form expands to fill the whole
  44. '   screen and is used as the back drop for all the
  45. '   drawing
  46. Option Explicit
  47. ' variables declared here
  48. Dim MouseX, MouseY ' Last position of the mouse moves
  49. Dim LastX As Integer, LastY As Integer
  50. 'Dim conv2x As Single, conv2y As Single
  51. Dim LastTime As Long
  52. Dim CurrentTime As Long
  53. Dim LinkTime As Long
  54. Dim PlotType As Integer
  55. Dim PlotInit As Integer
  56. Dim PlotEnd As Integer
  57. Dim RepeatIndex As Integer
  58. Dim Pointer As Integer
  59. Dim Mirror As Integer
  60. Dim RunMode As Integer
  61. Dim x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer
  62. Dim vx1 As Single, vy1 As Single, vx2 As Single, vy2 As Single
  63. Dim ax1 As Single, ax2 As Single, ay1 As Single, ay2 As Single
  64. Dim l As Long
  65. Dim m As Long
  66. Dim MaxSpeedX As Integer, MaxSpeedY As Integer
  67. Dim TimeInterval As Long
  68. Dim MaxTime As Long
  69. Dim Repeats As Integer
  70. Dim i As Integer
  71. Dim BoxHeight As Integer, BoxWidth As Integer
  72. Dim DC As Integer
  73. Dim Pattern As Long, Locked As Integer
  74. Dim Direction As Integer
  75. Dim Number As Integer
  76. Dim PicWidth As Integer, PicHeight As Integer
  77. Dim PriorityBreakPoints() As Single
  78. Dim Priorities() As Integer
  79. Dim TotalPriority As Single
  80. Dim MaxPlotType As Integer
  81. ' values for GetBrightNonGray:
  82. ' minimum magnitude squared of colors
  83. Const MinColor = 3000' was 10000
  84. ' minimum difference between colors
  85. Const MinDiff = 30
  86. 'Allocate Memory
  87. Dim x1a() As Integer
  88. Dim x2a() As Integer
  89. Dim y1a() As Integer
  90. Dim y2a() As Integer
  91. Dim x1da() As Integer
  92. Dim x2da() As Integer
  93. Dim y1da() As Integer
  94. Dim y2da() As Integer
  95. Dim x1sa() As Single
  96. Dim x2sa() As Single
  97. Dim y1sa() As Single
  98. Dim y2sa() As Single
  99. Dim vx1sa() As Single
  100. Dim vx2sa() As Single
  101. Dim vy1sa() As Single
  102. Dim vy2sa() As Single
  103. Dim ax1sa() As Single
  104. Dim ax2sa() As Single
  105. Dim ay1sa() As Single
  106. Dim ay2sa() As Single
  107. Dim Colors() As Long
  108. Dim DataPts() As Integer
  109. 'for filled polygons
  110. Dim Points() As POINTAPI
  111. Const PI = 3.14159265358979
  112. Const Sin45 = .707106781186547
  113. Const Cos45 = Sin45
  114. Const Sin22_5 = .38268343236509
  115. Const Cos22_5 = .923879532511287
  116. Const Sin11_25 = .195090322016128
  117. Const Cos11_25 = .98078528040323
  118. Const HighMirror = 10
  119. Function CheckIfValidSaver (NeedsMuchMemory As Integer) As Integer
  120.   'when in low memory mode the saver only runs the modules
  121.   'that draw on the screen, not those that manipulate
  122.   'bitmaps, savers that use more memory will pass
  123.   'NeedsMuchMemory as a non-zero value
  124.   If LowMemoryFlag = 0 Then 'if not low memory mode then done
  125.     CheckIfValidSaver = 1
  126.   Else
  127.     If NeedsMuchMemory <> 0 Then
  128.       LogFile ("Saver not valid in low memory: " + Str$(PlotType)), 0
  129.       NextSelection
  130.       CheckIfValidSaver = 0
  131.     Else
  132.       CheckIfValidSaver = 1
  133.     End If
  134.   End If
  135.   If Priorities(PlotType) = 0 Then
  136.     LogFile ("Saver disabled: " + Str$(PlotType)), 0
  137.     NextSelection
  138.     CheckIfValidSaver = 0
  139.   End If
  140. End Function
  141. Sub Circles ()
  142.   ' have a single elipse trace across the
  143.   ' screen with multiple previous copies following
  144.   ' it
  145.   Dim xRadius As Integer, yRadius As Integer
  146.   Dim HighMirror As Integer
  147.   ' if first time then initialize
  148.   If PlotInit = False Then
  149.    'see if we need to reset changes made from previous init
  150.    If PlotEnd = False Then
  151.     'check if saver is permitted to run
  152.     If CheckIfValidSaver(0) = 0 Then
  153.       Exit Sub
  154.     End If
  155.     PlotInit = True
  156.     Cls
  157.     ForeColor = QBColor(15)
  158.     'Set array size and clear the elements
  159.     ReDim x1a(MaxLines) As Integer
  160.     ReDim x2a(MaxLines) As Integer
  161.     ReDim y1a(MaxLines) As Integer
  162.     ReDim y2a(MaxLines) As Integer
  163.     Pointer = 1     ' start with array element 1
  164.     ' set index to count number of times to repeat color
  165.     '   to past maxvalue so that it will be recalculated
  166.     RepeatIndex = MaxLines + 1
  167.     'determine initial position of line
  168.     x1 = Rnd * ScaleWidth
  169.     x2 = Rnd * ScaleWidth
  170.     y1 = Rnd * ScaleHeight
  171.     y2 = Rnd * ScaleHeight
  172.     'set initial velocity
  173.     vx1 = 0
  174.     vx2 = 0
  175.     vy1 = 0
  176.     vy2 = 0
  177.     'set initial acceleration
  178.     ax1 = 0
  179.     ax2 = 0
  180.     ay1 = 0
  181.     ay2 = 0
  182.     'find background color
  183.     m = QBColor(0)
  184.     'Calculate velocity limits
  185.     MaxSpeedX = ScaleWidth * 15! / 800
  186.     MaxSpeedY = ScaleWidth * 15! / 600
  187.     'select mirroring method
  188.     HighMirror = 5
  189.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  190.   Else 'reset changes done by previous init
  191.     ClearScreen
  192.     'zero array sizes
  193.     ReDim x1a(0) As Integer
  194.     ReDim x2a(0) As Integer
  195.     ReDim y1a(0) As Integer
  196.     ReDim y2a(0) As Integer
  197.   End If
  198.   Else  ' put run code here
  199.     Tick.Enabled = False' disable timer until circles completed
  200.     ' check if time to get a new color
  201.     If RepeatIndex > RepeatCount Then
  202.     'set color
  203.     l = GetBrightNonGray()
  204.     RepeatIndex = 1
  205.     Else
  206.     RepeatIndex = RepeatIndex + 1
  207.     End If
  208.     'Delete original circle
  209.     xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  210.     yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  211.     If xRadius <> 0 Then
  212.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  213.     End If
  214.     DoEvents
  215.     Select Case Mirror
  216.     Case 1: 'mirror on x and y axis
  217.         
  218.         'Delete original circle mirrored on Y axis
  219.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  220.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  221.         If xRadius <> 0 Then
  222.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  223.         End If
  224.         DoEvents
  225.         'Delete original circle mirrored on X axis
  226.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  227.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  228.         If xRadius <> 0 Then
  229.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  230.         End If
  231.         DoEvents
  232.         'Delete original circle mirrored on origin
  233.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  234.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  235.         If xRadius <> 0 Then
  236.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  237.         End If
  238.         DoEvents
  239.     Case 2: 'mirror on Y axis
  240.         
  241.         'Delete original circle mirrored on Y axis
  242.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  243.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  244.         If xRadius <> 0 Then
  245.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  246.         End If
  247.         DoEvents
  248.     Case 3: 'mirror around center point
  249.         'Delete original circle mirrored on origin
  250.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  251.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  252.         If xRadius <> 0 Then
  253.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  254.         End If
  255.         DoEvents
  256.     Case Else: ' otherwise ignore (i.e. no mirror)
  257.     End Select
  258.     'Save New Circle
  259.     x1a(Pointer) = x1
  260.     x2a(Pointer) = x2
  261.     y1a(Pointer) = y1
  262.     y2a(Pointer) = y2
  263.     Select Case Mirror
  264.     Case 1: 'mirror on x and y axis
  265.         
  266.         'Delete original circle mirrored on Y axis
  267.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  268.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  269.         If xRadius <> 0 Then
  270.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  271.         End If
  272.         DoEvents
  273.         'Delete original circle mirrored on X axis
  274.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  275.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  276.         If xRadius <> 0 Then
  277.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  278.         End If
  279.         DoEvents
  280.         'Delete original circle mirrored on origin
  281.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  282.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  283.         If xRadius <> 0 Then
  284.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  285.         End If
  286.     Case 2: 'mirror on Y axis
  287.         
  288.         'Delete original circle mirrored on y axis
  289.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  290.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  291.         If xRadius <> 0 Then
  292.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  293.         End If
  294.     Case 3: 'mirror around center point
  295.         'Delete original circle mirrored on origin
  296.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  297.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  298.         If xRadius <> 0 Then
  299.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  300.         End If
  301.     Case Else: ' otherwise ignore (i.e. no mirror)
  302.     End Select
  303.     DoEvents
  304.     Tick.Enabled = True' re-enable timer
  305.     'Draw new Circle
  306.     xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  307.     yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  308.     If xRadius <> 0 Then
  309.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  310.     End If
  311.     'Move pointer to next item
  312.     Pointer = Pointer + 1
  313.     If Pointer > MaxLines Then
  314.         Pointer = 1
  315.     End If
  316.     'determine new acceleration
  317.     ax1 = Rnd - .5
  318.     ax2 = Rnd - .5
  319.     ay1 = Rnd - .5
  320.     ay2 = Rnd - .5
  321.     'calculate new position
  322.     x1 = x1 + vx1
  323.     x2 = x2 + vx2
  324.     y1 = y1 + vy1
  325.     y2 = y2 + vy2
  326.     'calculate new velocity
  327.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  328.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  329.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  330.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  331.     'check if off screen
  332.     If (x1 > ScaleWidth) Then
  333.         'change direction
  334.         vx1 = -Abs(vx1)
  335.     ElseIf (x1 < 0) Then
  336.         'change direction
  337.         vx1 = Abs(vx1)
  338.     End If
  339.     If (y1 > ScaleHeight) Then
  340.         'change direction
  341.         vy1 = -Abs(vy1)
  342.     ElseIf (y1 < 0) Then
  343.         'change direction
  344.         vy1 = Abs(vy1)
  345.     End If
  346.     If (x2 > ScaleWidth) Then
  347.         'change direction
  348.         vx2 = -Abs(vx2)
  349.     ElseIf (x2 < 0) Then
  350.         'change direction
  351.         vx2 = Abs(vx2)
  352.     End If
  353.     If (y2 > ScaleHeight) Then
  354.         'change direction
  355.         vy2 = -Abs(vy2)
  356.     ElseIf (y2 < 0) Then
  357.         'change direction
  358.         vy2 = Abs(vy2)
  359.     End If
  360.   End If
  361. End Sub
  362. Sub ClearScreen ()
  363. 'goes to extreme efforts to clear the screen
  364.   DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  365.   'clear display
  366.   BitBlt DC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &H42&
  367.   i = DeleteDC(DC)
  368.   picture = LoadPicture() ' clear picture
  369.   BackColor = QBColor(0)
  370.   Cls
  371. End Sub
  372. Sub Confetti ()
  373.   'put points on screen
  374.   'Dim i As Integer, j As Integer, k As Integer
  375.   Dim x As Integer, y As Integer
  376.   Dim Size As Integer
  377.   Dim UniformBoxes As Integer
  378.   ' if first time then initialize
  379.   If PlotInit = False Then
  380.     'see if we need to reset changes made from previous init
  381.     If PlotEnd = False Then
  382.       'check if saver is permitted to run
  383.       If CheckIfValidSaver(0) = 0 Then
  384.     Exit Sub
  385.       End If
  386.      If LowMemoryFlag = 0 Then 'if not low memory mode then done
  387.        picture = original.Image ' start with original screen
  388.      Else
  389.        Cls
  390.      End If
  391.       PlotInit = True
  392.       Size = Rnd * 5 + 1
  393.     Else 'reset changes done by previous init
  394.       Tick.Enabled = True
  395.       picture = LoadPicture()
  396.     End If
  397.   Else
  398.     Tick.Enabled = False
  399.     Size = Rnd * 5 + 1  ' size to make dots
  400.     If Rnd > .5 Then
  401.        UniformBoxes = True
  402.     Else
  403.        UniformBoxes = False
  404.     End If
  405.     Do
  406.       x = Int(Rnd * ScrnWidth)
  407.       y = Int(Rnd * ScrnHeight)
  408.       Line (x, y)-(x + Size, y + Size), GetNearestColor(hDC, RGB(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))), BF
  409.       If UniformBoxes = False Then
  410.     Size = Rnd ^ 10 * 40 + 2'new size
  411.       End If
  412.       DoEvents
  413.       CurrentTime = Timer
  414.       If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Do
  415.     Loop
  416.     Tick.Enabled = True
  417.     picture = LoadPicture()
  418.   End If
  419. End Sub
  420. Sub CyclePalette ()
  421.   Dim Header As Long, DataBits As Long, i As Integer, j As Integer
  422.   Dim l As Long
  423.   Dim Paint As PAINTSTRUCT
  424.   Static Xoffset As Integer, Yoffset As Integer, red As Integer, green As Integer, blue As Integer
  425.   Static Wdth As Integer, Hght As Integer
  426.   Static FastPalRunFlag As Integer, PassFlag As Integer
  427.   Dim FileName As String, File As String
  428.   Static PaletteFlag As Integer
  429.   ' if first time then initialize
  430.   If PlotInit = False Then
  431.     'see if we need to reset changes made from previous init
  432.     If PlotEnd = False Then
  433.     'check if saver is permitted to run
  434.     If CheckIfValidSaver(1) = 0 Then
  435.       Exit Sub
  436.     End If
  437.      'we only allow to run once since it has problems:
  438.      'if started more than once durring before program stops
  439.      'then resources can disappear drastically, there must
  440.      'be something about the animatepalette function or
  441.      'sendmessage that requires resources to be cleared?
  442.      If FastPalRunFlag Then
  443.        LogFile "Already ran Fast pallete cycle " + File, 1
  444.        NextSelection 'jump to next since there are no bitmap files in directory
  445.        Exit Sub
  446.      End If
  447.       '*****************************************************
  448.       'initialization code here:
  449.       File = GetNextFile(CycleBitmapsDir, 1, "dib", "gif", "")
  450.       If File = "" Then 'check if could not load
  451.     NextSelection 'jump to next since there are no bitmap files in directory
  452.     Exit Sub
  453.       End If
  454.       ' find file
  455.       'FileSpec = RTrim$(BitmapsDir) + "\*.dib"
  456.       j = Rnd * 50 ' pick file at random
  457.       For i = 1 To j
  458.     File = GetNextFile(CycleBitmapsDir, 0, "dib", "gif", "")' get next file
  459.       Next i
  460.       'i = LoadSlide(File, 1)
  461.       'If i = 0 Then 'check if could not load
  462.       '  LogFile "Could not load file " + File, 1
  463.       '  NextSelection 'jump to next since there are no bitmap files in directory
  464.       '  Exit Sub
  465.       'End If
  466.       If InStr(UCase$(File), ".GIF") = 0 Then
  467.     l = ManyDibLoad(File, Wdth, Hght)'load dib
  468.       
  469.     If l <= 0 Then 'check if could not load
  470.       LogFile "Could not read DIB file " + File, 1
  471.       NextSelection 'jump to next since there are no bitmap files in directory
  472.       Exit Sub
  473.     End If
  474.       
  475.       Else
  476.     l = ManyGifLoad(File, Wdth, Hght)'load gif
  477.       
  478.     If l <= 0 Then 'check if could not load
  479.       LogFile "Could not read GIF file " + File, 1
  480.       NextSelection 'jump to next since there are no bitmap files in directory
  481.       Exit Sub
  482.     End If
  483.       End If
  484.       If (TotalNumColors <= 256) And (FastPaletteCycleFlag <> 0) Then
  485.     FastPalRunFlag = 1
  486.     'free up all but 2 system palettes
  487.     i = SetSystemPaletteUse(hDC, SYSPAL_NOSTATIC)
  488.     'show the palettes
  489.     SetWindow2DIBPalette PC_RESERVED
  490.     LogFile "Using Fast Palette Cycling", 0
  491.     PaletteFlag = 1
  492.       Else 'don't mess with palettes
  493.     'picture = LoadPicture() ' clear screen
  494.     LogFile "Changing Palette using screen redraws", 0
  495.     PaletteFlag = 0
  496.       End If
  497.       PassFlag = 2
  498.       
  499.       PlotInit = True
  500.       'Cls
  501.       'position image
  502.       Xoffset = (ScrnWidth - Wdth) / 2
  503.       Yoffset = (ScrnHeight - Hght) / 2
  504.       'set tick rate
  505.       Tick.Interval = 25
  506.     Else 'reset changes done by previous init
  507.       If PaletteFlag <> 0 Then
  508.     'remove priority on palette entries
  509.     SetWindow2DIBPalette 0
  510.     i = SetSystemPaletteUse(hDC, SYSPAL_STATIC)'restore system palette
  511.       End If
  512.       'try to read last temp file for background
  513.       i = LoadSlideAndTile(RTrim$(BitmapsDir) + "\tmprary.dib")
  514.       'save current screen as new original
  515.       DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  516.       BitBlt original.hDC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &HCC0020
  517.       i = DeleteDC(DC)
  518.       ClearScreen
  519.       i = ManyDibFree() 'free memory used for dib
  520.       If i <> 0 Then
  521.     LogFile "Could not free memory", 1
  522.       End If
  523.       'set tick rate
  524.       Tick.Interval = 50
  525.     End If
  526.   Else  ' put run code here
  527.     If PassFlag > 1 Then
  528.       Header = ManyDibGet() 'get pointer to header
  529.       DataBits = ManyDibGetData() 'get pointer to data
  530.       If Header <> 0 Then
  531.     i = SetStretchBltMode(hDC, 3)
  532.     i = StretchDIBits(hDC, 0, 0, ScrnWidth, ScrnHeight, 0, 0, Wdth, Hght, DataBits, Header, 0, &HCC0020)'source copy
  533.       Else
  534.     LogFile "Header missing", 1
  535.     NextSelection
  536.     Exit Sub
  537.       End If
  538.       PassFlag = PassFlag - 1
  539.     Else
  540.       
  541.       Header = ManyDibGet() 'get pointer to header
  542.       DataBits = ManyDibGetData() 'get pointer to data
  543.       If Header <> 0 Then
  544.     If PaletteFlag <> 0 Then
  545.       DoAnimatePalette Pal, 1, 1'shift pallete by one
  546.     Else 'if not palette based, animate screen by
  547.          'changing colors and redrawing
  548.          
  549.       'draw screen
  550.       i = SetStretchBltMode(hDC, 3)
  551.       ManyDibCyclePalette -1, 1, 255'cycle colors
  552.       'i = StretchDIBits(hDC, 0, 0, ScrnWidth, ScrnHeight, 0, 0, 640, 480, DataBits, Header, 0, &HCC0020)'source copy
  553.       i = SetDIBitsToDevice(hDC, Xoffset, Yoffset, Wdth, Hght, 0, 0, 0, Hght, DataBits, Header, 0)
  554.     End If
  555.       Else
  556.     LogFile "Header missing", 1
  557.     NextSelection
  558.     Exit Sub
  559.       End If
  560.     End If
  561.   End If
  562.   Exit Sub
  563. End Sub
  564. Sub DoAnimatePalette (palette As LOGPALETTE, Start As Integer, StepSize As Integer)
  565. ' cycle palete entry and display
  566.     Dim entrynum%, i As Integer
  567.     Dim usepal As Integer
  568.     Dim holdentry As PALETTEENTRY
  569.     Dim temp As Long
  570.     For i = 1 To StepSize'shift n times
  571.       ' The following code simply loops the color values
  572.       LSet holdentry = palette.palPalEntry(Start)
  573.       For entrynum% = Start To PALENTRIES - 2
  574.     LSet palette.palPalEntry(entrynum%) = palette.palPalEntry(entrynum% + 1)
  575.       Next entrynum%
  576.       LSet palette.palPalEntry(PALENTRIES - 1) = holdentry
  577.     Next i
  578.     ' Get a handle to the control's palette
  579.     On Error GoTo DoAnimatePaletteError
  580.     usepal = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  581.     On Error GoTo 0
  582.     AnimatePalette usepal, 0, PALENTRIES, palette.palPalEntry(0)
  583.     Exit Sub
  584. DoAnimatePaletteError:
  585.   'overflow on getting palette handle
  586.   On Error GoTo 0
  587.   LogFile "Overflow on getting palette handle", 1
  588.   Exit Sub
  589. End Sub
  590. Sub Dribble ()
  591.   'dribbling paint on screen
  592.   Dim i As Integer, j As Integer, k As Integer
  593.   Static MaxHole As Integer
  594.   ' if first time then initialize
  595.   If PlotInit = False Then
  596.     'see if we need to reset changes made from previous init
  597.     If PlotEnd = False Then
  598.     'check if saver is permitted to run
  599.     If CheckIfValidSaver(1) = 0 Then
  600.       Exit Sub
  601.     End If
  602.     ' start with original screen
  603.     picture = original.Image
  604.     PlotInit = True
  605.     'determine initial position of shot
  606.     x1 = Rnd * ScaleWidth
  607.     y1 = Rnd * ScaleHeight
  608.     'Calculate velocity limits
  609.     MaxSpeedX = ScaleWidth * 20! / 800
  610.     MaxSpeedY = ScaleWidth * 20! / 600
  611.     ' zero initial velocity
  612.     vx1 = 0: vy1 = 0
  613.     'set maximum size of holes
  614.     MaxHole = 4
  615.     ForeColor = RGB(0, 0, 0)' use black box
  616.     FillColor = RGB(0, 0, 0) 'set black fill
  617.     FillStyle = 0 'solid fill
  618.     RunMode = Int(Rnd * 2#)'choose black or color
  619.     'Debug.Print RunMode
  620.     If RunMode > 0 Then ' if random color then use larger spots
  621.     MaxHole = 8
  622.     i = Rnd * 255: If i > 255 Then i = 255
  623.     j = Rnd * 255: If j > 255 Then j = 255
  624.     k = Rnd * 255: If k > 255 Then k = 255
  625.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  626.     FillColor = ForeColor
  627.     End If
  628.   Else 'reset changes done by previous init
  629.     ClearScreen
  630.     FillStyle = 1 'transparent fill
  631.   End If
  632.   Else  ' put run code here
  633.     If RunMode > 0 Then ' see if need to change to random color
  634.         If Rnd < .05 Then
  635.         i = Rnd * 255: If i > 255 Then i = 255
  636.         j = Rnd * 255: If j > 255 Then j = 255
  637.         k = Rnd * 255: If k > 255 Then k = 255
  638.         ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  639.         FillColor = ForeColor
  640.         End If
  641.     End If
  642.     ' put random hole here
  643.     Circle (x1 + Rnd * 20, y1 + Rnd * 20), MaxHole * Rnd + 2, , , , 1
  644.     'determine new acceleration
  645.     ax1 = 2 * Rnd - 1
  646.     ay1 = 2 * Rnd - 1
  647.         
  648.     'calculate new position
  649.     x1 = x1 + vx1
  650.     y1 = y1 + vy1
  651.         
  652.     'calculate new velocity
  653.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = -vx1 * .9: vy1 = -vy1 * .9: ax1 = 0
  654.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vx1 = -vx1 * .9: vy1 = -vy1 * .9: ay1 = 0
  655.         
  656.     'check if off screen
  657.     If (x1 > ScaleWidth) Then
  658.         'change direction
  659.         vx1 = -Abs(vx1)
  660.     ElseIf (x1 < 0) Then
  661.         'change direction
  662.         vx1 = Abs(vx1)
  663.     End If
  664.     If (y1 > ScaleHeight) Then
  665.         'change direction
  666.         vy1 = -Abs(vy1)
  667.     ElseIf (y1 < 0) Then
  668.         'change direction
  669.         vy1 = Abs(vy1)
  670.     End If
  671.   End If
  672. End Sub
  673. Sub Drop ()
  674.   ' bitblt's with various patterns, dragging them
  675.   ' across the screen randomly
  676.   Dim j As Integer
  677.   Static OldY As Integer
  678.   Static NotFoundCount As Integer
  679.   Const MaxCount = 200
  680.   ' if first time then initialize
  681.   If PlotInit = False Then
  682.     'see if we need to reset changes made from previous init
  683.     If PlotEnd = False Then
  684.     'check if saver is permitted to run
  685.     If CheckIfValidSaver(1) = 0 Then
  686.       Exit Sub
  687.     End If
  688.     'store whether column has dropped
  689.     ReDim x1a(ScaleWidth)
  690.     ' start with original screen
  691.     picture = original.Image
  692.     PlotInit = True
  693.     'flag that no column has been chosen
  694.     x1 = -1
  695.     'Calculate velocity limits
  696.     MaxSpeedY = ScaleWidth * 10! / 600
  697.     MaxSpeedX = ScaleWidth * 10! / 800
  698.     ' zero initial velocity
  699.     vy1 = 0
  700.     'width of column to drop
  701.     BoxWidth = 10 + Rnd * 100
  702.     i = Int(Rnd * 2#)'if i=0 then do jagged drop
  703.     x2 = 0 'used for width change
  704.   Else 'reset changes done by previous init
  705.     'store whether column has dropped
  706.     ReDim x1a(0)
  707.     ClearScreen
  708.   End If
  709. Else  ' put run code here
  710.   If x1 < 0 Then 'see if found valid column
  711.     x1 = Rnd * ScaleWidth / BoxWidth 'choose a column
  712.     If x1a(x1) = 0 Then 'check if not yet dropped
  713.     y1 = 0 'start position
  714.     x1a(x1) = 1 'flag that column has already been used
  715.     x2 = 0: vx2 = 0: OldY = 0' initialize variables
  716.     NotFoundCount = 0
  717.     Else
  718.     x1 = -1 'flag that no column chosen
  719.     ' count column failures
  720.     NotFoundCount = NotFoundCount + 1
  721.     If NotFoundCount > MaxCount Then
  722.         'restart dropping
  723.         'reset whether column has dropped
  724.         ReDim x1a(ScaleWidth)
  725.         ' start with original screen
  726.         picture = original.Image
  727.     End If
  728.     End If
  729.   Else 'if column already found, then drop it
  730.     If i = 0 Then 'check if jagged drop
  731.     'make sure effective width does not get too small
  732.     If x2 >= BoxWidth - 5 Then
  733.     x2 = BoxWidth - 5
  734.     vx2 = -vx2 'reverse direction
  735.     End If
  736.     j = x2 / 2 'get half of change
  737.     'shift column
  738.     DC = original.hDC
  739.     BitBlt hDC, x1 * BoxWidth + j, y1, BoxWidth - x2, ScaleHeight - y1, DC, x1 * BoxWidth + j, 0, &HCC0020'source copy
  740.     'blank top of column
  741.     BitBlt hDC, x1 * BoxWidth + j, OldY, BoxWidth - x2, y1 - OldY + 1, DC, x1 * BoxWidth + j, 0, &H42'blackout
  742.     Else ' not jagged drop
  743.     'shift column
  744.     DC = original.hDC
  745.     BitBlt hDC, x1 * BoxWidth, y1, BoxWidth, ScaleHeight - y1, DC, x1 * BoxWidth, 0, &HCC0020  'source copy
  746.     'blank top of column
  747.     BitBlt hDC, x1 * BoxWidth, OldY, BoxWidth, y1 - OldY + 1, DC, x1 * BoxWidth, 0, &H42'blackout
  748.     End If
  749.     'save current position
  750.     OldY = y1
  751.     'check if off screen
  752.     If (y1 > ScaleHeight) Then
  753.     x1 = -1 'flag done
  754.     vy1 = 0'zero velocity again
  755.     End If
  756.     'determine new acceleration
  757.     ay1 = Rnd * .25
  758.     ax2 = Rnd * .25 - .125
  759.     'calculate new positions
  760.     y1 = y1 + vy1
  761.     x2 = x2 + vx2
  762.     'calculate new velocity
  763.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = vy1 / 2: ay1 = 0
  764.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = vx2 / 2: ax2 = 0
  765.     End If
  766.   End If
  767. End Sub
  768. Sub EndScrnSaveForm ()
  769.   LogFile "EndScrnSaveFrom: before freeing memory", 1
  770.   i = SetSystemPaletteUse(hDC, SYSPAL_STATIC)'restore system palette
  771.   i = ManyDibFree() 'free memory used for dib
  772.   If i <> 0 Then
  773.     LogFile "Could not free memory", 1
  774.   End If
  775.   picture = LoadPicture()
  776.   EndScrnSave 'call global screen saver
  777. End Sub
  778. Sub FilledCircles ()
  779.   ' have a single filled elipse trace across the screen
  780.   Dim i As Integer, j As Integer, k As Integer, n As Integer
  781.   Dim xRadius As Integer, yRadius As Integer
  782.   ' if first time then initialize
  783.   If PlotInit = False Then
  784.     'see if we need to reset changes made from previous init
  785.     If PlotEnd = False Then
  786.     'check if saver is permitted to run
  787.     If CheckIfValidSaver(0) = 0 Then
  788.       Exit Sub
  789.     End If
  790.     PlotInit = True
  791.     Cls
  792.     ForeColor = QBColor(15)
  793.     FillColor = ForeColor
  794.     BackColor = QBColor(0)
  795.     FillStyle = 0' use solid fill
  796.     ' set index to count number of times to repeat color
  797.     '   to past maxvalue so that it will be recalculated
  798.     RepeatIndex = MaxLines + 1
  799.     'determine initial position of line
  800.     x1 = Rnd * ScaleWidth
  801.     x2 = Rnd * ScaleWidth
  802.     y1 = Rnd * ScaleHeight
  803.     y2 = Rnd * ScaleHeight
  804.     'set initial velocity
  805.     vx1 = 0
  806.     vx2 = 0
  807.     vy1 = 0
  808.     vy2 = 0
  809.     'set initial acceleration
  810.     ax1 = 0
  811.     ax2 = 0
  812.     ay1 = 0
  813.     ay2 = 0
  814.     'find background color
  815.     'Calculate velocity limits
  816.     MaxSpeedX = ScaleWidth * 15! / 800
  817.     MaxSpeedY = ScaleWidth * 15! / 600
  818.   Else 'reset changes done by previous init
  819.     ClearScreen
  820.     FillStyle = 1 'transparent fill
  821.   End If
  822.   Else  ' put run code here
  823.     ' check if time to get a new color
  824.     If RepeatIndex > RepeatCount Then
  825.     ' get random fore ground color
  826.     i = Rnd * 255: If i > 255 Then i = 255
  827.     j = Rnd * 255: If j > 255 Then j = 255
  828.     k = Rnd * 255: If k > 255 Then k = 255
  829.     ForeColor = RGB(i, j, k)
  830.     ' get random fill color
  831.     i = Rnd * 255: If i > 255 Then i = 255
  832.     j = Rnd * 255: If j > 255 Then j = 255
  833.     k = Rnd * 255: If k > 255 Then k = 255
  834.     FillColor = GetNearestColor(hDC, RGB(i, j, k))
  835.     RepeatIndex = 1
  836.     Else
  837.     RepeatIndex = RepeatIndex + 1
  838.     End If
  839.     'Draw new Circle
  840.     xRadius = Abs(x1 - x2) / 2
  841.     yRadius = Abs(y1 - y2) / 2
  842.     If xRadius <> 0 Then
  843.         Circle ((x1 + x2) / 2, (y1 + y2) / 2), xRadius, , , , yRadius / xRadius
  844.     End If
  845.     'Move pointer to next item
  846.     Pointer = Pointer + 1
  847.     If Pointer > MaxLines Then
  848.         Pointer = 1
  849.     End If
  850.     'determine new acceleration
  851.     ax1 = Rnd - .5
  852.     ax2 = Rnd - .5
  853.     ay1 = Rnd - .5
  854.     ay2 = Rnd - .5
  855.     'calculate new position
  856.     x1 = x1 + vx1
  857.     x2 = x2 + vx2
  858.     y1 = y1 + vy1
  859.     y2 = y2 + vy2
  860.     'calculate new velocity
  861.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  862.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  863.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  864.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  865.     'check if off screen
  866.     If (x1 > ScaleWidth) Then
  867.         'change direction
  868.         vx1 = -Abs(vx1)
  869.     ElseIf (x1 < 0) Then
  870.         'change direction
  871.         vx1 = Abs(vx1)
  872.     End If
  873.     If (y1 > ScaleHeight) Then
  874.         'change direction
  875.         vy1 = -Abs(vy1)
  876.     ElseIf (y1 < 0) Then
  877.         'change direction
  878.         vy1 = Abs(vy1)
  879.     End If
  880.     If (x2 > ScaleWidth) Then
  881.         'change direction
  882.         vx2 = -Abs(vx2)
  883.     ElseIf (x2 < 0) Then
  884.         'change direction
  885.         vx2 = Abs(vx2)
  886.     End If
  887.     If (y2 > ScaleHeight) Then
  888.         'change direction
  889.         vy2 = -Abs(vy2)
  890.     ElseIf (y2 < 0) Then
  891.         'change direction
  892.         vy2 = Abs(vy2)
  893.     End If
  894.   End If
  895. End Sub
  896. Sub FilledPolygons ()
  897.   ' draw a randomly moving polygon on the screen
  898.   ' slightly offset from previous polygon
  899.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  900.   Static Sets As Integer
  901.   ' if first time then initialize
  902.   If PlotInit = False Then
  903.     'see if we need to reset changes made from previous init
  904.     If PlotEnd = False Then
  905.     'check if saver is permitted to run
  906.     If CheckIfValidSaver(0) = 0 Then
  907.       Exit Sub
  908.     End If
  909.     PlotInit = True
  910.     ForeColor = RGB(255, 255, 255)
  911.     BackColor = RGB(0, 0, 0)
  912.     FillStyle = 0' use solid fill
  913.     DrawWidth = 1' use narrow line
  914.     j = SetPolyFillMode(hDC, 2)' use winding fill mode
  915.     Cls
  916.     'set number of corners between 3 and 5
  917.     Sets = Rnd * 4 + 3
  918.     'Set array size and clear the elements
  919.     ReDim Points(Sets) As POINTAPI
  920.     ReDim vx1sa(Sets) As Single
  921.     ReDim vy1sa(Sets) As Single
  922.     ReDim ax1sa(Sets) As Single
  923.     ReDim ay1sa(Sets) As Single
  924.     'counter for changing colors, set to overflow
  925.     RepeatIndex = RepeatCount + 1
  926.     For j = 1 To Sets
  927.     'determine initial position of line
  928.     Points(j).x = Rnd * ScaleWidth
  929.     Points(j).y = Rnd * ScaleHeight
  930.     Next j
  931.     'Calculate velocity limits
  932.     MaxSpeedX = ScaleWidth * 15! / 800
  933.     MaxSpeedY = ScaleWidth * 15! / 600
  934.   Else 'reset changes done by previous init
  935.     ReDim Points(0) As POINTAPI
  936.     ReDim vx1sa(0) As Single
  937.     ReDim vy1sa(0) As Single
  938.     ReDim ax1sa(0) As Single
  939.     ReDim ay1sa(0) As Single
  940.     FillStyle = 1 'transparent fill
  941.     j = SetPolyFillMode(hDC, 1)' reset to alternate fill mode
  942.     ClearScreen
  943.   End If
  944.   Else  ' put run code here
  945.     ' check if time to get a new color
  946.     If RepeatIndex > RepeatCount Then
  947.     'set fill color
  948.     i = Rnd * 255: If i > 255 Then i = 255
  949.     j = Rnd * 255: If j > 255 Then j = 255
  950.     k = Rnd * 255: If k > 255 Then k = 255
  951.     FillColor = GetNearestColor(hDC, RGB(i, j, k))
  952.     'set foreground color
  953.     i = Rnd * 255: If i > 255 Then i = 255
  954.     j = Rnd * 255: If j > 255 Then j = 255
  955.     k = Rnd * 255: If k > 255 Then k = 255
  956.     ForeColor = RGB(i, j, k)
  957.     RepeatIndex = 1
  958.     Else
  959.     RepeatIndex = RepeatIndex + 1
  960.     End If
  961.     'Draw polygon
  962.     j = Polygon(hDC, Points(0), Sets)
  963.     For j = 1 To Sets
  964.         'determine new acceleration
  965.         ax1sa(j) = Rnd - .5
  966.         ay1sa(j) = Rnd - .5
  967.         
  968.         'calculate new position
  969.         Points(j).x = Points(j).x + vx1sa(j)
  970.         Points(j).y = Points(j).y + vy1sa(j)
  971.         'calculate new velocity
  972.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  973.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  974.         'check if off screen
  975.         If (Points(j).x > ScaleWidth) Then
  976.         'change direction
  977.         vx1sa(j) = -Abs(vx1sa(j))
  978.         ElseIf (Points(j).x < 0) Then
  979.         'change direction
  980.         vx1sa(j) = Abs(vx1sa(j))
  981.         End If
  982.         If (Points(j).y > ScaleHeight) Then
  983.         'change direction
  984.         vy1sa(j) = -Abs(vy1sa(j))
  985.         ElseIf (Points(j).y < 0) Then
  986.         'change direction
  987.         vy1sa(j) = Abs(vy1sa(j))
  988.         End If
  989.     Next j
  990.     End If
  991. End Sub
  992. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  993.     Static KeyState As String * 257
  994.     Dim LongChar As Long
  995.     Dim KeyAscii As Integer
  996.     Static temp$    ' Collects characters each time key is pressed.
  997.     If Passwd = "" Then
  998.     LogFile ("KeyDown, Terminating"), 0
  999.     EndScrnSaveForm         ' End screen blanking
  1000.     Else
  1001.     'refresh system modal in case another process
  1002.     'has grabbed it
  1003.     If TestMode = 0 Then
  1004.         ZOrder 0' make sure form is still on top
  1005.         i = SetSysModalWindow(hWnd)
  1006.     End If
  1007.     'refresh password box
  1008.     PasswordLabel.Visible = False
  1009.     PasswordLabel.Visible = True
  1010.     'convert key to ascii
  1011.     'GetKeyboardStateBystring (KeyState)' get kb state
  1012.     'i = ToAsciiBystring(KeyCode, 0, KeyState, LongChar, 0)
  1013.     'KeyAscii = LongChar Mod 256
  1014.     KeyAscii = MapVirtualKey(KeyCode, 2) ' convert virtual key code to ascii
  1015.     LogFile ("KeyDown, (" + Str$(KeyCode) + ", " + Str$(Shift) + ") received, translated to '" + Chr$(KeyAscii) + "' (" + Str$(KeyAscii) + ")"), 0
  1016.     KeyCode = 0' clear key
  1017.     'parse key into password
  1018.     If KeyAscii = 13 Then       ' ENTER key pressed.
  1019.        KeyAscii = 0            ' Prevents Beep after ENTER Key.
  1020.        If temp$ = Passwd Then
  1021.          LogFile ("Password entered, Terminating"), 0
  1022.          EndScrnSaveForm          ' End screen blanking
  1023.        Else
  1024.          temp$ = ""
  1025.          LogFile ("Invalid Password entered, Continuing"), 0
  1026.          PasswordLabel.Caption = "Password Invalid  "
  1027.          Beep  ' Signal user that password failed.
  1028.          Exit Sub
  1029.        End If
  1030.     ElseIf KeyAscii = 8 Then    ' Backspace key pressed.
  1031.        KeyAscii = 0            'character is not passed on
  1032.        If temp$ <> "" Then 'only delete if not empty
  1033.          temp$ = Left$(temp$, Len(temp$) - 1) ' Remove one char.
  1034.        Else
  1035.          Beep
  1036.        End If
  1037.     ElseIf Len(temp$) = NUMCHARS Then      ' Limit size of password.
  1038.        KeyAscii = 0
  1039.        Beep                    ' Signal user that field is full.
  1040.     ElseIf KeyAscii < 32 Then  ' ignore control keys
  1041.        KeyAscii = 0            ' character is not passed on
  1042.     Else 'normal character that we can recognize?
  1043.        temp$ = temp$ + UCase$(Chr$(KeyAscii))    ' Add a character.
  1044.        KeyAscii = 0            'character is not passed on
  1045.     End If
  1046.     PasswordLabel.Caption = "Password>" + String$(Len(temp$), "*")
  1047.     End If
  1048. End Sub
  1049. Sub Form_KeyPress (KeyAscii As Integer)
  1050.     If Passwd <> "" Then
  1051.     'refresh system modal in case another process
  1052.     'has grabbed it
  1053.     If TestMode = 0 Then
  1054.        ZOrder 0' make sure form is still on top
  1055.        i = SetSysModalWindow(hWnd)
  1056.     End If
  1057.        'refresh password box
  1058.        PasswordLabel.Visible = False
  1059.        PasswordLabel.Visible = True
  1060.        LogFile ("KeyPress, '" + Chr$(KeyAscii) + "' received, code(" + Str$(KeyAscii) + ")"), 0
  1061.        KeyAscii = 0 ' trap characters
  1062.     Else
  1063.     LogFile ("KeyPress, Terminating"), 0
  1064.     EndScrnSaveForm            ' End screen blanking
  1065.     End If
  1066. End Sub
  1067. Sub Form_KeyUp (KeyCode As Integer, Shift As Integer)
  1068. LogFile ("KeyUp, (" + Str$(KeyCode) + ", " + Str$(Shift) + ") received"), 0
  1069. End Sub
  1070. Sub Form_Load ()
  1071.     ' stretch to full screen
  1072.     Move 0, 0, screen.Width, screen.Height
  1073.     TotalNumColors = GetNumberOfColors()'read number colors display can handle
  1074.     LogFile "Display supports " + Str$(TotalNumColors) + " colors", 0
  1075.     KeyPreview = True 'form takes priority on keys
  1076.     'set system modal
  1077.     If TestMode = 0 Then
  1078.       ZOrder 0' make sure form is still on top
  1079.       i = SetSysModalWindow(hWnd) 'make sure can't CTL-ALT-DEL out
  1080.     End If
  1081.     'make mouse invisible
  1082.     If TestMode = 0 Then
  1083.       HideMouse
  1084.     End If
  1085.     'tell windows to disable screen savers
  1086.     i = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, False, 0, 0)
  1087.     DrawWidth = 1
  1088.     Randomize
  1089.     MaxPlotType = 21
  1090.     ReadPriorities ' call each Plot type to get its priority
  1091.     ' Initialize variables now
  1092.     'set plot type
  1093.     If StartSaver = 0 Then
  1094.       PlotType = MaxPlotType * Rnd
  1095.     Else
  1096.       PlotType = StartSaver
  1097.     End If
  1098.     If PlotType > MaxPlotType Then PlotType = 1
  1099.     LogFile ("First Saver is " + Str$(PlotType)), 1
  1100.     PlotInit = False
  1101.     PlotEnd = False
  1102.     TimeInterval = 0
  1103.     MaxTime = MaxChangeMinutes * 60 + Timer ' calculate time in seconds
  1104.     'set tick rate
  1105.     Tick.Interval = 50
  1106.     Repeats = 1 ' number of drawings to make before returning
  1107.     Tick.Enabled = True
  1108. End Sub
  1109. Sub Form_MouseMove (Button As Integer, Shift As Integer, x As Single, y As Single)
  1110.     If IsEmpty(MouseX) Or IsEmpty(MouseY) Then
  1111.     MouseX = x
  1112.     MouseY = y
  1113.     LogFile ("First Mouse Movement (" + Str$(x) + "," + Str$(y) + ")"), 0
  1114.     End If
  1115.     '
  1116.     ' Only unblank the screen if the mouse moves quickly
  1117.     ' enough (more than 2 pixels at one time.
  1118.     '
  1119.     If Abs(MouseX - x) > 2 Or Abs(MouseY - y) > 2 Then
  1120.        
  1121.       If Passwd = "" Then ' only exit if no password
  1122.      LogFile ("Mouse Movement (" + Str$(x) + "," + Str$(y) + "), Terminating"), 0
  1123.      LogFile ("Old Pos (" + Str$(MouseX) + "," + Str$(MouseY) + "), Terminating"), 0
  1124.      EndScrnSaveForm          ' End screen blanking
  1125.       Else
  1126.     'refresh system modal in case another process
  1127.     'has grabbed it
  1128.     If TestMode = 0 Then
  1129.         i = SetSysModalWindow(hWnd)
  1130.     End If
  1131.     PasswordLabel.Visible = False
  1132.     PasswordLabel.Visible = True
  1133.       End If
  1134.     End If
  1135.     LogFile ("Mouse Movement (" + Str$(x) + "," + Str$(y) + "), Continuing"), 0
  1136.     MouseX = x                   ' Remember last position
  1137.     MouseY = y
  1138. End Sub
  1139. Sub Form_Paint ()
  1140.     ' stretch to full screen
  1141.     Move 0, 0, screen.Width, screen.Height
  1142. End Sub
  1143. Function GetBrightNonGray () As Long
  1144. ' this function is needed because in 256 color mode
  1145. ' many random colors get mapped to grays
  1146.   Dim i As Long, j As Long, k As Long
  1147.   Dim NewColor As Long
  1148.     i = Rnd * 255: If i > 255 Then i = 255
  1149.     j = Rnd * 255: If j > 255 Then j = 255
  1150.     k = Rnd * 255: If k > 255 Then k = 255
  1151.     'LogFile ("GetBrightNonGray testing color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1152.     'get nearest colors
  1153.     NewColor = GetNearestColor(hDC, RGB(i, j, k))
  1154.     i = NewColor And &HFF
  1155.     j = NewColor \ &H100 And &HFF
  1156.     k = NewColor \ &H10000 And &HFF
  1157.     'LogFile ("GetBrightNonGray nearest color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1158.     'make sure color is sufficiently bright, and not too gray
  1159.     Loop Until ((i * i + j * j + k * k) > MinColor) And ((Abs(i - j) > MinDiff) Or (Abs(j - k) > MinDiff))
  1160.   'LogFile ("GetBrightNonGray using color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1161.   GetBrightNonGray = NewColor
  1162. End Function
  1163. Function GetNumberOfColors () As Single
  1164.   Dim i As Integer, j As Integer, k As Integer
  1165.   ' get bits per pixel per plane
  1166.   i = GetDeviceCaps(hDC, BITSPIXEL)
  1167.   ' get number of planes
  1168.   j = GetDeviceCaps(hDC, PLANES)
  1169.   ' get total bits per pixel
  1170.   k = i * j
  1171.   GetNumberOfColors = 2# ^ k
  1172. End Function
  1173. Function GetSize (FileName$) As Integer
  1174.     Dim InLine$
  1175.     Dim Loaded As Integer
  1176.     Open FileName$ For Binary As #1
  1177.     '*****************************************************
  1178.     'read header
  1179.     InLine$ = Input$(26, 1)
  1180.     If Asc(Mid$(InLine$, 1, 1)) <> &H42 Then GoTo errorexit
  1181.     If Asc(Mid$(InLine$, 2, 1)) <> &H4D Then GoTo errorexit
  1182.     PicWidth = Asc(Mid$(InLine$, 19, 1)) + Asc(Mid$(InLine$, 20, 1)) * 256
  1183.     PicHeight = Asc(Mid$(InLine$, 23, 1)) + Asc(Mid$(InLine$, 24, 1)) * 256
  1184.     'Debug.Print SWidth, SHeight
  1185.     Close #1
  1186.     Loaded = 1 'flag good read
  1187.     GoTo regexit
  1188. errorexit: Loaded = 0
  1189. regexit: ' no error exit
  1190.     GetSize = Loaded'return read state
  1191. End Function
  1192. Sub Kalied ()
  1193.   ' have a line and its mirror images trace across the
  1194.   ' screen with multiple previous copies following
  1195.   ' it
  1196.   Dim xRadius As Integer, yRadius As Integer
  1197.   Static OldWidth As Integer, OldHeight As Integer
  1198.   Static OldLeft As Integer, OldTop As Integer
  1199.   Static Discontinuous As Integer
  1200.   ' if first time then initialize
  1201.   If PlotInit = False Then
  1202.    'see if we need to reset changes made from previous init
  1203.    If PlotEnd = False Then
  1204.     'check if saver is permitted to run
  1205.     If CheckIfValidSaver(0) = 0 Then
  1206.       Exit Sub
  1207.     End If
  1208.     PlotInit = True
  1209.     Cls
  1210.     ForeColor = QBColor(15)
  1211.     If Rnd > .5 Then
  1212.       Discontinuous = False
  1213.     Else
  1214.       Discontinuous = True
  1215.     End If
  1216.     'select mirroring method
  1217.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  1218.     'Set array size and clear the elements
  1219.     ReDim x1a(MaxLines) As Integer
  1220.     ReDim x2a(MaxLines) As Integer
  1221.     ReDim y1a(MaxLines) As Integer
  1222.     ReDim y2a(MaxLines) As Integer
  1223.     Pointer = 1     ' start with array element 1
  1224.     ' set index to count number of times to repeat color
  1225.     '   to past maxvalue so that it will be recalculated
  1226.     RepeatIndex = MaxLines + 1
  1227.     'save old
  1228.     OldWidth = ScaleWidth: OldHeight = ScaleHeight
  1229.     OldLeft = Scaleleft: OldTop = Scaletop
  1230.     'change scaleso they are symetrical:
  1231.     ScaleHeight = ScaleWidth
  1232.     Scaleleft = -ScaleHeight / 2
  1233.     Scaletop = Scaleleft
  1234.     'Calculate velocity limits
  1235.     MaxSpeedX = ScaleWidth * 15! / 800
  1236.     MaxSpeedY = ScaleWidth * 15! / 600
  1237.     'determine initial position of line
  1238.     x1 = (Rnd - .5) * ScaleWidth
  1239.     x2 = (Rnd - .5) * ScaleWidth
  1240.     y1 = (Rnd - .5) * ScaleHeight
  1241.     y2 = (Rnd - .5) * ScaleHeight
  1242.     'set initial velocity
  1243.     vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1244.     vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1245.     vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1246.     vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1247.     'set initial acceleration
  1248.     ax1 = 0
  1249.     ax2 = 0
  1250.     ay1 = 0
  1251.     ay2 = 0
  1252.     'find background color
  1253.     m = QBColor(0)
  1254.     'set tick rate
  1255.     Tick.Interval = 50
  1256.   Else 'reset changes done by previous init
  1257.     'reset tick rate
  1258.     Tick.Interval = 50
  1259.     'zero array sizes
  1260.     ReDim x1a(0) As Integer
  1261.     ReDim x2a(0) As Integer
  1262.     ReDim y1a(0) As Integer
  1263.     ReDim y2a(0) As Integer
  1264.       'reset screen dimensions
  1265.       ScaleWidth = OldWidth
  1266.       ScaleHeight = OldHeight
  1267.       Scaleleft = OldLeft
  1268.       Scaletop = OldTop
  1269.     ClearScreen
  1270.   End If
  1271.   Else  ' put run code here
  1272.     ' check if time to get a new color
  1273.     If RepeatIndex > RepeatCount Then
  1274.     ' get color
  1275.     l = GetBrightNonGray()
  1276.     If Discontinuous = True Then
  1277.       'determine new position of line
  1278.       x1 = (Rnd - .5) * ScaleWidth
  1279.       x2 = (Rnd - .5) * ScaleWidth
  1280.       y1 = (Rnd - .5) * ScaleHeight
  1281.       y2 = (Rnd - .5) * ScaleHeight
  1282.       'set new velocity
  1283.       vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1284.       vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1285.       vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1286.       vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1287.       'clear acceleration
  1288.       ax1 = 0
  1289.       ax2 = 0
  1290.       ay1 = 0
  1291.       ay2 = 0
  1292.     End If
  1293.     RepeatIndex = 1
  1294.     Else
  1295.     RepeatIndex = RepeatIndex + 1
  1296.     End If
  1297.     'Delete original Lines
  1298.     KaliedPlot Mirror, x1a(Pointer), y1a(Pointer), x2a(Pointer), y2a(Pointer), m
  1299.     'Save New Lines
  1300.     x1a(Pointer) = x1
  1301.     x2a(Pointer) = x2
  1302.     y1a(Pointer) = y1
  1303.     y2a(Pointer) = y2
  1304.     DoEvents
  1305.     'Draw New Lines
  1306.     KaliedPlot Mirror, x1, y1, x2, y2, l
  1307.     'Move pointer to next item
  1308.     Pointer = Pointer + 1
  1309.     If Pointer > MaxLines Then
  1310.         Pointer = 1
  1311.     End If
  1312.     'determine new acceleration
  1313.     ax1 = Rnd - .5
  1314.     ax2 = Rnd - .5
  1315.     ay1 = Rnd - .5
  1316.     ay2 = Rnd - .5
  1317.     'calculate new position
  1318.     x1 = x1 + vx1
  1319.     x2 = x2 + vx2
  1320.     y1 = y1 + vy1
  1321.     y2 = y2 + vy2
  1322.     'calculate new velocity
  1323.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1324.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  1325.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1326.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  1327.     'check if off screen
  1328.     If (x1 > -Scaleleft) Then
  1329.         'change direction
  1330.         vx1 = -Abs(vx1)
  1331.     ElseIf (x1 < Scaleleft) Then
  1332.         'change direction
  1333.         vx1 = Abs(vx1)
  1334.     End If
  1335.     If (y1 > -Scaletop) Then
  1336.         'change direction
  1337.         vy1 = -Abs(vy1)
  1338.     ElseIf (y1 < Scaletop) Then
  1339.         'change direction
  1340.         vy1 = Abs(vy1)
  1341.     End If
  1342.     If (x2 > -Scaleleft) Then
  1343.         'change direction
  1344.         vx2 = -Abs(vx2)
  1345.     ElseIf (x2 < Scaleleft) Then
  1346.         'change direction
  1347.         vx2 = Abs(vx2)
  1348.     End If
  1349.     If (y2 > -Scaletop) Then
  1350.         'change direction
  1351.         vy2 = -Abs(vy2)
  1352.     ElseIf (y2 < Scaletop) Then
  1353.         'change direction
  1354.         vy2 = Abs(vy2)
  1355.     End If
  1356.     End If
  1357. End Sub
  1358. Sub Kalied2 ()
  1359.   ' have a line and its mirror images trace across the
  1360.   ' screen with all the previous copies left on the screen
  1361.   ' until the maximum is reached and the screen cleared
  1362.   Dim xRadius As Integer, yRadius As Integer
  1363.   Static OldWidth As Integer, OldHeight As Integer
  1364.   Static OldLeft As Integer, OldTop As Integer
  1365.   Static Discontinuous As Integer
  1366.   ' if first time then initialize
  1367.   If PlotInit = False Then
  1368.     'see if we need to reset changes made from previous init
  1369.     If PlotEnd = True Then
  1370.       ScaleWidth = OldWidth
  1371.       ScaleHeight = OldHeight
  1372.       Scaleleft = OldLeft
  1373.       Scaletop = OldTop
  1374.       ClearScreen
  1375.       Exit Sub
  1376.     End If
  1377.     'check if saver is permitted to run
  1378.     If CheckIfValidSaver(0) = 0 Then
  1379.       Exit Sub
  1380.     End If
  1381.     PlotInit = True
  1382.     Cls
  1383.     ForeColor = QBColor(15)
  1384.     If Rnd > .5 Then
  1385.       Discontinuous = False
  1386.     Else
  1387.       Discontinuous = True
  1388.     End If
  1389.     'select mirroring method
  1390.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  1391.     Pointer = 1     ' set lines on screen to one
  1392.     ' set index to count number of times to repeat color
  1393.     '   to past maxvalue so that it will be recalculated
  1394.     RepeatIndex = MaxLines + 1
  1395.     'save old
  1396.     OldWidth = ScaleWidth: OldHeight = ScaleHeight
  1397.     OldLeft = Scaleleft: OldTop = Scaletop
  1398.     'change scaleso they are symetrical:
  1399.     ScaleHeight = ScaleWidth
  1400.     Scaleleft = -ScaleHeight / 2
  1401.     Scaletop = Scaleleft
  1402.     'determine initial position of line
  1403.     x1 = (Rnd - .5) * ScaleWidth
  1404.     x2 = (Rnd - .5) * ScaleWidth
  1405.     y1 = (Rnd - .5) * ScaleHeight
  1406.     y2 = (Rnd - .5) * ScaleHeight
  1407.     'set initial velocity
  1408.     vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1409.     vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1410.     vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1411.     vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1412.     'set initial acceleration
  1413.     ax1 = 0
  1414.     ax2 = 0
  1415.     ay1 = 0
  1416.     ay2 = 0
  1417.     'find background color
  1418.     m = QBColor(0)
  1419.     'Calculate velocity limits
  1420.     MaxSpeedX = ScaleWidth * 15! / 800
  1421.     MaxSpeedY = ScaleWidth * 15! / 600
  1422.   Else  ' put run code here
  1423.     ' check if time to get a new color
  1424.     If RepeatIndex > RepeatCount Then
  1425.     ' get color
  1426.     l = GetBrightNonGray()
  1427.     If Discontinuous = True Then
  1428.       'determine new position of line
  1429.       x1 = (Rnd - .5) * ScaleWidth
  1430.       x2 = (Rnd - .5) * ScaleWidth
  1431.       y1 = (Rnd - .5) * ScaleHeight
  1432.       y2 = (Rnd - .5) * ScaleHeight
  1433.       'set new velocity
  1434.       vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1435.       vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1436.       vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1437.       vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1438.       'clear acceleration
  1439.       ax1 = 0
  1440.       ax2 = 0
  1441.       ay1 = 0
  1442.       ay2 = 0
  1443.     End If
  1444.     RepeatIndex = 1
  1445.     Else
  1446.     RepeatIndex = RepeatIndex + 1
  1447.     End If
  1448.     'Draw New Lines
  1449.     KaliedPlot Mirror, x1, y1, x2, y2, l
  1450.     ' count total lines on screen
  1451.     Pointer = Pointer + 1
  1452.     If Pointer > MaxCums Then
  1453.         'when maximum reached then clear
  1454.         Cls
  1455.         Pointer = 1
  1456.     End If
  1457.     'determine new acceleration
  1458.     ax1 = Rnd - .5
  1459.     ax2 = Rnd - .5
  1460.     ay1 = Rnd - .5
  1461.     ay2 = Rnd - .5
  1462.     'calculate new position
  1463.     x1 = x1 + vx1
  1464.     x2 = x2 + vx2
  1465.     y1 = y1 + vy1
  1466.     y2 = y2 + vy2
  1467.     'calculate new velocity
  1468.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1469.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  1470.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1471.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  1472.     'check if off screen
  1473.     If (x1 > -Scaleleft) Then
  1474.         'change direction
  1475.         vx1 = -Abs(vx1)
  1476.     ElseIf (x1 < Scaleleft) Then
  1477.         'change direction
  1478.         vx1 = Abs(vx1)
  1479.     End If
  1480.     If (y1 > -Scaletop) Then
  1481.         'change direction
  1482.         vy1 = -Abs(vy1)
  1483.     ElseIf (y1 < Scaletop) Then
  1484.         'change direction
  1485.         vy1 = Abs(vy1)
  1486.     End If
  1487.     If (x2 > -Scaleleft) Then
  1488.         'change direction
  1489.         vx2 = -Abs(vx2)
  1490.     ElseIf (x2 < Scaleleft) Then
  1491.         'change direction
  1492.         vx2 = Abs(vx2)
  1493.     End If
  1494.     If (y2 > -Scaletop) Then
  1495.         'change direction
  1496.         vy2 = -Abs(vy2)
  1497.     ElseIf (y2 < Scaletop) Then
  1498.         'change direction
  1499.         vy2 = Abs(vy2)
  1500.     End If
  1501.     End If
  1502. End Sub
  1503. Sub KaliedPlot (MirrorMode As Integer, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, Color As Long)
  1504. 'warning -- recursive subroutine
  1505.   Dim xm1 As Integer, ym1 As Integer, xm2 As Integer, ym2 As Integer
  1506.     Select Case MirrorMode
  1507.     Case 1: 'mirror on x and y axis
  1508.         Line (x1, y1)-(x2, y2), Color
  1509.         Line (-x1, y1)-(-x2, y2), Color
  1510.         Line (x1, -y1)-(x2, -y2), Color
  1511.         Line (-x1, -y1)-(-x2, -y2), Color
  1512.     Case 2: 'mirror on Y axis
  1513.         Line (x1, y1)-(x2, y2), Color
  1514.         Line (-x1, y1)-(-x2, y2), Color
  1515.     Case 3: 'mirror around center point
  1516.         Line (x1, y1)-(x2, y2), Color
  1517.         Line (-x1, -y1)-(-x2, -y2), Color
  1518.     Case 4: 'mirror around center point and diagonally
  1519.         Line (x1, y1)-(x2, y2), Color
  1520.         Line (-x1, -y1)-(-x2, -y2), Color
  1521.         'mirror diagonally
  1522.         xm1 = y1
  1523.         ym1 = x1
  1524.         xm2 = y2
  1525.         ym2 = x2
  1526.         Line (-xm1, ym1)-(-xm2, ym2), Color
  1527.         Line (xm1, -ym1)-(xm2, -ym2), Color
  1528.     Case 5: 'mirror on x and y axis and diagonally
  1529.         Line (x1, y1)-(x2, y2), Color
  1530.         Line (-x1, y1)-(-x2, y2), Color
  1531.         Line (x1, -y1)-(x2, -y2), Color
  1532.         Line (-x1, -y1)-(-x2, -y2), Color
  1533.         'mirror diagonally
  1534.         xm1 = y1
  1535.         ym1 = x1
  1536.         xm2 = y2
  1537.         ym2 = x2
  1538.         Line (xm1, ym1)-(xm2, ym2), Color
  1539.         Line (-xm1, ym1)-(-xm2, ym2), Color
  1540.         Line (xm1, -ym1)-(xm2, -ym2), Color
  1541.         Line (-xm1, -ym1)-(-xm2, -ym2), Color
  1542.     Case 6: 'mirror around center point and diagonally
  1543.         'and then shift 45 degrees and repeat
  1544.         KaliedPlot 4, x1, y1, x2, y2, Color
  1545.         'shift 45 degrees, formula
  1546.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1547.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1548.         xm1 = x1 * Cos45 - y1 * Sin45
  1549.         ym1 = y1 * Cos45 + x1 * Sin45
  1550.         xm2 = x2 * Cos45 - y2 * Sin45
  1551.         ym2 = y2 * Cos45 + x2 * Sin45
  1552.         KaliedPlot 4, xm1, ym1, xm2, ym2, Color
  1553.     Case 7: 'mirror on x and y axis and diagonally
  1554.         'and then shift 45 degrees and repeat
  1555.         KaliedPlot 5, x1, y1, x2, y2, Color
  1556.         'shift 45 degrees, formula
  1557.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1558.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1559.         xm1 = x1 * Cos45 - y1 * Sin45
  1560.         ym1 = y1 * Cos45 + x1 * Sin45
  1561.         xm2 = x2 * Cos45 - y2 * Sin45
  1562.         ym2 = y2 * Cos45 + x2 * Sin45
  1563.         KaliedPlot 5, xm1, ym1, xm2, ym2, Color
  1564.     Case 8: 'mirror around center point and diagonally
  1565.         'and then shift 45 degrees and repeat
  1566.         'and then shift 22.5 and repeat the above
  1567.         KaliedPlot 6, x1, y1, x2, y2, Color
  1568.         'shift 22.5 degrees, formula
  1569.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1570.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1571.         xm1 = x1 * Cos22_5 - y1 * Sin22_5
  1572.         ym1 = y1 * Cos22_5 + x1 * Sin22_5
  1573.         xm2 = x2 * Cos22_5 - y2 * Sin22_5
  1574.         ym2 = y2 * Cos22_5 + x2 * Sin22_5
  1575.         KaliedPlot 6, xm1, ym1, xm2, ym2, Color
  1576.     Case 9: 'mirror on x and y axis and diagonally
  1577.         'and then shift 45 degrees and repeat
  1578.         'and then shift 22.5 and repeat the above
  1579.         KaliedPlot 7, x1, y1, x2, y2, Color
  1580.         'shift 22.5 degrees, formula
  1581.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1582.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1583.         xm1 = x1 * Cos22_5 - y1 * Sin22_5
  1584.         ym1 = y1 * Cos22_5 + x1 * Sin22_5
  1585.         xm2 = x2 * Cos22_5 - y2 * Sin22_5
  1586.         ym2 = y2 * Cos22_5 + x2 * Sin22_5
  1587.         KaliedPlot 7, xm1, ym1, xm2, ym2, Color
  1588.     Case 10: 'mirror around center point and diagonally
  1589.         'and then shift 45 degrees and repeat
  1590.         'and then shift 22.5 and repeat the above
  1591.         'and then shift 11.25 and repeat the above
  1592.         KaliedPlot 8, x1, y1, x2, y2, Color
  1593.         'shift 22.5 degrees, formula
  1594.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1595.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1596.         xm1 = x1 * Cos11_25 - y1 * Sin11_25
  1597.         ym1 = y1 * Cos11_25 + x1 * Sin11_25
  1598.         xm2 = x2 * Cos11_25 - y2 * Sin11_25
  1599.         ym2 = y2 * Cos11_25 + x2 * Sin11_25
  1600.         KaliedPlot 8, xm1, ym1, xm2, ym2, Color
  1601.     Case 11: 'mirror on x and y axis and diagonally
  1602.         'and then shift 45 degrees and repeat
  1603.         'and then shift 22.5 and repeat the above
  1604.         'and then shift 11.25 and repeat the above
  1605.         KaliedPlot 9, x1, y1, x2, y2, Color
  1606.         'shift 22.5 degrees, formula
  1607.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1608.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1609.         xm1 = x1 * Cos11_25 - y1 * Sin11_25
  1610.         ym1 = y1 * Cos11_25 + x1 * Sin11_25
  1611.         xm2 = x2 * Cos11_25 - y2 * Sin11_25
  1612.         ym2 = y2 * Cos11_25 + x2 * Sin11_25
  1613.         KaliedPlot 9, xm1, ym1, xm2, ym2, Color
  1614.     Case Else: MirrorMode = 1' if invalid value set, then change
  1615.     End Select
  1616. End Sub
  1617. Sub Lines ()
  1618.   ' have a random number of lines trace across the
  1619.   ' screen with multiple previous copies following
  1620.   ' them
  1621.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  1622.   Dim il As Long, jl As Long, kl As Long
  1623.   Static Sets As Integer
  1624.   ' if first time then initialize
  1625.   If PlotInit = False Then
  1626.    'see if we need to reset changes made from previous init
  1627.    If PlotEnd = False Then
  1628.     'check if saver is permitted to run
  1629.     If CheckIfValidSaver(0) = 0 Then
  1630.       Exit Sub
  1631.     End If
  1632.     PlotInit = True
  1633.     Cls
  1634.     ForeColor = QBColor(15)
  1635.     'set number of sets between 1 and 4
  1636.     Sets = Rnd * 3 + 1
  1637.     'Set array size and clear the elements
  1638.     ReDim x1da(MaxLines, Sets) As Integer
  1639.     ReDim x2da(MaxLines, Sets) As Integer
  1640.     ReDim y1da(MaxLines, Sets) As Integer
  1641.     ReDim y2da(MaxLines, Sets) As Integer
  1642.     ReDim x1sa(Sets) As Single
  1643.     ReDim x2sa(Sets) As Single
  1644.     ReDim y1sa(Sets) As Single
  1645.     ReDim y2sa(Sets) As Single
  1646.     ReDim vx1sa(Sets) As Single
  1647.     ReDim vx2sa(Sets) As Single
  1648.     ReDim vy1sa(Sets) As Single
  1649.     ReDim vy2sa(Sets) As Single
  1650.     ReDim ax1sa(Sets) As Single
  1651.     ReDim ax2sa(Sets) As Single
  1652.     ReDim ay1sa(Sets) As Single
  1653.     ReDim ay2sa(Sets) As Single
  1654.     ReDim Colors(Sets) As Long
  1655.     Pointer = 1     ' start with array element 1
  1656.     ' set index to count number of times to repeat color
  1657.     '   to past maxvalue so that it will be recalculated
  1658.     RepeatIndex = MaxLines + 1
  1659.     For j = 1 To Sets
  1660.     'determine initial position of line
  1661.     x1sa(j) = Rnd * ScaleWidth
  1662.     x2sa(j) = Rnd * ScaleWidth
  1663.     y1sa(j) = Rnd * ScaleHeight
  1664.     y2sa(j) = Rnd * ScaleHeight
  1665.     Next j
  1666.     'find background color
  1667.     m = QBColor(0)
  1668.     'Calculate velocity limits
  1669.     MaxSpeedX = ScaleWidth * 15! / 800
  1670.     MaxSpeedY = ScaleWidth * 15! / 600
  1671.   Else 'reset changes done by previous init
  1672.     'Set array size and clear the elements
  1673.     ReDim x1da(0, 0) As Integer
  1674.     ReDim x2da(0, 0) As Integer
  1675.     ReDim y1da(0, 0) As Integer
  1676.     ReDim y2da(0, 0) As Integer
  1677.     ReDim x1sa(0) As Single
  1678.     ReDim x2sa(0) As Single
  1679.     ReDim y1sa(0) As Single
  1680.     ReDim y2sa(0) As Single
  1681.     ReDim vx1sa(0) As Single
  1682.     ReDim vx2sa(0) As Single
  1683.     ReDim vy1sa(0) As Single
  1684.     ReDim vy2sa(0) As Single
  1685.     ReDim ax1sa(0) As Single
  1686.     ReDim ax2sa(0) As Single
  1687.     ReDim ay1sa(0) As Single
  1688.     ReDim ay2sa(0) As Single
  1689.     ReDim Colors(0) As Long
  1690.     ClearScreen
  1691.   End If
  1692.   Else  ' put run code here
  1693.     ' check if time to get a new color
  1694.     If RepeatIndex > RepeatCount Then
  1695.     ' get colors
  1696.     For ii = 1 To Sets
  1697.       Colors(ii) = GetBrightNonGray()
  1698.     Next ii
  1699.     RepeatIndex = 1
  1700.     Else
  1701.     RepeatIndex = RepeatIndex + 1
  1702.     End If
  1703.     'Delete original Lines
  1704.     For j = 1 To Sets
  1705.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), m
  1706.     Next j
  1707.     For j = 1 To Sets
  1708.         'Save New Lines
  1709.         x1da(Pointer, j) = x1sa(j)
  1710.         x2da(Pointer, j) = x2sa(j)
  1711.         y1da(Pointer, j) = y1sa(j)
  1712.         y2da(Pointer, j) = y2sa(j)
  1713.         'Draw new Line
  1714.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), Colors(j)
  1715.     Next j
  1716.     'Move pointer to next item
  1717.     Pointer = Pointer + 1
  1718.     If Pointer > MaxLines Then
  1719.         Pointer = 1
  1720.     End If
  1721.     For j = 1 To Sets
  1722.         'determine new acceleration
  1723.         ax1sa(j) = Rnd - .5
  1724.         ax2sa(j) = Rnd - .5
  1725.         ay1sa(j) = Rnd - .5
  1726.         ay2sa(j) = Rnd - .5
  1727.         'calculate new position
  1728.         x1sa(j) = x1sa(j) + vx1sa(j)
  1729.         x2sa(j) = x2sa(j) + vx2sa(j)
  1730.         y1sa(j) = y1sa(j) + vy1sa(j)
  1731.         y2sa(j) = y2sa(j) + vy2sa(j)
  1732.         'calculate new velocity
  1733.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  1734.         vx2sa(j) = (vx2sa(j) + ax2sa(j)): If Abs(vx2sa(j)) > MaxSpeedX Then vx2sa(j) = 0: ax2sa(j) = 0
  1735.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  1736.         vy2sa(j) = (vy2sa(j) + ay2sa(j)): If Abs(vy2sa(j)) > MaxSpeedY Then vy2sa(j) = 0: ay2sa(j) = 0
  1737.         'check if off screen
  1738.         If (x1sa(j) > ScaleWidth) Then
  1739.         'change direction
  1740.         vx1sa(j) = -Abs(vx1sa(j))
  1741.         ElseIf (x1sa(j) < 0) Then
  1742.         'change direction
  1743.         vx1sa(j) = Abs(vx1sa(j))
  1744.         End If
  1745.         If (y1sa(j) > ScaleHeight) Then
  1746.         'change direction
  1747.         vy1sa(j) = -Abs(vy1sa(j))
  1748.         ElseIf (y1sa(j) < 0) Then
  1749.         'change direction
  1750.         vy1sa(j) = Abs(vy1sa(j))
  1751.         End If
  1752.         If (x2sa(j) > ScaleWidth) Then
  1753.         'change direction
  1754.         vx2sa(j) = -Abs(vx2sa(j))
  1755.         ElseIf (x2sa(j) < 0) Then
  1756.         'change direction
  1757.         vx2sa(j) = Abs(vx2sa(j))
  1758.         End If
  1759.         If (y2sa(j) > ScaleHeight) Then
  1760.         'change direction
  1761.         vy2sa(j) = -Abs(vy2sa(j))
  1762.         ElseIf (y2sa(j) < 0) Then
  1763.         'change direction
  1764.         vy2sa(j) = Abs(vy2sa(j))
  1765.         End If
  1766.     Next j
  1767.   End If
  1768. End Sub
  1769. Function LoadSlide (File As String, ShowPic As Integer) As Integer
  1770.  'loads picture to screen, if gif file extension, then
  1771.  'save to dib bitmap, returns zero on failure
  1772.   Dim RetVal As Integer, i As Integer, l As Long
  1773.   Dim Header As Long, DataBits As Long
  1774.   Dim TempName As String
  1775.   RetVal = 1
  1776.   LogFile "Showing file " + File, 1
  1777.   If InStr(UCase$(File), ".GIF") = 0 Then
  1778.     ' if not gif file, then bitmap
  1779.     If ShowPic Then
  1780.       On Error GoTo LoadSlide_Error
  1781.       picture = LoadPicture(File)
  1782.       On Error GoTo 0
  1783.     End If
  1784.     'get dimensions of bitmap
  1785.     If GetSize(File) = 0 Then RetVal = 0
  1786.   Else ' convert gif to DIB
  1787.     l = ManyGifLoad(File, PicWidth, PicHeight)'load gif
  1788.     If l <= 0 Then
  1789.       LogFile "Could not read GIF file " + File, 1
  1790.       RetVal = 0
  1791.     Else
  1792.       'where to store converted file
  1793.       TempName = RTrim$(BitmapsDir) + "\tmprary.dib"
  1794.       i = ManyDIBWrite(TempName)
  1795.       If i <> 0 Then 'check for error
  1796.     LogFile "Could not write GIF file " + TempName, 1
  1797.     RetVal = 0
  1798.       Else
  1799.     If ShowPic Then
  1800.       On Error GoTo LoadSlide_Error
  1801.       picture = LoadPicture(TempName)
  1802.       On Error GoTo 0
  1803.     End If
  1804.       End If
  1805.     End If
  1806.   End If
  1807.   LoadSlide = RetVal
  1808.   Exit Function
  1809. LoadSlide_Error:
  1810.   'could not load file, out of memory?
  1811.   On Error GoTo 0
  1812.   RetVal = 0
  1813.   LogFile ("Could not load file " + File), 1
  1814.   Resume Next
  1815. End Function
  1816. Function LoadSlideAndTile (File As String) As Integer
  1817. ' returns zero on error
  1818.   Dim i As Integer, RetVal As Integer
  1819.   If File = "" Then
  1820.     RetVal = 0
  1821.   Else
  1822.     i = LoadSlide(File, 1)'put file on display
  1823.     If i = 0 Then 'check if could not load
  1824.       RetVal = 0
  1825.     Else
  1826.       Replicate
  1827.       RetVal = 1
  1828.     End If
  1829.   End If
  1830.   LoadSlideAndTile = RetVal
  1831. End Function
  1832. Sub MultiSpiros ()
  1833.   'Do spirograph like figures
  1834.   'reserve memory
  1835.   Const Deg2Pi = PI / 180
  1836.   Static MaxRad As Integer'maximum radius for circles
  1837.   Const MaxNodes = 35'maximum number of nodes on spiro
  1838.   Dim Nodes As Integer
  1839.   Const MaxRpts = 7'max times to go around circle
  1840.   Dim Rpts As Integer
  1841.   Const PlotPoints = 1'number of points to plot each time
  1842.   Const ClearCount = 3'number on screen before clearing
  1843.   Static PlotAngleIncr As Single
  1844.   Static PlotEndAngle As Single
  1845.   Static PlotAngle As Single
  1846.   Static SinIncr As Single
  1847.   Static SinAngle As Single
  1848.   Static Xcenter As Integer
  1849.   Static Ycenter As Integer
  1850.   Static Xincr As Integer
  1851.   Static Yincr As Integer
  1852.   Const MaxSpiro = 8' maximum number of simultaneous spiros
  1853.   Static SpiroCnt As Integer
  1854.   Static Rad1 As Integer
  1855.   Static Rad2 As Integer
  1856.   Dim r As Single
  1857.   Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, n As Integer
  1858.   Dim il As Long, jl As Long, kl As Long
  1859.   ' if first time then initialize
  1860.   If PlotInit = False Then
  1861.     'see if we need to reset changes made from previous init
  1862.     If PlotEnd = False Then
  1863.     'check if saver is permitted to run
  1864.     If CheckIfValidSaver(0) = 0 Then
  1865.       Exit Sub
  1866.     End If
  1867.       PlotInit = True
  1868.       ForeColor = RGB(255, 255, 255)
  1869.       BackColor = RGB(0, 0, 0)
  1870.       Cls
  1871.      'initialize variables used
  1872.      PlotEndAngle = 0
  1873.      PlotAngle = 10
  1874.      MaxRad = ScaleHeight / 3'maximum radius for circles
  1875.      Pointer = 0
  1876.     Else 'reset changes done by previous init
  1877.       DrawWidth = 1' use narrow line
  1878.       ClearScreen
  1879.     End If
  1880.   Else  ' put run code here
  1881.    Do
  1882.     ' check if time to do new spiro
  1883.     If PlotAngle > PlotEndAngle Then
  1884.     'set foreground color
  1885.     ForeColor = GetBrightNonGray()
  1886.     PlotAngle = Rnd * 180 * Deg2Pi'initial offset
  1887.     Rpts = Rnd * MaxRpts + .5
  1888.     PlotAngleIncr = .125 * Rpts * Deg2Pi
  1889.     PlotEndAngle = 360 * Rpts * Deg2Pi + PlotAngle + PlotAngleIncr
  1890.     Nodes = Rnd * MaxNodes + .5
  1891.     SinIncr = PlotAngleIncr * Nodes / Rpts
  1892.     SinAngle = 0
  1893.     Rad1 = MaxRad * Rnd + ScaleHeight / 80
  1894.     Rad2 = MaxRad * Rnd + ScaleHeight / 80
  1895.     'get location of first
  1896.     Xcenter = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  1897.     Ycenter = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  1898.     'get location of last
  1899.     i = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  1900.     j = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  1901.     'get number
  1902.     SpiroCnt = (MaxSpiro - 2) * Rnd + 2' maximum number of simultaneous spiros
  1903.     'calculate increment
  1904.     Xincr = (i - Xcenter) / (SpiroCnt - 1)
  1905.     Yincr = (j - Ycenter) / (SpiroCnt - 1)
  1906.     DrawWidth = 1 + 2 * Rnd ' set line width
  1907.     GoSub 3000 'calculate x1 and y1
  1908.     Delay 2'pause before clearing screen
  1909.     End If
  1910.     For i = 1 To PlotPoints
  1911.       GoSub 3000 'calculate x1 and y1
  1912.       k = x1: l = y1: m = LastX: n = LastY
  1913.       'plot each spiro
  1914.       For j = 1 To SpiroCnt
  1915.     'draw line
  1916.     Line (m, n)-(k, l)
  1917.     'get location for next
  1918.     k = k + Xincr: l = l + Yincr
  1919.     m = m + Xincr: n = n + Yincr
  1920.       Next j
  1921.     Next i
  1922.     DoEvents
  1923.     CurrentTime = Timer
  1924.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Sub
  1925.    Loop
  1926.   End If
  1927.   Exit Sub
  1928. 3000 'calculate new point on screen
  1929.   LastX = x1: LastY = y1
  1930.   r = Rad1 + Rad2 * Sin(SinAngle)
  1931.   x1 = r * Cos(PlotAngle) + Xcenter
  1932.   y1 = r * Sin(PlotAngle) + Ycenter
  1933.   SinAngle = SinAngle + SinIncr
  1934.   PlotAngle = PlotAngle + PlotAngleIncr
  1935.   Return
  1936. End Sub
  1937. Sub NextSelection ()
  1938. Dim i As Integer
  1939. Dim Level As Single
  1940. If RandomFlag <> 0 Then
  1941.   ' pick a new selection but not the same as the last
  1942.     'i = Int(Rnd * MaxPlotType) + 1'choose next one at random
  1943.     Level = Rnd * TotalPriority' get random proportion of TP
  1944.     'now search array to see which saver this prop. falls into
  1945.     i = 1
  1946.     While (PriorityBreakPoints(i) <= Level)
  1947.       i = i + 1
  1948.     Wend
  1949.     'Debug.Print i, Level, TotalPriority
  1950.     If (i > MaxPlotType) Or (i < 1) Then i = PlotType'flag to try again
  1951.   Loop While (i = PlotType)
  1952.   PlotType = i
  1953.   PlotType = PlotType + 1
  1954. End If
  1955. LogFile ("Next Saver is" + Str$(PlotType)), 1
  1956. End Sub
  1957. Sub Patch ()
  1958.   ' copy blocks of original screen to random spots
  1959.   ' if first time then initialize
  1960.   If PlotInit = False Then
  1961.    'see if we need to reset changes made from previous init
  1962.    If PlotEnd = False Then
  1963.     'check if saver is permitted to run
  1964.     If CheckIfValidSaver(1) = 0 Then
  1965.       Exit Sub
  1966.     End If
  1967.     ' set tick rate down
  1968.     Tick.Interval = 250
  1969.     ' start with original screen
  1970.     picture = original.Image
  1971.     PlotInit = True
  1972.     i = Int(Rnd * 2#) 'if i=0 then alternate reverse copy
  1973.   Else 'reset changes done by previous init
  1974.     ClearScreen
  1975.     'reset tick rate
  1976.     Tick.Interval = 50
  1977.   End If
  1978.   Else  ' put run code here
  1979.     BoxHeight = Rnd * ScaleHeight / 2.5
  1980.     BoxWidth = Rnd * ScaleWidth / 2.5 * (8# / 6#)
  1981.     ' get random locations
  1982.     x1 = Rnd * ScaleWidth
  1983.     y1 = Rnd * ScaleHeight
  1984.     x2 = Rnd * ScaleWidth
  1985.     y2 = Rnd * ScaleHeight
  1986.     'make sure room in destination and source blocks
  1987.     If x1 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x1
  1988.     If x2 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x2
  1989.     If y1 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y1
  1990.     If y2 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y2
  1991.     'BitBlt Box from x2,y2 to x1,y1
  1992.     DC = original.hDC
  1993.     If i = 0 And Rnd < .5 Then
  1994.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, &H330008 'not source copy
  1995.     Else
  1996.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, &HCC0020 'source copy
  1997.     End If
  1998.   End If
  1999. End Sub
  2000. Sub Polygons ()
  2001.   ' draw a randomly moving polygon on the screen
  2002.   ' with multiple previous copies following it
  2003.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  2004.   Dim il As Long, jl As Long, kl As Long
  2005.   Static Sets As Integer
  2006.   ' if first time then initialize
  2007.   If PlotInit = False Then
  2008.     'see if we need to reset changes made from previous init
  2009.     If PlotEnd = False Then
  2010.     'check if saver is permitted to run
  2011.     If CheckIfValidSaver(0) = 0 Then
  2012.       Exit Sub
  2013.     End If
  2014.     PlotInit = True
  2015.     Cls
  2016.     ForeColor = QBColor(15)
  2017.     'set number of sets between 3 and 5
  2018.     Sets = Rnd * 2 + 3
  2019.     'Set array size and clear the elements
  2020.     ReDim x1da(MaxLines, Sets) As Integer
  2021.     ReDim y1da(MaxLines, Sets) As Integer
  2022.     ReDim x1sa(Sets) As Single
  2023.     ReDim y1sa(Sets) As Single
  2024.     ReDim vx1sa(Sets) As Single
  2025.     ReDim vy1sa(Sets) As Single
  2026.     ReDim ax1sa(Sets) As Single
  2027.     ReDim ay1sa(Sets) As Single
  2028.     Pointer = 1     ' start with array element 1
  2029.     ' set index to count number of times to repeat color
  2030.     '   to past maxvalue so that it will be recalculated
  2031.     RepeatIndex = MaxLines + 1
  2032.     For j = 1 To Sets
  2033.     'determine initial position of line
  2034.     x1sa(j) = Rnd * ScaleWidth
  2035.     y1sa(j) = Rnd * ScaleHeight
  2036.     Next j
  2037.     'find background color
  2038.     m = QBColor(0)
  2039.     'Calculate velocity limits
  2040.     MaxSpeedX = ScaleWidth * 15! / 800
  2041.     MaxSpeedY = ScaleWidth * 15! / 600
  2042.   Else 'reset changes done by previous init
  2043.     'Set array size and clear the elements
  2044.     ReDim x1da(0, 0) As Integer
  2045.     ReDim y1da(0, 0) As Integer
  2046.     ReDim x1sa(0) As Single
  2047.     ReDim y1sa(0) As Single
  2048.     ReDim vx1sa(0) As Single
  2049.     ReDim vy1sa(0) As Single
  2050.     ReDim ax1sa(0) As Single
  2051.     ReDim ay1sa(0) As Single
  2052.     ClearScreen
  2053.   End If
  2054.   Else  ' put run code here
  2055.     ' check if time to get a new color
  2056.     If RepeatIndex > RepeatCount Then
  2057.     ' get colors
  2058.     l = GetBrightNonGray()
  2059.     RepeatIndex = 1
  2060.     Else
  2061.     RepeatIndex = RepeatIndex + 1
  2062.     End If
  2063.     'Delete original Lines
  2064.     Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), m
  2065.     For j = 3 To Sets
  2066.         Line -(x1da(Pointer, j), y1da(Pointer, j)), m
  2067.     Next j
  2068.     Line -(x1da(Pointer, 1), y1da(Pointer, 1)), m
  2069.     For j = 1 To Sets
  2070.         'Save New Lines
  2071.         x1da(Pointer, j) = x1sa(j)
  2072.         y1da(Pointer, j) = y1sa(j)
  2073.     Next j
  2074.     'Draw New Lines
  2075.     Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), l
  2076.     For j = 3 To Sets
  2077.         Line -(x1da(Pointer, j), y1da(Pointer, j)), l
  2078.     Next j
  2079.     Line -(x1da(Pointer, 1), y1da(Pointer, 1)), l
  2080.     'Move pointer to next item
  2081.     Pointer = Pointer + 1
  2082.     If Pointer > MaxLines Then
  2083.         Pointer = 1
  2084.     End If
  2085.     For j = 1 To Sets
  2086.         'determine new acceleration
  2087.         ax1sa(j) = Rnd - .5
  2088.         ay1sa(j) = Rnd - .5
  2089.         
  2090.         'calculate new position
  2091.         x1sa(j) = x1sa(j) + vx1sa(j)
  2092.         y1sa(j) = y1sa(j) + vy1sa(j)
  2093.         'calculate new velocity
  2094.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  2095.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  2096.         'check if off screen
  2097.         If (x1sa(j) > ScaleWidth) Then
  2098.         'change direction
  2099.         vx1sa(j) = -Abs(vx1sa(j))
  2100.         ElseIf (x1sa(j) < 0) Then
  2101.         'change direction
  2102.         vx1sa(j) = Abs(vx1sa(j))
  2103.         End If
  2104.         If (y1sa(j) > ScaleHeight) Then
  2105.         'change direction
  2106.         vy1sa(j) = -Abs(vy1sa(j))
  2107.         ElseIf (y1sa(j) < 0) Then
  2108.         'change direction
  2109.         vy1sa(j) = Abs(vy1sa(j))
  2110.         End If
  2111.     Next j
  2112.     End If
  2113. End Sub
  2114. Sub Puzzle ()
  2115.   'scramble screen by shifting one column or row at a time
  2116.   Dim tempx As Integer, tempy As Integer
  2117.   Dim x As Integer, y As Integer
  2118.   ' if first time then initialize
  2119.   If PlotInit = False Then
  2120.     'see if we need to reset changes made from previous init
  2121.     If PlotEnd = False Then
  2122.     'check if saver is permitted to run
  2123.     If CheckIfValidSaver(1) = 0 Then
  2124.       Exit Sub
  2125.     End If
  2126.     ' set tick rate down
  2127.     Tick.Interval = 1000
  2128.     ' start with original screen
  2129.     picture = original.Image
  2130.     'find background color
  2131.     m = QBColor(0)
  2132.     PlotInit = True
  2133.     Number = Rnd * 16 + 4
  2134.     'Number = 20
  2135.     BoxHeight = ScaleHeight / Number
  2136.     BoxWidth = ScaleWidth / Number
  2137.     'initialize blocks
  2138.     ReDim x1da(Number, Number) As Integer
  2139.     ReDim y1da(Number, Number) As Integer
  2140.     For x1 = 1 To Number
  2141.     For y1 = 1 To Number
  2142.         x1da(x1, y1) = (x1 - 1) * BoxWidth
  2143.         y1da(x1, y1) = (y1 - 1) * BoxHeight
  2144.     Next y1
  2145.     Next x1
  2146.   Else 'reset changes done by previous init
  2147.     ReDim x1da(0, 0) As Integer
  2148.     ReDim y1da(0, 0) As Integer
  2149.     'reset tick rate
  2150.     Tick.Interval = 50
  2151.     ClearScreen
  2152.   End If
  2153.   Else  ' put run code here
  2154.     If Int(Rnd * 2) = 1 Then 'shift column
  2155.     x1 = Rnd * Number + 1: If x1 > Number Then x1 = 1
  2156.     If Int(Rnd * 2) = 1 Then 'shift down
  2157.         tempx = x1da(x1, Number)
  2158.         tempy = y1da(x1, Number)
  2159.         For y1 = Number To 2 Step -1
  2160.         x1da(x1, y1) = x1da(x1, y1 - 1)
  2161.         y1da(x1, y1) = y1da(x1, y1 - 1)
  2162.         'BitBlt Box to x1,y1
  2163.         DC = original.hDC
  2164.         x = (x1 - 1) * BoxWidth
  2165.         y = (y1 - 1) * BoxHeight
  2166.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2167.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2168.         Next y1
  2169.         y1 = 1
  2170.         x1da(x1, y1) = tempx
  2171.         y1da(x1, y1) = tempy
  2172.         'BitBlt Box to x1,y1
  2173.         DC = original.hDC
  2174.         x = (x1 - 1) * BoxWidth
  2175.         y = (y1 - 1) * BoxHeight
  2176.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2177.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2178.     Else ' shift up
  2179.         tempx = x1da(x1, 1)
  2180.         tempy = y1da(x1, 1)
  2181.         For y1 = 1 To (Number - 1)
  2182.         x1da(x1, y1) = x1da(x1, y1 + 1)
  2183.         y1da(x1, y1) = y1da(x1, y1 + 1)
  2184.         'BitBlt Box to x1,y1
  2185.         DC = original.hDC
  2186.         x = (x1 - 1) * BoxWidth
  2187.         y = (y1 - 1) * BoxHeight
  2188.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2189.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2190.         
  2191.         Next y1
  2192.         y1 = Number
  2193.         x1da(x1, y1) = tempx
  2194.         y1da(x1, y1) = tempy
  2195.         'BitBlt Box to x1,y1
  2196.         DC = original.hDC
  2197.         x = (x1 - 1) * BoxWidth
  2198.         y = (y1 - 1) * BoxHeight
  2199.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2200.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2201.     End If
  2202.     Else ' shift row
  2203.     y1 = Rnd * Number + 1: If y1 > Number Then y1 = 1
  2204.     If Int(Rnd * 2) = 1 Then 'shift right
  2205.         tempx = x1da(Number, y1)
  2206.         tempy = y1da(Number, y1)
  2207.         For x1 = Number To 2 Step -1
  2208.         x1da(x1, y1) = x1da(x1 - 1, y1)
  2209.         y1da(x1, y1) = y1da(x1 - 1, y1)
  2210.         'BitBlt Box to x1,y1
  2211.         DC = original.hDC
  2212.         x = (x1 - 1) * BoxWidth
  2213.         y = (y1 - 1) * BoxHeight
  2214.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2215.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2216.         Next x1
  2217.         x1 = 1
  2218.         x1da(x1, y1) = tempx
  2219.         y1da(x1, y1) = tempy
  2220.         'BitBlt Box to x1,y1
  2221.         DC = original.hDC
  2222.         x = (x1 - 1) * BoxWidth
  2223.         y = (y1 - 1) * BoxHeight
  2224.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2225.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2226.     Else 'shift left
  2227.         tempx = x1da(1, y1)
  2228.         tempy = y1da(1, y1)
  2229.         For x1 = 1 To (Number - 1)
  2230.         x1da(x1, y1) = x1da(x1 + 1, y1)
  2231.         y1da(x1, y1) = y1da(x1 + 1, y1)
  2232.         'BitBlt Box to x1,y1
  2233.         DC = original.hDC
  2234.         x = (x1 - 1) * BoxWidth
  2235.         y = (y1 - 1) * BoxHeight
  2236.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2237.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2238.         Next x1
  2239.         x1 = Number
  2240.         x1da(x1, y1) = tempx
  2241.         y1da(x1, y1) = tempy
  2242.         'BitBlt Box to x1,y1
  2243.         DC = original.hDC
  2244.         x = (x1 - 1) * BoxWidth
  2245.         y = (y1 - 1) * BoxHeight
  2246.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2247.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2248.     End If
  2249.     End If
  2250.   End If
  2251. End Sub
  2252. Sub ReadPriorities ()
  2253.   Dim i As Integer, j As Integer
  2254.   Dim temp As String * 30, Out  As String
  2255.   Dim Priority As Single
  2256.   ReDim PriorityBreakPoints(MaxPlotType + 1) As Single
  2257.   ReDim Priorities(MaxPlotType) As Integer
  2258.   TotalPriority = 0
  2259.   For i = 1 To MaxPlotType
  2260.     j = GetPrivateProfileString(secName, PriorityBaseName + Int2Str(i), "1", temp, 28, iniName)
  2261.     Priority = Val(temp)
  2262.     Out = Out + Str$(Priority)
  2263.     If Priority < 0# Then Priority = 0#
  2264.     If Priority = 0# Then
  2265.       Priorities(i) = 0
  2266.     Else
  2267.       Priorities(i) = 1
  2268.     End If
  2269.     TotalPriority = TotalPriority + Priority
  2270.     PriorityBreakPoints(i) = TotalPriority
  2271.   Next
  2272.   LogFile "Priorites set to " + Out, 0
  2273.   PriorityBreakPoints(MaxPlotType + 1) = TotalPriority + 3.402E+38
  2274. End Sub
  2275. Sub Replicate ()
  2276.   Dim x As Integer, y As Integer, x1 As Integer, y1 As Integer
  2277.   DoEvents
  2278.   DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  2279.   'limit sizes
  2280.   If PicWidth > ScrnWidth Then PicWidth = ScrnWidth
  2281.   If PicHeight > ScrnHeight Then PicHeight = ScrnHeight
  2282.   If (PicWidth < ScrnWidth) Or (PicHeight < ScrnHeight) Then
  2283.     'need to center picture
  2284.     'first backup picture
  2285.     BitBlt original.hDC, 0, 0, PicWidth, PicHeight, DC, 0, 0, &HCC0020
  2286.     'clear original
  2287.     'Picture = LoadPicture()
  2288.     ' now copy back centered
  2289.     x = ScrnWidth / 2 - PicWidth / 2
  2290.     y = ScrnHeight / 2 - PicHeight / 2
  2291.     BitBlt hDC, x, y, PicWidth, PicHeight, original.hDC, 0, 0, &HCC0020
  2292.   End If
  2293.   If (PicWidth < ScrnWidth) Then 'fill row
  2294.     '1st copy left
  2295.     x1 = x
  2296.     While x1 > 0
  2297.       BitBlt hDC, x1 - PicWidth, 0, PicWidth, ScrnHeight, hDC, x, 0, &HCC0020
  2298.       x1 = x1 - PicWidth
  2299.     Wend
  2300.     'next copy right
  2301.     x1 = x
  2302.     While x1 < ScrnWidth
  2303.       BitBlt hDC, x1 + PicWidth, 0, PicWidth, ScrnHeight, hDC, x, 0, &HCC0020
  2304.       x1 = x1 + PicWidth
  2305.     Wend
  2306.   End If
  2307.   If (PicHeight < ScrnHeight) Then
  2308.     '1st copy up
  2309.     y1 = y
  2310.     While y1 > 0
  2311.       BitBlt hDC, 0, y1 - PicHeight, ScrnWidth, PicHeight, hDC, 0, y, &HCC0020
  2312.       y1 = y1 - PicHeight
  2313.     Wend
  2314.     'next copy down
  2315.     y1 = y
  2316.     While y1 < ScrnHeight
  2317.       BitBlt hDC, 0, y1 + PicHeight, ScrnWidth, PicHeight, hDC, 0, y, &HCC0020
  2318.       y1 = y1 + PicHeight
  2319.     Wend
  2320.   End If
  2321.   i = DeleteDC(DC)
  2322. End Sub
  2323. Sub Roll ()
  2324.   ' the display rolls both horizontally and vertically
  2325.   Dim v As Integer
  2326.   ' if first time then initialize
  2327.   If PlotInit = False Then
  2328.     'see if we need to reset changes made from previous init
  2329.     If PlotEnd = False Then
  2330.     'check if saver is permitted to run
  2331.     If CheckIfValidSaver(1) = 0 Then
  2332.       Exit Sub
  2333.     End If
  2334.     ' start with original screen
  2335.     picture = original.Image
  2336.     PlotInit = True
  2337.     'Calculate velocity limits
  2338.     MaxSpeedX = ScaleWidth * 15! / 800
  2339.     MaxSpeedY = ScaleWidth * 15! / 600
  2340.     ' initial velocities
  2341.     vy1 = 0: vx1 = 0
  2342.     ' initial offset
  2343.     x1 = 0: y1 = 0
  2344.     Direction = Rnd * 2: If Direction > 1 Then Direction = 0
  2345.   Else 'reset changes done by previous init
  2346.     ClearScreen
  2347.   End If
  2348.   Else  ' put run code here
  2349.     DC = original.hDC
  2350.     If Direction Then
  2351.     ' do vertical scroll
  2352.     BitBlt hDC, 0, y1, ScaleWidth, ScaleHeight - y1, DC, 0, 0, &HCC0020
  2353.     BitBlt hDC, 0, 0, ScaleWidth, y1, DC, 0, ScaleHeight - y1, &HCC0020
  2354.     Else
  2355.     ' do horizontal scroll
  2356.     BitBlt hDC, x1, 0, ScaleWidth - x1, ScaleHeight, DC, 0, 0, &HCC0020
  2357.     BitBlt hDC, 0, 0, x1, ScaleHeight, DC, ScaleWidth - x1, 0, &HCC0020
  2358.     End If
  2359.     'determine new acceleration
  2360.     ax1 = Rnd - .5
  2361.     ay1 = Rnd - .5
  2362.         
  2363.     'calculate new velocity
  2364.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  2365.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  2366.     'find new roll amount
  2367.     x1 = x1 + vx1
  2368.     If x1 > ScaleWidth Then
  2369.     x1 = x1 - ScaleWidth
  2370.     Else
  2371.     If x1 < 0 Then
  2372.         x1 = x1 + ScaleWidth
  2373.     End If
  2374.     End If
  2375.         
  2376.     y1 = y1 + vy1
  2377.     If y1 > ScaleHeight Then
  2378.     y1 = y1 - ScaleHeight
  2379.     Else
  2380.     If y1 < 0 Then
  2381.         y1 = y1 + ScaleHeight
  2382.     End If
  2383.     End If
  2384.         
  2385.   End If
  2386. End Sub
  2387. Sub RunSelection ()
  2388.     ' execute the appropriate selection
  2389.     Select Case PlotType
  2390.     Case 1: Squiggles
  2391.     Case 2: Kalied2
  2392.     Case 3: Polygons
  2393.     Case 4: Circles
  2394.     Case 5: Kalied
  2395.     Case 6: Lines
  2396.     Case 7: Roll
  2397.     Case 8: FilledCircles
  2398.     Case 9: Patch
  2399.     Case 10: Spiro
  2400.     Case 11: Scrape
  2401.     Case 12: Stretch
  2402.     Case 13: Dribble
  2403.     Case 14: Drop
  2404.     Case 15: Slides
  2405.     Case 16: FilledPolygons
  2406.     Case 17: MultiSpiros
  2407.     Case 18: Puzzle
  2408.     Case 19: ShootHoles
  2409.     Case 20: CyclePalette
  2410.     Case 21: Confetti
  2411.     Case Else: PlotType = 1
  2412.            RunSelection ' try again
  2413.     End Select
  2414. End Sub
  2415. Sub Scrape ()
  2416.   Static smear As Integer
  2417.   ' bitblt's with various patterns, dragging them
  2418.   ' across the screen randomly
  2419.   ' if first time then initialize
  2420.   If PlotInit = False Then
  2421.     'see if we need to reset changes made from previous init
  2422.     If PlotEnd = False Then
  2423.     'check if saver is permitted to run
  2424.     If CheckIfValidSaver(1) = 0 Then
  2425.       Exit Sub
  2426.     End If
  2427.     ' start with original screen
  2428.     picture = original.Image
  2429.     PlotInit = True
  2430.     'determine initial position of line
  2431.     x1 = Rnd * ScaleWidth
  2432.     y1 = Rnd * ScaleHeight
  2433.     'Calculate velocity limits
  2434.     MaxSpeedX = ScaleWidth * 15! / 800
  2435.     MaxSpeedY = ScaleWidth * 15! / 600
  2436.     BoxHeight = 400 * Rnd ^ 3 + 20
  2437.     BoxWidth = (400 * Rnd ^ 3 + 20) * (8# / 6#)
  2438.     ' zero initial velocity
  2439.     vx1 = 0: vy1 = 0
  2440.     'default for smear
  2441.     smear = False
  2442.     ' choose scrape type at random
  2443.     i = Rnd * 14 + 1
  2444.     'i = 12
  2445.     Select Case i
  2446.     Case 1: Pattern = &H42 'Black Out
  2447.         Locked = True
  2448.     Case 2: Pattern = &HFF0062 'White Out
  2449.         Locked = True
  2450.     Case 3: Pattern = &HBB0226 'MergePaint
  2451.         Locked = False
  2452.     Case 4: Pattern = &H330008 'Not source copy
  2453.         Locked = True
  2454.     Case 5: Pattern = &H330008 'Not source copy
  2455.         Locked = False
  2456.     Case 6: Pattern = &H330008 'Not source copy
  2457.         Locked = False
  2458.         picture = LoadPicture() ' start with blank screen
  2459.     Case 7: Pattern = &H330008 'Not source copy
  2460.         smear = True
  2461.         'set random source location
  2462.         x2 = Rnd * (ScaleWidth - BoxWidth)
  2463.         y2 = Rnd * (ScaleHeight - BoxHeight)
  2464.     Case 8: Pattern = &H660046 'source invert
  2465.         Locked = True
  2466.     Case 9: Pattern = &H8800C6 'source and
  2467.         Locked = False
  2468.     Case 10: Pattern = &HEE0086 'source paint (or)
  2469.         Locked = False
  2470.     Case 11: Pattern = &H550009 'Invert Destination
  2471.         Locked = True
  2472.     Case 12: Pattern = &HCC0020 'Source Copy
  2473.         Locked = False
  2474.     Case 13: Pattern = &HCC0020 'Source Copy
  2475.         Locked = True
  2476.         picture = LoadPicture() ' start with blank screen
  2477.     Case Else: Pattern = &HCC0020 'Source Copy
  2478.         smear = True
  2479.         'set random source location
  2480.         x2 = Rnd * (ScaleWidth - BoxWidth)
  2481.         y2 = Rnd * (ScaleHeight - BoxHeight)
  2482.     End Select
  2483.   Else 'reset changes done by previous init
  2484.     ClearScreen
  2485.   End If
  2486.   Else  ' put run code here
  2487.     If smear Then
  2488.       'do nothing
  2489.     ' do locking if necessary
  2490.     ElseIf Locked Then
  2491.         x2 = x1: y2 = y1
  2492.     Else 'do offset
  2493.         x2 = x1 + BoxWidth: If x2 + BoxWidth > ScaleWidth Then x2 = 0
  2494.         y2 = y1 + BoxHeight: If y2 + BoxHeight > ScaleHeight Then y2 = 0
  2495.     End If
  2496.     'BitBlt Box at x1,y1
  2497.     DC = original.hDC
  2498.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, Pattern
  2499.     'determine new acceleration
  2500.     ax1 = Rnd - .5
  2501.     ay1 = Rnd - .5
  2502.         
  2503.     'calculate new position
  2504.     x1 = x1 + vx1
  2505.     y1 = y1 + vy1
  2506.         
  2507.     'calculate new velocity
  2508.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  2509.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  2510.         
  2511.     'check if off screen
  2512.     If (x1 > ScaleWidth - BoxWidth) Then
  2513.         'change direction
  2514.         vx1 = -Abs(vx1)
  2515.     ElseIf (x1 < 0) Then
  2516.         'change direction
  2517.         vx1 = Abs(vx1)
  2518.     End If
  2519.     If (y1 > ScaleHeight - BoxHeight) Then
  2520.         'change direction
  2521.         vy1 = -Abs(vy1)
  2522.     ElseIf (y1 < 0) Then
  2523.         'change direction
  2524.         vy1 = Abs(vy1)
  2525.     End If
  2526.   End If
  2527. End Sub
  2528. Sub SetWindow2DIBPalette (State As Integer)
  2529.   Dim i As Integer, j As Integer, k As Integer, l As Integer
  2530.   Dim usepal%
  2531.   'read dib palette into logical palette for cycling
  2532.   ManyLoadLogPal Pal, 0, 256, State
  2533.   usepal% = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  2534.   'this has problems:
  2535.   'i = SetPaletteEntries%(usepal%, 0, PALENTRIES, Pal.palPalEntry(0))
  2536.   'Pal.palNumEntries
  2537.   'try to set windows palette to logical palette using clipboard
  2538.   If PaletteHandle <> 0 Then
  2539.     i = DeleteObject(PaletteHandle)
  2540.   End If
  2541.   PaletteHandle = CreatePalette(Pal)
  2542.   j = OpenClipboard(hWnd)
  2543.   k = SetClipboardData(CF_PALETTE, PaletteHandle)
  2544.   l = CloseClipboard()
  2545.   picture = Clipboard.GetData(CF_PALETTE)
  2546.   Clipboard.Clear
  2547. End Sub
  2548. Sub ShootHoles ()
  2549.   ' shoots small holes approximately at the same place
  2550.   Dim i As Integer, j As Integer, k As Integer
  2551.   Dim r As Long, x As Long, y As Long
  2552.   Static Radius As Integer, HoleSize  As Integer
  2553.   Dim temp As Single
  2554.   Const pi2 = PI * 2
  2555.   ' if first time then initialize
  2556.   If PlotInit = False Then
  2557.     'see if we need to reset changes made from previous init
  2558.     If PlotEnd = False Then
  2559.     'check if saver is permitted to run
  2560.     If CheckIfValidSaver(1) = 0 Then
  2561.       Exit Sub
  2562.     End If
  2563.     ' start with original screen
  2564.     picture = original.Image
  2565.     PlotInit = True
  2566.     'determine initial position of shot
  2567.     x1 = Rnd * ScaleWidth
  2568.     y1 = Rnd * ScaleHeight
  2569.     'determine maximum radius of shot
  2570.     Radius = (ScaleHeight - 100) * Rnd + 100
  2571.     'set size of holes
  2572.     HoleSize = 20 * Rnd ^ 2 + 2
  2573.     RunMode = Int(Rnd * 3)'choose color mode to show
  2574.     FillStyle = 0 'solid fill
  2575.     If RunMode > 0 Then ' if random color then use larger spots
  2576.     i = Rnd * 255: If i > 255 Then i = 255
  2577.     j = Rnd * 255: If j > 255 Then j = 255
  2578.     k = Rnd * 255: If k > 255 Then k = 255
  2579.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  2580.     FillColor = ForeColor
  2581.     Else
  2582.       ForeColor = RGB(0, 0, 0)' use black box
  2583.       FillColor = RGB(0, 0, 0) 'set black fill
  2584.     End If
  2585.   Else 'reset changes done by previous init
  2586.     ClearScreen
  2587.     FillStyle = 1 'transparent fill
  2588.   End If
  2589. Else  ' put run code here
  2590.     If RunMode > 1 Then ' if random color then use larger spots
  2591.     i = Rnd * 255: If i > 255 Then i = 255
  2592.     j = Rnd * 255: If j > 255 Then j = 255
  2593.     k = Rnd * 255: If k > 255 Then k = 255
  2594.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  2595.     FillColor = ForeColor
  2596.     End If
  2597.     'get distance from center
  2598.     r = Rnd * Radius
  2599.     'get random angle
  2600.     temp = Rnd * pi2
  2601.     'get x portion
  2602.     x = r * Cos(temp)
  2603.     'get y portion
  2604.     y = r * Sin(temp)
  2605.     ' randomly change sign of x offset
  2606.     If Rnd > .5 Then
  2607.       x = -x
  2608.     End If
  2609.     ' randomly change sign of y offset
  2610.     If Rnd > .5 Then
  2611.       y = -y
  2612.     End If
  2613.     ' put random hole here
  2614.     Circle (x1 + x, y1 + y), HoleSize, , , , 1
  2615.   End If
  2616. End Sub
  2617. Sub ShowPal (palette As LOGPALETTE)
  2618. 'displays the current palette
  2619.     Dim usepal%
  2620.     ' Get a handle to the control's palette
  2621.     usepal% = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  2622.     AnimatePalette usepal%, 0, PALENTRIES, palette.palPalEntry(0)
  2623. End Sub
  2624. Sub Slides ()
  2625.   'cycle between different bitmaps
  2626.   Dim j As Integer
  2627.   Static File As String
  2628.   Static OldTime As Long
  2629.   Static running As Integer
  2630.   Dim CurTime As Long
  2631.   Dim FileName As String
  2632.   ' if first time then initialize
  2633.   If PlotInit = False Then
  2634.    'see if we need to reset changes made from previous init
  2635.    If PlotEnd = False Then
  2636.     'check if saver is permitted to run
  2637.     If CheckIfValidSaver(1) = 0 Then
  2638.       Exit Sub
  2639.     End If
  2640.     File = GetNextFile(BitmapsDir, 1, "gif", "bmp", "")
  2641.     If File = "" Then 'check if could not find bitmap
  2642.       NextSelection 'jump to next since there are no bitmap files in directory
  2643.       Exit Sub
  2644.     End If
  2645.     ' find file
  2646.     j = Rnd * 50 ' pick file at random
  2647.     For i = 1 To j
  2648.       File = GetNextFile(BitmapsDir, 0, "gif", "bmp", "")' get next file
  2649.     Next i
  2650.     i = LoadSlideAndTile(File)
  2651.     If i = 0 Then 'check if could not load
  2652.       NextSelection 'jump to next since there are no bitmap files in directory
  2653.       Exit Sub
  2654.     End If
  2655.     OldTime = Timer
  2656.     running = False
  2657.     PlotInit = True
  2658.   Else 'reset changes done by previous init
  2659.     ' save screen in place of original for latter use
  2660.     ' we do this because on palette based systems
  2661.     ' the slide procedure messes up the color
  2662.     ' palette and the Clipboard.setData 9 and
  2663.     ' Clipboard.GetData(9) sequence does not restore
  2664.     ' it, so we just use the new picture with the
  2665.     ' new palette from now on
  2666.     DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  2667.     BitBlt original.hDC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &HCC0020
  2668.     i = DeleteDC(DC)
  2669.     i = ManyDibFree() 'free memory used for dib
  2670.     If i <> 0 Then
  2671.       LogFile "Could not free memory", 1
  2672.     End If
  2673.     ClearScreen
  2674.   End If
  2675. Else  ' put run code here
  2676.     If running Then Exit Sub ' no recursive calls
  2677.     If File = "" Then Exit Sub
  2678.     CurTime = Timer
  2679.     If (CurTime >= OldTime) And ((OldTime + BmpSeconds) > CurTime) Then Exit Sub
  2680.     OldTime = Timer
  2681.     running = True
  2682.     j = Rnd * 20
  2683.     For i = 1 To j
  2684.       File = GetNextFile(BitmapsDir, 0, "gif", "bmp", "")' get next file
  2685.     Next i
  2686.     i = LoadSlideAndTile(File)
  2687.     If i = 0 Then 'check if could not load
  2688.       NextSelection 'jump to next since there are no bitmap files in directory
  2689.       Exit Sub
  2690.     End If
  2691.   End If
  2692.   running = False
  2693.   Exit Sub
  2694. End Sub
  2695. Sub Spiro ()
  2696.   'Do spirograph like figures
  2697.   'reserve memory
  2698.   Const Deg2Pi = PI / 180
  2699.   Static MaxRad As Integer'maximum radius for circles
  2700.   Const MaxNodes = 35'maximum number of nodes on spiro
  2701.   Dim Nodes As Integer
  2702.   Const MaxRpts = 7'max times to go around circle
  2703.   Dim Rpts As Integer
  2704.   Const PlotPoints = 1'number of points to plot each time
  2705.   Const ClearCount = 3'number on screen before clearing
  2706.   Static PlotAngleIncr As Single
  2707.   Static PlotEndAngle As Single
  2708.   Static PlotAngle As Single
  2709.   Static SinIncr As Single
  2710.   Static SinAngle As Single
  2711.   Static Xcenter As Integer
  2712.   Static Ycenter As Integer
  2713.   Static Rad1 As Integer
  2714.   Static Rad2 As Integer
  2715.   Dim r As Single
  2716.   Dim l As Integer
  2717.   ' if first time then initialize
  2718.   If PlotInit = False Then
  2719.    'see if we need to reset changes made from previous init
  2720.    If PlotEnd = False Then
  2721.     'check if saver is permitted to run
  2722.     If CheckIfValidSaver(0) = 0 Then
  2723.       Exit Sub
  2724.     End If
  2725.       PlotInit = True
  2726.       ForeColor = RGB(255, 255, 255)
  2727.       BackColor = RGB(0, 0, 0)
  2728.       Cls
  2729.      'initialize variables used
  2730.      PlotEndAngle = 0
  2731.      PlotAngle = 10
  2732.      MaxRad = ScaleHeight / 3'maximum radius for circles
  2733.      Pointer = 0
  2734.     Else 'reset changes done by previous init
  2735.       DrawWidth = 1' use narrow line
  2736.       ClearScreen
  2737.     End If
  2738.   Else  ' put run code here
  2739.    Do
  2740.     ' check if time to do new spiro
  2741.     If PlotAngle > PlotEndAngle Then
  2742.     'set foreground color
  2743.     ForeColor = GetBrightNonGray()
  2744.     PlotAngle = Rnd * 180 * Deg2Pi'initial offset
  2745.     Rpts = Rnd * MaxRpts + .5
  2746.     PlotAngleIncr = .125 * Rpts * Deg2Pi
  2747.     PlotEndAngle = 360 * Rpts * Deg2Pi + PlotAngle + PlotAngleIncr
  2748.     Nodes = Rnd * MaxNodes + .5
  2749.     SinIncr = PlotAngleIncr * Nodes / Rpts
  2750.     SinAngle = 0
  2751.     Rad1 = MaxRad * Rnd + ScaleHeight / 80
  2752.     Rad2 = MaxRad * Rnd + ScaleHeight / 80
  2753.     Xcenter = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  2754.     Ycenter = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  2755.     DrawWidth = 1 + 2 * Rnd' use narrow line
  2756.     GoSub 2000 'calculate x1 and y1
  2757.     Pointer = Pointer + 1
  2758.     If Pointer >= ClearCount Then
  2759.       Delay 3'pause before clearing screen
  2760.       Cls
  2761.       Pointer = 0
  2762.     End If
  2763.     currentx = x1
  2764.     currenty = y1
  2765.     End If
  2766.     For l = 1 To PlotPoints
  2767.       GoSub 2000 'calculate x1 and y1
  2768.       'draw line
  2769.       'Line (LastX, LastY)-(x1, y1)
  2770.       Line -(x1, y1)
  2771.     Next l
  2772.     DoEvents
  2773.     CurrentTime = Timer
  2774.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Sub
  2775.    Loop
  2776.   End If
  2777.   Exit Sub
  2778. 2000 'calculate new point on screen
  2779.   'LastX = x1: LastY = y1
  2780.   r = Rad1 + Rad2 * Sin(SinAngle)
  2781.   x1 = r * Cos(PlotAngle) + Xcenter
  2782.   y1 = r * Sin(PlotAngle) + Ycenter
  2783.   SinAngle = SinAngle + SinIncr
  2784.   PlotAngle = PlotAngle + PlotAngleIncr
  2785.   Return
  2786. End Sub
  2787. Sub Squiggles ()
  2788.   ' draw multiple squiggles on the screen.
  2789.   ' each squiggle is assign a random color at the
  2790.   ' start, then the head travels randomly and the
  2791.   ' tail is erased
  2792.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  2793.   Dim il As Long, jl As Long, kl As Long
  2794.   Static SquigNumb As Integer
  2795.   Static SquigLen As Integer
  2796.   Static EndPointer As Integer, StartPointer As Integer
  2797.   ' if first time then initialize
  2798.   If PlotInit = False Then
  2799.    'see if we need to reset changes made from previous init
  2800.    If PlotEnd = False Then
  2801.     'check if saver is permitted to run
  2802.     If CheckIfValidSaver(0) = 0 Then
  2803.       Exit Sub
  2804.     End If
  2805.     PlotInit = True
  2806.     Cls
  2807.     ForeColor = QBColor(15)
  2808.     SquigNumb = Rnd * 10 + 10
  2809.     SquigLen = Rnd * 100 + 50
  2810.     'Allocate Memory
  2811.     ReDim x1da(SquigLen, SquigNumb)  As Integer
  2812.     ReDim y1da(SquigLen, SquigNumb)  As Integer
  2813.     ReDim x1sa(SquigNumb) As Single
  2814.     ReDim y1sa(SquigNumb) As Single
  2815.     ReDim vx1sa(SquigNumb) As Single
  2816.     ReDim vy1sa(SquigNumb) As Single
  2817.     ReDim ax1sa(SquigNumb) As Single
  2818.     ReDim ay1sa(SquigNumb) As Single
  2819.     ReDim Colors(SquigNumb) As Long
  2820.     Pointer = 1
  2821.     'Print "Clearing Array"
  2822.     For j = 1 To SquigNumb
  2823.     'determine initial position of line
  2824.     x1sa(j) = Rnd * ScaleWidth
  2825.     y1sa(j) = Rnd * ScaleHeight
  2826.     For i = 1 To SquigLen
  2827.         x1da(i, j) = x1sa(j)
  2828.         y1da(i, j) = y1sa(j)
  2829.     Next i
  2830.     Next j
  2831.     'find background color
  2832.     m = QBColor(0)
  2833.     ' get colors
  2834.     For ii = 1 To SquigNumb
  2835.     Colors(ii) = GetBrightNonGray()
  2836.     Next ii
  2837.     'Calculate velocity limits
  2838.     MaxSpeedX = ScaleWidth * 15! / 800
  2839.     MaxSpeedY = ScaleWidth * 15! / 600
  2840.   Else 'reset changes done by previous init
  2841.     ReDim x1da(0, 0)  As Integer
  2842.     ReDim y1da(0, 0)  As Integer
  2843.     ReDim x1sa(0) As Single
  2844.     ReDim y1sa(0) As Single
  2845.     ReDim vx1sa(0) As Single
  2846.     ReDim vy1sa(0) As Single
  2847.     ReDim ax1sa(0) As Single
  2848.     ReDim ay1sa(0) As Single
  2849.     ReDim Colors(0) As Long
  2850.     ClearScreen
  2851.   End If
  2852.   Else  ' put run code here
  2853.     'find where tail line went to
  2854.     If Pointer < SquigLen Then
  2855.         EndPointer = Pointer + 1
  2856.     Else
  2857.         EndPointer = 1
  2858.     End If
  2859.     'find where new line goes
  2860.     If Pointer > 1 Then
  2861.         StartPointer = Pointer - 1
  2862.     Else
  2863.         StartPointer = SquigLen
  2864.     End If
  2865.     If Rnd < .1 Then 'change a color 10% of the time
  2866.       ii = Int(Rnd * SquigNumb + 1)' get random squiggle to change
  2867.       If ii > SquigNumb Then ii = 1
  2868.       Colors(ii) = GetBrightNonGray()
  2869.     End If
  2870.     For j = 1 To SquigNumb
  2871.         'Erase tails of squigles
  2872.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x1da(EndPointer, j), y1da(EndPointer, j)), m
  2873.         'Save new points
  2874.         x1da(Pointer, j) = x1sa(j)
  2875.         y1da(Pointer, j) = y1sa(j)
  2876.         'Draw front of Squigles
  2877.         Line (x1da(StartPointer, j), y1da(StartPointer, j))-(x1da(Pointer, j), y1da(Pointer, j)), Colors(j)
  2878.     Next j
  2879.     'Move pointer to next item
  2880.     Pointer = Pointer + 1
  2881.     If Pointer > SquigLen Then
  2882.         Pointer = 1
  2883.     End If
  2884.     For j = 1 To SquigNumb
  2885.         'determine new acceleration
  2886.         ax1sa(j) = Rnd * 4 - 2
  2887.         ay1sa(j) = Rnd * 4 - 2
  2888.         'calculate new position
  2889.         x1sa(j) = x1sa(j) + vx1sa(j)
  2890.         y1sa(j) = y1sa(j) + vy1sa(j)
  2891.         'calculate new velocity
  2892.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > 20 Then vx1sa(j) = 0: ax1sa(j) = 0
  2893.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > 20 Then vy1sa(j) = 0: ay1sa(j) = 0
  2894.         'check if off screen
  2895.         If (x1sa(j) > ScaleWidth) Then
  2896.         x1sa(j) = ScaleWidth
  2897.         'change direction
  2898.         vx1sa(j) = -Abs(vx1sa(j))
  2899.         ElseIf (x1sa(j) < 0) Then
  2900.         x1sa(j) = 0
  2901.         'change direction
  2902.         vx1sa(j) = Abs(vx1sa(j))
  2903.         End If
  2904.         If (y1sa(j) > ScaleHeight) Then
  2905.         y1sa(j) = ScaleHeight
  2906.         'change direction
  2907.         vy1sa(j) = -Abs(vy1sa(j))
  2908.         ElseIf (y1sa(j) < 0) Then
  2909.         y1sa(j) = 0
  2910.         'change direction
  2911.         vy1sa(j) = Abs(vy1sa(j))
  2912.         End If
  2913.     Next j
  2914.   End If
  2915. End Sub
  2916. Sub Stretch ()
  2917.     Dim x As Integer, y As Integer
  2918.     Static ShadowDC As Integer
  2919.     Static oldBM As Integer
  2920.   ' does a StretchBlt from a random box within the Original
  2921.   ' image and then displays it on the screen
  2922.   ' if first time then initialize
  2923.   If PlotInit = False Then
  2924.     'see if we need to reset changes made from previous init
  2925.     If PlotEnd = False Then
  2926.     'check if saver is permitted to run
  2927.     If CheckIfValidSaver(1) = 0 Then
  2928.       Exit Sub
  2929.     End If
  2930.     'see how many colors display can handle
  2931.     If TotalNumColors <= 256 Then 'see if palette based
  2932.       LogFile ("Saver does not work in palette display mode: " + Str$(PlotType)), 0
  2933.       NextSelection 'jump to next since this does not work
  2934.             'well with palettes
  2935.       Exit Sub
  2936.     End If
  2937.     ' set tick rate down
  2938.     Tick.Interval = 300
  2939.     ' start with original screen
  2940.     picture = original.Image
  2941.     ' start temp form same as original
  2942.     DC = original.hDC
  2943.     BitBlt hDC, 0, 0, ScaleWidth, ScaleHeight, DC, 0, 0, &HCC0020
  2944.     'BitBlt Temp.hDC, 0, 0, ScaleWidth, ScaleHeight, hDC, 0, 0, &HCC0020
  2945.     'create hidden DC
  2946.     'ShadowDC = CreateCompatibleDC(hDC)
  2947.     'oldBM = SelectObject(ShadowDC, Original.Image)
  2948.     PlotInit = True
  2949.     'initial position is 1:1 copy
  2950.     x1 = 0
  2951.     y1 = 0
  2952.     x2 = ScaleWidth
  2953.     y2 = ScaleHeight
  2954.     'Calculate velocity limits
  2955.     MaxSpeedX = ScaleWidth * 15! / 800
  2956.     MaxSpeedY = ScaleWidth * 15! / 600
  2957.     ' zero initial velocity
  2958.     vx1 = MaxSpeedX * Rnd
  2959.     vy1 = MaxSpeedY * Rnd
  2960.     vx2 = -MaxSpeedX * Rnd
  2961.     vy2 = -MaxSpeedY * Rnd
  2962.     Pattern = &HCC0020 'Source Copy
  2963.   Else 'reset changes done by previous init
  2964.     ClearScreen
  2965.     'reset tick rate
  2966.     Tick.Interval = 50
  2967.     'destroy Device context
  2968.     'i = SelectObject(ShadowDC, oldBM)
  2969.     'i = DeleteDC(ShadowDC)
  2970.   End If
  2971.   Else  ' put run code here
  2972.     'make sure x1,y1 less than x2,y2 or swap
  2973.     If x1 > x2 Then x = x1: x1 = x2: x2 = x
  2974.     If y1 > y2 Then y = y1: y1 = y2: y2 = y
  2975.     'make sure that source box size does not
  2976.     'go below a minimum
  2977.     If x2 - x1 < 40 Then x2 = x1 + 40
  2978.     If y2 - y1 < 40 Then y2 = y1 + 40
  2979.     'Stretch Box from x1,y1 to x2,y2 onto display
  2980.     ' direct route does not work right:
  2981.     'DC = Original.hDC
  2982.     'i = StretchBlt(hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, DC, x1, y1, x, y, &HCC0020)
  2983.     'indirect route does not work on pallete display modes:
  2984.     DC = original.hDC
  2985.     x = x2 - x1: y = y2 - y1
  2986.     i = StretchBlt(temp.hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, DC, x1, y1, x, y, &HCC0020)
  2987.     ' now that it has been stretched, write to display
  2988.     DC = temp.hDC
  2989.     BitBlt hDC, 0, 0, ScaleWidth, ScaleHeight, DC, 0, 0, &HCC0020
  2990.     'try this method:
  2991.     'i = StretchBlt(hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, ShadowDC, x1, y1, x, y, &HCC0020)
  2992.     'determine new acceleration
  2993.     ax1 = Rnd - .5
  2994.     ay1 = Rnd - .5
  2995.     ax2 = Rnd - .5
  2996.     ay2 = Rnd - .5
  2997.         
  2998.     'calculate new position
  2999.     x1 = x1 + vx1
  3000.     y1 = y1 + vy1
  3001.     x2 = x2 + vx2
  3002.     y2 = y2 + vy2
  3003.     'calculate new velocity
  3004.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  3005.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  3006.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  3007.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  3008.     'check if off screen
  3009.     If (x1 >= ScaleWidth) Then
  3010.         'change direction
  3011.         vx1 = -Abs(vx1)
  3012.         x1 = ScaleWidth - 1
  3013.     ElseIf (x1 < 0) Then
  3014.         'change direction
  3015.         vx1 = Abs(vx1)
  3016.         x1 = 0
  3017.     End If
  3018.     If (y1 >= ScaleHeight) Then
  3019.         'change direction
  3020.         vy1 = -Abs(vy1)
  3021.         y1 = ScaleHeight - 1
  3022.     ElseIf (y1 < 0) Then
  3023.         'change direction
  3024.         vy1 = Abs(vy1)
  3025.         y1 = 0
  3026.     End If
  3027.     'check if off screen
  3028.     If (x2 >= ScaleWidth) Then
  3029.         'change direction
  3030.         vx2 = -Abs(vx2)
  3031.         x2 = ScaleWidth - 1
  3032.     ElseIf (x2 < 0) Then
  3033.         'change direction
  3034.         vx2 = Abs(vx2)
  3035.         x2 = 0
  3036.     End If
  3037.     If (y2 >= ScaleHeight) Then
  3038.         'change direction
  3039.         vy2 = -Abs(vy2)
  3040.         y2 = ScaleHeight - 1
  3041.     ElseIf (y2 < 0) Then
  3042.         'change direction
  3043.         vy2 = Abs(vy2)
  3044.         y2 = 0
  3045.     End If
  3046.   End If
  3047. End Sub
  3048. Sub Tick_Timer ()
  3049.     ' check elapsed time to see if need to change type of plot
  3050.     ' also check if past midnight
  3051.     CurrentTime = Timer
  3052.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then
  3053.     MaxTime = MaxChangeMinutes * 60 + CurrentTime ' calculate time in seconds
  3054.     ZOrder 0' make sure form is still on top
  3055.     'clear old saver
  3056.     PlotInit = False: PlotEnd = True
  3057.     LogFile ("Cleanup of" + Str$(PlotType)), 1
  3058.     RunSelection 'just clean up after running
  3059.     'LogFile ("After Cleanup of " + Str$(PlotType)), 1
  3060.     'see if we want random selection
  3061.     NextSelection 'get new PlotType
  3062.     PlotInit = False: PlotEnd = False
  3063.     'remove password prompt
  3064.     PasswordLabel.Visible = False
  3065.     End If
  3066.     LastTime = CurrentTime
  3067.     RunSelection
  3068. End Sub
  3069.