Difference between revisions of "680x0:Copperlist"

From Amiga Coding
Jump to: navigation, search
(Copperlist information (instructions text ripped from Amiga Hardware Reference Manual))
 
Line 1: Line 1:
The copper is a part of the Agnus chip which can execute simple instructions timed
+
__NOTOC__
on the position of the screen which is being generated.
+
<div style="float: right; background-color: #f0fff0; padding: 10px; white-space: nowrap;">
 
+
==Example of a copperlist==
 
 
==Writing a copperlist==
 
 
 
A copperlist is often written like this:
 
 
 
 
<code><pre>
 
<code><pre>
  dc.w  $....,$....
 
  dc.w  $FFFF,$FFFE  ; end of the copperlist
 
 
</pre></code>
 
</pre></code>
 +
</div>
 +
==What is a copperlist==
 +
The copper is a small piece of the Agnus chip. It can be programmed to write to custom registers synchronized with certain positions of the display. The small programs which the copper runs are called copperlists.
  
A copperlist should allways end with $FFFF,$FFFE. This will wait for line (VP) 255, (HP) 243, which won't happen.
 
 
 
===WAIT===
 
<table border="0">
 
<tr><td style="vertical-align: top; padding-right: 40px;">
 
The WAIT instruction causes the Copper to wait until the video beam counters are equal to (or greater than) the coordinates specified in the instruction. While waiting, the Copper is off the bus and not using memory cycles.
 
 
The first instruction word contains the vertical and horizontal coordinates of the beam position. The second word contains enable bits that are used to form a "mask" that tells the system which bits of the beam position to use in making the comparison.
 
 
The following example WAIT instruction waits for scan line 150 ($96) with the horizontal position masked off.
 
 
        DC.W    $9601,$FF00    ;Wait for line 150,
 
                                ;  ignore horizontal counters.
 
 
The following example WAIT instruction waits for scan line 255 and horizontal position 254. This event will never occur, so the Copper stops until the next  vertical blanking  interval begins.
 
 
        DC.W    $FFFF,$FFFE    ;Wait for line 255,
 
                                ;  H = 254 (ends Copper list).
 
 
To understand why position VP=$FF HP=$FE will never occur, you must look at the comparison operation of the Copper and the size restrictions of the position information. Line number 255 is a valid line to wait for, in fact it is the maximum value that will fit into this field. Since 255 is the maximum number, the next line will wrap to zero (line 256 will appear as a zero in the comparison.) The line number will never be greater than $FF. The horizontal position has a maximum value of $E2. This means that the largest number that will ever appear in the comparison is $FFE2. When waiting for $FFFE, the line $FF will be reached, but the horizontal position $FE will never happen. Thus, the position will never reach $FFFE.
 
 
You may be tempted to wait for horizontal position $FE (since it will never happen), and put a smaller number into the vertical position field. This will not lead to the desired result. The comparison operation is waiting for the beam position to become greater than or equal to the entered position. If the vertical position is not $FF, then as soon as the line number becomes higher than the entered number, the comparison will evaluate to true and the wait will end.
 
 
The following notes on horizontal and vertical beam position apply to both the WAIT instruction and to the  SKIP . instruction. The  SKIP  instruction is described below in the  Advanced Topics  section.
 
</td>
 
<td style="vertical-align: top; background-color: #f0fff0; padding: 10px; white-space: nowrap;">
 
'''FIRST WAIT INSTRUCTION WORD (IR1)'''
 
<table border=0>
 
<tr><td>Bit 0</td><td>Always set to 1</td></tr>
 
<tr><td>Bits 15 - 8</td><td>Vertical beam position (called VP)</td></tr>
 
<tr><td>Bits 7 - 1</td><td>Horizontal beam position (called HP)</td></tr>
 
</table>
 
 
 
'''SECOND WAIT INSTRUCTION WORD (IR2)'''
 
<table border=0>
 
<tr><td>Bit 0</td><td>Always set to 0.</td></tr>
 
<tr><td>Bit 15</td><td>The blitter-finished-disable bit.  Normally, this bit is a 1.</td></tr>
 
<tr><td>Bits 14 - 8</td><td>Vertical position compare enable bits (called VE).</td></tr>
 
<tr><td>Bits 7 - 1</td><td>Horizontal position compare enable bits (called HE).</td></tr>
 
</table>
 
 
 
'''Notes:'''
 
* HP can be an even number from $01 to $2E (226)
 
</td>
 
</tr>
 
</table>
 
 
 
===SKIP===
 
<table border="0">
 
<tr><td style="vertical-align: top; padding-right: 40px;">
 
The SKIP instruction causes the Copper to skip the next instruction if the video beam counters are equal to or greater than the value given in the instruction.
 
 
 
The contents of the SKIP instruction's words are shown below. They are identical to the  WAIT  instruction, except that bit 0 of the second instruction word is a 1 to identify this as a SKIP instruction.
 
</td>
 
<td style="vertical-align: top; background-color: #f0fff0; padding: 10px; white-space: nowrap;">
 
'''FIRST SKIP INSTRUCTION WORD (IR1)'''
 
<table border=0>
 
<tr><td>Bit 0</td><td>Always set to 1</td></tr>
 
<tr><td>Bits 15 - 8</td><td>Vertical beam position (called VP)</td></tr>
 
<tr><td>Bits 7 - 1</td><td>Horizontal beam position (called HP)</td></tr>
 
</table>
 
 
 
'''SECOND SKIP INSTRUCTION WORD (IR2)'''
 
<table border=0>
 
<tr><td>Bit 1</td><td>Always set to 1.</td></tr>
 
<tr><td>Bit 15</td><td>The blitter-finished-disable bit.  Normally, this bit is a 1.</td></tr>
 
<tr><td>Bits 14 - 8</td><td>Vertical position compare enable bits (called VE).</td></tr>
 
<tr><td>Bits 7 - 1</td><td>Horizontal position compare enable bits (called HE).</td></tr>
 
</table>
 
 
 
'''Notes:'''
 
* HP can be an even number from $01 to $2E (226)
 
</td>
 
</tr>
 
</table>
 
 
 
===MOVE===
 
<table border="0">
 
<tr><td style="vertical-align: top; padding-right: 40px;">
 
The MOVE instruction transfers data from RAM to a register destination. The transferred data is contained in the second word of the MOVE instruction; the first word contains the address of the destination
 
register.
 
 
The Copper can store data into the following registers:
 
  *  Any register whose address is $20 or above.  (Hexadecimal numbers
 
      are distinguished from decimal numbers by the $ prefix.)
 
  *  Any register whose address is between $10 and $20 if the Copper
 
      danger bit is a 1. The Copper danger bit is in the Copper's control
 
      register,  COPCON , which is described in the "Control Register"
 
      section.
 
  *  The Copper cannot write into any register whose address is lower
 
      than $10.
 
 
 
The following example MOVE instructions set bitplane pointer 1 to $21000 and bitplane pointer 2 to $25000.  (All sample code segments are in assembly language.)
 
 
        DC.W    $00E0,$0002    ;Move $0002 to register $0E0 (BPL1PTH)
 
        DC.W    $00E2,$1000    ;Move $1000 to register $0E2 (BPL1PTL)
 
        DC.W    $00E4,$0002    ;Move $0002 to register $0E4 (BPL2PTH)
 
        DC.W    $00E6,$5000    ;Move $5000 to register $0E6 (BPL2PTL)
 
 
Normally, the appropriate assembler ".i" files are included so that names, rather than addresses, may be used for referencing hardware registers.  It is strongly recommended that you reference all hardware addresses via their defined names in the system include files.  This will allow you to more easily adapt your software to take advantage of future hardware or enhancements.  For example:
 
 
        INCLUDE "hardware/custom.i"
 
 
        DC.W    bplpt+$00,$0002 ;Move $0002 into register $0E0 (BPL1PTH)
 
        DC.W    bplpt+$02,$1000 ;Move $1000 into register $0E2 (BPL1PTL)
 
        DC.W    bplpt+$04,$0002 ;Move $0002 into register $0E4 (BPL2PTH)
 
        DC.W    bplpt+$06,$5000 ;Move $5000 into register $0E6 (BPL2PTL)
 
  
For use in the hardware manual examples, we have made a special include file (see  Appendix I ) that defines all of the hardware register names based off of the "hardware/custom.i" file.  This was done to make the examples easier to read from a hardware point of view.  Most of the examples in this manual are here to help explain the hardware and are, in most cases, not useful without modification and a good deal of additional code.
+
==How to program a copperlist==
</td>
+
The copper knows three instructions
<td style="vertical-align: top; background-color: #f0fff0; padding: 10px; white-space: nowrap;">
+
* WAIT - wait for a position on the screen (and optionally till the blitter is ready)
'''FIRST MOVE INSTRUCTION WORD (IR1)'''
+
* SKIP - ignore the next instruction if the given position is/was allready reached (and optionally if the blitter is also ready)
<table>
+
* MOVE - writtes to one of the custom registers
<tr><td>Bit 0</td><td>Always set to 0.</td></tr>
 
<tr><td>Bits 8 - 1</td><td>Register destination address (DA8-1).</td></tr>
 
<tr><td>Bits 15 - 9</td><td>Not used, but should be set to 0.</td></tr>
 
</table>
 
  
  
'''SECOND MOVE INSTRUCTION WORD (IR2)'''
+
A copperlist is started by writing it's address to $DFF080.
<table>
+
The copper will directly jump to the given address.
<tr><td>Bits 15 - 0</td><td>16 bits of data to be transferred (moved) to the register destination.</td></tr>
 
</table>
 
</td>
 
</tr>
 
</table>
 
  
 +
For more info see [[680x0:Copperlist coding|Copperlist coding]]
  
==Copper tricks==
 
The copper makes it easy to create the following effects:
 
  
* Change colors (copperbars)
+
==What can it be used for==
* Reuse sprites at specific lines
+
* vertical screen dragging
* Mirror/reflection effects
+
* split-screen
* Plasma effect
+
* changing colors midscreen (copperbars)
* Freeze-protection?
+
* reuse sprites at specific lines
* Split-screen
+
* mirror/reflection effects
 +
* plasma effect
 +
* freeze-protection

Revision as of 15:43, 10 February 2008

Example of a copperlist

What is a copperlist

The copper is a small piece of the Agnus chip. It can be programmed to write to custom registers synchronized with certain positions of the display. The small programs which the copper runs are called copperlists.


How to program a copperlist

The copper knows three instructions

  • WAIT - wait for a position on the screen (and optionally till the blitter is ready)
  • SKIP - ignore the next instruction if the given position is/was allready reached (and optionally if the blitter is also ready)
  • MOVE - writtes to one of the custom registers


A copperlist is started by writing it's address to $DFF080. The copper will directly jump to the given address.

For more info see Copperlist coding


What can it be used for

  • vertical screen dragging
  • split-screen
  • changing colors midscreen (copperbars)
  • reuse sprites at specific lines
  • mirror/reflection effects
  • plasma effect
  • freeze-protection