Skip to content

Commit

Permalink
md: fix sh2 thread restart behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeUsher committed Oct 18, 2023
1 parent 1c61fc9 commit 7b433f3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ares/md/m32x/io-external.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ auto M32X::writeExternalIO(n1 upper, n1 lower, n24 address, n16 data) -> void {
io.adapterEnable = data.bit(0);

if(data.bit(1) == 0) {
shm.power(true);
shs.power(true);
shm.restart();
shs.restart();
}

io.adapterReset = data.bit(1);
Expand Down
1 change: 1 addition & 0 deletions ares/md/m32x/m32x.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct M32X {
auto main() -> void;
auto step(u32 clocks) -> void override;
auto power(bool reset) -> void;
auto restart() -> void;

auto busReadByte(u32 address) -> u32 override;
auto busReadWord(u32 address) -> u32 override;
Expand Down
8 changes: 8 additions & 0 deletions ares/md/m32x/sh7604.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ auto M32X::SH7604::power(bool reset) -> void {
irq.vres.enable = 1;
}

auto M32X::SH7604::restart() -> void {
minCyclesBetweenSyncs = 20;
SH2::power(true);
irq = {};
irq.vres.enable = 1;
Thread::restart({&M32X::SH7604::main, this});
}

auto M32X::SH7604::busReadByte(u32 address) -> u32 {
if(address & 1) {
return m32x.readInternal(0, 1, address & ~1).byte(0);
Expand Down

0 comments on commit 7b433f3

Please sign in to comment.