--- nono/vm/crtc2.cpp 2026/04/29 17:04:41 1.1.1.5 +++ nono/vm/crtc2.cpp 2026/04/29 17:05:10 1.1.1.8 @@ -4,26 +4,36 @@ // Licensed under nono-license.txt // +// +// CRTC-II (HD6445) +// + #include "crtc2.h" #include "renderer.h" +#include "scheduler.h" + +// グローバル参照用 +CRTC2Device *gCRTC2; +// コンストラクタ CRTC2Device::CRTC2Device() + : inherited("CRTC2") { - logname = "crtc2"; - devname = "CRTC2"; devaddr = 0xd1000000; - vdisp_event.dev = this; - vdisp_event.func = (DeviceCallback_t)&CRTC2Device::VDispCallback; - vdisp_event.SetName("CRTC2 V-DISP"); + vdisp_event.func = ToEventCallback(&CRTC2Device::VDispCallback); + vdisp_event.Regist("CRTC2 V-DISP"); } +// デストラクタ CRTC2Device::~CRTC2Device() { + gCRTC2 = NULL; } +// リセット void -CRTC2Device::ResetHard() +CRTC2Device::ResetHard(bool poweron) { // リセット信号で初期化されるレジスタ (他は維持) reg[30] = 0; @@ -37,15 +47,15 @@ CRTC2Device::ResetHard() // すぐに垂直帰線期間を開始する vdisp_event.time = 0; vdisp_event.code = 1; - vdisp_event.Start(); + gScheduler->RestartEvent(vdisp_event); } uint64 -CRTC2Device::Read(uint32 addr) +CRTC2Device::Read(uint32 offset) { uint32 data; - switch (addr) { + switch (offset) { case 0: // アドレスレジスタ // アドレスレジスタは書き込み専用 // XXX 何が読めるか @@ -84,9 +94,9 @@ CRTC2Device::Read(uint32 addr) } uint64 -CRTC2Device::Write(uint32 addr, uint32 data) +CRTC2Device::Write(uint32 offset, uint32 data) { - switch (addr) { + switch (offset) { case 0: // アドレスレジスタ ar = data & 0x3f; putlog(3, "アドレスレジスタ <- $%02x", ar); @@ -117,9 +127,9 @@ CRTC2Device::Write(uint32 addr, uint32 d } uint64 -CRTC2Device::Peek(uint32 addr) +CRTC2Device::Peek(uint32 offset) { - switch (addr) { + switch (offset) { case 0: // アドレスレジスタ return ar; @@ -155,5 +165,5 @@ CRTC2Device::VDispCallback(Event& ev) ev.time = 507.328_usec; // 32*Ht ev.code = 1; } - ev.Start(); + gScheduler->StartEvent(ev); }