--- nono/vm/opm.cpp 2026/04/29 17:05:24 1.1.1.7 +++ 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(); @@ -51,13 +49,14 @@ OPMDevice::ResetHard(bool poweron) } busdata -OPMDevice::Read(uint32 offset) +OPMDevice::ReadPort(uint32 offset) { busdata data; switch (offset) { case 0: - putlog(0, "Read $%06x (NOT IMPLEMENTED)", mpu->GetPaddr()); + putlog(0, "Read $%06x (NOT IMPLEMENTED)", + GetMainbusDevice()->GetPaddr()); data = 0; break; case 1: @@ -71,20 +70,21 @@ OPMDevice::Read(uint32 offset) putlog(1, "STAT -> $%02x", data.Data()); break; default: - VMPANIC("corrupted offset=%d", offset); + VMPANIC("corrupted offset=%u", offset); data = 0xff; break; } // InsideOut p.135 - const busdata read_wait = busdata::Wait(19 * 40_usec); + const busdata read_wait = busdata::Wait(19 * 40_nsec); data |= read_wait; + data |= BusData::Size1; return data; } busdata -OPMDevice::Write(uint32 offset, uint32 data) +OPMDevice::WritePort(uint32 offset, uint32 data) { uint64 now = scheduler->GetVirtTime(); @@ -117,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; @@ -131,28 +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; } // InsideOut p.135 const busdata write_wait = busdata::Wait(53 * 40_nsec); - return write_wait; + busdata r = write_wait; + r |= BusData::Size1; + return r; } busdata -OPMDevice::Peek(uint32 offset) +OPMDevice::PeekPort(uint32 offset) { // XXX 未実装 return 0xff; } +bool +OPMDevice::PokePort(uint32 offset, uint32 data) +{ + return false; +} + // OPM ステータスレジスタの B (BUSY) ビット bool OPMDevice::IsBusy() const