src/platform/qt/GBOverride.cpp (view raw)
1/* Copyright (c) 2013-2016 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 "GBOverride.h"
7
8#include <mgba/core/core.h>
9#include <mgba/internal/gb/gb.h>
10#include <mgba-util/crc32.h>
11
12using namespace QGBA;
13
14void GBOverride::apply(struct mCore* core) {
15 if (core->platform(core) != mPLATFORM_GB) {
16 return;
17 }
18 GBOverrideApply(static_cast<GB*>(core->board), &override);
19}
20
21void GBOverride::identify(const struct mCore* core) {
22 if (core->platform(core) != mPLATFORM_GB) {
23 return;
24 }
25 GB* gb = static_cast<GB*>(core->board);
26 if (!gb->memory.rom || gb->memory.romSize < sizeof(struct GBCartridge) + 0x100) {
27 return;
28 }
29 override.headerCrc32 = doCrc32(&gb->memory.rom[0x100], sizeof(struct GBCartridge));
30}
31
32void GBOverride::save(struct Configuration* config) const {
33 GBOverrideSave(config, &override);
34}