--- nono/vm/adpcm.cpp 2026/04/29 17:05:16 1.1.1.2 +++ nono/vm/adpcm.cpp 2026/04/29 17:05:28 1.1.1.4 @@ -18,8 +18,6 @@ ADPCMDevice::ADPCMDevice() : inherited(OBJ_ADPCM) { - event.func = ToEventCallback(&ADPCMDevice::EventCallback); - event.Regist("ADPCM"); } // デストラクタ @@ -38,6 +36,10 @@ ADPCMDevice::Init() dmac = GetDMACDevice(); ppi = GetPPIDevice(); + event.func = ToEventCallback(&ADPCMDevice::EventCallback); + event.SetName("ADPCM"); + scheduler->RegistEvent(event); + return true; } @@ -53,12 +55,10 @@ ADPCMDevice::ResetHard(bool poweron) div = 512; } -uint64 -ADPCMDevice::Read(uint32 offset) +busdata +ADPCMDevice::ReadPort(uint32 offset) { - uint8 data; - - mpu->AddCycle(18); // InsideOut p.135 + busdata data; switch (offset) { case 0: // STAT @@ -66,24 +66,27 @@ ADPCMDevice::Read(uint32 offset) if (playing) { data |= STAT_PLAY; } - putlog(1, "STAT -> $%02x", data); + putlog(1, "STAT -> $%02x", data.Data()); break; case 1: // DATA putlog(0, "Read $%06x (NOT IMPLEMENTED)", mpu->GetPaddr()); 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; } -uint64 -ADPCMDevice::Write(uint32 offset, uint32 data) +busdata +ADPCMDevice::WritePort(uint32 offset, uint32 data) { - mpu->AddCycle(22); // InsideOut p.135 - switch (offset) { case 0: // CMD putlog(1, "CMD <- $%02x", data); @@ -106,26 +109,37 @@ ADPCMDevice::Write(uint32 offset, uint32 } break; default: - VMPANIC("corrupted offset=%d", offset); + VMPANIC("corrupted offset=%u", offset); } - return 0; + // InsideOut p.135 + const busdata wait = busdata::Wait(22 * 40_nsec); + + busdata r = wait; + r |= BusData::Size1; + return r; } -uint64 -ADPCMDevice::Peek(uint32 offset) +busdata +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; @@ -138,7 +152,7 @@ ADPCMDevice::StartPlay() div = 512; break; default: - VMPANIC("corrupted ADPCM rate=%d", rate); + VMPANIC("corrupted ADPCM rate=%u", rate); } playing = true;