-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpu.h
45 lines (40 loc) · 826 Bytes
/
cpu.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
/*
this is a declaration of the CPU emulator for the game boy
*/
#include <stdint.h>
// copied from SameBoy
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define GB_BIG_ENDIAN
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define GB_LITTLE_ENDIAN
#else
#error Unable to detect endianess
#endif
union regs{
uint16_t registers[5];
struct {
uint16_t af,
bc,
de,
hl,
sp,
pc;
};
struct {
#ifdef GB_BIG_ENDIAN
uint8_t a, f,
b, c,
d, e,
h, l;
#else
uint8_t f, a,
c, b,
e, d,
l, h;
#endif
};
};
struct SM83 {
union regs regs;
uint8_t mem[1<<16]; // assume the whole memory map is RAM for simplicity
};