The copper is a part of the Agnus chip which can execute simple instructions timed on the position of the screen which is being generated.
Writing a copperlist
A copperlist is often written like this:
dc.w $....,$.... dc.w $FFFF,$FFFE ; end of the copperlist
A copperlist should allways end with $FFFF,$FFFE. This will wait for line (VP) 255, (HP) 243, which won't happen.
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.
FIRST WAIT INSTRUCTION WORD (IR1)
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.
FIRST SKIP INSTRUCTION WORD (IR1)
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.
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:
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.
FIRST MOVE INSTRUCTION WORD (IR1)
The copper makes it easy to create the following effects:
- Change colors (copperbars)
- Reuse sprites at specific lines
- Mirror/reflection effects
- Plasma effect