-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.cpp
41 lines (37 loc) · 950 Bytes
/
clock.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "clock.h"
Clock::Clock()
: Hardware("Generic Clock (compatible)", 0x12d0b402, 0x1, 0xff),
divisor(0),
elapsed_ticks(0),
ticks(0),
stop(false) {}
Clock::~Clock() {}
unsigned Clock::interrupt(word msg) {
switch (msg) {
case 0:
if (cpu) {
uint16_t reg_B = cpu->context()[B];
if (reg_B == 0) {
stop = true;
ticks = 0;
divisor = 0;
} else {
divisor = reg_B;
stop = false;
ticks = 0;
}
} else {
return 0;
}
case 1:
if (cpu) {
cpu->context()[C] = elapsed_ticks;
}
case 2:
default:
return 0;
}
return 0;
}
unsigned Clock::interrupt() { return 0; }
unsigned Clock::tick() { return 0; }