--- nono/vm/planevram.cpp 2026/04/29 17:05:33 1.1.1.5 +++ nono/vm/planevram.cpp 2026/04/29 17:05:42 1.1.1.6 @@ -32,30 +32,14 @@ PlaneVRAMDevice::PlaneVRAMDevice(int wid dirty.line.resize(height_); pending.line.resize(height_); - - // レンダリング時に使うテーブルを事前に計算。 - InitDeptable(); } -// デストラクタ -PlaneVRAMDevice::~PlaneVRAMDevice() +// 初期化 +bool +PlaneVRAMDevice::Init() { -} - -// リセット -void -PlaneVRAMDevice::ResetHard(bool poweron) -{ - // XXX ここ? - Invalidate(); -} - -// レンダリング時に使うテーブルを事前に計算。 -void -PlaneVRAMDevice::InitDeptable() -{ - deptable.reset(new uint64[256]); - + // レンダリング時に使うテーブルを事前に計算。 + // // %abcdefgh の8ビットを // リトルエンディアンホストでは // %0000000h'0000000g'0000000f'0000000e'0000000d'0000000c'0000000b'0000000a @@ -63,7 +47,14 @@ PlaneVRAMDevice::InitDeptable() // %0000000a'0000000b'0000000c'0000000d'0000000e'0000000f'0000000g'0000000h // の64ビットに伸張する。 // (8ビットを各バイトの最下位ビットに対応させる) - for (uint i = 0; i < 256; i++) { + constexpr uint num = 256; + deptable.reset(new(std::nothrow) uint64[num]); + if ((bool)deptable == false) { + warnx("Cannot allocate %zu bytes at %s", + sizeof(uint64) * num, __method__); + return false; + } + for (uint i = 0; i < num; i++) { uint64 res = 0; for (int bit = 0; bit < 8; bit++) { int n = bit * 8; @@ -74,6 +65,21 @@ PlaneVRAMDevice::InitDeptable() } deptable[i] = res; } + + return true; +} + +// デストラクタ +PlaneVRAMDevice::~PlaneVRAMDevice() +{ +} + +// リセット +void +PlaneVRAMDevice::ResetHard(bool poweron) +{ + // XXX ここ? + Invalidate(); } // 全画面の更新フラグを立てる