--- nono/vm/mfp.h 2026/04/29 17:05:10 1.1.1.11 +++ nono/vm/mfp.h 2026/04/29 17:05:25 1.1.1.14 @@ -15,6 +15,9 @@ #include "monitor.h" #include +class InterruptDevice; +class X68030Keyboard; + struct MFP { static const int GPIP = 0; // $E88001 @@ -109,14 +112,12 @@ struct MFP // --- --- --- RST BC3 BC2 BC1 BC0 : TBCR // --- CC2 CC1 CC0 --- DC2 DC1 DC0 : TCDCR - // tdr はカウンタの現在値。 - uint8 tdr[4]; + // tdr はカウンタの現在値 (1-256)。 + // カウンタが 1 から 0 になるタイミングで next_tdr を代入する。 + uint32 tdr[4]; - // initial_tdr はカウントダウン開始時点での TxDR の値。 - // カウンタが 1 から 0 になるタイミングで tdr の値をリロードする。 - // tdr に $00 を書き込むと 256 カウントになるため、 - // initial_tdr は 1..256 の値をとる。 - uint initial_tdr[4]; + // next_tdr は次回の TxDR のリロード値 (1-256)。 + uint32 next_tdr[4]; uint8 scr; @@ -189,12 +190,13 @@ class MFPDevice : public IODevice public: MFPDevice(); - virtual ~MFPDevice() override; + ~MFPDevice() override; + bool Init() override; void ResetHard(bool poweron) override; // 割り込みアクノリッジ - int InterruptAcknowledge(); + busdata InterruptAcknowledge(); // HSync 入力 void SetHSync(bool hsync); @@ -202,6 +204,12 @@ class MFPDevice : public IODevice // VDisp 入力 void SetVDisp(bool vdisp); + // 電源ボタン状態入力 + void SetPowSW(bool powsw); + + // ALARM 信号入力 + void SetAlarmOut(bool alarm); + // KEY CTRL 状態を設定する void SetKeyCtrl(bool ctrl); @@ -214,11 +222,12 @@ class MFPDevice : public IODevice protected: // BusIO インタフェース static const uint32 NPORT = 0x20; - uint64 Read(uint32 offset); - uint64 Write(uint32 offset, uint32 data); - uint64 Peek(uint32 offset); + busdata Read(uint32 offset); + busdata Write(uint32 offset, uint32 data); + busdata Peek(uint32 offset); private: + void SetIER(uint8& ier, uint8& ipr, uint32 data); void SetTCR(int ch, uint32 data); uint8 GetTDR(int ch) const; void SetTDR(int ch, uint32 data); @@ -254,6 +263,9 @@ class MFPDevice : public IODevice Monitor monitor { this }; + InterruptDevice *interrupt {}; + X68030Keyboard *keyboard {}; + static const char *intrname[]; static const char *gpipname[]; static const int prescale_ns[8]; @@ -261,4 +273,6 @@ class MFPDevice : public IODevice static const int timer_vector[4]; }; -extern MFPDevice *gMFP; +static inline MFPDevice *GetMFPDevice() { + return Object::GetObject(OBJ_MFP); +}