summaryrefslogtreecommitdiff
path: root/arm9/lib/src
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@users.noreply.github.com>2020-09-09 13:42:32 -0400
committerGitHub <noreply@github.com>2020-09-09 13:42:32 -0400
commit4d9614826c565c4ad22da1c988034ff2bff4001a (patch)
tree60650bf82207f63ff387e3855f88bae86e715325 /arm9/lib/src
parent8aba1bb4d0cb579bae4d797588c3ca85466b6e20 (diff)
parent85cf49ed0d9d8837e6e5dc9537b0c77a2f966f13 (diff)
Merge pull request #284 from red031000/master
arm9 MI_dma_card and MI_dma_hblank
Diffstat (limited to 'arm9/lib/src')
-rw-r--r--arm9/lib/src/MI_dma.c4
-rw-r--r--arm9/lib/src/MI_dma_card.c24
-rw-r--r--arm9/lib/src/MI_dma_hblank.c31
-rw-r--r--arm9/lib/src/MI_init.c1
4 files changed, 58 insertions, 2 deletions
diff --git a/arm9/lib/src/MI_dma.c b/arm9/lib/src/MI_dma.c
index 565b1ef6..f322f87f 100644
--- a/arm9/lib/src/MI_dma.c
+++ b/arm9/lib/src/MI_dma.c
@@ -258,8 +258,8 @@ ARM_FUNC void MIi_CheckAnotherAutoDMA(u32 dmaNo, u32 dmaType)
timing = dmaCnt & 0x38000000;
if (timing == dmaType
- || (timing == 0x8000000 && dmaType == 0x10000000)
- || (timing == 0x10000000 && dmaType == 0x8000000))
+ || (timing == 0x8000000 && dmaType == MI_DMA_TIMING_H_BLANK)
+ || (timing == MI_DMA_TIMING_H_BLANK && dmaType == 0x8000000))
{
continue;
}
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));
+}
diff --git a/arm9/lib/src/MI_dma_hblank.c b/arm9/lib/src/MI_dma_hblank.c
new file mode 100644
index 00000000..67e579fe
--- /dev/null
+++ b/arm9/lib/src/MI_dma_hblank.c
@@ -0,0 +1,31 @@
+#include "MI_dma_hblank.h"
+#include "MI_dma.h"
+#include "function_target.h"
+
+ARM_FUNC void MI_HBlankDmaCopy32(u32 dmaNo, const void *src, void *dest, u32 size)
+{
+ MIi_CheckAnotherAutoDMA(dmaNo, MI_DMA_TIMING_H_BLANK);
+ MIi_CheckDma0SourceAddress(dmaNo, (u32)src, size, MI_DMA_SRC_INC);
+
+ if (size == 0)
+ {
+ return;
+ }
+
+ MI_WaitDma(dmaNo);
+ MIi_DmaSetParams(dmaNo, (u32)src, (u32)dest, (u32)(0x96600000 | (size / 4)));
+}
+
+ARM_FUNC void MI_HBlankDmaCopy16(u32 dmaNo, const void *src, void *dest, u32 size)
+{
+ MIi_CheckAnotherAutoDMA(dmaNo, MI_DMA_TIMING_H_BLANK);
+ MIi_CheckDma0SourceAddress(dmaNo, (u32)src, size, MI_DMA_SRC_INC);
+
+ if (size == 0)
+ {
+ return;
+ }
+
+ MI_WaitDma(dmaNo);
+ MIi_DmaSetParams(dmaNo, (u32)src, (u32)dest, (u32)(0x92600000 | (size / 2)));
+}
diff --git a/arm9/lib/src/MI_init.c b/arm9/lib/src/MI_init.c
index 4556e95a..4c861286 100644
--- a/arm9/lib/src/MI_init.c
+++ b/arm9/lib/src/MI_init.c
@@ -1,3 +1,4 @@
+#include "MI_init.h"
#include "nitro/types.h"
#include "function_target.h"
#include "MI_dma.h"