-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cpu.hpp
50 lines (38 loc) · 1.1 KB
/
Cpu.hpp
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
#pragma once
#include <memory>
#include <map>
#include <unordered_map>
#include "InstructionTypes.hpp"
#include "RegisterFile.hpp"
enum class cpu_instructions : unsigned char;
enum class cpu_special_funcs : unsigned char;
enum class cpu_bconds : unsigned char;
// ref:
// https://svkt.org/~simias/guide.pdf
// https://problemkaputt.de/psx-spx.htm
// http://hitmen.c02.at/files/docs/psx/psx.pdf
class Cpu
{
public:
RegisterFile register_file;
void init();
void reset();
void tick();
void save_state(std::stringstream& file);
void load_state(std::stringstream& file);
void execute(const instruction_union& instruction);
void execute_special(const instruction_union& instr);
void execute_bcond(const instruction_union& instr);
void execute_cop(const instruction_union& instr);
unsigned int get_immediate_base_addr(const instruction_union& instr);
unsigned int hi = 0;
unsigned int lo = 0;
unsigned int current_pc = 0;
unsigned int next_pc = 0;
unsigned int current_instruction = 0;
unsigned int next_instruction = 0;
bool in_delay_slot = false;
static Cpu * get_instance();
private:
Cpu() = default;
};