diff options
-rw-r--r-- | src/gba-buttons.c | 616 | ||||
-rw-r--r-- | src/main.c | 415 |
2 files changed, 341 insertions, 690 deletions
diff --git a/src/gba-buttons.c b/src/gba-buttons.c index 7d40031..cbf6f8b 100644 --- a/src/gba-buttons.c +++ b/src/gba-buttons.c | |||
@@ -1,536 +1,66 @@ | |||
1 | // 1bpp packed | 1 | // 1bpp packed |
2 | u32 gba_btn_a_data[] = { | 2 | u32 gba_btn_a_data[] = { |
3 | 0x00000000, 0x00000000, 0x00000000, 0x000000c0, | 3 | 0xc0300804, 0x844242c2, 0x030c1020, 0x21424243, |
4 | 0x00000000, 0x00000003, 0x00000000, 0x00000000, | 4 | 0x42440408, 0x30c00000, 0x42222010, 0x0c030000, |
5 | 0x00000000, 0x00000000, 0x30080484, 0x4242c242, | ||
6 | 0x0c102021, 0x42424342, 0x00000000, 0x00000000, | ||
7 | 0x00000000, 0x00000000, 0x42060c34, 0xc830c000, | ||
8 | 0x4260302c, 0x130c0300, 0x00000000, 0x00000000, | ||
9 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
10 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
11 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
12 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
13 | 0x00000000, 0x00000000, 0xc0300804, 0x844242c2, | ||
14 | 0x030c1020, 0x21424243, 0x00000000, 0x00000000, | ||
15 | 0x00000000, 0x00000000, 0x4242040c, 0x38f0c000, | ||
16 | 0x42422030, 0x1c0f0300, 0x00000000, 0x00000000, | ||
17 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
18 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
19 | 0x00000000, 0x00000000, 0x00000000, 0x00000080, | ||
20 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
21 | 0x00000000, 0x00000000, 0x00c43008, 0x04844242, | ||
22 | 0x00230c10, 0x20214242, 0x00000000, 0x00000000, | ||
23 | 0x80000000, 0x00000000, 0xc2424404, 0x0832c000, | ||
24 | 0x43422220, 0x104c0300, 0x01000000, 0x00000000, | ||
25 | 0x00000000, 0x00000000, 0x80000000, 0x00000000, | ||
26 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
27 | 0x00000000, 0x00408000, 0x00000080, 0x80800001, | ||
28 | 0x00000000, 0x00000080, 0x00000000, 0x00020100, | ||
29 | 0x00000000, 0x00000000, 0x00c03008, 0x04844242, | ||
30 | 0x00030c10, 0x20214242, 0x00000000, 0x00000000, | ||
31 | 0x38000000, 0x00000080, 0xc2424404, 0x0830c000, | ||
32 | 0x43422220, 0x100c0300, 0x1c000000, 0x00000001, | ||
33 | 0x40200000, 0x00000000, 0x00008080, 0x80000000, | ||
34 | 0x00000000, 0x00000000, 0x02040000, 0x00000000, | ||
35 | 0x00000000, 0x20400000, 0x00008080, 0x00000000, | ||
36 | 0x00000000, 0x00000000, 0x00000000, 0x04020000, | ||
37 | 0x00000000, 0x00000000, 0x00c03008, 0x04844242, | ||
38 | 0x00030c10, 0x20214242, 0x00000000, 0x00000000, | ||
39 | 0x0c000000, 0x00000000, 0xc2424404, 0x0830c000, | ||
40 | 0x43422220, 0x100c0300, 0x30000000, 0x00000000, | ||
41 | 0x00201000, 0x00000000, 0x00000080, 0x80000000, | ||
42 | 0x00000000, 0x00000000, 0x00040800, 0x00000000, | ||
43 | 0x00000000, 0x20000000, 0x00008000, 0x00000000, | ||
44 | 0x00000000, 0x00000000, 0x00000000, 0x04000000, | ||
45 | 0x00000000, 0x00000000, 0x00c03008, 0x04844242, | ||
46 | 0x00030c10, 0x20214242, 0x00000000, 0x00000000, | ||
47 | 0x04000000, 0x00000000, 0xc2424404, 0x0830c000, | ||
48 | 0x43422220, 0x100c0300, 0x20000000, 0x00000000, | ||
49 | 0x00001000, 0x00000000, 0x00000000, 0x80000000, | ||
50 | 0x00000000, 0x00000000, 0x00000800, 0x00000000, | ||
51 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
52 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
53 | 0x00000000, 0x00000000, 0x00c03008, 0x04844242, | ||
54 | 0x00030c10, 0x20214242, 0x00000000, 0x00000000, | ||
55 | 0x00000000, 0x00000000, 0xc2424404, 0x0830c000, | ||
56 | 0x43422220, 0x100c0300, 0x00000000, 0x00000000, | ||
57 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
58 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
59 | }; | 5 | }; |
60 | 6 | ||
61 | u32 gba_btn_b_data[] = { | 7 | u32 gba_btn_b_data[] = { |
62 | 0x00000000, 0x00000000, 0x00000000, 0x000000c0, | 8 | 0xc0300804, 0xc442c242, 0x030c1020, 0x21424142, |
63 | 0x00000000, 0x00000003, 0x00000000, 0x00000000, | 9 | 0x42c40408, 0x30c00000, 0x42212010, 0x0c030000, |
64 | 0x00000000, 0x00000000, 0x300804c4, 0x42c24242, | ||
65 | 0x0c102021, 0x42414242, 0x00000000, 0x00000000, | ||
66 | 0x00000000, 0x00000000, 0xc2060c34, 0xc830c000, | ||
67 | 0x4160302c, 0x130c0300, 0x00000000, 0x00000000, | ||
68 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
69 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
70 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
71 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
72 | 0x00000000, 0x00000000, 0xc0300804, 0xc442c242, | ||
73 | 0x030c1020, 0x21424142, 0x00000000, 0x00000000, | ||
74 | 0x00000000, 0x00000000, 0x42c2040c, 0x38f0c000, | ||
75 | 0x42412030, 0x1c0f0300, 0x00000000, 0x00000000, | ||
76 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
77 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
78 | 0x00000000, 0x00000000, 0x00000000, 0x00000080, | ||
79 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
80 | 0x00000000, 0x00000000, 0x00c43008, 0x04c442c2, | ||
81 | 0x00230c10, 0x20214241, 0x00000000, 0x00000000, | ||
82 | 0x80000000, 0x00000000, 0x4242c404, 0x0832c000, | ||
83 | 0x42422120, 0x104c0300, 0x01000000, 0x00000000, | ||
84 | 0x00000000, 0x00000000, 0x80000000, 0x00000000, | ||
85 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
86 | 0x00000000, 0x00408000, 0x00000080, 0x80800001, | ||
87 | 0x00000000, 0x00000080, 0x00000000, 0x00020100, | ||
88 | 0x00000000, 0x00000000, 0x00c03008, 0x04c442c2, | ||
89 | 0x00030c10, 0x20214241, 0x00000000, 0x00000000, | ||
90 | 0x38000000, 0x00000080, 0x4242c404, 0x0830c000, | ||
91 | 0x42422120, 0x100c0300, 0x1c000000, 0x00000001, | ||
92 | 0x40200000, 0x00000000, 0x00008080, 0x80000000, | ||
93 | 0x00000000, 0x00000000, 0x02040000, 0x00000000, | ||
94 | 0x00000000, 0x20400000, 0x00808000, 0x00000000, | ||
95 | 0x00000000, 0x00000000, 0x00000000, 0x04020000, | ||
96 | 0x00000000, 0x00000000, 0x00c03008, 0x04c442c2, | ||
97 | 0x00030c10, 0x20214241, 0x00000000, 0x00000000, | ||
98 | 0x0c000000, 0x00000000, 0x4242c404, 0x0830c000, | ||
99 | 0x42422120, 0x100c0300, 0x30000000, 0x00000000, | ||
100 | 0x00201000, 0x00000000, 0x00000000, 0x80800000, | ||
101 | 0x00000000, 0x00000000, 0x00040800, 0x00000000, | ||
102 | 0x00000000, 0x20000000, 0x00800000, 0x00000000, | ||
103 | 0x00000000, 0x00000000, 0x00000000, 0x04000000, | ||
104 | 0x00000000, 0x00000000, 0x00c03008, 0x04c442c2, | ||
105 | 0x00030c10, 0x20214241, 0x00000000, 0x00000000, | ||
106 | 0x04000000, 0x00000000, 0x4242c404, 0x0830c000, | ||
107 | 0x42422120, 0x100c0300, 0x20000000, 0x00000000, | ||
108 | 0x00001000, 0x00000000, 0x00000000, 0x00800000, | ||
109 | 0x00000000, 0x00000000, 0x00000800, 0x00000000, | ||
110 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
111 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
112 | 0x00000000, 0x00000000, 0x00c03008, 0x04c442c2, | ||
113 | 0x00030c10, 0x20214241, 0x00000000, 0x00000000, | ||
114 | 0x00000000, 0x00000000, 0x4242c404, 0x0830c000, | ||
115 | 0x42422120, 0x100c0300, 0x00000000, 0x00000000, | ||
116 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
117 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
118 | }; | 10 | }; |
119 | 11 | ||
120 | u32 gba_btn_up_data[] = { | 12 | u32 gba_btn_updown_data[] = { |
121 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | 13 | 0x00f01010, 0x90d01010, 0x001f1011, 0x13171111, |
122 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | 14 | 0x101020c0, 0x00000000, 0x11110807, 0x00000000, |
123 | 0x00000000, 0x00000000, 0xf80888c8, 0xe8888888, | ||
124 | 0x0f080809, 0x0b080808, 0x00000000, 0x00000000, | ||
125 | 0x00000000, 0x00000000, 0x8818e810, 0xe0000000, | ||
126 | 0x080c0b04, 0x03000000, 0x00000000, 0x00000000, | ||
127 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
128 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
129 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
130 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
131 | 0x00000000, 0x00000000, 0x00f80888, 0xc8e88888, | ||
132 | 0x000f0808, 0x090b0808, 0x00000000, 0x00000000, | ||
133 | 0x00000000, 0x00000000, 0x888818f0, 0xe0000000, | ||
134 | 0x08080c07, 0x03000000, 0x00000000, 0x00000000, | ||
135 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
136 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
137 | 0x00000000, 0x00000000, 0x00000000, 0x00000080, | ||
138 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
139 | 0x00000000, 0x00000000, 0x0002f808, 0x88c8e888, | ||
140 | 0x00200f08, 0x08090b08, 0x00000000, 0x00000000, | ||
141 | 0x00000000, 0x00000000, 0x88888810, 0xe0000000, | ||
142 | 0x08080804, 0x03000000, 0x00000000, 0x00000000, | ||
143 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
144 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
145 | 0x00000000, 0x00000080, 0x00000000, 0x00808000, | ||
146 | 0x00000000, 0x00000080, 0x00000000, 0x00000000, | ||
147 | 0x00000000, 0x00000000, 0x0100f808, 0x88c8e888, | ||
148 | 0x40000f08, 0x08090b08, 0x00000000, 0x00000000, | ||
149 | 0x00000000, 0x00000000, 0x88888810, 0xe0000000, | ||
150 | 0x08080804, 0x03000000, 0x00000000, 0x00000000, | ||
151 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
152 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
153 | 0x00000000, 0x00004080, 0x00000000, 0x80800000, | ||
154 | 0x00000000, 0x00000080, 0x00000000, 0x00000100, | ||
155 | 0x00000000, 0x00000000, 0x0000f808, 0x88c8e888, | ||
156 | 0x00000f08, 0x08090b08, 0x00000000, 0x00000000, | ||
157 | 0x00000000, 0x00000000, 0x88888810, 0xe0000000, | ||
158 | 0x08080804, 0x03000000, 0x00000000, 0x00000000, | ||
159 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
160 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
161 | 0x00000000, 0x00200000, 0x00000080, 0x00000000, | ||
162 | 0x00000000, 0x00000000, 0x00000000, 0x00020000, | ||
163 | 0x00000000, 0x00000000, 0x0000f808, 0x88c8e888, | ||
164 | 0x00000f08, 0x08090b08, 0x00000000, 0x00000000, | ||
165 | 0x00000000, 0x00000000, 0x88888810, 0xe0000000, | ||
166 | 0x08080804, 0x03000000, 0x00000000, 0x00000000, | ||
167 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
168 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
169 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
170 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
171 | 0x00000000, 0x00000000, 0x0000f808, 0x88c8e888, | ||
172 | 0x00000f08, 0x08090b08, 0x00000000, 0x00000000, | ||
173 | 0x00000000, 0x00000000, 0x88888810, 0xe0000000, | ||
174 | 0x08080804, 0x03000000, 0x00000000, 0x00000000, | ||
175 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
176 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
177 | }; | 15 | }; |
178 | 16 | ||
179 | u32 gba_btn_down_data[] = { | 17 | u32 gba_btn_leftright_data[] = { |
180 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | 18 | 0x000000f8, 0x0888c8e8, 0x0000000f, 0x1020202f, |
181 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | 19 | 0xc88808f8, 0x00000000, 0x2020100f, 0x00000000, |
182 | 0x00000000, 0x00000000, 0x00e01088, 0x888888e8, | ||
183 | 0x00030408, 0x0808080b, 0x00000000, 0x00000000, | ||
184 | 0x00000000, 0x00000000, 0xc88808f8, 0x08f80000, | ||
185 | 0x0908080f, 0x080f0000, 0x00000000, 0x00000000, | ||
186 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
187 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
188 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
189 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
190 | 0x00000000, 0x00000000, 0x0000e010, 0x88888888, | ||
191 | 0x00000304, 0x08080808, 0x00000000, 0x00000000, | ||
192 | 0x00000000, 0x00000000, 0xe8c88808, 0xf8f80000, | ||
193 | 0x0b090808, 0x0f0f0000, 0x00000000, 0x00000000, | ||
194 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
195 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
196 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
197 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
198 | 0x00000000, 0x00000000, 0x000000e0, 0x10888888, | ||
199 | 0x00000003, 0x04080808, 0x00000000, 0x00000000, | ||
200 | 0x00000000, 0x00000000, 0x88e8c888, 0x08f80200, | ||
201 | 0x080b0908, 0x080f2000, 0x00000000, 0x00000000, | ||
202 | 0x00000000, 0x00000000, 0x80000000, 0x00000000, | ||
203 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
204 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
205 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
206 | 0x00000000, 0x00000000, 0x000000e0, 0x10888888, | ||
207 | 0x00000003, 0x04080808, 0x00000000, 0x00000000, | ||
208 | 0x00000000, 0x00000000, 0x88e8c888, 0x08f80001, | ||
209 | 0x080b0908, 0x080f0040, 0x00000000, 0x00000000, | ||
210 | 0x80000000, 0x00000000, 0x00808000, 0x00000000, | ||
211 | 0x80000000, 0x00000000, 0x00000000, 0x00000000, | ||
212 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
213 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
214 | 0x00000000, 0x00000000, 0x000000e0, 0x10888888, | ||
215 | 0x00000003, 0x04080808, 0x00000000, 0x00000000, | ||
216 | 0x00000000, 0x00000000, 0x88e8c888, 0x08f80000, | ||
217 | 0x080b0908, 0x080f0000, 0x00000000, 0x00000000, | ||
218 | 0x80400000, 0x00000000, 0x00008080, 0x00000000, | ||
219 | 0x80000000, 0x00000000, 0x00010000, 0x00000000, | ||
220 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
221 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
222 | 0x00000000, 0x00000000, 0x000000e0, 0x10888888, | ||
223 | 0x00000003, 0x04080808, 0x00000000, 0x00000000, | ||
224 | 0x00000000, 0x00000000, 0x88e8c888, 0x08f80000, | ||
225 | 0x080b0908, 0x080f0000, 0x00000000, 0x00000000, | ||
226 | 0x00002000, 0x00000000, 0x00000000, 0x80000000, | ||
227 | 0x00000000, 0x00000000, 0x00000200, 0x00000000, | ||
228 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
229 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
230 | 0x00000000, 0x00000000, 0x000000e0, 0x10888888, | ||
231 | 0x00000003, 0x04080808, 0x00000000, 0x00000000, | ||
232 | 0x00000000, 0x00000000, 0x88e8c888, 0x08f80000, | ||
233 | 0x080b0908, 0x080f0000, 0x00000000, 0x00000000, | ||
234 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
235 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
236 | }; | 20 | }; |
237 | 21 | ||
238 | u32 gba_btn_left_data[] = { | 22 | u32 gba_btn_l_data[] = { |
239 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | 23 | 0xfc028181, 0x818101ff, 0xff808080, 0x808380ff, |
240 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
241 | 0x00000000, 0x00000000, 0x0000f808, 0x88c8e8c8, | ||
242 | 0x00000f10, 0x20202f20, 0x00000000, 0x00000000, | ||
243 | 0x00000000, 0x00000000, 0x8808f808, 0xf8000000, | ||
244 | 0x20302f10, 0x0f000000, 0x00000000, 0x00000000, | ||
245 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
246 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
247 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
248 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
249 | 0x00000000, 0x00000000, 0x000000f8, 0x0888c8e8, | ||
250 | 0x0000000f, 0x1020202f, 0x00000000, 0x00000000, | ||
251 | 0x00000000, 0x00000000, 0xc88808f8, 0xf8000000, | ||
252 | 0x2020301f, 0x0f000000, 0x00000000, 0x00000000, | ||
253 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
254 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
255 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
256 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
257 | 0x00000000, 0x00000000, 0x00000400, 0xf80888c8, | ||
258 | 0x00000000, 0x0f102020, 0x00000000, 0x00000000, | ||
259 | 0x00000000, 0x00000000, 0xe9c88808, 0xf8000400, | ||
260 | 0x2f202010, 0x0f000000, 0x00000000, 0x00000000, | ||
261 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
262 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
263 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
264 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
265 | 0x00000000, 0x00000000, 0x01020000, 0xf80888c8, | ||
266 | 0x00000000, 0x0f102020, 0x00000000, 0x00000000, | ||
267 | 0xc0000000, 0x00000000, 0xe8c88808, 0xf8000002, | ||
268 | 0x2f202010, 0x0f000000, 0x00000000, 0x00000000, | ||
269 | 0x00000000, 0x00000000, 0x01000000, 0x00000000, | ||
270 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
271 | 0x00000000, 0x00000080, 0x00000000, 0x00000000, | ||
272 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
273 | 0x00000000, 0x00000000, 0x01000000, 0xf80888c8, | ||
274 | 0x00000000, 0x0f102020, 0x00000000, 0x00000000, | ||
275 | 0x60000000, 0x00000000, 0xe8c88808, 0xf8000000, | ||
276 | 0x2f202010, 0x0f000000, 0x00000000, 0x00000000, | ||
277 | 0x00800000, 0x00000000, 0x01000000, 0x00000000, | ||
278 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
279 | 0x00000000, 0x00004000, 0x00000000, 0x00000000, | ||
280 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
281 | 0x00000000, 0x00000000, 0x00000000, 0xf80888c8, | ||
282 | 0x00000000, 0x0f102020, 0x00000000, 0x00000000, | ||
283 | 0x10000000, 0x00000000, 0xe8c88808, 0xf8000000, | ||
284 | 0x2f202010, 0x0f000000, 0x00000000, 0x00000000, | ||
285 | 0x00004000, 0x00000000, 0x00000000, 0x00000000, | ||
286 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
287 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
288 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
289 | 0x00000000, 0x00000000, 0x00000000, 0xf80888c8, | ||
290 | 0x00000000, 0x0f102020, 0x00000000, 0x00000000, | ||
291 | 0x00000000, 0x00000000, 0xe8c88808, 0xf8000000, | ||
292 | 0x2f202010, 0x0f000000, 0x00000000, 0x00000000, | ||
293 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
294 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
295 | }; | 24 | }; |
296 | 25 | ||
297 | u32 gba_btn_right_data[] = { | 26 | u32 gba_btn_r_data[] = { |
298 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | 27 | 0xff018181, 0x818101ff, 0x3f408182, 0x818280ff, |
299 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
300 | 0x00000000, 0x00000000, 0x0000f008, 0x0404f404, | ||
301 | 0x00001f10, 0x11131713, 0x00000000, 0x00000000, | ||
302 | 0x00000000, 0x00000000, 0x040cf408, 0xf0000000, | ||
303 | 0x11101f10, 0x1f000000, 0x00000000, 0x00000000, | ||
304 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
305 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
306 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
307 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
308 | 0x00000000, 0x00000000, 0x000000f0, 0x080404f4, | ||
309 | 0x0000001f, 0x10111317, 0x00000000, 0x00000000, | ||
310 | 0x00000000, 0x00000000, 0x04040cf8, 0xf0000000, | ||
311 | 0x1311101f, 0x1f000000, 0x00000000, 0x00000000, | ||
312 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
313 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
314 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
315 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
316 | 0x00000000, 0x00000000, 0x00000000, 0xf0080404, | ||
317 | 0x00002000, 0x1f101113, 0x00000000, 0x00000000, | ||
318 | 0x00000000, 0x00000000, 0xf4040408, 0xf0000000, | ||
319 | 0x97131110, 0x1f002000, 0x00000000, 0x00000000, | ||
320 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
321 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
322 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
323 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
324 | 0x00000000, 0x00000000, 0x00000000, 0xf0080404, | ||
325 | 0x80400000, 0x1f101113, 0x00000000, 0x00000000, | ||
326 | 0x00000000, 0x00000000, 0xf4040408, 0xf0000000, | ||
327 | 0x17131110, 0x1f000040, 0x03000000, 0x00000000, | ||
328 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
329 | 0x80000000, 0x00000000, 0x00000000, 0x00000000, | ||
330 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
331 | 0x00000000, 0x00000000, 0x00000000, 0x00000001, | ||
332 | 0x00000000, 0x00000000, 0x00000000, 0xf0080404, | ||
333 | 0x80000000, 0x1f101113, 0x00000000, 0x00000000, | ||
334 | 0x00000000, 0x00000000, 0xf4040408, 0xf0000000, | ||
335 | 0x17131110, 0x1f000000, 0x06000000, 0x00000000, | ||
336 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
337 | 0x80000000, 0x00000000, 0x00010000, 0x00000000, | ||
338 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
339 | 0x00000000, 0x00000000, 0x00000000, 0x00000200, | ||
340 | 0x00000000, 0x00000000, 0x00000000, 0xf0080404, | ||
341 | 0x00000000, 0x1f101113, 0x00000000, 0x00000000, | ||
342 | 0x00000000, 0x00000000, 0xf4040408, 0xf0000000, | ||
343 | 0x17131110, 0x1f000000, 0x08000000, 0x00000000, | ||
344 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
345 | 0x00000000, 0x00000000, 0x00000200, 0x00000000, | ||
346 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
347 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
348 | 0x00000000, 0x00000000, 0x00000000, 0xf0080404, | ||
349 | 0x00000000, 0x1f101113, 0x00000000, 0x00000000, | ||
350 | 0x00000000, 0x00000000, 0xf4040408, 0xf0000000, | ||
351 | 0x17131110, 0x1f000000, 0x00000000, 0x00000000, | ||
352 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
353 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
354 | }; | 28 | }; |
355 | 29 | ||
356 | u32 gba_btn_l_data[] = { | 30 | u32 gba_btn_ab_shadow_data[] = { |
357 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | 31 | 0x00020204, 0x040830c0, 0x00404020, 0x20100c03, |
358 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
359 | 0x00000000, 0x00000000, 0x0000fc02, 0x01010101, | ||
360 | 0x0000ff00, 0x01010107, 0x00000302, 0x02020202, | ||
361 | 0x00000000, 0x00000000, 0x01ff01ff, 0x00000000, | ||
362 | 0x00ff00ff, 0x00000000, 0x02030203, 0x00000000, | ||
363 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
364 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
365 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
366 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
367 | 0x00000000, 0x00000000, 0x000000fc, 0x02010101, | ||
368 | 0x000000ff, 0x00010101, 0x00000003, 0x02020202, | ||
369 | 0x00000000, 0x00000000, 0x0101ffff, 0x00000000, | ||
370 | 0x0700ffff, 0x00000000, 0x02020303, 0x00000000, | ||
371 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
372 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
373 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
374 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
375 | 0x00000080, 0x00000040, 0x00001000, 0xfc020101, | ||
376 | 0x00000000, 0xff000101, 0x00000000, 0x03020202, | ||
377 | 0x00000000, 0x00000000, 0x010101ff, 0x00000000, | ||
378 | 0x010700ff, 0x00000000, 0x02020203, 0x00000000, | ||
379 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
380 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
381 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
382 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
383 | 0x00204000, 0x00000030, 0x10100000, 0xfc020101, | ||
384 | 0x00000000, 0xff000101, 0x00000000, 0x03020202, | ||
385 | 0x00000000, 0x00000000, 0x010101ff, 0x00000000, | ||
386 | 0x010700ff, 0x00000000, 0x02020203, 0x00000000, | ||
387 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
388 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
389 | 0x00000000, 0x00000000, 0x00000000, 0x00000010, | ||
390 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
391 | 0x10200000, 0x00000018, 0x10000000, 0xfc020101, | ||
392 | 0x00000000, 0xff000101, 0x00000000, 0x03020202, | ||
393 | 0x00000000, 0x00000000, 0x010101ff, 0x00000000, | ||
394 | 0x010700ff, 0x00000000, 0x02020203, 0x00000000, | ||
395 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
396 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
397 | 0x00000000, 0x00000000, 0x00000000, 0x00000010, | ||
398 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
399 | 0x10000000, 0x00000004, 0x00000000, 0xfc020101, | ||
400 | 0x00000000, 0xff000101, 0x00000000, 0x03020202, | ||
401 | 0x00000000, 0x00000000, 0x010101ff, 0x00000000, | ||
402 | 0x010700ff, 0x00000000, 0x02020203, 0x00000000, | ||
403 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
404 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
405 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
406 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
407 | 0x00000000, 0x00000000, 0x00000000, 0xfc020101, | ||
408 | 0x00000000, 0xff000101, 0x00000000, 0x03020202, | ||
409 | 0x00000000, 0x00000000, 0x010101ff, 0x00000000, | ||
410 | 0x010700ff, 0x00000000, 0x02020203, 0x00000000, | ||
411 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
412 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
413 | }; | 32 | }; |
414 | 33 | ||
415 | u32 gba_btn_r_data[] = { | 34 | u32 gba_btn_up_shadow_data[] = { |
416 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | 35 | 0x00000010, 0x1020c000, 0x00000010, 0x10080700, |
417 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
418 | 0x0000c040, 0x40404040, 0x0000ff00, 0x60a060a0, | ||
419 | 0x00003f40, 0x80808080, 0x00000000, 0x00000000, | ||
420 | 0x40c040c0, 0x00000000, 0x00ff00ff, 0x00000000, | ||
421 | 0x80ff80ff, 0x00000000, 0x00000000, 0x00000000, | ||
422 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
423 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
424 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
425 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
426 | 0x000000c0, 0x40404040, 0x000000ff, 0x0060a060, | ||
427 | 0x0000003f, 0x40808080, 0x00000000, 0x00000000, | ||
428 | 0x4040c0c0, 0x00000000, 0xa000ffff, 0x00000000, | ||
429 | 0x8080ffff, 0x00000000, 0x00000000, 0x00000000, | ||
430 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
431 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
432 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
433 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
434 | 0x00000000, 0xc0404040, 0x00000000, 0xff0060a0, | ||
435 | 0x00000800, 0x3f408080, 0x00000001, 0x00000002, | ||
436 | 0x404040c0, 0x00000000, 0x60a000ff, 0x00000000, | ||
437 | 0x808080ff, 0x00000000, 0x00000000, 0x00000000, | ||
438 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
439 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
440 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
441 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
442 | 0x00000000, 0xc0404040, 0x00000000, 0xff0060a0, | ||
443 | 0x08080000, 0x3f408080, 0x00040200, 0x0000000c, | ||
444 | 0x404040c0, 0x00000000, 0x60a000ff, 0x00000000, | ||
445 | 0x808080ff, 0x00000000, 0x00000000, 0x00000000, | ||
446 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
447 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
448 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
449 | 0x00000000, 0x00000008, 0x00000000, 0x00000000, | ||
450 | 0x00000000, 0xc0404040, 0x00000000, 0xff0060a0, | ||
451 | 0x08000000, 0x3f408080, 0x08040000, 0x00000018, | ||
452 | 0x404040c0, 0x00000000, 0x60a000ff, 0x00000000, | ||
453 | 0x808080ff, 0x00000000, 0x00000000, 0x00000000, | ||
454 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
455 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
456 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
457 | 0x00000000, 0x00000008, 0x00000000, 0x00000000, | ||
458 | 0x00000000, 0xc0404040, 0x00000000, 0xff0060a0, | ||
459 | 0x00000000, 0x3f408080, 0x08000000, 0x00000020, | ||
460 | 0x404040c0, 0x00000000, 0x60a000ff, 0x00000000, | ||
461 | 0x808080ff, 0x00000000, 0x00000000, 0x00000000, | ||
462 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
463 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
464 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
465 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
466 | 0x00000000, 0xc0404040, 0x00000000, 0xff0060a0, | ||
467 | 0x00000000, 0x3f408080, 0x00000000, 0x00000000, | ||
468 | 0x404040c0, 0x00000000, 0x60a000ff, 0x00000000, | ||
469 | 0x808080ff, 0x00000000, 0x00000000, 0x00000000, | ||
470 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
471 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
472 | }; | 36 | }; |
473 | 37 | ||
474 | u32 gba_btn_start_data[] = { | 38 | u32 gba_btn_down_shadow_data[] = { |
475 | 0x00000000, 0x00000000, 0x00000000, 0x0000f008, | 39 | 0x00000000, 0x10f00000, 0x00000000, 0x101f0000, |
476 | 0x00000000, 0x00001f20, 0x00000000, 0x00000000, | ||
477 | 0x00000080, 0x80008000, 0xf8f000bb, 0x91929300, | ||
478 | 0x3f1f009b, 0x2a1b2a00, 0x00000003, 0x01010100, | ||
479 | 0x00000000, 0x00000000, 0x00000000, 0x000000f0, | ||
480 | 0x00000000, 0x0000001f, 0x00000000, 0x00000000, | ||
481 | 0x00000080, 0x80008000, 0x08f000bb, 0x91929300, | ||
482 | 0x201f009b, 0x2a1b2a00, 0x00000003, 0x01010100, | ||
483 | 0x00000000, 0x00000000, 0x00000000, 0x001000f0, | ||
484 | 0x00000000, 0x0110001f, 0x00000000, 0x00000000, | ||
485 | 0x00000080, 0x80008000, 0x0af000bb, 0x91929300, | ||
486 | 0xa01f009b, 0x2a1b2a00, 0x00000003, 0x01010100, | ||
487 | 0x00000000, 0x00000000, 0x00000004, 0x080000f0, | ||
488 | 0x00000141, 0x2000001f, 0x00000000, 0x00000000, | ||
489 | 0x80000080, 0x80008000, 0x09f000bb, 0x91929300, | ||
490 | 0x201f009b, 0x2a1b2a00, 0x03000003, 0x01010100, | ||
491 | 0x00000000, 0x00000000, 0x00000204, 0x000000f0, | ||
492 | 0x00018140, 0x0000001f, 0x00000000, 0x00000000, | ||
493 | 0xc0000080, 0x80008000, 0x08f000bb, 0x91929300, | ||
494 | 0x201f009b, 0x2a1b2a00, 0x06000003, 0x01010100, | ||
495 | 0x00000000, 0x00000000, 0x00000200, 0x000000f0, | ||
496 | 0x00018000, 0x0000001f, 0x00000000, 0x00000000, | ||
497 | 0x40000080, 0x80008000, 0x08f000bb, 0x91929300, | ||
498 | 0x201f009b, 0x2a1b2a00, 0x04000003, 0x01010100, | ||
499 | 0x00000000, 0x00000000, 0x00000000, 0x000000f0, | ||
500 | 0x00000000, 0x0000001f, 0x00000000, 0x00000000, | ||
501 | 0x00000080, 0x80008000, 0x08f000bb, 0x91929300, | ||
502 | 0x201f009b, 0x2a1b2a00, 0x00000003, 0x01010100, | ||
503 | }; | 40 | }; |
504 | 41 | ||
505 | u32 gba_btn_select_data[] = { | 42 | u32 gba_btn_leftright_shadow_data[] = { |
506 | 0x00000000, 0x00000000, 0x00000000, 0x0000f008, | 43 | 0x00000000, 0x000008f8, 0x00000000, 0x2020100f, |
507 | 0x00000000, 0x00001f20, 0x00000000, 0x00000000, | 44 | }; |
508 | 0x000000e0, 0x6080e000, 0xf8f0002e, 0x2622ee00, | 45 | |
509 | 0x3f1f00ee, 0x2622ee00, 0x0000000e, 0x04040400, | 46 | u32 gba_btn_lr_shadow_data[] = { |
510 | 0x00000000, 0x00000000, 0x00000000, 0x000000f0, | 47 | 0x00000000, 0x000001ff, 0x00000000, 0x000080ff, |
511 | 0x00000000, 0x0000001f, 0x00000000, 0x00000000, | 48 | }; |
512 | 0x000000e0, 0x6080e000, 0x08f0002e, 0x2622ee00, | 49 | |
513 | 0x201f00ee, 0x2622ee00, 0x0000000e, 0x04040400, | 50 | u32 gba_btn_startselect_data[] = { |
514 | 0x00000000, 0x00000000, 0x00000000, 0x001000f0, | 51 | 0x0000f804, 0xfcf80000, 0x00001f20, 0x3f1f0000, |
515 | 0x00000000, 0x0110001f, 0x00000000, 0x00000000, | 52 | 0x000000f8, 0x04f80000, 0x0000001f, 0x201f0000, |
516 | 0x000000e0, 0x6080e000, 0x0af0002e, 0x2622ee00, | 53 | }; |
517 | 0xa01f00ee, 0x2622ee00, 0x0000000e, 0x04040400, | 54 | |
518 | 0x00000000, 0x00000000, 0x00000004, 0x080000f0, | 55 | u32 gba_btn_fx_downup[] = { |
519 | 0x00000141, 0x2000001f, 0x00000000, 0x00000000, | 56 | 0x00000000, 0x00000000, 0x04000000, 0x00000000, |
520 | 0x800000e0, 0x6080e000, 0x09f0002e, 0x2622ee00, | 57 | 0x40000100, 0x00000000, 0x00000000, 0x00000000, |
521 | 0x201f00ee, 0x2622ee00, 0x0300000e, 0x04040400, | 58 | 0x00000000, 0x00000000, 0x00000201, 0x00000000, |
522 | 0x00000000, 0x00000000, 0x00000204, 0x000000f0, | 59 | 0x00008000, 0x01010000, 0x00000001, 0x00000000, |
523 | 0x00018140, 0x0000001f, 0x00000000, 0x00000000, | 60 | 0x00000000, 0x80000000, 0x00000001, 0x00000000, |
524 | 0xc00000e0, 0x6080e000, 0x08f0002e, 0x2622ee00, | 61 | 0x00000000, 0x00010100, 0x00000001, 0x02000000, |
525 | 0x201f00ee, 0x2622ee00, 0x0600000e, 0x04040400, | 62 | 0x00000000, 0x00400000, 0x00000000, 0x00000000, |
526 | 0x00000000, 0x00000000, 0x00000200, 0x000000f0, | 63 | 0x00000000, 0x00000001, 0x00000000, 0x00040000, |
527 | 0x00018000, 0x0000001f, 0x00000000, 0x00000000, | ||
528 | 0x400000e0, 0x6080e000, 0x08f0002e, 0x2622ee00, | ||
529 | 0x201f00ee, 0x2622ee00, 0x0400000e, 0x04040400, | ||
530 | 0x00000000, 0x00000000, 0x00000000, 0x000000f0, | ||
531 | 0x00000000, 0x0000001f, 0x00000000, 0x00000000, | ||
532 | 0x000000e0, 0x6080e000, 0x08f0002e, 0x2622ee00, | ||
533 | 0x201f00ee, 0x2622ee00, 0x0000000e, 0x04040400, | ||
534 | }; | 64 | }; |
535 | 65 | ||
536 | typedef struct SpriteAnimation { | 66 | typedef struct SpriteAnimation { |
@@ -538,10 +68,11 @@ typedef struct SpriteAnimation { | |||
538 | size_t n_frames; | 68 | size_t n_frames; |
539 | } SpriteAnimation; | 69 | } SpriteAnimation; |
540 | 70 | ||
541 | typedef enum {BTN_STATE_IDLE, BTN_STATE_PRESSED} BtnState; | 71 | typedef enum {BTN_STATE_IDLE, BTN_STATE_PRESSED, BTN_STATE_RELEASED, BTN_STATE_HOLD} BtnState; |
542 | 72 | ||
543 | static size_t btn_state_idle[] = {0}; | 73 | static size_t btn_state_idle[] = {0}; |
544 | static size_t btn_state_pressed[] = {16, 16, 32, 32, 48, 48, 64, 64, 80, 96}; | 74 | // static size_t btn_state_pressed[] = {16, 16, 32, 32, 48, 48, 64, 64, 80, 96}; |
75 | static size_t btn_state_pressed[] = {0}; | ||
545 | 76 | ||
546 | static SpriteAnimation *animation_states[] = { | 77 | static SpriteAnimation *animation_states[] = { |
547 | &(SpriteAnimation){ | 78 | &(SpriteAnimation){ |
@@ -553,3 +84,60 @@ static SpriteAnimation *animation_states[] = { | |||
553 | .n_frames = sizeof(btn_state_pressed) / sizeof(size_t), | 84 | .n_frames = sizeof(btn_state_pressed) / sizeof(size_t), |
554 | }, | 85 | }, |
555 | }; | 86 | }; |
87 | |||
88 | typedef struct AnimationEntry { | ||
89 | int x_offset; | ||
90 | int y_offset; | ||
91 | int tile_offset; | ||
92 | // NOTE: Maybe this should be a part of an animation? | ||
93 | // For example, hidden state, h/v flip. | ||
94 | u16 hidden; | ||
95 | // u16 obj_attr_1; | ||
96 | // u16 obj_attr_2; | ||
97 | } AnimationEntry; | ||
98 | |||
99 | typedef struct ObjState { | ||
100 | size_t id; | ||
101 | int x; | ||
102 | int y; | ||
103 | u32 *data; | ||
104 | size_t base_tile; | ||
105 | size_t n_tiles; | ||
106 | size_t frames; | ||
107 | u16 obj_attr_0; | ||
108 | u16 obj_attr_1; | ||
109 | u16 obj_attr_2; | ||
110 | } ObjState; | ||
111 | |||
112 | AnimationEntry *btn_down_animation[] = { | ||
113 | &(AnimationEntry[]){ | ||
114 | {0, 0, 0, 0}, | ||
115 | {0, 0, 0, 0}, | ||
116 | {0, 1, 0, 0}, | ||
117 | {0, 1, 0, 0}, | ||
118 | {0, 2, 0, 0}, | ||
119 | {0, 2, 0, 0}, | ||
120 | {0, 2, 0, 0}, | ||
121 | {0, 2, 0, 0}, | ||
122 | }, | ||
123 | &(AnimationEntry[]){ | ||
124 | {0, 11, 0, 0}, | ||
125 | {0, 11, 0, 0}, | ||
126 | {0, 11, 0, 0}, | ||
127 | {0, 11, 0, 0}, | ||
128 | {0, 11, 0, 0}, | ||
129 | {0, 11, 0, 0}, | ||
130 | {0, 11, 0, 0}, | ||
131 | {0, 11, 0, 0}, | ||
132 | }, | ||
133 | &(AnimationEntry[]){ | ||
134 | {-8, 17, 0, 1}, | ||
135 | {-8, 17, 0, 0}, | ||
136 | {-8, 17, 4, 0}, | ||
137 | {-8, 17, 4, 0}, | ||
138 | {-8, 17, 8, 0}, | ||
139 | {-8, 17, 8, 0}, | ||
140 | {-8, 17, 12, 0}, | ||
141 | {-8, 17, 12, 1}, | ||
142 | }, | ||
143 | }; | ||
@@ -142,6 +142,33 @@ rgb15(u32 red, u32 green, u32 blue ) { | |||
142 | #define OBJ_AFFINE_PC(N) *((vs16*)(MEM_OAM + 6 + 8 * 2 + 8 * 4 * (N))) | 142 | #define OBJ_AFFINE_PC(N) *((vs16*)(MEM_OAM + 6 + 8 * 2 + 8 * 4 * (N))) |
143 | #define OBJ_AFFINE_PD(N) *((vs16*)(MEM_OAM + 6 + 8 * 3 + 8 * 4 * (N))) | 143 | #define OBJ_AFFINE_PD(N) *((vs16*)(MEM_OAM + 6 + 8 * 3 + 8 * 4 * (N))) |
144 | 144 | ||
145 | // OBJ_ATTR_0 parameters | ||
146 | #define OBJ_Y_COORD(N) ((N) & 0xFF) | ||
147 | #define OBJ_NORMAL (0x00 << 0x8) | ||
148 | #define OBJ_AFFINE (0x01 << 0x8) | ||
149 | #define OBJ_HIDDEN (0x02 << 0x8) | ||
150 | #define OBJ_AFFINE_2X (0x03 << 0x8) | ||
151 | #define OBJ_ALPHA_BLEND (0x01 << 0xA) | ||
152 | #define OBJ_WINDOW (0x02 << 0xA) | ||
153 | #define OBJ_SHAPE_SQUARE (0x00 << 0xE) | ||
154 | #define OBJ_SHAPE_WIDE (0x01 << 0xE) | ||
155 | #define OBJ_SHAPE_TALL (0x02 << 0xE) | ||
156 | |||
157 | // OBJ_ATTR_1 parameters | ||
158 | #define OBJ_X_COORD(N) ((N) & 0x1FF) | ||
159 | #define OBJ_AFFINE_IDX(N) ((N) << 0x9) | ||
160 | #define OBJ_H_FLIP (0x01 << 0xC) | ||
161 | #define OBJ_V_FLIP (0x01 << 0xD) | ||
162 | #define OBJ_SIZE_SMALL (0x00 << 0xE) | ||
163 | #define OBJ_SIZE_MID (0x01 << 0xE) | ||
164 | #define OBJ_SIZE_BIG (0x02 << 0xE) | ||
165 | #define OBJ_SIZE_HUGE (0x03 << 0xE) | ||
166 | |||
167 | // OBJ_ATTR_2 parameters | ||
168 | #define OBJ_TILE_INDEX(N) ((N) & 0x3FF) | ||
169 | #define OBJ_PRIORITY(N) ((N) << 0xA) | ||
170 | #define OBJ_PAL_BANK(N) ((N) << 0xC) | ||
171 | |||
145 | // Using bd-font, an 8x8 bitmap font. | 172 | // Using bd-font, an 8x8 bitmap font. |
146 | static void | 173 | static void |
147 | put_char(int x, int y, Color clr, u8 chr) { | 174 | put_char(int x, int y, Color clr, u8 chr) { |
@@ -504,6 +531,15 @@ typedef struct ButtonSprite { | |||
504 | BtnState state; | 531 | BtnState state; |
505 | } ButtonSprite; | 532 | } ButtonSprite; |
506 | 533 | ||
534 | typedef struct MultiSprite { | ||
535 | ObjState *sprites; | ||
536 | AnimationEntry **animations; | ||
537 | int frame; | ||
538 | size_t n_obj; | ||
539 | size_t n_frames; | ||
540 | BtnState state; | ||
541 | } MultiSprite; | ||
542 | |||
507 | #define NUM_SPRITES 128 | 543 | #define NUM_SPRITES 128 |
508 | 544 | ||
509 | Sprite sprites[NUM_SPRITES]; | 545 | Sprite sprites[NUM_SPRITES]; |
@@ -550,6 +586,73 @@ load_packed_sprite_data(u32 *sprite_data, size_t n_tiles, size_t n_frames) { | |||
550 | return sprite_counter++; | 586 | return sprite_counter++; |
551 | } | 587 | } |
552 | 588 | ||
589 | void | ||
590 | init_button_sprite(MultiSprite *btn) { | ||
591 | for (size_t i = 0; i < btn->n_obj; ++i) { | ||
592 | btn->sprites[i].id = load_packed_sprite_data( | ||
593 | btn->sprites[i].data, | ||
594 | btn->sprites[i].n_tiles, | ||
595 | btn->sprites[i].frames); | ||
596 | btn->sprites[i].base_tile = sprites[btn->sprites[i].id].tile_start; | ||
597 | } | ||
598 | } | ||
599 | |||
600 | void | ||
601 | button_tick(MultiSprite *btn) { | ||
602 | // Nothing to do here. | ||
603 | if (btn->state == BTN_STATE_IDLE) { | ||
604 | return; | ||
605 | } | ||
606 | |||
607 | // Reset animation state. | ||
608 | if (btn->state == BTN_STATE_PRESSED && btn->frame != 0) { | ||
609 | btn->frame = 0; | ||
610 | } | ||
611 | |||
612 | // Continue the animation. | ||
613 | if (btn->state == BTN_STATE_HOLD || btn->state == BTN_STATE_PRESSED ) { | ||
614 | if(btn->frame < btn->n_frames - 1) { | ||
615 | btn->frame++; | ||
616 | } | ||
617 | } | ||
618 | |||
619 | // Finish the animation and return to idle. | ||
620 | if (btn->state == BTN_STATE_RELEASED) { | ||
621 | if (btn->frame > 0 && btn->frame < btn->n_frames - 1) { | ||
622 | btn->frame++; | ||
623 | } else { | ||
624 | btn->frame = 0; | ||
625 | btn->state = BTN_STATE_IDLE; | ||
626 | } | ||
627 | } | ||
628 | for (size_t i = 0; i < btn->n_obj; ++i) { | ||
629 | AnimationEntry anim_frame = btn->animations[i][btn->frame]; | ||
630 | int x = btn->sprites[i].x + anim_frame.x_offset; | ||
631 | int y = btn->sprites[i].y + anim_frame.y_offset; | ||
632 | int base_tile = btn->sprites[i].base_tile + anim_frame.tile_offset; | ||
633 | |||
634 | // Clear the previous x/y coordinate and base tiles. | ||
635 | btn->sprites[i].obj_attr_0 &= ~0xFF; | ||
636 | btn->sprites[i].obj_attr_1 &= ~0x1FF; | ||
637 | btn->sprites[i].obj_attr_2 &= ~0x3FF; | ||
638 | |||
639 | // Update x/y/tile and hidden state from the animations. | ||
640 | btn->sprites[i].obj_attr_0 |= OBJ_Y_COORD(y); | ||
641 | btn->sprites[i].obj_attr_1 |= OBJ_X_COORD(x); | ||
642 | btn->sprites[i].obj_attr_2 |= base_tile; | ||
643 | if (anim_frame.hidden) { | ||
644 | btn->sprites[i].obj_attr_0 |= OBJ_HIDDEN; | ||
645 | } else { | ||
646 | btn->sprites[i].obj_attr_0 &= ~OBJ_HIDDEN; | ||
647 | } | ||
648 | |||
649 | // Update OBJ attributes. | ||
650 | OBJ_ATTR_0(btn->sprites[i].id) = btn->sprites[i].obj_attr_0; | ||
651 | OBJ_ATTR_1(btn->sprites[i].id) = btn->sprites[i].obj_attr_1; | ||
652 | OBJ_ATTR_2(btn->sprites[i].id) = btn->sprites[i].obj_attr_2; | ||
653 | } | ||
654 | } | ||
655 | |||
553 | int main(void) { | 656 | int main(void) { |
554 | 657 | ||
555 | // Add colors to the sprite color palette. Tiles with color number 0 are | 658 | // Add colors to the sprite color palette. Tiles with color number 0 are |
@@ -586,93 +689,152 @@ int main(void) { | |||
586 | int buttons_x = SCREEN_WIDTH / 2; | 689 | int buttons_x = SCREEN_WIDTH / 2; |
587 | int buttons_y = SCREEN_HEIGHT / 2; | 690 | int buttons_y = SCREEN_HEIGHT / 2; |
588 | ButtonSprite btn_b = { | 691 | ButtonSprite btn_b = { |
589 | .id = load_packed_sprite_data(&gba_btn_b_data, 16, 7), | 692 | .id = load_packed_sprite_data(&gba_btn_b_data, 4, 1), |
590 | .x = buttons_x + 32, | 693 | .x = buttons_x + 32, |
591 | .y = buttons_y + 32, | 694 | .y = buttons_y + 32, |
592 | .frame = 0, | 695 | .frame = 0, |
593 | .state = BTN_STATE_IDLE, | 696 | .state = BTN_STATE_IDLE, |
594 | }; | 697 | }; |
595 | OBJ_ATTR_0(btn_b.id) = btn_b.y; | 698 | OBJ_ATTR_0(btn_b.id) = btn_b.y; |
596 | OBJ_ATTR_1(btn_b.id) = btn_b.x | (1 << 0xF); | 699 | OBJ_ATTR_1(btn_b.id) = btn_b.x | (1 << 0xE); |
597 | OBJ_ATTR_2(btn_b.id) = sprites[btn_b.id].tile_start; | 700 | OBJ_ATTR_2(btn_b.id) = sprites[btn_b.id].tile_start; |
598 | 701 | ||
599 | ButtonSprite btn_a = { | 702 | ButtonSprite btn_a = { |
600 | .id = load_packed_sprite_data(&gba_btn_a_data, 16, 7), | 703 | .id = load_packed_sprite_data(&gba_btn_a_data, 4, 1), |
601 | .x = buttons_x + 32 + 20, | 704 | .x = buttons_x + 32 + 20, |
602 | .y = buttons_y + 32 - 16, | 705 | .y = buttons_y + 32 - 16, |
603 | .frame = 0, | 706 | .frame = 0, |
604 | .state = BTN_STATE_IDLE, | 707 | .state = BTN_STATE_IDLE, |
605 | }; | 708 | }; |
606 | OBJ_ATTR_0(btn_a.id) = btn_a.y; | 709 | OBJ_ATTR_0(btn_a.id) = btn_a.y; |
607 | OBJ_ATTR_1(btn_a.id) = btn_a.x | (1 << 0xF); | 710 | OBJ_ATTR_1(btn_a.id) = btn_a.x | (1 << 0xE); |
608 | OBJ_ATTR_2(btn_a.id) = sprites[btn_a.id].tile_start; | 711 | OBJ_ATTR_2(btn_a.id) = sprites[btn_a.id].tile_start; |
609 | 712 | ||
610 | ButtonSprite btn_down = { | ||
611 | .id = load_packed_sprite_data(&gba_btn_down_data, 16, 7), | ||
612 | .x = buttons_x - 64 - 16, | ||
613 | .y = buttons_y + 32, | ||
614 | .frame = 0, | ||
615 | .state = BTN_STATE_IDLE, | ||
616 | }; | ||
617 | OBJ_ATTR_0(btn_down.id) = btn_down.y; | ||
618 | OBJ_ATTR_1(btn_down.id) = btn_down.x | (1 << 0xF); | ||
619 | OBJ_ATTR_2(btn_down.id) = sprites[btn_down.id].tile_start; | ||
620 | |||
621 | ButtonSprite btn_up = { | 713 | ButtonSprite btn_up = { |
622 | .id = load_packed_sprite_data(&gba_btn_up_data, 16, 7), | 714 | .id = load_packed_sprite_data(&gba_btn_updown_data, 4, 1), |
623 | .x = buttons_x - 64 - 16, | 715 | .x = buttons_x - 64 - 16, |
624 | .y = buttons_y + 32 - 18, | 716 | .y = buttons_y + 32 - 18, |
625 | .frame = 0, | 717 | .frame = 0, |
626 | .state = BTN_STATE_IDLE, | 718 | .state = BTN_STATE_IDLE, |
627 | }; | 719 | }; |
628 | OBJ_ATTR_0(btn_up.id) = btn_up.y; | 720 | OBJ_ATTR_0(btn_up.id) = btn_up.y; |
629 | OBJ_ATTR_1(btn_up.id) = btn_up.x | (1 << 0xF); | 721 | OBJ_ATTR_1(btn_up.id) = btn_up.x | (1 << 0xE); |
630 | OBJ_ATTR_2(btn_up.id) = sprites[btn_up.id].tile_start; | 722 | OBJ_ATTR_2(btn_up.id) = sprites[btn_up.id].tile_start; |
631 | 723 | ||
632 | ButtonSprite btn_left = { | 724 | ButtonSprite btn_left = { |
633 | .id = load_packed_sprite_data(&gba_btn_left_data, 16, 7), | 725 | .id = load_packed_sprite_data(&gba_btn_leftright_data, 4, 1), |
634 | .x = buttons_x - 64 - 16 - 12, | 726 | .x = buttons_x - 64 - 16 - 10, |
635 | .y = buttons_y + 32 - 10, | 727 | .y = buttons_y + 32 - 10, |
636 | .frame = 0, | 728 | .frame = 0, |
637 | .state = BTN_STATE_IDLE, | 729 | .state = BTN_STATE_IDLE, |
638 | }; | 730 | }; |
639 | OBJ_ATTR_0(btn_left.id) = btn_left.y; | 731 | OBJ_ATTR_0(btn_left.id) = btn_left.y; |
640 | OBJ_ATTR_1(btn_left.id) = btn_left.x | (1 << 0xF); | 732 | OBJ_ATTR_1(btn_left.id) = btn_left.x | (1 << 0xE); |
641 | OBJ_ATTR_2(btn_left.id) = sprites[btn_left.id].tile_start; | 733 | OBJ_ATTR_2(btn_left.id) = sprites[btn_left.id].tile_start; |
642 | 734 | ||
643 | ButtonSprite btn_right = { | 735 | ButtonSprite btn_right = { |
644 | .id = load_packed_sprite_data(&gba_btn_right_data, 16, 7), | 736 | .id = load_packed_sprite_data(&gba_btn_leftright_data, 4, 1), |
645 | .x = buttons_x - 64 - 16 + 11, | 737 | .x = buttons_x - 64 - 16 + 11, |
646 | .y = buttons_y + 32 - 10, | 738 | .y = buttons_y + 32 - 10, |
647 | .frame = 0, | 739 | .frame = 0, |
648 | .state = BTN_STATE_IDLE, | 740 | .state = BTN_STATE_IDLE, |
649 | }; | 741 | }; |
650 | OBJ_ATTR_0(btn_right.id) = btn_right.y; | 742 | OBJ_ATTR_0(btn_right.id) = btn_right.y; |
651 | OBJ_ATTR_1(btn_right.id) = btn_right.x | (1 << 0xF); | 743 | OBJ_ATTR_1(btn_right.id) = btn_right.x | (1 << 0xE) | (1 << 0xC); |
652 | OBJ_ATTR_2(btn_right.id) = sprites[btn_right.id].tile_start; | 744 | OBJ_ATTR_2(btn_right.id) = sprites[btn_right.id].tile_start; |
653 | 745 | ||
654 | ButtonSprite btn_l = { | 746 | ButtonSprite btn_l = { |
655 | .id = load_packed_sprite_data(&gba_btn_l_data, 16, 7), | 747 | .id = load_packed_sprite_data(&gba_btn_l_data, 2, 1), |
656 | .x = buttons_x - 64 - 28, | 748 | .x = buttons_x - 64 - 28, |
657 | .y = buttons_y - 32 - 20, | 749 | .y = buttons_y - 32 - 20, |
658 | .frame = 0, | 750 | .frame = 0, |
659 | .state = BTN_STATE_IDLE, | 751 | .state = BTN_STATE_IDLE, |
660 | }; | 752 | }; |
661 | OBJ_ATTR_0(btn_l.id) = btn_l.y; | 753 | OBJ_ATTR_0(btn_l.id) = btn_l.y | (1 << 0xE); |
662 | OBJ_ATTR_1(btn_l.id) = btn_l.x | (1 << 0xF); | 754 | OBJ_ATTR_1(btn_l.id) = btn_l.x; |
663 | OBJ_ATTR_2(btn_l.id) = sprites[btn_l.id].tile_start; | 755 | OBJ_ATTR_2(btn_l.id) = sprites[btn_l.id].tile_start; |
664 | 756 | ||
665 | ButtonSprite btn_r = { | 757 | ButtonSprite btn_r = { |
666 | .id = load_packed_sprite_data(&gba_btn_r_data, 16, 7), | 758 | .id = load_packed_sprite_data(&gba_btn_r_data, 2, 1), |
667 | .x = buttons_x + 32 + 20, | 759 | .x = buttons_x + 32 + 20, |
668 | .y = buttons_y - 32 - 20, | 760 | .y = buttons_y - 32 - 20, |
669 | .frame = 0, | 761 | .frame = 0, |
670 | .state = BTN_STATE_IDLE, | 762 | .state = BTN_STATE_IDLE, |
671 | }; | 763 | }; |
672 | OBJ_ATTR_0(btn_r.id) = btn_r.y; | 764 | OBJ_ATTR_0(btn_r.id) = btn_r.y | (1 << 0xE); |
673 | OBJ_ATTR_1(btn_r.id) = btn_r.x | (1 << 0xF); | 765 | OBJ_ATTR_1(btn_r.id) = btn_r.x; |
674 | OBJ_ATTR_2(btn_r.id) = sprites[btn_r.id].tile_start; | 766 | OBJ_ATTR_2(btn_r.id) = sprites[btn_r.id].tile_start; |
675 | 767 | ||
768 | ButtonSprite btn_start = { | ||
769 | .id = load_packed_sprite_data(&gba_btn_startselect_data, 2, 2), | ||
770 | .x = buttons_x - 10, | ||
771 | .y = buttons_y + 40, | ||
772 | .frame = 0, | ||
773 | .state = BTN_STATE_IDLE, | ||
774 | }; | ||
775 | OBJ_ATTR_0(btn_start.id) = btn_start.y | (1 << 0xE); | ||
776 | OBJ_ATTR_1(btn_start.id) = btn_start.x; | ||
777 | OBJ_ATTR_2(btn_start.id) = sprites[btn_start.id].tile_start; | ||
778 | |||
779 | ButtonSprite btn_select = { | ||
780 | .id = load_packed_sprite_data(&gba_btn_startselect_data, 2, 2), | ||
781 | .x = buttons_x - 32, | ||
782 | .y = buttons_y + 40, | ||
783 | .frame = 0, | ||
784 | .state = BTN_STATE_IDLE, | ||
785 | }; | ||
786 | OBJ_ATTR_0(btn_select.id) = btn_select.y | (1 << 0xE); | ||
787 | OBJ_ATTR_1(btn_select.id) = btn_select.x; | ||
788 | OBJ_ATTR_2(btn_select.id) = sprites[btn_select.id].tile_start; | ||
789 | |||
790 | MultiSprite buttons[] = { | ||
791 | { | ||
792 | .frame = 0, | ||
793 | .n_obj = 3, | ||
794 | .n_frames = 8, | ||
795 | .state = BTN_STATE_RELEASED, | ||
796 | .animations = &btn_down_animation, | ||
797 | .sprites = &(ObjState[]){ | ||
798 | { | ||
799 | .id = 0, | ||
800 | .x = buttons_x - 64 - 16, | ||
801 | .y = buttons_y + 29, | ||
802 | .data = &gba_btn_updown_data, | ||
803 | .n_tiles = 4, | ||
804 | .frames = 1, | ||
805 | .obj_attr_0 = 0, | ||
806 | .obj_attr_1 = OBJ_V_FLIP | OBJ_SIZE_MID, | ||
807 | .obj_attr_2 = 0 | ||
808 | }, | ||
809 | { | ||
810 | .id = 0, | ||
811 | .x = buttons_x - 64 - 16, | ||
812 | .y = buttons_y + 29, | ||
813 | .data = &gba_btn_down_shadow_data, | ||
814 | .n_tiles = 2, | ||
815 | .frames = 1, | ||
816 | .obj_attr_0 = OBJ_SHAPE_WIDE, | ||
817 | .obj_attr_1 = OBJ_SIZE_SMALL, | ||
818 | .obj_attr_2 = 0 | ||
819 | }, | ||
820 | { | ||
821 | .id = 0, | ||
822 | .x = buttons_x - 64 - 16, | ||
823 | .y = buttons_y + 29, | ||
824 | .data = &gba_btn_fx_downup, | ||
825 | .n_tiles = 4, | ||
826 | .frames = 4, | ||
827 | .obj_attr_0 = OBJ_SHAPE_WIDE, | ||
828 | .obj_attr_1 = OBJ_SIZE_MID, | ||
829 | .obj_attr_2 = 0 | ||
830 | }, | ||
831 | }, | ||
832 | }, | ||
833 | }; | ||
834 | for (size_t i = 0; i < sizeof(buttons) / sizeof(MultiSprite); ++i) { | ||
835 | init_button_sprite(&buttons[i]); | ||
836 | } | ||
837 | |||
676 | int frame_counter = 0; | 838 | int frame_counter = 0; |
677 | int x = 0; | 839 | int x = 0; |
678 | int y = 0; | 840 | int y = 0; |
@@ -680,149 +842,46 @@ int main(void) { | |||
680 | wait_vsync(); | 842 | wait_vsync(); |
681 | poll_keys(); | 843 | poll_keys(); |
682 | 844 | ||
683 | if (key_pressed(KEY_B)) { | 845 | // if (key_pressed(KEY_B)) { |
684 | btn_b.frame = 0; | 846 | // btn_b.frame = 0; |
685 | btn_b.state = BTN_STATE_PRESSED; | 847 | // btn_b.state = BTN_STATE_PRESSED; |
686 | } else if (key_hold(KEY_B)) { | 848 | // } else if (key_hold(KEY_B)) { |
687 | size_t n_frames = animation_states[btn_b.state]->n_frames; | 849 | // if (btn_b.frame < btn_b.n_frames - 1) { |
688 | if (btn_b.frame < n_frames - 1) { | 850 | // btn_b.frame++; |
689 | btn_b.frame++; | 851 | // } |
690 | } | 852 | // } else { |
691 | } else { | 853 | // // Finish the animation and reset idle state. |
692 | // Finish the animation and reset idle state. | 854 | // if (btn_b.frame > 0 && btn_b.frame < btn_b.n_frames - 1) { |
693 | size_t n_frames = animation_states[btn_b.state]->n_frames; | 855 | // btn_b.frame++; |
694 | if (btn_b.frame > 0 && btn_b.frame < n_frames - 1) { | 856 | // } else { |
695 | btn_b.frame++; | 857 | // btn_b.frame = 0; |
696 | } else { | 858 | // btn_b.state = BTN_STATE_IDLE; |
697 | btn_b.frame = 0; | 859 | // } |
698 | btn_b.state = BTN_STATE_IDLE; | 860 | // } |
699 | } | 861 | // if (key_pressed(KEY_A)) { |
700 | } | 862 | // btn_a.frame = 0; |
701 | if (key_pressed(KEY_A)) { | 863 | // btn_a.state = BTN_STATE_PRESSED; |
702 | btn_a.frame = 0; | 864 | // } else if (key_hold(KEY_A)) { |
703 | btn_a.state = BTN_STATE_PRESSED; | 865 | // size_t n_frames = animation_states[btn_a.state]->n_frames; |
704 | } else if (key_hold(KEY_A)) { | 866 | // if (btn_a.frame < n_frames - 1) { |
705 | size_t n_frames = animation_states[btn_a.state]->n_frames; | 867 | // btn_a.frame++; |
706 | if (btn_a.frame < n_frames - 1) { | 868 | // } |
707 | btn_a.frame++; | 869 | // } else { |
708 | } | 870 | // // Finish the animation and reset idle state. |
709 | } else { | 871 | // size_t n_frames = animation_states[btn_a.state]->n_frames; |
710 | // Finish the animation and reset idle state. | 872 | // if (btn_a.frame > 0 && btn_a.frame < n_frames - 1) { |
711 | size_t n_frames = animation_states[btn_a.state]->n_frames; | 873 | // btn_a.frame++; |
712 | if (btn_a.frame > 0 && btn_a.frame < n_frames - 1) { | 874 | // } else { |
713 | btn_a.frame++; | 875 | // btn_a.frame = 0; |
714 | } else { | 876 | // btn_a.state = BTN_STATE_IDLE; |
715 | btn_a.frame = 0; | 877 | // } |
716 | btn_a.state = BTN_STATE_IDLE; | 878 | // } |
717 | } | ||
718 | } | ||
719 | if (key_pressed(KEY_DOWN)) { | 879 | if (key_pressed(KEY_DOWN)) { |
720 | btn_down.frame = 0; | 880 | buttons[0].state = BTN_STATE_PRESSED; |
721 | btn_down.state = BTN_STATE_PRESSED; | ||
722 | } else if (key_hold(KEY_DOWN)) { | 881 | } else if (key_hold(KEY_DOWN)) { |
723 | size_t n_frames = animation_states[btn_down.state]->n_frames; | 882 | buttons[0].state = BTN_STATE_HOLD; |
724 | if (btn_down.frame < n_frames - 1) { | ||
725 | btn_down.frame++; | ||
726 | } | ||
727 | } else { | ||
728 | // Finish the animation and reset idle state. | ||
729 | size_t n_frames = animation_states[btn_down.state]->n_frames; | ||
730 | if (btn_down.frame > 0 && btn_down.frame < n_frames - 1) { | ||
731 | btn_down.frame++; | ||
732 | } else { | ||
733 | btn_down.frame = 0; | ||
734 | btn_down.state = BTN_STATE_IDLE; | ||
735 | } | ||
736 | } | ||
737 | if (key_pressed(KEY_UP)) { | ||
738 | btn_up.frame = 0; | ||
739 | btn_up.state = BTN_STATE_PRESSED; | ||
740 | } else if (key_hold(KEY_UP)) { | ||
741 | size_t n_frames = animation_states[btn_up.state]->n_frames; | ||
742 | if (btn_up.frame < n_frames - 1) { | ||
743 | btn_up.frame++; | ||
744 | } | ||
745 | } else { | ||
746 | // Finish the animation and reset idle state. | ||
747 | size_t n_frames = animation_states[btn_up.state]->n_frames; | ||
748 | if (btn_up.frame > 0 && btn_up.frame < n_frames - 1) { | ||
749 | btn_up.frame++; | ||
750 | } else { | ||
751 | btn_up.frame = 0; | ||
752 | btn_up.state = BTN_STATE_IDLE; | ||
753 | } | ||
754 | } | ||
755 | if (key_pressed(KEY_LEFT)) { | ||
756 | btn_left.frame = 0; | ||
757 | btn_left.state = BTN_STATE_PRESSED; | ||
758 | } else if (key_hold(KEY_LEFT)) { | ||
759 | size_t n_frames = animation_states[btn_left.state]->n_frames; | ||
760 | if (btn_left.frame < n_frames - 1) { | ||
761 | btn_left.frame++; | ||
762 | } | ||
763 | } else { | ||
764 | // Finish the animation and reset idle state. | ||
765 | size_t n_frames = animation_states[btn_left.state]->n_frames; | ||
766 | if (btn_left.frame > 0 && btn_left.frame < n_frames - 1) { | ||
767 | btn_left.frame++; | ||
768 | } else { | ||
769 | btn_left.frame = 0; | ||
770 | btn_left.state = BTN_STATE_IDLE; | ||
771 | } | ||
772 | } | ||
773 | if (key_pressed(KEY_RIGHT)) { | ||
774 | btn_right.frame = 0; | ||
775 | btn_right.state = BTN_STATE_PRESSED; | ||
776 | } else if (key_hold(KEY_RIGHT)) { | ||
777 | size_t n_frames = animation_states[btn_right.state]->n_frames; | ||
778 | if (btn_right.frame < n_frames - 1) { | ||
779 | btn_right.frame++; | ||
780 | } | ||
781 | } else { | ||
782 | // Finish the animation and reset idle state. | ||
783 | size_t n_frames = animation_states[btn_right.state]->n_frames; | ||
784 | if (btn_right.frame > 0 && btn_right.frame < n_frames - 1) { | ||
785 | btn_right.frame++; | ||
786 | } else { | ||
787 | btn_right.frame = 0; | ||
788 | btn_right.state = BTN_STATE_IDLE; | ||
789 | } | ||
790 | } | ||
791 | if (key_pressed(KEY_L)) { | ||
792 | btn_l.frame = 0; | ||
793 | btn_l.state = BTN_STATE_PRESSED; | ||
794 | } else if (key_hold(KEY_L)) { | ||
795 | size_t n_frames = animation_states[btn_l.state]->n_frames; | ||
796 | if (btn_l.frame < n_frames - 1) { | ||
797 | btn_l.frame++; | ||
798 | } | ||
799 | } else { | 883 | } else { |
800 | // Finish the animation and reset idle state. | 884 | buttons[0].state = BTN_STATE_RELEASED; |
801 | size_t n_frames = animation_states[btn_l.state]->n_frames; | ||
802 | if (btn_l.frame > 0 && btn_l.frame < n_frames - 1) { | ||
803 | btn_l.frame++; | ||
804 | } else { | ||
805 | btn_l.frame = 0; | ||
806 | btn_l.state = BTN_STATE_IDLE; | ||
807 | } | ||
808 | } | ||
809 | if (key_pressed(KEY_R)) { | ||
810 | btn_r.frame = 0; | ||
811 | btn_r.state = BTN_STATE_PRESSED; | ||
812 | } else if (key_hold(KEY_R)) { | ||
813 | size_t n_frames = animation_states[btn_r.state]->n_frames; | ||
814 | if (btn_r.frame < n_frames - 1) { | ||
815 | btn_r.frame++; | ||
816 | } | ||
817 | } else { | ||
818 | // Finish the animation and reset idle state. | ||
819 | size_t n_frames = animation_states[btn_r.state]->n_frames; | ||
820 | if (btn_r.frame > 0 && btn_r.frame < n_frames - 1) { | ||
821 | btn_r.frame++; | ||
822 | } else { | ||
823 | btn_r.frame = 0; | ||
824 | btn_r.state = BTN_STATE_IDLE; | ||
825 | } | ||
826 | } | 885 | } |
827 | 886 | ||
828 | if (key_hold(KEY_DOWN)) { | 887 | if (key_hold(KEY_DOWN)) { |
@@ -838,17 +897,21 @@ int main(void) { | |||
838 | x += 3; | 897 | x += 3; |
839 | } | 898 | } |
840 | 899 | ||
841 | OBJ_ATTR_2(btn_b.id) = sprites[btn_b.id].tile_start + animation_states[btn_b.state]->tile_offsets[btn_b.frame]; | 900 | // OBJ_ATTR_2(btn_b.id) = sprites[btn_b.id].tile_start + animation_states[btn_b.state]->tile_offsets[btn_b.frame]; |
842 | OBJ_ATTR_2(btn_a.id) = sprites[btn_a.id].tile_start + animation_states[btn_a.state]->tile_offsets[btn_a.frame]; | 901 | // OBJ_ATTR_2(btn_a.id) = sprites[btn_a.id].tile_start + animation_states[btn_a.state]->tile_offsets[btn_a.frame]; |
843 | OBJ_ATTR_2(btn_up.id) = sprites[btn_up.id].tile_start + animation_states[btn_up.state]->tile_offsets[btn_up.frame]; | 902 | // OBJ_ATTR_2(btn_up.id) = sprites[btn_up.id].tile_start + animation_states[btn_up.state]->tile_offsets[btn_up.frame]; |
844 | OBJ_ATTR_2(btn_down.id) = sprites[btn_down.id].tile_start + animation_states[btn_down.state]->tile_offsets[btn_down.frame]; | 903 | // // OBJ_ATTR_2(btn_down.id) = sprites[btn_down.id].tile_start + animation_states[btn_down.state]->tile_offsets[btn_down.frame]; |
845 | OBJ_ATTR_2(btn_left.id) = sprites[btn_left.id].tile_start + animation_states[btn_left.state]->tile_offsets[btn_left.frame]; | 904 | // OBJ_ATTR_2(btn_left.id) = sprites[btn_left.id].tile_start + animation_states[btn_left.state]->tile_offsets[btn_left.frame]; |
846 | OBJ_ATTR_2(btn_right.id) = sprites[btn_right.id].tile_start + animation_states[btn_right.state]->tile_offsets[btn_right.frame]; | 905 | // OBJ_ATTR_2(btn_right.id) = sprites[btn_right.id].tile_start + animation_states[btn_right.state]->tile_offsets[btn_right.frame]; |
847 | OBJ_ATTR_2(btn_l.id) = sprites[btn_l.id].tile_start + animation_states[btn_l.state]->tile_offsets[btn_l.frame]; | 906 | // OBJ_ATTR_2(btn_l.id) = sprites[btn_l.id].tile_start + animation_states[btn_l.state]->tile_offsets[btn_l.frame]; |
848 | OBJ_ATTR_2(btn_r.id) = sprites[btn_r.id].tile_start + animation_states[btn_r.state]->tile_offsets[btn_r.frame]; | 907 | // OBJ_ATTR_2(btn_r.id) = sprites[btn_r.id].tile_start + animation_states[btn_r.state]->tile_offsets[btn_r.frame]; |
849 | frame_counter++; | 908 | frame_counter++; |
850 | BG_H_SCROLL_0 = x; | 909 | BG_H_SCROLL_0 = x; |
851 | BG_V_SCROLL_0 = y; | 910 | BG_V_SCROLL_0 = y; |
911 | |||
912 | for (size_t i = 0; i < sizeof(buttons) / sizeof(MultiSprite); ++i) { | ||
913 | button_tick(&buttons[i]); | ||
914 | } | ||
852 | }; | 915 | }; |
853 | 916 | ||
854 | return 0; | 917 | return 0; |