all repos — mgba @ 4d6b6fb3df0a7bc4083e71816a7c8fde045ed941

mGBA Game Boy Advance Emulator

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}
 425
 426M_TEST_DEFINE(doPARv3IfXxX) {
 427	struct mCore* core = *state;
 428	struct mCheatDevice* device = core->cheatDevice(core);
 429	assert_non_null(device);
 430	struct mCheatSet* set = device->createSet(device, NULL);
 431	assert_non_null(set);
 432	GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
 433	assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
 434	assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
 435	assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
 436	assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 437	assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
 438	assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 439	assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
 440	assert_true(set->addLine(set, "88300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 441	assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
 442	assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 443	assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
 444
 445	core->reset(core);
 446	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
 447	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 448	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 449	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
 450	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
 451
 452	mCheatRefresh(device, set);
 453	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 454	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 455	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 456	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 457	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 458
 459	core->reset(core);
 460	core->rawWrite8(core, 0x03000000, -1, 0x1);
 461	mCheatRefresh(device, set);
 462	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 463	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 464	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 465	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 466	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 467
 468	core->reset(core);
 469	core->rawWrite8(core, 0x03000001, -1, 0x1);
 470	mCheatRefresh(device, set);
 471	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 472	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 473	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 474	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 475	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 476
 477	core->reset(core);
 478	core->rawWrite8(core, 0x03000000, -1, 0x1);
 479	core->rawWrite8(core, 0x03000001, -1, 0x1);
 480	mCheatRefresh(device, set);
 481	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 482	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 483	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 484	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 485	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 486}
 487
 488M_TEST_DEFINE(doPARv3IfXElse) {
 489	struct mCore* core = *state;
 490	struct mCheatDevice* device = core->cheatDevice(core);
 491	assert_non_null(device);
 492	struct mCheatSet* set = device->createSet(device, NULL);
 493	assert_non_null(set);
 494	GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
 495	assert_true(set->addLine(set, "00300001 00000011", GBA_CHEAT_PRO_ACTION_REPLAY));
 496	assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
 497	assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 498	assert_true(set->addLine(set, "00300001 00000012", GBA_CHEAT_PRO_ACTION_REPLAY));
 499	assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 500	assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
 501	assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 502	assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
 503
 504	core->reset(core);
 505	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
 506	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 507	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 508
 509	mCheatRefresh(device, set);
 510	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 511	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x12);
 512	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 513
 514	core->reset(core);
 515	core->rawWrite8(core, 0x03000000, -1, 0x1);
 516	mCheatRefresh(device, set);
 517	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 518	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x11);
 519	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 520}
 521
 522M_TEST_DEFINE(doPARv3IfXElsexX) {
 523	struct mCore* core = *state;
 524	struct mCheatDevice* device = core->cheatDevice(core);
 525	assert_non_null(device);
 526	struct mCheatSet* set = device->createSet(device, NULL);
 527	assert_non_null(set);
 528	GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
 529	assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
 530	assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
 531	assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
 532	assert_true(set->addLine(set, "00300005 00000051", GBA_CHEAT_PRO_ACTION_REPLAY));
 533	assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 534	assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
 535	assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 536	assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
 537	assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 538	assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
 539	assert_true(set->addLine(set, "88300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 540	assert_true(set->addLine(set, "00300005 00000052", GBA_CHEAT_PRO_ACTION_REPLAY));
 541	assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 542	assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
 543
 544	core->reset(core);
 545	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
 546	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 547	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 548	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
 549	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
 550	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
 551
 552	mCheatRefresh(device, set);
 553	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 554	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 555	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 556	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 557	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 558	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 559
 560	core->reset(core);
 561	core->rawWrite8(core, 0x03000000, -1, 0x1);
 562	mCheatRefresh(device, set);
 563	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 564	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 565	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 566	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 567	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 568	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 569
 570	core->reset(core);
 571	core->rawWrite8(core, 0x03000001, -1, 0x1);
 572	mCheatRefresh(device, set);
 573	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 574	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 575	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 576	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 577	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 578	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
 579
 580	core->reset(core);
 581	core->rawWrite8(core, 0x03000000, -1, 0x1);
 582	core->rawWrite8(core, 0x03000001, -1, 0x1);
 583	mCheatRefresh(device, set);
 584	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 585	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 586	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 587	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 588	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 589	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
 590}
 591
 592M_TEST_DEFINE(doPARv3IfXElsexXElse) {
 593	struct mCore* core = *state;
 594	struct mCheatDevice* device = core->cheatDevice(core);
 595	assert_non_null(device);
 596	struct mCheatSet* set = device->createSet(device, NULL);
 597	assert_non_null(set);
 598	GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
 599	assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
 600	assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
 601	assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
 602	assert_true(set->addLine(set, "00300005 00000051", GBA_CHEAT_PRO_ACTION_REPLAY));
 603	assert_true(set->addLine(set, "00300006 00000061", GBA_CHEAT_PRO_ACTION_REPLAY));
 604	assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 605	assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
 606	assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 607	assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
 608	assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 609	assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
 610	assert_true(set->addLine(set, "88300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 611	assert_true(set->addLine(set, "00300005 00000052", GBA_CHEAT_PRO_ACTION_REPLAY));
 612	assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 613	assert_true(set->addLine(set, "00300006 00000062", GBA_CHEAT_PRO_ACTION_REPLAY));
 614	assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 615	assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
 616
 617	core->reset(core);
 618	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
 619	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 620	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 621	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
 622	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
 623	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
 624	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0);
 625
 626	mCheatRefresh(device, set);
 627	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 628	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 629	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 630	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 631	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 632	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 633
 634	core->reset(core);
 635	core->rawWrite8(core, 0x03000000, -1, 0x1);
 636	mCheatRefresh(device, set);
 637	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 638	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 639	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 640	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 641	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 642	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 643	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x61);
 644
 645	core->reset(core);
 646	core->rawWrite8(core, 0x03000001, -1, 0x1);
 647	mCheatRefresh(device, set);
 648	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 649	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 650	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 651	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 652	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 653	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
 654	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
 655
 656	core->reset(core);
 657	core->rawWrite8(core, 0x03000000, -1, 0x1);
 658	core->rawWrite8(core, 0x03000001, -1, 0x1);
 659	mCheatRefresh(device, set);
 660	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 661	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 662	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 663	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 664	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 665	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
 666	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
 667}
 668
 669M_TEST_DEFINE(doPARv3IfXContain1) {
 670	struct mCore* core = *state;
 671	struct mCheatDevice* device = core->cheatDevice(core);
 672	assert_non_null(device);
 673	struct mCheatSet* set = device->createSet(device, NULL);
 674	assert_non_null(set);
 675	GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
 676	assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
 677	assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
 678	assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
 679	assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 680	assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
 681	assert_true(set->addLine(set, "08300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 682	assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
 683	assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
 684	assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 685	assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
 686
 687	core->reset(core);
 688	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
 689	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 690	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 691	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
 692	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
 693
 694	mCheatRefresh(device, set);
 695	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 696	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 697	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 698	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 699	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 700
 701	core->reset(core);
 702	core->rawWrite8(core, 0x03000000, -1, 0x1);
 703	mCheatRefresh(device, set);
 704	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 705	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 706	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 707	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 708	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 709
 710	core->reset(core);
 711	core->rawWrite8(core, 0x03000001, -1, 0x1);
 712	mCheatRefresh(device, set);
 713	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 714	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 715	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 716	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 717	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 718
 719	core->reset(core);
 720	core->rawWrite8(core, 0x03000000, -1, 0x1);
 721	core->rawWrite8(core, 0x03000001, -1, 0x1);
 722	mCheatRefresh(device, set);
 723	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 724	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 725	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 726	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 727	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 728}
 729
 730M_TEST_DEFINE(doPARv3IfXContain1Else) {
 731	struct mCore* core = *state;
 732	struct mCheatDevice* device = core->cheatDevice(core);
 733	assert_non_null(device);
 734	struct mCheatSet* set = device->createSet(device, NULL);
 735	assert_non_null(set);
 736	GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
 737	assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
 738	assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
 739	assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
 740	assert_true(set->addLine(set, "00300005 00000051", GBA_CHEAT_PRO_ACTION_REPLAY));
 741	assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 742	assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
 743	assert_true(set->addLine(set, "08300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 744	assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
 745	assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
 746	assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 747	assert_true(set->addLine(set, "00300005 00000052", GBA_CHEAT_PRO_ACTION_REPLAY));
 748	assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 749	assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
 750
 751	core->reset(core);
 752	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
 753	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 754	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 755	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
 756	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
 757	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
 758
 759	mCheatRefresh(device, set);
 760	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 761	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 762	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 763	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 764	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 765	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
 766
 767	core->reset(core);
 768	core->rawWrite8(core, 0x03000000, -1, 0x1);
 769	mCheatRefresh(device, set);
 770	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 771	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 772	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 773	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 774	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 775	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 776
 777	core->reset(core);
 778	core->rawWrite8(core, 0x03000001, -1, 0x1);
 779	mCheatRefresh(device, set);
 780	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 781	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 782	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 783	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 784	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 785	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
 786
 787	core->reset(core);
 788	core->rawWrite8(core, 0x03000000, -1, 0x1);
 789	core->rawWrite8(core, 0x03000001, -1, 0x1);
 790	mCheatRefresh(device, set);
 791	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 792	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 793	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 794	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 795	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 796	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 797}
 798
 799M_TEST_DEFINE(doPARv3IfXElseContain1) {
 800	struct mCore* core = *state;
 801	struct mCheatDevice* device = core->cheatDevice(core);
 802	assert_non_null(device);
 803	struct mCheatSet* set = device->createSet(device, NULL);
 804	assert_non_null(set);
 805	GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
 806	assert_true(set->addLine(set, "00300002 00000021", GBA_CHEAT_PRO_ACTION_REPLAY));
 807	assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
 808	assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
 809	assert_true(set->addLine(set, "00300005 00000051", GBA_CHEAT_PRO_ACTION_REPLAY));
 810	assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 811	assert_true(set->addLine(set, "00300002 00000022", GBA_CHEAT_PRO_ACTION_REPLAY));
 812	assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 813	assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
 814	assert_true(set->addLine(set, "08300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 815	assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
 816	assert_true(set->addLine(set, "00300005 00000052", GBA_CHEAT_PRO_ACTION_REPLAY));
 817	assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 818	assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
 819
 820	core->reset(core);
 821	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
 822	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 823	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 824	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
 825	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
 826	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
 827
 828	mCheatRefresh(device, set);
 829	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 830	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 831	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 832	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 833	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 834	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
 835
 836	core->reset(core);
 837	core->rawWrite8(core, 0x03000000, -1, 0x1);
 838	mCheatRefresh(device, set);
 839	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 840	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 841	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 842	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 843	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 844	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 845
 846	core->reset(core);
 847	core->rawWrite8(core, 0x03000001, -1, 0x1);
 848	mCheatRefresh(device, set);
 849	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 850	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 851	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x22);
 852	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 853	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 854	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
 855
 856	core->reset(core);
 857	core->rawWrite8(core, 0x03000000, -1, 0x1);
 858	core->rawWrite8(core, 0x03000001, -1, 0x1);
 859	mCheatRefresh(device, set);
 860	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 861	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 862	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x21);
 863	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 864	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 865	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 866}
 867
 868M_TEST_DEFINE(doPARv3IfXContain1ElseContain1) {
 869	struct mCore* core = *state;
 870	struct mCheatDevice* device = core->cheatDevice(core);
 871	assert_non_null(device);
 872	struct mCheatSet* set = device->createSet(device, NULL);
 873	assert_non_null(set);
 874	GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW);
 875	assert_true(set->addLine(set, "00300003 00000031", GBA_CHEAT_PRO_ACTION_REPLAY));
 876	assert_true(set->addLine(set, "00300004 00000041", GBA_CHEAT_PRO_ACTION_REPLAY));
 877	assert_true(set->addLine(set, "00300005 00000051", GBA_CHEAT_PRO_ACTION_REPLAY));
 878	assert_true(set->addLine(set, "00300006 00000061", GBA_CHEAT_PRO_ACTION_REPLAY));
 879	assert_true(set->addLine(set, "00300007 00000071", GBA_CHEAT_PRO_ACTION_REPLAY));
 880	assert_true(set->addLine(set, "00300008 00000081", GBA_CHEAT_PRO_ACTION_REPLAY));
 881	assert_true(set->addLine(set, "88300000 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 882	assert_true(set->addLine(set, "00300003 00000032", GBA_CHEAT_PRO_ACTION_REPLAY));
 883	assert_true(set->addLine(set, "08300001 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 884	assert_true(set->addLine(set, "00300004 00000042", GBA_CHEAT_PRO_ACTION_REPLAY));
 885	assert_true(set->addLine(set, "00300005 00000052", GBA_CHEAT_PRO_ACTION_REPLAY));
 886	assert_true(set->addLine(set, "00000000 60000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 887	assert_true(set->addLine(set, "00300006 00000062", GBA_CHEAT_PRO_ACTION_REPLAY));
 888	assert_true(set->addLine(set, "08300002 00000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 889	assert_true(set->addLine(set, "00300007 00000072", GBA_CHEAT_PRO_ACTION_REPLAY));
 890	assert_true(set->addLine(set, "00300008 00000082", GBA_CHEAT_PRO_ACTION_REPLAY));
 891	assert_true(set->addLine(set, "00000000 40000000", GBA_CHEAT_PRO_ACTION_REPLAY));
 892	assert_true(set->addLine(set, "00300000 00000001", GBA_CHEAT_PRO_ACTION_REPLAY));
 893
 894	core->reset(core);
 895	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0);
 896	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 897	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 898	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0);
 899	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0);
 900	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0);
 901	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0);
 902	assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0);
 903	assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0);
 904
 905	mCheatRefresh(device, set);
 906	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 907	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 908	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 909	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 910	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 911	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 912	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x61);
 913	assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
 914	assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x81);
 915
 916	core->reset(core);
 917	core->rawWrite8(core, 0x03000000, -1, 0x1);
 918	mCheatRefresh(device, set);
 919	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 920	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 921	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 922	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 923	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 924	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
 925	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
 926	assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x72);
 927	assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x82);
 928
 929	core->reset(core);
 930	core->rawWrite8(core, 0x03000001, -1, 0x1);
 931	mCheatRefresh(device, set);
 932	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 933	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 934	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 935	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 936	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 937	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 938	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x61);
 939	assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
 940	assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x81);
 941
 942	core->reset(core);
 943	core->rawWrite8(core, 0x03000002, -1, 0x1);
 944	mCheatRefresh(device, set);
 945	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 946	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 947	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x1);
 948	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 949	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x42);
 950	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 951	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x61);
 952	assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
 953	assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x81);
 954
 955	core->reset(core);
 956	core->rawWrite8(core, 0x03000000, -1, 0x1);
 957	core->rawWrite8(core, 0x03000001, -1, 0x1);
 958	mCheatRefresh(device, set);
 959	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 960	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 961	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0);
 962	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 963	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 964	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
 965	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
 966	assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x72);
 967	assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x82);
 968
 969	core->reset(core);
 970	core->rawWrite8(core, 0x03000000, -1, 0x1);
 971	core->rawWrite8(core, 0x03000002, -1, 0x1);
 972	mCheatRefresh(device, set);
 973	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 974	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0);
 975	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x1);
 976	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
 977	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 978	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
 979	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
 980	assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
 981	assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x82);
 982
 983	core->reset(core);
 984	core->rawWrite8(core, 0x03000001, -1, 0x1);
 985	core->rawWrite8(core, 0x03000002, -1, 0x1);
 986	mCheatRefresh(device, set);
 987	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
 988	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
 989	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x1);
 990	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x32);
 991	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
 992	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x52);
 993	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x61);
 994	assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
 995	assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x81);
 996
 997	core->reset(core);
 998	core->rawWrite8(core, 0x03000000, -1, 0x1);
 999	core->rawWrite8(core, 0x03000001, -1, 0x1);
1000	core->rawWrite8(core, 0x03000002, -1, 0x1);
1001	mCheatRefresh(device, set);
1002	assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0x1);
1003	assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0x1);
1004	assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0x1);
1005	assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0x31);
1006	assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0x41);
1007	assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0x51);
1008	assert_int_equal(core->rawRead8(core, 0x03000006, -1), 0x62);
1009	assert_int_equal(core->rawRead8(core, 0x03000007, -1), 0x71);
1010	assert_int_equal(core->rawRead8(core, 0x03000008, -1), 0x82);
1011}
1012
1013M_TEST_SUITE_DEFINE_SETUP_TEARDOWN(GBACheats,
1014	cmocka_unit_test(createSet),
1015	cmocka_unit_test(addRawPARv3),
1016	cmocka_unit_test(doPARv3Assign),
1017	cmocka_unit_test(doPARv3Slide1),
1018	cmocka_unit_test(doPARv3Slide2),
1019	cmocka_unit_test(doPARv3Slide4),
1020	cmocka_unit_test(doPARv3If1),
1021	cmocka_unit_test(doPARv3If1x1),
1022	cmocka_unit_test(doPARv3If2),
1023	cmocka_unit_test(doPARv3If2x2),
1024	cmocka_unit_test(doPARv3If2Contain1),
1025	cmocka_unit_test(doPARv3IfX),
1026	cmocka_unit_test(doPARv3IfXxX),
1027	cmocka_unit_test(doPARv3IfXElse),
1028	cmocka_unit_test(doPARv3IfXElsexX),
1029	cmocka_unit_test(doPARv3IfXElsexXElse),
1030	cmocka_unit_test(doPARv3IfXContain1),
1031	cmocka_unit_test(doPARv3IfXContain1Else),
1032	cmocka_unit_test(doPARv3IfXElseContain1),
1033	cmocka_unit_test(doPARv3IfXContain1ElseContain1))