--- nono/vm/scc.cpp 2026/04/29 17:05:17 1.1.1.12 +++ nono/vm/scc.cpp 2026/04/29 17:05:24 1.1.1.13 @@ -14,6 +14,10 @@ #include "keyboard.h" #include "mpu.h" +// InsideOut p.135 +static const busdata read_wait = busdata::Wait(41 * 40_nsec); +static const busdata write_wait = busdata::Wait(49 * 40_nsec); + // コンストラクタ SCCDevice::SCCDevice() : inherited() @@ -165,6 +169,8 @@ SCCDevice::ResetChannel(MPSCCChan& chan) chan.wr15 = 0xf8; // RR0 b0,1=%0、b2,6=%1 + chan.rxlen = 0; + chan.txlen = 0; chan.tx_underrun = true; // RR1 b1,2=%1、b3-7=%0 @@ -184,12 +190,10 @@ SCCDevice::ResetChannel(MPSCCChan& chan) ResetChannelCommon(chan); } -uint64 +busdata SCCDevice::Read(uint32 offset) { - uint64 data; - - mpu->AddCycle(41); // InsideOut p.135 + busdata data; switch (offset) { case 0: // $E98001 @@ -207,14 +211,14 @@ SCCDevice::Read(uint32 offset) default: VMPANIC("corrupted offset=%d", offset); } + + data |= read_wait; return data; } -uint64 +busdata SCCDevice::Write(uint32 offset, uint32 data) { - mpu->AddCycle(49); // InsideOut p.135 - switch (offset) { case 0: // $E98001 WriteCtrl(mpscc.chan[1], data); @@ -231,10 +235,11 @@ SCCDevice::Write(uint32 offset, uint32 d default: VMPANIC("corrupted offset=%d", offset); } - return 0; + + return write_wait; } -uint64 +busdata SCCDevice::Peek(uint32 offset) { uint64 data; @@ -1016,7 +1021,7 @@ SCCDevice::SetXC(MPSCCChan& chan) } // 割り込みアクノリッジ -int +busdata SCCDevice::InterruptAcknowledge() { return GetSR2B();