-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpu.h
76 lines (62 loc) · 1.03 KB
/
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
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
73
74
75
76
#ifndef CPU_H
#define CPU_H
#include "instructions.h"
#define FLAG_CARRY (1 << 4)
#define FLAG_HALF_CARRY (1 << 5)
#define FLAG_NEGATIVE (1 << 6)
#define FLAG_ZERO (1 << 7)
#define INT_VBLANK (1 << 0)
#define FLAGS_ISSET(regf, x) (regf & (x))
#define FLAGS_SET(regf, x) (regf |= (x))
#define FLAGS_CLEAR(regf, x) (regf &= ~(x))
struct registers {
struct {
union {
struct {
unsigned char f;
unsigned char a;
};
unsigned short af;
};
};
struct {
union {
struct {
unsigned char c;
unsigned char b;
};
unsigned short bc;
};
};
struct {
union {
struct {
unsigned char e;
unsigned char d;
};
unsigned short de;
};
};
struct {
union {
struct {
unsigned char l;
unsigned char h;
};
unsigned short hl;
};
};
unsigned short sp;
unsigned short pc;
};
struct interrupts {
unsigned char master;
unsigned char incoming_interrupts;
};
struct cpu {
struct registers registers;
struct interrupts interrupts;
};
struct gbmu;
int cpu_step(struct gbmu *gbmu);
#endif