--- nono/vm/sysport.cpp 2026/04/29 17:04:36 1.1.1.3 +++ nono/vm/sysport.cpp 2026/04/29 17:04:50 1.1.1.5 @@ -6,8 +6,12 @@ #include "sysport.h" #include "mfp.h" +#include "ram.h" +#include "romimg_x68k.h" #include "sram.h" +std::unique_ptr gSysport; + SysportDevice::SysportDevice() { logname = "sysport"; @@ -20,12 +24,19 @@ SysportDevice::~SysportDevice() { } +void +SysportDevice::ResetHard() +{ + sysport.ram_wait = 0; + sysport.rom_wait = 0; +} + uint64 -SysportDevice::Read(uint32 addr) +SysportDevice::Read(uint32 offset) { uint32 data; - switch (addr) { + switch (offset) { case SYSPORT::CONTRAST: data = 0xf0 | sysport.contrast; break; @@ -54,14 +65,14 @@ SysportDevice::Read(uint32 addr) default: __unreachable(); } - putlog(1, "$%06X -> $%02x", addr, data); + putlog(1, "$%06X -> $%02x", gMPU->GetPaddr(), data); return data; } uint64 -SysportDevice::Write(uint32 addr, uint32 data) +SysportDevice::Write(uint32 offset, uint32 data) { - switch (addr) { + switch (offset) { case SYSPORT::CONTRAST: sysport.contrast = data & 15; break; @@ -81,10 +92,22 @@ SysportDevice::Write(uint32 addr, uint32 break; case SYSPORT::WAIT: + { // 設定値で保持 sysport.rom_wait = data >> 4; sysport.ram_wait = data; + + // ROM に指示。常に設定値 + 2 でよい + gIPLROM1->SetWait(sysport.rom_wait + 2); + gIPLROM2->SetWait(sysport.rom_wait + 2); + gCGROM->SetWait(sysport.rom_wait + 2); + // RAM に指示。InsideOut p.124 + int wait = sysport.ram_wait; + if (wait > 0) + wait += 2; + gRAM->SetWait(wait); break; + } case SYSPORT::MPU: break; @@ -98,7 +121,7 @@ SysportDevice::Write(uint32 addr, uint32 break; case SYSPORT::POWEROFF: - putlog(0, "$E8E00F (POWEROFF) 未サポート書き込み %02x", data); + putlog(0, "$e8e00f (POWEROFF) 未サポート書き込み %02x", data); break; default: @@ -108,11 +131,11 @@ SysportDevice::Write(uint32 addr, uint32 } uint64 -SysportDevice::Peek(uint32 addr) +SysportDevice::Peek(uint32 offset) { uint32 data; - switch (addr) { + switch (offset) { case SYSPORT::CONTRAST: data = 0xf0 | sysport.contrast; break;