--- nono/vm/bankram.cpp 2026/04/29 17:05:38 1.1.1.4 +++ nono/vm/bankram.cpp 2026/04/29 17:05:51 1.1.1.6 @@ -13,6 +13,7 @@ #include "bankram.h" #include "config.h" +#include "mpu.h" // コンストラクタ BankRAMDevice::BankRAMDevice(uint objid_, int ram_size_MB) @@ -34,7 +35,14 @@ BankRAMDevice::~BankRAMDevice() bool BankRAMDevice::Init() { - ram.reset(new uint8[ram_size]); + ram.reset(new(std::nothrow) uint8[ram_size]); + if ((bool)ram == false) { + errno = ENOMEM; + warn("BankRAM(%u bytes)", ram_size); + return false; + } + + wait = busdata::Wait(1 * mpu->GetClock_nsec()); return true; } @@ -71,7 +79,7 @@ BankRAMDevice::Read(busaddr addr) data = *(uint32 *)&ram[offset & ~3U]; putlog(4, "$%06x ($%06x) -> $%08x", addr.Addr(), offset, data.Data()); - data |= busdata::Wait(1); + data |= wait; data |= BusData::Size4; return data; } @@ -102,7 +110,7 @@ BankRAMDevice::Write(busaddr addr, uint3 } } - busdata r = busdata::Wait(1); + busdata r = wait; r |= BusData::Size4; return r; }