--- nono/vm/mfp.h 2026/04/29 17:04:50 1.1.1.7 +++ nono/vm/mfp.h 2026/04/29 17:05:14 1.1.1.12 @@ -4,10 +4,16 @@ // Licensed under nono-license.txt // +// +// MFP (MC68901) +// + #pragma once #include "device.h" -#include "scheduler.h" +#include "event.h" +#include "monitor.h" +#include struct MFP { @@ -175,8 +181,7 @@ struct MFP uint16 udr; }; -class MFPDevice - : public IODevice +class MFPDevice : public IODevice { using inherited = IODevice; @@ -186,20 +191,28 @@ class MFPDevice MFPDevice(); virtual ~MFPDevice() override; - void ResetHard() override; - void MonitorUpdate(TextScreen&) override; + void ResetHard(bool poweron) override; // 割り込みアクノリッジ int InterruptAcknowledge(); + // HSync 入力 + void SetHSync(bool hsync); + // VDisp 入力 void SetVDisp(bool vdisp); + // 電源ボタン状態入力 + void SetPowSW(bool powsw); + + // ALARM 信号入力 + void SetAlarmOut(bool alarm); + // KEY CTRL 状態を設定する void SetKeyCtrl(bool ctrl); - // RR 線の状態を返す - bool IsRR() const; + // キーボードからの送信が可能なら true を返す。 + bool RxIsReady() const; // キーボードからデータを受信 void Rx(uint32 data); @@ -223,6 +236,12 @@ class MFPDevice void SetRSR(uint32 data); void SetUDR(uint32 data); + // RSR::BF ビットの状態を変える + void SetBF(); + void ClearBF(); + // MFP の RR 線の状態を返す + bool IsRR() const; + // イベントコールバック void TimerCallback(Event& ev); void KeyCallback(Event& ev); @@ -233,15 +252,13 @@ class MFPDevice // 割り込み信号線の状態を変える void ChangeInterrupt(); - struct MFP mfp {}; - Event event[4] {}; - Event key_event {}; + DECLARE_MONITOR_CALLBACK(MonitorUpdate); - // Receiver Ready 線の状態 - bool rr {}; + struct MFP mfp {}; + std::array event {}; + Event key_event { this }; - // システムポート#4 の KEY CTRL 状態 - bool key_ctrl {}; + Monitor monitor { this }; static const char *intrname[]; static const char *gpipname[]; @@ -250,4 +267,4 @@ class MFPDevice static const int timer_vector[4]; }; -extern std::unique_ptr gMFP; +extern MFPDevice *gMFP;