29 June 2024, 11:12 | #1 |
Registered User
Join Date: Dec 2007
Location: Aarhus / Denmark
Posts: 45
|
Does disabling copper DMA stop the copper?
If copper DMA is disabled, and I enable it mid-frame, does the copper continue immediately from where it left off, or does it stay paused until the next vblank (or write to COMJMP)?
Does the behavior perhaps depend on what the copper was doing when DMA was turned off, and/or whether a vblank has happened in the meantime? |
29 June 2024, 11:41 | #2 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,508
|
DMACON bits toggle the DMA channels from 'idle' mode to 'active' mode.
So yes, the Copper simply pause and then continue from where it was. With one exception, that is, if a new video frame started. In this case by setting the bit the copper starts from the beginning; or rather, from the address present in COP1LC. |
29 June 2024, 12:09 | #3 |
Registered User
Join Date: Dec 2007
Location: Aarhus / Denmark
Posts: 45
|
I feared as much.
My use case is I want to use all of chip memory for my demo. If I just disable copper DMA, initialize chip memory, set COP1LC and then enable copper DMA, the copper might execute whatever is now in the place where the system copperlist was. If I wait a frame after setting COP1LC before enabling copper DMA, it might execute my copperlist immediately, rather than waiting for the next vblank as desired. It seems this requires some dance, like, point COP1LC to an FFFFFFFE longword, wait a frame, point COP1LC to my proper copperlist, then enable copper DMA. Any ideas for a simpler way to achieve this? |
29 June 2024, 12:10 | #4 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,508
|
Furthermore, since you mentioned COPJMP, it is better to clarify its functioning to avoid unwanted effects (too often in demos its 'abuse' leads to problems, it should be used with caution..).
Copper's Program Counter is internally just one and COP1LC/COP2LC are just buffers that contain values that can be 'pushed' in it. But in only one case the insertion is automatic (and only for COP1LC), that when a new vblank is happening. In the remaining cases it can be done manually through COPJMPx, even with active Copper DMA (non in Wait state). And the latter situation can also lead to video glitches (in the best case scenario) or even a machine crash in particular conditions (there is a description of this case on EAB somewhere, search for Copper Wait/Blitter bug or similar..). That said, a correct use is to set COP1LC during the frame and let the system automatically insert the value for the next vblank. In the meantime you can change LCs and stop the Copper as you like EDIT: I hadn't read your message above yet, but I basically replied to you in this |
29 June 2024, 12:17 | #5 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,508
|
|
29 June 2024, 12:22 | #6 |
Registered User
Join Date: Dec 2007
Location: Aarhus / Denmark
Posts: 45
|
|
29 June 2024, 12:27 | #7 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,508
|
Quote:
It's a few cycles at most! I can't imagine such a case, but I don't know what you want to do with your CPU/Copper code... EDIT: hmm, maybe you fill the chip memory with Copper Moves? And this need to start exactly at vblank? But why? I'm curious now Last edited by ross; 29 June 2024 at 12:33. Reason: typos... |
|
29 June 2024, 12:46 | #8 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,508
|
I offer you a dirty alternative, but I don't know if you at least have location 0 available.
Usually contains 0*, but you can also put the value $FFFFFFFE and then reset it to 0 at program exit. Set COP1LC=0 ant COPJMP1 immediately (don't turn off the Copper). Fill the chip memory as much as you like and then finally set the correct value for Copper PTR. Then you definitely get what you wanted. *Copper HALT (it re-start and re-HALT at next vblank) |
29 June 2024, 13:18 | #9 |
Registered User
Join Date: Dec 2007
Location: Aarhus / Denmark
Posts: 45
|
Even if I have no locations available, I can do:
- Put $FFFFFFFE temporarily somewhere and point COP1LC to it. - Wait for vblank. - Set correct COP1LC. - Restore the $FFFFFFFE to what I wanted to have there. Interesting. I thought 0 was a copper no-op (move to dummy address). |
29 June 2024, 13:24 | #10 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,508
|
Quote:
Not only 0, all Copper 'opcodes' that do a Move on 'protected' RGA registers (i.e. the usuals with CDANG=0) |
|
16 July 2024, 10:58 | #11 |
Registered User
Join Date: Apr 2023
Location: "Hamcastle"
Posts: 27
|
The thread reminded me of a question that is lingering in my mind...If copper DMA is off and vertical blanking occurs which copper list will then be executed when copper DMA is turned on?: 1) The one that was in $dff080 at the time of vertical blanking or 2) can you reload $dff080 with another copper list at a later beam position before copper DMA is turned on and then this copper list will be executed?
According to some tests a while ago, case 2) seems to hold true which is a bit confusing to me since I seem to remember an EAB thread that sounded to me more like case 1) should be true. |
16 July 2024, 11:53 | #12 | |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,650
|
Quote:
|
|
16 July 2024, 12:02 | #13 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,076
|
This is how I look at it: copper doesn't need DMA to access its $dffxxx registers, so it should always have access to the latest coplc0/1 and detect the writes to copjmp0/1. Turning DMA off only prevents it from fetching copperlist instructions.
|
16 July 2024, 14:29 | #14 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,366
|
For what the OP wants, i think there is another solution :
- stop copper DMA - fill chip mem - setup COP1LC to coplist you want to execute - setup COP2LC to some FFFF FFFE (there should be one somewhere now ?) - hit COP2JMP - start copper DMA |
17 July 2024, 11:55 | #15 |
Registered User
Join Date: Apr 2023
Location: "Hamcastle"
Posts: 27
|
Thanks a lot for the fast replies!
@hooverphonique: Maybe my interpretation is not correct but post 4 seems to match case 1 of my former question. I am confused. @a/b: Yep, but what if you don't use copjmp and let the vertical blank (vbl) do the job - and this with copper DMA disabled? Is it then that the vbl "strobes" the copper and the enabling of the copper DMA at a later beam position then executes the copper list which was in $dff080 at vbl'ing with ignoring any other write to $dff080 in between or is it rather that the vbl "arms" the copper with still giving you the possibility to reload $dff080 afterwards and that the subsequent enabling of the copper DMA then "strobes" the copper? I hope you understand what I mean??? (Maybe pedantic hair splitting on my side, but sometimes you have these litte and annyoing questions in your head.) |
17 July 2024, 13:28 | #16 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,076
|
The curent (last written) value *at the moment of strobing* is copied to the internal pc. If you update $dff080 after VBL and don't strobe manually, it will use the "old" value (copied at VBL) when you enable DMA, until next strobe (either VBL or manual) when it will pick up the updated value.
|
17 July 2024, 14:50 | #17 | |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,279
|
Quote:
Code:
include hardware/custom.i include hardware/intbits.i include hardware/dmabits.i section code,code start lea $dff000,a6 move.w #$7fff,d0 move.w d0,intena(a6) bsr waitframe move.w d0,dmacon(a6) move.w #$200,bplcon0(a6) move.l #copper1,cop1lc(a6) bsr waitframe move.l #copper2,cop1lc(a6) move.w #DMAF_SETCLR!DMAF_MASTER!DMAF_COPPER,dmacon(a6) move.l #copper1,cop1lc(a6) move.w #DMAF_COPPER,dmacon(a6) .halt bra .halt waitframe move.w #INTF_VERTB,intreq(a6) .wait btst.b #INTB_VERTB,intreqr+1(a6) beq .wait rts section data_c,data_c copper1 dc.w color,$f00 dc.l -2 copper2 dc.w color,$0f0 dc.l -2 The screen goes green indicating that cop1lc was read only after DMA was enabled. |
|
17 July 2024, 18:18 | #18 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,076
|
Hmm, you're right. I did that simple test and it looks like it works that way.
However, your example is constructed in such a way that it seems that enabling copper DMA also acts as a strobe (sequence is: red, VBL, green, enable, red, disable)?!? If that is correct, then resuming wouldn't be possible? I'm confused now. Is there a timing issue or some kind of circuitry "feature" behind it? I was always under impression that the entire strobe thing is decoupled from DMA. |
17 July 2024, 18:35 | #19 | |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,279
|
Quote:
I will leave it to more knowledgeable people to explain exactly what happens, but my mental model is that VBL isn't exactly like strobing COPJMP1, but more like "on next copper used DMA cycle, spend it moving COP1LC -> internal instruction pointer". Tried to make sense of copper state machine in WinUAE source a bit earlier to confirm, but that's beyond my capabilities Don't know if you get into a similar situation otherwise. |
|
17 July 2024, 18:55 | #20 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,076
|
Yeah, did the same earlier today and it's too complicated . It would take some prior knowledge or having to really dig into it to understand all the intricacies.
|
Currently Active Users Viewing This Thread: 2 (1 members and 1 guests) | |
wodan |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Copper WAIT, copper SKIP and $80/$100 vpos problem | defor | Coders. Asm / Hardware | 2 | 23 July 2021 08:32 |
Combining copper scrolling with copper background | phx | Coders. Asm / Hardware | 16 | 13 February 2021 12:41 |
Copper, Horizontal Blanking, and DMA | AlexBruger | support.Hardware | 5 | 19 July 2020 17:31 |
Copper instructions and dma | Jherek Carnelia | Coders. Asm / Hardware | 4 | 05 December 2019 22:33 |
Best way to mix blitting with copper and copper effects | roondar | Coders. Asm / Hardware | 3 | 12 September 2016 13:12 |
|
|