--- nono/vm/tvram.cpp 2026/04/29 17:05:38 1.1.1.13 +++ nono/vm/tvram.cpp 2026/04/29 17:06:01 1.1.1.16 @@ -12,11 +12,13 @@ // バイトアクセス時は HLB()、ワードアクセス時は HLW() マクロを使用のこと。 #include "tvram.h" +#include "event.h" #include "textscreen.h" #include "videoctlr.h" // InsideOut p.135 -static const busdata wait = busdata::Wait(9 * 40_nsec); +/*static*/ const busdata +TVRAMDevice::wait = busdata::Wait(9 * 40_nsec); // コンストラクタ TVRAMDevice::TVRAMDevice() @@ -26,12 +28,8 @@ TVRAMDevice::TVRAMDevice() ClearAlias(); AddAlias("TVRAM"); - uint devlen = 512 * 1024; - // プレーン数は4枚固定 nplane = NPLANE; - - mem.reset(new uint8[devlen]); } // デストラクタ @@ -43,10 +41,21 @@ TVRAMDevice::~TVRAMDevice() bool TVRAMDevice::Init() { + if (inherited::Init() == false) { + return false; + } + + constexpr size_t devlen = 512 * 1024; + mem.reset(new(std::nothrow) uint8[devlen]); + if ((bool)mem == false) { + warnx("Could not allocate %zu bytes at %s", devlen, __method__); + return false; + } + videoctlr = GetVideoCtlrDevice(); - // 加工済みパレットを取得 - palette = &(videoctlr->GetHostPalette())[0]; + // 加工済みテキストパレットを取得。 + palette = videoctlr->GetHostPalettePtr(256); return true; }