Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/snes/alt/smp/smp.hpp
2 views
1
class SMP : public Processor {
2
public:
3
static const uint8 iplrom[64];
4
uint8 *apuram;
5
6
enum : bool { Threaded = false };
7
alwaysinline void synchronize_cpu();
8
alwaysinline void synchronize_dsp();
9
10
unsigned port_read(unsigned port);
11
void port_write(unsigned port, unsigned data);
12
13
unsigned mmio_read(unsigned addr);
14
void mmio_write(unsigned addr, unsigned data);
15
16
void enter();
17
void power();
18
void reset();
19
20
void serialize(serializer&);
21
SMP();
22
~SMP();
23
void initialize();
24
25
void disassemble_opcode(char *output, uint16 addr);
26
27
//private:
28
struct Flags {
29
bool n, v, p, b, h, i, z, c;
30
31
alwaysinline operator unsigned() const {
32
return (n << 7) | (v << 6) | (p << 5) | (b << 4)
33
| (h << 3) | (i << 2) | (z << 1) | (c << 0);
34
};
35
36
alwaysinline unsigned operator=(unsigned data) {
37
n = data & 0x80; v = data & 0x40; p = data & 0x20; b = data & 0x10;
38
h = data & 0x08; i = data & 0x04; z = data & 0x02; c = data & 0x01;
39
return data;
40
}
41
42
alwaysinline unsigned operator|=(unsigned data) { return operator=(operator unsigned() | data); }
43
alwaysinline unsigned operator^=(unsigned data) { return operator=(operator unsigned() ^ data); }
44
alwaysinline unsigned operator&=(unsigned data) { return operator=(operator unsigned() & data); }
45
};
46
47
unsigned opcode_number;
48
unsigned opcode_cycle;
49
50
struct Regs {
51
uint16 pc;
52
uint8 sp;
53
union {
54
uint16 ya;
55
struct { uint8 order_lsb2(a, y); };
56
};
57
uint8 x;
58
Flags p;
59
} regs;
60
61
uint16 rd, wr, dp, sp, ya, bit;
62
63
struct Status {
64
//$00f1
65
bool iplrom_enable;
66
67
//$00f2
68
unsigned dsp_addr;
69
70
//$00f8,$00f9
71
unsigned ram00f8;
72
unsigned ram00f9;
73
} status;
74
75
template<unsigned frequency>
76
struct Timer {
77
bool enable;
78
uint8 target;
79
uint8 stage1_ticks;
80
uint8 stage2_ticks;
81
uint8 stage3_ticks;
82
83
void tick();
84
void tick(unsigned clocks);
85
};
86
87
Timer<128> timer0;
88
Timer<128> timer1;
89
Timer< 16> timer2;
90
91
void tick();
92
alwaysinline void op_io();
93
alwaysinline uint8 op_read(uint16 addr, eCDLog_Flags flags);
94
alwaysinline void op_write(uint16 addr, uint8 data);
95
alwaysinline void op_step();
96
static const unsigned cycle_count_table[256];
97
uint64 cycle_table_cpu[256];
98
unsigned cycle_table_dsp[256];
99
uint64 cycle_step_cpu;
100
101
uint8 op_adc (uint8 x, uint8 y);
102
uint16 op_addw(uint16 x, uint16 y);
103
uint8 op_and (uint8 x, uint8 y);
104
uint8 op_cmp (uint8 x, uint8 y);
105
uint16 op_cmpw(uint16 x, uint16 y);
106
uint8 op_eor (uint8 x, uint8 y);
107
uint8 op_inc (uint8 x);
108
uint8 op_dec (uint8 x);
109
uint8 op_or (uint8 x, uint8 y);
110
uint8 op_sbc (uint8 x, uint8 y);
111
uint16 op_subw(uint16 x, uint16 y);
112
uint8 op_asl (uint8 x);
113
uint8 op_lsr (uint8 x);
114
uint8 op_rol (uint8 x);
115
uint8 op_ror (uint8 x);
116
};
117
118
extern SMP smp;
119
120