-
Notifications
You must be signed in to change notification settings - Fork 0
/
CPU.h
127 lines (114 loc) · 3.62 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#pragma once
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <memory>
using _BIT = bool;
using WORD = unsigned short;
using BYTE = unsigned char;
struct Memory {
BYTE Read(WORD Address);
void Write(WORD ADDRESS, BYTE Data);
std::vector<BYTE> data; // needs to hold 64KB of data
void init();
};
struct CPU {
WORD PC = 0xFFFC;
BYTE SP = (BYTE) 0;
BYTE A, X, Y;
// _BIT CF, ZF, ID, DM, BC, OF, NF, _BRK;
_BIT N, V, BR, B, D, I, Z, C;
int Cycle = 0;
int Ticks = 0;
std::map<int, std::string> Matrix;
void Tick(int n);
void Reset(std::unique_ptr<Memory>& mem);
void Log();
void Log(std::string s);
std::string Decode(BYTE opcode);
void Step(std::unique_ptr<Memory>& mem);
void Start(std::unique_ptr<Memory>& mem);
void FillMatrix();
std::unique_ptr<Memory> mem;
// operations
void ADC(std::unique_ptr<Memory>& mem);
void AND(std::unique_ptr<Memory>& mem);
void ASL(std::unique_ptr<Memory>& mem);
void BCC(std::unique_ptr<Memory>& mem);
void BCS(std::unique_ptr<Memory>& mem);
void BEQ(std::unique_ptr<Memory>& mem);
void BIT(std::unique_ptr<Memory>& mem);
void BMI(std::unique_ptr<Memory>& mem);
void BNE(std::unique_ptr<Memory>& mem);
void BPL(std::unique_ptr<Memory>& mem);
void BRK(std::unique_ptr<Memory>& mem);
void BVC(std::unique_ptr<Memory>& mem);
void BVS(std::unique_ptr<Memory>& mem);
void CLC(std::unique_ptr<Memory>& mem);
void CLD(std::unique_ptr<Memory>& mem);
void CLI(std::unique_ptr<Memory>& mem);
void CLV(std::unique_ptr<Memory>& mem);
void CMP(std::unique_ptr<Memory>& mem);
void CPX(std::unique_ptr<Memory>& mem);
void CPY(std::unique_ptr<Memory>& mem);
void DEC(std::unique_ptr<Memory>& mem);
void DEX(std::unique_ptr<Memory>& mem);
void DEY(std::unique_ptr<Memory>& mem);
void EOR(std::unique_ptr<Memory>& mem);
void INC(std::unique_ptr<Memory>& mem);
void INX(std::unique_ptr<Memory>& mem);
void INY(std::unique_ptr<Memory>& mem);
void JMP(std::unique_ptr<Memory>& mem);
void JSR(std::unique_ptr<Memory>& mem);
void LDA(std::unique_ptr<Memory>& mem);
void LDX(std::unique_ptr<Memory>& mem);
void LDY(std::unique_ptr<Memory>& mem);
void LSR(std::unique_ptr<Memory>& mem);
void NOP(std::unique_ptr<Memory>& mem);
void ORA(std::unique_ptr<Memory>& mem);
void PHA(std::unique_ptr<Memory>& mem);
void PHP(std::unique_ptr<Memory>& mem);
void PLA(std::unique_ptr<Memory>& mem);
void PLP(std::unique_ptr<Memory>& mem);
void ROL(std::unique_ptr<Memory>& mem);
void ROR(std::unique_ptr<Memory>& mem);
void RTI(std::unique_ptr<Memory>& mem);
void RTS(std::unique_ptr<Memory>& mem);
void SBC(std::unique_ptr<Memory>& mem);
void SEC(std::unique_ptr<Memory>& mem);
void SED(std::unique_ptr<Memory>& mem);
void SEI(std::unique_ptr<Memory>& mem);
void STA(std::unique_ptr<Memory>& mem);
void STX(std::unique_ptr<Memory>& mem);
void STY(std::unique_ptr<Memory>& mem);
void TAX(std::unique_ptr<Memory>& mem);
void TAY(std::unique_ptr<Memory>& mem);
void TSX(std::unique_ptr<Memory>& mem);
void TXA(std::unique_ptr<Memory>& mem);
void TXS(std::unique_ptr<Memory>& mem);
void TYA(std::unique_ptr<Memory>& mem);
void WAI(std::unique_ptr<Memory>& mem);
};
/*
WORD AB;
BYTE DB;
BIT BE;
BIT IRQB;
BIT MLB;
BIT NMIB;
BIT NC;
BIT PHI10;
BIT PHI2;
BIT PHI20;
BIT RDY;
BIT RESB;
BIT RWB;
BIT SOB;
BIT SYNC;
BIT VDD;
BIT VPD;
BIT VSS;
*/