-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06-03-screen-effects.html
351 lines (280 loc) · 15.9 KB
/
06-03-screen-effects.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!doctype html>
<html lang="en">
<head>
<!--
This Amos Professional Manual is written by asymetrix for the Amiga community and should stay completely FREE FOREVER.
Created 2008. :)
It was created from the original AMOS Professional Manual by Europress Software Ltd.
It has been updated by Fredrik Rambris.
-->
<title>Screen Effects - AMOS Professional Manual</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="keywords" content="Amos Professional, Amiga, Programming, Basic, Francois Lionet, Europress Software Ltd, Amos, computing, code, AmigaDOS">
<meta name="author" content="asymetrix,Fredrik Rambris">
<link rel="GitHub" href="https://github.com/fredrik-rambris/amospromanual">
<meta property="og:site_name" content="AMOS Professional Manual">
<meta property="og:image" content="https://amospromanual.dev/images/cover.jpg">
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="canonical" href="https://amospromanual.dev/06-03-screen-effects.html">
</head>
<body>
<section>
<h1>Screen Effects</h1>
<p>The AMOS Professional programmer expects to achieve superb visual effects with simple,
economic commands. Classic cinematic and video techniques are readily available, as well as
more spectacular routines that are only made possible by the power of the computer.</p>
<p>When the image of one screen dissolves and melts into the image of another screen, various
"fade" effects are produced.</p>
<h3 class="command" id="i-appear">APPEAR</h3>
<p><i>instruction: fade between two screens</i><br>
<b>Appear</b> source screen <b>To</b> destination screen, pixels<br>
<b>Appear</b> source screen <b>To</b> destination screen, number pixels, range</p>
<p>
This command creates a fade between two pictures. Choose the number of the source screen
where the original picture comes from, then the number of the destination screen whose picture
it fades into. LOGIC and PHYSIC functions can be substituted for screen numbers, if required.</p>
<p>
Next determine a value that will cause the desired effect, by setting the number of pixel points
on the screen, ranging from 1 pixel all the way up to every pixel in the display.</p>
<p>
Normally APPEAR affects the whole of your screen area, but there is an optional parameter that
causes only part of the screen to be faded. Because screens are drawn from top to bottom, set the
area to be faded by adding the range of the number of pixels from the top of the screen.
For example:</p>
<code class="prefix edit">Load "AMOSPro_Tutorial:Objects/Bobs.Abk"
Flash Off : Get Bob Palette
Paste Bob 100,0,1
Wait 100
Screen Open 1,320,90,16,Lowres
Flash Off : Get Bob Palette
Appear 0 To 1,1,28800
</code>
<p>
That example fades the top part of your default screen into the newly opened Screen 1.
Obviously, the appearance of fades will vary, depending on the screen mode being used.</p>
<h3 class="command" id="i-fade">FADE</h3>
<p><i>instruction: blend colours to new values</i><br>
<b>Fade</b> speed<br>
<b>Fade</b> speed,colour list<br>
<b>Fade</b> speed <b>To</b> screen number<br>
<b>Fade</b> speed <b>To</b> screen number,mask</p>
<p>
The classic "fade to black" movie effect takes the current palette and gradually fades all values to
zero. Set the speed of the fade by choosing the number of vertical blank periods between each
colour change. Try this:</p>
<code class="prefix edit">Flash Off : Curs Off
Centre "GOOD NIGHT"
Fade 5
</code>
<p>
Fade effects are executed using interrupts, so it is sensible to wait until the fade has ended
before going on to the next program instruction. The length of wait required can be calculated
with this formula:</p>
<code class="prefix edit">Fade 5 : Wait 75</code>
<p>
By adding a list of colour values, the fade effect will generate a new palette directly from your
list, and it is used like this:</p>
<code class="prefix edit">Flash Off : Curs Off
Centre "RED SKY AT NIGHT"
Fade 10,$100,$F00,$300
Wait 150
</code>
<p>
Any number of new colours can be set up like this, depending on the maximum number
allowed in your current screen mode. Any settings that are omitted will leave those colours
completely unaffected by the fade, as long as you include the right number of commas.
For example:</p>
<code class="prefix edit">Fade 5,,$100,,,$200,$300</code>
<p>
There is an even more powerful use of the FADE command, which takes the palette from
another screen and fades it into the colours of the current screen. Set the speed of the fade as
usual, then give the number of the screen whose palette is to be accessed. By using a negative
number instead of a screen number, the palette from the sprite bank will be loaded instead.</p>
<p>
There is one more parameter that can be added, and this creates a mask that only permits
certain colours to be faded in. Each colour is associated with a single bit in the pattern,
numbered from 0 to 15, and any bit that is set to 1 will be affected by a colour change.
For example:</p>
<code class="prefix edit">Load "AMOSPro_Tutorial:Objects/Bobs.Abk"
Screen Open 1,320,90,16,Lowres
Flash Off : Get Object Palette
Paste Bob 100,0,1
Wait 100
Fade 1 To 0,%01111000011001010
Wait 15
</code>
</section>
<section id="01-flashing-colours">
<h2>Flashing colours</h2>
<p>You will already be aware that colour index number 3 is pre-set to flash on and off, and is the</p>
<p>
default setting for the text cursor. By using interrupts, any colour index can be cycled through a
series of colour changes, producing complex flashing effects.</p>
<h3 class="command" id="i-flash">FLASH</h3>
<p><i>instruction: set flashing colour sequence</i><br>
<b>Flash</b> index number,"(colour,delay)(colour,delay)(colour,delay)..."<br>
<b>Flash</b> Off</p>
<p>
When FLASH is followed by the index number of any colour, that colour will display animated
flashing every time it is used, until FLASH OFF is called. Up to 16 colours can be cycled to
customise your flashing effects, and the rate of delay from one colour change to the next can be
individually set. Try this:</p>
<code class="prefix edit">Flash 1 ,"(0A0,10)(F0F,40)"</code>
<p>
In that example, the colour to be affected is set to index number 1. After the comma, the set of
quotation marks can contain up to 16 pairs of brackets, and each pair of brackets contains the
colour that is next on the list to be flashed, and the time it will appear for. Colour is set in RGB
component values, which are fully explained in the next Chapter. Delay time is set in units of a
50th of a second. So the last example has the effect of flashing colour number 1 between a green
value and a violet value once every second. The next example is more subtle:</p>
<code class="prefix edit">Cls : Centre "SILENT MOVIES"
Flash 1,"(111,4)(333,4)(555,4)(777,4)(555,7)(333,7)
Curs Off : Wait 250 : Flash Off
</code>
<h3 class="command" id="i-shift-up">SHIFT UP</h3>
<p><i>instruction: rotate colour values upwards</i><br>
<b>Shift Up</b> delay,first,last,flag</p>
<p>
This command takes the values held in the colour registers and shunts them forwards. The
delay between colour shifts is set in 50ths of a second, similarly to the FADE command.</p>
<p>
Next the values of the colours to be affected are set, from the first colour to the last colour in the
sequence. The first colour in the list will be copied to the second, the second to the third, and so
on until the last colour in the series is reached.</p>
<p>
Finally, a flag is set to either 0 or 1. When this flag is set to zero, the last colour is discarded, and
the rotation will cycle for the number of times it takes to replace all colours with the first colour
in the list. Alternatively, if the flag is set to one, the last colour index in the list is copied into the
first, causing the colours to rotate continuously on screen.</p>
<p>
Each of your screens can have its own set of animated colour rotations, and because they are
executed using interrupts they will not affect the running of your programs.</p>
<h3 class="command" id="i-shift-down">SHIFT DOWN</h3>
<p><i>instruction: rotate colour values downwards</i><br>
<b>Shift Down</b> delay,first,last,flag</p>
<p>
This command is identical to SHIFT UP, except for the fact that colours are rotated in the
opposite direction, so that the second colour is copied into the first, the third to the second, and
so on. With the final flag set to zero, all colours are eventually replaced with the last colour in
the list.</p>
<h3 class="command" id="i-shift-off">SHIFT OFF</h3>
<p><i>instruction: turn off all colour shifts for current screen</i><br>
<b>Shift Off</b></p>
<p>
Use this command to terminate all colour rotations previously set by the SHIFT UP and SHIFT
DOWN instructions.</p>
</section>
<section id="02-rainbow-effects">
<h2>Rainbow effects</h2>
<p>So far, most of the screen effects in this Chapter take a colour index and change its value over a
set period of time. AMOS Professional offers an alternative system, where colour indexes are
changed depending on specific screen locations. This means that a single colour index can be
used to generate hundreds of colours in some spectacular rainbow effects. Before any rainbows
can be conjured up, their parameters must first be set.</p>
<h3 class="command" id="i-set-rainbow">SET RAINBOW</h3>
<p><i>instruction: define a rainbow</i><br>
<b>Set Rainbow</b> number,index,height,red$,green$,blue$</p>
<p>Try the next example before analysing how it works:</p>
<code class="prefix edit">Set Rainbow 0,1,16,"(1,1,15)","",""
Rainbow 0,56,1,255
Curs Off : Flash Off
Locate ,12 : Centre "RED STRIPE"
</code>
<p>
Up to four different rainbows may be set up for later use, and SET RAINBOW is followed by an
identification number for this rainbow, from 0 to 3.</p>
<p>
The next parameter is the colour index that is to be changed, and only colours 0 to 15 can be
affected. In practice, this colour can be assigned a different value for each horizontal screen scan
line, if necessary.</p>
<p>
Following this, the height parameter sets the size of the table to be used for colour storage, in
other words, it sets the height of the rainbow in units, with each unit ready to hold one scan line
of colour. The size of this table can range from 16 to 65500, but only the first 280 or so lines can
be displayed on screen at once. So if your table is less than the physical height of your rainbow,
the colour pattern will be repeated on the screen.</p>
<p>
Finally, the Red, Blue and Green components of the rainbow colours are set up as strings, each
within their own brackets. The last example leaves out any reference to the Green and Blue
components, which is why the resulting effect is completely in the Red. These strings will be</p>
<p>
cycled to produce the final rainbow pattern, and their format comprises three values contained
in each relevant pair of brackets, as follows:</p>
<p>(number,step,count)</p>
<p>
Number refers to the number of scan lines assigned to one colour value. Think of it as
controlling the "speed" of the sequence. Step is a value to be added to the colour, which controls
the colour change. Count is simply the number of times this whole process is performed.</p>
<h3 class="command" id="i-rainbow">RAINBOW</h3>
<p><i>instruction: display a rainbow</i><br>
<b>Rainbow</b> number,offset,vertical position,height</p>
<p>
The last example also demonstrates the parameters of the RAINBOW command, which is used
to display one of the rainbows created with SET RAINBOW.</p>
<p>
The rainbow number is obvious, and refers to one of the four possible rainbow patterns from 0
to 3. The offset sets the value for the first colour in the table created with SET RAINBOW, and it
governs the cycling or repetition of the rainbow on screen.</p>
<p>
The vertical position is a coordinate which must have a minimum value of 40, and it affects the
starting point of the rainbow's vertical display on screen. If a lower coordinate is used, the
rainbow will be displayed from line number 40 onwards.</p>
<p>Finally, the height number sets the rainbow's vertical height in screen scan lines.</p>
<p>
Please note that normally only one rainbow at a time can be displayed at a particular scan line,
and the one with the lowest identification number will be drawn in front of any others
However, experienced Amiga users will be able to start more than one rainbow at the same line,
using the Copper. See <a href="14-appendix-f-copper-lists.html">Appendix F</a> for an explanation of this technique.</p>
<h3 class="command" id="i-rainbow-del">RAINBOW DEL</h3>
<p><i>instruction: delete a rainbow</i><br>
<b>Rainbow Del</b><br>
<b>Rainbow Del</b> number</p>
<p>
Use this command on its own to get rid of all rainbows that have been set up. If a rainbow
identity number is added, then only that particular rainbow will be deleted.</p>
<h3 class="command" id="resv-rain">RAIN</h3>
<p><i>function: change the colour of a rainbow line</i><br>
<b>Rain</b>(number,line)=colour</p>
<p>
This powerful rainbow instruction allows you to change the colour of any rainbow line to
value you choose. RAIN is followed by a pair of brackets containing the number of the rainbow
to be changed and the scan line number that is to be affected.</p>
<p>
The next example demonstrates the following technique. Rainbow number 1, with colour index
1, is given a colour table length of 4097, which is one entry for every colour value that will be
displayed on screen. The RGB values are left blank, to be set up by the first FOR ... NEXT
routine, that contains the RAIN command. The second FOR ... NEXT routine uses RAINBOW to
display a pattern 255 lines long, starting at scan line 40. The DO ... LOOP structure is used to
repeat the process.</p>
<code class="prefix edit">Curs Off : Centre "OVER THE RAINBOW"
Set Rainbow 1,1,4097,"","",""
For L=0 To 4095
Rain(1,L)=L
Next L
Do
For 0=0 To 4095-255 Step 4
Rainbow 1,C,40,255
Wait Vbl
Next C
Loop
</code>
</section>
<section id="03-the-copper-list">
<h2>The copper list</h2>
<p>The appearance of every line displayed on your screen is controlled by the Amiga's co-
processor, known as the "copper". The copper is a self-contained processor with its own special
set of instructions, and its own internal memory. A massive number of special effects can be
created by programming the copper, but the copper list is notoriously difficult to manipulate,
and many competent programmers have failed to master its mysteries.</p>
<p>A full discussion of the copper lists may be found in <a href="14-appendix-f-copper-lists.html">Appendix F</a> of this User Guide.</p>
</section>
<footer>
<a href="06-02-using-screens.html" rel="prev">Using Screens</a>
<a href="./">Contents</a>
<a href="14-appendix-g-command-index.html">Index</a>
<a href="06-04-graphics.html" rel="next">Graphics</a>
</footer>
</body>
</html>