question about DMA

For anything related to VDP (plane, color, sprite, tiles)

Moderators: BigEvilCorporation, Mask of Destiny

zhengyaxin_8bit
Very interested
Posts: 101
Joined: Thu Sep 04, 2008 2:57 am
Location: China

Post by zhengyaxin_8bit » Mon Jan 09, 2012 3:06 pm

Yes, Change brs to jsr ,the error disappear. :D
Thanks you very much

zhengyaxin_8bit
Very interested
Posts: 101
Joined: Thu Sep 04, 2008 2:57 am
Location: China

Post by zhengyaxin_8bit » Mon Jan 09, 2012 3:26 pm

Now,I have know how to creat the map file ,and use C or asm to fixed data. The question of DMA's transmission has solved. :D

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Mon Jan 09, 2012 7:00 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.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Tue Jan 10, 2012 12:09 pm

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.
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.
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.

zhengyaxin_8bit
Very interested
Posts: 101
Joined: Thu Sep 04, 2008 2:57 am
Location: China

Post by zhengyaxin_8bit » Tue Jan 10, 2012 4:54 pm

Hi stef,how to set bank in sgdk?I'm not mind to do this.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Tue Jan 10, 2012 6:55 pm

zhengyaxin_8bit wrote:Hi stef,how to set bank in sgdk?I'm not mind to do this.
set bank ?

You don't need that, just use :

Code: Select all

u8 myData[0x8000];

...

VDP_doVRamDMA((u32) myData, vram_address, sizeof(myData));
...
and your DMA will be safe.

See the source of the DMA transfert method here : vdp_dma.c

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Jan 10, 2012 8:25 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. :D

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.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Wed Jan 11, 2012 9:12 am

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. :D

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.
IMO as soon you do PCM audio you have to avoid to use 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.

Post Reply