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