all repos — mgba @ 8622ba7ed0d556e2c0a4c8e7c9aa8b349ace4046

mGBA Game Boy Advance Emulator

src/gb/gb.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_H
 7#define GB_H
 8
 9#include "util/common.h"
10
11#include "lr35902/lr35902.h"
12
13#include "gb/memory.h"
14#include "gb/video.h"
15
16extern const uint32_t DMG_LR35902_FREQUENCY;
17extern const uint32_t CGB_LR35902_FREQUENCY;
18extern const uint32_t SGB_LR35902_FREQUENCY;
19
20// TODO: Prefix GBAIRQ
21enum GBIRQ {
22	GB_IRQ_VBLANK = 0x0,
23	GB_IRQ_LCDSTAT = 0x1,
24	GB_IRQ_TIMER = 0x2,
25	GB_IRQ_SIO = 0x3,
26	GB_IRQ_KEYPAD = 0x4,
27};
28
29enum GBIRQVector {
30	GB_VECTOR_VBLANK = 0x40,
31	GB_VECTOR_LCDSTAT = 0x48,
32	GB_VECTOR_TIMER = 0x50,
33	GB_VECTOR_SIO = 0x58,
34	GB_VECTOR_KEYPAD = 0x60,
35};
36
37struct GB {
38	struct LR35902Component d;
39
40	struct LR35902Core* cpu;
41	struct GBMemory memory;
42	struct GBVideo video;
43
44	int* keySource;
45
46	void* pristineRom;
47	size_t pristineRomSize;
48	size_t yankedRomSize;
49	uint32_t romCrc32;
50	struct VFile* romVf;
51
52	const char* activeFile;
53};
54
55void GBCreate(struct GB* gb);
56void GBDestroy(struct GB* gb);
57
58void GBReset(struct LR35902Core* cpu);
59
60void GBUpdateIRQs(struct GB* gb);
61void GBHalt(struct GB* gb);
62void GBStop(struct GB* gb);
63
64struct VFile;
65bool GBLoadROM(struct GB* gb, struct VFile* vf, struct VFile* sav, const char* fname);
66void GBYankROM(struct GB* gb);
67void GBUnloadROM(struct GB* gb);
68
69struct Patch;
70void GBApplyPatch(struct GB* gb, struct Patch* patch);
71
72bool GBIsROM(struct VFile* vf);
73
74void GBFrameStarted(struct GB* gb);
75void GBFrameEnded(struct GB* gb);
76
77#endif