include/mgba/gb/interface.h (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#ifndef GB_INTERFACE_H
7#define GB_INTERFACE_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13enum GBModel {
14 GB_MODEL_AUTODETECT = 0xFF,
15 GB_MODEL_DMG = 0x00,
16 GB_MODEL_SGB = 0x20,
17 GB_MODEL_MGB = 0x40,
18 GB_MODEL_SGB2 = 0x60,
19 GB_MODEL_CGB = 0x80,
20 GB_MODEL_AGB = 0xC0
21};
22
23enum GBMemoryBankControllerType {
24 GB_MBC_AUTODETECT = -1,
25 GB_MBC_NONE = 0,
26 GB_MBC1 = 1,
27 GB_MBC2 = 2,
28 GB_MBC3 = 3,
29 GB_MBC5 = 5,
30 GB_MBC6 = 6,
31 GB_MBC7 = 7,
32 GB_MMM01 = 0x10,
33 GB_HuC1 = 0x11,
34 GB_HuC3 = 0x12,
35 GB_POCKETCAM = 0x13,
36 GB_TAMA5 = 0x14,
37 GB_MBC3_RTC = 0x103,
38 GB_MBC5_RUMBLE = 0x105,
39 GB_UNL_WISDOM_TREE = 0x200,
40 GB_UNL_PKJD = 0x203,
41 GB_UNL_BBD = 0x220, // Also used as a mask for MBCs that need special read behavior
42 GB_UNL_HITEK = 0x221,
43};
44
45struct GBSIODriver {
46 struct GBSIO* p;
47
48 bool (*init)(struct GBSIODriver* driver);
49 void (*deinit)(struct GBSIODriver* driver);
50 void (*writeSB)(struct GBSIODriver* driver, uint8_t value);
51 uint8_t (*writeSC)(struct GBSIODriver* driver, uint8_t value);
52};
53
54struct VFile;
55
56bool GBIsROM(struct VFile* vf);
57bool GBIsBIOS(struct VFile* vf);
58
59enum GBModel GBNameToModel(const char*);
60const char* GBModelToName(enum GBModel);
61
62int GBValidModels(const uint8_t* bank0);
63
64CXX_GUARD_END
65
66#endif