--- nono/vm/opm.cpp 2026/04/29 17:05:16 1.1.1.6 +++ nono/vm/opm.cpp 2026/04/29 17:05:49 1.1.1.10 @@ -10,6 +10,7 @@ #include "opm.h" #include "adpcm.h" +#include "event.h" #include "fdc.h" #include "mpu.h" #include "scheduler.h" @@ -29,10 +30,6 @@ OPMDevice::~OPMDevice() bool OPMDevice::Init() { - if (inherited::Init() == false) { - return false; - } - adpcm = GetADPCMDevice(); fdc = GetFDCDevice(); @@ -50,17 +47,16 @@ OPMDevice::ResetHard(bool poweron) fdc->SetForceReady(false); } -uint64 -OPMDevice::Read(uint32 offset) +busdata +OPMDevice::ReadPort(uint32 offset) { - uint8 data; - - mpu->AddCycle(19); // InsideOut p.135 + busdata data; switch (offset) { case 0: putlog(0, "Read $%06x (NOT IMPLEMENTED)", mpu->GetPaddr()); - return 0; + data = 0; + break; case 1: // OPM ステータスレジスタ data = 0; @@ -69,19 +65,25 @@ OPMDevice::Read(uint32 offset) } // タイマ関係の bit1, bit0 は未実装 - putlog(1, "STAT -> $%02x", data); - return data; + putlog(1, "STAT -> $%02x", data.Data()); + break; default: - VMPANIC("corrupted offset=%d", offset); - return 0xff; + VMPANIC("corrupted offset=%u", offset); + data = 0xff; + break; } + + // InsideOut p.135 + const busdata read_wait = busdata::Wait(19 * 40_nsec); + data |= read_wait; + + data |= BusData::Size1; + return data; } -uint64 -OPMDevice::Write(uint32 offset, uint32 data) +busdata +OPMDevice::WritePort(uint32 offset, uint32 data) { - mpu->AddCycle(53); // InsideOut p.135 - uint64 now = scheduler->GetVirtTime(); switch (offset) { @@ -132,20 +134,31 @@ OPMDevice::Write(uint32 offset, uint32 d } break; default: - VMPANIC("corrupted offset=%d", offset); + VMPANIC("corrupted offset=%u", offset); break; } - return 0; + // InsideOut p.135 + const busdata write_wait = busdata::Wait(53 * 40_nsec); + + busdata r = write_wait; + r |= BusData::Size1; + return r; } -uint64 -OPMDevice::Peek(uint32 offset) +busdata +OPMDevice::PeekPort(uint32 offset) { // XXX 未実装 return 0xff; } +bool +OPMDevice::PokePort(uint32 offset, uint32 data) +{ + return false; +} + // OPM ステータスレジスタの B (BUSY) ビット bool OPMDevice::IsBusy() const