summaryrefslogtreecommitdiff
path: root/arm9/lib
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/lib')
-rw-r--r--arm9/lib/include/MI_dma.h3
-rw-r--r--arm9/lib/include/MI_dma_card.h8
-rw-r--r--arm9/lib/src/MI_dma_card.c24
3 files changed, 35 insertions, 0 deletions
diff --git a/arm9/lib/include/MI_dma.h b/arm9/lib/include/MI_dma.h
index e8938ef9..bf07129a 100644
--- a/arm9/lib/include/MI_dma.h
+++ b/arm9/lib/include/MI_dma.h
@@ -16,6 +16,9 @@ typedef void (*MIDmaCallback)(void *);
#define MI_CNT_COPY32_IF(size) (0xc4000000 | ((size)/4))
#define MI_CNT_COPY16(size) (0x80000000 | ((size)/2))
+#define MI_DMA_SRC_FIX (2UL << 23)
+#define MIi_DMA_TIMING_ANY (u32)(~0)
+
typedef union
{
u32 b32;
diff --git a/arm9/lib/include/MI_dma_card.h b/arm9/lib/include/MI_dma_card.h
new file mode 100644
index 00000000..efd70ba6
--- /dev/null
+++ b/arm9/lib/include/MI_dma_card.h
@@ -0,0 +1,8 @@
+#ifndef POKEDIAMOND_MI_DMA_CARD_H
+#define POKEDIAMOND_MI_DMA_CARD_H
+
+#include "nitro/types.h"
+
+void MIi_CardDmaCopy32(u32 dmaNo, const void *src, void *dest, u32 size);
+
+#endif //POKEDIAMOND_MI_DMA_CARD_H
diff --git a/arm9/lib/src/MI_dma_card.c b/arm9/lib/src/MI_dma_card.c
new file mode 100644
index 00000000..c3b8b897
--- /dev/null
+++ b/arm9/lib/src/MI_dma_card.c
@@ -0,0 +1,24 @@
+#include "MI_dma_card.h"
+#include "MI_dma.h"
+#include "function_target.h"
+
+ARM_FUNC void MIi_CardDmaCopy32(u32 dmaNo, const void *src, void *dest, u32 size)
+{
+ MIi_CheckAnotherAutoDMA(dmaNo, MIi_DMA_TIMING_ANY);
+ MIi_CheckDma0SourceAddress(dmaNo, (u32)src, size, MI_DMA_SRC_FIX);
+
+ if (size == 0)
+ {
+ return;
+ }
+
+ vu32 *dmaCntp;
+
+ do
+ {
+ dmaCntp = &((vu32 *)REG_ADDR_DMA0SAD)[dmaNo * 3 + 2];
+ while (*dmaCntp & 0x80000000) {}
+ } while(0);
+
+ MIi_DmaSetParams(dmaNo, (u32)src, (u32)dest, (u32)(0xaf000001));
+}