-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpleCPU.h
70 lines (61 loc) · 1.47 KB
/
simpleCPU.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
#pragma warning(disable:4996)
#ifndef SIMPLE_CPU_H
#define SIMPLE_CPU_H
#include "types.h"
#include "Mappers/Mapper.h"
#ifdef _WIN32
#include <windows.h>
#endif
#define PAL_CPU_CLOCK_DIVIDER 16
#define NTSC_CPU_CLOCK_DIVIDER 12
#define STACK_END 0x100
#define N_FLAG 0b10000000
#define V_FLAG 0b01000000
#define __FLAG 0b00100000
#define B_FLAG 0b00010000
#define D_FLAG 0b00001000
#define I_FLAG 0b00000100
#define Z_FLAG 0b00000010
#define C_FLAG 0b00000001
#define NEG_NZ_FLAGS 0b01111101
#define NEG_CV_FLAGS 0b10111110
#define SR_RST 0b00100100 // IGNORED(_), B and INTERRUPT are set to 1
extern u8 ram[];
enum VideoModes {
PAL,
NTSC
};
#define VIDEO_MODE NTSC
static const u8 _6502InstBaseCycles[256] = {
7,6,2,8,3,3,5,5,3,2,2,2,4,4,6,6,
2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,
6,6,2,8,3,3,5,5,4,2,2,2,4,4,6,6,
2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,
6,6,2,8,3,3,5,5,3,2,2,2,3,4,6,6,
2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,
6,6,2,8,3,3,5,5,4,2,2,2,5,4,6,6,
2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,
2,6,2,6,3,3,3,3,2,2,2,2,4,4,4,4,
2,6,2,6,4,4,4,4,2,5,2,5,5,5,5,5,
2,6,2,6,3,3,3,3,2,2,2,2,4,4,4,4,
2,5,2,5,4,4,4,4,2,4,2,5,4,4,4,4,
2,6,2,8,3,3,5,5,2,2,2,2,4,4,6,6,
2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7,
2,6,2,8,3,3,5,5,2,2,2,2,4,4,6,6,
2,5,2,8,4,4,6,6,2,4,2,7,4,4,7,7
};
class Cpu {
public:
Cpu();
void afficher();
};
u8 rd(u16 at);
void _nmi();
void pressKey(u16 pressed);
void specialCom();
void addCycle();
void manualIRQ();
void _rst();
u64 getTotalCycles();
u32 getCycles();
#endif