--- nono/vm/opm.cpp 2026/04/29 17:05:16 1.1.1.6 +++ nono/vm/opm.cpp 2026/04/29 17:05:59 1.1.1.11 @@ -10,7 +10,9 @@ #include "opm.h" #include "adpcm.h" +#include "event.h" #include "fdc.h" +#include "mainbus.h" #include "mpu.h" #include "scheduler.h" @@ -29,10 +31,6 @@ OPMDevice::~OPMDevice() bool OPMDevice::Init() { - if (inherited::Init() == false) { - return false; - } - adpcm = GetADPCMDevice(); fdc = GetFDCDevice(); @@ -50,17 +48,17 @@ 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; + putlog(0, "Read $%06x (NOT IMPLEMENTED)", + GetMainbusDevice()->GetPaddr()); + data = 0; + break; case 1: // OPM ステータスレジスタ data = 0; @@ -69,19 +67,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) { @@ -113,7 +117,7 @@ OPMDevice::Write(uint32 offset, uint32 d // 時刻の起点は CPU 側の命令によって異なるはずだが // わからないので命令のぶんは無視しておく。 // 53 クロックのウェイトのほうは足す。 - busy_origin = now + 53 * mpu->GetClock_nsec(); + busy_origin = now + 53 * mpu->GetClock_tsec(); // busy_start のほうはとりあえず 10 クロックにしておく。 busy_start = busy_origin + 10 * clk; @@ -127,25 +131,36 @@ OPMDevice::Write(uint32 offset, uint32 d break; default: putlog(0, "Write $%06x <- $%02x (NOT IMPLEMENTED)", - mpu->GetPaddr(), data); + GetMainbusDevice()->GetPaddr(), data); break; } 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