Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/snes/chip/icd2/icd2.cpp
2 views
1
#if defined(GAMEBOY)
2
3
#include <snes/snes.hpp>
4
5
#define ICD2_CPP
6
namespace SNES {
7
8
#include "interface/interface.cpp"
9
#include "mmio/mmio.cpp"
10
#include "serialization.cpp"
11
ICD2 icd2;
12
13
void ICD2::Enter() { icd2.enter(); }
14
15
void ICD2::enter() {
16
while(true) {
17
if(scheduler.sync == Scheduler::SynchronizeMode::All) {
18
GameBoy::system.runtosave();
19
scheduler.exit(Scheduler::ExitReason::SynchronizeEvent);
20
}
21
22
if(r6003 & 0x80) {
23
GameBoy::system.run();
24
step(GameBoy::system.clocks_executed);
25
GameBoy::system.clocks_executed = 0;
26
} else { //DMG halted
27
audio.coprocessor_sample(0x0000, 0x0000);
28
step(1);
29
}
30
synchronize_cpu();
31
}
32
}
33
34
void ICD2::init() {
35
}
36
37
void ICD2::load() {
38
}
39
40
void ICD2::unload() {
41
}
42
43
void ICD2::power() {
44
audio.coprocessor_enable(true);
45
audio.coprocessor_frequency(4 * 1024 * 1024);
46
}
47
48
void ICD2::reset() {
49
create(ICD2::Enter, cpu.frequency / 5);
50
51
r6000_ly = 0x00;
52
r6000_row = 0x00;
53
r6003 = 0x00;
54
r6004 = 0xff;
55
r6005 = 0xff;
56
r6006 = 0xff;
57
r6007 = 0xff;
58
for(unsigned n = 0; n < 16; n++) r7000[n] = 0x00;
59
r7800 = 0x0000;
60
mlt_req = 0;
61
62
for(auto &n : lcd.buffer) n = 0;
63
for(auto &n : lcd.output) n = 0;
64
lcd.row = 0;
65
66
packetsize = 0;
67
joyp_id = 3;
68
joyp15lock = 0;
69
joyp14lock = 0;
70
pulselock = true;
71
72
GameBoy::system.init();
73
GameBoy::system.power();
74
}
75
76
ICD2::ICD2()
77
{
78
GameBoy::interface = this;
79
}
80
81
}
82
83
#endif
84
85