--- nono/vm/lunafb.cpp 2026/04/29 17:05:28 1.1.1.6 +++ nono/vm/lunafb.cpp 2026/04/29 17:05:59 1.1.1.11 @@ -41,6 +41,7 @@ #include "bt45x.h" #include "builtinrom.h" #include "busio.h" +#include "monitor.h" #include "mpu.h" // コンストラクタ @@ -51,9 +52,9 @@ LunafbDevice::LunafbDevice() ClearAlias(); AddAlias("Lunafb"); - monitor.func = ToMonitorCallback(&LunafbDevice::MonitorUpdate); - monitor.SetSize(39, 11); - monitor.Regist(ID_MONITOR_LUNAVC); + monitor = gMonitorManager->Regist(ID_MONITOR_LUNAVC, this); + monitor->SetCallback(&LunafbDevice::MonitorScreen); + monitor->SetSize(39, 11); } // デストラクタ @@ -76,13 +77,18 @@ LunafbDevice::Init() fcset_end = fcset0base + 0x40000 * nplane; // プレーン数によってメモリを確保 - mem.reset(new uint8 [0x40000 * nplane]); + size_t memsize = 0x40000 * nplane; + mem.reset(new(std::nothrow) uint8 [memsize]); + if ((bool)mem == false) { + warnx("Could not allocate %zu bytes at %s", memsize, __method__); + return false; + } // ホストパレットを取得。 palette = &(bt45x->GetHostPalette())[0]; // XXX とりあえず RAM と同じウェイトを入れておく (未調査) - wait = busdata::Wait(1 * mpu->GetClock_nsec()); + wait = busdata::Wait(1 * mpu->GetClock_tsec()); return true; } @@ -246,7 +252,7 @@ LunafbDevice::WriteReg(busaddr addr, uin WriteRFCNT(data); } else { // BMSEL - bmsel = data & ((1 << nplane) - 1); + bmsel = data & ((1U << nplane) - 1); putlog(1, "BMSEL <- $%08x", data); } @@ -285,7 +291,7 @@ LunafbDevice::Poke1(uint32 addr, uint32 } void -LunafbDevice::MonitorUpdate(Monitor *, TextScreen& screen) +LunafbDevice::MonitorScreen(Monitor *, TextScreen& screen) { int i; @@ -299,12 +305,12 @@ LunafbDevice::MonitorUpdate(Monitor *, T // Plane#0 Sel THRU $ffffffff screen.Print(0, 0, "RFCNT: $%08x (X=%4ddot, Y=%4ddot)", rfcnt, xscroll, yscroll); - screen.Print(3, 2, "BMSEL=$%02x ROP Mask", bmsel); + screen.Print(2, 2, "BMSEL=$%02x ROP Mask", bmsel); for (i = 0; i < nplane; i++) { screen.Print(0, 3 + i, "Plane#%u %s %s $%08x", i, - (bmsel & (1 << i)) ? "Sel" : "---", + (bmsel & (1U << i)) ? "Sel" : "---", RopStr(fcset[i]), fcmask[i]); } for (; i < MAX_PLANES; i++) { @@ -332,7 +338,7 @@ LunafbDevice::SetDirty(uint32 offset) // 更新フラグはラスタ単位 uint y = (offset >> 8); - dirty[y] = 1; + dirty.line[y] = true; } // X 方向にはみ出したときに対応する仮想画面の Y 座標を返す。 @@ -385,7 +391,7 @@ LunafbDevice::WriteCommonBitmap8(uint32 uint32 offset = addr - 0xb1080000; putlog(2, "Common Plane $%08x <- $%02x", addr, data); for (int i = 0; i < nplane; i++) { - if ((bmsel & (1 << i))) { + if ((bmsel & (1U << i))) { WritePlane8(i, offset, data); } } @@ -399,7 +405,7 @@ LunafbDevice::WriteCommonBitmap16(uint32 uint32 offset = addr - 0xb1080000; putlog(2, "Common Plane $%08x <- $%04x", addr, data); for (int i = 0; i < nplane; i++) { - if ((bmsel & (1 << i))) { + if ((bmsel & (1U << i))) { WritePlane16(i, offset, data); } } @@ -413,7 +419,7 @@ LunafbDevice::WriteCommonBitmap32(uint32 uint32 offset = addr - 0xb1080000; putlog(2, "Common Plane $%08x <- $%08x", addr, data); for (int i = 0; i < nplane; i++) { - if ((bmsel & (1 << i))) { + if ((bmsel & (1U << i))) { WritePlane32(i, offset, data); } } @@ -425,7 +431,7 @@ void LunafbDevice::WriteCommonFCSet(uint rop, uint32 data) { for (int i = 0; i < nplane; i++) { - if ((bmsel & (1 << i))) { + if ((bmsel & (1U << i))) { fcset[i] = rop; fcmask[i] = data; } @@ -645,7 +651,7 @@ void LunafbDevice::EmuInitScreen() { // 同時書き込み設定 - bmsel = (1 << nplane) - 1; + bmsel = (1U << nplane) - 1; // ROP を初期化 WriteCommonFCSet(ROP::THRU, 0xffffffff);