home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / UTILS / AMOSPRO4.DMS / in.adf / Tutorials / Fade.AMOS / Fade.amosSourceCode
Encoding:
AMOS Source Code  |  1992-09-28  |  6.5 KB  |  206 lines

  1. '*************************** 
  2. '*    AMOS Professional    * 
  3. '*                         * 
  4. '*           FADE          * 
  5. '*                         * 
  6. '* (c) Europress Software  * 
  7. '*                         * 
  8. '*     Ronnie Simpson      * 
  9. '*************************** 
  10. '
  11. '------------------------------------------- 
  12. 'SETTING UP
  13. '------------------------------------------- 
  14. 'Standard form of Fade. (fade all colours in a palette to black)   
  15. '
  16. '        +----->The command (Smoothly blend all colours to black)
  17. '        |  +----->The speed (in vertical blanks) of each colour change  
  18. '        |  |     +----->Wait until all colours have changed 
  19. '        |  |     |   +----->The number of vertical blank periods required 
  20. '        |  |     |   |
  21. '        ^  ^     ^   ^
  22. '      Fade 5 : Wait 60
  23. '
  24. 'The standard form of this command takes each colour index in a palette and  
  25. 'reduces its value by 1 until it reaches 0 (black) 
  26. 'eg.  if colour 1 was initially $585 then the sequence would be- 
  27. '     $585 - $474 - $363 - $252 - $141 - $030 - $020 - $010 - $000 
  28. '
  29. 'The speed of the fade is counted in vertical blank periods (50 per second)
  30. 'ie. Fade 1 is the fastest and Fade 25 would be slow, with each colour change  
  31. 'taking half a second. 
  32. '
  33. 'The wait command is used to halt program operation until the fade is
  34. 'complete and can be calculated as follows:- 
  35. '                     Wait time=fade speed * 15  
  36. '  
  37. 'eg.   Fade 1 : Wait 15       Fade 2 : Wait 30       Fade 10 : Wait 150  
  38. '
  39. '------------------------------------------- 
  40. 'EXTENDED FORMS OF FADE
  41. '------------------------------------------- 
  42. 'Fade to a new palette 
  43. '
  44. 'eg.    Fade 2,$222,$444,$666,$888,$AAA : Wait 30
  45. '
  46. 'This form of fade would slowly alter the palette to the new colour values 
  47. 'used in the instruction.
  48. 'Any number of colours can be altered up to the maximum for the screen mode
  49. 'and any that are left out will be totally unnafected by the fade.   
  50. 'For example to alter only colours 0,1,2,5 and 7 you would use:- 
  51. '
  52. '         Fade 5,$0,$F0,$F00,,,$639,,$936 : Wait 60
  53. '
  54. '------------------------------------------- 
  55. 'Fade to a palette taken from another screen 
  56. '
  57. '     Fade speed to screen number
  58. '
  59. 'eg.     Fade 5 To 1   (Fade speed 5 to colours of palette at screen 1)
  60. '        Fade 1 To 2   (Fade speed 1 to colours of palette at screen 2)
  61. '
  62. '--------------------------- 
  63. 'Fade to the sprite palette  
  64. '
  65. '     Fade speed to -1  (use any negative number)  
  66. '  
  67. 'eg.     Fade 5 To -1   (Fade speed 5 to colours of Sprite palette)  
  68. '
  69. 'When a fade to screen or sprite palette is made, an optional 16 bit mask    
  70. 'may be used to load just part of the palette  
  71. '
  72. '        Fade speed to screen number , mask
  73. '
  74. 'eg.     Fade 5 To 1,%1010101010101010   (fade every second colour)
  75. '        Fade 5 To 1,%1110   (fade colours 1,2,3 and ingnore colour 0) 
  76. '
  77. 'Each colour is represented by 1 bit of the mask, if a bit is set to 1   
  78. 'then that colour will be changed.   
  79. '------------------------------------------- 
  80. 'WORKING EXAMPLE 
  81. '--------------------------------------------------------------  
  82. 'The following program opens 2 screens, plots some graphics and  
  83. 'demonstrates the various uses of the fade instruction.
  84. '--------------------------------------------------------------
  85. Rem *** Open and tidy the screens
  86. '
  87. Screen Open 1,640,200,16,Hires
  88. Screen Open 0,640,200,16,Hires
  89. Screen To Front 0 : Screen 0
  90. Flash Off : Cls 0 : Hide 
  91. Ink 8,0 : Text 270,199,"PLEASE WAIT......"
  92. '
  93. '
  94. Rem *** Call a procedure to draw the graphics
  95. '
  96. INIT_SCREEN
  97. Ink 8,0 : Text 195,199,"PRESS AND HOLD ANY MOUSE KEY TO QUIT"
  98. '
  99. '
  100. Rem *** start the main loop
  101. '
  102. Do 
  103.    '
  104.    '
  105.    Rem *** Select the type of fade  
  106.    '
  107.    TYPE=Rnd(5)
  108.    '
  109.    '--------------------------------------------------------- 
  110.    Rem *** If TYPE=1 then fade a palette to the hidden screen 
  111.    '
  112.    If TYPE=1
  113.       R=Rnd(2)+1
  114.       Screen 1
  115.       SPEED=1 : Gosub(R) : Wait 15
  116.       Exit If Mouse Key
  117.       Screen 0
  118.       '
  119.       '
  120.       Rem *** now perform a Fade to screen with mask 
  121.       Fade 5 To 1,%101010101010101 : Wait 45
  122.       Exit If Mouse Key
  123.    End If 
  124.    '--------------------------------------------------------- 
  125.    '
  126.    Rem *** Select a random fade type (R) and a random speed 
  127.    '
  128.    R=Rnd(12)+1
  129.    SPEED=Rnd(10)+1
  130.    '
  131.    '
  132.    Rem *** Using a subroutine perform the fade
  133.    '
  134.    Gosub(R) : Wait SPEED*15
  135.    Exit If Mouse Key
  136.    '
  137.    '
  138.    Rem *** Go back and do it all again
  139. Loop 
  140. '  
  141. '
  142. Edit 
  143. '
  144. '
  145. Rem *** The subroutines
  146. '
  147. 1 Fade SPEED,0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$A,$B,$C,$D,$E,$F : Return 
  148. 2 Fade SPEED,0,$10,$20,$30,$40,$50,$60,$70,$80,$90,$A0,$B0,$C0,$D0,$E0,$F0 : Return 
  149. 3 Fade SPEED,0,$100,$200,$300,$400,$500,$600,$700,$800,$900,$A00,$B00,$C00,$D00,$E00,$F00 : Return 
  150. 4 Fade SPEED,0,$101,$202,$303,$404,$505,$606,$707,$808,$909,$A0A,$B0B,$C0C,$D0D,$E0E,$F0F : Return 
  151. 5 Fade SPEED,0,$11,$22,$33,$44,$55,$66,$77,$88,$99,$AA,$BB,$CC,$DD,$EE,$FF : Return 
  152. 6 Fade SPEED,0,$110,$220,$330,$440,$550,$660,$770,$880,$990,$AA0,$BB0,$CC0,$DD0,$EE0,$FF0 : Return 
  153. 7 Fade SPEED,0,$111,$222,$333,$444,$555,$666,$777,$888,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF : Return 
  154. 8 Fade SPEED,0,$F00,$E00,$D00,$C00,$B00,$A00,$901,$802,$703,$604,$505,$406,$307,$208,$109 : Return 
  155. 9 Fade SPEED,0,$F0,$E0,$D0,$C0,$B0,$A0,$91,$82,$73,$64,$55,$46,$37,$28,$19 : Return 
  156. 10 Fade SPEED : Return 
  157. 11 Fade SPEED,0,,0,,0,,0,,0,,0,,0,,0 : Return 
  158. 12 Fade SPEED,,0,,0,,0,,0,,0,,0,,0,,0 : Return 
  159. 13 Fade SPEED,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF : Return 
  160. '
  161. '
  162. Rem *** The draw graphics procedure
  163. Procedure INIT_SCREEN
  164.    Palette 0,$111,$222,$333,$444,$555,$666,$777,$888,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF
  165.    For X=0 To 14
  166.       Ink X+1
  167.       Draw X,0 To X,104
  168.       Draw 29-X,0 To 29-X,104
  169.       Draw X+30,0 To X+30,104
  170.       Draw 59-X,0 To 59-X,104
  171.       Draw X+60,0 To X+60,104
  172.       Draw 89-X,0 To 89-X,104
  173.       Draw X+90,0 To X+90,104
  174.       Draw 119-X,0 To 119-X,104
  175.       Draw X+120,0 To X+120,104
  176.       Draw 149-X,0 To 149-X,104
  177.    Next 
  178.    For Y=0 To 14
  179.       Ink Y+1
  180.       Draw 170,Y To 319,Y
  181.       Draw 170,29-Y To 319,29-Y
  182.       Draw 170,Y+30 To 319,Y+30
  183.       Draw 170,59-Y To 319,59-Y
  184.       Draw 170,Y+60 To 319,Y+60
  185.       Draw 170,89-Y To 319,89-Y
  186.       Draw 170,Y+90 To 319,Y+90
  187.    Next 
  188.    For X=0 To 90
  189.       Add C,1,1 To 15 : Ink C
  190.       Box 100-X,153-X/2 To 100+X,153+X/2
  191.    Next 
  192.    For X=1 To 45
  193.       Add C,1,1 To 15 : Ink C
  194.       Circle 540,153,X
  195.    Next 
  196.    For X=4 To 120
  197.       Add C,1,1 To 15 : Ink C
  198.       Ellipse 320,153,X,X/4
  199.    Next 
  200.    Clip 350,0 To 630,104
  201.    For X=350 To 740
  202.       Add C,1,1 To 15 : Ink C
  203.       Draw X,0 To X-X,0+X
  204.    Next 
  205.    Clip 
  206. End Proc