question about DMA
Moderators: BigEvilCorporation, Mask of Destiny
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Oh, good. By the way, you only need to worry about the DMA data when it crosses a particular boundary, but that doesn't necessarily mean you NEED to align the data to that size - you only need to align to the max size of the DMA which is also an even divisor of that boundary. For example, let's say the largest DMA a particular game/demo does is 11 KB. To make sure it doesn't cross 128KB boundary, you don't need to align to 128KB, you only need to align to 16KB. 16KB is an even divisor of 128KB, and is the next larger size up from the max amount of data DMA'd. If the max you DMA is 128 bytes, you only need to align to 128 bytes.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
The easiest way to avoid 128 KB boundary data problem with DMA is to write a method which split your DMA to not cross 128 KB bank.Chilly Willy wrote:Oh, good. By the way, you only need to worry about the DMA data when it crosses a particular boundary, but that doesn't necessarily mean you NEED to align the data to that size - you only need to align to the max size of the DMA which is also an even divisor of that boundary. For example, let's say the largest DMA a particular game/demo does is 11 KB. To make sure it doesn't cross 128KB boundary, you don't need to align to 128KB, you only need to align to 16KB. 16KB is an even divisor of 128KB, and is the next larger size up from the max amount of data DMA'd. If the max you DMA is 128 bytes, you only need to align to 128 bytes.
It was i did in SGDK so i've never to worry about that...
Last edited by Stef on Tue Jan 10, 2012 6:45 pm, edited 1 time in total.
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
set bank ?zhengyaxin_8bit wrote:Hi stef,how to set bank in sgdk?I'm not mind to do this.
You don't need that, just use :
Code: Select all
u8 myData[0x8000];
...
VDP_doVRamDMA((u32) myData, vram_address, sizeof(myData));
...
See the source of the DMA transfert method here : vdp_dma.c
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Yeah, splitting the transfer in the code is the safest way to deal with it, and saves memory to boot since you aren't padding to reach a boundary.
Uh, does your DMA code break large blocks into smaller ones to avoid causing trouble to PCM audio from the rom?
EDIT: Answering myself, a look at the code linked above, it does not. So that's one thing to keep in mind as an author on the MD - watch out for the size of DMA if you are also playing PCM audio from the rom. Remember that DMA holds off EVERYTHING until it is done, so you can disrupt the PCM playback by the Z80 with DMA.
Uh, does your DMA code break large blocks into smaller ones to avoid causing trouble to PCM audio from the rom?
EDIT: Answering myself, a look at the code linked above, it does not. So that's one thing to keep in mind as an author on the MD - watch out for the size of DMA if you are also playing PCM audio from the rom. Remember that DMA holds off EVERYTHING until it is done, so you can disrupt the PCM playback by the Z80 with DMA.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
IMO as soon you do PCM audio you have to avoid to use DMA.Chilly Willy wrote:Yeah, splitting the transfer in the code is the safest way to deal with it, and saves memory to boot since you aren't padding to reach a boundary.
Uh, does your DMA code break large blocks into smaller ones to avoid causing trouble to PCM audio from the rom?
EDIT: Answering myself, a look at the code linked above, it does not. So that's one thing to keep in mind as an author on the MD - watch out for the size of DMA if you are also playing PCM audio from the rom. Remember that DMA holds off EVERYTHING until it is done, so you can disrupt the PCM playback by the Z80 with DMA.
I do not use any DMA as soon i have PCM audio working on Z80 as my PCM drivers use Z80 cycles to synchronize sample output. When you use DMA, even on small block, sound becomes somewhat distorted.