--- nono/vm/adpcm.cpp 2026/04/29 17:05:24 1.1.1.3 +++ nono/vm/adpcm.cpp 2026/04/29 17:05:49 1.1.1.6 @@ -10,6 +10,7 @@ #include "adpcm.h" #include "dmac.h" +#include "event.h" #include "mpu.h" #include "pio.h" #include "scheduler.h" @@ -18,8 +19,6 @@ ADPCMDevice::ADPCMDevice() : inherited(OBJ_ADPCM) { - event.func = ToEventCallback(&ADPCMDevice::EventCallback); - event.Regist("ADPCM"); } // デストラクタ @@ -31,13 +30,14 @@ ADPCMDevice::~ADPCMDevice() bool ADPCMDevice::Init() { - if (inherited::Init() == false) { - return false; - } - dmac = GetDMACDevice(); ppi = GetPPIDevice(); + auto evman = GetEventManager(); + event = evman->Regist(this, + ToEventCallback(&ADPCMDevice::EventCallback), + "ADPCM"); + return true; } @@ -54,7 +54,7 @@ ADPCMDevice::ResetHard(bool poweron) } busdata -ADPCMDevice::Read(uint32 offset) +ADPCMDevice::ReadPort(uint32 offset) { busdata data; @@ -71,18 +71,19 @@ ADPCMDevice::Read(uint32 offset) data = 0xff; break; default: - VMPANIC("corrupted offset=%d", offset); + VMPANIC("corrupted offset=%u", offset); } // InsideOut p.135 const busdata wait = busdata::Wait(18 * 40_nsec); data |= wait; + data |= BusData::Size1; return data; } busdata -ADPCMDevice::Write(uint32 offset, uint32 data) +ADPCMDevice::WritePort(uint32 offset, uint32 data) { switch (offset) { case 0: // CMD @@ -106,28 +107,37 @@ ADPCMDevice::Write(uint32 offset, uint32 } break; default: - VMPANIC("corrupted offset=%d", offset); + VMPANIC("corrupted offset=%u", offset); } // InsideOut p.135 const busdata wait = busdata::Wait(22 * 40_nsec); - return wait; + + busdata r = wait; + r |= BusData::Size1; + return r; } busdata -ADPCMDevice::Peek(uint32 offset) +ADPCMDevice::PeekPort(uint32 offset) { // XXX 未実装 return 0xff; } +bool +ADPCMDevice::PokePort(uint32 offset, uint32 data) +{ + return false; +} + // 再生開始 void ADPCMDevice::StartPlay() { // PPI で設定されているサンプリングレートをここで読み出す。 // XXX パンは未対応 - int rate = ppi->GetADPCMRate(); + uint rate = ppi->GetADPCMRate(); switch (rate) { case 0: div = 1024; @@ -140,19 +150,19 @@ ADPCMDevice::StartPlay() div = 512; break; default: - VMPANIC("corrupted ADPCM rate=%d", rate); + VMPANIC("corrupted ADPCM rate=%u", rate); } playing = true; dmac->AssertREQ(3); - event.time = div / clk; + event->time = div / clk; scheduler->StartEvent(event); } // イベント void -ADPCMDevice::EventCallback(Event& ev) +ADPCMDevice::EventCallback(Event *ev) { // XXX 適当 if (playing) {