-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14-appendix-f-copper-lists.html
267 lines (212 loc) · 13 KB
/
14-appendix-f-copper-lists.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
<!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>App. F: Copper Lists - 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/14-appendix-f-copper-lists.html">
</head>
<body>
<section>
<h1>App. F: Copper Lists</h1>
</section>
<section id="01-the-amiga-co-processor">
<h2>The Amiga co-processor</h2>
<p>
While AMOS Professional allows you to harness the power of the Amiga with the greatest of
ease, it has to perform a great deal of work behind the scenes when manipulating entire screens
at great speed. The source of much of this power is a special hardware chip called the "co-
processor", or copper.</p>
<p>
The copper is in effect a simple micro-processor, with its own separate programs, and its own
unique memory registers. It supports only three instructions, MOVE, WAIT and SKIP, and these
commands insert values into the computer's hardware registers at certain points on the display,
which change the way pictures are drawn on the screen.</p>
<p>
These hardware registers hold the values that determine the precise appearance of the display,
such as its size and position, as well as the number of colours. For example, all the colour values
used by AMOS Professional screens are held in the colour registers from $180 to $1BE. Because
the appearance of every line displayed on your screen is controlled by the copper, a massive
number of special effects can be created by changing these registers during a program, using a
list of instructions known as the "copper list".</p>
</section>
<section id="02-the-copper-list">
<h2>The Copper List</h2>
<p>
The copper list is executed automatically, fifty times every second, at the same time that the
screen is re-drawn. This is how the AMOS Professional RAINBOW commands work, waiting for
a rainbow line to appear on screen and then immediately poking a new value into the selected
colour register. This causes dramatic colour changes, depending on the position of the line in the
display.</p>
<p>
Exactly the same process can be applied to the rest of the display system, and by placing the
appropriate value into certain hardware registers at exactly the right moment, the position, type
and size of the display can be changed at will! Unfortunately, the copper list is notoriously
difficult to manipulate, and many competent programmers have failed to master its mysteries.</p>
<p>
Although the copper is automatically managed by AMOS Professional, you cannot expect the
system to teach you everything about the inner workings of the Amiga's hardware. Indeed,
Francois Lionet has written AMOS Professional to save you the years of hard work and
experience needed to gain such expert knowledge. However, for those expert programmers
who insist on meddling with the copper directly, AMOS Professional includes a powerful trap-
door into the realms of the co-processor. This allows advanced programmers to generate
astounding effects, and also allows novices to send their displays berserk and crash their
computers. You have been warned!</p>
</section>
<section id="03-accessing-the-copper">
<h2>Accessing the Copper</h2>
<h3 class="command" id="i-copper-off">COPPER OFF</h3>
<p><i>instruction: turn off the standard copper list</i><br>
<b>Copper Off</b></p>
<p>
If you ignore the warning in the last paragraph and use this instruction, the automatic copper
generation that forms the backbone of the AMOS Professional system is turned off.
From now on, you are on your own!</p>
<p>
You should now understand that AMOS Professional actually holds <b>two</b> separate copper lists in
memory, and the principle is very similar to the logical and physical screens of the DOUBLE
BUFFER system.</p>
<p>
The <b>logical</b> copper list is the list being created from AMOS Professional Basic, and it is
completely invisible. The <b>physical</b> list holds the copper instructions that are generating the
current TV display. It cannot be accessed from AMOS Professional at all, as this would corrupt
the display completely. As a default, these copper lists are limited to 12k in length, which is the
equivalent to approximately six thousand instructions. This limit may be increased using an
option from the Interpreter set-up dialogue box.</p>
<p>Copper lists can be defined in one of three ways:</p>
<p>
The first method is to enter the copper list using a combination of the COP MOVE and COP
WAIT instructions, from AMOS Professional Basic.</p>
<p>
The second way is to find the address of the logical copper list, using COP LOGIC. This can then
be manipulated directly using DEEK and DOKE, allowing minor modifications to be made to
the existing screen without having to generate a completely new copper list at all. This is perfect
for the creation of rainbow effects.</p>
<p>
The third alternative is for assembly language buffs. Copper lists can be generated using
machine code, and as before, the current address is available via the COP LOGIC function. Note
that this address will change during the course of a program, and it must be entered every time
the machine code routine is called.</p>
</section>
<section id="04-recommended-procedures">
<h2>Recommended Procedures</h2>
<p>
If you want to create copper lists from beginning to end, you must take personal control over
the hardware Sprites, the display positioning, the location of screens, and their sizes. You must
then ensure that the resulting screens have the correct amount of memory, before loading the
appropriate registers with the addresses of the required bitmaps. This can be achieved with the
LOGBASE function.</p>
<p>
Additionally, if you intend to use DOUBLE BUFFER, a separate copper list must be produced
for both the logical and physical screens. Here is the procedure:</p>
<ul>
<li>Define the copper list for the first screen.</li>
<li>Switch copper lists using the COP SWAP command.</li>
<li>Swap between the logical and physical screens with SCREEN SWAP.</li>
<li>Define a copper list for the second screen.</li>
</ul>
<p>
Providing that all is well, you may access your screens using -all of the normal AMOS
Professional drawing commands, including SCREEN COPY, DRAW, PRINT and PLOT. As well
as this, there should be no problems using Blitter Objects.</p>
<p>
However, multiple screens and Sprites are only supported by the standard AMOS Professional
copper system, so you cannot use SCREEN OPEN, SCREEN DISPLAY, RAINBOWS or any of
the SPRITE commands. If you need to generate such effects, you will have to program them for
yourself! For those of you who wish to give up now, the following command may be useful.</p>
<h3 class="command" id="i-copper-on">COPPER ON</h3>
<p><i>instruction: re-start automatic copper generation</i><br>
<b>Copper On</b></p>
<p>
The COPPER ON command re-starts all standard copper calculations, and returns AMOS
Professional back to normal. The experts (and foolhardy) may now continue.</p>
<h3 class="command" id="i-cop-move">COP MOVE</h3>
<p><i>instruction: write a MOVE instruction to current copper list</i><br>
<b>Cop Move</b> address,value</p>
<p>
MOVE is an internal instruction used by the copper, and it is very similar to the AMOS
Professional DOKE command. It inserts a MOVE command into the current logical copper list,
by copying a value from 0 to 65535 into the selected register address. The address refers to a
copper register from $7F to $1BE.</p>
<h3 class="command" id="i-cop-movel">COP MOVEL</h3>
<p><i>instruction: write a long MOVE instruction to copper list</i><br>
<b>Cop Movel</b> address,value</p>
<p>
This is a special option from AMOS Professional Basic, which generates a matched pair of
MOVE commands in the new copper list. These load a 32-bit (long word) value into the selected
address, exactly like a normal LOKE instruction.</p>
<h3 class="command" id="i-cop-wait">COP WAIT</h3>
<p><i>instruction: insert a WAIT instruction into copper list</i><br>
<b>Cop Wait</b> x,y<br>
<b>Cop Wait</b> x,y,xmask,ymask<br>
<p>
The COP WAIT command enters a WAIT instruction at the current position in the copper list.
WAIT forces the copper to stop in its tracks until the screen has been drawn at the specified
hardware coordinates x,y. The copper then continues from the next instruction in the copper
list.</p>
<p>
WAIT is usually called immediately before a MOVE command, creating a pause until the display
reaches a specific screen line. The MOVE instruction is then used to change the attributes of the
screen area below this line. Rainbows are an excellent example of this technique, with each line
of the rainbow generated with a pair of commands like this:</p>
<code class="prefix ex">Cop Wait 0,Y : <comment>Rem Y is starting coordinate of next colour shift</comment>
Cop Move $180,$777 : <comment>Rem $180 is address of colour 0 and $777 is new colour</comment>
</code>
<p>
The x-coordinate is a hardware coordinate from 0 to 448. Since the Amiga is only capable of
performing this test every four screen points, this coordinate is rounded to the nearest multiple
of four.</p>
<p>
The y-coordinate can be any value from 0 to 312. Normally, coordinates from 256 to 312 require
special programming, but AMOS Professional generates the correct instructions automatically,
so there is no need for concern! Here are some examples:</p>
<code class="prefix ex">Cop Wait 0,130: <comment>Rem Wait for screen to reach hardware coords 0,100</comment>
Cop Wait 0,300: <comment>Rem Wait for line 300</comment>
Cop Wait 12,10: <comment>Rem Wait for coordinates 12,10 to arrive</comment>
</code>
<p>
The optional xmask and ymask parameters are bit-mask values which allow for a pause until the
screen coordinates satisfy a specific combination of bits. The default value is $1FF. For example:</p>
<code class="prefix ex">Cop Wait 0,2,$1FF,%11 : <comment>Rem Await next EVEN scan line</comment></code>
<h3 class="command" id="i-cop-reset">COP RESET</h3>
<p><i>instruction: re-set copper list pointer</i><br>
<b>Cop Reset</b></p>
<p>
This command is used to add a pair of MOVE commands, forcing the copper list to re-start from
the very first instruction. This may be used to generate simple loops.</p>
<h3 class="command" id="i-cop-swap">COP SWAP</h3>
<p><i>instruction: swap logical and physical copper lists</i><br>
<b>Cop Swap</b></p>
<p>
The COP SWAP command switches over the logical and physical copper lists. The new copper
list will now be flicked into place, and the results will be shown after the next vertical blank
period. For example:</p>
<code class="prefix ex">Cop Swap : Wait Vbl</code>
<h3 class="command" id="fn-cop-logic">COP LOGIC</h3>
<p><i>function: give address of logical copper list</i><br>
address=<b>Cop Logic</b></p>
<p>
This command returns the absolute address of the logical copper list in memory. It can be used
to manipulate the copper list directly from AMOS Professional Basic. Lists can also be generated
by using assembly language.</p>
</section>
<footer>
<a href="14-appendix-e-memory-bank-structures.html" rel="prev">App. E: Memory Bank Structures</a>
<a href="./">Contents</a>
<a href="14-appendix-g-command-index.html">Index</a>
</footer>
</body>
</html>