-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessor.h
73 lines (66 loc) · 1.31 KB
/
processor.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
#ifndef TRTLE_PROCESSOR_H
#define TRTLE_PROCESSOR_H
#include <stdbool.h>
#include <stdint.h>
#define PROCESSOR_CLOCK_SPEED (4194304)
typedef struct GameBoy GameBoy;
typedef struct Processor {
union {
uint16_t af;
struct {
#ifdef __ORDER_LITTLE_ENDIAN__
uint8_t f;
uint8_t a;
#else
uint8_t a;
uint8_t f;
#endif
};
};
union {
uint16_t bc;
struct {
#ifdef __ORDER_LITTLE_ENDIAN__
uint8_t c;
uint8_t b;
#else
uint8_t b;
uint8_t c;
#endif
};
};
union {
uint16_t de;
struct {
#ifdef __ORDER_LITTLE_ENDIAN__
uint8_t e;
uint8_t d;
#else
uint8_t d;
uint8_t e;
#endif
};
};
union {
uint16_t hl;
struct {
#ifdef __ORDER_LITTLE_ENDIAN__
uint8_t l;
uint8_t h;
#else
uint8_t h;
uint8_t l;
#endif
};
};
uint16_t sp;
uint16_t pc;
uint8_t ram[8192];
uint8_t hram[0x7F];
bool halt_mode;
bool skip_pc_increment;
bool skip_next_interrupt;
} Processor;
void processor_initialize(Processor * const p, bool skip_bootrom);
void processor_process_instruction(GameBoy * const gb);
#endif /* !TRTLE_PROCESSOR_H */