diff options
Diffstat (limited to 'gba/source/link.c')
-rw-r--r-- | gba/source/link.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/gba/source/link.c b/gba/source/link.c index 26443c8..05e4732 100644 --- a/gba/source/link.c +++ b/gba/source/link.c | |||
@@ -12,9 +12,9 @@ | |||
12 | 12 | ||
13 | void initializeLink() | 13 | void initializeLink() |
14 | { | 14 | { |
15 | REG_HS_CTRL |= JOY_RW; | ||
16 | REG_JOYTR = 0; | 15 | REG_JOYTR = 0; |
17 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | 16 | REG_HS_CTRL |= JOY_RW; |
17 | while ((REG_HS_CTRL & JOY_READ) == 0); | ||
18 | REG_HS_CTRL |= JOY_RW; | 18 | REG_HS_CTRL |= JOY_RW; |
19 | } | 19 | } |
20 | 20 | ||
@@ -22,29 +22,22 @@ void waitForAck() | |||
22 | { | 22 | { |
23 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | 23 | while ((REG_HS_CTRL & JOY_WRITE) == 0); |
24 | REG_HS_CTRL |= JOY_RW; | 24 | REG_HS_CTRL |= JOY_RW; |
25 | REG_JOYTR = 0; | ||
26 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | ||
27 | REG_HS_CTRL |= JOY_RW; | ||
28 | } | 25 | } |
29 | 26 | ||
30 | u32 waitForResponse() | 27 | u32 waitForResponse() |
31 | { | 28 | { |
32 | u32 val; | 29 | u32 val; |
33 | 30 | ||
34 | REG_JOYTR = 1; | ||
35 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | ||
36 | val = REG_JOYRE; | ||
37 | REG_HS_CTRL |= JOY_RW; | ||
38 | REG_JOYTR = 0; | ||
39 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | 31 | while ((REG_HS_CTRL & JOY_WRITE) == 0); |
40 | REG_HS_CTRL |= JOY_RW; | 32 | REG_HS_CTRL |= JOY_RW; |
33 | val = REG_JOYRE; | ||
41 | 34 | ||
42 | return val; | 35 | return val; |
43 | } | 36 | } |
44 | 37 | ||
45 | void sendS32(s32 val) | 38 | void sendS32(s32 val) |
46 | { | 39 | { |
47 | REG_JOYTR = val; | 40 | sendU32(val); |
48 | } | 41 | } |
49 | 42 | ||
50 | void sendU32(u32 val) | 43 | void sendU32(u32 val) |