--- nono/vm/gvram.cpp 2026/04/29 17:04:55 1.1.1.5 +++ nono/vm/gvram.cpp 2026/04/29 17:05:25 1.1.1.8 @@ -4,68 +4,72 @@ // Licensed under nono-license.txt // -#include "gvram.h" -#include "mpu.h" -#include "videoctlr.h" - // // GVRAM // + // GVRAM はワード単位でホストバイトオーダ配置なので、 // バイトアクセス時は HB() マクロを使用のこと。 -// -std::unique_ptr gGVRAM; +#include "gvram.h" +#include "mpu.h" +#include "videoctlr.h" + +// 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]); } +// デストラクタ GVRAMDevice::~GVRAMDevice() { } -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)]; }