Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/snes/chip/superfx/superfx.cpp
2 views
1
#include <snes/snes.hpp>
2
3
#define SUPERFX_CPP
4
namespace SNES {
5
6
#include "serialization.cpp"
7
#include "bus/bus.cpp"
8
#include "core/core.cpp"
9
#include "memory/memory.cpp"
10
#include "mmio/mmio.cpp"
11
#include "timing/timing.cpp"
12
#include "disasm/disasm.cpp"
13
14
SuperFX superfx;
15
16
void SuperFX::Enter() { superfx.enter(); }
17
18
void SuperFX::enter() {
19
while(true) {
20
if(scheduler.sync == Scheduler::SynchronizeMode::All) {
21
scheduler.exit(Scheduler::ExitReason::SynchronizeEvent);
22
}
23
24
if(regs.sfr.g == 0) {
25
add_clocks(6);
26
synchronize_cpu();
27
continue;
28
}
29
30
(this->*opcode_table[(regs.sfr & 0x0300) + peekpipe()])();
31
if(r15_modified == false) regs.r[15]++;
32
33
if(++instruction_counter >= 128) {
34
instruction_counter = 0;
35
synchronize_cpu();
36
}
37
}
38
}
39
40
void SuperFX::init() {
41
initialize_opcode_table();
42
regs.r[14].on_modify = { &SuperFX::r14_modify, this };
43
regs.r[15].on_modify = { &SuperFX::r15_modify, this };
44
}
45
46
void SuperFX::load() {
47
}
48
49
void SuperFX::unload() {
50
}
51
52
void SuperFX::power() {
53
clockmode = config.superfx.speed;
54
}
55
56
void SuperFX::reset() {
57
create(SuperFX::Enter, system.cpu_frequency());
58
instruction_counter = 0;
59
60
for(unsigned n = 0; n < 16; n++) regs.r[n] = 0x0000;
61
regs.sfr = 0x0000;
62
regs.pbr = 0x00;
63
regs.rombr = 0x00;
64
regs.rambr = 0;
65
regs.cbr = 0x0000;
66
regs.scbr = 0x00;
67
regs.scmr = 0x00;
68
regs.colr = 0x00;
69
regs.por = 0x00;
70
regs.bramr = 0;
71
regs.vcr = 0x04;
72
regs.cfgr = 0x00;
73
regs.clsr = 0;
74
regs.pipeline = 0x01; //nop
75
regs.ramaddr = 0x0000;
76
regs.reset();
77
78
memory_reset();
79
timing_reset();
80
}
81
82
}
83
84