-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChip8.h
More file actions
102 lines (83 loc) · 2.29 KB
/
Chip8.h
File metadata and controls
102 lines (83 loc) · 2.29 KB
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
#ifndef CHIP8_H
#define CHIP8_H
#include <cstdint>
#include <stack>
#include <QtCore/QString>
#include <QtCore/QTimer>
#include <array>
#include <Chip8Screen.h>
class Chip8 : public QObject
{
Q_OBJECT
public:
Chip8();
Chip8Screen* getChip8Screen() { return &mScreenBuffer; }
public slots:
void loadRom(const QString& urlAsString);
void startEmulation();
void stopEmulation();
signals:
void imageChanged();
private:
std::uint16_t PC = 0x200; // Compteur d'instruction
std::array< std::int8_t, 16 > V; // Registres V0 -> V15
std::array< std::int8_t, 8 > RPL; // Regitres RPL
std::uint16_t I; // Registre I
std::array< std::int8_t, 4096 > memory; // Ram dans laquelle le programme sera stocké
std::int8_t DT; // Timer d'usage général
std::int8_t ST; // Timer pour le son
bool keyboard[16]; // Pour la gestion des entrées clavier
Chip8Screen mScreenBuffer;
// Variables temporaires nécessaire aux intrutions */
ushort NNN;
std::uint8_t KK;
std::uint8_t K;
std::uint8_t X;
std::uint8_t Y;
std::stack< std::uint16_t > adressStack;
std::random_device r;
// Choose a random mean between 1 and 6
std::default_random_engine e1;
std::uniform_int_distribution< std::uint8_t > uniform_dist;
QTimer mChip8Timer;
void emulate();
// Instructions //
void Inst_00E0();
void Inst_00EE();
void Inst_1NNN();
void Inst_2NNN();
void Inst_3XKK();
void Inst_4XKK();
void Inst_5XY0();
void Inst_6XKK();
void Inst_7XKK();
void Inst_8XY0();
void Inst_8XY1();
void Inst_8XY2();
void Inst_8XY3();
void Inst_8XY4();
void Inst_8XY5();
void Inst_8XY6();
void Inst_8XY7();
void Inst_8XYE();
void Inst_9XY0();
void Inst_ANNN();
void Inst_BNNN();
void Inst_CXKK();
void Inst_DXYK();
void Inst_EX9E();
void Inst_EXA1();
void Inst_FX07();
void Inst_FX0A();
void Inst_FX15();
void Inst_FX18();
void Inst_FX1E();
void Inst_FX29();
void Inst_FX30();
void Inst_FX33();
void Inst_FX55();
void Inst_FX65();
void Inst_FX75();
void Inst_FX85();
};
#endif // CHIP8_H