ricopperfxlib
This library writes copper instructions into the custom space of a
coplist object of the display library, the space given to the coplist
when it is set up with InitCopList. A coplist without custom space
cannot be used: every command then does nothing. CopperResetAdr
points the library at a custom space of a copper list of your own
instead, for programs that build their copper lists themselves.
CopperReset must come first. It chooses the coplist, the line at
which the next colour split starts and the place in the custom space,
counted in copper instructions of 4 bytes, where the next instruction
goes. Each command then appends its instructions and moves that place
on. Nothing checks the size of the custom space: make it large enough
for everything you add.
DoColSplit writes a colour gradient over a number of lines into one
colour register, RedoColSplit changes the colours of such a split in
place, and CopperMove, CopperWait, CopperSkip, CopperCommand,
CopperAGACol and CopperEnd add single instructions. The colour
splits and CopperAGACol use the 24 bit colours of the AGA chip set. The
commands only write into memory and touch no hardware themselves, so
they work in Amiga and in Blitz mode; the copper list takes effect
when the display library shows the coplist.
The colours of a split are six longs, the red, green and blue of the first line and then of the last line, each from 0 to 255. A fade of colour 0 from black to white over 200 lines, from line 44 of coplist 0 on, and later the same split in other colours:
NEWTYPE .colourinfo
r1.l
g1.l
b1.l
r2.l
g2.l
b2.l
End NEWTYPE
DEFTYPE .colourinfo cols
cols\r1=0,0,0,255,255,255
CopperReset 0,44
pos.w=GetCCOffset
DoColSplit &cols,200,0
CopperEnd
; ...
cols\r1=255,0,0,0,0,255
RedoColSplit &cols,200,posBased on the RI CopperFX Lib guide by Reflective Images.
Library number 11.
Commands
ColSplitBplcon3
Sets the low byte of the register BPLCON3 that colour splits and their colour changes write, for example to blank the border or to set the sprite resolution.
Statement. Help text: bplcon3 - low byte of bplcon 3
Arguments: .b
It applies to the DoColSplit calls that follow; CopperAGACol and
CopperEnd do not use it.
CopperAGACol
Sets one AGA colour register (0 to 255) to the red, green and blue values r,g,b (0 to 255), with four copper instructions.
Statement or function, result .l. Help text: col#,r,g,b
Arguments: .w, .w, .w, .w
AGA only. Used as a function, it returns -1 when it wrote the colour and 0 when no custom space is set.
CopperCommand
Writes one copper instruction, given as its two words, into the custom space.
Statement. Help text: copins1,copins2
Arguments: .w, .w
CopperEnd
Ends the custom instructions with four of its own, a wait for line 300 (line 44 if the list has not passed line 255), bitplane and sprite DMA off, colour bank 0 and colour 0 black.
Statement. No help text.
No arguments.
CopperInfoBlock
Returns the address of the library’s internal state, 20 bytes.
Function, result .l. No help text.
No arguments.
CopperMove
Writes a copper move instruction that puts a word value into a custom chip register, given as its offset from the start of the registers (for example $180 for colour 0).
Statement. Help text: register,value
Arguments: .w, .w
CopperReset
Makes the library work on the custom space of a coplist. startline is the line where the next colour split starts; the optional ccoffset is the place in the custom space, in instructions from its start, where the next instruction goes (0 without it).
Statement. Help text: coplist#,startline[,ccoffset]
2 forms:
.w, .w.w, .w, .w
It must be called before the other commands. If the coplist has no custom space, the other commands do nothing.
CopperResetAdr
Makes the library work on a copper list of your own. The first argument is not a coplist number but the address of the space in your copper list that the library may fill; startline is the line where the next colour split starts.
Statement. Help text: coplist#,startline
Arguments: .l, .w
The place of the next instruction starts at 0. Nothing checks the size of the space.
CopperSkip
Writes a copper skip instruction for the position x,y, which skips the next instruction once the beam has passed that position.
Statement. Help text: x,y
Arguments: .w, .w
Unlike CopperWait, x is not converted: it is the horizontal
position as the copper counts it, with bit 0 cleared and only its low
8 bits used. Only the low 8 bits of y are used.
CopperWait
Writes a copper wait instruction for the position x,y. The copper resolves x only in steps of 4 low resolution pixels.
Statement. Help text: x,y
Arguments: .w, .w
Only the low 8 bits of y are used.
DoColSplit
Writes a 24 bit colour gradient into one colour register (0 to 255) over numlines lines, from the current start line on. cols_adr is the address of six longs, the red, green and blue of the first line and of the last, each 0 to 255.
Statement or function, result .w. Help text: cols_adr,numlines,colour_register
Arguments: .l, .w, .w
AGA only. Each line takes five copper instructions; a line 256 gets one more, the wait that the copper needs to reach the lines below 255. Afterwards the start line is the line after the split, so several splits can follow each other. Without a coplist or custom space nothing is written. Used as a function, it returns -1 when it wrote the split and 0 when it did not.
With runtime error checking, a numlines below 1 is the error
“Colour split needs at least one line”. Without it, 0 divides by zero
and stops the program with a processor exception, and a negative
count writes up to 65536 lines over the memory after the custom
space.
GetCCOffset
Returns the place of the next instruction in the custom space, in instructions from its start, or -1 if no custom space was chosen with CopperReset or CopperResetAdr.
Function, result .w. Help text: - get current custom copper offset
No arguments.
RedoColSplit
Writes new colours into a colour split made by DoColSplit, without building it again. cols_adr and numlines are as for DoColSplit; ccoffset is the place of the split in the custom space, in instructions, as GetCCOffset returned it just before the DoColSplit.
Statement. Help text: cols_adr,numlines,ccoffset
Arguments: .l, .w, .l
numlines is checked as with DoColSplit.