2016-01-27 11:31:39 +00:00
|
|
|
#include <ws/ws.hpp>
|
|
|
|
|
|
|
|
namespace WonderSwan {
|
|
|
|
|
|
|
|
APU apu;
|
|
|
|
|
|
|
|
auto APU::Enter() -> void {
|
2016-02-09 11:51:12 +00:00
|
|
|
while(true) scheduler.synchronize(), apu.main();
|
2016-01-27 11:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto APU::main() -> void {
|
2016-02-09 11:51:12 +00:00
|
|
|
step(128);
|
|
|
|
interface->audioSample(0, 0);
|
2016-01-27 11:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto APU::step(uint clocks) -> void {
|
|
|
|
clock += clocks;
|
2016-02-09 11:51:12 +00:00
|
|
|
if(clock >= 0 && !scheduler.synchronizing()) co_switch(cpu.thread);
|
2016-01-27 11:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto APU::power() -> void {
|
2016-02-09 11:51:12 +00:00
|
|
|
create(APU::Enter, 3'072'000);
|
2016-01-27 11:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|