--- nono/vm/scc.cpp 2026/04/29 17:05:10 1.1.1.10 +++ nono/vm/scc.cpp 2026/04/29 17:05:14 1.1.1.11 @@ -70,6 +70,8 @@ SCCDevice::ResetHard(bool poweron) // XXX Reset for (auto& chan : mpscc.chan) { + // XC 設定は ResetChannel() の前に必要。 + SetXC(chan); ResetChannel(chan); // WR10 b5,6 = %0 @@ -93,6 +95,8 @@ SCCDevice::ResetHard(bool poweron) void SCCDevice::ResetChannel(MPSCCChan& chan) { + uint8 val; + // WR0 b0-7 = %0 chan.crc_cmd = 0; chan.cmd = 0; @@ -111,11 +115,12 @@ SCCDevice::ResetChannel(MPSCCChan& chan) // WR4 b2 = %1 // b2,3 が StopBits 設定だが b2 だけ %1 にするらしい…。 // 少なくとも非同期モードにしときたいということだろうか。 - chan.cr4 |= 0x04; + val = GetCR4(chan); + SetCR4(chan, val | 0x04); // WR5 b1,2,3,4,7 = %0 - chan.cr5 &= 0x61; - chan.tx_enable = false; + val = GetCR5(chan); + SetCR5(chan, val & 0x61); // WR9 b5 = %0 (未実装ビット) @@ -167,7 +172,7 @@ SCCDevice::Read(uint32 offset) data = ReadCtrl(mpscc.chan[0]); break; case 3: // $E98007 - putlog(0, "ChA データレジスタ読み込み (未実装)"); + putlog(0, "Read ChA Data Register (NOT IMPLEMENTED)"); data = ReadData(mpscc.chan[0]); break; default: @@ -296,13 +301,14 @@ SCCDevice::ReadCtrl(MPSCCChan& chan) case 14: case 15: case 11: - putlog(0, "ReadCtrl 未実装 %d", chan.ptr); + putlog(0, "ReadCtrl %d (NOT IMPLEMENTED)", chan.ptr); data = 0xff; break; default: __unreachable(); } + chan.ptr = 0; return data; } @@ -417,7 +423,6 @@ SCCDevice::PeekCtrl(const MPSCCChan& cha case 14: case 15: case 11: - putlog(0, "PeekCtrl 未実装 %d", chan.ptr); data = 0xff; break; @@ -533,7 +538,8 @@ SCCDevice::WriteWR0(MPSCCChan& chan, uin if (chan.crc_cmd != 0) { // CRC は非同期モードでは不要のはず - putlog(3, "%s CRC リセット未実装 %d", WRName(chan, 0), chan.crc_cmd); + putlog(3, "%s CRC Reset %d (NOT IMPLEMENTED)", + WRName(chan, 0), chan.crc_cmd); } if (chan.cmd == 0 || chan.cmd == 1) { @@ -598,7 +604,11 @@ SCCDevice::WriteWR2(uint32 data) void SCCDevice::WriteWR5(MPSCCChan& chan, uint32 data) { - bool rts = bit_falling(chan.cr5, data, MPSCC::WR5_nRTS); + // ~RTS 端子の立ち下がりでマウスに送信要求。 + // ~RTS 端子の立ち下がりは nRTS ビットでは立ち上がりになる。 + bool old_nRTS = chan.nRTS; + bool new_nRTS = (data & MPSCC::WR5_nRTS); + bool rts = (old_nRTS == false && new_nRTS); inherited::WriteCR5(chan, data); @@ -654,14 +664,14 @@ SCCDevice::WriteWR9(uint32 data) void SCCDevice::WriteWR10(MPSCCChan& chan, uint32 data) { - putlog(2, "%s <- $%02x (未実装)", WRName(chan), data); + putlog(2, "%s <- $%02x (NOT IMPLEMENTED)", WRName(chan), data); chan.wr10 = data; } void SCCDevice::WriteWR11(MPSCCChan& chan, uint32 data) { - putlog(2, "%s <- $%02x (未実装)", WRName(chan), data); + putlog(2, "%s <- $%02x (NOT IMPLEMENTED)", WRName(chan), data); chan.wr11 = data; } @@ -684,14 +694,14 @@ SCCDevice::WriteWR13(MPSCCChan& chan, ui void SCCDevice::WriteWR14(MPSCCChan& chan, uint32 data) { - putlog(2, "%s <- $%02x (未実装)", WRName(chan), data); + putlog(2, "%s <- $%02x (NOT IMPLEMENTED)", WRName(chan), data); chan.wr14 = data; } void SCCDevice::WriteWR15(MPSCCChan& chan, uint32 data) { - putlog(2, "%s <- $%02x (未実装)", WRName(chan), data); + putlog(2, "%s <- $%02x (NOT IMPLEMENTED)", WRName(chan), data); chan.wr15 = data; } @@ -756,6 +766,8 @@ SCCDevice::MonitorUpdateCh(TextScreen& s uint wr3; uint wr4; uint wr5; + uint wr6; + uint wr7; uint wr10; uint wr11; uint wr14; @@ -774,8 +786,10 @@ SCCDevice::MonitorUpdateCh(TextScreen& s ptr = chan.ptr; wr1 = GetWR1(chan); wr3 = GetCR3(chan); - wr4 = chan.cr4; + wr4 = GetCR4(chan); wr5 = GetCR5(chan); + wr6 = chan.cr6; + wr7 = chan.cr7; wr10 = chan.wr10; wr11 = chan.wr11; tc = chan.tc; @@ -792,6 +806,7 @@ SCCDevice::MonitorUpdateCh(TextScreen& s // Channel A: Serial Console DataAddr $000000 // WR0: $xx CRC=x CMD=x PTR=x CtrlAddr $000000 // WR1: $xx WE 0 WR RXInt=x 0 TXEn ESEn + // WR13/WR12: $001f (196000bps) WR7/WR6:$1234 x = xbase; y = ybase; @@ -805,7 +820,8 @@ SCCDevice::MonitorUpdateCh(TextScreen& s screen.Print(x, y++, "WR11:$%02x", wr11); screen.Print(x, y++, "WR14:$%02x", wr14); screen.Print(x, y++, "WR15:$%02x", wr15); - screen.Print(x, y++, "WR12/WR13:$%04x", tc); + screen.Print(x, y, "WR13/WR12:$%04x (%.1fbps)", tc, chan.baudrate); + screen.Print(x + 35, y++, "WR7/WR6:$%02x%02x", wr7, wr6); screen.Print(x, y++, "RR0: $%02x", rr0); screen.Print(x, y++, "RR1: $%02x", rr1); screen.Print(x, y++, "RR10:$%02x", rr10); @@ -944,14 +960,14 @@ SCCDevice::MonitorUpdateCh(TextScreen& s y++; // 右列 - y = ybase; + y = ybase + 1; x = xbase + 51; - screen.Print(x, y++, "DataAddr $%06x", chan.dataaddr); - screen.Print(x, y++, "CtrlAddr $%06x", chan.ctrladdr); + screen.Print(x, y++, "DataAddr: $%06x", chan.dataaddr); + screen.Print(x, y++, "CtrlAddr: $%06x", chan.ctrladdr); y++; - screen.Print(x, y++, "Param %12s", GetParamStr(chan).c_str()); - screen.Print(x, y++, "Rx Bits/Frame %2d", chan.rxbits); - screen.Print(x, y++, "Tx Bits/Frame %2d", chan.txbits); + screen.Print(x, y++, "Param: %12s", GetParamStr(chan).c_str()); + screen.Print(x, y++, "Rx Bits/Frame: %2d", chan.rxframebits); + screen.Print(x, y++, "Tx Bits/Frame: %2d", chan.txframebits); } // 内部の送信データクロックの設定 @@ -960,7 +976,8 @@ SCCDevice::SetXC(MPSCCChan& chan) { // 5MHz = 200nsec // 12bit = 2.4usec - xc12_ns = (2 * (chan.tc + 2)) * 2.4_usec; + chan.xc12_ns = (2 * (chan.tc + 2)) * 2.4_usec; + ChangeBaudrate(chan); } // 割り込みアクノリッジ