The SGADE Documentation

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


Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

SoDMA

All DMA handling. More...

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.


Detailed Description

All DMA handling.

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:

Perform the following steps when you want to do a DMA transfer:

Warning:
When SO_DMA_REPEAT is set and V-blanking or H-blanking are selected as the moment of DMA startup, DMA is restarted when the next startup condition occurs (a VBlank or HBlank). In this mode, restarting will continue as long as the DMA enable flag is set. To clear this flag and prevent the DMA from restarting, use the SoDMAStop method
Warning:
When transferring data to OAM or OBJ VRAM by DMA during a H-blank, the HBlank must first be freed from OBJ display hardware processing periods using the SO_REG_DISP_CNT register.

Define Documentation

#define SO_DMA_START_FIFO
 

Start when direct sound FIFO is empty.

Only available for DMA channel 1 and 2.


Function Documentation

void SoDMA0Transfer const void *    a_Source,
void *    a_Destination,
u32    a_WordCount,
u32    a_Control
 

Transfers a memory block using DMA channel 0.

Parameters:
a_Source  Source address
a_Destination  Destination address
a_WordCount  Set the number of data items transferred
a_Control  Specifies the transfer method
DMA0 has the highest priority, and is therefore never interrupted. It's best to use it for short bursts of transfer that need to be reliable, for example during HBlank intervals.

Note:
The area 0x00000000-0x7FFFFFF (All RAM space) can be specified as source and destination.
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.

void SoDMA1Transfer const void *    a_Source,
void *    a_Destination,
u32    a_WordCount,
u32    a_Control
 

Transfers a memory block using DMA channel 1.

Parameters:
a_Source  Source address
a_Destination  Destination address
a_WordCount  Set the number of data items transferred
a_Control  Specifies the transfer method
Note:
The area 0x00000000 to 0xFFFFFFF (ROM and RAM) can be used as source.
The area 0x00000000 to 0x7FFFFFF (RAM only) can be used as destination.

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.

void SoDMA2Transfer const void *    a_Source,
void *    a_Destination,
u32    a_WordCount,
u32    a_Control
 

Transfers a memory block using DMA channel 2.

Parameters:
a_Source  Source address
a_Destination  Destination address
a_WordCount  Set the number of data items transferred
a_Control  Specifies the transfer method
DMA2 is used for direct sound functions, which require relatively high priority, or for general-purpose transfers.

Note:
The area 0x00000000 to 0xFFFFFFF (ROM and RAM) can be used as source.
The area 0x00000000 to 0x7FFFFFF (RAM only) can be used as destination.

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.

void SoDMA3Transfer const void *    a_Source,
void *    a_Destination,
u32    a_WordCount,
u32    a_Control
 

Transfers a memory block using DMA channel 3.

Parameters:
a_Source  Source address
a_Destination  Destination address
a_WordCount  Set the number of data items transferred
a_Control  Specifies the transfer method
DMA3 is used for the most general types of transfers.

Warning:
The area 0x00000000 - 0x0FFFFFFF (all addresses) can be specified as source and destination addresses.
The number of data items can be specified in the range 0x0000 to 0xFFFF (when 0x0000h is used, 0x10000 is done. Thus, in 16-bit data transfer mode, up to 0x10000 * 2 bytes = 0x20000 bytes can be transferred, and in 32-bit data transfer mode, up to 0x10000 * 4 bytes = 0x40000 bytes can be transferred.

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

void SoDMAStop u32    a_Channel
 

Stops DMA transfer.

Parameters:
a_Channel  DMA channel

void SoDMATransfer u32    a_Channel,
void *    a_Source,
void *    a_Destination,
u32    a_WordCount,
u32    a_Control
 

Transfers a memory block using DMA.

Parameters:
a_Channel  DMA channel
a_Source  Source address
a_Destination  Destination address
a_WordCount  Set the number of data items transferred
a_Control  Specifies the transfer method


Copyright 2002 by the SGADE authors. See SoLicense.h or Visit the SGADE page for more information.