--- nono/vm/console.cpp 2026/04/29 17:05:32 1.1 +++ nono/vm/console.cpp 2026/04/29 17:05:45 1.1.1.3 @@ -42,6 +42,7 @@ ConsoleDevice::ConsoleDevice() screen.resize(width * height); dirty.resize(height); pending.resize(height); + SetPalette(false); } // デストラクタ @@ -57,10 +58,6 @@ ConsoleDevice::~ConsoleDevice() bool ConsoleDevice::Init() { - if (inherited::Init() == false) { - return false; - } - renderer = GetRenderer(); // ログファイル。 @@ -81,12 +78,13 @@ ConsoleDevice::Init() } // COM ドライバを接続。 -// NULL を指定すると解除。 // (HostCOM の cons ドライバが呼ぶ) void ConsoleDevice::Attach(COMDriver *comdriver_) { comdriver = comdriver_; + + SetPalette((comdriver != NULL)); } void @@ -101,9 +99,7 @@ ConsoleDevice::ResetHard(bool poweron) Locate(0, 0); } - if (comdriver) { - scheduler->RestartEvent(vsync_event); - } + scheduler->RestartEvent(vsync_event); ResetTerminal(); } @@ -135,6 +131,27 @@ ConsoleDevice::VSyncCallback(Event& ev) scheduler->StartEvent(ev); } +// パレットの状態を変更する。 +void +ConsoleDevice::SetPalette(bool console_is_active) +{ + if (console_is_active) { + palette[0] = UD_LIGHT_GREY; // BG + palette[1] = UD_BLACK; // FG + } else { + palette[0] = UD_LIGHT_GREY; // BG + palette[1] = UD_GREY; // FG + } + // 反転色。 + palette[2] = palette[0]; + + // 画面に即反映させる。 + { + std::unique_lock lock(mtx); + std::fill(pending.begin(), pending.end(), true); + } +} + // 端末の状態をリセットする。 // (画面のクリアはここではしない?) void @@ -963,10 +980,6 @@ ConsoleDevice::SetAttr(uint32 new_attr) bool ConsoleDevice::Render(BitmapRGBX& dst) { - if (comdriver == NULL) { - return false; - } - bool updated = false; // フチも含めて再描画。 @@ -1302,14 +1315,6 @@ ConsoleDevice::Render(BitmapRGBX& dst) B(00010000), }; -// パレット。 -// [0] からだと通常色、[1] からだと反転色になる。 -/*static*/ const Color ConsoleDevice::palette[3] = { - UD_LIGHT_GREY, // BG - UD_BLACK, // FG - UD_LIGHT_GREY, // BG -}; - // // 入力担当デバイス @@ -1329,7 +1334,7 @@ ConsoleKeyboard::~ConsoleKeyboard() // COM ドライバを接続。 // (HostCOM の cons ドライバが呼ぶ) void -ConsoleKeyboard::Attach(COMDriverCons *comdriver_) +ConsoleKeyboard::Attach(COMDriverConsole *comdriver_) { comdriver = comdriver_; }