diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gba-buttons.c | 233 | ||||
-rw-r--r-- | src/main.c | 140 |
2 files changed, 309 insertions, 64 deletions
diff --git a/src/gba-buttons.c b/src/gba-buttons.c new file mode 100644 index 0000000..d9553a5 --- /dev/null +++ b/src/gba-buttons.c | |||
@@ -0,0 +1,233 @@ | |||
1 | u32 gba_buttons_tiles[224][8] = { | ||
2 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
3 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
4 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
5 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
6 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
7 | {0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x11000100, 0x01000010, 0x11000010}, | ||
8 | {0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001, 0x01000010, 0x01000001}, | ||
9 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
10 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
11 | {0x01000010, 0x01000010, 0x11000010, 0x00000110, 0x00001100, 0x00110100, 0x11001000, 0x00110000}, | ||
12 | {0x01000010, 0x01000010, 0x01000001, 0x01100000, 0x00110000, 0x00101100, 0x00010011, 0x00001100}, | ||
13 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
14 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
15 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
16 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
17 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
18 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
19 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
20 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
21 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
22 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
23 | {0x00000000, 0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x11000100, 0x01000010}, | ||
24 | {0x00000000, 0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001, 0x01000010}, | ||
25 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
26 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
27 | {0x11000010, 0x01000010, 0x01000010, 0x11000010, 0x00000100, 0x00001100, 0x00111000, 0x11110000}, | ||
28 | {0x01000001, 0x01000010, 0x01000010, 0x01000001, 0x00100000, 0x00110000, 0x00011100, 0x00001111}, | ||
29 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
30 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
31 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
32 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
33 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
34 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
35 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
36 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
37 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
38 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
39 | {0x00000000, 0x10000000, 0x00000000, 0x11000100, 0x00110000, 0x00001000, 0x00000100, 0x11000100}, | ||
40 | {0x00000000, 0x00000000, 0x00000000, 0x00100011, 0x00001100, 0x00010000, 0x00100000, 0x00100001}, | ||
41 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
42 | {0x00000000, 0x00000000, 0x10000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
43 | {0x01000010, 0x11000010, 0x01000010, 0x01000010, 0x11000100, 0x00000100, 0x00001000, 0x00110010}, | ||
44 | {0x01000010, 0x01000001, 0x01000010, 0x01000010, 0x00100001, 0x00100000, 0x00010000, 0x01001100}, | ||
45 | {0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
46 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
47 | {0x11000000, 0x00000000, 0x10000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
48 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
49 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
50 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000000}, | ||
51 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x10000000, 0x10000000}, | ||
52 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
53 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000010}, | ||
54 | {0x10000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
55 | {0x00000000, 0x00000001, 0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x11000100}, | ||
56 | {0x00000000, 0x10000000, 0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001}, | ||
57 | {0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
58 | {0x00000000, 0x00000000, 0x00111000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
59 | {0x01000010, 0x11000010, 0x01000010, 0x01000010, 0x11000100, 0x00000100, 0x00001000, 0x00110000}, | ||
60 | {0x01000010, 0x01000001, 0x01000010, 0x01000010, 0x00100001, 0x00100000, 0x00010000, 0x00001100}, | ||
61 | {0x00000000, 0x00000000, 0x00011100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
62 | {0x00000000, 0x10000000, 0x01000000, 0x00100000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
63 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x10000000, 0x10000000, 0x00000000}, | ||
64 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
65 | {0x00000000, 0x00000001, 0x00000010, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
66 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00100000, 0x01000000}, | ||
67 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x10000000, 0x00000000, 0x00000000}, | ||
68 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
69 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00000010}, | ||
70 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
71 | {0x00000000, 0x00000000, 0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x11000100}, | ||
72 | {0x00000000, 0x00000000, 0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001}, | ||
73 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
74 | {0x00000000, 0x00000000, 0x00001100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
75 | {0x01000010, 0x11000010, 0x01000010, 0x01000010, 0x11000100, 0x00000100, 0x00001000, 0x00110000}, | ||
76 | {0x01000010, 0x01000001, 0x01000010, 0x01000010, 0x00100001, 0x00100000, 0x00010000, 0x00001100}, | ||
77 | {0x00000000, 0x00000000, 0x00110000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
78 | {0x00000000, 0x00000000, 0x00000000, 0x00100000, 0x00010000, 0x00000000, 0x00000000, 0x00000000}, | ||
79 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x10000000, 0x00000000}, | ||
80 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
81 | {0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00001000, 0x00000000, 0x00000000, 0x00000000}, | ||
82 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00100000, 0x00000000}, | ||
83 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x00000000, 0x00000000, 0x00000000}, | ||
84 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
85 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00000000}, | ||
86 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
87 | {0x00000000, 0x00000000, 0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x11000100}, | ||
88 | {0x00000000, 0x00000000, 0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001}, | ||
89 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
90 | {0x00000000, 0x00000000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
91 | {0x01000010, 0x11000010, 0x01000010, 0x01000010, 0x11000100, 0x00000100, 0x00001000, 0x00110000}, | ||
92 | {0x01000010, 0x01000001, 0x01000010, 0x01000010, 0x00100001, 0x00100000, 0x00010000, 0x00001100}, | ||
93 | {0x00000000, 0x00000000, 0x00100000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
94 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, 0x00000000, 0x00000000}, | ||
95 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x00000000}, | ||
96 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
97 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001000, 0x00000000, 0x00000000, 0x00000000}, | ||
98 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
99 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
100 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
101 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
102 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
103 | {0x00000000, 0x00000000, 0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x11000100}, | ||
104 | {0x00000000, 0x00000000, 0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001}, | ||
105 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
106 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
107 | {0x01000010, 0x11000010, 0x01000010, 0x01000010, 0x11000100, 0x00000100, 0x00001000, 0x00110000}, | ||
108 | {0x01000010, 0x01000001, 0x01000010, 0x01000010, 0x00100001, 0x00100000, 0x00010000, 0x00001100}, | ||
109 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
110 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
111 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
112 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
113 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
114 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
115 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
116 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
117 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
118 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
119 | {0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x10000100, 0x01000010, 0x01000010}, | ||
120 | {0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001, 0x01000010, 0x01000010}, | ||
121 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
122 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
123 | {0x11000010, 0x01000010, 0x01000010, 0x00000110, 0x00001100, 0x00110100, 0x11001000, 0x00110000}, | ||
124 | {0x01000011, 0x01000010, 0x01000010, 0x01100000, 0x00110000, 0x00101100, 0x00010011, 0x00001100}, | ||
125 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
126 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
127 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
128 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
129 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
130 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
131 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
132 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
133 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
134 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
135 | {0x00000000, 0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x10000100, 0x01000010}, | ||
136 | {0x00000000, 0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001, 0x01000010}, | ||
137 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
138 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
139 | {0x01000010, 0x11000010, 0x01000010, 0x01000010, 0x00000100, 0x00001100, 0x00111000, 0x11110000}, | ||
140 | {0x01000010, 0x01000011, 0x01000010, 0x01000010, 0x00100000, 0x00110000, 0x00011100, 0x00001111}, | ||
141 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
142 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
143 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
144 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
145 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
146 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
147 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
148 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
149 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
150 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
151 | {0x00000000, 0x10000000, 0x00000000, 0x11000100, 0x00110000, 0x00001000, 0x00000100, 0x10000100}, | ||
152 | {0x00000000, 0x00000000, 0x00000000, 0x00100011, 0x00001100, 0x00010000, 0x00100000, 0x00100001}, | ||
153 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
154 | {0x00000000, 0x00000000, 0x10000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
155 | {0x01000010, 0x01000010, 0x11000010, 0x01000010, 0x01000100, 0x00000100, 0x00001000, 0x00110010}, | ||
156 | {0x01000010, 0x01000010, 0x01000011, 0x01000010, 0x00100010, 0x00100000, 0x00010000, 0x01001100}, | ||
157 | {0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
158 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
159 | {0x11000000, 0x00000000, 0x10000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
160 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
161 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
162 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01000000}, | ||
163 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x10000000, 0x10000000}, | ||
164 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
165 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000010}, | ||
166 | {0x10000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
167 | {0x00000000, 0x00000001, 0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x10000100}, | ||
168 | {0x00000000, 0x10000000, 0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001}, | ||
169 | {0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
170 | {0x00000000, 0x00000000, 0x00111000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
171 | {0x01000010, 0x01000010, 0x11000010, 0x01000010, 0x01000100, 0x00000100, 0x00001000, 0x00110000}, | ||
172 | {0x01000010, 0x01000010, 0x01000011, 0x01000010, 0x00100010, 0x00100000, 0x00010000, 0x00001100}, | ||
173 | {0x00000000, 0x00000000, 0x00011100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
174 | {0x00000000, 0x10000000, 0x01000000, 0x00100000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
175 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x10000000, 0x10000000, 0x00000000}, | ||
176 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
177 | {0x00000000, 0x00000001, 0x00000010, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
178 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00100000, 0x01000000}, | ||
179 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x10000000, 0x00000000, 0x00000000}, | ||
180 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
181 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00000010}, | ||
182 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
183 | {0x00000000, 0x00000000, 0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x10000100}, | ||
184 | {0x00000000, 0x00000000, 0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001}, | ||
185 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
186 | {0x00000000, 0x00000000, 0x00001100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
187 | {0x01000010, 0x01000010, 0x11000010, 0x01000010, 0x01000100, 0x00000100, 0x00001000, 0x00110000}, | ||
188 | {0x01000010, 0x01000010, 0x01000011, 0x01000010, 0x00100010, 0x00100000, 0x00010000, 0x00001100}, | ||
189 | {0x00000000, 0x00000000, 0x00110000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
190 | {0x00000000, 0x00000000, 0x00000000, 0x00100000, 0x00010000, 0x00000000, 0x00000000, 0x00000000}, | ||
191 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x10000000, 0x00000000}, | ||
192 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
193 | {0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00001000, 0x00000000, 0x00000000, 0x00000000}, | ||
194 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00100000, 0x00000000}, | ||
195 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x00000000, 0x00000000, 0x00000000}, | ||
196 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
197 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000100, 0x00000000}, | ||
198 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
199 | {0x00000000, 0x00000000, 0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x10000100}, | ||
200 | {0x00000000, 0x00000000, 0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001}, | ||
201 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
202 | {0x00000000, 0x00000000, 0x00000100, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
203 | {0x01000010, 0x01000010, 0x11000010, 0x01000010, 0x01000100, 0x00000100, 0x00001000, 0x00110000}, | ||
204 | {0x01000010, 0x01000010, 0x01000011, 0x01000010, 0x00100010, 0x00100000, 0x00010000, 0x00001100}, | ||
205 | {0x00000000, 0x00000000, 0x00100000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
206 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00010000, 0x00000000, 0x00000000, 0x00000000}, | ||
207 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x10000000, 0x00000000}, | ||
208 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
209 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001000, 0x00000000, 0x00000000, 0x00000000}, | ||
210 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
211 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
212 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
213 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
214 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
215 | {0x00000000, 0x00000000, 0x00000000, 0x11000000, 0x00110000, 0x00001000, 0x00000100, 0x10000100}, | ||
216 | {0x00000000, 0x00000000, 0x00000000, 0x00000011, 0x00001100, 0x00010000, 0x00100000, 0x00100001}, | ||
217 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
218 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
219 | {0x01000010, 0x01000010, 0x11000010, 0x01000010, 0x01000100, 0x00000100, 0x00001000, 0x00110000}, | ||
220 | {0x01000010, 0x01000010, 0x01000011, 0x01000010, 0x00100010, 0x00100000, 0x00010000, 0x00001100}, | ||
221 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
222 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
223 | {0x11000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
224 | {0x00000011, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
225 | {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, | ||
226 | }; | ||
227 | |||
228 | // u16 palette[16] = { | ||
229 | // 0x7fff, 0x0000, 0x7fff, 0x7fff, | ||
230 | // 0x7fff, 0x7fff, 0x7fff, 0x7fff, | ||
231 | // 0x7fff, 0x7fff, 0x7fff, 0x7fff, | ||
232 | // 0x7fff, 0x7fff, 0x7fff, 0x7fff, | ||
233 | // }; | ||
@@ -1,5 +1,6 @@ | |||
1 | #include "shorthand.h" | 1 | #include "shorthand.h" |
2 | #include "bd-font.c" | 2 | #include "bd-font.c" |
3 | #include "gba-buttons.c" | ||
3 | 4 | ||
4 | // | 5 | // |
5 | // Memory sections. | 6 | // Memory sections. |
@@ -249,7 +250,7 @@ draw_fill_rect(int x0, int y0, int x1, int y1, Color clr) { | |||
249 | } | 250 | } |
250 | 251 | ||
251 | static inline void | 252 | static inline void |
252 | wait_vsync() { | 253 | wait_vsync(void) { |
253 | while(DISP_VCOUNT >= 160); | 254 | while(DISP_VCOUNT >= 160); |
254 | while(DISP_VCOUNT < 160); | 255 | while(DISP_VCOUNT < 160); |
255 | } | 256 | } |
@@ -290,7 +291,7 @@ draw_fill_rect_m4(int x0, int y0, int x1, int y1, u8 col_index, vu16 *buffer) { | |||
290 | } | 291 | } |
291 | 292 | ||
292 | static inline void | 293 | static inline void |
293 | flip_page() { | 294 | flip_page(void) { |
294 | DISP_CTRL ^= DISP_PAGE; | 295 | DISP_CTRL ^= DISP_PAGE; |
295 | } | 296 | } |
296 | 297 | ||
@@ -323,7 +324,7 @@ flip_page() { | |||
323 | // functions is called. Don't use if the code we are trying to profile make use | 324 | // functions is called. Don't use if the code we are trying to profile make use |
324 | // of these timers. | 325 | // of these timers. |
325 | static inline | 326 | static inline |
326 | void profile_start() { | 327 | void profile_start(void) { |
327 | TIMER_DATA_2 = 0; | 328 | TIMER_DATA_2 = 0; |
328 | TIMER_DATA_3 = 0; | 329 | TIMER_DATA_3 = 0; |
329 | TIMER_CTRL_2 = 0; | 330 | TIMER_CTRL_2 = 0; |
@@ -333,7 +334,7 @@ void profile_start() { | |||
333 | } | 334 | } |
334 | 335 | ||
335 | static inline | 336 | static inline |
336 | u32 profile_stop() { | 337 | u32 profile_stop(void) { |
337 | TIMER_CTRL_2 = 0; | 338 | TIMER_CTRL_2 = 0; |
338 | return (TIMER_DATA_3 << 16) | TIMER_DATA_2; | 339 | return (TIMER_DATA_3 << 16) | TIMER_DATA_2; |
339 | } | 340 | } |
@@ -364,7 +365,7 @@ static u16 key_curr = 0; | |||
364 | static u16 key_prev = 0; | 365 | static u16 key_prev = 0; |
365 | 366 | ||
366 | static inline void | 367 | static inline void |
367 | poll_keys() { | 368 | poll_keys(void) { |
368 | key_prev = key_curr; | 369 | key_prev = key_curr; |
369 | key_curr = ~KEY_INPUTS & KEY_MASK; | 370 | key_curr = ~KEY_INPUTS & KEY_MASK; |
370 | } | 371 | } |
@@ -388,7 +389,7 @@ key_hold(u32 key) { | |||
388 | #define KEY_PRESSED(key) (~(KEY_INPUTS) & key) | 389 | #define KEY_PRESSED(key) (~(KEY_INPUTS) & key) |
389 | 390 | ||
390 | void | 391 | void |
391 | draw_logo() { | 392 | draw_logo(void) { |
392 | int side = 60; | 393 | int side = 60; |
393 | int line = 35; | 394 | int line = 35; |
394 | int height = side * 0.5; | 395 | int height = side * 0.5; |
@@ -472,20 +473,14 @@ typedef struct FontSprite { | |||
472 | u32 pal_bank; | 473 | u32 pal_bank; |
473 | } FontSprite; | 474 | } FontSprite; |
474 | 475 | ||
475 | 476 | typedef struct ButtonSprite { | |
476 | static u32 test_tiles[][8] = { | 477 | int x; |
477 | {0x33322111, 0x33322111, 0x33322111, 0x33322111, 0x33322111, 0x33322111, 0x33322111, 0x33322111}, | 478 | int y; |
478 | {0x00044000, 0x00044000, 0x00044000, 0x44444444, 0x44444444, 0x00044000, 0x00044000, 0x00044000}, | 479 | int frame; |
479 | {0x44400444, 0x44400444, 0x44400444, 0x00000000, 0x00000000, 0x44400444, 0x44400444, 0x44400444}, | 480 | int n_frames; |
480 | {0x11122333, 0x11122333, 0x11122333, 0x11122333, 0x11122333, 0x11122333, 0x11122333, 0x11122333}, | 481 | u32 tile_index; |
481 | }; | 482 | u32 pal_bank; |
482 | 483 | } ButtonSprite; | |
483 | static u16 test_palette[16] = { | ||
484 | 0x0000, 0x001f, 0x03e0, 0x7c00, | ||
485 | 0x7fff, 0x0000, 0x0000, 0x0000, | ||
486 | 0x0000, 0x0000, 0x0000, 0x0000, | ||
487 | 0x0000, 0x0000, 0x0000, 0x0000 | ||
488 | }; | ||
489 | 484 | ||
490 | int main(void) { | 485 | int main(void) { |
491 | // Configure the display in mode 0 to show OBJs, where tile memory is | 486 | // Configure the display in mode 0 to show OBJs, where tile memory is |
@@ -495,8 +490,7 @@ int main(void) { | |||
495 | // Add colors to the sprite color palette. Tiles with color number 0 are | 490 | // Add colors to the sprite color palette. Tiles with color number 0 are |
496 | // treated as transparent. | 491 | // treated as transparent. |
497 | for (size_t i = 0; i < 16; ++i) { | 492 | for (size_t i = 0; i < 16; ++i) { |
498 | PAL_BUFFER_SPRITES[i] = test_palette[i]; | 493 | PAL_BUFFER_SPRITES[i] = COLOR_WHITE; |
499 | PAL_BUFFER_SPRITES[i + 16] = COLOR_WHITE; | ||
500 | } | 494 | } |
501 | 495 | ||
502 | // Initialize all attributes by disabling rendering. If we don't do this, | 496 | // Initialize all attributes by disabling rendering. If we don't do this, |
@@ -508,45 +502,38 @@ int main(void) { | |||
508 | size_t initial_tile = 512; | 502 | size_t initial_tile = 512; |
509 | Tile *tile_mem = &TILE_MEM[4][initial_tile]; | 503 | Tile *tile_mem = &TILE_MEM[4][initial_tile]; |
510 | 504 | ||
511 | // Load bd-font as tiles. The full extended ASCII range (256 characters) | ||
512 | // will be available as an offset of the initial tile. For example, the | ||
513 | // uppercase A letter will be at tile index of 512 + 65. | ||
514 | copy_font_to_tile_memory(tile_mem); | ||
515 | |||
516 | // Test copying the exported tiles. | 505 | // Test copying the exported tiles. |
517 | for (size_t i = 0; i < 4; ++i) { | 506 | for (size_t i = 0; i < 224; ++i) { |
518 | for (size_t j = 0; j < 8; ++j) { | 507 | for (size_t j = 0; j < 8; ++j) { |
519 | (tile_mem + i)->data[j] = test_tiles[i][j]; | 508 | (tile_mem + i)->data[j] = gba_buttons_tiles[i][j]; |
520 | } | 509 | } |
521 | } | 510 | } |
522 | 511 | ||
523 | // Initialize character sprites for all font chars. | 512 | // Initialize the A/B button sprites. |
524 | FontSprite font_sprites[256] = {0}; | 513 | int buttons_x = SCREEN_WIDTH - 64 - 10; |
525 | size_t x = 49; | 514 | int buttons_y = 120; |
526 | size_t y = 8; | 515 | ButtonSprite btn_b = { |
527 | for (size_t i = 0; i < 256; ++i) { | 516 | .x = buttons_x, |
528 | if ((i % 16) == 0 && i != 0) { | 517 | .y = buttons_y, |
529 | y += 16; | 518 | .frame = 0, |
530 | x = 49; | 519 | .n_frames = 6, |
531 | } | 520 | .tile_index = initial_tile, |
532 | font_sprites[i].x = x; | 521 | .pal_bank = 0, |
533 | font_sprites[i].y = y; | 522 | }; |
534 | font_sprites[i].tile_index = initial_tile + i; | 523 | OBJ_ATTR_0(0) = btn_b.y; |
535 | font_sprites[i].animation_state = i % 56; | 524 | OBJ_ATTR_1(0) = btn_b.x | (1 << 0xF); |
536 | x += 8; | 525 | OBJ_ATTR_2(0) = btn_b.tile_index; |
537 | } | 526 | ButtonSprite btn_a = { |
538 | 527 | .x = buttons_x + 20, | |
539 | // Number of characters to become sprites. | 528 | .y = buttons_y - 16, |
540 | size_t n_chars = 128; | 529 | .frame = 0, |
541 | for (size_t i = 0; i < n_chars; ++i) { | 530 | .n_frames = 6, |
542 | OBJ_ATTR_0(i) = font_sprites[i].y; | 531 | .tile_index = initial_tile + 16 * 7, |
543 | OBJ_ATTR_1(i) = font_sprites[i].x; | 532 | .pal_bank = 0, |
544 | if (i < 4) { | 533 | }; |
545 | OBJ_ATTR_2(i) = font_sprites[i].tile_index; | 534 | OBJ_ATTR_0(1) = btn_a.y; |
546 | } else { | 535 | OBJ_ATTR_1(1) = btn_a.x | (1 << 0xF); |
547 | OBJ_ATTR_2(i) = font_sprites[i].tile_index | (1 << 0xC); | 536 | OBJ_ATTR_2(1) = btn_a.tile_index; |
548 | } | ||
549 | } | ||
550 | 537 | ||
551 | // draw_logo(); | 538 | // draw_logo(); |
552 | 539 | ||
@@ -565,20 +552,45 @@ int main(void) { | |||
565 | if (key_pressed(KEY_RIGHT) || key_hold(KEY_RIGHT)) { | 552 | if (key_pressed(KEY_RIGHT) || key_hold(KEY_RIGHT)) { |
566 | } | 553 | } |
567 | if (key_pressed(KEY_B)) { | 554 | if (key_pressed(KEY_B)) { |
555 | btn_b.frame = 1; | ||
556 | } else if (key_pressed(KEY_B) || key_hold(KEY_B)) { | ||
557 | // DEBUG: Slowing animation rate. What would be a better solution? | ||
558 | if (frame_counter++ % 3 == 0) { | ||
559 | if (btn_b.frame < btn_b.n_frames) { | ||
560 | btn_b.frame++; | ||
561 | } | ||
562 | } | ||
563 | } else { | ||
564 | if (btn_b.frame > 0 && btn_b.frame < btn_b.n_frames) { | ||
565 | btn_b.frame++; | ||
566 | } else { | ||
567 | btn_b.frame = 0; | ||
568 | } | ||
569 | } | ||
570 | if (key_pressed(KEY_A)) { | ||
571 | btn_a.frame = 1; | ||
572 | } else if (key_pressed(KEY_A) || key_hold(KEY_A)) { | ||
573 | // DEBUG: Slowing animation rate. What would be a better solution? | ||
574 | if (frame_counter++ % 3 == 0) { | ||
575 | if (btn_a.frame < btn_a.n_frames) { | ||
576 | btn_a.frame++; | ||
577 | } | ||
578 | } | ||
579 | } else { | ||
580 | if (btn_a.frame > 0 && btn_a.frame < btn_a.n_frames) { | ||
581 | btn_a.frame++; | ||
582 | } else { | ||
583 | btn_a.frame = 0; | ||
584 | } | ||
568 | } | 585 | } |
569 | if (key_pressed(KEY_L)) { | 586 | if (key_pressed(KEY_L)) { |
570 | } | 587 | } |
571 | if (key_pressed(KEY_R)) { | 588 | if (key_pressed(KEY_R)) { |
572 | } | 589 | } |
573 | 590 | ||
574 | for (size_t i = 0; i < 128; ++i) { | 591 | OBJ_ATTR_2(0) = btn_b.tile_index + 16 * btn_b.frame; |
575 | int y = font_sprites[i].y; | 592 | OBJ_ATTR_2(1) = btn_a.tile_index + 16 * btn_a.frame; |
576 | y -= bouncing_animation[font_sprites[i].animation_state++]; | 593 | |
577 | if (font_sprites[i].animation_state > 56) { | ||
578 | font_sprites[i].animation_state = 0; | ||
579 | } | ||
580 | OBJ_ATTR_0(i) = (OBJ_ATTR_0(i) & ~0xFF) | (y & 0xFF); | ||
581 | } | ||
582 | }; | 594 | }; |
583 | 595 | ||
584 | return 0; | 596 | return 0; |