From 57afb4058710a978bd7b07a368125d04378c62f1 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 11 Jul 2017 16:37:21 -0400 Subject: started tweaking with stuff --- gba/source/link.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 gba/source/link.c (limited to 'gba/source/link.c') diff --git a/gba/source/link.c b/gba/source/link.c new file mode 100644 index 0000000..e695622 --- /dev/null +++ b/gba/source/link.c @@ -0,0 +1,41 @@ +#include "link.h" + +#define JOY_WRITE 2 +#define JOY_READ 4 +#define JOY_RW 6 + +void waitForWriteAccess() +{ + //while ((REG_HS_CTRL & JOY_READ) == 0); + while ((REG_HS_CTRL & JOY_WRITE) == 0); + REG_HS_CTRL |= JOY_RW; +} + +void waitForAck() +{ + while ((REG_HS_CTRL & JOY_WRITE) == 0); + REG_HS_CTRL |= JOY_RW; + REG_JOYTR = 0; + while ((REG_HS_CTRL & JOY_WRITE) == 0); + REG_HS_CTRL |= JOY_RW; +} + +void sendS32(s32 val) +{ + REG_JOYTR = val; + //waitForWriteAccess(); +} + +void sendU32(u32 val) +{ + REG_JOYTR = val; + //waitForWriteAccess(); +} + +u32 recieveU32() +{ + while ((REG_HS_CTRL & JOY_WRITE) == 0); + REG_HS_CTRL |= JOY_RW; + return REG_JOYRE; +} + -- cgit 1.4.1