aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNebuleon Fumika2013-02-03 15:29:05 -0500
committerNebuleon Fumika2013-02-03 15:29:05 -0500
commit397bf5192a44ea95a82a9792cb7a8a23b112bb3e (patch)
treef53a62fdb5d4490ccff260c4d01bd667c0a251b3
parent9b75c09a7fd7c78d8c42077478e796672fae5c1b (diff)
downloadsnes9x2005-397bf5192a44ea95a82a9792cb7a8a23b112bb3e.tar.gz
snes9x2005-397bf5192a44ea95a82a9792cb7a8a23b112bb3e.tar.bz2
snes9x2005-397bf5192a44ea95a82a9792cb7a8a23b112bb3e.zip
Add some forgotten DMA files.
-rw-r--r--source/nds/dma_adj.c26
-rw-r--r--source/nds/dma_adj.h25
2 files changed, 51 insertions, 0 deletions
diff --git a/source/nds/dma_adj.c b/source/nds/dma_adj.c
new file mode 100644
index 0000000..8b6f9ad
--- /dev/null
+++ b/source/nds/dma_adj.c
@@ -0,0 +1,26 @@
+#include "ds2_malloc.h"
+#include "dma_adj.h"
+
+#ifdef DS2_DMA
+
+struct SPointerAdjustments PtrAdj;
+
+void* AlignedMalloc (unsigned int Size, unsigned int Alignment, unsigned int* Adjustment)
+{
+ if (Alignment == 0) Alignment = 1;
+
+ unsigned char* result = (unsigned char*) malloc(Size + Alignment);
+ if (!result) {
+ return result;
+ } else {
+ *Adjustment = Alignment - ((unsigned int) result & (Alignment - 1));
+ return (void*) (result + *Adjustment);
+ }
+}
+
+void AlignedFree (void* Memory, unsigned int Adjustment)
+{
+ free((void*) ((unsigned char*) Memory - Adjustment));
+}
+
+#endif // DS2_DMA
diff --git a/source/nds/dma_adj.h b/source/nds/dma_adj.h
new file mode 100644
index 0000000..62b0098
--- /dev/null
+++ b/source/nds/dma_adj.h
@@ -0,0 +1,25 @@
+#ifndef _DMA_ADJ_H_
+#define _DMA_ADJ_H_
+
+#ifdef DS2_DMA
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct SPointerAdjustments {
+ unsigned int GFXScreen;
+};
+
+extern struct SPointerAdjustments PtrAdj;
+
+extern void* AlignedMalloc (unsigned int Size, unsigned int Alignment, unsigned int* Adjustment);
+extern void AlignedFree (void* Memory, unsigned int Adjustment);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // DS2_DMA
+
+#endif // !_DMA_ADJ_H_