--- nono/vm/tvram.cpp 2026/04/29 17:05:18 1.1.1.9 +++ nono/vm/tvram.cpp 2026/04/29 17:05:25 1.1.1.10 @@ -15,6 +15,9 @@ #include "mpu.h" #include "videoctlr.h" +// InsideOut p.135 +static const busdata wait = busdata::Wait(9 * 40_nsec); + // コンストラクタ TVRAMDevice::TVRAMDevice() : inherited(1024, 1024) @@ -53,45 +56,39 @@ TVRAMDevice::Init() return true; } -// リセット -void -TVRAMDevice::ResetHard(bool poweron) -{ - // XXX ここ? - Invalidate(); -} - -inline uint64 +inline uint32 TVRAMDevice::Decoder(uint32 addr) const { return addr - baseaddr; } -uint64 +busdata TVRAMDevice::Read8(uint32 addr) { - mpu->AddCycle(9); // Inside/Out p.135 + busdata data; uint32 offset = Decoder(addr); - return mem[HLB(offset)]; + data = mem[HLB(offset)]; + data |= wait; + return data; } -uint64 +busdata TVRAMDevice::Read16(uint32 addr) { - mpu->AddCycle(9); // Inside/Out p.135 + busdata data; uint32 offset = Decoder(addr); - return *(uint16 *)&mem[HLW(offset)]; + data = *(uint16 *)&mem[HLW(offset)]; + data |= wait; + return data; } -uint64 +busdata TVRAMDevice::Write8(uint32 addr, uint32 data) { uint32 offset = Decoder(addr); uint8 *ptr; uint8 mask8; - mpu->AddCycle(9); // Inside/Out p.135 - // XXX とりあえずね putlog(3, "Write $%06x.B <- $%02x", addr, data); @@ -120,18 +117,16 @@ TVRAMDevice::Write8(uint32 addr, uint32 *ptr = (data & ~mask8) | (*ptr & mask8); } SetDirty(poffset); - return 0; + return wait; } -uint64 +busdata TVRAMDevice::Write16(uint32 addr, uint32 data) { uint32 offset = Decoder(addr); uint16 *ptr; uint16 mask16; - mpu->AddCycle(9); // Inside/Out p.135 - // XXX とりあえずね putlog(3, "Write $%06x.W <- $%04x", addr, data); @@ -156,17 +151,17 @@ TVRAMDevice::Write16(uint32 addr, uint32 *ptr = (data & ~mask16) | (*ptr & mask16); } SetDirty(poffset); - return 0; + return wait; } -uint64 +busdata TVRAMDevice::Peek8(uint32 addr) { uint32 offset = Decoder(addr); return mem[HLB(offset)]; } -uint64 +bool TVRAMDevice::Poke8(uint32 addr, uint32 data) { if ((int32)data >= 0) { @@ -176,7 +171,7 @@ TVRAMDevice::Poke8(uint32 addr, uint32 d // この場合も画面を更新する SetDirty(poffset); } - return 0; + return true; } // offset の位置に対応する更新フラグを立てる。