Page 2 of 2
Posted: Mon Jan 09, 2012 3:06 pm
by zhengyaxin_8bit
Yes, Change brs to jsr ,the error disappear.
Thanks you very much
Posted: Mon Jan 09, 2012 3:26 pm
by zhengyaxin_8bit
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.

Posted: Mon Jan 09, 2012 7:00 pm
by Chilly Willy
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.
Posted: Tue Jan 10, 2012 12:09 pm
by Stef
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...
Posted: Tue Jan 10, 2012 4:54 pm
by zhengyaxin_8bit
Hi stef,how to set bank in sgdk?I'm not mind to do this.
Posted: Tue Jan 10, 2012 6:55 pm
by Stef
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
Posted: Tue Jan 10, 2012 8:25 pm
by Chilly Willy
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.
Posted: Wed Jan 11, 2012 9:12 am
by Stef
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.
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.