--- nono/vm/mfp.cpp 2026/04/29 17:05:50 1.1.1.20 +++ nono/vm/mfp.cpp 2026/04/29 17:06:00 1.1.1.21 @@ -104,8 +104,8 @@ #include "event.h" #include "interrupt.h" #include "keyboard.h" +#include "mainbus.h" #include "monitor.h" -#include "mpu.h" #include "scheduler.h" #include "syncer.h" #include "x68kkbd.h" @@ -119,7 +119,7 @@ MFPDevice::MFPDevice() : inherited(OBJ_MFP) { monitor = gMonitorManager->Regist(ID_MONITOR_MFP, this); - monitor->func = ToMonitorCallback(&MFPDevice::MonitorUpdate); + monitor->SetCallback(&MFPDevice::MonitorScreen); monitor->SetSize(77, 26); } @@ -310,7 +310,8 @@ MFPDevice::ReadPort(uint32 offset) } else if (offset < MFP::RegMax) { putlogn("%s -> $%02x", regname[offset], data.Data()); } else { - putlogn("$%06x -> $%02x", mpu->GetPaddr(), data.Data()); + putlogn("$%06x -> $%02x", + GetMainbusDevice()->GetPaddr(), data.Data()); } } data |= wait; @@ -536,7 +537,7 @@ MFPDevice::PokePort(uint32 offset, uint3 } void -MFPDevice::MonitorUpdate(Monitor *, TextScreen& screen) +MFPDevice::MonitorScreen(Monitor *, TextScreen& screen) { MFP mfp_; std::array tdr_; @@ -687,7 +688,7 @@ MFPDevice::gpipname[] = { // TxCR の設定値から分周期間というかメインカウンタ1回分の時間を返す /*static*/ const uint64 -MFPDevice::prescale_ns[8] = { +MFPDevice::prescale_tsec[8] = { 0, 1000_nsec, // /4 2500_nsec, // /10 @@ -778,7 +779,7 @@ MFPDevice::SetTCR(int ch, uint32 data) // ここで TDR を確定させる。 // タイマー動作中の TDR の参照はイベント開始時刻から求めていたが // イベントを停止すると求められなくなるので、停止前に求めておく。 - uint64 period = prescale_ns[prev]; + uint64 period = prescale_tsec[prev]; uint64 now = scheduler->GetVirtTime(); mfp.timer[ch].tdr = timer.GetCounter(now, period); @@ -798,7 +799,7 @@ MFPDevice::SetTCR(int ch, uint32 data) // タイマー開始時は TDR はリロードしない。 // 割り込みを上げる必要がある時だけイベントを使う。 - uint64 period = prescale_ns[data]; + uint64 period = prescale_tsec[data]; uint64 now = scheduler->GetVirtTime(); timer.start = now; if (IsTimerIntrEnable(ch)) { @@ -819,11 +820,10 @@ MFPDevice::SetTCR(int ch, uint32 data) event[ch]->SetName(string_format("MFP Timer-%c FreeRun", ch + 'A')); } - putlog(1, "Timer-%c Start Delay mode(%u x %u.%uusec)", + putlog(1, "Timer-%c Start Delay mode(%u x %.1fusec)", ch + 'A', timer.tdr, - (uint)period / 1000, - (uint)(period / 100) % 10); + (double)period / 1_usec); return; } else if (data == 8) { @@ -858,7 +858,7 @@ MFPDevice::GetTDR(int ch) const // ディレイモード動作中なら現在値は保持していないので、算出する。 // XXX sync_rt == true で割り込み有効にしているタイマーの // TDR を読み出しても割り込みと整合しないがもう仕方ない。 - uint64 period = prescale_ns[timer.tcr]; + uint64 period = prescale_tsec[timer.tcr]; uint64 now = scheduler->GetVirtTime(); return timer.GetCounter(now, period); @@ -914,7 +914,7 @@ MFPDevice::TimerCallback(Event *ev) timer.tdr = timer.next_tdr; timer.start = 0; // TDR (のリロード値) が変わったのでタイマー周りも再設定。 - uint64 period = prescale_ns[timer.tcr]; + uint64 period = prescale_tsec[timer.tcr]; ev->time = period * timer.tdr; if (sync_rt) { rt_period[ch] = ev->time; @@ -958,7 +958,7 @@ MFPDevice::RestartTimerEvent(int ch) assert(timer.start != 0); uint64 now = scheduler->GetVirtTime(); - uint64 period = prescale_ns[timer.tcr]; + uint64 period = prescale_tsec[timer.tcr]; uint64 timeout = period * timer.tdr; event[ch]->time = timeout - ((now - timer.start) % timeout); scheduler->RestartEvent(event[ch]);