-
Notifications
You must be signed in to change notification settings - Fork 4
/
gb.h
72 lines (62 loc) · 1.77 KB
/
gb.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef _GB_GB_H_
#define _GB_GB_H_
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <semaphore.h>
struct gb;
#include "sync.h"
#include "irq.h"
#include "cpu.h"
#include "memory.h"
#include "rtc.h"
#include "cart.h"
#include "gpu.h"
#include "input.h"
#include "dma.h"
#include "hdma.h"
#include "timer.h"
#include "spu.h"
#include "frontend.h"
/* DMG CPU frequency. Super GameBoy runs slightly faster (4.295454MHz). */
#define GB_CPU_FREQ_HZ 4194304U
struct gb {
/* True if we're emulating a GBC, false if we're emulating a DMG */
bool gbc;
/* True if a speed switch has been requested. It will take effect when a
* STOP operation is executed */
bool speed_switch_pending;
/* True if the GBC is running in double-speed mode */
bool double_speed;
/* Counter keeping track of how many CPU cycles have elapsed since an
* arbitrary point in time. Used to synchronize the other devices. */
int32_t timestamp;
/* Set by the frontend when the user requested that the emulation stops */
bool quit;
struct gb_irq irq;
struct gb_frontend frontend;
struct gb_sync sync;
struct gb_cpu cpu;
struct gb_cart cart;
struct gb_gpu gpu;
struct gb_input input;
struct gb_dma dma;
struct gb_hdma hdma;
struct gb_timer timer;
struct gb_spu spu;
/* Internal RAM: 8KiB on DMG, 32 KiB on GBC */
uint8_t iram[0x8000];
/* Always 1 on DMG, 1-7 on GBC */
uint8_t iram_high_bank;
/* Zero-page RAM */
uint8_t zram[0x7f];
/* Video RAM: 8KiB on DMG, 16KiB on GBC */
uint8_t vram[0x4000];
/* Always false on DMG */
bool vram_high_bank;
};
static inline void die(void) {
exit(EXIT_FAILURE);
}
#endif /* _GB_GB_H_ */