The Socrates Gameboy Advance Development Engine
The SGADE is a development library for the Nintendo Gameboy
Advance. It's free for all uses and is distributed without guarantees.
For more information visit
the SGADE page.
Files | |
| file | SoDMA.c |
| file | SoDMA.h |
Defines | |
| #define | SO_DMA_DEST_INC |
| The destination counter is incremented after each transfer (default). | |
| #define | SO_DMA_DEST_DEC |
| The destination counter is decremented after each transfer. | |
| #define | SO_DMA_DEST_FIX |
| Fixed. | |
| #define | SO_DMA_SOURCE_INC |
| The source counter is incremented after each transfer (default). | |
| #define | SO_DMA_SOURCE_DEC |
| The source counter is decremented after each transfer. | |
| #define | SO_DMA_SOURCE_FIX |
| Fixed. | |
| #define | SO_DMA_REPEAT |
| This will cause the DMA to repeat every HBlank or VBlank if you have that specified in your timing bits. | |
| #define | SO_DMA_16 |
| Copies in 16-bit words (default). | |
| #define | SO_DMA_32 |
| Copies in 32-bit words. | |
| #define | SO_DMA_START_NOW |
| Start immediately (default). | |
| #define | SO_DMA_START_VBL |
| Start at the VBlank. | |
| #define | SO_DMA_START_HBL |
| Start at the HBlank. | |
| #define | SO_DMA_START_FIFO |
| Start when direct sound FIFO is empty. | |
| #define | SO_DMA_INTERRUPT |
| Causes the end of the DMA transfer to generate an interrupt. | |
| #define | SO_DMA_MEMCPY(src, dest, wordcount) |
| copy one block of memory to another | |
| #define | SO_DMA_MEMCPY_REV(src, dest, wordcount) |
| copy one block of memory to another (back to front order) | |
| #define | SO_DMA_MEMSET(dest, wordcount, value) |
| set the contents of memory to a fixed value | |
Functions | |
| void | SoDMAStop (u32 a_Channel) |
| Stops DMA transfer. | |
| void | SoDMATransfer (u32 a_Channel, void *a_Source, void *a_Destination, u32 a_WordCount, u32 a_Control) |
| Transfers a memory block using DMA. | |
| void | SoDMA0Transfer (const void *a_Source, void *a_Destination, u32 a_WordCount, u32 a_Control) |
| Transfers a memory block using DMA channel 0. | |
| void | SoDMA1Transfer (const void *a_Source, void *a_Destination, u32 a_WordCount, u32 a_Control) |
| Transfers a memory block using DMA channel 1. | |
| void | SoDMA2Transfer (const void *a_Source, void *a_Destination, u32 a_WordCount, u32 a_Control) |
| Transfers a memory block using DMA channel 2. | |
| void | SoDMA3Transfer (const void *a_Source, void *a_Destination, u32 a_WordCount, u32 a_Control) |
| Transfers a memory block using DMA channel 3. | |
Singleton
This module takes care of everything that has to do with DMA transfers.
There are 4 seperate DMA channels on the GBA each with their own priority. The highest priority channel is DMA0, then DMA1, then DMA2, and finally DMA3.
Suppose a DMA transfer is currently being executed, and another DMA transfer is started with a higher priority. The current transfer will be halted, and it will resume upon completion of the higher priority DMA.
There are several different uses for DMA, for which different channels are appropriate:
|
|
Start when direct sound FIFO is empty. Only available for DMA channel 1 and 2. |
|
||||||||||||||||||||
|
Transfers a memory block using DMA channel 0.
|
|
||||||||||||||||||||
|
Transfers a memory block using DMA channel 1.
The amount of data can be specified in the range 0x0000 to 0x3FFF (when 0x0000h is set, 0x4000 is used). In 16-bit transfers, up to 0x4000 * 2 bytes = 0x8000 bytes can be transferred, and in 32-bit transfers, up to 0x4000 * 4 = 0x10000 bytes can be transferred. The word-count register setting is not used in direct-sound transfers. With each request received from sound FIFO, 32 bits * 4 words of sound data are transferred. When in direct sound transfers, the destination address is fixed and unrelated to the control settings and the data are transferred in 32-bit units, make sure to select SO_DMA_REPEAT too. When the Gamepakbus has been set to the source address, make sure you select increment. |
|
||||||||||||||||||||
|
Transfers a memory block using DMA channel 2.
The amount of data can be specified in the range 0x0000 to 0x3FFF (when 0x0000h is set, 0x4000 is used). In 16-bit transfers, up to 0x4000 * 2 bytes = 0x8000 bytes can be transferred, and in 32-bit transfers, up to 0x4000 * 4 = 0x10000 bytes can be transferred. The word-count register setting is not used in direct-sound transfers. With each request received from sound FIFO, 32 bits * 4 words of sound data are transferred. When in direct sound transfers, the destination address is fixed and unrelated to the control settings and the data are transferred in 32-bit units, make sure to select SO_DMA_REPEAT too. When the Gamepakbus has been set to the source address, make sure you select increment. |
|
||||||||||||||||||||
|
Transfers a memory block using DMA channel 3.
When transfering from ROM do not use the SO_DMA_REPEAT function. If the source is from ROM, make sure you select SO_DMA_SOURCE_INC (increment). |
|
|
Stops DMA transfer.
|
|
||||||||||||||||||||||||
|
Transfers a memory block using DMA.
|