Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/snes/alt/cpu/cpu.hpp
2 views
1
class CPU : public Processor, public CPUcore, public PPUcounter {
2
public:
3
uint8* wram; //[128 * 1024];
4
5
enum : bool { Threaded = true };
6
array<Processor*> coprocessors;
7
alwaysinline void step(unsigned clocks);
8
alwaysinline void synchronize_smp();
9
void synchronize_ppu();
10
void synchronize_coprocessors();
11
void synchronize_controllers();
12
13
uint8 pio();
14
bool joylatch();
15
bool interrupt_pending();
16
uint8 port_read(uint8 port);
17
void port_write(uint8 port, uint8 data);
18
uint8 mmio_read(unsigned addr);
19
void mmio_write(unsigned addr, uint8 data);
20
21
void op_io();
22
uint8 op_read(unsigned addr, eCDLog_Flags = eCDLog_Flags_CPUData);
23
void op_write(unsigned addr, uint8 data);
24
25
void enter();
26
void enable();
27
void power();
28
void reset();
29
30
void serialize(serializer&);
31
CPU();
32
~CPU();
33
void initialize();
34
35
private:
36
//cpu
37
static void Enter();
38
void op_step();
39
40
//timing
41
struct QueueEvent {
42
enum : unsigned {
43
DramRefresh,
44
HdmaRun,
45
};
46
};
47
nall::priority_queue<unsigned> queue;
48
void queue_event(unsigned id);
49
void last_cycle();
50
void add_clocks(unsigned clocks);
51
void scanline();
52
void run_auto_joypad_poll();
53
54
//memory
55
unsigned speed(unsigned addr) const;
56
57
//dma
58
bool dma_transfer_valid(uint8 bbus, unsigned abus);
59
bool dma_addr_valid(unsigned abus);
60
uint8 dma_read(unsigned abus);
61
void dma_write(bool valid, unsigned addr, uint8 data);
62
void dma_transfer(bool direction, uint8 bbus, unsigned abus);
63
uint8 dma_bbus(unsigned i, unsigned index);
64
unsigned dma_addr(unsigned i);
65
unsigned hdma_addr(unsigned i);
66
unsigned hdma_iaddr(unsigned i);
67
void dma_run();
68
bool hdma_active_after(unsigned i);
69
void hdma_update(unsigned i);
70
void hdma_run();
71
void hdma_init();
72
void dma_reset();
73
74
//registers
75
uint8 port_data[4];
76
77
struct Channel {
78
bool dma_enabled;
79
bool hdma_enabled;
80
81
bool direction;
82
bool indirect;
83
bool unused;
84
bool reverse_transfer;
85
bool fixed_transfer;
86
uint8 transfer_mode;
87
88
uint8 dest_addr;
89
uint16 source_addr;
90
uint8 source_bank;
91
92
union {
93
uint16 transfer_size;
94
uint16 indirect_addr;
95
};
96
97
uint8 indirect_bank;
98
uint16 hdma_addr;
99
uint8 line_counter;
100
uint8 unknown;
101
102
bool hdma_completed;
103
bool hdma_do_transfer;
104
} channel[8];
105
106
struct Status {
107
bool nmi_valid;
108
bool nmi_line;
109
bool nmi_transition;
110
bool nmi_pending;
111
112
bool irq_valid;
113
bool irq_line;
114
bool irq_transition;
115
bool irq_pending;
116
117
bool irq_lock;
118
bool hdma_pending;
119
120
unsigned wram_addr;
121
122
bool joypad_strobe_latch;
123
124
bool nmi_enabled;
125
bool virq_enabled;
126
bool hirq_enabled;
127
bool auto_joypad_poll_enabled;
128
129
uint8 pio;
130
131
uint8 wrmpya;
132
uint8 wrmpyb;
133
uint16 wrdiva;
134
uint8 wrdivb;
135
136
uint16 htime;
137
uint16 vtime;
138
139
unsigned rom_speed;
140
141
uint16 rddiv;
142
uint16 rdmpy;
143
144
uint8 joy1l, joy1h;
145
uint8 joy2l, joy2h;
146
uint8 joy3l, joy3h;
147
uint8 joy4l, joy4h;
148
} status;
149
150
public:
151
struct Debugger {
152
hook<void (uint24)> op_exec;
153
hook<void (uint24)> op_read;
154
hook<void (uint24, uint8)> op_write;
155
hook<void ()> op_nmi;
156
hook<void ()> op_irq;
157
} debugger;
158
159
};
160
161
extern CPU cpu;
162
163