Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/snes/chip/link/link.cpp
2 views
1
#include <snes/snes.hpp>
2
3
#define LINK_HPP
4
namespace SNES {
5
6
Link link;
7
8
void Link::Enter() { link.enter(); }
9
10
void Link::enter() {
11
while(true) {
12
cpu.synchronize_coprocessors();
13
unsigned clocks = 1;
14
if(link_run) clocks = link_run();
15
step(clocks);
16
synchronize_cpu();
17
}
18
}
19
20
void Link::init() {
21
}
22
23
void Link::load() {
24
if(opened()) close();
25
string basename = interface()->path(Cartridge::Slot::Base, "");
26
string name = program != "" ? program : notdir(basename);
27
string path = dir(basename);
28
if(open(name, path)) {
29
link_power = sym("link_power");
30
link_reset = sym("link_reset");
31
link_run = sym("link_run" );
32
link_read = sym("link_read" );
33
link_write = sym("link_write");
34
}
35
}
36
37
void Link::unload() {
38
if(opened()) close();
39
}
40
41
void Link::power() {
42
if(link_power) link_power();
43
}
44
45
void Link::reset() {
46
if(link_reset) link_reset();
47
create(Link::Enter, frequency);
48
}
49
50
uint8 Link::read(unsigned addr) {
51
if(link_read) return link_read(addr);
52
return cpu.regs.mdr;
53
}
54
55
void Link::write(unsigned addr, uint8 data) {
56
if(link_write) return link_write(addr, data);
57
}
58
59
}
60
61