-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcpu.h
More file actions
49 lines (41 loc) · 806 Bytes
/
Copy pathcpu.h
File metadata and controls
49 lines (41 loc) · 806 Bytes
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
#ifndef GBC_CPU_H
#define GBC_CPU_H
#include "types.h"
// 16 bit register
union reg {
u16 v;
struct {
u8 lo;
u8 hi;
};
};
struct CpuState {
// registers
reg bc, de, hl;
u8 f;
u8 a;
u16 sp, pc;
bool halt;
uint64_t cycleCount;
uint64_t divOffset;
u8 ime;
u32 timSubcount;
};
// external interface:
extern CpuState globalState;
void resetCpu(); // reinitialize the cpu
u32 cpuStep(); // step 1 instruction, returns number of clock cycles elapsed
bool getZeroFlag();
bool getSubtractFlag();
bool getHalfCarryFlag();
bool getCarryFlag();
void setZeroFlag();
void clearZeroFlag();
void setSubtractFlag();
void clearSubtractFlag();
void setHalfCarryFlag();
void clearHalfCarryFlag();
void setCarryFlag();
void clearCarryFlag();
void clearAllFlags();
#endif //GBC_CPU_H