--- nono/vm/gvram.cpp 2026/04/29 17:04:28 1.1 +++ nono/vm/gvram.cpp 2026/04/29 17:04:55 1.1.1.5 @@ -1,10 +1,12 @@ // // nono -// Copyright (C) 2018 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #include "gvram.h" -#include "vicon.h" +#include "mpu.h" +#include "videoctlr.h" // // GVRAM @@ -13,26 +15,25 @@ // バイトアクセス時は HB() マクロを使用のこと。 // -GVRAMDevice *gGVRAM; +std::unique_ptr gGVRAM; GVRAMDevice::GVRAMDevice() + : inherited("GVRAM") { - logname = "gvram"; - devname = "GVRAM"; devaddr = 0xc00000; devlen = 0x200000; // XXX とりあえず - mem = new uint8[devlen]; + mem.reset(new uint8[devlen]); } GVRAMDevice::~GVRAMDevice() { - delete[] mem; } uint64 GVRAMDevice::Read8(uint32 addr) { + gMPU->AddCycle(9); // Inside/Out p.135 uint32 offset = addr - devaddr; return mem[HB(offset)]; } @@ -40,6 +41,7 @@ GVRAMDevice::Read8(uint32 addr) uint64 GVRAMDevice::Read16(uint32 addr) { + gMPU->AddCycle(9); // Inside/Out p.135 uint32 offset = addr - devaddr; return *(uint16 *)&mem[offset]; } @@ -47,6 +49,7 @@ GVRAMDevice::Read16(uint32 addr) uint64 GVRAMDevice::Write8(uint32 addr, uint32 data) { + gMPU->AddCycle(9); // Inside/Out p.135 uint32 offset = addr - devaddr; mem[HB(offset)] = data; return 0; @@ -55,6 +58,7 @@ GVRAMDevice::Write8(uint32 addr, uint32 uint64 GVRAMDevice::Write16(uint32 addr, uint32 data) { + gMPU->AddCycle(9); // Inside/Out p.135 uint32 offset = addr - devaddr; *(uint16 *)&mem[offset] = data; return 0;