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.
00001 // ---------------------------------------------------------------------------- 00013 // ---------------------------------------------------------------------------- 00014 00015 #ifndef SO_DMA_H 00016 #define SO_DMA_H 00017 00018 #ifdef __cplusplus 00019 extern "C" { 00020 #endif 00021 00022 // ---------------------------------------------------------------------------- 00073 00075 // ---------------------------------------------------------------------------- 00076 00077 // ---------------------------------------------------------------------------- 00078 // Includes 00079 // ---------------------------------------------------------------------------- 00080 #include "SoSystem.h" 00081 00082 // ---------------------------------------------------------------------------- 00083 // Defines 00084 // ---------------------------------------------------------------------------- 00085 00086 #define SO_DMA_DEST_INC 0 00087 #define SO_DMA_DEST_DEC (SO_BIT_5) 00088 #define SO_DMA_DEST_FIX (SO_BIT_6) 00089 00090 #define SO_DMA_SOURCE_INC 0 00091 #define SO_DMA_SOURCE_DEC (SO_BIT_7) 00092 #define SO_DMA_SOURCE_FIX (SO_BIT_8) 00093 00094 #define SO_DMA_REPEAT (SO_BIT_9) 00095 00096 #define SO_DMA_16 0 00097 #define SO_DMA_32 (SO_BIT_10) 00098 00099 #define SO_DMA_START_NOW 0 00100 #define SO_DMA_START_VBL (SO_BIT_12) 00101 #define SO_DMA_START_HBL (SO_BIT_13) 00102 00105 #define SO_DMA_START_FIFO (SO_BIT_12 | SO_BIT_13) 00106 00108 #define SO_DMA_INTERRUPT (SO_BIT_14) 00109 00110 00111 // ---------------------------------------------------------------------------- 00112 // Macros; 00113 // ---------------------------------------------------------------------------- 00114 00116 #define SO_DMA_MEMCPY(src, dest, wordcount) \ 00117 { \ 00118 SoDMATransfer(3, (void*)src, (void*)dest, wordcount, \ 00119 SO_DMA_SOURCE_INC|SO_DMA_DEST_INC|SO_DMA_32); \ 00120 } 00121 00123 #define SO_DMA_MEMCPY_REV(src, dest, wordcount) \ 00124 { \ 00125 SoDMATransfer(3, (u32*)(src)+((wordcount)-1), \ 00126 (u32*)(dest)+((wordcount)-1), wordcount, \ 00127 SO_DMA_SOURCE_DEC|SO_DMA_DEST_DEC|SO_DMA_32); \ 00128 } 00129 00131 #define SO_DMA_MEMSET(dest, wordcount, value) \ 00132 { \ 00133 u32 data = value; \ 00134 SoDMATransfer(3, &data, (void*)dest, wordcount, \ 00135 SO_DMA_SOURCE_FIX|SO_DMA_DEST_INC|SO_DMA_32); \ 00136 } 00137 00138 00139 // ---------------------------------------------------------------------------- 00140 // Public methods; 00141 // ---------------------------------------------------------------------------- 00142 void SoDMAStop( u32 a_Channel ); 00143 00144 void SoDMATransfer ( u32 a_Channel, void* a_Source, void* a_Destination, u32 a_WordCount, u32 a_Control ); 00145 00146 void SoDMA0Transfer( const void *a_Source, void *a_Destination, u32 a_WordCount, u32 a_Control ); 00147 void SoDMA1Transfer( const void *a_Source, void *a_Destination, u32 a_WordCount, u32 a_Control ); 00148 void SoDMA2Transfer( const void *a_Source, void *a_Destination, u32 a_WordCount, u32 a_Control ); 00149 void SoDMA3Transfer( const void *a_Source, void *a_Destination, u32 a_WordCount, u32 a_Control ); 00150 00151 // ---------------------------------------------------------------------------- 00152 // EOF; 00153 // ---------------------------------------------------------------------------- 00154 00156 00157 #ifdef __cplusplus 00158 } // extern "C" 00159 #endif 00160 00161 #endif