--- nono/vm/videoctlr.cpp 2026/04/29 17:05:29 1.1.1.10 +++ nono/vm/videoctlr.cpp 2026/04/29 17:05:37 1.1.1.12 @@ -16,6 +16,7 @@ // 以上の 4KB をミラー。 #include "videoctlr.h" +#include "mainapp.h" #include "planevram.h" #include "renderer.h" #include "scheduler.h" @@ -50,10 +51,6 @@ VideoCtlrDevice::~VideoCtlrDevice() bool VideoCtlrDevice::Init() { - if (inherited::Init() == false) { - return false; - } - planevram = GetPlaneVRAMDevice(); renderer = GetRenderer(); @@ -302,9 +299,6 @@ VideoCtlrDevice::ContrastCallback(Event& if (new_contrast != running_contrast) { running_contrast = new_contrast; - - // 強制再描画をレンダラに通知 - renderer->Invalidate2(); } scheduler->RestartEvent(ev); @@ -332,8 +326,9 @@ VideoCtlrDevice::MakePalette() hostcolor[i].b = B; } - // パレット変更が起きたことをレンダラに通知 - renderer->Invalidate2(); + // パレット変更が起きたことをテキストレンダラに通知。 + // この後ここでグラフィックレンダラにも通知。 + planevram->Invalidate2(); // UI にも通知 UIMessage::Post(UIMessage::PALETTE); @@ -353,18 +348,41 @@ VideoCtlrDevice::GetIntPalette() const return ipal; } +// 画面の作成。CRTC から VDisp のタイミングで呼ばれる。 +// Renderer に作画指示を出すかどうかを決める。 +void +VideoCtlrDevice::VDisp() +{ + bool update_needed = false; + + // 今はテキスト画面しかない。 + if (planevram->Snap()) { + update_needed = true; + } + + // コントラストが変わっていても再描画。 + if (__predict_false(rendering_contrast != running_contrast)) { + pending_contrast = running_contrast; + update_needed = true; + } + + if (update_needed) { + renderer->NotifyRender(); + } +} + // 画面合成。 // レンダリングスレッドから呼ばれる。 bool -VideoCtlrDevice::Render(BitmapRGBX& dst, const ModifyInfo& modify) +VideoCtlrDevice::Render(BitmapRGBX& dst) { // 今はテキスト画面しかない。 - bool updated = planevram->Render(textbmp, modify); + bool updated = planevram->Render(textbmp); // 最後にコントラスト適用。 - // アトミックじゃなくても大丈夫のはず。 - if (__predict_false(rendering_contrast != running_contrast)) { - rendering_contrast = running_contrast; + int contrast = pending_contrast.exchange(rendering_contrast); + if (contrast != rendering_contrast) { + rendering_contrast = contrast; updated = true; } if (__predict_false(updated)) {