--- nono/vm/mfp.cpp 2026/04/29 17:04:52 1.1.1.9 +++ nono/vm/mfp.cpp 2026/04/29 17:04:59 1.1.1.11 @@ -14,14 +14,12 @@ std::unique_ptr gMFP; // コンストラクタ MFPDevice::MFPDevice() + : inherited("MFP") { - logname = "mfp"; - devname = "MFP"; devaddr = baseaddr; devlen = 0x2000; - monitor_size = nnSize(77, 26); - for (int ch = 0; ch < countof(event); ch++) { + for (int ch = 0; ch < event.size(); ch++) { event[ch].dev = this; event[ch].func = (DeviceCallback_t)&MFPDevice::TimerCallback; event[ch].code = ch; @@ -29,10 +27,13 @@ MFPDevice::MFPDevice() } // キーボード周りは x68kkbd.cpp のコメント参照 - key_event.dev = this; key_event.func = (DeviceCallback_t)&MFPDevice::KeyCallback; key_event.time = 3750_usec; key_event.SetName("MFP USART"); + + monitor.func = (MonitorCallback_t)&MFPDevice::MonitorUpdate; + monitor.SetSize(77, 26); + monitor.Regist(ID_MONITOR_MFP); } // デストラクタ @@ -62,8 +63,8 @@ MFPDevice::ResetHard() mfp.tsr = MFP::TSR_BE; // All timers are stopped. - for (int ch = 0; ch < countof(event); ch++) { - event[ch].Stop(); + for (auto& ev : event) { + ev.Stop(); } key_event.Stop(); @@ -374,12 +375,12 @@ MFPDevice::Peek(uint32 offset) } void -MFPDevice::MonitorUpdate(TextScreen& monitor) +MFPDevice::MonitorUpdate(Monitor *, TextScreen& screen) { int x; int y; - monitor.Clear(); + screen.Clear(); // 0 1 2 3 4 5 6 // 01234567890123456789012345678901234567890123456789012345678901234567890 @@ -393,53 +394,53 @@ MFPDevice::MonitorUpdate(TextScreen& mon // 1列目(GPIP 関連と VR) x = 0; y = 0; - monitor.Print(x, y++, "$%06x(GPIP):$%02x", A(MFP::GPIP), mfp.gpip); - monitor.Print(x, y++, "$%06x(AER): $%02x", A(MFP::AER), mfp.aer); - monitor.Print(x, y++, "$%06x(DDR): $%02x", A(MFP::DDR), mfp.ddr); - monitor.Print(x, y++, "$%06x(VR): $%02x", A(MFP::VR), mfp.GetVR()); + screen.Print(x, y++, "$%06x(GPIP):$%02x", A(MFP::GPIP), mfp.gpip); + screen.Print(x, y++, "$%06x(AER): $%02x", A(MFP::AER), mfp.aer); + screen.Print(x, y++, "$%06x(DDR): $%02x", A(MFP::DDR), mfp.ddr); + screen.Print(x, y++, "$%06x(VR): $%02x", A(MFP::VR), mfp.GetVR()); // 2列目(割り込み関連) x = 20; y = 0; - monitor.Print(x, y++, "$%06x(IERA):$%02x", A(MFP::IERA), mfp.ier.a); - monitor.Print(x, y++, "$%06x(IERB):$%02x", A(MFP::IERB), mfp.ier.b); - monitor.Print(x, y++, "$%06x(IPRA):$%02x", A(MFP::IPRA), mfp.ipr.a); - monitor.Print(x, y++, "$%06x(IPRB):$%02x", A(MFP::IPRB), mfp.ipr.b); - monitor.Print(x, y++, "$%06x(ISRA):$%02x", A(MFP::ISRA), mfp.isr.a); - monitor.Print(x, y++, "$%06x(ISRB):$%02x", A(MFP::ISRB), mfp.isr.b); - monitor.Print(x, y++, "$%06x(IMRA):$%02x", A(MFP::IMRA), mfp.imr.a); - monitor.Print(x, y++, "$%06x(IMRB):$%02x", A(MFP::IMRB), mfp.imr.b); + screen.Print(x, y++, "$%06x(IERA):$%02x", A(MFP::IERA), mfp.ier.a); + screen.Print(x, y++, "$%06x(IERB):$%02x", A(MFP::IERB), mfp.ier.b); + screen.Print(x, y++, "$%06x(IPRA):$%02x", A(MFP::IPRA), mfp.ipr.a); + screen.Print(x, y++, "$%06x(IPRB):$%02x", A(MFP::IPRB), mfp.ipr.b); + screen.Print(x, y++, "$%06x(ISRA):$%02x", A(MFP::ISRA), mfp.isr.a); + screen.Print(x, y++, "$%06x(ISRB):$%02x", A(MFP::ISRB), mfp.isr.b); + screen.Print(x, y++, "$%06x(IMRA):$%02x", A(MFP::IMRA), mfp.imr.a); + screen.Print(x, y++, "$%06x(IMRB):$%02x", A(MFP::IMRB), mfp.imr.b); // 3列目(タイマー関連) x = 40; y = 0; - monitor.Print(x, y++, "$%06x(TACR): $%02x", A(MFP::TACR), mfp.tcr[0]); - monitor.Print(x, y++, "$%06x(TBCR): $%02x", A(MFP::TBCR), mfp.tcr[1]); - monitor.Print(x, y++, "$%06x(TCDCR):$%02x", A(MFP::TCDCR), + screen.Print(x, y++, "$%06x(TACR): $%02x", A(MFP::TACR), mfp.tcr[0]); + screen.Print(x, y++, "$%06x(TBCR): $%02x", A(MFP::TBCR), mfp.tcr[1]); + screen.Print(x, y++, "$%06x(TCDCR):$%02x", A(MFP::TCDCR), (mfp.tcr[2] << 4) | mfp.tcr[3]); - monitor.Print(x, y++, "$%06x(TADR): $%02x", A(MFP::TADR), GetTDR(0)); - monitor.Print(x, y++, "$%06x(TBDR): $%02x", A(MFP::TBDR), GetTDR(1)); - monitor.Print(x, y++, "$%06x(TCDR): $%02x", A(MFP::TCDR), GetTDR(2)); - monitor.Print(x, y++, "$%06x(TDDR): $%02x", A(MFP::TDDR), GetTDR(3)); + screen.Print(x, y++, "$%06x(TADR): $%02x", A(MFP::TADR), GetTDR(0)); + screen.Print(x, y++, "$%06x(TBDR): $%02x", A(MFP::TBDR), GetTDR(1)); + screen.Print(x, y++, "$%06x(TCDR): $%02x", A(MFP::TCDR), GetTDR(2)); + screen.Print(x, y++, "$%06x(TDDR): $%02x", A(MFP::TDDR), GetTDR(3)); // 4列目(USART 関連) x = 61; y = 0; - monitor.Print(x, y++, "$%06x(SCR):$%02x", A(MFP::SCR), mfp.scr); - monitor.Print(x, y++, "$%06x(UCR):$%02x", A(MFP::UCR), mfp.ucr); - monitor.Print(x, y++, "$%06x(RSR):$%02x", A(MFP::RSR), mfp.rsr); - monitor.Print(x, y++, "$%06x(TSR):$%02x", A(MFP::TSR), mfp.tsr); - monitor.Print(x, y, "$%06x(UDR):", A(MFP::UDR)); + screen.Print(x, y++, "$%06x(SCR):$%02x", A(MFP::SCR), mfp.scr); + screen.Print(x, y++, "$%06x(UCR):$%02x", A(MFP::UCR), mfp.ucr); + screen.Print(x, y++, "$%06x(RSR):$%02x", A(MFP::RSR), mfp.rsr); + screen.Print(x, y++, "$%06x(TSR):$%02x", A(MFP::TSR), mfp.tsr); + screen.Print(x, y, "$%06x(UDR):", A(MFP::UDR)); if ((int16)mfp.udr >= 0) { - monitor.Print(x + 13, y, "$%02x", mfp.udr); + screen.Print(x + 13, y, "$%02x", mfp.udr); } else { - monitor.Print(x + 13, y, "---"); + screen.Print(x + 13, y, "---"); } // 割り込み関連 y = 9; - monitor.Print(0, y++, " %-6s %-4s %-4s %-4s", + screen.Print(0, y++, " %-6s %-4s %-4s %-4s", "IER", "IMR", "IPR", "ISR"); for (int i = 15; i >= 0; i--, y++) { uint16 mask = (1 << i); - monitor.Print(0, y, "%c%d:%-12s %-6s %-4s %-4s %-4s", + screen.Print(0, y, "%c%d:%-12s %-6s %-4s %-4s %-4s", i >= 8 ? 'A' : 'B', (i % 8), intrname[i], @@ -452,31 +453,31 @@ MFPDevice::MonitorUpdate(TextScreen& mon // タイマー関連 x = 39; y = 9; - monitor.Print(x, y++, " Mode TDR Ini"); + screen.Print(x, y++, " Mode TDR Ini"); for (int ch = 0; ch < 4; ch++) { - monitor.Print(x, y, "Timer-%c", ch + 'A'); + screen.Print(x, y, "Timer-%c", ch + 'A'); if (mfp.tcr[ch] == 0) { - monitor.Print(x + 8, y, "Stopped"); + screen.Print(x + 8, y, "Stopped"); } else if (mfp.tcr[ch] == 8) { - monitor.Print(x + 8, y, "Event"); + screen.Print(x + 8, y, "Event"); } else if (mfp.tcr[ch] > 8) { - monitor.Print(x + 8, y, "Pulse(%s)", prescale_str[mfp.tcr[ch] - 8]); + screen.Print(x + 8, y, "Pulse(%s)", prescale_str[mfp.tcr[ch] - 8]); } else { - monitor.Print(x + 8, y, "Delay(%s)", prescale_str[mfp.tcr[ch]]); + screen.Print(x + 8, y, "Delay(%s)", prescale_str[mfp.tcr[ch]]); } - monitor.Print(x + 19, y, "%3d", GetTDR(ch)); - monitor.Print(x + 23, y, "%3d", mfp.initial_tdr[ch]); + screen.Print(x + 19, y, "%3d", GetTDR(ch)); + screen.Print(x + 23, y, "%3d", mfp.initial_tdr[ch]); y++; } // GPIP 関連 x = 39; y = 9 + 8; - monitor.Puts(x, y++, " GPIP AER DDR"); + screen.Puts(x, y++, " GPIP AER DDR"); for (int i = 7; i >= 0; i--, y++) { uint mask = (1 << i); - monitor.Print(x, y, "b%d %-6s %d %d %s", i, gpipname[i], + screen.Print(x, y, "b%d %-6s %d %d %s", i, gpipname[i], (mfp.gpip & mask) ? 1 : 0, (mfp.aer & mask) ? 1 : 0, (mfp.ddr & mask) ? "OUT" : "IN");