680x0:Copperlist coding

From Amiga Coding
Revision as of 16:47, 10 February 2008 by Spellcoder (talk | contribs) (New page: ==Writing a copperlist== A copperlist is often written like this: <code><pre> dc.w $....,$.... dc.w $FFFF,$FFFE ; end of the copperlist </pre></code> A copperlist should allways ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.


WAIT

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.

SKIP

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.

MOVE

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.

FIRST WAIT INSTRUCTION WORD (IR1)

Bit 0Always set to 1
Bits 15 - 8Vertical beam position (called VP)
Bits 7 - 1Horizontal beam position (called HP)


SECOND WAIT INSTRUCTION WORD (IR2)

Bit 0Always set to 0.
Bit 15The blitter-finished-disable bit. Normally, this bit is a 1.
Bits 14 - 8Vertical position compare enable bits (called VE).
Bits 7 - 1Horizontal position compare enable bits (called HE).


Notes:

  • HP can be an even number from $01 to $2E (226)

FIRST SKIP INSTRUCTION WORD (IR1)

Bit 0Always set to 1
Bits 15 - 8Vertical beam position (called VP)
Bits 7 - 1Horizontal beam position (called HP)


SECOND SKIP INSTRUCTION WORD (IR2)

Bit 1Always set to 1.
Bit 15The blitter-finished-disable bit. Normally, this bit is a 1.
Bits 14 - 8Vertical position compare enable bits (called VE).
Bits 7 - 1Horizontal position compare enable bits (called HE).


Notes:

  • HP can be an even number from $01 to $2E (226)

FIRST MOVE INSTRUCTION WORD (IR1)

Bit 0Always set to 0.
Bits 8 - 1Register destination address (DA8-1).
Bits 15 - 9Not used, but should be set to 0.


SECOND MOVE INSTRUCTION WORD (IR2)

Bits 15 - 016 bits of data to be transferred (moved) to the register destination.