A.D.A. Amiga Demoscene Archive

        Welcome guest!

  

  

  

log in with SceneID

  

Demos Amiga Demoscene Archive Forum / Coding / Copper interrupt

 

Author Message
Reloaded
Member
#1 - Posted: 7 Jun 2012 14:36
Reply Quote
Hello. I have a question about the Copper. I need to wait for line 200 to trigger an interrupt to run the c2p routine when DMA is off. How can it be done?.

Thanks a lot.
hooverphonique
Member
#2 - Posted: 12 Jun 2012 17:10
Reply Quote
noname
Member
#3 - Posted: 12 Jun 2012 18:31
Reply Quote
Be aware that it will be more complex than you might think at the moment. Merely waiting for line 200 (whatever the number) and then starting the c2p is not enough, as the c2p, or rather the chip-mem is so slow that the execution of the c2p will overflow into the next frame and not be finished before the DMA is on again. Bummer!

What you are looking for once you are happy with interrupts triggered from the copper-list is the supervisor mode. You will need to implement a context-switcher that is called from your newly created copper interrupts. The switcher will need to switch to continue any pending c2p jobs after, say, line 200 and likewise return control to your main task at, say, line 20. So in fact you will have two tasks running internally that you continously switch around based on the position of the beam/DMA. Documentation of the supervisor can be found in the MC68060 manual. Finally, please note that all this can only be done with the system disabled.

Thats the theory behind DMA-off c2p. I never actually gotten around implementing this in my own demos, but I wrote test-code and always wanted to have it in my system. Also I don't think I have seen any decent tutorial on this. Maybe we need to write one?
hooverphonique
Member
#4 - Posted: 12 Jun 2012 22:31
Reply Quote
I think what you are saying, noname.. you need to use the copper interrupt to trigger a context switch between task 1 and 2, where 1 is e.g. your main democode and 2 is c2p.. this is in line with how interrupts are used in operating systems: interrupt code must be as fast/short as possible but are able to affect primitives in task-space (semaphores, etc).
noname
Member
#5 - Posted: 13 Jun 2012 00:34
Reply Quote
Basically: yes - not sure about the stuff after your "but" though.
jamie2010
Member
#6 - Posted: 13 Jun 2012 01:47
Reply Quote
Basically what you need is one copper interruption, split your c2p in two pass to be sure to acces chip memory during dma off. First pass will draw half of the screen and the second pass will draw the other half.

If you use a triple buffering you can totaly desynchronise your c2p from your effect, in some situations it can help to have a more constant framerate on the other side if you need to do some accurate synchronizations it can be more painful but it's another story.
Blueberry
Member
#7 - Posted: 14 Jun 2012 15:00
Reply Quote
Even if you are writing to chip memory with the DMA off, you still waste more than two thirds of the C2P time waiting for the chip memory. If you want to take full advantage of the CPU while running the C2P, find some meaningful computation to interleave into the C2P code. 3D point transformation is a classical example. FPU computations are particularly well suited for interleaving, as they don't increase register pressure (if you are only using the FPU registers).

Such interleaving makes decoupling of the C2P and the effect somewhat more tricky, though. :)
hooverphonique
Member
#8 - Posted: 14 Jun 2012 16:14
Reply Quote
but does the FPU not run async to the CPU? I mean, you could run *both* FPU and CPU instructions interleaved with c2p, correct? or does this only work with an external FPU?
Crumb
Member
#9 - Posted: 19 Jun 2012 17:52
Reply Quote
@Blueberry
I guess it could be easier to perform c2p that keeps resulting planar buffer in fastram and performs copy when DMA is off as fast2chip copy operation (using movem.l for example) could use less registers than c2p. But using movem.l perhaps makes more difficult interleaving fpu instructions (or less useful since it "blocks" access to memory more time than smaller moves).

BTW, I remember Doom wrote some time ago that he was working on a tricky c2p that used FPU to do it faster than "copyspeed". I'll do a silly question: Are fpu writes to memory faster than integer ones on 68040/68060?
jamie2010
Member
#10 - Posted: 19 Jun 2012 20:01
Reply Quote
@Blueberry
Yeah you can speed up your code if you do some computation during c2p but the code is harder to maintain. For transformations i like to use cpu/fpu and prefetch, if i want to do transformations during c2p i will use fpu but you can't interleave all transformation cycles.

I don't like the fact to code all effects in the c2p as the code is more complicated, the best solution is to find something that will speed up all effects.
Angry Retired Bastard
Member
#11 - Posted: 21 Jun 2012 16:41
Reply Quote
"the best solution is to find something that will speed up all effects"

Actually, the best solution is to find something that speeds up the development of the demo so that it doesn't take years and years for each release. ;)
jamie2010
Member
#12 - Posted: 21 Jun 2012 17:11
Reply Quote
Quit your job and your family and you are good to produce demo every partys:)

 

  Please log in to comment

  

  

  

 

A.D.A. Amiga Demoscene Archive, Version 3.0