summaryrefslogtreecommitdiff
path: root/src/Dolphin/GBA/GBAWrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Dolphin/GBA/GBAWrite.c')
-rw-r--r--src/Dolphin/GBA/GBAWrite.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Dolphin/GBA/GBAWrite.c b/src/Dolphin/GBA/GBAWrite.c
new file mode 100644
index 0000000..f040f92
--- /dev/null
+++ b/src/Dolphin/GBA/GBAWrite.c
@@ -0,0 +1,42 @@
+#include "dolphin/GBAPriv.h"
+
+void WriteProc(s32 chan) {
+ GBA* gba;
+ gba = &__GBA[chan];
+
+ if (gba->result != 0) {
+ return;
+ }
+
+ gba->status[0] = gba->dst[0] & GBA_JSTAT_MASK;
+}
+
+s32 GBAWriteAsync(s32 chan, u8* src, u8* status, GBACallback callback) {
+ GBA* gba;
+ s32 ret;
+ gba = &__GBA[chan];
+
+ if (gba->callback != NULL) {
+ ret = GBA_BUSY;
+ } else {
+ gba->command = 0x15;
+ memcpy(gba->src, src, 4);
+ gba->buffer = src;
+ gba->status = status;
+ gba->callback = callback;
+ ret = __GBATransfer(chan, 5, 1, WriteProc);
+ }
+
+ return ret;
+}
+
+
+s32 GBAWrite(s32 chan, u8* src, u8* status) {
+ s32 ret;
+ s32 tmp;
+ ret = GBAWriteAsync(chan, src, status, __GBASyncCallback);
+ if (ret != GBA_READY) {
+ return ret;
+ }
+ return __GBASync(chan);
+}