--- nono/vm/tvram.cpp 2026/04/29 17:05:29 1.1.1.11 +++ nono/vm/tvram.cpp 2026/04/29 17:06:01 1.1.1.16 @@ -12,10 +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() @@ -25,12 +28,8 @@ TVRAMDevice::TVRAMDevice() ClearAlias(); AddAlias("TVRAM"); - uint devlen = 512 * 1024; - // プレーン数は4枚固定 nplane = NPLANE; - - mem.reset(new uint8[devlen]); } // デストラクタ @@ -46,11 +45,17 @@ TVRAMDevice::Init() return false; } - renderer = GetRenderer(); - auto videoctlr = GetVideoCtlrDevice(); + 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; } @@ -186,7 +191,7 @@ TVRAMDevice::SetDirty(uint32 offset) // 更新フラグはラスタ単位 uint y = offset >> 7; - dirty[y] = 1; + dirty.line[y] = true; } // X 方向にはみ出したときに対応する仮想画面の Y 座標を返す。 @@ -209,7 +214,7 @@ void TVRAMDevice::SetScrollY(int y) { yscroll = y; - renderer->Invalidate2(); + Invalidate2(); } // CRTC R21 での同時アクセス設定を反映する。