--- nono/vm/gvram.cpp 2026/04/29 17:05:10 1.1.1.6 +++ nono/vm/gvram.cpp 2026/04/29 17:05:25 1.1.1.8 @@ -15,15 +15,14 @@ #include "mpu.h" #include "videoctlr.h" -// グローバル参照用 -GVRAMDevice *gGVRAM; +// InsideOut p.135 +static const busdata wait = busdata::Wait(9 * 40_nsec); // コンストラクタ GVRAMDevice::GVRAMDevice() - : inherited("GVRAM") + : inherited(OBJ_GVRAM) { - devaddr = 0xc00000; - devlen = 0x200000; // XXX とりあえず + uint devlen = 0x20'0000; // XXX とりあえず mem.reset(new uint8[devlen]); } @@ -31,45 +30,46 @@ GVRAMDevice::GVRAMDevice() // デストラクタ GVRAMDevice::~GVRAMDevice() { - gGVRAM = NULL; } -uint64 +busdata GVRAMDevice::Read8(uint32 addr) { - gMPU->AddCycle(9); // Inside/Out p.135 - uint32 offset = addr - devaddr; - return mem[HB(offset)]; + busdata data; + uint32 offset = addr - baseaddr; + data = mem[HB(offset)]; + data |= wait; + return data; } -uint64 +busdata GVRAMDevice::Read16(uint32 addr) { - gMPU->AddCycle(9); // Inside/Out p.135 - uint32 offset = addr - devaddr; - return *(uint16 *)&mem[offset]; + busdata data; + uint32 offset = addr - baseaddr; + data = *(uint16 *)&mem[offset]; + data |= wait; + return data; } -uint64 +busdata GVRAMDevice::Write8(uint32 addr, uint32 data) { - gMPU->AddCycle(9); // Inside/Out p.135 - uint32 offset = addr - devaddr; + uint32 offset = addr - baseaddr; mem[HB(offset)] = data; - return 0; + return wait; } -uint64 +busdata GVRAMDevice::Write16(uint32 addr, uint32 data) { - gMPU->AddCycle(9); // Inside/Out p.135 - uint32 offset = addr - devaddr; + uint32 offset = addr - baseaddr; *(uint16 *)&mem[offset] = data; - return 0; + return wait; } -uint64 +busdata GVRAMDevice::Peek8(uint32 addr) { - return mem[HB(addr - devaddr)]; + return mem[HB(addr - baseaddr)]; }