Skip to content

Commit

Permalink
[Mega-CD] fix timer
Browse files Browse the repository at this point in the history
  • Loading branch information
TascoDLX authored and Screwtapello committed Mar 20, 2021
1 parent 086fb10 commit a589c82
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions higan/md/mcd/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ auto MCD::readIO(uint1 upper, uint1 lower, uint24 address, uint16 data) -> uint1
}

if(address == 0xff8030) {
data.bit(0, 7) = timer.counter;
data.bit(0, 7) = timer.setpoint;
data.bit(8,15) = Unmapped;
}

Expand Down Expand Up @@ -251,7 +251,7 @@ auto MCD::writeIO(uint1 upper, uint1 lower, uint24 address, uint16 data) -> void

if(address == 0xff8030) {
if(lower) {
timer.counter = data.byte(0);
timer.counter = timer.setpoint = data.byte(0);
}
}

Expand Down
1 change: 1 addition & 0 deletions higan/md/mcd/mcd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ struct MCD : M68K, Thread {

IRQ irq;
uint8 counter;
uint8 setpoint;
} timer;

struct GPU {
Expand Down
1 change: 1 addition & 0 deletions higan/md/mcd/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ auto MCD::CDD::serialize(serializer& s) -> void {
auto MCD::Timer::serialize(serializer& s) -> void {
irq.serialize(s);
s.integer(counter);
s.integer(setpoint);
}

auto MCD::GPU::serialize(serializer& s) -> void {
Expand Down
5 changes: 3 additions & 2 deletions higan/md/mcd/timer.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
auto MCD::Timer::clock() -> void {
if(counter && !--counter) {
if(setpoint && !--counter) {
irq.raise();
counter = setpoint;
}
}

auto MCD::Timer::power(bool reset) -> void {
irq = {};
counter = 0;
counter = setpoint = 0;
}

0 comments on commit a589c82

Please sign in to comment.