aboutsummaryrefslogtreecommitdiff
path: root/sdk-modifications/libsrc/core/ds2_dma.c
diff options
context:
space:
mode:
authorNebuleon Fumika2013-02-04 23:45:44 -0500
committerNebuleon Fumika2013-02-04 23:45:44 -0500
commitd1a7bf5eb558e7db4a1a27e15ebedb02e6b7f804 (patch)
treed951252d393b9d7defb508483aba29e0daad764c /sdk-modifications/libsrc/core/ds2_dma.c
parentb1c298ab5066c2e37a69c7c30bd499dd11ed6eb3 (diff)
downloadsnes9x2005-d1a7bf5eb558e7db4a1a27e15ebedb02e6b7f804.tar.gz
snes9x2005-d1a7bf5eb558e7db4a1a27e15ebedb02e6b7f804.tar.bz2
snes9x2005-d1a7bf5eb558e7db4a1a27e15ebedb02e6b7f804.zip
Fully integrate BassAceGold's libraries, finally. The README still states that 1.2 is required to overwrite 0.13's stuff; really, 0.13 is needed only for `gcc`. So the sequence goes 0.13's `gcc` -> 1.2 -> BassAceGold's libraries -> make `libds2a.a`.
DMA function names changed to match BassAceGold's.
Diffstat (limited to 'sdk-modifications/libsrc/core/ds2_dma.c')
-rw-r--r--sdk-modifications/libsrc/core/ds2_dma.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/sdk-modifications/libsrc/core/ds2_dma.c b/sdk-modifications/libsrc/core/ds2_dma.c
new file mode 100644
index 0000000..0b0eca1
--- /dev/null
+++ b/sdk-modifications/libsrc/core/ds2_dma.c
@@ -0,0 +1,34 @@
+#include "ds2_dma.h"
+
+
+
+//register a DMA transfer request
+//ch: channel id request, there are 6 channles,
+//irq_handler: the DMA interruption handle
+//arg: argument to the handle
+//mode: DMA mode, such as port width, address increased/fixed, and so on
+//type: DMA request type
+extern int dma_request(int ch, void (*irq_handler)(unsigned int), unsigned int arg,
+ unsigned int mode, unsigned int type);
+
+//start DMA transfer, must request a DMA first
+//ch: channel id
+//srcAddr: DMA source address
+//dstAddr: DMA destination address
+//count: DMA transfer count, the total bytes due the mode in dma_request
+extern void dma_start(int ch, unsigned int srcAddr, unsigned int dstAddr,
+ unsigned int count);
+
+
+int _dmaCopy(int ch, void *dest, void *src, unsigned int size, unsigned int flags){
+ int test = 0;
+ if(!(test = dma_request(ch, 0, 0,
+ //increment dest addr
+ DMAC_DCMD_DAI | flags,
+ //auto request type
+ DMAC_DRSR_RS_AUTO)))
+ {
+ dma_start(ch, (unsigned int)src, (unsigned int)dest, size);
+ }
+ return test;
+}