src/gba/test/cheats.c (view raw)
1/* Copyright (c) 2013-2017 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#include "util/test/suite.h"
7
8#include <mgba/core/cheats.h>
9#include <mgba/core/core.h>
10#include <mgba/gba/core.h>
11#include <mgba/internal/gba/cheats.h>
12
13#include "gba/cheats/parv3.h"
14#include "gba/cheats/gameshark.h"
15
16M_TEST_SUITE_SETUP(GBACheats) {
17 struct mCore* core = GBACoreCreate();
18 core->init(core);
19 core->cheatDevice(core);
20 *state = core;
21 return 0;
22}
23
24M_TEST_SUITE_TEARDOWN(GBACheats) {
25 if (!*state) {
26 return 0;
27 }
28 struct mCore* core = *state;
29 core->deinit(core);
30 return 0;
31}
32
33M_TEST_DEFINE(createSet) {
34 struct mCore* core = *state;
35 struct mCheatDevice* device = core->cheatDevice(core);
36 assert_non_null(device);
37 struct mCheatSet* set = device->createSet(device, NULL);
38 assert_non_null(set);
39 set->deinit(set);
40}
41
42M_TEST_DEFINE(addRawPARv3) {
43 struct mCore* core = *state;
44 struct mCheatDevice* device = core->cheatDevice(core);
45 assert_non_null(device);
46 struct mCheatSet* set = device->createSet(device, NULL);
47 assert_non_null(set);
48 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
49 assert_true(set->addLine(set, "80000000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
50 assert_false(set->addLine(set, "43000000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
51 set->deinit(set);
52}
53
54M_TEST_DEFINE(doPARv3Assign) {
55 struct mCore* core = *state;
56 struct mCheatDevice* device = core->cheatDevice(core);
57 assert_non_null(device);
58 struct mCheatSet* set = device->createSet(device, NULL);
59 assert_non_null(set);
60 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
61 assert_true(set->addLine(set, "00300000 00000078", GBA_CHEAT_PRO_ACTION_REPLAY));
62 assert_true(set->addLine(set, "02300002 00005678", GBA_CHEAT_PRO_ACTION_REPLAY));
63 assert_true(set->addLine(set, "04300004 12345678", GBA_CHEAT_PRO_ACTION_REPLAY));
64
65 core->reset(core);
66 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
67 assert_int_equal(core->rawRead16(core, 0x03000002, -1), 0);
68 assert_int_equal(core->rawRead32(core, 0x03000004, -1), 0);
69
70 mCheatRefresh(device, set);
71 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x78);
72 assert_int_equal(core->rawRead16(core, 0x03000002, -1), 0x5678);
73 assert_int_equal(core->rawRead32(core, 0x03000004, -1), 0x12345678);
74
75 set->deinit(set);
76}
77
78M_TEST_DEFINE(doPARv3Slide1) {
79 struct mCore* core = *state;
80 struct mCheatDevice* device = core->cheatDevice(core);
81 assert_non_null(device);
82 struct mCheatSet* set = device->createSet(device, NULL);
83 assert_non_null(set);
84 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
85 assert_true(set->addLine(set, "00000000 80300000", GBA_CHEAT_PRO_ACTION_REPLAY));
86 assert_true(set->addLine(set, "00000001 01020002", GBA_CHEAT_PRO_ACTION_REPLAY));
87
88 core->reset(core);
89 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
90 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
91 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
92 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
93 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
94 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
95
96 mCheatRefresh(device, set);
97 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 1);
98 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
99 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 2);
100 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
101 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
102 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
103
104 set->deinit(set);
105}
106
107M_TEST_DEFINE(doPARv3Slide2) {
108 struct mCore* core = *state;
109 struct mCheatDevice* device = core->cheatDevice(core);
110 assert_non_null(device);
111 struct mCheatSet* set = device->createSet(device, NULL);
112 assert_non_null(set);
113 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
114 assert_true(set->addLine(set, "00000000 82300000", GBA_CHEAT_PRO_ACTION_REPLAY));
115 assert_true(set->addLine(set, "00000001 01020002", GBA_CHEAT_PRO_ACTION_REPLAY));
116
117 core->reset(core);
118 assert_int_equal(core->rawRead16(core, 0x03000000, -1), 0);
119 assert_int_equal(core->rawRead16(core, 0x03000002, -1), 0);
120 assert_int_equal(core->rawRead16(core, 0x03000004, -1), 0);
121 assert_int_equal(core->rawRead16(core, 0x03000006, -1), 0);
122 assert_int_equal(core->rawRead16(core, 0x03000008, -1), 0);
123 assert_int_equal(core->rawRead16(core, 0x0300000A, -1), 0);
124
125 mCheatRefresh(device, set);
126 assert_int_equal(core->rawRead16(core, 0x03000000, -1), 1);
127 assert_int_equal(core->rawRead16(core, 0x03000002, -1), 0);
128 assert_int_equal(core->rawRead16(core, 0x03000004, -1), 2);
129 assert_int_equal(core->rawRead16(core, 0x03000006, -1), 0);
130 assert_int_equal(core->rawRead16(core, 0x03000008, -1), 0);
131 assert_int_equal(core->rawRead16(core, 0x0300000A, -1), 0);
132
133 set->deinit(set);
134}
135
136M_TEST_DEFINE(doPARv3Slide4) {
137 struct mCore* core = *state;
138 struct mCheatDevice* device = core->cheatDevice(core);
139 assert_non_null(device);
140 struct mCheatSet* set = device->createSet(device, NULL);
141 assert_non_null(set);
142 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
143 assert_true(set->addLine(set, "00000000 84300000", GBA_CHEAT_PRO_ACTION_REPLAY));
144 assert_true(set->addLine(set, "00000001 01020002", GBA_CHEAT_PRO_ACTION_REPLAY));
145
146 core->reset(core);
147 assert_int_equal(core->rawRead32(core, 0x03000000, -1), 0);
148 assert_int_equal(core->rawRead32(core, 0x03000004, -1), 0);
149 assert_int_equal(core->rawRead32(core, 0x03000008, -1), 0);
150 assert_int_equal(core->rawRead32(core, 0x0300000C, -1), 0);
151 assert_int_equal(core->rawRead32(core, 0x03000010, -1), 0);
152 assert_int_equal(core->rawRead32(core, 0x03000014, -1), 0);
153
154 mCheatRefresh(device, set);
155 assert_int_equal(core->rawRead16(core, 0x03000000, -1), 1);
156 assert_int_equal(core->rawRead16(core, 0x03000004, -1), 0);
157 assert_int_equal(core->rawRead16(core, 0x03000008, -1), 2);
158 assert_int_equal(core->rawRead16(core, 0x0300000C, -1), 0);
159 assert_int_equal(core->rawRead16(core, 0x03000010, -1), 0);
160 assert_int_equal(core->rawRead16(core, 0x03000014, -1), 0);
161
162 set->deinit(set);
163}
164
165M_TEST_DEFINE(doPARv3If1) {
166 struct mCore* core = *state;
167 struct mCheatDevice* device = core->cheatDevice(core);
168 assert_non_null(device);
169 struct mCheatSet* set = device->createSet(device, NULL);
170 assert_non_null(set);
171 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
172 assert_true(set->addLine(set, "00300001 00000011", GBA_CHEAT_PRO_ACTION_REPLAY));
173 assert_true(set->addLine(set, "08300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
174 assert_true(set->addLine(set, "00300001 00000012", GBA_CHEAT_PRO_ACTION_REPLAY));
175 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
176
177 core->reset(core);
178 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
179 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
180
181 mCheatRefresh(device, set);
182 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
183 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x12);
184
185 core->reset(core);
186 core->rawWrite8(core, 0x03000000, -1, 0x1);
187 mCheatRefresh(device, set);
188 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
189 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x11);
190
191 set->deinit(set);
192}
193
194M_TEST_DEFINE(doPARv3If1x1) {
195 struct mCore* core = *state;
196 struct mCheatDevice* device = core->cheatDevice(core);
197 assert_non_null(device);
198 struct mCheatSet* set = device->createSet(device, NULL);
199 assert_non_null(set);
200 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
201 assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
202 assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
203 assert_true(set->addLine(set, "08300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
204 assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
205 assert_true(set->addLine(set, "08300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
206 assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
207 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
208
209 core->reset(core);
210 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
211 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
212 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
213 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
214
215 mCheatRefresh(device, set);
216 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
217 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
218 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
219 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
220
221 core->reset(core);
222 core->rawWrite8(core, 0x03000000, -1, 0x1);
223 mCheatRefresh(device, set);
224 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
225 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
226 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
227 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
228
229 core->reset(core);
230 core->rawWrite8(core, 0x03000001, -1, 0x1);
231 mCheatRefresh(device, set);
232 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
233 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
234 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
235 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
236
237 core->reset(core);
238 core->rawWrite8(core, 0x03000000, -1, 0x1);
239 core->rawWrite8(core, 0x03000001, -1, 0x1);
240 mCheatRefresh(device, set);
241 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
242 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
243 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
244 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
245
246 set->deinit(set);
247}
248
249M_TEST_DEFINE(doPARv3If2) {
250 struct mCore* core = *state;
251 struct mCheatDevice* device = core->cheatDevice(core);
252 assert_non_null(device);
253 struct mCheatSet* set = device->createSet(device, NULL);
254 assert_non_null(set);
255 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
256 assert_true(set->addLine(set, "00300001 00000011", GBA_CHEAT_PRO_ACTION_REPLAY));
257 assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
258 assert_true(set->addLine(set, "48300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
259 assert_true(set->addLine(set, "00300001 00000012", GBA_CHEAT_PRO_ACTION_REPLAY));
260 assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
261 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
262
263 core->reset(core);
264 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
265 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
266 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
267
268 mCheatRefresh(device, set);
269 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
270 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x12);
271 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
272
273 core->reset(core);
274 core->rawWrite8(core, 0x03000000, -1, 0x1);
275 mCheatRefresh(device, set);
276 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
277 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x11);
278 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
279
280 set->deinit(set);
281}
282
283M_TEST_DEFINE(doPARv3If2x2) {
284 struct mCore* core = *state;
285 struct mCheatDevice* device = core->cheatDevice(core);
286 assert_non_null(device);
287 struct mCheatSet* set = device->createSet(device, NULL);
288 assert_non_null(set);
289 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
290 assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
291 assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
292 assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
293 assert_true(set->addLine(set, "00300005 00000051", GBA_CHEAT_PRO_ACTION_REPLAY));
294 assert_true(set->addLine(set, "48300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
295 assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
296 assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
297 assert_true(set->addLine(set, "48300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
298 assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
299 assert_true(set->addLine(set, "00300005 00000052", GBA_CHEAT_PRO_ACTION_REPLAY));
300 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
301
302 core->reset(core);
303 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
304 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
305 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
306 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
307 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
308 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
309
310 mCheatRefresh(device, set);
311 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
312 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
313 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
314 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
315 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
316 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
317
318 core->reset(core);
319 core->rawWrite8(core, 0x03000000, -1, 0x1);
320 mCheatRefresh(device, set);
321 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
322 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
323 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
324 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
325 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
326 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
327
328 core->reset(core);
329 core->rawWrite8(core, 0x03000001, -1, 0x1);
330 mCheatRefresh(device, set);
331 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
332 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
333 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
334 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
335 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
336 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
337
338 core->reset(core);
339 core->rawWrite8(core, 0x03000000, -1, 0x1);
340 core->rawWrite8(core, 0x03000001, -1, 0x1);
341 mCheatRefresh(device, set);
342 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
343 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
344 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
345 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
346 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
347 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
348 set->deinit(set);
349}
350
351M_TEST_DEFINE(doPARv3If2Contain1) {
352 struct mCore* core = *state;
353 struct mCheatDevice* device = core->cheatDevice(core);
354 assert_non_null(device);
355 struct mCheatSet* set = device->createSet(device, NULL);
356 assert_non_null(set);
357 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
358 assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
359 assert_true(set->addLine(set, "48300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
360 assert_true(set->addLine(set, "08300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
361 assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
362 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
363
364 core->reset(core);
365 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
366 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
367 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
368
369 mCheatRefresh(device, set);
370 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
371 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
372 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
373
374 core->reset(core);
375 core->rawWrite8(core, 0x03000000, -1, 0x1);
376 mCheatRefresh(device, set);
377 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
378 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
379 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
380
381 core->reset(core);
382 core->rawWrite8(core, 0x03000001, -1, 0x1);
383 mCheatRefresh(device, set);
384 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
385 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
386 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
387
388 core->reset(core);
389 core->rawWrite8(core, 0x03000000, -1, 0x1);
390 core->rawWrite8(core, 0x03000001, -1, 0x1);
391 mCheatRefresh(device, set);
392 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
393 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
394 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
395 set->deinit(set);
396}
397
398M_TEST_DEFINE(doPARv3IfX) {
399 struct mCore* core = *state;
400 struct mCheatDevice* device = core->cheatDevice(core);
401 assert_non_null(device);
402 struct mCheatSet* set = device->createSet(device, NULL);
403 assert_non_null(set);
404 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
405 assert_true(set->addLine(set, "00300001 00000011", GBA_CHEAT_PRO_ACTION_REPLAY));
406 assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
407 assert_true(set->addLine(set, "00300001 00000012", GBA_CHEAT_PRO_ACTION_REPLAY));
408 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
409 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
410
411 core->reset(core);
412 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
413 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
414
415 mCheatRefresh(device, set);
416 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
417 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x12);
418
419 core->reset(core);
420 core->rawWrite8(core, 0x03000000, -1, 0x1);
421 mCheatRefresh(device, set);
422 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
423 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x11);
424 set->deinit(set);
425}
426
427M_TEST_DEFINE(doPARv3IfXxX) {
428 struct mCore* core = *state;
429 struct mCheatDevice* device = core->cheatDevice(core);
430 assert_non_null(device);
431 struct mCheatSet* set = device->createSet(device, NULL);
432 assert_non_null(set);
433 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
434 assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
435 assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
436 assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
437 assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
438 assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
439 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
440 assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
441 assert_true(set->addLine(set, "88300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
442 assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
443 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
444 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
445
446 core->reset(core);
447 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
448 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
449 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
450 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
451 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
452
453 mCheatRefresh(device, set);
454 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
455 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
456 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
457 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
458 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
459
460 core->reset(core);
461 core->rawWrite8(core, 0x03000000, -1, 0x1);
462 mCheatRefresh(device, set);
463 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
464 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
465 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
466 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
467 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
468
469 core->reset(core);
470 core->rawWrite8(core, 0x03000001, -1, 0x1);
471 mCheatRefresh(device, set);
472 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
473 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
474 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
475 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
476 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
477
478 core->reset(core);
479 core->rawWrite8(core, 0x03000000, -1, 0x1);
480 core->rawWrite8(core, 0x03000001, -1, 0x1);
481 mCheatRefresh(device, set);
482 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
483 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
484 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
485 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
486 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
487 set->deinit(set);
488}
489
490M_TEST_DEFINE(doPARv3IfXElse) {
491 struct mCore* core = *state;
492 struct mCheatDevice* device = core->cheatDevice(core);
493 assert_non_null(device);
494 struct mCheatSet* set = device->createSet(device, NULL);
495 assert_non_null(set);
496 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
497 assert_true(set->addLine(set, "00300001 00000011", GBA_CHEAT_PRO_ACTION_REPLAY));
498 assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
499 assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
500 assert_true(set->addLine(set, "00300001 00000012", GBA_CHEAT_PRO_ACTION_REPLAY));
501 assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
502 assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
503 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
504 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
505
506 core->reset(core);
507 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
508 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
509 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
510
511 mCheatRefresh(device, set);
512 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
513 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x12);
514 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
515
516 core->reset(core);
517 core->rawWrite8(core, 0x03000000, -1, 0x1);
518 mCheatRefresh(device, set);
519 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
520 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x11);
521 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
522 set->deinit(set);
523}
524
525M_TEST_DEFINE(doPARv3IfXElsexX) {
526 struct mCore* core = *state;
527 struct mCheatDevice* device = core->cheatDevice(core);
528 assert_non_null(device);
529 struct mCheatSet* set = device->createSet(device, NULL);
530 assert_non_null(set);
531 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
532 assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
533 assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
534 assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
535 assert_true(set->addLine(set, "00300005 00000051", GBA_CHEAT_PRO_ACTION_REPLAY));
536 assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
537 assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
538 assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
539 assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
540 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
541 assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
542 assert_true(set->addLine(set, "88300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
543 assert_true(set->addLine(set, "00300005 00000052", GBA_CHEAT_PRO_ACTION_REPLAY));
544 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
545 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
546
547 core->reset(core);
548 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
549 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
550 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
551 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
552 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
553 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
554
555 mCheatRefresh(device, set);
556 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
557 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
558 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
559 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
560 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
561 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
562
563 core->reset(core);
564 core->rawWrite8(core, 0x03000000, -1, 0x1);
565 mCheatRefresh(device, set);
566 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
567 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
568 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
569 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
570 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
571 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
572
573 core->reset(core);
574 core->rawWrite8(core, 0x03000001, -1, 0x1);
575 mCheatRefresh(device, set);
576 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
577 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
578 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
579 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
580 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
581 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
582
583 core->reset(core);
584 core->rawWrite8(core, 0x03000000, -1, 0x1);
585 core->rawWrite8(core, 0x03000001, -1, 0x1);
586 mCheatRefresh(device, set);
587 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
588 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
589 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
590 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
591 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
592 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
593 set->deinit(set);
594}
595
596M_TEST_DEFINE(doPARv3IfXElsexXElse) {
597 struct mCore* core = *state;
598 struct mCheatDevice* device = core->cheatDevice(core);
599 assert_non_null(device);
600 struct mCheatSet* set = device->createSet(device, NULL);
601 assert_non_null(set);
602 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
603 assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
604 assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
605 assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
606 assert_true(set->addLine(set, "00300005 00000051", GBA_CHEAT_PRO_ACTION_REPLAY));
607 assert_true(set->addLine(set, "00300006 00000061", GBA_CHEAT_PRO_ACTION_REPLAY));
608 assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
609 assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
610 assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
611 assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
612 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
613 assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
614 assert_true(set->addLine(set, "88300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
615 assert_true(set->addLine(set, "00300005 00000052", GBA_CHEAT_PRO_ACTION_REPLAY));
616 assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
617 assert_true(set->addLine(set, "00300006 00000062", GBA_CHEAT_PRO_ACTION_REPLAY));
618 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
619 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
620
621 core->reset(core);
622 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
623 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
624 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
625 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
626 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
627 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
628 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0);
629
630 mCheatRefresh(device, set);
631 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
632 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
633 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
634 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
635 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
636 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
637
638 core->reset(core);
639 core->rawWrite8(core, 0x03000000, -1, 0x1);
640 mCheatRefresh(device, set);
641 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
642 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
643 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
644 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
645 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
646 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
647 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x61);
648
649 core->reset(core);
650 core->rawWrite8(core, 0x03000001, -1, 0x1);
651 mCheatRefresh(device, set);
652 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
653 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
654 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
655 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
656 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
657 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
658 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
659
660 core->reset(core);
661 core->rawWrite8(core, 0x03000000, -1, 0x1);
662 core->rawWrite8(core, 0x03000001, -1, 0x1);
663 mCheatRefresh(device, set);
664 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
665 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
666 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
667 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
668 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
669 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
670 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
671 set->deinit(set);
672}
673
674M_TEST_DEFINE(doPARv3IfXContain1) {
675 struct mCore* core = *state;
676 struct mCheatDevice* device = core->cheatDevice(core);
677 assert_non_null(device);
678 struct mCheatSet* set = device->createSet(device, NULL);
679 assert_non_null(set);
680 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
681 assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
682 assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
683 assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
684 assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
685 assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
686 assert_true(set->addLine(set, "08300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
687 assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
688 assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
689 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
690 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
691
692 core->reset(core);
693 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
694 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
695 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
696 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
697 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
698
699 mCheatRefresh(device, set);
700 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
701 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
702 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
703 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
704 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
705
706 core->reset(core);
707 core->rawWrite8(core, 0x03000000, -1, 0x1);
708 mCheatRefresh(device, set);
709 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
710 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
711 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
712 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
713 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
714
715 core->reset(core);
716 core->rawWrite8(core, 0x03000001, -1, 0x1);
717 mCheatRefresh(device, set);
718 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
719 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
720 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
721 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
722 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
723
724 core->reset(core);
725 core->rawWrite8(core, 0x03000000, -1, 0x1);
726 core->rawWrite8(core, 0x03000001, -1, 0x1);
727 mCheatRefresh(device, set);
728 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
729 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
730 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
731 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
732 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
733 set->deinit(set);
734}
735
736M_TEST_DEFINE(doPARv3IfXContain1Else) {
737 struct mCore* core = *state;
738 struct mCheatDevice* device = core->cheatDevice(core);
739 assert_non_null(device);
740 struct mCheatSet* set = device->createSet(device, NULL);
741 assert_non_null(set);
742 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
743 assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
744 assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
745 assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
746 assert_true(set->addLine(set, "00300005 00000051", GBA_CHEAT_PRO_ACTION_REPLAY));
747 assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
748 assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
749 assert_true(set->addLine(set, "08300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
750 assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
751 assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
752 assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
753 assert_true(set->addLine(set, "00300005 00000052", GBA_CHEAT_PRO_ACTION_REPLAY));
754 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
755 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
756
757 core->reset(core);
758 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
759 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
760 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
761 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
762 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
763 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
764
765 mCheatRefresh(device, set);
766 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
767 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
768 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
769 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
770 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
771 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
772
773 core->reset(core);
774 core->rawWrite8(core, 0x03000000, -1, 0x1);
775 mCheatRefresh(device, set);
776 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
777 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
778 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
779 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
780 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
781 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
782
783 core->reset(core);
784 core->rawWrite8(core, 0x03000001, -1, 0x1);
785 mCheatRefresh(device, set);
786 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
787 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
788 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
789 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
790 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
791 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
792
793 core->reset(core);
794 core->rawWrite8(core, 0x03000000, -1, 0x1);
795 core->rawWrite8(core, 0x03000001, -1, 0x1);
796 mCheatRefresh(device, set);
797 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
798 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
799 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
800 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
801 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
802 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
803 set->deinit(set);
804}
805
806M_TEST_DEFINE(doPARv3IfXElseContain1) {
807 struct mCore* core = *state;
808 struct mCheatDevice* device = core->cheatDevice(core);
809 assert_non_null(device);
810 struct mCheatSet* set = device->createSet(device, NULL);
811 assert_non_null(set);
812 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
813 assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
814 assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
815 assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
816 assert_true(set->addLine(set, "00300005 00000051", GBA_CHEAT_PRO_ACTION_REPLAY));
817 assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
818 assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
819 assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
820 assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
821 assert_true(set->addLine(set, "08300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
822 assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
823 assert_true(set->addLine(set, "00300005 00000052", GBA_CHEAT_PRO_ACTION_REPLAY));
824 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
825 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
826
827 core->reset(core);
828 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
829 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
830 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
831 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
832 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
833 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
834
835 mCheatRefresh(device, set);
836 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
837 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
838 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
839 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
840 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
841 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
842
843 core->reset(core);
844 core->rawWrite8(core, 0x03000000, -1, 0x1);
845 mCheatRefresh(device, set);
846 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
847 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
848 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
849 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
850 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
851 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
852
853 core->reset(core);
854 core->rawWrite8(core, 0x03000001, -1, 0x1);
855 mCheatRefresh(device, set);
856 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
857 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
858 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
859 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
860 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
861 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
862
863 core->reset(core);
864 core->rawWrite8(core, 0x03000000, -1, 0x1);
865 core->rawWrite8(core, 0x03000001, -1, 0x1);
866 mCheatRefresh(device, set);
867 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
868 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
869 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
870 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
871 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
872 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
873 set->deinit(set);
874}
875
876M_TEST_DEFINE(doPARv3IfXContain1ElseContain1) {
877 struct mCore* core = *state;
878 struct mCheatDevice* device = core->cheatDevice(core);
879 assert_non_null(device);
880 struct mCheatSet* set = device->createSet(device, NULL);
881 assert_non_null(set);
882 GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
883 assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
884 assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
885 assert_true(set->addLine(set, "00300005 00000051", GBA_CHEAT_PRO_ACTION_REPLAY));
886 assert_true(set->addLine(set, "00300006 00000061", GBA_CHEAT_PRO_ACTION_REPLAY));
887 assert_true(set->addLine(set, "00300007 00000071", GBA_CHEAT_PRO_ACTION_REPLAY));
888 assert_true(set->addLine(set, "00300008 00000081", GBA_CHEAT_PRO_ACTION_REPLAY));
889 assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
890 assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
891 assert_true(set->addLine(set, "08300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
892 assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
893 assert_true(set->addLine(set, "00300005 00000052", GBA_CHEAT_PRO_ACTION_REPLAY));
894 assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
895 assert_true(set->addLine(set, "00300006 00000062", GBA_CHEAT_PRO_ACTION_REPLAY));
896 assert_true(set->addLine(set, "08300002 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
897 assert_true(set->addLine(set, "00300007 00000072", GBA_CHEAT_PRO_ACTION_REPLAY));
898 assert_true(set->addLine(set, "00300008 00000082", GBA_CHEAT_PRO_ACTION_REPLAY));
899 assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
900 assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
901
902 core->reset(core);
903 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
904 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
905 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
906 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
907 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
908 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
909 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0);
910 assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0);
911 assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0);
912
913 mCheatRefresh(device, set);
914 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
915 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
916 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
917 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
918 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
919 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
920 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x61);
921 assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
922 assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x81);
923
924 core->reset(core);
925 core->rawWrite8(core, 0x03000000, -1, 0x1);
926 mCheatRefresh(device, set);
927 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
928 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
929 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
930 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
931 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
932 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
933 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
934 assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x72);
935 assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x82);
936
937 core->reset(core);
938 core->rawWrite8(core, 0x03000001, -1, 0x1);
939 mCheatRefresh(device, set);
940 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
941 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
942 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
943 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
944 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
945 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
946 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x61);
947 assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
948 assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x81);
949
950 core->reset(core);
951 core->rawWrite8(core, 0x03000002, -1, 0x1);
952 mCheatRefresh(device, set);
953 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
954 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
955 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x1);
956 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
957 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
958 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
959 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x61);
960 assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
961 assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x81);
962
963 core->reset(core);
964 core->rawWrite8(core, 0x03000000, -1, 0x1);
965 core->rawWrite8(core, 0x03000001, -1, 0x1);
966 mCheatRefresh(device, set);
967 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
968 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
969 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
970 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
971 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
972 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
973 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
974 assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x72);
975 assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x82);
976
977 core->reset(core);
978 core->rawWrite8(core, 0x03000000, -1, 0x1);
979 core->rawWrite8(core, 0x03000002, -1, 0x1);
980 mCheatRefresh(device, set);
981 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
982 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
983 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x1);
984 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
985 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
986 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
987 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
988 assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
989 assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x82);
990
991 core->reset(core);
992 core->rawWrite8(core, 0x03000001, -1, 0x1);
993 core->rawWrite8(core, 0x03000002, -1, 0x1);
994 mCheatRefresh(device, set);
995 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
996 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
997 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x1);
998 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
999 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
1000 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
1001 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x61);
1002 assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
1003 assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x81);
1004
1005 core->reset(core);
1006 core->rawWrite8(core, 0x03000000, -1, 0x1);
1007 core->rawWrite8(core, 0x03000001, -1, 0x1);
1008 core->rawWrite8(core, 0x03000002, -1, 0x1);
1009 mCheatRefresh(device, set);
1010 assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
1011 assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
1012 assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x1);
1013 assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
1014 assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
1015 assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
1016 assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
1017 assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
1018 assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x82);
1019}
1020
1021M_TEST_SUITE_DEFINE_SETUP_TEARDOWN(GBACheats,
1022 cmocka_unit_test(createSet),
1023 cmocka_unit_test(addRawPARv3),
1024 cmocka_unit_test(doPARv3Assign),
1025 cmocka_unit_test(doPARv3Slide1),
1026 cmocka_unit_test(doPARv3Slide2),
1027 cmocka_unit_test(doPARv3Slide4),
1028 cmocka_unit_test(doPARv3If1),
1029 cmocka_unit_test(doPARv3If1x1),
1030 cmocka_unit_test(doPARv3If2),
1031 cmocka_unit_test(doPARv3If2x2),
1032 cmocka_unit_test(doPARv3If2Contain1),
1033 cmocka_unit_test(doPARv3IfX),
1034 cmocka_unit_test(doPARv3IfXxX),
1035 cmocka_unit_test(doPARv3IfXElse),
1036 cmocka_unit_test(doPARv3IfXElsexX),
1037 cmocka_unit_test(doPARv3IfXElsexXElse),
1038 cmocka_unit_test(doPARv3IfXContain1),
1039 cmocka_unit_test(doPARv3IfXContain1Else),
1040 cmocka_unit_test(doPARv3IfXElseContain1),
1041 cmocka_unit_test(doPARv3IfXContain1ElseContain1))