summaryrefslogtreecommitdiff
path: root/src/Dolphin/GBA/GBARead.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2023-02-01 18:45:02 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2023-02-01 18:50:25 -0400
commit9fa0a7f1da1b70bee995f53c6c96c43189018772 (patch)
tree114548896790eaff23cdca84a025281de86bbb51 /src/Dolphin/GBA/GBARead.c
parent2ba3289286bbfcf9fcc13fd135d976058d8b6c2e (diff)
global: Import Dolphin SDK
This version comes from the Metroid Prime decompilation project. https://github.com/PrimeDecomp/prime
Diffstat (limited to 'src/Dolphin/GBA/GBARead.c')
-rw-r--r--src/Dolphin/GBA/GBARead.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Dolphin/GBA/GBARead.c b/src/Dolphin/GBA/GBARead.c
new file mode 100644
index 0000000..ab19bbb
--- /dev/null
+++ b/src/Dolphin/GBA/GBARead.c
@@ -0,0 +1,42 @@
+#include "dolphin/GBAPriv.h"
+
+void ReadProc(s32 chan) {
+ GBA* gba;
+ gba = &__GBA[chan];
+
+ if (gba->result == 0) {
+ memcpy(gba->buffer, &gba->dst, 4);
+ gba->status[0] = gba->_09 & GBA_JSTAT_MASK;
+ }
+}
+
+s32 GBAReadAsync(s32 chan, u8* dst, u8* status, GBACallback callback) {
+ GBA* gba;
+ s32 ret;
+
+ gba = &__GBA[chan];
+
+ if (gba->callback != NULL) {
+ ret = 2;
+ } else {
+ gba->command = 0x14;
+ gba->buffer = dst;
+ gba->status = status;
+ gba->callback = callback;
+ ret = __GBATransfer(chan, 1, 5, ReadProc);
+ }
+
+ return ret;
+}
+
+
+s32 GBARead(s32 chan, u8* dst, u8* status) {
+ s32 tmp;
+ s32 ret;
+ ret = GBAReadAsync(chan, dst, status, __GBASyncCallback);
+ if (ret != GBA_READY) {
+ return ret;
+ }
+
+ return __GBASync(chan);
+}