Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Copper / copperlist  (Read 9030 times)

0 Members and 4 Guests are viewing this topic.

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Copper / copperlist
« on: September 06, 2007, 10:17:28 PM »


hi,

Some of you may know that I am messing with the copperlist (or copper). I can successfully create a rainbow effect with colour 0, but that's it :( Does anyone know how to create a proper copperlist? Heres the default copperlist (after opening AMOS and loading Kyzer's Copdis.AMOS routine - see Kyzer.lha on Aminet):


$1003FFFE: WAIT  x=3,y=16  (mask=$FFFE)
$01200004: MOVE  #$4,spr0pth
$0122B648: MOVE  #$B648,spr0ptl
$01240004: MOVE  #$4,spr1pth
$0126B850: MOVE  #$B850,spr1ptl
$01280004: MOVE  #$4,spr2pth
$012ABA58: MOVE  #$BA58,spr2ptl
$012C0004: MOVE  #$4,spr3pth
$012EBC60: MOVE  #$BC60,spr3ptl
$01300004: MOVE  #$4,spr4pth
$0132BE68: MOVE  #$BE68,spr4ptl
$01340004: MOVE  #$4,spr5pth
$0136C070: MOVE  #$C070,spr5ptl
$01380004: MOVE  #$4,spr6pth
$013AC278: MOVE  #$C278,spr6ptl
$013C0004: MOVE  #$4,spr7pth
$013EC480: MOVE  #$C480,spr7ptl
$2F03FFFE: WAIT  x=3,y=47  (mask=$FFFE)
$00960100: MOVE  #$100,dmacon
$01800000: MOVE  #$0,color00
$01820A40: MOVE  #$A40,color01
$01840FFF: MOVE  #$FFF,color02
$01860001: MOVE  #$1,color03
$01880F00: MOVE  #$F00,color04
$018A00F0: MOVE  #$F0,color05
$018C000F: MOVE  #$F,color06
$018E0666: MOVE  #$666,color07
$01900555: MOVE  #$555,color08
$01920333: MOVE  #$333,color09
$01940733: MOVE  #$733,color10
$01960373: MOVE  #$373,color11
$01980773: MOVE  #$773,color12
$019A0337: MOVE  #$337,color13
$019C0737: MOVE  #$737,color14
$019E0377: MOVE  #$377,color15
$00E00004: MOVE  #$4,bpl1pth
$00E2E708: MOVE  #$E708,bpl1ptl
$00E40006: MOVE  #$6,bpl2pth
$00E639C8: MOVE  #$39C8,bpl2ptl
$008E0181: MOVE  #$181,diwstrt
$009037C1: MOVE  #$37C1,diwstop
$0092003C: MOVE  #$3C,ddfstrt
$009400D4: MOVE  #$D4,ddfstop
$01080000: MOVE  #$0,bpl1mod
$010A0000: MOVE  #$0,bpl2mod
$0100A200: MOVE  #$A200,bplcon0
$01020000: MOVE  #$0,bplcon1
$01040024: MOVE  #$24,bplcon2
$3003FFFE: WAIT  x=3,y=48  (mask=$FFFE)
$00968300: MOVE  #$8300,dmacon
$01A00000: MOVE  #$0,color16
$01A20EC8: MOVE  #$EC8,color17
$01A40C60: MOVE  #$C60,color18
$01A60EA0: MOVE  #$EA0,color19
$01A8027F: MOVE  #$27F,color20
$01AA049D: MOVE  #$49D,color21
$01AC05AE: MOVE  #$5AE,color22
$01AE0ADF: MOVE  #$ADF,color23
$01B00BDF: MOVE  #$BDF,color24
$01B20CEF: MOVE  #$CEF,color25
$01B40FFF: MOVE  #$FFF,color26
$01B60408: MOVE  #$408,color27
$01B80A0E: MOVE  #$A0E,color28
$01BA0E0E: MOVE  #$E0E,color29
$01BC0E08: MOVE  #$E08,color30
$01BE0EEE: MOVE  #$EEE,color31
$FFDFFFFE: WAIT  x=223,y=255  (mask=$FFFE)
$3003FFFE: WAIT  x=3,y=48  (mask=$FFFE)
$00960100: MOVE  #$100,dmacon
$01800000: MOVE  #$0,color00
$FFFFFFFE: CEND


Perhaps I should look at Kyzers code and see what references dmacon etc. are in terms of addresses, and then copy it into AMOS code. Once I have it working then I can play with it, can't I? :)


Failing that, does anyone know how to reroute the copper to say a copperlist stored in a bank?


Regards,
Lonewolf10

.... who loves to play :)
Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Copper / copperlist
« Reply #1 on: September 06, 2007, 10:27:21 PM »


Sorry, just remembered this.

Does anyone know where the length of the copperlist is stored? The reason I ask is that when writing your own copperlist the screen can become corrupted - the reason being that your own AMOS copperlist isn't long enough to overwrite what was left (I know this from playing with it a few weeks ago).

I resolved it by creating a rather large copperlist, which finally enabled me to get my own copperlist (the rainbow versions, as mentioned in previous message) working. I'll attach demo code tomorrow night (no time to find it and .lha it).


Regards,
Lonewolf10

...who has too many projects on the go!
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Copper / copperlist
« Reply #2 on: September 06, 2007, 11:59:35 PM »

You can find the system-friendly way to deal with copperlists at http://utilitybase.com/ref/?keyword=MrgCop&funcgroup=AmigaOS&action=Search.  It will list out all of the affected system structures at the bottom.  I'm not sure how to do it with Amos though.
Logged

Spellcoder

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 27
    • Amiga Coding WIKI
Re: Copper / copperlist
« Reply #3 on: September 13, 2007, 09:11:22 PM »

I've made copperlists in assembler but never in AMOS.
From what I see in the AMOSPro manual you won't have to mess with all the hexcodes but can use:
Cop Move address,value
Cop Wait x,y
Cop Wait x,y,xmask,ymask


Keep in mind:
- for creating copperbars effect you usually wait for the next scanline
- then move a new color into one of morecolor registers
- the memory of the custom chip registers start range from $DFF000-$DFFFFF, but the copper only needs the last 3 digits ($000-$FFF)
- Color00 register is $180, Color01 = $182, Color02 = $184, Color03 = $186 etc..
- You have to handle setting up the screen, spites yourself if you use your own copperlist (I think)


The next is what I think should somewhat work without having tried it in AMOS :P.
To make a copperbar effect starting with $500 (very dark red) and going to bright red goes like this:

; Set up your screen:
; Addresses of important registers
bpl1pth =$E0
bpl1ptl = $E2
bpl2pth = $E4
bpl2ptl = $E6
dmacon = $96
bplcon0 = $100
bplcon1 = $102
bplcon2 = $104
bpl1mod = $108
bpl2mod = $10A

Copper Off ; disable AMOS's automatic copperlist generation

; Wait for the start of the screen
Cop Wait 3,47

; Set where to read each bitplane
Cop Move #Phybase(0) / 65536,bpl1pth
Cop Move #Phybase(0) % 65535,bpl1ptl
Cop Move #Phybase(1) / 65536,bpl2pth
Cop Move #Phybase(1) % 65535,bpl2ptl

; forgot the specifics, but I think this was start tell the drawing position of the screen
; I copied these values from your normal AMOS copperlist.
Cop Move #$181,diwstrt
Cop Move #$37C1,diwstop
Cop Move #$3C,ddfstrt
Cop Move #$D4,ddfstop

; the mod is how much bytes to skip after having drawn one line on the screen
; if you set it to -(screenwidth/8)*numberoflinestoskip it goes backwards and you can get a reflection effect :P
; I copied these values from your normal AMOS copperlist.
Cop Move $0,bpl1mod ; odd bitplanes mod
Cop Move $0,bpl2mod ; even bitplanes mod

; Set some info about the screen (amount bitplanes/scrolling/playfields)
Cop Move $A200,bplcon0 ; stuff like which bitplanes are active, dual playfield
Cop Move $0,bplcon1 ; fine tuning of scrolling a screen (per playfield)
Cop Move $24,bplcon2 ; stuff like dual playfield priority (which screen is above) and extra halfbrite mode

; Time to start showing the screen
Cop Move $8300,dmacon ; enable display of bitplanes + set 'enable all DMA below'

; Rainbow effect
; we will fade color 0 from $500 to $700 and color 1 from $005 to $007
Cop Wait 0,120
Cop Move $180,$500
Cop Move $182,$005
Cop Wait 0,121
Cop Move $180,$600
Cop Move $182,$006
Cop Wait 0,122
Cop Move $180,$700
Cop Move $182,$007

; Wait for the end of the screen
Cop Wait 223,255

Cop Move $100,dmacon ; disable display of all bitplanes

Cop Move $180,$000 ; so outside our screen will be black again

Cop Reset ; make the copper wait and start our nice copperlist again (?)



Some knowledge to make even more funky effects: (not in the AMOS documentation)
- X position has an accuracy of 2 lowres pixels
- every Cop Move instruction takes 8 lowres pixels of time, so you could abuse it for a very lowres plasma effects while only using 1 color


So if you leave out all the waits:
Cop Move $180,$500
Cop Move $180,$600
Cop Move $180,$700
Cop Move $180,$800

You get a nice horizontal copperbar effect. Which is nice to make effects like 'scrolling colorlines' (or whatever you call it) and
if you the wait for the next line and do this again you can get plasma effects.


It's also possible to get reflection effects (by telling the chipset to go backwards two lines or more in memory after completing reading a line,
and giving those lines other colors to get fading effects). The nice thing is that the reflection looks impressive but only takes a little copper time.

A lot more freaky stuff is possible with the copper :).
For a list of all custom chipset registers see: http://home-1.tiscali.nl/~solognt/AGA/agaregindex.html#regs_adr
There are nice Amigaguides of the list too, I think one is bundled with the AsmPro assembler.
« Last Edit: September 13, 2007, 09:16:05 PM by Spellcoder »
Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Copper / copperlist
« Reply #4 on: September 13, 2007, 10:04:28 PM »


Thanks for that. I have copied the info to my laptop so I can have a play this weekend :)


Regards,
Lonewolf10

Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Copper / copperlist
« Reply #5 on: September 22, 2007, 08:59:25 PM »

Spellcoder,
I'd forgotten you posted some helpful info here. Seems I misplaced the file on my harddrive so will copy it down again :)

Here's all the other registers, as taken from the Amiga Hardware Reference Manual: Revised & Updated (First Printing 1989). The manual covers the A500, A1000 and A2000. I know the A600 didn't come out until 1992, so the following locations *should* work on the A600 too.


BPL1MOD=$108  (bit plane modulo - odd planes)
BPL2MOD=$10A  (bit plane modulo - even planes)
   
BPLCON0=$100  (bit plane control bits - misc. control)
BPLCON1=$102  (bit plane control register - horizontal scroll control)
BPLCON2=$104  (bit plane control register - video priority control)

BPL1DAT=$110  (bit plane 1 data - parallel to serial convert)
BPL1DAT=$112  (bit plane 2 data - parallel to serial convert)
BPL1DAT=$114  (bit plane 3 data - parallel to serial convert)
BPL1DAT=$116  (bit plane 4 data - parallel to serial convert)
BPL1DAT=$118  (bit plane 5 data - parallel to serial convert)
BPL1DAT=$11A  (bit plane 6 data - parallel to serial convert)


BPL1PTH=$0E0  (bit-plane 1 part high bits)  \ Address of bit-plane 1
BPL1PTL=$0E2  (bit-plane 1 part low bits)   /
BPL2PTH=$0E4  (bit-plane 2 part high bits)  \ Address of bit-plane 2
BPL2PTL=$0E6  (bit-plane 2 part low bits)   /
BPL3PTH=$0E8  (bit-plane 3 part high bits)  \ Address of bit-plane 3
BPL3PTL=$0EA  (bit-plane 3 part low bits)   /
BPL4PTH=$0EC  (bit-plane 4 part high bits)  \ Address of bit-plane 4
BPL4PTL=$0EE  (bit-plane 4 part low bits)   /
BPL5PTH=$0F0  (bit-plane 5 part high bits)  \ Address of bit-plane 5
BPL5PTL=$0F2  (bit-plane 5 part low bits)   /
BPL6PTH=$0F4  (bit-plane 6 part high bits)  \ Address of bit-plane 6
BPL6PTL=$0F6  (bit-plane 6 part low bits)   /



COLOR00=$180  (colour registers - RGB format (xxxxRRRRGGGGBBBB)
COLOR01=$182
COLOR02=$184
COLOR03=$186
COLOR04=$188
COLOR05=$18A
COLOR06=$18C
COLOR07=$18E
COLOR08=$190
COLOR09=$192
COLOR10=$194
COLOR11=$196
COLOR12=$198
COLOR13=$19A
COLOR14=$19C
COLOR15=$19E
COLOR16=$1A0
COLOR17=$1A2
COLOR18=$1A4
COLOR19=$1A6
COLOR20=$1A8
COLOR21=$1AA
COLOR22=$1AC
COLOR23=$1AE
COLOR24=$1B0
COLOR25=$1B2
COLOR26=$1B4
COLOR27=$1B6
COLOR28=$1B8
COLOR29=$1BA
COLOR30=$1BC
COLOR31=$1BE

COP1LCH=$080   (Copper first location register (Jump address) - High 3 bits)
COP1LCL=$082   (Copper first location register (Jump address) - Low 15 bits)
COP2LCH=$084   (Copper second location register (Jump address) - High 3 bits)
COP2LCL=$086   (Copper second location register (Jump address) - Low 15 bits)

COPCON =$02E   (Copper control register, set bit 1 to 1 for copper to access blitter)

DDFSTOP=$094   (Display data fetch stop (horiz. position))  \ See Amiga Hardware Ref
DDFSTRT=$092   (Display data fetch start (horiz. position)) / Manual, Appendix A (p.271)

DIWSTOP=$090   (Display window stop (lower right vertical-horizontal position)
DIWSTRT=$08E   (Display window start (upper left vertical-horizontal position)

DMACON =$096   (DMA control write - clear or set)

SPR0PTH=$120   (Sprite 0 pointer of DMA data - High 3 bits)
SPR0PTL=$122   (Sprite 0 pointer of DMA data - Low 15 bits)
SPR1PTH=$124   (Sprite 1 pointer of DMA data - High 3 bits)
SPR1PTL=$126   (Sprite 1 pointer of DMA data - Low 15 bits)
SPR2PTH=$128   (Sprite 2 pointer of DMA data - High 3 bits)
SPR2PTL=$12A   (Sprite 2 pointer of DMA data - Low 15 bits)
SPR3PTH=$12C   (Sprite 3 pointer of DMA data - High 3 bits)
SPR3PTL=$12E   (Sprite 3 pointer of DMA data - Low 15 bits)
SPR4PTH=$130   (Sprite 4 pointer of DMA data - High 3 bits)
SPR4PTL=$132   (Sprite 4 pointer of DMA data - Low 15 bits)
SPR5PTH=$134   (Sprite 5 pointer of DMA data - High 3 bits)
SPR5PTL=$136   (Sprite 5 pointer of DMA data - Low 15 bits)
SPR6PTH=$138   (Sprite 6 pointer of DMA data - High 3 bits)
SPR6PTL=$13A   (Sprite 6 pointer of DMA data - Low 15 bits)
SPR7PTH=$13C   (Sprite 7 pointer of DMA data - High 3 bits)
SPR7PTL=$13E   (Sprite 7 pointer of DMA data - Low 15 bits)


I recreated the AMOS default copperlist using the addresses above (both with and without $DFF000 added), but on both occasions the screen went black :( [Edit: That may be because I forgot to swap the logical and physical copperlists using Cop Swap. Just found the command when doublechecking that AMOS doesn't use the copper's Skip command] I'll use the hardware manual register appendix to help me create a simple copperlist from scratch, as a starting block for doing more complex stuff later.


Also, I examined some of the registers that AMOS uses, and the screen data is never kept in the same place. I'm going to have to create a bank to store my screen data, otherwise I have no chance of getting my own copperlist to work.


Regards,
Lonewolf10

« Last Edit: September 22, 2007, 09:15:22 PM by Lonewolf10 »
Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Copper / copperlist
« Reply #6 on: September 22, 2007, 09:05:19 PM »

Cop Reset ; make the copper wait and start our nice copperlist again (?)

No.

Cop Reset is used to create loops within the copperlist. It's not an instruction I recommend on using.


AMOS doesn't use the Skip command which the Copper has. It's used to skip instructions if the scan beam has already reached a specific part.


Regards,
Lonewolf10

Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Copper / copperlist
« Reply #7 on: September 23, 2007, 08:26:22 PM »


I went back and checked that I hadn't forgotten the Cop Swap at the end of the coppperlist. I had but that didn't make any difference. I also discovered that AMOS uses Cop Move ADDRESS,VALUE rather than the other way round as Kyzer's CopDis had put it. Swapping the values to the correct side still had no effect. I still end up with a black screen.

I guess I'll have to put this one the back burner for now. For all we know the AMOS copper commands may not even work!! :(


Regards,
Lonewolf10

Logged

Spellcoder

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 27
    • Amiga Coding WIKI
Re: Copper / copperlist
« Reply #8 on: September 24, 2007, 08:36:08 PM »

Quote
Also, I examined some of the registers that AMOS uses, and the screen data is never kept in the same place. I'm going to have to create a bank to store my screen data, otherwise I have no chance of getting my own copperlist to work.

Yep, AMOS politely asks AmigaOS for chip memory it can use for it's screen bitplanes.
So the address of the bitplanes will change.
That's what the Phybase() bit in my code was for.

I've started taking a look in AMOSPro again (almost never touched it the last few years)
and I've fixed the code to write the BPL1PTH and BPL1PTL.
It should now at least run, determine the amount of bitplanes on your screen itself and
I've commented it:

(you got to scroll the sourcecode, the forumsoftware cuts it off :|)


Code: [Select]
' Set where to read each bitplane

' Calculate how many bitplanes the current screen has
BITPLANES=Sqr(Screen Colour)

' Copy the address for each bitplane (numbering starts at 0)
For BPL=0 To BITPLANES-1

'  The copper can only write one word (2 bytes) at a time,
'  so we need to write twice to get the full bitplane address (4 bytes)

'  The upper 16 bits (PoinTer Higher word):
'  Get the bitplane address, move it 16 bits and then mask away all upper bits
'  Phybase(BPL)/65536 will also work, but only due to the way AMOS rounds numbers.
'  (this way is safer:)
   PTH = Phybase(BPL)
   Ror.l 16 , PTH
   PTH = PTH and 65535

'  The lower 16 bits: (PoinTer Lower word)
'  Just mask away the upper bits
   PTL = Phybase(BPL) and 65535

   Cop Move PTH , BPL1PTH+BPL*4
   Cop Move PTL , BPL1PTL+BPL*4
Next BPL


However, I never tested the code. I'd have to sit down for some hours to get some working code I think.
It's a hard thing to master, especially if you've never wrote things in assembler that uses copperlists.
« Last Edit: September 25, 2007, 12:39:13 PM by Spellcoder »
Logged

rednova

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 225
    • http://www.feryogi.com
Re: Copper / copperlist
« Reply #9 on: September 25, 2007, 06:29:27 PM »

Hi Lonewolf:

I already posted this on amiga.org, however I do not know if you read it.
I cannot help you with this...but I have a suggestion:the amos pd cd might have an example of how to do what you want, all you have to do is find it on the cd, just load it and try it. I can send you a copy of the amos pd cd list...which lists every disk and show what they have inside.
Good luck!!!

rednova
-mobilis in mobile-
Logged
-mobilis in mobile-

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Copper / copperlist
« Reply #10 on: September 26, 2007, 08:29:48 PM »


Rednova,
            thanks, but I don't need it now!


Spellcoder,
               your code is buggy (I think). It (of course) didn't work on it's own, so I tried to import the other bits from the AMOS copperlist and it still failed (but could be for the same reason the AMOS one failed - read on).
After it failed I went back to the AMOS one and decided to comment each one out one by one. Eventually I found the line with the problem. I had mistyped the address variable as "SPR6TH" instead of "SPR6PTH". What this meant was that as a new variable AMOS declared it with a value of 0 and it was poking a word value onto register 0 (BLTDDAT - Blitter destination early read)!!
With that sorted I now have the copperlist working - sort of. There is a slight problem in that the screen is squished horizontally and it seems a bitplane is displayed side-by-side, but atleast it's working :)
Now, with the help of the hardware manual's register list, I can play with the various settings to sort things out for myself.

Thanks for all the help, I got there in the end.


Regards,
Lonewolf10

Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Copper / copperlist
« Reply #11 on: September 29, 2007, 08:55:14 PM »


Hi,

After spending the day examining the register list and accompanying documentation in the Amiga Hardware Reference Manual, i have solved all copperlist problems except 2:


 - Mouse not working (ignore this, I haven't even tried to get it working yet!)

 - Only 4/5's of the screen being used. I think I have all the registers set correctly (BPLCON0 - 3, BPL1PTH - BPL6PTH, BPL1PTL - BPL6PTL, DMACON, BPL1MOD, BPL2MOD, DIWSTRT and DDFSTRT). I'm guessing the problem is probably with DIWSTOP and DDFSTOP, but I have been playing with them all day with no luck so far :(


See the "Copper Play" thread in the submissions section for my latest copperlist code ("Cop2.1.lha")

Regards,
Lonewolf10

Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022