--- nono/vm/sysport.cpp 2026/04/29 17:05:20 1.1.1.11 +++ nono/vm/sysport.cpp 2026/04/29 17:05:24 1.1.1.12 @@ -16,12 +16,16 @@ #include "power.h" #include "romimg_x68k.h" #include "sram.h" +#include "videoctlr.h" #include // コンストラクタ SysportDevice::SysportDevice() : inherited(OBJ_SYSPORT) { + monitor.func = ToMonitorCallback(&SysportDevice::MonitorUpdate); + monitor.SetSize(56, 8); + monitor.Regist(ID_MONITOR_SYSPORT); } // デストラクタ @@ -44,6 +48,7 @@ SysportDevice::Init() mainram = GetMainRAMDevice(); nmi = GetNMIDevice(); sram = GetSRAMDevice(); + videoctlr = GetVideoCtlrDevice(); return true; } @@ -52,7 +57,6 @@ SysportDevice::Init() void SysportDevice::ResetHard(bool poweron) { - sysport.contrast = 0; // XXX 未調査 sysport.ram_wait = 0; sysport.rom_wait = 0; sysport.key_ctrl = false; @@ -60,14 +64,14 @@ SysportDevice::ResetHard(bool poweron) GetPowerDevice()->SetSystemPowerOn(true); } -uint64 +busdata SysportDevice::Read(uint32 offset) { uint32 data; switch (offset) { case SYSPORT::CONTRAST: - data = 0xf0 | sysport.contrast; + data = 0xf0 | videoctlr->GetContrast(); break; case SYSPORT::SCOPE3D: data = 0xff; @@ -102,12 +106,13 @@ SysportDevice::Read(uint32 offset) return data; } -uint64 +busdata SysportDevice::Write(uint32 offset, uint32 data) { switch (offset) { case SYSPORT::CONTRAST: - sysport.contrast = data & 15; + putlog(1, "$e8e001 <- $%02x", data); + videoctlr->SetContrast(data & 15); break; case SYSPORT::SCOPE3D: @@ -129,19 +134,24 @@ SysportDevice::Write(uint32 offset, uint case SYSPORT::WAIT: { - // 設定値で保持 - sysport.rom_wait = data >> 4; - sysport.ram_wait = data; - - // ROM に指示。常に設定値 + 2 でよい - iplrom1->SetWait(sysport.rom_wait + 2); - iplrom2->SetWait(sysport.rom_wait + 2); - cgrom->SetWait(sysport.rom_wait + 2); - // RAM に指示。InsideOut p.124 - int wait = sysport.ram_wait; - if (wait > 0) - wait += 2; - mainram->SetWait(wait); + uint32 rom_wait = data >> 4; + uint32 ram_wait = data & 0xf; + + // InsideOut p.124 + rom_wait += 2; + if (ram_wait > 0) { + ram_wait += 2; + } + + // ROM/RAM に指示。 + iplrom1->SetWait(rom_wait); + iplrom2->SetWait(rom_wait); + cgrom->SetWait(rom_wait); + mainram->SetWait(ram_wait); + + // ROM/RAM への指定値で保持する。 + sysport.rom_wait = rom_wait; + sysport.ram_wait = ram_wait; break; } @@ -188,14 +198,14 @@ SysportDevice::Write(uint32 offset, uint return 0; } -uint64 +busdata SysportDevice::Peek(uint32 offset) { uint32 data; switch (offset) { case SYSPORT::CONTRAST: - data = 0xf0 | sysport.contrast; + data = 0xf0 | videoctlr->GetContrast(); break; case SYSPORT::SCOPE3D: data = 0xff; @@ -228,3 +238,60 @@ SysportDevice::Peek(uint32 offset) } return data; } + +void +SysportDevice::MonitorUpdate(Monitor *, TextScreen& screen) +{ + screen.Clear(); + + static const char * const name[] = { + "Contrast", + "3D Scope", + "Image Unit", + "Keyboard Control", + "ROM/RAM Wait", + "MPU/FPU Type", + "SRAM Protect", + "PowerOff Sequence", + }; + + uint8 val[8]; + const uint32 disphex = 0x39; + for (int i = 0; i < 8; i++) { + char hex[4]; + if ((disphex & (1U << i)) != 0) { + val[i] = Peek(i); + snprintf(hex, sizeof(hex), "%02x", val[i]); + } else { + strlcpy(hex, "--", sizeof(hex)); + } + + screen.Print(0, i, "$%06x %s: #%d %-17s:", + baseaddr + 1 + i * 2, hex, i, name[i]); + } + + int x = 34; + // #0 Contrast + screen.Print(x, 0, "%2d", videoctlr->GetContrast()); + screen.Puts(x, 1, "(Not Supported)"); + screen.Puts(x, 2, "(Not Supported)"); + // #3 Keyboard + if ((val[SYSPORT::KEY] & 0x08) != 0) { + screen.Puts(x, 3, "Connected"); + } else { + screen.Puts(x, 3, "Not connected"); + } + // #4 ROM/RAM Wait + screen.Print(x, 4, "ROM %2u clk, RAM %2u clk", + sysport.rom_wait, sysport.ram_wait); + // #5 MPU/FPU Type + screen.Puts(x, 5, "MC68030 / 25MHz"); + // #6 SRAM + if (sram->IsWriteable()) { + screen.Puts(x, 6, "Writeable"); + } else { + screen.Puts(x, 6, "Protected"); + } + // #7 PowerOff + screen.Print(x, 7, "%d/3", sysport.pwoff_count); +}